HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_Detail.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Geometry Library (C++)
7  *
8  * COMMENTS:
9  * This defines the detail class (the container for all points/primitives)
10  */
11 
12 #ifndef __GEO_Detail_h__
13 #define __GEO_Detail_h__
14 
15 #include "GEO_API.h"
16 #include "GEO_PrimList.h"
17 #include "GEO_PrimTypeCompat.h"
18 
19 #include <GA/GA_Defaults.h>
20 #include <GA/GA_Detail.h>
21 #include <GA/GA_ElementGroup.h>
22 #include <GA/GA_GBMacros.h> // for convenience of GEO_Detail.h includers
23 #include <GA/GA_Handle.h>
24 #include <GA/GA_IntrinsicManager.h>
25 #include <GA/GA_Range.h>
26 #include <GA/GA_ReuseStrategy.h>
27 #include <GA/GA_Types.h>
28 
29 #include <UT/UT_Array.h>
30 #include <UT/UT_Color.h>
31 #include <UT/UT_Matrix3.h>
32 #include <UT/UT_Matrix4.h>
33 #include <UT/UT_Vector3.h>
34 #include <UT/UT_VectorTypes.h>
35 #include <SYS/SYS_Deprecated.h>
36 #include <SYS/SYS_Inline.h>
37 #include <SYS/SYS_Types.h>
38 
39 #include <iosfwd>
40 
41 template<typename T> class UT_BoundingBoxT;
42 // IWYU pragma: private, include <UT/UT_BoundingBox.h>
44 class UT_BoundingSphere;
45 class UT_IStream;
46 class UT_MemoryCounter;
47 class UT_Options;
48 class UT_OptionsHolder;
49 template <typename T> class UT_QuaternionT;
50 class UT_Ramp;
51 class UT_String;
52 class UT_StringArray;
53 class UT_StringHolder;
54 template<typename T> class UT_StringMap;
55 class UT_StringRef;
56 class UT_XformOrder;
59 class GA_AttributeDict;
60 class GA_AttributeFilter;
62 class GA_AttributeRefMap;
63 class GA_Breakpoint;
64 class GA_BreakpointGroup;
65 class GA_EdgeGroup;
66 class GA_ElementGroup;
67 class GA_Group;
68 class GA_IntrinsicEval;
69 class GA_LoadOptions;
70 class GA_PointWrangler;
71 namespace GA_PrimCompat { class TypeMask; }
72 class GA_Primitive;
74 class GA_SaveOptions;
75 class GA_Stat;
76 class GA_VertexWrangler;
77 
79 class GEO_Delta;
80 class GEO_MirrorParms;
82 class GEO_Primitive;
83 class GEO_Rolloff;
84 class GEO_Vertex;
85 
86 template<typename T, bool B> class GA_EdgeT;
88 
89 
90 //
91 // these are the names of standard attributes
92 //
93 
94 #define GEO_STD_ATTRIB_POSITION "P"
95 #define GEO_STD_ATTRIB_NORMAL "N"
96 #define GEO_STD_ATTRIB_TEXTURE "uv"
97 #define GEO_STD_ATTRIB_VELOCITY "v"
98 #define GEO_STD_ATTRIB_ANGULAR_VELOCITY "w"
99 #define GEO_STD_ATTRIB_MATERIAL "shop_materialpath"
100 #define GEO_STD_ATTRIB_OGLSHOP "ogl_shop"
101 #define GEO_STD_ATTRIB_DIFFUSE "Cd"
102 #define GEO_STD_ATTRIB_ALPHA "Alpha"
103 #define GEO_STD_ATTRIB_COM "com"
104 #define GEO_STD_ATTRIB_DISTANCE "dist"
105 #define GEO_STD_ATTRIB_LOD "lod"
106 #define GEO_STD_ATTRIB_REST "rest"
107 #define GEO_STD_ATTRIB_MASS "mass"
108 #define GEO_STD_ATTRIB_DRAG "drag"
109 #define GEO_STD_ATTRIB_TENSION "tension"
110 #define GEO_STD_ATTRIB_SPRINGK "springk"
111 #define GEO_STD_ATTRIB_LIFE "life"
112 #define GEO_STD_ATTRIB_AGE "age"
113 #define GEO_STD_ATTRIB_DIST "dist"
114 #define GEO_STD_ATTRIB_UP "up"
115 #define GEO_STD_ATTRIB_ORIENT "orient"
116 #define GEO_STD_ATTRIB_ID "id"
117 #define GEO_STD_ATTRIB_PSCALE "pscale"
118 #define GEO_STD_ATTRIB_CREASE "creaseweight"
119 #define GEO_STD_ATTRIB_AREA "area"
120 #define GEO_STD_ATTRIB_PERIMETER "perimeter"
121 #define GEO_STD_ATTRIB_WIDTH "width"
122 #define GEO_STD_ATTRIB_LAYERMERGE "layermerge"
123 #define GEO_STD_ATTRIB_SEGS "segs"
124 #define GEO_STD_ATTRIB_DIV "div"
125 #define GEO_STD_ATTRIB_LAGE "lage"
126 #define GEO_STD_ATTRIB_ARC "arc"
127 #define GEO_STD_ATTRIB_GEN "gen"
128 #define GEO_STD_ATTRIB_TUBECAPTURE "tubeCapt"
129 #define GEO_STD_ATTRIB_PNT_CAPTURE_ALPHA "pCaptAlpha"
130 #define GEO_STD_ATTRIB_PNT_CAPTURE_PATH "pCaptPath"
131 #define GEO_STD_ATTRIB_PNT_CAPTURE_DATA "pCaptData"
132 #define GEO_STD_ATTRIB_CAPTUREFRAME "pCaptFrame"
133 #define GEO_STD_ATTRIB_CAPT_SKELROOT "pCaptSkelRoot"
134 #define GEO_STD_ATTRIB_CLOTH_CAPT "clothCapt"
135 #define GEO_STD_ATTRIB_WIRE_CAPT_U "wireCaptU"
136 #define GEO_STD_ATTRIB_WIRE_CAPT_V "wireCaptV"
137 #define GEO_STD_ATTRIB_WIRE_CAPT_PRIMU "wireCaptPrimU"
138 #define GEO_STD_ATTRIB_META_CAPT_FRAME "metaCaptFrame"
139 #define GEO_STD_ATTRIB_META_CAPT_GROUPS "metaCaptGroups"
140 #define GEO_STD_ATTRIB_META_CAPT_ROOT "metaCaptRoot"
141 #define GEO_STD_ATTRIB_META_CAPT_PATHS "metaCaptPaths"
142 #define GEO_STD_ATTRIB_META_CAPT_DATA "metaCaptData"
143 #define GEO_STD_ATTRIB_META_CAPT_GROUP_MAP "metaCaptGroupMap"
144 #define GEO_STD_ATTRIB_META_SLIDE "slideModifier"
145 #define GEO_STD_ATTRIB_INFLATE_MODIFIER "inflatemodifier"
146 #define GEO_STD_ATTRIB_MUSCLE_REST_ANCHOR "restAnchor"
147 #define GEO_STD_ATTRIB_MUSCLE_REST_XFORMS "restTransforms"
148 #define GEO_STD_ATTRIB_MUSCLE_INFLATE_NORM "muscleInflateNormal"
149 #define GEO_STD_ATTRIB_MUSCLE_POSITION_BIAS "positionbiasvalues"
150 #define GEO_STD_ATTRIB_MUSCLE_CAPT_NAMES "muscleCaptNames"
151 #define GEO_STD_ATTRIB_RIXLATE "rixlate"
152 #define GEO_STD_ATTRIB_DEFORM_SKIN_METHOD "deformSkinMethod"
153 #define GEO_STD_ATTRIB_DEFORM_DUAL_QUATERNION_BLEND_ATTRIB "deformDualQuaternionBlendAttrib"
154 #define GEO_STD_ATTRIB_DEFORM_TRANSFORMS_PATH "deformTransformsPath"
155 #define GEO_STD_ATTRIB_DEFORM_TRANSFORM_REGIONS_PATH "deformTransformRegionsPath"
156 #define GEO_STD_ATTRIB_DEFORM_TRANSFORM_TARGETS_PATH "deformTransformTargetsPath"
157 #define GEO_STD_ATTRIB_POSE_SHAPE_EXAMPLE_PATH "poseShapeExamplePath"
158 #define GEO_STD_ATTRIB_SHAPE_DIFF_METHOD "shapeDiffMethod"
159 #define GEO_STD_ATTRIB_SHAPE_DIFF_ORIENT_ATTRIB "shapeDiffOrientAttrib"
160 #define GEO_STD_ATTRIB_SHAPE_DIFF_TRANSFORM_ATTRIB "shapeDiffTransformAttrib"
161 #define GEO_STD_ATTRIB_STASH_POSE_PATH "stashPosePath"
162 
163 /* Update the getStandardAttributes method when adding attribs */
164 /* These become the indices into the "context" detail attribute to
165  * look up when doing a getStandardAttribute */
167 {
203 };
204 
206 {
210 };
211 
213 {
218 };
219 
221 {
226 };
227 
229 {
232 };
233 
235 {
238 };
239 
240 /// An enum for GEO_Detail::copy's method parameter.
246 };
247 
249 {
250 public:
252  bool full_topology=true);
253  ~GEO_Detail() override;
254 
255  /// Compute memory usage (includes all shared memory)
256  int64 getMemoryUsage(bool inclusive) const override;
257 
258  /// Count memory usage using a UT_MemoryCounter in order to count
259  /// shared memory correctly.
260  /// If inclusive is true, the size of this object is counted,
261  /// else only memory owned by this object is counted.
262  /// If this is pointed to by the calling object, inclusive should be true.
263  /// If this is contained in the calling object, inclusive should be false.
264  /// (Its memory was already counted in the size of the calling object.)
265  void countMemory(UT_MemoryCounter &counter, bool inclusive) const override;
266 
267  /// Clear all the points/primitives out of this detail
269  {
270  clearCaches();
273  }
274 
275  /// Merge the whole detail, or only a group of prims, or only some points.
276  ///
277  /// If a @c primGroup is given, only the primitives in that group will be
278  /// merged into this detail. Only points referenced by the primitives will
279  /// be merged. The @c primGroup should exist on the @c src detail.
280  ///
281  /// Primitives will be appended to the primitive list unless @c
282  /// insertPrimsAtHead is set.
283  ///
284  /// If @c mergePrimGroup is set, primitive groups will be copied from the
285  /// source detail. If @c keep_internal_groups is true, @b all groups
286  /// will be copied, not just public primitive groups.
287  ///
288  /// If @c data_id_strategy is GA_DATA_ID_CLONE and it's a full merge into
289  /// an empty detail, any attributes whose source has a valid data id will
290  /// inherit that data id. Otherwise, each merged attribute will get a new
291  /// unique data id if this detail is generating such.
292  ///
293  void merge(const GEO_Detail &src,
294  const GA_PrimitiveGroup *primGrp = nullptr,
295  bool mergePrimGroup = true,
296  bool insertPrimsAtHead= false,
297  bool keep_internal_groups = true,
298  GA_DataIdStrategy data_id_strategy = GA_DATA_ID_BUMP);
299 
300  /// Merge points from the source detail into this detail.
301  ///
302  /// If the @c ptGrp group is specified, only points in the @c src detail's
303  /// group will be merged.
304  ///
305  /// If @c merge_groups is set, point groups will be copied from the source
306  /// detail. If @c keep_internal_groups is set, @b all groups will be
307  /// copied (not just public point groups).
308  void mergePoints(const GEO_Detail &src,
309  const GA_PointGroup *ptGrp = 0,
310  bool merge_groups = true,
311  bool keep_internal_groups = true);
312 
313  /// Merge only a group of points.
314  void mergePoints(const GEO_Detail &src, const GA_Range &points);
315 
316  /// Merge only a group of prims.
317  void mergePrimitives(const GEO_Detail &src, const GA_Range &prims);
318 
319  /// Merge a single primitive into this detail.
320  void merge(const GEO_Primitive &sprim, bool insertPrimAtHead=false);
321 
322  /// Copy the source detail into this detail.
323  ///
324  /// If @c data_id_strategy is GA_DATA_ID_CLONE and method is GEO_COPY_ONCE,
325  /// any attributes whose source has a valid data id will inherit that data
326  /// id. Otherwise, each merged attribute will get a new unique data id if
327  /// this detail is generating such.
328  bool copy(const GEO_Detail &src, GEO_CopyMethod method = GEO_COPY_ONCE,
329  bool this_parameter_is_ignored = true,
330  bool keep_internal_groups = true,
331  GA_DataIdStrategy data_id_strategy = GA_DATA_ID_BUMP);
332 
333  void collapseIndexAttributes();
334 
335  /// Mirrors a portion of the gdp across some plane
336  void mirror(GEO_MirrorParms &parms);
337 
338  /// Transform a range of primitives. Note that this will only transform
339  /// the points used by the primitives.
340  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
341  template<typename FLOAT_T>
342  void transform(const UT_Matrix4T<FLOAT_T> &mat,
343  const GA_Range &primitives,
344  bool just_P,
345  bool keep_vector_lengths = true,
346  bool check_pasting = true,
347  bool neg_determinant_flip_vector = true,
348  bool update_ptnormals = false,
349  GEO_Delta *geodelta = nullptr,
350  bool updateaffectednormals = false,
351  const char *attribpattern = nullptr);
352  /// Transform a range of primitives & points.
353  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
354  template<typename FLOAT_T>
355  void transform(const UT_Matrix4T<FLOAT_T> &mat,
356  const GA_Range &primitives,
357  const GA_Range &points,
358  bool just_P,
359  bool keep_vector_lengths = true,
360  bool check_pasting = true,
361  bool neg_determinant_flip_vector = true,
362  bool update_ptnormals = false,
363  GEO_Delta *geodelta = nullptr,
364  bool updateaffectednormals = false,
365  const char *attribpattern = nullptr);
366 
367 
368  /// Transform/translate all or some of the primitives. The methods will run
369  /// more efficiently if you happen to know the point closure apriori.
370  /// If 'just_P' is true, we only transform P, and not other attributes,
371  /// and don't check for reflection matrix.
372  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
373  template<typename FLOAT_T>
374  void transform(const UT_Matrix4T<FLOAT_T> &mat,
375  const GA_PrimitiveGroup *primGrp = 0,
376  const GA_PointGroup *pointClosure = 0,
377  bool just_P = false,
378  bool keep_vector_lengths = true,
379  bool check_pasting = true,
380  bool neg_determinant_flipvector = true,
381  bool update_ptnormals = false,
382  GEO_Delta *geodelta = 0,
383  bool updateaffectednormals = false,
384  const char *attribpattern = nullptr);
385 
386  // We transform from min_ptnum to max_ptnum *inclusive*.
387  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
388  template<typename FLOAT_T>
389  void transformRange(const UT_Matrix4T<FLOAT_T> &mat,
390  GA_Index min_ptnum, GA_Index max_ptnum,
391  GA_Index min_primnum, GA_Index max_primnum,
392  bool just_P = false,
393  bool keep_vector_lengths = true,
394  bool check_pasting = true,
395  bool neg_determinant_flipvector = true,
396  bool update_ptnormals = false,
397  GEO_Delta *geodelta = 0,
398  bool updateaffectednormals = false,
399  const char *attribpattern = nullptr);
400 
401  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
402  template<typename FLOAT_T>
403  void translate(const UT_Vector3T<FLOAT_T> &delta,
404  const GA_PrimitiveGroup *primGrp = 0,
405  const GA_PointGroup *pointClosure = 0,
406  bool check_pasting = true,
407  bool update_ptnormals = false,
408  GEO_Delta *geodelta = 0,
409  bool updateaffectednormals = false,
410  const char *attribpattern = nullptr);
411 
412  /// Transform all range of the points.
413  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
414  template<typename FLOAT_T>
415  void transformPoints(const UT_Matrix4T<FLOAT_T> &mat,
416  const GA_Range &points,
417  bool just_P = false,
418  bool keep_vector_lengths = true,
419  bool check_pasting = true,
420  bool neg_determinant_flipvector = true,
421  bool update_ptnormals = false,
422  GEO_Delta *geodelta = 0,
423  bool updateaffectednormals = false,
424  const char *attribpattern = nullptr);
425  /// Transform/translate all or some of the points.
426  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
427  template<typename FLOAT_T>
428  void transformPoints(const UT_Matrix4T<FLOAT_T> &mat,
429  const GA_PointGroup *pointGroup = 0,
430  const GA_PrimitiveGroup *primClosure = 0,
431  bool just_P = false,
432  bool keep_vector_lengths = true,
433  bool check_pasting = true,
434  bool neg_determinant_flipvector = true,
435  bool update_ptnormals = false,
436  GEO_Delta *geodelta = 0,
437  bool updateaffectednormals = false,
438  const char *attribpattern = nullptr);
439 
440  /// Transform a range of points by an attrib which stores a matrix4
441  /// for each point.
442  template <typename FLOAT_T, bool INVERT=false>
443  void transformPointsByAttribute(
444  const GA_ROHandleT<UT_Matrix4T<FLOAT_T> > &xformhandle,
445  const GA_Range &points,
446  bool keep_vector_lengths = true,
447  bool updateaffectednormals = true,
448  const char *attribpattern = nullptr);
449 
450  /// Rotates/shears all the attributes by a matrix3 for each point.
451  /// Note: Does not scale/rotate GA_TYPE_POINT/GA_TYPE_HPOINT.
452  template <typename FLOAT_T, bool INVERT=false>
453  void transformPointsByAttribute(
454  const GA_ROHandleT<UT_Matrix3T<FLOAT_T> > &xformhandle,
455  const GA_Range &points,
456  bool keep_vector_lengths = true,
457  bool updateaffectednormals = true,
458  const char *attribpattern = nullptr);
459 
460  /// Rotates all the attributes by a quaternion for each point.
461  /// Note: Does not rotate GA_TYPE_POINT/GA_TYPE_HPOINT.
462  template <typename FLOAT_T, bool INVERT=false>
463  void transformPointsByAttribute(
464  const GA_ROHandleT<UT_QuaternionT<FLOAT_T> > &xformhandle,
465  const GA_Range &points,
466  bool keep_vector_lengths = true,
467  bool updateaffectednormals = true,
468  const char *attribpattern = nullptr);
469 
470  /// Translates all the attributes by a displacement for each point.
471  /// Note: Only affects GA_TYPE_POINT/GA_TYPE_HPOINT.
472  template <typename FLOAT_T, bool INVERT=false>
473  void translatePointsByAttribute(
474  const GA_ROHandleT<UT_Vector3T<FLOAT_T> > &xformhandle,
475  const GA_Range &points,
476  bool keep_vector_lengths = true,
477  bool updateaffectednormals = true,
478  const char *attribpattern = nullptr);
479 
480  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
481  template<typename FLOAT_T>
482  void translatePoints(const UT_Vector3T<FLOAT_T> &delta,
483  const GA_PointGroup *pointGroup = 0,
484  bool check_pasting = true,
485  bool update_ptnormals = false,
486  GEO_Delta *geodelta = 0,
487  bool updateaffectednormals = false,
488  const char *attribpattern = nullptr);
489 
490  /// Transforms edges, calls transformPoints on the point closure of the
491  /// edges.
492  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
493  template<typename FLOAT_T>
494  void transformEdges(const UT_Matrix4T<FLOAT_T> &mat,
495  const GA_EdgeGroup *edgegrp = 0,
496  const GA_PrimitiveGroup *primclosure = 0,
497  bool just_P = false,
498  bool keep_vector_lengths = true,
499  bool check_pasting = true,
500  bool neg_determinant_flipvector = true,
501  bool update_ptnormals = false,
502  GEO_Delta *geodelta = 0,
503  bool updateaffectednormals = false,
504  const char *attribpattern = nullptr);
505 
506  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
507  template<typename FLOAT_T>
508  void translateEdges(const UT_Vector3T<FLOAT_T> &delta,
509  const GA_EdgeGroup *edgegrp = 0,
510  bool check_pasting = true,
511  bool update_ptnormals = false,
512  GEO_Delta *geodelta = 0,
513  bool updateaffectednormals = false,
514  const char *attribpattern = nullptr);
515 
516  /// Transforms breakpoints
517  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
518  template<typename FLOAT_T>
519  void transformBreakpoints(const UT_Matrix4T<FLOAT_T> &mat,
520  const GA_BreakpointGroup *grp = 0,
521  bool just_P = false,
522  bool update_ptnormals = false,
523  GEO_Delta *geodelta = 0,
524  bool updateaffectednormals = false,
525  const char *attribpattern = nullptr);
526 
527  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
528  template<typename FLOAT_T>
529  void translateBreakpoints(const UT_Vector3T<FLOAT_T> &delta,
530  const GA_BreakpointGroup *grp = 0,
531  bool update_ptnormals = false,
532  GEO_Delta *geodelta = 0,
533  bool updateaffectednormals = false,
534  const char *attribpattern = nullptr);
535 
536  /// Convenience function, will call the appropriate transform/translate
537  /// depending on the type of group
538  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
539  template<typename FLOAT_T>
540  void transformGroup(const UT_Matrix4T<FLOAT_T> &mat,
541  const GA_Group &grp,
542  bool just_P = false,
543  bool keep_vector_lengths = true,
544  bool check_pasting = true,
545  bool neg_determinant_flipvector = true,
546  const GA_PointGroup *ptclosure = 0,
547  const GA_PrimitiveGroup *primclosure = 0,
548  bool update_ptnormals = false,
549  GEO_Delta *geodelta = 0,
550  bool updateaffectednormals = false,
551  const char *attribpattern = nullptr);
552 
553  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
554  template<typename FLOAT_T>
555  void translateGroup(const UT_Vector3T<FLOAT_T> &delta,
556  const GA_Group &grp,
557  bool check_pasting = true,
558  const GA_PointGroup *ptclosure = 0,
559  bool update_ptnormals = false,
560  GEO_Delta *geodelta = 0,
561  bool updateaffectednormals = false,
562  const char *attribpattern = nullptr);
563 
564  void visualizeSoftPoints(const GEO_Rolloff &rolloff,
565  const GA_PointGroup *ptgroup,
566  UT_ColorRamp ramp);
567 
568  /// Class for passing symmetry arguments to certain soft transform related
569  /// methods.
571  {
572  public:
573  bool operator==(const SoftSymmetryParms &other) const
574  {
575  return myNormal == other.myNormal
576  && myOrigin == other.myOrigin
577  && myTol == other.myTol;
578  }
579 
580  bool operator!=(const SoftSymmetryParms &other) const
581  {
582  return !(*this == other);
583  }
584 
585  UT_Vector3 myNormal; // assumed to be normalized!
587  float myTol;
588  };
589 
590  // this function is outdated, GUsurfaceDistance should be used
591  /// symmetry - the soft falloff from any points not directly on the plane
592  /// of symmetry will be clamped to that plane of symmetry when
593  /// provided
594  /// affected_group - if provided, all points within the soft falloff
595  /// will be added to this group
596  void computeSoftPointFalloff(
597  const bool connected,
598  const fpreal radius,
599  const GEO_Rolloff *rolloff,
600  const GA_PointGroup *ptgroup,
601  const SoftSymmetryParms *symmetry,
602  const GA_RWHandleF &falloff,
603  const GA_ROHandleV3 &p_attrib,
604  GA_PointGroup* affected_group = nullptr,
605  GA_RWHandleID* source_points = nullptr) const;
606 
607  /// The computeNormal methods compute the normals of primitives, points,
608  /// edges and breakpoints. The primitive one is there for completeness.
609  /// An edge normal is the average of its primitive normals.
610 
611  /// For internal functions:
612  /// If nml_offset > -1, the attribute at that offset will be returned,
613  /// else if the geometry has a normal attribute ("N"), nml_offset
614  /// will be set to the offset of that attribute and that attributes
615  /// value will be returned,
616  /// else if the geometry has an internal normal attribute ("internalN")
617  /// the value of the internal attribute will be returned and
618  /// nml_offset will be set to its offset,
619  /// else the "internalN" attribute is created by a call to normal(1),
620  /// nml_offset is set to it, and the calculated value returned.
621  /// If nml_offset is null, the case of nml_offset == -1 is followed
622  /// except nml_offset is not written to.
623  /// Otherwise:
624  /// Recompute the normal. No side-effects happen, but this is much
625  /// slower.
626 
627  /// A faster version of computeNormal which has the side effect of
628  /// computing the internal normal if it's not there
629  void computeNormalInternal(GA_Offset ptoff, UT_Vector3 &nml);
630 
631  /// This is the same as prim.computeNormal()
632  void computeNormal(const GEO_Primitive &prim, UT_Vector3 &nml) const;
633  void computeNormal(const GA_Edge &edge, UT_Vector3 &nml) const;
634 
635  /// WARNING: This could be very slow! Are you sure you need no side-effects?
636  /// See computeNormalInternal!
637  void computeNormal(const GA_Breakpoint &bkpt, UT_Vector3 &nml) const;
638 
639  /// Compute the normal, and (optionally) tangents, at the specified
640  /// breakpoint. An extension of computeNormal() that also computes
641  /// partial tangents.
642  void computeNormalAndTangents(const GA_Breakpoint &bkpt,
643  UT_Vector3 &nml,
644  UT_Vector3 *u_tangent,
645  UT_Vector3 *v_tangent,
646  bool normalize) const;
647 
648  /// The normalTranslate* methods translate points, prims, edges or
649  /// breakpoints along each of their normals.
650  void normalTranslatePoints(float length = 1.0F,
651  int check_pasting = 1,
652  const GA_PointGroup *grp = 0,
653  int update_ptnormals = 0,
654  GEO_Delta *geodelta = 0,
655  bool updateaffectednormals = false,
656  const GA_Attribute *custom_attrib = nullptr,
657  const bool normalize_attrib = false,
658  const GA_Attribute *mask = nullptr);
659  void normalTranslatePrimitives(float length = 1.0F,
660  int check_pasting = 1,
661  const GA_PrimitiveGroup *grp = 0,
662  int update_ptnormals = 0,
663  GEO_Delta *geodelta = 0,
664  bool updateaffectednormals = false,
665  const GA_Attribute *custom_attrib = nullptr,
666  const bool normalize_attrib = false,
667  const GA_Attribute *mask = nullptr);
668  void normalTranslate(const GA_PointGroup &grp,
669  float length = 1.0F, int check_pasting = 1,
670  int update_ptnormals = 0,
671  GEO_Delta *geodelta = 0,
672  bool updateaffectednormals = false,
673  const GA_Attribute *custom_attrib = nullptr,
674  const bool normalize_attrib = false,
675  const GA_Attribute *mask = nullptr);
676  void normalTranslate(const GA_PrimitiveGroup &grp,
677  float length = 1.0F, int check_pasting = 1,
678  int update_ptnormals = 0,
679  GEO_Delta *geodelta = 0,
680  bool updateaffectednormals = false,
681  const GA_Attribute *custom_attrib = nullptr,
682  const bool normalize_attrib = false,
683  const GA_Attribute *mask = nullptr);
684  void normalTranslate(const GA_EdgeGroup &grp,
685  float length = 1.0F, int check_pasting = 1,
686  int update_ptnormals = 0,
687  GEO_Delta *geodelta = 0,
688  bool updateaffectednormals = false,
689  const GA_Attribute *custom_attrib = nullptr,
690  const bool normalize_attrib = false,
691  const GA_Attribute *mask = nullptr);
692  void normalTranslate(const GA_BreakpointGroup &grp,
693  float length = 1.0F, int check_pasting = 1,
694  int update_ptnormals = 0,
695  GEO_Delta *geodelta = 0,
696  bool updateaffectednormals = false,
697  const GA_Attribute *mask = nullptr);
698  void normalTranslateGroup(const GA_Group &grp,
699  float length = 1.0F, int check_pasting = 1,
700  int update_ptnormals = 0,
701  GEO_Delta *geodelta = 0,
702  bool updateaffectednormals = false,
703  const GA_Attribute *custom_attrib = nullptr,
704  const bool normalize_attrib = false,
705  const GA_Attribute *mask = nullptr);
706 
707  /// Update the point normals that are affected by a transform
708  /// applied to a given point group. If the transform is the same
709  /// everywhere, only points on the boundary will be recomputed.
710  /// Also recomputes vertex normals.
711  /// See GEOcomputeNormals() as well.
712  void updateAffectedNormals(const GA_Range &ptrange,
713  GEO_Delta *geodelta = 0,
714  bool allsametransform = false);
715 
716  /// Slide edges along adjacent primitive edges. The transform matrix is
717  /// used to compute translation deltas for the edge endpoints.
718  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
719  template<typename FLOAT_T>
720  void slideTransformEdges(const UT_Matrix4T<FLOAT_T> &mat,
721  const GA_EdgeGroup *edgegrp = 0,
722  const GA_PrimitiveGroup *primclosure = 0,
723  bool just_P = false,
724  bool keep_vector_lengths = true,
725  bool check_pasting = true,
726  bool neg_determinant_flipvector = true,
727  bool update_ptnormals = false,
728  GEO_Delta *geodelta = 0,
729  bool updateaffectednormals = false);
730 
731  /// Slide points across the face of adjacent primitives.
732  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
733  template<typename FLOAT_T>
734  void slideTransformPoints(const UT_Matrix4T<FLOAT_T> &mat,
735  const GA_PointGroup *ptgrp = 0,
736  const GA_PrimitiveGroup *primclosure = 0,
737  bool just_P = false,
738  bool keep_vector_lengths = true,
739  bool check_pasting = true,
740  bool neg_determinant_flipvector = true,
741  bool update_ptnormals = false,
742  GEO_Delta *geodelta = 0,
743  bool updateaffectednormals = false,
744  GEO_PointSliderCache *slider_cache = 0);
745 
746  /// Slide primitives (by their points) across the face of adjacent
747  /// primitives.
748  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
749  template<typename FLOAT_T>
750  void slideTransformPrimitives(const UT_Matrix4T<FLOAT_T> &mat,
751  const GA_PrimitiveGroup *primgrp = 0,
752  const GA_PointGroup *ptclosure = 0,
753  bool just_P = false,
754  bool keep_vector_lengths = true,
755  bool check_pasting = true,
756  bool neg_determinant_flipvector = true,
757  bool update_ptnormals = false,
758  GEO_Delta *geodelta = 0,
759  bool updateaffectednormals = false,
760  GEO_PointSliderCache *slider_cache = 0);
761 
762  /// Convenience function, will call the appropriate slide transform
763  /// depending on the type of group
764  /// Don't use update_ptnormals, except for compatibility; use updateaffectednormals.
765  /// The GEO_PointSliderCache argument is unused for edge groups.
766  template<typename FLOAT_T>
767  void slideTransformGroup(const UT_Matrix4T<FLOAT_T> &mat,
768  const GA_Group &grp,
769  bool just_P = false,
770  bool keep_vector_lengths = true,
771  bool check_pasting = true,
772  bool neg_determinant_flipvector = true,
773  const GA_PointGroup *ptclosure = 0,
774  const GA_PrimitiveGroup *primclosure = 0,
775  bool update_ptnormals = false,
776  GEO_Delta *geodelta = 0,
777  bool updateaffectednormals = false,
778  GEO_PointSliderCache *slider_cache = 0);
779 
780 
781  /// Class for passing local context arguments to certain softTransform*()
782  /// methods.
783  template <typename FLOAT_T>
785  {
786  public:
787  // Enum for flagging how the coordinate frame is specified.
788  enum class Type
789  { LOOKAT, ORIENT };
790 
791  // Enum for flagging whether the pivot transform is specified in
792  // global or local space.
793  enum class PivotSpace
794  { GLOBAL, LOCAL };
795 
796  /// Coordinate frame defined by lookat(zero, forward, up).
798  const UT_Vector3T<FLOAT_T> &up,
799  PivotSpace pivot_space)
800  : myFwdVector(forward), myUpVector(up), myType(Type::LOOKAT),
801  myPivotSpace(pivot_space) {}
802 
803  /// Coordinate frame defined by an orient (rotate) matrix and origin.
804  /// The orient matrix should transform row vector coordinates in the
805  /// local basis to the standard world basis.
807  const UT_Vector3T<FLOAT_T> &origin,
808  PivotSpace pivot_space)
809  : myOrient(orient), myOrigin(origin), myType(Type::ORIENT),
810  myPivotSpace(pivot_space) {}
811 
812  // These two members are only set when myType == Type::LOOKAT.
815 
816  // These two members are only set when myType == Type::ORIENT.
819 
822  };
826 
827  /// Perform the transformation given by t*, s*, p*, s_*, in the
828  /// coordinate frame described by local_frame.
829  template<typename FLT>
830  static
831  UT_Matrix4T<FLT> localSpaceXformMatrix(const UT_XformOrder &order,
833  &local_frame,
834  FLT tx, FLT ty, FLT tz,
835  FLT rx, FLT ry, FLT rz,
836  FLT sx, FLT sy, FLT sz,
837  FLT s_xy, FLT s_xz, FLT s_yz,
838  FLT px, FLT py, FLT pz,
839  FLT prx, FLT pry, FLT prz);
840 
841  /// Transform points using soft-selections (proportional xform):
842  /// symmetry - the soft falloff from any points not directly on the plane
843  /// of symmetry will be clamped to that plane of symmetry when
844  /// provided
845  /// falloff_output - any non-zero falloffs used during this call will be
846  /// written to this attribute when provided
847  /// falloff_written - will be set to true when provided if falloff_output
848  /// is provided, and this call did not skip processing
849  /// any non-zero falloffs. If not set, you must call
850  /// computeSoftPointFalloff() to obtain the falloffs.
851  void softTransformPoints(
852  const UT_XformOrder &order,
853  float tx, float ty, float tz,
854  float rx, float ry, float rz,
855  float sx, float sy, float sz,
856  float s_xy, float s_xz, float s_yz,
857  float px, float py, float pz,
858  float prx, float pry, float prz,
859  const GEO_Rolloff &rolloff,
860  const GA_PointGroup *ptgroup = 0,
861  const SoftSymmetryParms *symmetry = 0,
862  int just_P = 0,
863  int keep_vector_lengths = 1,
864  int check_pasting = 1,
865  int neg_determinant_flipvector = 1,
866  int update_ptnormals = 0,
867  GEO_Delta *geodelta = 0,
868  bool updateaffectednormals = false,
869  const char *attribpattern = nullptr,
870  const GA_RWHandleF *falloff_output = nullptr,
871  bool *falloff_written = nullptr);
872  void softTransformEdges(
873  const UT_XformOrder &order,
874  float tx, float ty, float tz,
875  float rx, float ry, float rz,
876  float sx, float sy, float sz,
877  float s_xy, float s_xz, float s_yz,
878  float px, float py, float pz,
879  float prx, float pry, float prz,
880  const GEO_Rolloff &rolloff,
881  const GA_EdgeGroup *edgegrp = 0,
882  const SoftSymmetryParms *symmetry = 0,
883  int just_P = 0,
884  int keep_vector_lengths = 1,
885  int check_pasting = 1,
886  int neg_determinant_flipvector = 1,
887  int update_ptnormals = 0,
888  GEO_Delta *geodelta = 0,
889  bool updateaffectednormals = false,
890  const char *attribpattern = nullptr,
891  const GA_RWHandleF *falloff_output = nullptr,
892  bool *falloff_written = nullptr);
893 
894  void softTransformPoints(
895  const LocalXformContextF *local,
896  const UT_XformOrder &order,
897  float tx, float ty, float tz,
898  float rx, float ry, float rz,
899  float sx, float sy, float sz,
900  float s_xy, float s_xz, float s_yz,
901  float px, float py, float pz,
902  float prx, float pry, float prz,
903  const GEO_Rolloff &rolloff,
904  const GA_PointGroup *ptgroup = 0,
905  const SoftSymmetryParms *symmetry = 0,
906  int just_P = 0,
907  int keep_vector_lengths = 1,
908  int check_pasting = 1,
909  int neg_determinant_flipvector = 1,
910  int update_ptnormals = 0,
911  GEO_Delta *geodelta = 0,
912  bool updateaffectednormals = false,
913  const char *attribpattern = nullptr,
914  const GA_RWHandleF *falloff_output = nullptr,
915  bool *falloff_written = nullptr);
916  void softTransformEdges(
917  const LocalXformContextF *local,
918  const UT_XformOrder &order,
919  float tx, float ty, float tz,
920  float rx, float ry, float rz,
921  float sx, float sy, float sz,
922  float s_xy, float s_xz, float s_yz,
923  float px, float py, float pz,
924  float prx, float pry, float prz,
925  const GEO_Rolloff &rolloff,
926  const GA_EdgeGroup *edgegrp = 0,
927  const SoftSymmetryParms *symmetry = 0,
928  int just_P = 0,
929  int keep_vector_lengths = 1,
930  int check_pasting = 1,
931  int neg_determinant_flipvector = 1,
932  int update_ptnormals = 0,
933  GEO_Delta *geodelta = 0,
934  bool updateaffectednormals = false,
935  const char *attribpattern = nullptr,
936  const GA_RWHandleF *falloff_output = nullptr,
937  bool *falloff_written = nullptr);
938 
939  /// Translate points using soft-selections (proportional xlate):
940  /// symmetry - the soft falloff from any points not directly on the plane
941  /// of symmetry will be clamped to that plane of symmetry when
942  /// provided
943  /// falloff_output - any non-zero falloffs used during this call will be
944  /// written to this attribute when provided
945  /// falloff_written - will be set to true when provided if falloff_output
946  /// is provided, and this call did not skip processing
947  /// any non-zero falloffs. If not set, you must call
948  /// computeSoftPointFalloff() to obtain the falloffs.
949  void softTranslatePoints(
950  const UT_Vector3 &delta,
951  const GEO_Rolloff &rolloff,
952  const GA_PointGroup *ptgroup = 0,
953  const SoftSymmetryParms *symmetry = 0,
954  int check_pasting = 1,
955  int update_ptnormals = 0,
956  GEO_Delta *geodelta = 0,
957  bool updateaffectednormals = false,
958  const char *attribpattern = nullptr,
959  const GA_RWHandleF *falloff_output = nullptr,
960  bool *falloff_written = nullptr);
961  void softTranslateEdges(
962  const UT_Vector3 &delta,
963  const GEO_Rolloff &rolloff,
964  const GA_EdgeGroup *edgegrp = 0,
965  const SoftSymmetryParms *symmetry = 0,
966  int check_pasting = 1,
967  int update_ptnormals = 0,
968  GEO_Delta *geodelta = 0,
969  bool updateaffectednormals = false,
970  const char *attribpattern = nullptr,
971  const GA_RWHandleF *falloff_output = nullptr,
972  bool *falloff_written = nullptr);
973 
974  /// Translate points along their normals using soft-selections
975  /// symmetry - the soft falloff from any points not directly on the plane
976  /// of symmetry will be clamped to the plane of symmetry when
977  /// provided
978  /// falloff_output - any non-zero falloffs used during this call will be
979  /// written to this attribute when provided
980  /// falloff_written - will be set to true when provided if falloff_output
981  /// is provided, and this call did not skip processing
982  /// any non-zero falloffs. If not set, you must call
983  /// computeSoftPointFalloff() to obtain the falloffs.
984  void softNormalTranslatePoints(
985  float distance,
986  const GEO_Rolloff &rolloff,
987  const GA_PointGroup *ptgroup = nullptr,
988  const SoftSymmetryParms *symmetry = nullptr,
989  int along_lead_normal = 1,
990  int check_pasting = 1,
991  int update_ptnormals = 0,
992  GEO_Delta *geodelta = nullptr,
993  bool updateaffectednormals = false,
994  const GA_RWHandleF *falloff_output = nullptr,
995  bool *falloff_written = nullptr);
996 
997  /// Add and compute normal attributes. Returns the normal attribute.
998  /// If given a primgroup, only points within the selection are used
999  /// in the calculation, all others are zeroed.
1000  GA_Attribute *normal(bool internal = false,
1001  const GA_PrimitiveGroup *primgroup = nullptr);
1002 
1003  /// Return normals computed from the geometry, ignoring the "N" attribute.
1004  void normal(UT_Vector3Array &output, bool use_internaln = true) const;
1005  void normal(UT_Vector3DArray &output, bool use_internaln = true) const;
1006 
1007  /// Compute normals into the existing attribute given. The attribute
1008  /// can be detached, and the detail won't ever be modified.
1009  void normal(const GA_RWHandleV3 &attrib,
1010  const GA_PrimitiveGroup *primgroup = nullptr) const;
1011 
1012  /// Add and compute vertex normal attributes. Returns the normals.
1013  void getVertexNormals(UT_Vector3Array &output) const;
1014 
1015  /// Methods for manipulating capture weights (GEO_CaptureWeight.C)
1017  {
1018  CAPTURE_BONE = 0,
1022  CAPTURE_MUSCLE
1023  };
1024 
1025  /// Get the name of the point attribute which contains (region, weight)
1026  /// pairs of capture data.
1027  static const UT_StringHolder
1028  &getPointCaptureAttribName(CaptureType type);
1029 
1030  /// Get the name of the property which contains an index of
1031  /// region names (like capture regions and metaball groups). Returns nullptr
1032  /// if no such region mapping exists for a type.
1033  static const char *getPointCaptureIndexPropertyName(CaptureType type);
1034 
1035  /// Get the name of the detail attribute for capture frame. Returns nullptr
1036  /// if a capture type doesn't use capture frame.
1037  static const UT_StringHolder
1038  &getPointCaptureFrameAttribName(CaptureType type);
1039 
1040  /// Get the name of the detail attribute for capture root. Returns nullptr
1041  /// if a capture type doesn't use capture frame.
1042  static const UT_StringHolder
1043  &getPointCaptureRootAttribName(CaptureType type);
1044 
1045  /// Get the name of the property for capture data (usually,
1046  /// a linear array of transformation matrices + possibly other data).
1047  /// Returns nullptr if a capture type doesn't use a capture data attribute.
1048  static const char *getPointCaptureDataPropertyName(CaptureType type);
1049 
1050  // Get the cregion root path. Returns true if successful with the value
1051  // in root_path.
1052  bool getCaptureRegionRootPath(UT_String &root_path,
1053  CaptureType t = CAPTURE_BONE) const;
1054  bool setCaptureRegionRootPath(const UT_String &root_path,
1055  CaptureType t = CAPTURE_BONE);
1056 
1057  /// Given a string representing a capture region for type t, return that
1058  /// region's index. -1 is returned if no index exists.
1059  int getCaptureRegionIndex(const UT_String &cregion_name,
1060  CaptureType t = CAPTURE_BONE);
1061 
1062  /// Add a new bone capture region. Sets the detail's capture transforms
1063  /// for the new region. Returns the index for this new region or -1 for
1064  /// failure.
1065  int addCaptureRegion(const UT_String &cregion_name,
1066  const UT_Matrix4 &parent_xform,
1067  const GEO_Detail *tube_gdp);
1068  int addCaptureRegion(const UT_String &cregion_name,
1069  const UT_Matrix4 &xform, float tcap, float bcap,
1070  float taperx, float taperz);
1071 
1072  /// Add a non-bone capture capture region of type type to this detail.
1073  /// Returns the index for this new region, or -1 for failure.
1074  int addCaptureRegion(const UT_String &cregion_name,
1075  CaptureType type);
1076 
1077  /// Delete a capture region (detail and point attributes) data.
1078  /// Return index of deleted attribute, -1 if cannot delete capture region
1079  int removeCaptureRegion(const UT_String &cregion_name,
1080  CaptureType t = CAPTURE_BONE);
1081 
1082  /// Set the capture weight on a group of points
1083  void setCaptureWeight(int cregion_index, float weight,
1084  const GA_PointGroup *ptgroup = nullptr,
1085  GEO_Delta *geodelta = nullptr,
1086  bool add_weight = false,
1087  bool clamp_negative = false,
1088  bool normalizeweight = false,
1089  CaptureType t = CAPTURE_BONE);
1090 
1091  /// Set the capture weight on a point
1092  void setCaptureWeight(int cregion_index, float weight,
1093  GA_Offset ptoff,
1094  GEO_Delta *geodelta = nullptr,
1095  bool add_weight = false,
1096  bool clamp_negative = false,
1097  bool normalizeweight = false,
1098  CaptureType t = CAPTURE_BONE);
1099 
1100  /// Get the capture weight of a point
1101  float getCaptureWeight(int cregion_index, GA_Offset ptoff,
1102  CaptureType t = CAPTURE_BONE) const;
1103 
1104  /// Get the average capture weight of a set of points
1105  bool addAverageCaptureWeight(const GA_PointGroup *ptgroup,
1106  const UT_String &root_path,
1107  UT_StringMap<float *> &averages ) const;
1108 
1109  void getCaptureWeights(GA_Offset ptoff, UT_IntArray &regions,
1110  UT_FloatArray &weights,
1111  CaptureType t = CAPTURE_BONE) const;
1112  void clearCaptureWeights(GA_Offset ptoff,
1113  CaptureType t = CAPTURE_BONE);
1114 
1116  {
1118  VISTYPE_MULTIPLE
1119  };
1120 
1121  /// Color points according to their capture (normalized) weight
1122  void colorPointsByCaptureWeight(
1123  const UT_Array<const UT_Vector3 *> &colors,
1124  const UT_Vector3 &zero_weight_color,
1125  CaptureType t = CAPTURE_BONE,
1126  VisualizationType vistype = VISTYPE_MULTIPLE,
1127  UT_ColorRamp singlevismode = UT_COLORRAMP_FALSE);
1128 
1129  /// Color points according to their capture weight, with option to
1130  /// normalize the weights for visualization.
1131  void colorPointsByCaptureWeight(
1132  const UT_Array<const UT_Vector3 *> &colors,
1133  const UT_Vector3 &zero_weight_color,
1134  CaptureType t,
1135  VisualizationType vistype,
1136  UT_ColorRamp singlevismode,
1137  bool normalize);
1138 
1139  void normalizeCaptureWeights(const GA_PointGroup *ptgroup = nullptr,
1140  CaptureType t = CAPTURE_BONE,
1141  fpreal tolerance = SYS_FTOLERANCE_R);
1142 
1143  /// clamp the capture weights to the given low/hi values, if the
1144  /// corresponding flag is true and the capture weight is below/above
1145  /// the corresponding threshold. If low/hi flag is false, the capture
1146  /// weight will be unaffected for respecive clamping.
1147  void clampCaptureWeights(const GA_PointGroup *ptgroup = nullptr,
1148  bool clamp_low_flag = true,
1149  float low_threshold = 0.0f, float low_val = 0.0f,
1150  bool clamp_hi_flag = false,
1151  float hi_threshold = 1.0f, float hi_val = 1.0f,
1152  CaptureType t = GEO_Detail::CAPTURE_BONE);
1153 
1154  /// This specifies a capture index that is exempt from normalization.
1155  void normalizeRelativeCaptureWeights(int idx, GA_Offset ptoff,
1156  GEO_Delta *delta=nullptr);
1157 
1158  ///
1159  /// Methods for adding to the point list.
1160  ///
1161  GA_Offset insertPointOffset(GA_Index beforeWhich = GA_INVALID_INDEX);
1164  /// Insert a point, copying data from the source point. If the @c
1165  /// beforeWhich index isn't specified, the point will be added at the
1166  /// end of the point list.
1167  GA_Offset insertPointCopy(GA_Offset src,
1168  GA_PointWrangler &wrangler,
1169  GA_Index beforeWhich = GA_INVALID_INDEX);
1170  /// Insert a point, copying data from the source point. If the @c
1171  /// beforeWhich index isn't specified, the point will be added at the
1172  /// end of the point list.
1173  /// @note It is more efficient to use the GA_PointWrangler version.
1174  GA_Offset insertPointCopy(GA_Offset src,
1175  GA_Index beforeWhich = GA_INVALID_INDEX);
1176 
1177  /// Append a point, copying data from the source point.
1179  { return insertPointCopy(src, wrangler); }
1180  /// Append a point, copying data from the source point.
1181  /// @note It is more efficient to use the GA_PointWrangler version.
1183  { return insertPointCopy(src); }
1184 
1185  /// Provide a few additional overloads of deletePoints() in addition
1186  /// to those available in GA_Detail.
1188  GA_Size deletePoints(const GA_PointGroup &point_group,
1189  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES)
1190  {
1191  return destroyPoints(GA_Range(point_group), mode);
1192  }
1193 
1194  /// Get a GEO_Primitive pointer by primitive offset
1195  /// @{
1198  {
1199  if (!GAisValid(primoff))
1200  return nullptr;
1201  // reinterpret_cast to avoid including header
1202  return reinterpret_cast<GEO_Primitive*>(
1203  getPrimitive(primoff));
1204  }
1207  {
1208  if (!GAisValid(off))
1209  return nullptr;
1210  return reinterpret_cast<const GEO_Primitive*>(
1211  getPrimitive(off));
1212  }
1213  /// @}
1214 
1215  /// Get a GEO_Primitive pointer by primitive index
1216  /// @{
1218  {
1219  if (!GAisValid(idx))
1220  return nullptr;
1221  return reinterpret_cast<GEO_Primitive*>(
1222  getPrimitiveByIndex(idx));
1223  }
1225  {
1226  if (!GAisValid(idx))
1227  return nullptr;
1228  return reinterpret_cast<const GEO_Primitive*>(
1229  getPrimitiveByIndex(idx));
1230  }
1231  /// @}
1232 
1233  /// @{
1234  /// GA uses "destroy" instead of "delete" as the verb. However, the old
1235  /// GEO/GB code made extensive use of "delete". These methods are to save
1236  /// the sanity of people trying to port code.
1238  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES)
1239  { return destroyPoints(range, mode); }
1240  GA_Size deletePrimitives(const GA_Range &range, bool and_points=false)
1241  { return destroyPrimitives(range, and_points); }
1242  bool deletePrimitive(GA_Primitive &prim, bool and_points=false)
1243  { return destroyPrimitive(prim, and_points); }
1244  /// @}
1245 
1246  /// Inserting and appending a new primitive
1247  /// Insertion works the same way as insertion of points. However, the
1248  /// primitive is not allocated beforehand, leaving this to the allocator.
1249  /// If the source primitive is from another detail, our primitive attribute
1250  /// dictionary must be an extension of that detail's (see
1251  /// sortAllAttributes()). Note that this last condition is the reverse of
1252  /// that for inserting or appending a copy of a point.
1253  GEO_Primitive *insertPrimitive(const GA_PrimitiveTypeId &type,
1254  const GEO_Primitive *beforeWhich = nullptr);
1257  {
1258  // NOTE: This is not a static_cast to avoid needing the definition
1259  // of GEO_Primitive.
1260  return (GEO_Primitive *) GA_Detail::appendPrimitive(type);
1261  }
1262 
1263  /// Provide a few additional overloads of deletePrimitives() in addition
1264  /// to those available in GA_Detail.
1265  GA_Size deletePrimitives(const GA_PrimitiveGroup &primGrp,
1266  bool and_points = false);
1267  GA_Size deletePrimitives(
1268  const UT_Array<GEO_Primitive*> &prims_in,
1269  bool and_points = false);
1270 
1271  /// Delete a whole group of breakpoints.
1272  /// @note The group is cleared when done (non-const operation)
1273  virtual void deleteBreakpoints(const GA_BreakpointGroup &bkptgrp);
1274 
1275  // Find the bounding box (optionally of a group of primitives)
1276  // instantiation. Returns false if the box is empty and true otherwise.
1277  bool getBBox(UT_BoundingBox *bbox,
1278  const GA_PrimitiveGroup *g = nullptr) const;
1279 
1280  /// Find the bounding box (optionally of a group of primitives) of
1281  /// transformed instantiation. Returns false if the box is empty and true
1282  /// otherwise.
1283  bool getBBox(UT_BoundingBox &bbox,
1284  const UT_Matrix4R &transform,
1285  const GA_PrimitiveGroup *g = nullptr) const;
1286 
1287  /// Find bounding box of visible primitives.
1288  /// Returns false if the box is empty and true otherwise.
1289  bool getVisibleBBox(
1290  UT_BoundingBox *bbox,
1291  const UT_Matrix4R *transform = nullptr,
1292  const GA_PrimitiveGroup *g = nullptr) const;
1293 
1294  bool getBSphere(UT_BoundingSphere *bsphere,
1295  const GA_PrimitiveGroup *g = nullptr,
1296  bool accurate_bounds = false) const;
1297 
1298  /// Find the bounding box (optionally of a group of points)
1299  /// instantiation. Returns false if the box is empty and true otherwise.
1300  bool getPointBBox(
1301  UT_BoundingBox *bbox,
1302  const GA_PointGroup *g = nullptr) const;
1304  UT_BoundingBox& bbox,
1305  const UT_Matrix4R &transform,
1306  const GA_PointGroup *g = nullptr) const
1307  {
1308  return getPointBBox(bbox, transform,
1309  getPointRange(g));
1310  }
1311  bool getPointBBox(
1312  UT_BoundingBox& bbox,
1313  const UT_Matrix4R &transform,
1314  const GA_Range &range) const;
1315  bool getPointBSphere(
1316  UT_BoundingSphere *bsphere,
1317  const GA_PointGroup *g = nullptr,
1318  bool accurate_bounds = false) const;
1319  bool getVertexBBox(
1320  UT_BoundingBox *bbox,
1321  const GA_VertexGroup *g = nullptr) const;
1322  bool getVertexBBox(
1323  UT_BoundingBox& bbox,
1324  const UT_Matrix4R &transform,
1325  const GA_VertexGroup *g = nullptr) const;
1326  bool getEdgeBBox(
1327  UT_BoundingBox &bbox,
1328  const GA_EdgeGroup &grp) const;
1329  bool getEdgeBBox(
1330  UT_BoundingBox &bbox,
1331  const UT_Matrix4R &transform,
1332  const GA_EdgeGroup &grp) const;
1333  bool getEdgeBSphere(
1334  UT_BoundingSphere &bsphere,
1335  const GA_EdgeGroup &grp,
1336  bool accurate_bounds = false) const;
1337  bool getBreakpointBBox(
1338  UT_BoundingBox &bbox,
1339  const GA_BreakpointGroup &grp) const;
1340  bool getBreakpointBBox(
1341  UT_BoundingBox &bbox,
1342  const UT_Matrix4R &transform,
1343  const GA_BreakpointGroup &grp) const;
1344  bool getBreakpointBSphere(
1345  UT_BoundingSphere &bsphere,
1346  const GA_BreakpointGroup &grp,
1347  bool accurate_bounds = false) const;
1348  bool getGroupBBox(
1349  UT_BoundingBox *bbox,
1350  const GA_Group *grp) const;
1351  bool getGroupBBox(
1352  UT_BoundingBox& bbox,
1353  const UT_Matrix4R &transform,
1354  const GA_Group *grp) const;
1355  bool getGroupBSphere(
1356  UT_BoundingSphere *bsphere,
1357  const GA_Group *grp,
1358  bool accurate_bounds) const;
1359 
1360  /// The following method computes either a 2D or 3D bounding box
1361  /// for the specified float attribute.
1362  bool getPointAttribBBox(
1363  const UT_StringRef &name,
1364  UT_BoundingBox *bbox,
1365  const GA_PointGroup *g = nullptr) const;
1366  bool getPointAttribBBox(
1367  const UT_StringRef &name,
1368  UT_BoundingBox *bbox,
1369  const GA_PrimitiveGroup &g) const;
1370  bool getPointAttribBBox(
1371  const UT_StringRef &name,
1372  UT_BoundingBox *bbox,
1373  const GA_EdgeGroup &g) const;
1374  bool getPointAttribBBox(
1375  const UT_StringRef &name,
1376  UT_BoundingBox *bbox,
1377  const GA_VertexGroup &g) const;
1378 
1379  /// Compute the 3D centroid with the given attribute and group.
1380  /// typename T can either be single or double precision.
1381  /// Returns false if there are no points. Behaviour is undefined if the
1382  /// attribute has less than 3 components.
1383  template <typename T>
1384  bool getPointAttribCentroid(
1385  UT_Vector3T<T> &centroid,
1386  const GA_Attribute &attrib,
1387  const GA_PointGroup *grp = nullptr) const;
1388 
1389  bool getPointAttribGroupBBox(
1390  const UT_StringRef &name,
1391  UT_BoundingBox *bbox,
1392  const GA_Group *grp) const;
1393 
1394  bool getVertexAttribBBox(
1395  const UT_StringRef &name,
1396  UT_BoundingBox *bbox,
1397  const GA_PointGroup *g = nullptr) const;
1398  bool getVertexAttribBBox(
1399  const UT_StringRef &name,
1400  UT_BoundingBox *bbox,
1401  const GA_PrimitiveGroup &g) const;
1402  bool getVertexAttribBBox(
1403  const UT_StringRef &name,
1404  UT_BoundingBox *bbox,
1405  const GA_EdgeGroup &g) const;
1406  bool getVertexAttribBBox(
1407  const UT_StringRef &name,
1408  UT_BoundingBox *bbox,
1409  const GA_VertexGroup &g) const;
1410  bool getVertexAttribGroupBBox(
1411  const UT_StringRef &name,
1412  UT_BoundingBox *bbox,
1413  const GA_Group *grp) const;
1414 
1415  /// Copy vertex attributes from source to destination
1416  SYS_DEPRECATED_HDK(13.0)
1417  void copyVertexAttributes(GEO_Vertex dest,
1418  const GEO_Vertex &src) const;
1419  void copyVertexAttributes(GA_Offset dest, GA_Offset src,
1420  GA_VertexWrangler &wrangler) const;
1421  /// Copy vertex AND point attributes
1422  SYS_DEPRECATED_HDK(13.0)
1423  void copyPointVertexAttributes(GEO_Vertex dest,
1424  const GEO_Vertex &src,
1425  bool copy_point_P = true) const;
1426  void copyPointVertexAttributes(
1427  GA_Offset dest_vtx, GA_Offset src_vtx,
1428  const GA_AttributeRefMap &vertex_attribs,
1429  const GA_AttributeRefMap &point_attribs);
1430  void copyPointVertexAttributes(
1431  GA_Offset dest_vtx, GA_Offset src_vtx,
1432  GA_VertexWrangler &vertex_wrangler,
1433  GA_PointWrangler &point_wrangler,
1434  bool copy_point_P)
1435  {
1436  copyVertex(dest_vtx, src_vtx, vertex_wrangler,
1437  point_wrangler, copy_point_P);
1438  }
1439  /// Copy vertex attributes AND change the point reference of the vertex
1440  SYS_DEPRECATED_HDK(13.0)
1441  void copyFullVertex(GEO_Vertex dest,
1442  const GEO_Vertex &src) const;
1443  /// Copy vertex attributes AND change the point reference of the vertex
1444  void copyFullVertex(GA_Offset dest_vtx,
1445  GA_Offset src_vtx,
1446  GA_VertexWrangler &vertex_wrangler)
1447  {
1448  copyVertex(dest_vtx, src_vtx, vertex_wrangler,
1449  nullptr);
1450  }
1451  /// Copy primitive attributes
1452  void copyPrimitiveAttributes(GEO_Primitive &dest,
1453  const GEO_Primitive &src);
1454 
1455  void copyPrimitiveGroups(GEO_Primitive &dest,
1456  const GEO_Primitive &src) const;
1457 
1458  /// Create a copy of the source vertex. Regardless of the "shallow" parm,
1459  /// this method will copy the vertex attribute data. If not shallow, it
1460  /// will also copy the point attribute data and will assign the source
1461  /// point position to the destination point. If shallow, it will assign the
1462  /// source point offset to the destination.
1463  SYS_DEPRECATED_HDK(13.0)
1464  void copyVertex(GEO_Vertex dest, const GEO_Vertex &src,
1465  int shallow = 0) const;
1466 
1467  /// Inherit the simple version of copyVertex from GA_Detail.
1468  using GA_Detail::copyVertex;
1469 
1470  /// Create a copy of the source vertex, copying only the vertex attributes
1471  /// specified by "vertex_attribs" and only the point attributes specified
1472  /// by the optional "point_attribs". If "point_attribs" is nullptr, then a
1473  /// shallow point copy is performed wiring the source's point (if any) to
1474  /// dest.
1475  void copyVertex(GA_Offset dest, GA_Offset src,
1476  GA_AttributeRefMap &vertex_attribs,
1477  GA_AttributeRefMap *point_attribs);
1478 
1479  /// Create a copy of the source vertex using the supplied wranglers to
1480  /// copy attributes. If "point_wrangler" is nullptr, then a shallow point
1481  /// copy is performed, wiring the source's point (if any) to dest.
1482  void copyVertex(GA_Offset dest, GA_Offset src,
1483  GA_VertexWrangler &vertex_wrangler,
1484  GA_PointWrangler *point_wrangler);
1485 
1486  /// Create a copy of the source vertex using the supplied wranglers to
1487  /// copy attributes. Unlike the previous method which takes an optional
1488  /// "point_wrangler", this overload always performs a non-shallow point
1489  /// copy and specifies whether or not "P" should be copied, regardless of
1490  /// the setting of the point wrangler.
1491  void copyVertex(GA_Offset dest, GA_Offset src,
1492  GA_VertexWrangler &vertex_wrangler,
1493  GA_PointWrangler &point_wrangler,
1494  bool copy_point_p);
1495 
1496  /// The following method will fix all rational curve/patch weights by
1497  /// flagging the curve/patch appropriately. It is quite expensive since
1498  /// it traverses the entire primitive list. Only call it as a last resort.
1499  void fixSplineWeights();
1500 
1501  /// Some useful alias functions, they simplify your life a lot
1502  /// Attribute handling
1503  ///
1504  /// These alias methods return the offset of the (new) attribute, or -1 if
1505  /// they failed for some reason.
1506 
1507  GA_Attribute *addNormalAttribute(GA_AttributeOwner who,
1509  GA_Attribute *addTextureAttribute(GA_AttributeOwner who,
1510  GA_Storage s = GA_STORE_INVALID);
1511  GA_Attribute *addVelocityAttribute(GA_AttributeOwner who,
1512  GA_Storage s = GA_STORE_INVALID);
1513  GA_Attribute *addAngularVelocityAttribute(GA_AttributeOwner who,
1514  GA_Storage s = GA_STORE_INVALID);
1515  GA_Attribute *addOrientAttribute(GA_AttributeOwner who,
1516  GA_Storage s = GA_STORE_INVALID);
1517  GA_Attribute *addAlphaAttribute(GA_AttributeOwner who,
1518  GA_Storage s = GA_STORE_INVALID);
1519  GA_Attribute *addComAttribute(GA_AttributeOwner who,
1520  GA_Storage s = GA_STORE_INVALID);
1521  GA_Attribute *addDiffuseAttribute(GA_AttributeOwner who,
1522  GA_Storage s = GA_STORE_INVALID);
1523  GA_Attribute *addDistanceAttribute(GA_AttributeOwner who,
1524  GA_Storage s = GA_STORE_INVALID);
1525  GA_Attribute *addLODAttribute(GA_AttributeOwner who,
1526  GA_Storage s = GA_STORE_INVALID);
1527  GA_Attribute *addRestAttribute(GA_AttributeOwner who,
1528  GA_Storage s = GA_STORE_INVALID,
1529  const UT_StringHolder &name
1530  = UT_StringHolder::theEmptyString);
1531  GA_Attribute *addTubeCaptureAttribute(
1532  GA_Storage s = GA_STORE_INVALID);
1533 
1534  /// Add the detail's capture frame attribute for capture type t.
1535  GA_Attribute *addCaptureFrameAttribute(CaptureType t = CAPTURE_BONE,
1536  GA_Storage s = GA_STORE_INVALID);
1537 
1538  /// Add the bone capture skeleton root detail attribute.
1539  GA_Attribute *addCaptureSkelRootAttribute(CaptureType t
1540  = CAPTURE_BONE);
1541 
1542  /// Add a new custom (index, weight) point attribute.
1543  /// TODO: geo_NPairs is temporary to force examination of old signature
1544  /// uses, which took size in bytes instead of the # of pairs.
1546  {
1547  public:
1548  explicit geo_NPairs(int v) : myValue(v) {}
1549 
1550  int getValue() const { return myValue; }
1551  private:
1552  int myValue;
1553  };
1554  GA_Attribute *addPtIndexPairAttribute(const UT_StringHolder &name,
1555  geo_NPairs n_pairs,
1557  GA_Attribute *addIndexPairAttribute(GA_AttributeOwner owner,
1558  const UT_StringHolder &name,
1559  int n_pairs,
1561 
1562  /// Add the (index, weight) point attribute for capture type t.
1563  GA_Attribute *addPointCaptureAttribute(geo_NPairs n_pairs,
1564  CaptureType t = CAPTURE_BONE,
1565  GA_Storage s =
1567 
1568  /// Add the bone capture alpha point attribute.
1569  GA_Attribute *addPointCaptureAlphaAttribute(float dflt,
1571 
1572  const GA_Attribute *findNormalAttribute(GA_AttributeOwner who) const;
1573  GA_Attribute *findNormalAttribute(GA_AttributeOwner who);
1574  const GA_Attribute *findTextureAttribute(GA_AttributeOwner who) const;
1575  GA_Attribute *findTextureAttribute(GA_AttributeOwner who);
1576  const GA_Attribute *findVelocityAttribute(GA_AttributeOwner who) const;
1577  GA_Attribute *findVelocityAttribute(GA_AttributeOwner who);
1578  const GA_Attribute *findAlphaAttribute(GA_AttributeOwner who) const;
1579  GA_Attribute *findAlphaAttribute(GA_AttributeOwner who);
1580  const GA_Attribute *findComAttribute(GA_AttributeOwner who) const;
1581  GA_Attribute *findComAttribute(GA_AttributeOwner who);
1582  const GA_Attribute *findDiffuseAttribute(GA_AttributeOwner who) const;
1583  GA_Attribute *findDiffuseAttribute(GA_AttributeOwner who);
1584  const GA_Attribute *findDistanceAttribute(GA_AttributeOwner who) const;
1585  GA_Attribute *findDistanceAttribute(GA_AttributeOwner who);
1586  const GA_Attribute *findLODAttribute(GA_AttributeOwner who) const;
1587  GA_Attribute *findLODAttribute(GA_AttributeOwner who);
1588  const GA_Attribute *findRestAttribute(GA_AttributeOwner who) const;
1589  GA_Attribute *findRestAttribute(GA_AttributeOwner who);
1590  const GA_Attribute *findTubeCaptureAttribute() const;
1591  GA_Attribute *findTubeCaptureAttribute();
1592 
1593  /// Find the material attribute if it exists. This checks for the
1594  /// GEO_STD_ATTRIB_MATERIAL name.
1595  GA_ROHandleS findMaterialAttribute(GA_AttributeOwner who) const;
1596 
1597  /// The internal normal attribute is always a point attribute
1598  /// @todo Remove internalN code path with the H11 viewport?
1599  const GA_Attribute *findInternalNormalAttribute() const;
1600  GA_Attribute *findInternalNormalAttribute();
1601 
1602  /// Find the offset for the detail's capture frame attribute for capture
1603  /// type t.
1604  const GA_Attribute *findCaptureFrameAttribute(
1605  CaptureType t = CAPTURE_BONE) const;
1606  GA_Attribute *findCaptureFrameAttribute(
1607  CaptureType t = CAPTURE_BONE);
1608 
1609  /// Find the offset for the bone capture skeleton root detail attribute.
1610  const GA_Attribute *findCaptureSkelRootAttribute(CaptureType t
1611  = CAPTURE_BONE) const;
1612  GA_Attribute *findCaptureSkelRootAttribute(CaptureType t
1613  = CAPTURE_BONE);
1614 
1615  /// Find the offset for the (region, weight) point capture *point*
1616  /// attribute for capture type t. If attrib_name is given, it will use the
1617  /// given name instead of the default.
1618  /// @{
1619  const GA_Attribute *findPointCaptureAttribute(
1620  CaptureType t = CAPTURE_BONE,
1621  const UT_StringRef &name
1623  bool strict = true
1624  ) const;
1625  GA_Attribute *findPointCaptureAttribute(
1626  CaptureType t = CAPTURE_BONE,
1627  const UT_StringRef &name
1629  bool strict = true
1630  );
1631  /// @}
1632 
1633  /// Find the offset for the bone capture alpha point attribute.
1634  const GA_Attribute *findPointCaptureAlphaAttribute() const;
1635  GA_Attribute *findPointCaptureAlphaAttribute();
1636 
1637  /// Find the offset for a custom (index, weight) point attribute.
1638  const GA_Attribute *findPtIndexPairAttribute(const UT_StringRef &name) const;
1639  GA_Attribute *findPtIndexPairAttribute(const UT_StringRef &name);
1640 
1641  void destroyNormalAttribute(GA_AttributeOwner who);
1642  void destroyInternalNormalAttribute();
1643  void destroyTextureAttribute(GA_AttributeOwner who);
1644  void destroyVelocityAttribute(GA_AttributeOwner who);
1645  void destroyAlphaAttribute(GA_AttributeOwner who);
1646  void destroyComAttribute(GA_AttributeOwner who);
1647  void destroyDiffuseAttribute(GA_AttributeOwner who);
1648  void destroyDistanceAttribute(GA_AttributeOwner who);
1649  void destroyLODAttribute(GA_AttributeOwner who);
1650  void destroyRestAttribute(GA_AttributeOwner who);
1651  void destroyTubeCaptureAttribute();
1652 
1653  /// Destroy the detail's capture frame attribute for capture type t.
1654  void destroyCaptureFrameAttribute(CaptureType t
1655  = CAPTURE_BONE);
1656 
1657  /// Destroy the bone capture skeleton root detail attribute.
1658  void destroyCaptureSkelRootAttribute(CaptureType t
1659  = CAPTURE_BONE);
1660 
1661  /// Destroy the (region, weight) point capture *point* attribute for
1662  /// capture type t.
1663  void destroyPointCaptureAttribute(CaptureType t =
1664  CAPTURE_BONE);
1665 
1666  /// Destroy the bone capture alpha point attribute.
1667  void destroyPointCaptureAlphaAttribute();
1668 
1669  /// Destroy a custom (index, weight) point attribute.
1670  void destroyPtIndexPairAttribute(const UT_StringRef &name);
1671 
1672  /// Retrieve the restAnchor string attribute from this gdp, if
1673  /// it exists - return true if successful
1674  bool getMetaRestAnchorPath(UT_String &anchorPath) const;
1675 
1676  /// You should never assume that "uv" is textures!
1677  /// Note that Point capture is still special cased.
1678  /// If the supplied layer is <= 0, then the current layer is used.
1679  /// To extract all the layers names, one should do:
1680  /// for (layer = 1; layer <= getNumLayers(); layer++)
1681  /// layername[layer] = getStdAttributeName(..., layer);
1682  ///
1683  /// WARNING: The returned UT_StringHolder may own the string it references,
1684  /// so you *must* either assign it to a UT_StringHolder or UT_String,
1685  /// or pass it to a function that takes a UT_StringHolder, UT_StringRef,
1686  /// const UT_StringHolder&, or const UT_StringRef&.
1687  /// *DO* *NOT* assign it to a const char* variable! The UT_StringHolder
1688  /// will be destructed immediately after the assignment, deleting the
1689  /// string that the const char* points to!
1690  UT_StringHolder getStdAttributeName(GEO_Standard_Attributes name,
1691  int layer = -1) const;
1692  int getAttributeLayer(const char* attr_name) const;
1693 
1694  static GA_TypeInfo getStdAttributeTypeInfo(const char *name, int floattuplesize);
1695 
1696  /// These handle layers:
1697  int getCurrentLayer() const;
1698  void setCurrentLayer(int layer);
1699  void setNumLayers(int numlayer);
1700  int getNumLayers() const;
1701  /// These get and set the CURRENT layer's merge mode:
1702  void setLayerMerge(int preclear, int mask, int srcblend,
1703  int dstblend);
1704  void getLayerMerge(int &preclear, int &mask, int &srcblend,
1705  int &dstblend) const;
1706 
1707  void addVariableName(const char *attr, const char *varname);
1708  void removeVariableName(const char *varname)
1709  { addVariableName(0, varname); }
1710  /// This gets a raw list of the variable maps suitable for caching
1711  /// to see if they changed.
1712  void getVariableNameMap(UT_String &result) const;
1713 
1714  /// Traverses the variable name mappings currently present:
1715  void traverseVariableNames(int (*function)(const char *attr,
1716  const char *varname, void *data),
1717  void *data) const;
1718 
1719  /// increase the memory size of the attribute
1720  GA_Attribute *growPointCaptureAttribute(geo_NPairs num_added_pairs,
1721  CaptureType t = CAPTURE_BONE);
1722 
1725  {
1726  return getAttributes().cloneAttribute(
1728  src->getName(), *src, true);
1729  }
1732  const UT_StringHolder &n,
1733  const UT_Options *creation_args,
1734  const GA_AttributeOptions *attribute_options,
1735  const UT_StringRef &attribtype)
1736  {
1737  return createAttribute(GA_ATTRIB_POINT, scope, n,
1738  creation_args, attribute_options,attribtype);
1739  }
1742  const UT_Options *creation_args,
1743  const GA_AttributeOptions *attribute_options,
1744  const UT_StringRef &attribtype)
1745  {
1746  return createAttribute(GA_ATTRIB_POINT, n,
1747  creation_args, attribute_options,attribtype);
1748  }
1749 
1750  /// Replace old findPointAttribute(const char *name...) with
1751  /// findIntTuple(GA_ATTRIB_POINT, ...), findFloatTuple(),
1752  /// findStringTuple(), etc.
1755  { return findPointAttribute(src.getScope(),
1756  src.getName()); }
1759  { return findPointAttribute(src.getScope(),
1760  src.getName()); }
1761 
1762  /// Looks for a 3-float point attribute
1765  const UT_StringRef &n) const
1766  { return findFloatTuple(GA_ATTRIB_POINT, s, n, 3, 3); }
1769  { return findFloatTuple(GA_ATTRIB_POINT, n, 3, 3); }
1772  const UT_StringRef &n)
1773  { return findFloatTuple(GA_ATTRIB_POINT, s, n, 3, 3); }
1776  { return findFloatTuple(GA_ATTRIB_POINT, n, 3, 3); }
1777 
1780  const UT_StringRef &n,
1781  const GA_AttributeFilter *filter=nullptr)
1782  { destroyAttribute(GA_ATTRIB_POINT,scope, n, filter); }
1785  const GA_AttributeFilter *filter=nullptr)
1786  { destroyAttribute(GA_ATTRIB_POINT, n, filter); }
1787 
1788  bool promotePointAttrib(GA_AttributeScope scope,
1789  const UT_StringRef &name);
1792  { return promotePointAttrib(GA_SCOPE_PUBLIC, name); }
1793 
1796  {
1797  return getAttributes().cloneAttribute(
1799  src->getName(), *src, true);
1800  }
1803  const UT_Options *creation_args,
1804  const GA_AttributeOptions *attribute_options,
1805  const UT_StringRef &attribtype)
1806  {
1807  return createAttribute(GA_ATTRIB_VERTEX, scope, n,
1808  creation_args, attribute_options,attribtype);
1809  }
1812  const UT_Options *creation_args,
1813  const GA_AttributeOptions *attribute_options,
1814  const UT_StringRef &attribtype)
1815  {
1816  return createAttribute(GA_ATTRIB_VERTEX, n,
1817  creation_args, attribute_options,attribtype);
1818  }
1819 
1820  /// Replace old findVertexAttribute(const char *name...) with
1821  /// findIntTuple(GA_ATTRIB_VERTEX, ...), findFloatTuple(),
1822  /// findStringTuple(), etc.
1825  { return findVertexAttribute(src.getScope(),
1826  src.getName()); }
1829  { return findVertexAttribute(src.getScope(),
1830  src.getName()); }
1831 
1832  /// Looks for a 3-float vertex attribute
1835  const UT_StringRef &n) const
1836  { return findFloatTuple(GA_ATTRIB_VERTEX,s, n, 3, 3); }
1839  { return findFloatTuple(GA_ATTRIB_VERTEX, n, 3, 3); }
1842  const UT_StringRef &n)
1843  { return findFloatTuple(GA_ATTRIB_VERTEX,s, n, 3, 3); }
1846  { return findFloatTuple(GA_ATTRIB_VERTEX, n, 3, 3); }
1847 
1850  const UT_StringRef &n,
1851  const GA_AttributeFilter *filter=nullptr)
1852  { destroyAttribute(GA_ATTRIB_VERTEX,scope, n,filter); }
1855  const GA_AttributeFilter *filter=nullptr)
1856  { destroyAttribute(GA_ATTRIB_VERTEX, n, filter); }
1857 
1858  bool demoteVertexAttrib(GA_AttributeScope scope,
1859  const UT_StringRef &name);
1862  { return demoteVertexAttrib(GA_SCOPE_PUBLIC, name); }
1863 
1866  {
1867  return getAttributes().cloneAttribute(
1869  src->getName(), *src,true);
1870  }
1873  const UT_Options *creation_args,
1874  const GA_AttributeOptions *attribute_options,
1875  const UT_StringRef &attribtype)
1876  {
1877  return createAttribute(GA_ATTRIB_PRIMITIVE, scope,
1878  n, creation_args, attribute_options,attribtype);
1879  }
1882  const UT_Options *creation_args,
1883  const GA_AttributeOptions *attribute_options,
1884  const UT_StringRef &attribtype)
1885  {
1886  return createAttribute(GA_ATTRIB_PRIMITIVE, n,
1887  creation_args, attribute_options,attribtype);
1888  }
1889 
1890  /// Replace old findPrimAttribute(const char *name...) with
1891  /// findIntTuple(GA_ATTRIB_PRIMITIVE, ...), findFloatTuple(),
1892  /// findStringTuple(), etc.
1895  { return findPrimitiveAttribute(src.getScope(),
1896  src.getName()); }
1899  { return findPrimitiveAttribute(src.getScope(),
1900  src.getName()); }
1901 
1904  const UT_StringRef &n,
1905  const GA_AttributeFilter *filter=nullptr)
1906  {
1907  destroyAttribute(GA_ATTRIB_PRIMITIVE, scope, n,
1908  filter);
1909  }
1912  const GA_AttributeFilter *filter=nullptr)
1913  {
1914  destroyAttribute(GA_ATTRIB_PRIMITIVE, n, filter);
1915  }
1916 
1917  /// Note: if attrib already exists, will return pointer to existing
1918  /// attrib.
1921  {
1922  return getAttributes().cloneAttribute(
1924  src->getName(), *src, true);
1925  }
1928  const UT_StringHolder &n,
1929  const UT_Options *creation_args,
1930  const GA_AttributeOptions *attribute_options,
1931  const UT_StringRef &attribtype)
1932  {
1933  return createAttribute(GA_ATTRIB_DETAIL, scope, n,
1934  creation_args, attribute_options,attribtype);
1935  }
1938  const UT_Options *creation_args,
1939  const GA_AttributeOptions *attribute_options,
1940  const UT_StringRef &attribtype)
1941  {
1942  return createAttribute(GA_ATTRIB_DETAIL, n,
1943  creation_args, attribute_options,attribtype);
1944  }
1945 
1948  { return findGlobalAttribute(src.getScope(),
1949  src.getName()); }
1952  { return findGlobalAttribute(src.getScope(),
1953  src.getName()); }
1956  const UT_StringRef &n,
1957  const GA_AttributeFilter *filter=nullptr)
1958  { destroyAttribute(GA_ATTRIB_DETAIL,scope, n,filter); }
1961  const GA_AttributeFilter *filter=nullptr)
1962  { destroyAttribute(GA_ATTRIB_DETAIL, n, filter); }
1963 
1965  /// Query the internal structures:
1966  SYS_DEPRECATED_HDK(13.0)
1967  GEO_PrimList primitives()
1968  {
1969  return GEO_PrimList(getPrimitiveMap());
1970  }
1971  SYS_DEPRECATED_HDK(13.0)
1972  const GEO_PrimList primitives() const
1973  {
1974  return GEO_PrimList(getPrimitiveMap());
1975  }
1977 
1979  const GA_AttributeDict &pointAttribs() const
1980  { return getAttributes().getDict(
1981  GA_ATTRIB_POINT); }
1984  { return getAttributes().getDict(
1988  { return getAttributes().getDict(
1989  GA_ATTRIB_VERTEX); }
1991  const GA_AttributeDict &attribs() const
1992  { return getAttributes().getDict(
1993  GA_ATTRIB_DETAIL); }
1994 
1995  // Typedef for the GA_Detail::GB_MACRO_CAST static methods.
1997 
1998  bool hasMetaPrimitives() const;
1999  bool hasPastedPrimitives() const;
2000  bool hasQuadricPrimitives() const;
2001  bool hasParticlePrimitives() const;
2002  bool hasVolumePrimitives() const;
2003  bool hasChannelPrimitives() const;
2004  bool hasCameraPrimitives() const;
2005  bool hasTransformingPrimitives() const;
2006 
2007  /// Check to see whether the detail has any custom primitive types (i.e.
2008  /// non-factory primitives)
2009  bool hasCustomPrimitives() const;
2010 
2011  GA_Size getMetaCount() const;
2012  GA_Size getPastedCount() const;
2013  GA_Size getQuadricCount() const;
2014  GA_Size getParticleCount() const;
2015  GA_Size getVolumeCount() const;
2016 
2017  // This function will find the GEO_Standard_Attributes enum that
2018  // matches the provided string s.
2019  // true is returned on if a match is found; false if no match.
2020  bool getStandardAttributes(const char *s, GEO_Standard_Attributes &a);
2021 
2022  bool mergeCaptureProperties(
2023  GA_Attribute *my_atr,
2024  const GA_Attribute *src_atr,
2025  UT_IntArray &new_indices);
2026 
2027  /// Methods for dealing with attribute handles. It is important to note
2028  /// that the const methods return READ-ONLY handles which will fail when
2029  /// any write methods are called.
2030  SYS_DEPRECATED_HDK(13.0)
2031  GEO_AttributeHandle getPointAttribute (const char *attrib_name) const;
2032  SYS_DEPRECATED_HDK(13.0)
2033  GEO_AttributeHandle getPointAttribute (const char *attrib_name);
2034  SYS_DEPRECATED_HDK(13.0)
2035  GEO_AttributeHandle getPrimAttribute (const char *attrib_name) const;
2036  SYS_DEPRECATED_HDK(13.0)
2037  GEO_AttributeHandle getPrimAttribute (const char *attrib_name);
2038  SYS_DEPRECATED_HDK(13.0)
2039  GEO_AttributeHandle getVertexAttribute(const char *attrib_name) const;
2040  SYS_DEPRECATED_HDK(13.0)
2041  GEO_AttributeHandle getVertexAttribute(const char *attrib_name);
2042  SYS_DEPRECATED_HDK(13.0)
2043  GEO_AttributeHandle getDetailAttribute(const char *attrib_name) const;
2044  SYS_DEPRECATED_HDK(13.0)
2045  GEO_AttributeHandle getDetailAttribute(const char *attrib_name);
2046  SYS_DEPRECATED_HDK(13.0)
2047  GEO_AttributeHandle getAttribute(GA_AttributeOwner dict,
2048  const char *attrib_name) const;
2049  SYS_DEPRECATED_HDK(13.0)
2050  GEO_AttributeHandle getAttribute(GA_AttributeOwner dict,
2051  const char *attrib_name);
2052 
2053  /// Change the storage type from one type to another. For example, cast an
2054  /// integer attribute into a floating point attribute, or vice versa.
2055  /// Only some casting methods have been implemented, so it's quite likely
2056  /// that this method may fail.
2057  bool changeAttributeStorage(GA_AttributeOwner dict,
2058  const UT_StringRef &name,
2059  GA_Storage new_storage);
2060  bool changePointAttributeStorage(const UT_StringRef &nm, GA_Storage s);
2061  bool changeVertexAttributeStorage(const UT_StringRef &nm, GA_Storage s);
2062  bool changePrimAttributeStorage(const UT_StringRef &nm, GA_Storage s);
2063  bool changeDetailAttributeStorage(const UT_StringRef &nm, GA_Storage s);
2064 
2065  /// @{
2066  /// Convenience functions to set a detail attribute to a specific
2067  /// value, and also create the attribute if it doesn't exist.
2068  /// Values will only be assigned to the first N tuple components. For
2069  /// example, for strings, only the first string value will be set, while
2070  /// for a vector2, only the first 2 components will be set.
2071  /// @note Storing a ramp will call the save() method on the UT_Ramp and
2072  /// assign that string to the attribute.
2073  /// @note If the attribute already exists but is the wrong type, or the
2074  /// attribute has too small a tuple size, this method will fail.
2075  bool setDetailAttributeS(const UT_StringHolder &aname, const char *value);
2076  bool setDetailAttributeS(const UT_StringHolder &aname, const UT_StringArray &s);
2077  bool setDetailAttributeR(const UT_StringHolder &aname, const UT_Ramp &ramp);
2078  bool setDetailAttributeF(const UT_StringHolder &aname, float v);
2079  bool setDetailAttributeF(const UT_StringHolder &aname, float v1, float v2);
2080  bool setDetailAttributeF(const UT_StringHolder &aname, const UT_Vector2 &v);
2081  bool setDetailAttributeF(const UT_StringHolder &aname, const UT_Vector3 &v);
2082  bool setDetailAttributeF(const UT_StringHolder &aname, const UT_Vector4 &v);
2083  bool setDetailAttributeF(const UT_StringHolder &aname, const UT_Matrix3 &v);
2084  bool setDetailAttributeF(const UT_StringHolder &aname, const UT_Matrix4 &v);
2085  bool setDetailAttributeD(const UT_StringHolder &aname, double v);
2086  bool setDetailAttributeD(const UT_StringHolder &aname, double v1, double v2);
2087  bool setDetailAttributeD(const UT_StringHolder &aname, const UT_Vector2D &v);
2088  bool setDetailAttributeD(const UT_StringHolder &aname, const UT_Vector3D &v);
2089  bool setDetailAttributeD(const UT_StringHolder &aname, const UT_Vector4D &v);
2090  bool setDetailAttributeD(const UT_StringHolder &aname, const UT_Matrix3D &v);
2091  bool setDetailAttributeD(const UT_StringHolder &aname, const UT_Matrix4D &v);
2092  bool setDetailAttributeI(const UT_StringHolder &aname, int v);
2093  /// @}
2094 
2095  /// @{
2096  /// Convenience routines to retrieve a group of points referenced
2097  /// by a range/group of primitives. These routines assume that the point
2098  /// group pointer is not nullptr and return the size of the resulting point
2099  /// group.
2100  GA_Size getPointGroupAdjacentToPrimitiveGroup(
2101  const GA_PrimitiveGroup *in_prim_grp,
2102  GA_PointGroup *adj_pt_grp);
2103  GA_Size getPointGroupAdjacentToPrimitiveRange(
2104  const GA_Range &in_prim_rng,
2105  GA_PointGroup *adj_pt_rng);
2106  GA_Size getVertexGroupAdjacentToPrimitiveGroup(
2107  const GA_PrimitiveGroup *in_prim_grp,
2108  GA_VertexGroup *adj_vtx_grp);
2109  GA_Size getVertexGroupAdjacentToPrimitiveRange(
2110  const GA_Range &in_prim_rng,
2111  GA_VertexGroup *adj_vtx_rng);
2112  /// @}
2113 
2114 private:
2115  struct AdjacentPolygonData
2116  {
2117  GA_Offset myAdjacentPolygon;
2118 
2119  bool operator==(const AdjacentPolygonData &pad) const
2120  { return myAdjacentPolygon == pad.myAdjacentPolygon; }
2121  bool operator<(const AdjacentPolygonData &pad) const
2122  { return myAdjacentPolygon < pad.myAdjacentPolygon; }
2123  };
2124 
2125 public:
2126 
2127  struct PointAdjacencyData : public AdjacentPolygonData
2128  {
2130  };
2131 
2132  struct EdgeAdjacencyData : public AdjacentPolygonData
2133  {
2137  };
2138 
2141 
2142  // Get an array of PointAdjacencyData structs representing the polygons
2143  // adjacent to a polygon (poly_off) through a point. Notice that
2144  // PointAdjacencyData contains a point shared by the two polygons
2145  GA_Size getPointAdjacentPolygons(GEO_PointAdjArray &adjacencies,
2146  GA_Offset poly_off) const;
2147 
2148  // Get an array of polygon Offsets adjacent to a polygon (poly_off)
2149  // through a point
2150  GA_Size getPointAdjacentPolygons(GA_OffsetArray &polygons,
2151  GA_Offset poly_off) const;
2152 
2153 
2154  // Get an array of EdgeAdjacencyData structs representing the polygons
2155  // adjacent to a polygon (poly_off) through an edge. Notice that
2156  // EdgeAdjacencyData contains additional information about the type of
2157  // adjacency
2158  GA_Size getEdgeAdjacentPolygons(GEO_EdgeAdjArray &adjacencies,
2159  GA_Offset poly_off) const;
2160 
2161  // Get an array of polygon Offsets adjacent to a polygon (poly_off)
2162  // through an edge
2163  GA_Size getEdgeAdjacentPolygons(GA_OffsetArray &polygons,
2164  GA_Offset poly_off) const;
2165 
2166  /// Searches primitive list for a primitive whose name attribute
2167  /// matches the given name.
2168  /// UT_String::multiMatch is used for comparison so searching
2169  /// for Cd.* will return as expected.
2170  /// Returns the matchnumberth matching primitive.
2171  const GEO_Primitive *findPrimitiveByName(const char *nametomatch,
2174  const char *nameattrib="name",
2175  int matchnumber = 0) const;
2176  GEO_Primitive *findPrimitiveByName(const char *nametomatch,
2179  const char *nameattrib="name",
2180  int matchnumber = 0);
2181 
2182  /// Like findPrimitiveByName, but adds all matching primitives to the list
2183  void findAllPrimitivesByName(
2185  const char *nametomatch,
2188  const char *nameattrib="name") const;
2189  void findAllPrimitivesByName(
2190  UT_Array<GEO_Primitive*> &primlist,
2191  const char *nametomatch,
2194  const char *nameattrib="name");
2195 
2196  /// Merges attributes from 'src' into this detail. Capture attributes for
2197  /// newly merged points are also updated. Newly merged points are
2198  /// identified by point numbers beginning from 'num_pts_prev'.
2199  void mergeDetailAttributes( const GEO_Detail &src,
2200  int num_pts_prev );
2201 
2203  { destroyElementGroup(g); }
2205  { destroyElementGroup(g); }
2207  { destroyElementGroup(g); }
2208  bool destroyPointGroup(const char *name)
2209  { return
2210  destroyElementGroup(GA_ATTRIB_POINT, name); }
2211  bool destroyPrimitiveGroup(const char *name)
2212  { return
2213  destroyElementGroup(GA_ATTRIB_PRIMITIVE, name); }
2214  bool destroyVertexGroup(const char *name)
2215  { return
2216  destroyElementGroup(GA_ATTRIB_VERTEX, name); }
2217 
2218  /// Attempt to copy groups from the source detail. If override is true,
2219  /// existing groups with the same names as src groups are cleared, else
2220  /// existing groups are not affected. The status (ordered/unordered,
2221  /// internal/persistent) of the source group is also copied.
2222  ///
2223  /// Membership is matched by element index for point and primitive groups,
2224  /// by primitive and local vertex index for vertex groups, and by element
2225  /// index validated by adjacency for edge groups.
2226  void mergeGroups(const GEO_Detail &src, bool override,
2227  unsigned mask = GA_GMASK_FULL_MASK);
2228  GA_PointGroup *mergeGroup(const GEO_Detail &src,
2229  const GA_PointGroup &group,
2230  bool override = true);
2231  GA_PrimitiveGroup *mergeGroup(const GEO_Detail &src,
2232  const GA_PrimitiveGroup &group,
2233  bool override = true);
2234  GA_VertexGroup *mergeGroup(const GEO_Detail &src,
2235  const GA_VertexGroup &group,
2236  GA_OffsetArray &map_cache,
2237  bool override = true);
2238  GA_EdgeGroup *mergeGroup(const GEO_Detail &src,
2239  const GA_EdgeGroup &group,
2240  bool override = true);
2241 
2242 protected:
2244  registerIntrinsics(GA_PrimitiveFactory &factory);
2245 
2246  GA_Size localIntrinsicTupleSize(
2247  GA_IntrinsicEval &eval) const override;
2248  GA_Size localGetIntrinsicS(GA_IntrinsicEval &eval,
2249  UT_String &value) const override;
2250  GA_Size localGetIntrinsicSA(GA_IntrinsicEval &eval,
2251  UT_StringArray &value) const override;
2252  GA_Size localGetIntrinsicD(GA_IntrinsicEval &eval,
2253  UT_OptionsHolder &value) const override;
2254  GA_Size localGetIntrinsicDA(GA_IntrinsicEval &eval,
2256  ) const override;
2257  GA_Size localGetIntrinsicI(GA_IntrinsicEval &eval,
2258  int64 *value, GA_Size size) const override;
2259  GA_Size localGetIntrinsicF(GA_IntrinsicEval &eval,
2260  fpreal64 *value, GA_Size size) const override;
2261  GA_Size localSetIntrinsicS(GA_IntrinsicEval &eval,
2262  const char *value) override;
2263  GA_Size localSetIntrinsicSA(GA_IntrinsicEval &eval,
2264  const UT_StringArray &value) override;
2265  GA_Size localSetIntrinsicSS(GA_IntrinsicEval &eval,
2266  const char **value, GA_Size size) override;
2267  GA_Size localSetIntrinsicDA(GA_IntrinsicEval &eval,
2269  ) override;
2270  GA_Size localSetIntrinsicDS(GA_IntrinsicEval &eval,
2271  const UT_OptionsHolder *value,
2272  GA_Size size) override;
2273  GA_Size localSetIntrinsicI(GA_IntrinsicEval &eval,
2274  const int64 *value, GA_Size size) override;
2275  GA_Size localSetIntrinsicF(GA_IntrinsicEval &eval,
2276  const fpreal64 *value, GA_Size size) override;
2277 
2278  GA_Detail::IOStatus saveH9Stream(std::ostream& os, bool binary,
2279  const GA_SaveOptions *options) const;
2280  GA_Detail::IOStatus loadH9(UT_IStream &is, const GA_LoadOptions *options);
2281 
2282  /// Simple stat of an H9 file. This only fills out the point/prim counts
2283  /// This assumes the magic number (32-bits) has already been read from the
2284  /// file.
2285  static GA_Detail::IOStatus statH9Basic(UT_IStream &is, GA_Stat &sbuf,
2286  bool binstream);
2287 
2288  bool convertIndexPairDataFromH9();
2289  bool convertIndexPairDataToH9();
2290 
2291  template<typename FLOAT_T>
2292  void transformInternal(const UT_Matrix4T<FLOAT_T> &mat,
2293  const GA_Range &prim_range,
2294  const GA_Range &pt_range,
2295  bool just_P,
2296  bool keep_vector_lengths,
2297  bool check_pasting,
2298  bool neg_determinant_flipvector,
2299  bool update_ptnormals,
2300  GEO_Delta *geodelta,
2301  bool updateaffectednormals,
2302  const char *attribpattern);
2303 
2304 private:
2305  GA_ElementGroup *mergeElementGroup(const GEO_Detail &src,
2306  const GA_ElementGroup &group,
2307  bool override = true);
2308 
2309 public:
2310  /// Some common methods for the standard guys
2311  GA_Attribute *addAttribute(const UT_StringHolder &name,
2312  const UT_Options *creation_args,
2313  const GA_AttributeOptions *attribute_options,
2314  const UT_StringRef &attribtype,
2315  GA_AttributeOwner who,
2317  GA_Attribute *growTuple(GA_AttributeOwner owner,
2318  GA_AttributeScope scope,
2319  const UT_StringRef &name,
2320  int added_size);
2323  const UT_StringRef &name,
2324  int added_size)
2325  {
2326  return growTuple(owner, GA_SCOPE_PUBLIC, name, added_size);
2327  }
2328  void destroyAttribute(GA_AttributeOwner owner,
2329  GA_AttributeScope scope,
2330  const UT_StringRef &name,
2331  const GA_AttributeFilter *filter = 0);
2334  const UT_StringRef &name,
2335  const GA_AttributeFilter *filter = 0)
2336  {
2337  destroyAttribute(owner, GA_SCOPE_PUBLIC, name,
2338  filter);
2339  }
2340 
2341  /// Convenience method to find floating point, int, or string tuples of a
2342  /// specified size range. If max_size or min_size are <= 0, then we won't
2343  /// perform the corresponding size check.
2344  /// @{
2345  const GA_Attribute *findFloatTuple(GA_AttributeOwner owner,
2346  GA_AttributeScope scope,
2347  const UT_StringRef &name,
2348  int min_size=1, int max_size=-1) const;
2351  const UT_StringRef &name,
2352  int min_size=1, int max_size=-1) const
2353  {
2354  return findFloatTuple(owner, GA_SCOPE_PUBLIC, name,
2355  min_size, max_size);
2356  }
2357  GA_Attribute *findFloatTuple(GA_AttributeOwner owner,
2358  GA_AttributeScope scope,
2359  const UT_StringRef &name,
2360  int min_size=1, int max_size=-1);
2363  const UT_StringRef &name,
2364  int min_size=1, int max_size=-1)
2365  {
2366  return findFloatTuple(owner, GA_SCOPE_PUBLIC, name,
2367  min_size, max_size);
2368  }
2369  const GA_Attribute *findIntTuple(GA_AttributeOwner owner,
2370  GA_AttributeScope scope,
2371  const UT_StringRef &name,
2372  int min_size=1, int max_size=-1) const;
2375  const UT_StringRef &name,
2376  int min_size=1, int max_size=-1) const
2377  {
2378  return findIntTuple(owner, GA_SCOPE_PUBLIC, name,
2379  min_size, max_size);
2380  }
2381  GA_Attribute *findIntTuple(GA_AttributeOwner owner,
2382  GA_AttributeScope scope,
2383  const UT_StringRef &name,
2384  int min_size=1, int max_size=-1);
2387  const UT_StringRef &name,
2388  int min_size=1, int max_size=-1)
2389  {
2390  return findIntTuple(owner, GA_SCOPE_PUBLIC, name,
2391  min_size, max_size);
2392  }
2393  /// findNumericTuple will find either float or int.
2394  const GA_Attribute *findNumericTuple(GA_AttributeOwner owner,
2395  GA_AttributeScope scope,
2396  const UT_StringRef &name,
2397  int min_size=1, int max_size=-1) const;
2400  const UT_StringRef &name,
2401  int min_size=1, int max_size=-1) const
2402  {
2403  return findNumericTuple(owner, GA_SCOPE_PUBLIC,
2404  name, min_size, max_size);
2405  }
2406  /// findNumericTuple will find either float or int.
2407  GA_Attribute *findNumericTuple(GA_AttributeOwner owner,
2408  GA_AttributeScope scope,
2409  const UT_StringRef &name,
2410  int min_size=1, int max_size=-1);
2413  const UT_StringRef &name,
2414  int min_size=1, int max_size=-1)
2415  {
2416  return findNumericTuple(owner, GA_SCOPE_PUBLIC,
2417  name, min_size, max_size);
2418  }
2419  const GA_Attribute *findStringTuple(GA_AttributeOwner owner,
2420  GA_AttributeScope scope,
2421  const UT_StringRef &name,
2422  int min_size=1, int max_size=-1) const;
2425  const UT_StringRef &name,
2426  int min_size=1, int max_size=-1) const
2427  {
2428  return findStringTuple(owner, GA_SCOPE_PUBLIC,
2429  name, min_size, max_size);
2430  }
2431  GA_Attribute *findStringTuple(GA_AttributeOwner owner,
2432  GA_AttributeScope scope,
2433  const UT_StringRef &name,
2434  int min_size=1, int max_size=-1);
2437  const UT_StringRef &name,
2438  int min_size=1, int max_size=-1)
2439  {
2440  return findStringTuple(owner, GA_SCOPE_PUBLIC,
2441  name, min_size, max_size);
2442  }
2443 
2444  const GA_Attribute *findDictTuple(GA_AttributeOwner owner,
2445  GA_AttributeScope scope,
2446  const UT_StringRef &name,
2447  int min_size=1, int max_size=-1) const;
2450  const UT_StringRef &name,
2451  int min_size=1, int max_size=-1) const
2452  {
2453  return findDictTuple(owner, GA_SCOPE_PUBLIC,
2454  name, min_size, max_size);
2455  }
2456  GA_Attribute *findDictTuple(GA_AttributeOwner owner,
2457  GA_AttributeScope scope,
2458  const UT_StringRef &name,
2459  int min_size=1, int max_size=-1);
2462  const UT_StringRef &name,
2463  int min_size=1, int max_size=-1)
2464  {
2465  return findDictTuple(owner, GA_SCOPE_PUBLIC,
2466  name, min_size, max_size);
2467  }
2468 
2469  const GA_Attribute *findIndexPair(GA_AttributeOwner owner,
2470  GA_AttributeScope scope,
2471  const UT_StringRef &name) const;
2474  const UT_StringRef &name) const
2475  {
2476  return findIndexPair(owner, GA_SCOPE_PUBLIC, name);
2477  }
2478  GA_Attribute *findIndexPair(GA_AttributeOwner owner,
2479  GA_AttributeScope scope,
2480  const UT_StringRef &name);
2483  const UT_StringRef &name)
2484  {
2485  return findIndexPair(owner, GA_SCOPE_PUBLIC, name);
2486  }
2487  const GA_Attribute *findFloatArray(GA_AttributeOwner owner,
2488  GA_AttributeScope scope,
2489  const UT_StringRef &name,
2490  int min_size=1, int max_size=-1) const;
2493  const UT_StringRef &name,
2494  int min_size=1, int max_size=-1) const
2495  {
2496  return findFloatArray(owner, GA_SCOPE_PUBLIC, name,
2497  min_size, max_size);
2498  }
2499  GA_Attribute *findFloatArray(GA_AttributeOwner owner,
2500  GA_AttributeScope scope,
2501  const UT_StringRef &name,
2502  int min_size=1, int max_size=-1);
2505  const UT_StringRef &name,
2506  int min_size=1, int max_size=-1)
2507  {
2508  return findFloatArray(owner, GA_SCOPE_PUBLIC, name,
2509  min_size, max_size);
2510  }
2511  const GA_Attribute *findIntArray(GA_AttributeOwner owner,
2512  GA_AttributeScope scope,
2513  const UT_StringRef &name,
2514  int min_size=1, int max_size=-1) const;
2517  const UT_StringRef &name,
2518  int min_size=1, int max_size=-1) const
2519  {
2520  return findIntArray(owner, GA_SCOPE_PUBLIC, name,
2521  min_size, max_size);
2522  }
2523  GA_Attribute *findIntArray(GA_AttributeOwner owner,
2524  GA_AttributeScope scope,
2525  const UT_StringRef &name,
2526  int min_size=1, int max_size=-1);
2529  const UT_StringRef &name,
2530  int min_size=1, int max_size=-1)
2531  {
2532  return findIntArray(owner, GA_SCOPE_PUBLIC, name,
2533  min_size, max_size);
2534  }
2535  const GA_Attribute *findNumericArray(GA_AttributeOwner owner,
2536  GA_AttributeScope scope,
2537  const UT_StringRef &name,
2538  int min_size=1, int max_size=-1) const;
2541  const UT_StringRef &name,
2542  int min_size=1, int max_size=-1) const
2543  {
2544  return findNumericArray(owner, GA_SCOPE_PUBLIC, name,
2545  min_size, max_size);
2546  }
2547  GA_Attribute *findNumericArray(GA_AttributeOwner owner,
2548  GA_AttributeScope scope,
2549  const UT_StringRef &name,
2550  int min_size=1, int max_size=-1);
2553  const UT_StringRef &name,
2554  int min_size=1, int max_size=-1)
2555  {
2556  return findNumericArray(owner, GA_SCOPE_PUBLIC, name,
2557  min_size, max_size);
2558  }
2559  const GA_Attribute *findStringArray(GA_AttributeOwner owner,
2560  GA_AttributeScope scope,
2561  const UT_StringRef &name,
2562  int min_size=1, int max_size=-1) const;
2565  const UT_StringRef &name,
2566  int min_size=1, int max_size=-1) const
2567  {
2568  return findStringArray(owner, GA_SCOPE_PUBLIC, name,
2569  min_size, max_size);
2570  }
2571  GA_Attribute *findStringArray(GA_AttributeOwner owner,
2572  GA_AttributeScope scope,
2573  const UT_StringRef &name,
2574  int min_size=1, int max_size=-1);
2577  const UT_StringRef &name,
2578  int min_size=1, int max_size=-1)
2579  {
2580  return findStringArray(owner, GA_SCOPE_PUBLIC, name,
2581  min_size, max_size);
2582  }
2583  const GA_Attribute *findDictArray(GA_AttributeOwner owner,
2584  GA_AttributeScope scope,
2585  const UT_StringRef &name,
2586  int min_size=1, int max_size=-1) const;
2589  const UT_StringRef &name,
2590  int min_size=1, int max_size=-1) const
2591  {
2592  return findDictArray(owner, GA_SCOPE_PUBLIC, name,
2593  min_size, max_size);
2594  }
2595  GA_Attribute *findDictArray(GA_AttributeOwner owner,
2596  GA_AttributeScope scope,
2597  const UT_StringRef &name,
2598  int min_size=1, int max_size=-1);
2601  const UT_StringRef &name,
2602  int min_size=1, int max_size=-1)
2603  {
2604  return findDictArray(owner, GA_SCOPE_PUBLIC, name,
2605  min_size, max_size);
2606  }
2607  /// @}
2608 
2609  /// @{
2610  /// Convenience method for adding a float, integer or string tuple
2611  /// attribute.
2612  ///
2613  /// If there's an existing attribute of the same name, the
2614  /// GA_ReuseStrategy will be used. By default, this will return
2615  /// the existing attribute if it is the same type. If not, it will
2616  /// try to replace it with a new one and copy the old data over.
2617  ///
2618  /// The attribute storage will be determined by the @c storage parameter.
2619  /// For example, if it's GA_STORE_REAL32 or GA_STORE_REAL16, a floating
2620  /// point tuple will be added. An integer tuple would be created for
2621  /// GA_STORE_INT64 and a string tuple for GA_STORE_STRING.
2622  ///
2623  /// The defaults will be ignored for string attributes.
2624  /// @note If you have a GA_StorageClass, you can call
2625  /// @c GAgetDefaultStorage(storageclass);
2626  GA_Attribute *addTuple(GA_Storage storage,
2627  GA_AttributeOwner owner,
2628  GA_AttributeScope scope,
2629  const UT_StringHolder &name,
2630  int tuple_size,
2631  const GA_Defaults &defaults = GA_Defaults(0.0),
2632  const UT_Options *creation_args = 0,
2633  const GA_AttributeOptions *attribute_options = 0,
2634  const GA_ReuseStrategy &reuse =
2635  GA_ReuseStrategy());
2638  GA_AttributeOwner owner,
2639  const UT_StringHolder &name,
2640  int tuple_size,
2641  const GA_Defaults &defaults = GA_Defaults(0.0),
2642  const UT_Options *creation_args = 0,
2643  const GA_AttributeOptions *attribute_options = 0,
2644  const GA_ReuseStrategy &reuse =
2645  GA_ReuseStrategy())
2646  {
2647  return addTuple(storage,
2648  owner,
2650  name,
2651  tuple_size,
2652  defaults,
2653  creation_args,
2654  attribute_options,
2655  reuse);
2656  }
2657  /// @}
2658 
2659  /// @{
2660  /// Convenience method to add a new floating point, int or string tuple
2661  /// attribute.
2662  ///
2663  /// If there's an existing attribute of the same name, the
2664  /// GA_ReuseStrategy will be used. By default, this will return
2665  /// the existing attribute if it is the same type. If not, it will
2666  /// try to replace it with a new one and copy the old data over.
2667  GA_Attribute *addFloatTuple(GA_AttributeOwner owner,
2668  GA_AttributeScope scope,
2669  const UT_StringHolder &name,
2670  int tuple_size,
2671  const GA_Defaults &defaults = GA_Defaults(0.0),
2672  const UT_Options *creation_args=0,
2673  const GA_AttributeOptions *attribute_options=0,
2674  GA_Storage storage = GA_STORE_REAL32,
2675  const GA_ReuseStrategy &reuse
2676  = GA_ReuseStrategy());
2679  const UT_StringHolder &name,
2680  int tuple_size,
2681  const GA_Defaults &defaults = GA_Defaults(0.0),
2682  const UT_Options *creation_args=0,
2683  const GA_AttributeOptions *attribute_options=0,
2684  GA_Storage storage = GA_STORE_REAL32,
2685  const GA_ReuseStrategy &reuse
2686  = GA_ReuseStrategy())
2687  {
2688  return addFloatTuple(owner, GA_SCOPE_PUBLIC, name,
2689  tuple_size, defaults,
2690  creation_args,
2691  attribute_options,
2692  storage, reuse);
2693  }
2694  GA_Attribute *addIntTuple(GA_AttributeOwner owner,
2695  GA_AttributeScope scope,
2696  const UT_StringHolder &name,
2697  int tuple_size,
2698  const GA_Defaults &defaults = GA_Defaults(0),
2699  const UT_Options *creation_args=0,
2700  const GA_AttributeOptions *attribute_options=0,
2701  GA_Storage storage = GA_STORE_INT32,
2702  const GA_ReuseStrategy &reuse
2703  = GA_ReuseStrategy());
2706  const UT_StringHolder &name,
2707  int tuple_size,
2708  const GA_Defaults &defaults = GA_Defaults(0),
2709  const UT_Options *creation_args=0,
2710  const GA_AttributeOptions *attribute_options=0,
2711  GA_Storage storage = GA_STORE_INT32,
2712  const GA_ReuseStrategy &reuse
2713  = GA_ReuseStrategy())
2714  {
2715  return addIntTuple(owner, GA_SCOPE_PUBLIC, name,
2716  tuple_size, defaults,
2717  creation_args,
2718  attribute_options,
2719  storage, reuse);
2720  }
2721 
2722  GA_Attribute *addStringTuple(GA_AttributeOwner owner,
2723  GA_AttributeScope scope,
2724  const UT_StringHolder &name,
2725  int tuple_size,
2726  const UT_Options *creation_args=0,
2727  const GA_AttributeOptions *attribute_options=0,
2728  const GA_ReuseStrategy &reuse
2729  = GA_ReuseStrategy());
2732  const UT_StringHolder &name,
2733  int tuple_size,
2734  const UT_Options *creation_args=0,
2735  const GA_AttributeOptions *attribute_options=0,
2736  const GA_ReuseStrategy &reuse
2737  = GA_ReuseStrategy())
2738  {
2739  return addStringTuple(owner, GA_SCOPE_PUBLIC,
2740  name, tuple_size, creation_args,
2741  attribute_options, reuse);
2742  }
2743 
2744  GA_Attribute *addDictTuple(GA_AttributeOwner owner,
2745  GA_AttributeScope scope,
2746  const UT_StringHolder &name,
2747  int tuple_size,
2748  const UT_Options *creation_args=0,
2749  const GA_AttributeOptions *attribute_options=0,
2750  const GA_ReuseStrategy &reuse
2751  = GA_ReuseStrategy());
2754  const UT_StringHolder &name,
2755  int tuple_size,
2756  const UT_Options *creation_args=0,
2757  const GA_AttributeOptions *attribute_options=0,
2758  const GA_ReuseStrategy &reuse
2759  = GA_ReuseStrategy())
2760  {
2761  return addDictTuple(owner, GA_SCOPE_PUBLIC,
2762  name, tuple_size, creation_args,
2763  attribute_options, reuse);
2764  }
2765  /// @}
2766 
2767  /// @{
2768  /// Convenience method to add a new floating point, or int array
2769  /// attribute.
2770  ///
2771  /// If there's an existing attribute of the same name, the
2772  /// GA_ReuseStrategy will be used. By default, this will return
2773  /// the existing attribute if it is the same type. If not, it will
2774  /// try to replace it with a new one and copy the old data over.
2775  GA_Attribute *addFloatArray(GA_AttributeOwner owner,
2776  GA_AttributeScope scope,
2777  const UT_StringHolder &name,
2778  int tuple_size = 1,
2779  const UT_Options *creation_args=0,
2780  const GA_AttributeOptions *attribute_options=0,
2781  GA_Storage storage = GA_STORE_REAL32,
2782  const GA_ReuseStrategy &reuse
2783  = GA_ReuseStrategy());
2786  const UT_StringHolder &name,
2787  int tuple_size = 1,
2788  const UT_Options *creation_args=0,
2789  const GA_AttributeOptions *attribute_options=0,
2790  GA_Storage storage = GA_STORE_REAL32,
2791  const GA_ReuseStrategy &reuse
2792  = GA_ReuseStrategy())
2793  {
2794  return addFloatArray(owner, GA_SCOPE_PUBLIC, name,
2795  tuple_size,
2796  creation_args,
2797  attribute_options,
2798  storage, reuse);
2799  }
2800  GA_Attribute *addIntArray(GA_AttributeOwner owner,
2801  GA_AttributeScope scope,
2802  const UT_StringHolder &name,
2803  int tuple_size = 1,
2804  const UT_Options *creation_args=0,
2805  const GA_AttributeOptions *attribute_options=0,
2806  GA_Storage storage = GA_STORE_INT32,
2807  const GA_ReuseStrategy &reuse
2808  = GA_ReuseStrategy());
2811  const UT_StringHolder &name,
2812  int tuple_size = 1,
2813  const UT_Options *creation_args=0,
2814  const GA_AttributeOptions *attribute_options=0,
2815  GA_Storage storage = GA_STORE_INT32,
2816  const GA_ReuseStrategy &reuse
2817  = GA_ReuseStrategy())
2818  {
2819  return addIntArray(owner, GA_SCOPE_PUBLIC, name,
2820  tuple_size,
2821  creation_args,
2822  attribute_options,
2823  storage, reuse);
2824  }
2825  GA_Attribute *addStringArray(GA_AttributeOwner owner,
2826  GA_AttributeScope scope,
2827  const UT_StringHolder &name, int tuple_size=1,
2828  const UT_Options *creation_args=0,
2829  const GA_AttributeOptions *attribute_options=0,
2830  GA_Storage storage = GA_STORE_STRING,
2831  const GA_ReuseStrategy &reuse
2832  = GA_ReuseStrategy());
2835  const UT_StringHolder &name, int tuple_size=1,
2836  const UT_Options *creation_args=0,
2837  const GA_AttributeOptions *attribute_options=0,
2838  GA_Storage storage = GA_STORE_STRING,
2839  const GA_ReuseStrategy &reuse
2840  = GA_ReuseStrategy())
2841  {
2842  return addStringArray(owner, GA_SCOPE_PUBLIC, name,
2843  tuple_size,
2844  creation_args,
2845  attribute_options,
2846  storage, reuse);
2847  }
2848  GA_Attribute *addDictArray(GA_AttributeOwner owner,
2849  GA_AttributeScope scope,
2850  const UT_StringHolder &name, int tuple_size=1,
2851  const UT_Options *creation_args=0,
2852  const GA_AttributeOptions *attribute_options=0,
2853  GA_Storage storage = GA_STORE_STRING,
2854  const GA_ReuseStrategy &reuse
2855  = GA_ReuseStrategy());
2858  const UT_StringHolder &name, int tuple_size=1,
2859  const UT_Options *creation_args=0,
2860  const GA_AttributeOptions *attribute_options=0,
2861  GA_Storage storage = GA_STORE_STRING,
2862  const GA_ReuseStrategy &reuse
2863  = GA_ReuseStrategy())
2864  {
2865  return addDictArray(owner, GA_SCOPE_PUBLIC, name,
2866  tuple_size,
2867  creation_args,
2868  attribute_options,
2869  storage, reuse);
2870  }
2871  /// @}
2872 
2873  /// Magic number for ASCII geometry files
2874  static inline int asciiMagicH9()
2875  {
2876  return (('P'<<24) + ('G'<<16) + ('E'<<8) + 'O');
2877  }
2878  /// Magic number for binary geometry files
2879  static inline int binaryMagicH9()
2880  {
2881  return (('B'<<24) + ('g'<<16) + ('e'<<8) + 'o');
2882  }
2883 
2884 private:
2885  bool loadPointsH9(UT_IStream &is, int count,
2887  bool savePointsH9(std::ostream &os, bool binary,
2888  const UT_Array<GA_AttribSaveDataH9> &) const;
2889  bool savePointH9(std::ostream &os, bool binary, GA_Offset offset,
2890  const UT_Array<GA_AttribSaveDataH9> &) const;
2891  bool saveExtraH9(std::ostream &os, bool binary,
2892  const UT_Array<const GA_Primitive*> &) const;
2893  bool loadExtraH9(UT_IStream &is);
2894  bool loadVersionH9(UT_IStream &is, int binary);
2895 
2896 //
2897 // Friends
2898  friend std::ostream &operator<<(std::ostream &os, const GEO_Detail &d)
2899  {
2900  d.saveClassic(
2901  os, /*binary*/ false, /*options*/ nullptr);
2902  return os;
2903  }
2904 
2905  friend class GEO_IOTable; // For loadH9/saveH9
2906  friend class GU_IOClassic; // For loadH9/saveH9
2907 
2908 protected:
2909 
2910  /// This is here just so that GA_AttributeSet::jsonSave() can call
2911  /// GEOcomputeNormals()
2912  void privateComputeNormal(
2913  const GA_RWHandleV3 &normalattrib,
2914  const GA_Group *group,
2915  const float cuspangledegrees,
2916  const int method) const override;
2917 
2918 // The compiler reports some deprecated overrides here
2920 };
2922 
2923 #endif
void destroyPrimitiveGroup(GA_PrimitiveGroup *g)
Definition: GEO_Detail.h:2204
virtual void clearCaches()
Definition: GA_Detail.h:1952
SYS_FORCE_INLINE GA_Attribute * addIntArray(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size=1, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_INT32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2810
SYS_FORCE_INLINE const GA_Attribute * findStringTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2424
Definition of a geometry attribute.
Definition: GA_Attribute.h:203
SYS_FORCE_INLINE GA_Attribute * addPointAttrib(const GA_Attribute *src)
Definition: GEO_Detail.h:1724
SYS_FORCE_INLINE const GA_Attribute * findNumericArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2540
void incrementMetaCacheCount()
Definition: GA_Detail.h:2422
Specify when and how to reuse an existing attribute.
GLenum GLint * range
Definition: glcorearb.h:1925
SYS_FORCE_INLINE const GA_Attribute * findPointVectorAttrib(GA_AttributeScope s, const UT_StringRef &n) const
Looks for a 3-float point attribute.
Definition: GEO_Detail.h:1764
SYS_FORCE_INLINE GA_Attribute * findNumericTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2412
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
SYS_FORCE_INLINE void destroyGlobalAttrib(GA_AttributeScope scope, const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1955
Axis-aligned bounding box (AABB).
Definition: GEO_Detail.h:41
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:632
SYS_FORCE_INLINE void destroyPointAttrib(GA_AttributeScope scope, const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1779
SYS_FORCE_INLINE GA_Attribute * findIntTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2386
GEO_Capture_Bone_Property
Definition: GEO_Detail.h:205
Class which stores the default values for a GA_Attribute.
Definition: GA_Defaults.h:32
void
Definition: png.h:1083
GEO_Capture_Cloth_Property
Definition: GEO_Detail.h:234
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
SYS_FORCE_INLINE const GA_Attribute * findDictTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2449
SYS_FORCE_INLINE GA_Attribute * addDictArray(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size=1, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_STRING, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2857
GA_DataIdStrategy
Definition: GA_Types.h:218
const GLdouble * v
Definition: glcorearb.h:837
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
Transformation order of scales, rotates, and translates.
Definition: UT_XformOrder.h:23
SYS_FORCE_INLINE GA_Attribute * addPrimAttrib(const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1881
GLsizei const GLfloat * value
Definition: glcorearb.h:824
void clearAndDestroy()
Clear all the points/primitives out of this detail.
Definition: GEO_Detail.h:268
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
SYS_FORCE_INLINE GA_Attribute * addTuple(GA_Storage storage, GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2637
SYS_FORCE_INLINE GA_Attribute * addVertexAttrib(GA_AttributeScope scope, const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1802
SYS_FORCE_INLINE void destroyVertexAttrib(GA_AttributeScope scope, const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1849
GLboolean GLboolean g
Definition: glcorearb.h:1222
bool deletePrimitive(GA_Primitive &prim, bool and_points=false)
Definition: GEO_Detail.h:1242
SYS_FORCE_INLINE GA_Attribute * findGlobalAttrib(const GA_Attribute &src)
Definition: GEO_Detail.h:1951
SYS_FORCE_INLINE GA_Attribute * findIndexPair(GA_AttributeOwner owner, const UT_StringRef &name)
Definition: GEO_Detail.h:2482
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
SYS_FORCE_INLINE GA_AttributeScope getScope() const
Definition: GA_Attribute.h:217
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
SYS_FORCE_INLINE GA_Attribute * findStringTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2436
Class used to map H9 geometry files to a form used by GA.
Definition: GA_AIFFileH9.h:318
void destroyVertexGroup(GA_VertexGroup *g)
Definition: GEO_Detail.h:2206
IOStatus saveClassic(const char *, const GA_SaveOptions *) const
**But if you need a result
Definition: thread.h:622
SYS_FORCE_INLINE const GA_Attribute * findFloatTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2350
Standard user attribute level.
Definition: GA_Types.h:154
GA_Size deletePoints(const GA_Range &range, GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES)
Definition: GEO_Detail.h:1237
static int binaryMagicH9()
Magic number for binary geometry files.
Definition: GEO_Detail.h:2879
UT_Vector3T< FLOAT_T > myUpVector
Definition: GEO_Detail.h:814
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
Definition: GA_Types.h:662
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:243
GA_Size deletePrimitives(const GA_Range &range, bool and_points=false)
Definition: GEO_Detail.h:1240
virtual int64 getMemoryUsage(bool inclusive) const
Compute memory usage (includes all shared memory)
GEO_Capture_Wire_Property
Definition: GEO_Detail.h:228
GA_Offset appendPointCopy(GA_Offset src)
Definition: GEO_Detail.h:1182
GA_DestroyPointMode
Definition: GA_Detail.h:651
void pad(T &out, int n)
Definition: ImfXdr.h:407
void removeVariableName(const char *varname)
Definition: GEO_Detail.h:1708
A range of elements in an index-map.
Definition: GA_Range.h:42
GLenum GLuint GLint GLint layer
Definition: glcorearb.h:1299
SYS_FORCE_INLINE const GA_Attribute * findVertexAttrib(const GA_Attribute &src) const
Definition: GEO_Detail.h:1824
SYS_FORCE_INLINE GA_Attribute * findDictArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2600
SYS_FORCE_INLINE const UT_StringHolder & getName() const
Definition: GA_Attribute.h:292
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
SYS_FORCE_INLINE GEO_Primitive * getGEOPrimitive(GA_Offset primoff)
Definition: GEO_Detail.h:1197
SYS_FORCE_INLINE GA_Attribute * addPrimAttrib(GA_AttributeScope scope, const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1872
double fpreal64
Definition: SYS_Types.h:201
SYS_FORCE_INLINE GA_Attribute * findPrimAttrib(const GA_Attribute &src)
Definition: GEO_Detail.h:1898
SYS_FORCE_INLINE void destroyPrimAttrib(const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1911
GA_Size GA_Offset
Definition: GA_Types.h:653
SYS_FORCE_INLINE GA_Attribute * addVertexAttrib(const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1811
SYS_FORCE_INLINE const GEO_Primitive * getGEOPrimitive(GA_Offset off) const
Definition: GEO_Detail.h:1206
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
UT_Array< EdgeAdjacencyData > GEO_EdgeAdjArray
Definition: GEO_Detail.h:2140
GA_AttributeScope
Definition: GA_Types.h:148
GLdouble n
Definition: glcorearb.h:2008
SYS_FORCE_INLINE const GA_Attribute * findPointAttrib(const GA_Attribute &src) const
Definition: GEO_Detail.h:1754
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
bool operator!=(const SoftSymmetryParms &other) const
Definition: GEO_Detail.h:580
UT_Matrix3T< FLOAT_T > myOrient
Definition: GEO_Detail.h:817
SYS_FORCE_INLINE GA_Attribute * addPrimAttrib(const GA_Attribute *src)
Definition: GEO_Detail.h:1865
CaptureType
Methods for manipulating capture weights (GEO_CaptureWeight.C)
Definition: GEO_Detail.h:1016
GLintptr offset
Definition: glcorearb.h:665
SYS_FORCE_INLINE GA_Attribute * findVertexAttrib(const GA_Attribute &src)
Definition: GEO_Detail.h:1828
SYS_FORCE_INLINE const GA_Attribute * findGlobalAttrib(const GA_Attribute &src) const
Definition: GEO_Detail.h:1947
UT_Array< PointAdjacencyData > GEO_PointAdjArray
Definition: GEO_Detail.h:2139
Class used to keep track of inheritance of intrinsic attribute evaluation.
SYS_FORCE_INLINE GA_Attribute * addIntTuple(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_INT32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2705
friend std::ostream & operator<<(std::ostream &os, const GEO_Detail &d)
Definition: GEO_Detail.h:2898
SYS_FORCE_INLINE bool promotePointAttrib(const UT_StringRef &name)
Definition: GEO_Detail.h:1791
SYS_FORCE_INLINE GA_Attribute * addFloatArray(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size=1, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_REAL32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2785
SYS_FORCE_INLINE GA_Attribute * addGlobalAttrib(GA_AttributeScope scope, const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1927
UT_BoundingBoxT< float > UT_BoundingBox
Definition: GEO_Detail.h:41
SYS_FORCE_INLINE void destroyAttribute(GA_AttributeOwner owner, const UT_StringRef &name, const GA_AttributeFilter *filter=0)
Definition: GEO_Detail.h:2333
static const UT_StringHolder theEmptyString
SYS_FORCE_INLINE const GA_Attribute * findNumericTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2399
UT_ColorRamp
Definition: UT_Color.h:33
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
SYS_FORCE_INLINE GA_Offset appendPoint()
Append a new point, returning its new data offset.
Definition: GA_Detail.h:335
GLint GLuint mask
Definition: glcorearb.h:124
bool getPointBBox(UT_BoundingBox &bbox, const UT_Matrix4R &transform, const GA_PointGroup *g=nullptr) const
Definition: GEO_Detail.h:1303
SYS_FORCE_INLINE const GA_Attribute * findDictArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2588
#define GEO_API
Definition: GEO_API.h:14
SYS_FORCE_INLINE void destroyVertexAttrib(const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1854
Create macros which emulate the macros in the obsolete GB library.
SYS_FORCE_INLINE const GA_Attribute * findFloatArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2492
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
long long int64
Definition: SYS_Types.h:116
A handle to simplify manipulation of multiple attributes.
SYS_FORCE_INLINE GA_Attribute * findFloatTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2362
SYS_FORCE_INLINE const GA_Attribute * findVertexVectorAttrib(GA_AttributeScope s, const UT_StringRef &n) const
Looks for a 3-float vertex attribute.
Definition: GEO_Detail.h:1834
HUSD_API bool eval(VtValue &val, T &ret_val)
const GEO_Primitive * getGEOPrimitiveByIndex(GA_Index idx) const
Definition: GEO_Detail.h:1224
GLuint const GLchar * name
Definition: glcorearb.h:786
#define SYS_DEPRECATED_HDK(__V__)
SYS_FORCE_INLINE GA_Attribute * addPointAttrib(const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1741
GEO_Primitive GB_MACRO_PRIM_TYPE
Definition: GEO_Detail.h:1996
SYS_FORCE_INLINE void destroyPointAttrib(const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1784
SYS_FORCE_INLINE const GA_Attribute * findIndexPair(GA_AttributeOwner owner, const UT_StringRef &name) const
Definition: GEO_Detail.h:2473
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:647
GA_API const UT_StringHolder transform
UT_Vector3T< FLOAT_T > myFwdVector
Definition: GEO_Detail.h:813
GA_API const UT_StringHolder orient
SYS_FORCE_INLINE GA_Attribute * growTuple(GA_AttributeOwner owner, const UT_StringRef &name, int added_size)
Definition: GEO_Detail.h:2322
GA_TypeInfo
Definition: GA_Types.h:105
SYS_FORCE_INLINE GA_Attribute * findPointAttrib(const GA_Attribute &src)
Definition: GEO_Detail.h:1758
GLdouble t
Definition: glad.h:2397
SYS_FORCE_INLINE const GA_AttributeDict & attribs() const
Definition: GEO_Detail.h:1991
GLenum mode
Definition: glcorearb.h:99
bool destroyPointGroup(const char *name)
Definition: GEO_Detail.h:2208
LocalXformContextT(const UT_Matrix3T< FLOAT_T > &orient, const UT_Vector3T< FLOAT_T > &origin, PivotSpace pivot_space)
Definition: GEO_Detail.h:806
SYS_FORCE_INLINE GA_Attribute * findFloatArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2504
GEO_Primitive * getGEOPrimitiveByIndex(GA_Index idx)
Definition: GEO_Detail.h:1217
IFDmantra py
Definition: HDK_Image.dox:266
Contains transitional objects to provide some backward compatibility for code that references old GEO...
GEO_API const TypeMask GEOPRIMALL
GLsizeiptr size
Definition: glcorearb.h:664
SYS_FORCE_INLINE GA_Offset appendPointOffset()
Definition: GEO_Detail.h:1163
GA_AttributeOwner
Definition: GA_Types.h:35
A map of string to various well defined value types.
Definition: UT_Options.h:87
Quaternion class.
Definition: GEO_Detail.h:49
Class to return information about a GA_Detail.
Definition: GA_Stat.h:51
GA_API const UT_StringHolder parms
SYS_FORCE_INLINE const GA_Attribute * findPrimAttrib(const GA_Attribute &src) const
Definition: GEO_Detail.h:1894
void clear()
Definition: GA_Detail.h:136
SYS_FORCE_INLINE GA_Attribute * findStringArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2576
SYS_FORCE_INLINE GA_Attribute * findPointVectorAttrib(GA_AttributeScope s, const UT_StringRef &n)
Definition: GEO_Detail.h:1771
SYS_FORCE_INLINE GA_Attribute * addGlobalAttrib(const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1937
SYS_FORCE_INLINE GA_Attribute * addDictTuple(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2753
SYS_FORCE_INLINE bool demoteVertexAttrib(const UT_StringRef &name)
Definition: GEO_Detail.h:1861
SYS_FORCE_INLINE const GA_Attribute * findPointVectorAttrib(const UT_StringRef &n) const
Definition: GEO_Detail.h:1768
GA_Primitive * appendPrimitive(const GA_PrimitiveTypeId &type)
Append a primitive by GA_PrimitiveTypeId.
int getValue() const
Definition: GEO_Detail.h:1550
virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const
SYS_FORCE_INLINE GA_Attribute * findIntArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2528
fpreal64 fpreal
Definition: SYS_Types.h:283
static int asciiMagicH9()
Magic number for ASCII geometry files.
Definition: GEO_Detail.h:2874
SYS_FORCE_INLINE const GA_Attribute * findIntArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2516
#define SYS_FTOLERANCE_R
Definition: SYS_Types.h:289
SYS_FORCE_INLINE GEO_Primitive * appendPrimitive(const GA_PrimitiveTypeId &type)
Definition: GEO_Detail.h:1256
SYS_FORCE_INLINE GA_Attribute * addGlobalAttrib(const GA_Attribute *src)
Definition: GEO_Detail.h:1920
SYS_FORCE_INLINE const GA_AttributeDict & primitiveAttribs() const
Definition: GEO_Detail.h:1983
Utility class for containing a color ramp.
Definition: UT_Ramp.h:96
void destroyPointGroup(GA_PointGroup *g)
Definition: GEO_Detail.h:2202
GEO_Capture_Muscle_Property
Definition: GEO_Detail.h:212
Class used to map the GA attribute into a form for H9 geometry files.
Definition: GA_AIFFileH9.h:262
GLfloat GLfloat v1
Definition: glcorearb.h:817
FMT_CONSTEXPR basic_fp< F > normalize(basic_fp< F > value)
Definition: format.h:1701
SYS_FORCE_INLINE GA_Attribute * findNumericArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2552
SYS_FORCE_INLINE GA_Size deletePoints(const GA_PointGroup &point_group, GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES)
Definition: GEO_Detail.h:1188
SYS_FORCE_INLINE GA_Attribute * addFloatTuple(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0), const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_REAL32, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2678
bool destroyPrimitiveGroup(const char *name)
Definition: GEO_Detail.h:2211
GU_API void xform(CE_Context &context, bool recompile, int npts, const cl::Buffer &outPos, const cl::Buffer &inPos, const cl::Buffer &surfacexform, const cl::Buffer *grp=nullptr)
SYS_FORCE_INLINE GA_Attribute * addStringArray(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size=1, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, GA_Storage storage=GA_STORE_STRING, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2834
#define GA_INVALID_INDEX
Definition: GA_Types.h:693
SYS_FORCE_INLINE GA_Attribute * addPointAttrib(GA_AttributeScope scope, const UT_StringHolder &n, const UT_Options *creation_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GEO_Detail.h:1731
SYS_FORCE_INLINE GA_Attribute * findVertexVectorAttrib(const UT_StringRef &n)
Definition: GEO_Detail.h:1845
SYS_FORCE_INLINE GA_Attribute * findPointVectorAttrib(const UT_StringRef &n)
Definition: GEO_Detail.h:1775
Container class for all geometry.
Definition: GA_Detail.h:105
SYS_FORCE_INLINE const GA_Attribute * findIntTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2374
UT_Vector3T< FLOAT_T > myOrigin
Definition: GEO_Detail.h:818
cgltf_primitive * getPrimitive(const cgltf_data &data, const GLTF_Index mesh_id, const GLTF_Index prim_id)
SYS_FORCE_INLINE void destroyGlobalAttrib(const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1960
GA_Offset appendPointCopy(GA_Offset src, GA_PointWrangler &wrangler)
Append a point, copying data from the source point.
Definition: GEO_Detail.h:1178
OutGridT XformOp bool bool MergePolicy merge
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8574
SYS_FORCE_INLINE void destroyPrimAttrib(GA_AttributeScope scope, const UT_StringRef &n, const GA_AttributeFilter *filter=nullptr)
Definition: GEO_Detail.h:1903
SIM_API const UT_StringHolder distance
SYS_FORCE_INLINE GA_Attribute * addVertexAttrib(const GA_Attribute *src)
Definition: GEO_Detail.h:1795
GEO_Capture_Meta_Property
Definition: GEO_Detail.h:220
SYS_FORCE_INLINE GA_Attribute * addStringTuple(GA_AttributeOwner owner, const UT_StringHolder &name, int tuple_size, const UT_Options *creation_args=0, const GA_AttributeOptions *attribute_options=0, const GA_ReuseStrategy &reuse=GA_ReuseStrategy())
Definition: GEO_Detail.h:2731
SYS_FORCE_INLINE const GA_Attribute * findStringArray(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1) const
Definition: GEO_Detail.h:2564
bool operator==(const SoftSymmetryParms &other) const
Definition: GEO_Detail.h:573
SYS_FORCE_INLINE GA_Attribute * findDictTuple(GA_AttributeOwner owner, const UT_StringRef &name, int min_size=1, int max_size=-1)
Definition: GEO_Detail.h:2461
Class to specify options for loading geometry.
GEO_Standard_Attributes
Definition: GEO_Detail.h:166
SYS_FORCE_INLINE GA_Attribute * findVertexVectorAttrib(GA_AttributeScope s, const UT_StringRef &n)
Definition: GEO_Detail.h:1841
GA_Storage
Definition: GA_Types.h:52
LocalXformContextT(const UT_Vector3T< FLOAT_T > &forward, const UT_Vector3T< FLOAT_T > &up, PivotSpace pivot_space)
Coordinate frame defined by lookat(zero, forward, up).
Definition: GEO_Detail.h:797
GEO_CopyMethod
An enum for GEO_Detail::copy's method parameter.
Definition: GEO_Detail.h:241
GLint GLsizei count
Definition: glcorearb.h:405
Definition: format.h:1821
bool destroyVertexGroup(const char *name)
Definition: GEO_Detail.h:2214
SYS_FORCE_INLINE const GA_Attribute * findVertexVectorAttrib(const UT_StringRef &n) const
Definition: GEO_Detail.h:1838
SYS_FORCE_INLINE const GA_AttributeDict & vertexAttribs() const
Definition: GEO_Detail.h:1987
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
GLenum src
Definition: glcorearb.h:1793