HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_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: GA_Detail.h ( GA Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #pragma once
12 
13 #ifndef __GA_Detail__
14 #define __GA_Detail__
15 
16 #include "GA_API.h"
17 #include "GA_ATITopology.h"
18 #include "GA_AttributeRef.h"
19 #include "GA_AttributeSet.h"
20 #include "GA_Defaults.h"
21 #include "GA_EdgeGroup.h"
22 #include "GA_EdgeGroupTable.h"
23 #include "GA_ElementGroup.h"
24 #include "GA_ElementGroupOrder.h"
25 #include "GA_ElementGroupTable.h"
26 #include "GA_Handle.h"
27 #include "GA_IndexMap.h"
28 #include "GA_IntrinsicManager.h"
29 #include "GA_OffsetList.h"
30 #include "GA_PrimitiveFactory.h"
31 #include "GA_PrimitiveList.h"
32 #include "GA_PrimitiveTypeMask.h"
33 #include "GA_Range.h"
34 #include "GA_Topology.h"
35 #include "GA_Types.h"
36 
37 #include <UT/UT_Assert.h>
38 #include <UT/UT_BoundingBox.h>
39 #include <UT/UT_BoundingRect.h>
40 #include <UT/UT_Vector2.h>
41 #include <UT/UT_Vector3.h>
42 #include <UT/UT_Vector4.h>
43 
44 #include <SYS/SYS_Compiler.h>
45 #include <SYS/SYS_Inline.h>
46 #include <SYS/SYS_Types.h>
47 
48 #include <iosfwd>
49 
50 class UT_IStream;
51 class UT_JSONParser;
52 class UT_JSONWriter;
53 class UT_MemoryCounter;
54 class UT_Options;
55 class UT_String;
56 class UT_StringArray;
57 class UT_StringHolder;
58 class UT_StringRef;
59 class UT_WorkBuffer;
60 template <typename T> class UT_Array;
61 
62 class GA_ATINumeric;
65 class GA_Attribute;
66 class GA_AttributeDict;
67 class GA_AttributeFilter;
70 class GA_AttributeType;
71 class GA_CEAttribute;
72 class GA_Group;
73 class GA_GroupTable;
74 class GA_IntrinsicEval;
75 class GA_IO;
76 class GA_LoadMap;
77 class GA_LoadOptions;
78 class GA_MergeMap;
79 class GA_MergeOptions;
80 class GA_PolyCounts;
81 class GA_Primitive;
82 class GA_PrimitiveTypeId;
84 class GA_SaveOptions;
85 class GA_Stat;
86 class ga_TailInitializeTable;
87 
88 namespace GA_FileFormatH9 { class PrimTypeXlate; }
89 
90 /// @brief Container class for all geometry.
91 ///
92 /// All Houdini geometry is stored in a GA_Detail class. The detail stores
93 /// lists of attributes (GA_Attribute) which are maintained in GA_AttributeSet
94 /// collections. The attribute set contains 4 separate classes of attribute
95 /// based on the GA_AttributeOwner enum.
97 {
98 public:
99  /// @param Pstorage determines the precision of the @b P attribute.
100  /// @param isprimary determines the default value of the @b P attribute.
101  /// true yields (0,0,0) as the default, and false yields (0,0,1),
102  /// for use by GD_Detail, where the z component is actually the
103  /// point weight for NURBS/Bezier trim/profile curves.
104  /// P will have typeinfo "hpoint" if secondary, and "point" if primary.
105  /// @param full_topology indicates whether the detail should maintain
106  /// additional attributes which make it easy to lookup
107  /// - Primitives using a shared point
108  /// - The primitive containing a unique point (vertex)
109  /// - The list of vertices referencing a shared point
110  /// @see typedef::GA_Storage.
112  bool isprimary=true,
113  bool full_topology=true);
114  /// Destructor
115  virtual ~GA_Detail();
116 
117  exint getUniqueId() const { return myUniqueId; }
118 
119  /// Re-initialize:
120  /// - Clears all attributes
121  /// - Clears all geometry elements (points, primitives, vertices, etc.)
122  /// - Clears all groups
123  /// NOTE: Does *NOT* clear caches like the primitive stash or selections,
124  /// though it does clear the attribute instance matrix. It has
125  /// to keep the stash, because it's used by stashAll().
126  /// Use clearAndDestroy() to clear everything.
127  void clear() { clearData(false); }
128 
129  /// Returns true if the detail is empty. This is not just
130  /// having zero points/primitives, but also only having trivial
131  /// attributes.
132  bool isEmpty() const;
133 
134  /// These two functions should be used instead of the more
135  /// destructive clearAndDestroy() when it it likely the
136  /// geometry it relatively stable between operations
137  /// @{
138  void stashAll()
139  {
140  clearCaches();
141 
142  getPrimitiveList().stashAll();
143 
144  // We have to clear the primitive index map before calling the virtual
145  // clearAndDestroy() to prevent primitive iterators from ending up in
146  // a bad state with expected entries missing from the primitive list.
147  getIndexMap(GA_ATTRIB_PRIMITIVE).clear(/*clear_capacity*/ true);
148 
149  // Increment the meta-cache count, since it did so before, in case
150  // anything is relying on it being incremented here.
151  incrementMetaCacheCount();
152 
153  // remove the rest
154  clear();
155  }
157  {
158  getPrimitiveList().destroyStashed();
159  }
160  ///@}
161 
162  // -------------- P attribute ----------------------------
163  /// Convenience method to access the @b P attribute
164  GA_Attribute *getP() { return myP; }
165  const GA_Attribute *getP() const { return myP; }
166 
167  /// Determine if we've bound 64-bit position. Relies on double being
168  /// alternate binding of our handle. Esoteric position attribute types
169  /// will confuse this
170  SYS_FORCE_INLINE bool isPDouble() const { return myHandlePV3.isAltBound(); }
171 
172  /// The ptoff passed is the point offset. @see vertexPoint()
174  {
175  UT_Vector3 v3 = myHandlePV3.get(ptoff);
176  return UT_Vector2(v3.x(), v3.y());
177  }
179  {
180  UT_Vector3D v3 = UTmakeVector3T( myHandlePV3.getAlt(ptoff) );
181  return UT_Vector2D(v3.x(), v3.y());
182  }
183  /// The ptoff passed is the point offset. @see vertexPoint()
185  getPos3(GA_Offset ptoff) const
186  {
187  return myHandlePV3.get(ptoff);
188  }
190  getPos3D(GA_Offset ptoff) const
191  {
192  return UTmakeVector3T( myHandlePV3.getAlt(ptoff) );
193  }
194  template <typename T>
196  getPos3T(GA_Offset ptoff) const
197  {
198  if constexpr(std::is_same<T, float>::value)
199  return getPos3(ptoff);
200  else
201  return getPos3D(ptoff);
202  }
203  /// Get an array of all positions from the given point range.
204  /// The template parameter T is must be one of: fpreal, fpreal32, or
205  /// fpreal64.
206  template <typename T>
208  const GA_Range &ptrange,
209  UT_Array< UT_Vector3T<T> > &positions) const
210  {
211  return getAttributeAsArray(getP(), ptrange, positions);
212  }
213  /// Get an array of all positions from the given point range.
214  /// The template parameter T is must be one of: fpreal, fpreal32, or
215  /// fpreal64.
216  template <typename T>
218  const GA_Range &ptrange,
219  const UT_Array< UT_Vector3T<T> > &positions)
220  {
221  return setAttributeFromArray(getP(), ptrange, positions);
222  }
223 
224  /// Set @b P from a UT_Vector2
225  void setPos2(GA_Offset ptoff, const UT_Vector2 &pos)
226  {
227  UT_Vector3 v3(pos.x(), pos.y(), myHandlePV3.get(ptoff).z());
228  myHandlePV3.set(ptoff, v3);
229  }
230  void setPos2(GA_Offset ptoff, const UT_Vector2D &pos)
231  {
232  UT_Vector3D v3(pos.x(), pos.y(), myHandlePV3.getAlt(ptoff)[2]);
233  myHandlePV3.setAlt(ptoff, UTmakeFixedVector(v3));
234  }
235  /// Set @b P from a UT_Vector3
237  void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
238  {
239  myHandlePV3.set(ptoff, pos);
240  }
242  void setPos3(GA_Offset ptoff, const UT_Vector3D &pos)
243  {
244  myHandlePV3.setAlt(ptoff, UTmakeFixedVector(pos));
245  }
246  /// Set @b P given the x, y, z components.
249  {
250  myHandlePV3.setAlt(ptoff, UTmakeFixedVector(UT_Vector3D(x,y,z)));
251  }
252 
253  /// Apply a translation to the specified point index. @see vertexPoint()
254  /// Effectively setPos3(offset, getPos3(offset) + delta)
256  void translatePoint(GA_Offset ptoff, const UT_Vector3 &delta)
257  {
258  myHandlePV3.add(ptoff, delta);
259  }
261  void translatePoint(GA_Offset ptoff, const UT_Vector3D &delta)
262  {
263  myHandlePV3.addAlt(ptoff, UTmakeFixedVector(delta) );
264  }
265 
266  //
267  // Functions for handling Pw: specific to rational NURBS and Bezier
268  // curves and surfaces! DO NOT USE unless you actually need to adjust the
269  // point weights!
270  //
271 
272  /// Get the homogeneous coordinate for a point
273  fpreal getPw(GA_Offset ptoff) const;
274  /// Set the homogeneous coordinate for a point
275  void setPw(GA_Offset ptoff, fpreal w);
276  /// NOTE: This will usually return nullptr, because very
277  /// few things actually set the homogenous coordinate
278  /// to anything other than 1.0, in which case, the
279  /// attribute won't be created.
280  /// @{
282  {
283  return myPw;
284  }
286  {
287  return myPw;
288  }
289  /// @}
290 
291  /// The ptoff passed is the point offset. @see vertexPoint()
293  {
294  return UT_Vector4(getPos3(ptoff), getPw(ptoff));
295  }
297  {
298  return UT_Vector4D(getPos3D(ptoff), getPw(ptoff));
299  }
300 
301  /// Set @b P from a UT_Vector4
302  void setPos4(GA_Offset ptoff, const UT_Vector4 &pos)
303  {
304  setPos3(ptoff, UT_Vector3(pos));
305  setPw(ptoff, pos.w());
306  }
307  void setPos4(GA_Offset ptoff, const UT_Vector4D &pos)
308  {
309  setPos3(ptoff, UT_Vector3D(pos));
310  setPw(ptoff, pos.w());
311  }
312  /// Set @b P given the x, y, z, w components.
314  fpreal z, fpreal w)
315  {
316  setPos3(ptoff, x, y, z);
317  setPw(ptoff, w);
318  }
319 
320  //
321  // -------------- Element Interface ----------------------
322  //
323 
324  /// Append a new point, returning its new data offset
327  { return appendPointBlock(1); }
328  /// Append new points, returning the first offset of the contiguous block
331  { return myPointMap.addElementBlock(npoints); }
332  /// Return the number of points
335  { return myPointMap.indexSize(); }
336  /// This will be an exclusive, possibly loose, upper bound when iterating
337  /// over point offsets.
338  /// Every point offset in this detail will be strictly less than this.
339  /// @note (getNumPoints() <= getNumPointOffsets()) is always true.
342  { return myPointMap.offsetSize(); }
343  /// Given a point's index (in append order), return its data offset
346  { return myPointMap.offsetFromIndex(index); }
347  /// Given a point's data offset, return its index
350  { return myPointMap.indexFromOffset(offset); }
351  /// Reorder a point. The index of the point at the given data offset
352  /// will be changed to the new order (provided that the ordered position is
353  /// in a valid range).
354  /// @return The new index of the point, or -1 if there was an error
355  GA_Index reorderPoint(GA_Offset ptoff, GA_Index new_order);
356 
357  /// Append a primitive by GA_PrimitiveTypeId
358  GA_Primitive *appendPrimitive(const GA_PrimitiveTypeId &type);
359  /// Append a primitive by type name string
360  GA_Primitive *appendPrimitive(const UT_StringRef &type);
361  /// Append a contiguous block of primitives by GA_PrimitiveTypeId
362  GA_Offset appendPrimitiveBlock(const GA_PrimitiveTypeId &type,
363  GA_Size nprimitives);
364 
365  /// Append a contiguous block of primitives and a contiguous
366  /// block of vertices, with each primitive having nvertices_each vertices,
367  /// though the vertices will be unwired, so the caller is responsible
368  /// for wiring the vertices to points.
369  /// Make absolutely sure you know what you're doing if you call this!
370  /// It's used by GEO_PrimPoly::buildBlock() and GEO_PrimTetrahedron::
371  /// buildBlock().
372  /// The return value is the start offset of the primitive block,
373  /// and vertex_block_start is filled with the start offset of the
374  /// vertex block.
375  GA_Offset appendPrimitivesAndVertices(
376  const GA_PrimitiveTypeId &type,
377  GA_Size nprimitives,
378  GA_Size nvertices_each,
379  GA_Offset &vertex_block_start,
380  bool closed_flag = false);
381 
382  /// Append a contiguous block of primitives and a contiguous
383  /// block of vertices, with vertex_counts being a run-length encoded
384  /// array indicating the number of vertices in each primitive,
385  /// though the vertices will be unwired, so the caller is responsible
386  /// for wiring the vertices to points.
387  /// Make absolutely sure you know what you're doing if you call this!
388  /// It's used by GEO_PrimPoly::buildBlock() and GEO_PrimTetrahedron::
389  /// buildBlock().
390  /// The return value is the start offset of the primitive block,
391  /// and vertex_block_start is filled with the start offset of the
392  /// vertex block.
393  GA_Offset appendPrimitivesAndVertices(
394  const GA_PrimitiveTypeId &type,
395  const GA_PolyCounts &vertex_counts,
396  GA_Offset &vertex_block_start,
397  bool closed_flag = false);
398 
399  GA_Offset appendPrimitivesAndVertices(
400  const std::pair<int,exint> *primtype_count_pairs,
401  const GA_PolyCounts &vertex_counts,
402  GA_Offset &vertex_block_start,
403  const exint *closed_span_length = nullptr,
404  exint ncopies=1);
405 
406  /// Return the number of primitives
409  { return myPrimitiveMap.indexSize(); }
410  /// This will be an exclusive, possibly loose, upper bound when iterating
411  /// over primitive offsets.
412  /// Every primitive offset in this detail will be strictly less than this.
413  /// @note (getNumPrimitives() <= getNumPrimitiveOffsets()) is always true.
416  { return myPrimitiveMap.offsetSize(); }
417  /// Given a primitive's index (in append order), return its data offset
420  { return myPrimitiveMap.offsetFromIndex(index); }
421  /// Given a primitive's data offset, return its index
424  { return myPrimitiveMap.indexFromOffset(offset); }
425 
426  /// Get the primitive by offset
427  /// @{
430  { return myPrimitiveList.get(prim_off); }
432  const GA_Primitive *getPrimitive(GA_Offset prim_off) const
433  { return myPrimitiveList.get(prim_off); }
434  /// @}
435 
436  /// Get the primitive by index
437  /// @{
439  { return myPrimitiveList.get(primitiveOffset(prim_idx)); }
441  { return myPrimitiveList.get(primitiveOffset(prim_idx)); }
442  /// @}
443 
444  /// Returns a shallow copy of the vertex list of the primitive at the
445  /// specified primitive offset.
446  /// You must include GA_Primitive.h to use this.
448  GA_OffsetListRef getPrimitiveVertexList(GA_Offset primoff) const;
449 
450  /// Returns the number of vertices in the primitive at the specified
451  /// primitive offset.
452  /// You must include GA_Primitive.h to use this.
454  GA_Size getPrimitiveVertexCount(GA_Offset primoff) const;
455 
456  /// Returns the vertex offset in the primitive at the specified
457  /// primitive offset in vertex list position i.
458  /// If you're accessing all vertex offsets, it'll be faster to
459  /// call getVertexList() once and either read from that or
460  /// call forEach(fucntor) on it.
461  /// You must include GA_Primitive.h to use this.
463  GA_Offset getPrimitiveVertexOffset(GA_Offset primoff, GA_Size i) const;
464 
465  /// Returns the type ID of the primitive at the specified
466  /// primitive offset.
467  /// You must include GA_Primitive.h to use this.
469  int getPrimitiveTypeId(GA_Offset primoff) const;
470 
471  /// Returns the "closed" flag for polygon, NURBS curve, or Bezier curve
472  /// primitives, or false for other primitive types.
473  /// You must include GA_Primitive.h to use this.
475  bool getPrimitiveClosedFlag(GA_Offset primoff) const;
476 
477  /// Sets the "closed" flag for polygon primitives.
478  /// For NURBS curve or Bezier curve primitives, use GEO_Face::close()
479  /// or GEO_Face::open().
480  /// You must include GA_Primitive.h to use this.
482  void setPrimitiveClosedFlag(GA_Offset primoff, bool closed);
483 
484 
485  /// Reorder a primitive. The index of the primitive at the given data
486  /// offset will be changed to the new order (provided that the ordered
487  /// position is in a valid range).
488  /// @return The new index of the primitive, or -1 if there was an error
489  GA_Index reorderPrimitive(GA_Offset offset, GA_Index new_order);
490 
491  /// Swap the order of the two specified primitive data offsets.
492  bool swapPrimitiveOrder(GA_Offset offset1,
493  GA_Offset offset2);
494 
495  /// Append a vertex (for the entire detail)
497  GA_Offset appendVertex() { return appendVertexBlock(1); }
498  /// Append new vertices, returning the first offset of the contiguous block
501  { return myVertexMap.addElementBlock(nvertices); }
502  /// Return the number verticies in the entire detail
505  { return myVertexMap.indexSize(); }
506  /// This will be an exclusive, possibly loose, upper bound when iterating
507  /// over vertex offsets.
508  /// Every vertex offset in this detail will be strictly less than this.
509  /// @note (getNumVertices() <= getNumVertexOffsets()) is always true.
512  { return myVertexMap.offsetSize(); }
513  /// Given a vertex's index (in append order), return its data offset
516  { return myVertexMap.offsetFromIndex(index); }
517  /// Given a vertex's data offset, return its index
520  { return myVertexMap.indexFromOffset(offset); }
521 
522  /// @private @see GA_WorkVertexBuffer
523  GA_Offset appendTemporaryPoint();
524  /// @private @see GA_WorkVertexBuffer
525  GA_Offset appendTemporaryVertex();
526 
527  /// Given a vertex, return the point it references
530  {
531  UT_ASSERT_P(!myVertexMap.isOffsetVacant(vertex));
532  return myTopology.getPointRef()->getLink(vertex);
533  }
534 
535  /// Given a vertex, set the corresponding point offset.
537  {
538  UT_ASSERT_P(!myVertexMap.isOffsetVacant(vertex));
539  myTopology.wireVertexPoint(vertex, ptoff);
540  }
541 
542  /// Given a vertex, return primitive it references
543  /// Returns -1 if no topology attributes exist.
546  {
547  UT_ASSERT_P(!myVertexMap.isOffsetVacant(vertex));
548  const GA_ATITopology *pref = myTopology.getPrimitiveRef();
549  UT_ASSERT_P(pref);
550  return pref->getLink(vertex);
551  }
552 
553  /// Given a point, returns *a* vertex that it references.
554  /// More than one vertex may refer to a single point, and it is
555  /// quite possible that no vertices refer to the point.
556  /// GA_INVALID_OFFSET is returned if no vertices match.
557  /// See getVerticesReferencingPoint() for methods to get all the points.
560  {
561  UT_ASSERT_P(!myPointMap.isOffsetVacant(point));
562  const GA_ATITopology *ref = myTopology.getVertexRef();
563  UT_ASSERT_P(ref);
564  return ref->getLink(point);
565  }
566 
567  /// Given a vertex, returns the next one that shares the same
568  /// point as this vertex. GA_INVALID_OFFSET if no further
569  /// vertices match
572  {
573  UT_ASSERT_P(!myVertexMap.isOffsetVacant(vtx));
574  const GA_ATITopology *ref = myTopology.getVertexNextRef();
575  UT_ASSERT_P(ref);
576  return ref->getLink(vtx);
577  }
578 
579  /// Given a vertex, returns the previous one that shares the same
580  /// point as this vertex. GA_INVALID_OFFSET if no further
581  /// vertices match
584  {
585  UT_ASSERT_P(!myVertexMap.isOffsetVacant(vtx));
586  const GA_ATITopology *ref = myTopology.getVertexPrevRef();
587  UT_ASSERT_P(ref);
588  return ref->getLink(vtx);
589  }
590 
591  /// Given a point and primitive, find the corresponding vertex. Note that
592  /// this is O(N) on the number of vertices which share the point. If the
593  /// primitive offset is -1, then the "first" vertex which references the
594  /// point will be returned. The order of the "first" vertex is arbitrary,
595  /// though it will likely be the same for each call.
596  ///
597  /// Returns -1 if no topology attributes exist.
598  GA_Offset getVertexReferencingPoint(GA_Offset ptoff,
599  GA_Offset primoff = GA_INVALID_OFFSET) const;
600 
601  /// Given a point offset, return a list of all vertices which reference it.
602  /// NOTE: The vertex offsets might be in ANY order, and may even be
603  /// different from run to run, so DO NOT rely on the order!
604  GA_Size getVerticesReferencingPoint(
605  GA_OffsetArray &vertices,
606  GA_Offset point_offset) const;
607  /// Given a point offset, return a list of all primitives which reference it.
608  /// The primitive offsets will be in ascending order and have no duplicates,
609  /// so you can do:
610  /// detail.getPrimitivesReferencingPoint(prims0, p0off);
611  /// detail.getPrimitivesReferencingPoint(prims1, p1off);
612  /// prims0.sortedIntersection(prims1);
613  /// to quickly get a list of primitives that contain both p0off and p1off,
614  /// (not necessarily as an edge, but this can be used as a first pass check.)
615  GA_Size getPrimitivesReferencingPoint(
616  GA_OffsetArray &primitives,
617  GA_Offset point_offset) const;
618 
619  /// Returns false if any point is shared, ie, more than one vertex
620  /// points to the same point. This being true means each point
621  /// has at most one vertex and belongs to at most one primitive.
622  /// Note that points can belong to zero vertices and zero primitives
623  /// still. Requires topology.
624  bool hasNoSharedPoints() const;
625 
626  /// When destroying points, there are three different modes when dealing
627  /// with primitives that reference the points. These modes cause different
628  /// behaviours when notifying primitives about point deletion. The
629  /// behaviour is determined by the result of @c
630  /// primitive->dereferencePoint() or @c primitive->dereferencePoints().
631  /// - GA_LEAVE_PRIMITIVES @n
632  /// Primitive is destroyed if it returns GA_DEREFERENCE_DESTROY.
633  /// Point will @b not be destroyed if prim returns GA_DEREFERENCE_FAIL.
634  /// - GA_DESTROY_DEGENERATE @n
635  /// Primitive is destroyed if it returns GA_DEREFERENCE_DEGENERATE or
636  /// GA_DEREFERENCE_DESTROY. Point is not destroyed if prim returns
637  /// GA_DEREFERENCE_FAIL.
638  /// - GA_DESTROY_DEGENERATE_INCOMPATIBLE @n
639  /// Primitive is destroyed if it returns GA_DEREFERENCE_DEGENERATE,
640  /// GA_DEREFERENCE_DESTROY, or GA_DEREFERENCE_FAIL. The point will
641  /// always be destroyed.
643  {
647  };
648 
649  /// @{
650  /// Destroy the given point. This may leave dangling vertex references if
651  /// there is no full topology.
652  ///
653  /// If the @c guarantee_no_vertex_references flag is true, the operation
654  /// will be more efficient, but you must truly guarantee that there are no
655  /// vertices referring to the point.
656  bool destroyPointOffset(GA_Offset ptoff,
657  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES,
658  bool guarantee_no_vertex_references=false);
659  bool destroyPointIndex(GA_Index index,
660  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES,
661  bool guarantee_no_vertex_references=false);
662  /// @}
663  /// Destroy the given vertex
664  bool destroyVertexOffset(GA_Offset offset);
665  /// Destroy the given primitive. Optionally destroy any referenced points
666  /// that will no longer be in use after this operation. Note that this
667  /// option requires full topology.
668  virtual bool destroyPrimitiveOffset(GA_Offset offset,
669  bool and_points = false);
670  bool destroyPrimitiveIndex(GA_Index index,
671  bool and_points = false);
672  bool destroyPrimitive(GA_Primitive &prim,
673  bool and_points = false);
674 
675  /// Destroy the given primitives. Optionally destroy any referenced points
676  /// that will no longer be in use after this operation. Note that this
677  /// option requires full topology.
678  virtual GA_Size destroyPrimitiveOffsets(const GA_Range &it,
679  bool and_points = false);
681  bool and_points = false)
682  { return destroyPrimitiveOffsets(it, and_points); }
683  GA_Size destroyDegeneratePrimitives(const GA_Range &it,
684  bool and_points = false);
685  GA_Size destroyDegeneratePrimitives(const GA_PrimitiveGroup *prims=0, bool and_points = false);
686 
687 
688  /// Destroy unused points. If ptgrp is given, then only within the group
690  {
691  return destroyUnusedPoints(getPointRange(ptgrp));
692  }
693  /// @{
694  /// Destroy unused points in given point range
695  GA_Size destroyUnusedPoints(const GA_Range &point_range);
697  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES,
698  bool guarantee_no_vertex_references=false)
699  {
700  return destroyElements(range, mode,
701  guarantee_no_vertex_references);
702  }
704  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES,
705  bool guarantee_no_vertex_references=false)
706  {
707  return destroyPointOffsets(range, mode,
708  guarantee_no_vertex_references);
709  }
710  /// @}
711 
712 
714  { return destroyElements(range); }
716  { return destroyVertexOffsets(range); }
717 
718  /// Returns whether a point is referenced by any vertices
719  /// This may be a slow operation if there is no topology allocated
720  bool isPointUsed(GA_Offset point) const;
721  /// Returns if a point is referenced. Fails catastrophically
722  /// if you do not have full topology.
723  bool isPointUsedFast(GA_Offset point) const
724  {
725  return GAisValid(pointVertex(point));
726  }
727 
728  /// Returns true if there are any unused points.
729  /// If the offset list is given, it is set to all of the found
730  /// unused points.
731  bool findUnusedPoints(GA_OffsetList *unused=nullptr) const;
732 
733  // -------------- Index Maps -----------------------------
734  const GA_IndexMap &getIndexMap(GA_AttributeOwner owner) const;
736  {
737  return const_cast<GA_IndexMap &>(
738  static_cast<const GA_Detail *>(this)
739  ->getIndexMap(owner));
740  }
741  const GA_IndexMap &getPointMap() const { return myPointMap; }
742  const GA_IndexMap &getVertexMap() const { return myVertexMap; }
743  const GA_IndexMap &getPrimitiveMap() const { return myPrimitiveMap; }
744  const GA_IndexMap &getGlobalMap() const { return myGlobalMap; }
745 
746  /// This is a helpful class for getting the ranges of elements
747  /// created after such an OffsetMarker is declared. For example,
748  ///
749  /// GA_Detail::OffsetMarker marker(*gdp);
750  /// ... // Some code that creates points, vertices, or primitives
751  /// for (GA_Iterator it(marker.pointRange()); !it.atEnd(); ++it)
752  /// ... // Do something to each created point
753  /// for (GA_Iterator it(marker.vertexRange()); !it.atEnd(); ++it)
754  /// ... // Do something to each created vertex
755  /// for (GA_Iterator it(marker.primitiveRange()); !it.atEnd(); ++it)
756  /// ... // Do something to each created primitive
757  ///
758  /// NOTE: The code doing the creating can't delete elements from
759  /// the detail before adding any new elements.
761  {
762  public:
763  OffsetMarker(const GA_Detail &detail)
764  : myPointMarker(detail.getPointMap())
765  , myVertexMarker(detail.getVertexMap())
766  , myPrimitiveMarker(detail.getPrimitiveMap())
767  {}
769  { return myPointMarker.getRange(); }
771  { return myVertexMarker.getRange(); }
773  { return myPrimitiveMarker.getRange(); }
775  { return myPointMarker.getBegin(); }
777  { return myVertexMarker.getBegin(); }
779  { return myPrimitiveMarker.getBegin(); }
781  { return myPointMarker.getEnd(); }
783  { return myVertexMarker.getEnd(); }
785  { return myPrimitiveMarker.getEnd(); }
786  private:
787  const GA_IndexMap::Marker myPointMarker;
788  const GA_IndexMap::Marker myVertexMarker;
789  const GA_IndexMap::Marker myPrimitiveMarker;
790  };
791 
793  { return myPrimitiveList; }
795  { return myPrimitiveList; }
796  GA_AttributeSet &getAttributes() { return myAttributes; }
797  const GA_AttributeSet &getAttributes() const{ return myAttributes; }
798  GA_Topology &getTopology() { return myTopology; }
799  const GA_Topology &getTopology() const { return myTopology; }
800  bool checkValidTopology() const;
801  void createTopologyAttributes();
802  void clearTopologyAttributes();
803 
804  /// This bumps all data IDs in this detail, including
805  /// point, vertex, primitive, and detail attribute data IDs,
806  /// the primitive list data ID, and edge group data IDs.
807  void bumpAllDataIds();
808 
809  /// Call this to bump the appropriate topology data IDs when
810  /// vertices have been rewired to different points.
811  ///
812  /// If vertices have been added or removed, or if they've been
813  /// "stolen" by a different primitive,
814  /// just call bumpDataIdsForAddOrRemove(____,true,____) instead.
815  /// If points have been added or removed, but vertices have
816  /// only been rewired, call bumpDataIdsForAddOrRemove(true,false,false)
817  /// in addition to this.
818  void bumpDataIdsForRewire();
819 
820  /// Call this to bump the appropriate data IDs when points, vertices,
821  /// or primitives have been added or removed. If you're not 100%
822  /// sure whether an element type has been added or removed,
823  /// it's better to err on the side of safety and pass true for it.
824  void bumpDataIdsForAddOrRemove(
825  bool added_or_removed_points,
826  bool added_or_removed_vertices,
827  bool added_or_removed_primitives);
828 
829  /// @{
830  /// Get access to the attributes for one element type
831  GA_AttributeOwner getAttributeOwner(const GA_AttributeDict &dict) const;
833  { return myAttributes.getDict(owner); }
834  /// @}
835 
836  /// Defragment index maps
837  /// NOTE: To make sure that it actually defragments when there is even just
838  /// one hole, you must pass a UT_Options with a "removeholes"
839  /// bool option set to true.
840  /// NOTE: If any defragmenting occurs, this bumps data IDs for everything
841  /// that is modified.
842  bool defragment(GA_AttributeOwner owner,
843  const UT_Options *options = nullptr);
844  /// Defragment everything.
845  /// NOTE: To make sure that it actually defragments when there is even just
846  /// one hole, you must pass a UT_Options with a "removeholes"
847  /// bool option set to true.
848  /// NOTE: If any defragmenting occurs, this bumps data IDs for everything
849  /// that is modified.
850  bool defragment(const UT_Options *options = nullptr);
851 
852  /// Optimized layout of vertex index map. This sorts the vertex index map
853  /// by the primitive order use. The map will be defragmented after this
854  /// function is called.
855  void sortVertexMapByPrimitiveUse();
856 
857  // -------------- Attributes ----------------------------
858 
859  /// @{
860  /// createAttribute is very general purpose method, requiring
861  /// some knowledge about ATIs, etc. Unless you are creating
862  /// your own user-defined attributes, it would likely be better
863  /// to use something at the GEO_Detail level, like addFloatTuple.
865  GA_AttributeScope scope,
866  const UT_StringHolder &name,
867  const UT_Options *create_args,
868  const GA_AttributeOptions *attribute_options,
869  const UT_StringRef &attribtype)
870  {
871  return myAttributes.createAttribute(
872  owner, scope, name, create_args,
873  attribute_options, attribtype);
874  }
876  const UT_StringHolder &name,
877  const UT_Options *create_args,
878  const GA_AttributeOptions *attribute_options,
879  const UT_StringRef &attribtype)
880  {
881  return myAttributes.createAttribute(
882  owner, name, create_args,
883  attribute_options, attribtype);
884  }
885  /// @}
886 
887  /// This will create detached attributes. They will have the right number
888  /// of elements at the moment of creation, but will not update with changes
889  /// to the detail. These attributes will have no name.
890  /// @{
893  GA_AttributeOwner owner,
895  int tuple_size,
896  const GA_Defaults &defaults=GA_Defaults(0.0f),
897  const GA_AttributeOptions *attribute_options = nullptr) const
898  {
899  return myAttributes.createDetachedTupleAttribute(
900  owner, storage, tuple_size,
901  defaults, attribute_options);
902  }
903 
906  GA_AttributeOwner owner,
907  const UT_StringRef &attribtype,
908  const UT_Options *create_args = nullptr,
909  const GA_AttributeOptions *attribute_options = nullptr) const
910  {
911  return myAttributes.createDetachedAttribute(
912  owner, attribtype, create_args,
913  attribute_options);
914  }
915 
918  GA_AttributeOwner owner,
919  const GA_AttributeType &attribtype,
920  const UT_Options *create_args = nullptr,
921  const GA_AttributeOptions *attribute_options = nullptr) const
922  {
923  return myAttributes.createDetachedAttribute(
924  owner, attribtype, create_args,
925  attribute_options);
926  }
927  /// @}
928 
931  GA_AttributeScope scope,
932  const UT_StringRef &name)
933  {
934  return myAttributes.destroyAttribute(owner,
935  scope, name);
936  }
939  const UT_StringRef &name)
940  {
941  return myAttributes.destroyAttribute(owner, name);
942  }
945  GA_AttributeScope scope,
946  const UT_StringRef &from_name,
947  const UT_StringHolder &to_name)
948  {
949  return myAttributes.renameAttribute(owner, scope,
950  from_name, to_name);
951  }
952 
953  // Convenience attribute methods
955  GA_AttributeScope scope,
956  const UT_StringHolder &name,
957  GA_Storage storage,
958  int tuple_size,
959  const GA_Defaults &defaults = GA_Defaults(0.0f),
960  const UT_Options *create_args = nullptr,
961  const GA_AttributeOptions *attribute_options = nullptr)
962  {
963  return myAttributes.createTupleAttribute(
964  owner, scope, name, storage,
965  tuple_size, defaults,
966  create_args,
967  attribute_options);
968  }
970  const UT_StringHolder &name,
971  GA_Storage storage,
972  int tuple_size,
973  const GA_Defaults &defaults = GA_Defaults(0.0f),
974  const UT_Options *create_args = nullptr,
975  const GA_AttributeOptions *attribute_options = nullptr)
976  {
977  return myAttributes.createTupleAttribute(
978  owner, name, storage,
979  tuple_size, defaults,
980  create_args,
981  attribute_options);
982  }
984  GA_AttributeScope scope,
985  const UT_StringHolder &name,
986  const UT_Options *create_args=nullptr,
987  const GA_AttributeOptions *attribute_options=nullptr)
988  {
989  return myAttributes.createStringAttribute(
990  owner, scope, name, 1,
991  create_args,
992  attribute_options);
993  }
995  const UT_StringHolder &name,
996  const UT_Options *create_args=nullptr,
997  const GA_AttributeOptions *attribute_options=nullptr)
998  {
999  return myAttributes.createStringAttribute(
1000  owner, name, 1, create_args,
1001  attribute_options);
1002  }
1003 
1004  /// Find an existing attribute, returning a read-only reference.
1005  ///
1008  const UT_StringRef &name,
1009  const GA_AttributeOwner search_order[],
1010  int search_size) const
1011  {
1012  return myAttributes.findAttribute(
1013  scope, name, search_order,
1014  search_size);
1015  }
1018  const GA_AttributeOwner search_order[],
1019  int search_size) const
1020  {
1021  return myAttributes.findAttribute(
1022  name, search_order, search_size);
1023  }
1026  GA_AttributeScope scope,
1027  const UT_StringRef &name) const
1028  { return findAttribute(scope, name, &owner, 1); }
1031  const UT_StringRef &name) const
1032  { return findAttribute(name, &owner, 1); }
1035  const UT_StringRef &name) const
1036  { return findAttribute(GA_ATTRIB_POINT, s, name); }
1039  { return findAttribute(GA_ATTRIB_POINT, name); }
1042  const UT_StringRef &name) const
1043  { return findAttribute(GA_ATTRIB_VERTEX,s, name); }
1046  { return findAttribute(GA_ATTRIB_VERTEX, name); }
1049  const UT_StringRef &name) const
1050  {return findAttribute(GA_ATTRIB_PRIMITIVE,s,name);}
1053  {return findAttribute(GA_ATTRIB_PRIMITIVE, name);}
1056  const UT_StringRef &name) const
1057  { return findAttribute(GA_ATTRIB_GLOBAL,s, name); }
1060  { return findAttribute(GA_ATTRIB_GLOBAL, name); }
1061 
1062  /// Find an existing attribute, returning a read-write reference.
1063  ///
1066  const UT_StringRef &name,
1067  const GA_AttributeOwner search_order[],
1068  int search_size)
1069  {
1070  return myAttributes.findAttribute(
1071  scope, name, search_order,
1072  search_size);
1073  }
1076  const GA_AttributeOwner search_order[],
1077  int search_size)
1078  {
1079  return myAttributes.findAttribute(
1080  name, search_order, search_size);
1081  }
1084  GA_AttributeScope scope,
1085  const UT_StringRef &name)
1086  { return findAttribute(scope, name, &owner, 1); }
1089  const UT_StringRef &name)
1090  { return findAttribute(name, &owner, 1); }
1093  const UT_StringRef &name)
1094  { return findAttribute(GA_ATTRIB_POINT, s, name); }
1097  { return findAttribute(GA_ATTRIB_POINT, name); }
1100  const UT_StringRef &name)
1101  { return findAttribute(GA_ATTRIB_VERTEX,s, name); }
1104  { return findAttribute(GA_ATTRIB_VERTEX, name); }
1107  const UT_StringRef &name)
1108  {return findAttribute(GA_ATTRIB_PRIMITIVE,s,name);}
1111  {return findAttribute(GA_ATTRIB_PRIMITIVE, name);}
1114  const UT_StringRef &name)
1115  { return findAttribute(GA_ATTRIB_GLOBAL,s, name); }
1118  { return findAttribute(GA_ATTRIB_GLOBAL, name); }
1119 
1120  /// Get/set all the point attribute data from/to a contiguous array
1121  // @{
1122 
1123  /// Valid types for T are:
1124  /// int32, int64, fpreal32, fpreal64,
1125  /// UT_Vector2T<S>, UT_Vector3T<S>, UT_Vector4T<S>,
1126  /// UT_QuaternionT<S>, UT_Matrix3T<S>, UT_Matrix4T<S>
1127  /// where S is one of: fpreal, fpreal32, fpreal64,
1128  /// For the UT_Vector classes, S can also be one of: int, int32, int64
1129  template <typename T>
1130  bool getAttributeAsArray(
1131  const GA_Attribute *atr,
1132  const GA_Range &range,
1133  UT_Array<T> &result) const;
1134 
1135  /// Valid types for T are:
1136  /// int32, int64, fpreal32, fpreal64,
1137  /// UT_Vector2T<S>, UT_Vector3T<S>, UT_Vector4T<S>,
1138  /// UT_QuaternionT<S>, UT_Matrix3T<S>, UT_Matrix4T<S>
1139  /// where S is one of: fpreal, fpreal32, fpreal64,
1140  /// For the UT_Vector classes, S can also be one of: int, int32, int64
1141  template <typename T>
1142  bool setAttributeFromArray(
1143  GA_Attribute *atr,
1144  const GA_Range &range,
1145  const UT_Array<T> &src);
1146  // @}
1147 
1148  // -------------- Groups ---------------------------------
1149  GA_ElementGroup *createElementGroup(GA_AttributeOwner owner,
1150  const UT_StringHolder &name,
1151  bool ordered=false);
1152  GA_ElementGroup *createInternalElementGroup(GA_AttributeOwner owner,
1153  bool ordered=false);
1154  GA_ElementGroup *findElementGroup(GA_AttributeOwner owner,
1155  const UT_StringRef &name);
1156  const GA_ElementGroup *findElementGroup(GA_AttributeOwner owner,
1157  const UT_StringRef &name) const;
1158 
1159  // Only accepts GA_ATTRIB_POINT,GA_ATTRIB_VERTEX,GA_ATTRIB_PRIMITIVE
1160  const GA_ElementGroupTable &
1161  getElementGroupTable(GA_AttributeOwner owner) const;
1164  {
1165  return const_cast<GA_ElementGroupTable &>(
1166  static_cast<const GA_Detail *>(this)
1167  ->getElementGroupTable(owner));
1168  }
1169 
1170  // Gets any group table.
1171  GA_GroupTable *getGroupTable(GA_GroupType group_type);
1172  const GA_GroupTable *getGroupTable(GA_GroupType group_type) const;
1173 
1174  /// @{
1175  /// Access point, primitive, vertex, or edge group tables
1177  { return myPointGroups; }
1179  { return myPointGroups; }
1181  { return myPrimitiveGroups; }
1183  { return myPrimitiveGroups; }
1185  { return myVertexGroups; }
1187  { return myVertexGroups; }
1189  { return myEdgeGroups; }
1191  { return myEdgeGroups; }
1192  /// @}
1193 
1194  template <GA_AttributeOwner OWNER>
1198  bool ordered=false)
1199  {
1201  createElementGroup(OWNER, name, ordered));
1202  }
1203 
1204  template <GA_AttributeOwner OWNER>
1207  createInternalElementGroup(bool ordered=false)
1208  {
1210  createInternalElementGroup(OWNER,ordered));
1211  }
1212 
1213  template <GA_AttributeOwner OWNER>
1217  {
1219  findElementGroup(OWNER, name));
1220  }
1221  template <GA_AttributeOwner OWNER>
1224  findElementGroup(const UT_StringRef &name) const
1225  {
1227  findElementGroup(OWNER, name));
1228  }
1229 
1230  void getElementGroupList(GA_AttributeOwner owner,
1231  UT_Array<const GA_ElementGroup *> &list) const;
1232  void getElementGroupList(GA_AttributeOwner owner,
1236  const UT_StringRef &name)
1237  { return getElementGroupTable(owner).destroy(name); }
1240  const char *name)
1241  { return getElementGroupTable(owner).destroy(name); }
1242  bool destroyElementGroup(GA_ElementGroup *group);
1243  bool destroyGroup(GA_Group *group);
1244 
1245  // Convenience group methods
1247  const GA_PointGroup *findPointGroup(const UT_StringRef &name) const
1248  { return findElementGroup<GA_ATTRIB_POINT>(name); }
1250  const GA_VertexGroup *findVertexGroup(const UT_StringRef &name) const
1251  { return findElementGroup<GA_ATTRIB_VERTEX>(name); }
1254  { return findElementGroup<GA_ATTRIB_PRIMITIVE>(name); }
1255 
1258  { return findElementGroup<GA_ATTRIB_POINT>(name); }
1261  { return findElementGroup<GA_ATTRIB_VERTEX>(name); }
1264  { return findElementGroup<GA_ATTRIB_PRIMITIVE>(name); }
1265 
1266  GA_EdgeGroup *createEdgeGroup(const UT_StringHolder &name);
1267  GA_EdgeGroup *createInternalEdgeGroup();
1268  const GA_EdgeGroup *findEdgeGroup(const UT_StringRef &name) const;
1269  GA_EdgeGroup *findEdgeGroup(const UT_StringRef &name);
1270  void getEdgeGroupList(
1271  UT_Array<const GA_EdgeGroup *> &list) const;
1272  void getEdgeGroupList(
1273  UT_Array<GA_EdgeGroup *> &list);
1275  bool destroyEdgeGroup(const UT_StringRef &name)
1276  { return myEdgeGroups.destroy(name); }
1279  { return g ? myEdgeGroups.destroy(g) : false; }
1280 
1281  // Utility group functions
1282  GA_Size destroyEmptyGroups(GA_AttributeOwner owner);
1283  GA_Size destroyAllEmptyGroups();
1284 
1285  /// Creates a non-internal group with the specified name,
1286  /// owned by this detail.
1287  /// @{
1289  {
1290  return static_cast<GA_PointGroup *>(pointGroups().newGroup(name));
1291  }
1293  {
1294  return static_cast<GA_VertexGroup *>(vertexGroups().newGroup(name));
1295  }
1297  {
1298  return static_cast<GA_PrimitiveGroup *>(primitiveGroups().newGroup(name));
1299  }
1301  {
1302  return static_cast<GA_EdgeGroup *>(edgeGroups().newGroup(name));
1303  }
1304  /// @}
1305 
1306  /// Creates an internal group with a unique name,
1307  /// owned by this detail.
1308  /// Be sure to call GA_Detail::destroyGroup (or destroyElementGroup)
1309  /// with this group to clean it up.
1310  /// @{
1312  {
1313  return static_cast<GA_PointGroup *>(pointGroups().newInternalGroup());
1314  }
1316  {
1317  return static_cast<GA_VertexGroup *>(vertexGroups().newInternalGroup());
1318  }
1320  {
1321  return static_cast<GA_PrimitiveGroup *>(primitiveGroups().newInternalGroup());
1322  }
1324  {
1325  return static_cast<GA_EdgeGroup *>(edgeGroups().newInternalGroup());
1326  }
1327  /// @}
1328 
1329  /// Creates a detached group with no name, owned by the caller.
1330  /// NOTE: The detail knows nothing about any detached groups that
1331  /// are created so these become invalid if the detail is modified.
1332  /// @{
1333  /// Be sure to do "delete group;" to clean it up.
1334  SYS_DEPRECATED_REPLACE(20.0, "createDetachedPointGroup")
1335  GA_PointGroup *newDetachedPointGroup() const
1336  {
1337  return new GA_PointGroup(*this);
1338  }
1339  /// Be sure to do "delete group;" to clean it up.
1340  SYS_DEPRECATED_REPLACE(20.0, "createDetachedPrimitiveGroup")
1341  GA_PrimitiveGroup *newDetachedPrimitiveGroup() const
1342  {
1343  return new GA_PrimitiveGroup(*this);
1344  }
1345  /// Be sure to do "delete group;" to clean it up.
1346  SYS_DEPRECATED_REPLACE(20.0, "createDetachedVertexGroup")
1347  GA_VertexGroup *newDetachedVertexGroup() const
1348  {
1349  return new GA_VertexGroup(*this);
1350  }
1351  /// Be sure to do "delete group;" to clean it up.
1352  SYS_DEPRECATED_REPLACE(20.0, "createDetachedEdgeGroup")
1353  GA_EdgeGroup *newDetachedEdgeGroup() const
1354  {
1355  return new GA_EdgeGroup(*this);
1356  }
1357 
1359  {
1360  return UTmakeUnique<GA_PointGroup>(*this);
1361  }
1363  {
1364  return UTmakeUnique<GA_PrimitiveGroup>(*this);
1365  }
1367  {
1368  return UTmakeUnique<GA_VertexGroup>(*this);
1369  }
1371  {
1372  return UTmakeUnique<GA_EdgeGroup>(*this);
1373  }
1374  /// @}
1375 
1376  /// TODO: Deprecate internal groups with user-specified names.
1377  /// @{
1378  GA_PointGroup *newPointGroup(const UT_StringHolder &name, bool internal)
1379  {
1380  return static_cast<GA_PointGroup *>(pointGroups().newGroup(name, internal));
1381  }
1383  {
1384  return static_cast<GA_PrimitiveGroup *>(primitiveGroups().newGroup(name, internal));
1385  }
1386  GA_VertexGroup *newVertexGroup(const UT_StringHolder &name, bool internal)
1387  {
1388  return static_cast<GA_VertexGroup *>(vertexGroups().newGroup(name, internal));
1389  }
1390  GA_EdgeGroup *newEdgeGroup(const UT_StringHolder &name, bool internal)
1391  {
1392  return static_cast<GA_EdgeGroup *>(edgeGroups().newGroup(name, internal));
1393  }
1394  /// @}
1395 
1396  // -------------- Intrinsics ------------------------
1397  /// Register global intrinsics.
1398  /// Each subclass should have registration which looks like: @code
1399  /// SubClass::registerIntrinsics(GA_PrimitiveFactory &factory)
1400  /// {
1401  /// GA_LocalIntrinsicMap map(factory.getDetailIntrinsics());
1402  /// BaseClass::registerIntrinsics(factory);
1403  /// map.addAttribute(...);
1404  /// map.addAttribute(...);
1405  /// }
1406  /// @endcode
1408  registerIntrinsics(GA_PrimitiveFactory &factory);
1409 
1410  /// Get the intrinsic manager for global/detail intrinsics.
1411  ///
1412  /// At the current time, these include:
1413  /// - "string globaltokens[]" @n List of all global/detail intrinsics
1414  /// - "string primitivetokens[]" @n List of all primitive intrinsics
1415  /// - "int vertexcount" @n Number of vertices in the detail
1416  /// - "int pointcount" @n Number of points in the detail
1417  /// - "int primitivecount" @n Number of primitives in the detail
1419  { return myPrimitiveFactory.getDetailIntrinsics(); }
1420 
1421  /// @{
1422  /// Query properties of the @b global/detail intrinsic
1423  /// Note that the tuple size calls the virtual method since the tuple size
1424  /// may be dynamic (i.e. basis knot vector)
1426  { return getIntrinsicManager().getLocalHandle(nm); }
1428  { return getIntrinsicManager().getLocalHandle(h); }
1430  { return getIntrinsicManager().getGlobalHandle(h); }
1431 
1433  { return getIntrinsicManager().getName(h); }
1434  GA_Size getIntrinsicTupleSize(GA_LocalIntrinsic h) const;
1436  { return getIntrinsicManager().getStorage(h); }
1438  { return getIntrinsicManager().getReadOnly(h); }
1440  { return getIntrinsicManager().getOptions(h); }
1441  /// @}
1442 
1443  /// @{
1444  /// Get the value of a global/detail intrinsic.
1445  /// These methods return the number of items retrieved.
1446  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_String &val) const;
1447  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_StringArray &val) const;
1448  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_OptionsHolder &val) const;
1450  GA_Size getIntrinsic(GA_LocalIntrinsic h, int64 *v, GA_Size size) const;
1451  GA_Size getIntrinsic(GA_LocalIntrinsic h, fpreal64 *v, GA_Size sz) const;
1452  /// @}
1453 
1454  /// @{
1455  /// Get the value of a global/detail intrinsic.
1456  /// Returns false if not the right type or not found.
1457  /// Always will clear out the provided value.
1458  bool getIntrinsic(GA_LocalIntrinsic h, float &v) const;
1459  bool getIntrinsic(GA_LocalIntrinsic h, int &v) const;
1460  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector2 &v) const;
1461  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector3 &v) const;
1462  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector4 &v) const;
1463  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix2 &v) const;
1464  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix3 &v) const;
1465  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix4 &v) const;
1466  bool getIntrinsic(GA_LocalIntrinsic h, double &v) const;
1467  bool getIntrinsic(GA_LocalIntrinsic h, int64 &v) const;
1468  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector2D &v) const;
1469  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector3D &v) const;
1470  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector4D &v) const;
1471  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix2D &v) const;
1472  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix3D &v) const;
1473  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix4D &v) const;
1474 
1475  /// @}
1476 
1477  /// @{
1478  /// Set intrinsic. This will fail if the intrinsic is read-only.
1479  /// These methods return the number of items set.
1480  GA_Size setIntrinsic(GA_LocalIntrinsic h, const char *value);
1481  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_StringArray &value);
1482  GA_Size setIntrinsic(GA_LocalIntrinsic h, const char **val, GA_Size s);
1483  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_OptionsHolder &val);
1485  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_OptionsHolder *val, GA_Size s);
1486  GA_Size setIntrinsic(GA_LocalIntrinsic h, const int64 val);
1487  GA_Size setIntrinsic(GA_LocalIntrinsic h, const fpreal64 val);
1488  GA_Size setIntrinsic(GA_LocalIntrinsic h, const int64 *val, GA_Size sz);
1489  GA_Size setIntrinsic(GA_LocalIntrinsic h, const fpreal64 *v, GA_Size sz);
1490  /// @}
1491 
1492  /// Calls functor on every active point offset.
1493  /// This is easiest to use with C++ lambdas, e.g.:
1494  /// detail.forEachPoint([&vec,&detail](GA_Offset ptoff) {
1495  /// vec += detail.getPos3(ptoff);
1496  /// });
1497  template<typename FUNCTOR>
1499  void forEachPoint(FUNCTOR &&functor) const
1500  {
1501  myPointMap.forEachOffset(functor);
1502  }
1503 
1504  /// Calls functor on every point offset in a group.
1505  /// This is easiest to use with C++ lambdas, e.g.:
1506  /// detail.forEachPoint(group, [&vec,&detail](GA_Offset ptoff) {
1507  /// vec += detail.getPos3(ptoff);
1508  /// });
1509  template<typename FUNCTOR>
1511  void forEachPoint(const GA_PointGroup *group, FUNCTOR &&functor) const
1512  {
1513  forEachOffset(functor, myPointMap, group);
1514  }
1515 
1516  /// Calls functor on every point offset in a group, (or not in a group
1517  /// if complement is true).
1518  template<typename FUNCTOR>
1520  void forEachPoint(const GA_PointGroup *group, bool complement, FUNCTOR &&functor) const
1521  {
1522  forEachOffset(functor, myPointMap, group, complement);
1523  }
1524 
1525  /// Like forEachPoint, except taking a functor that
1526  /// returns true to continue, and false to break.
1527  /// @{
1528  template<typename FUNCTOR>
1530  void forEachPointBreak(FUNCTOR &&functor) const
1531  {
1532  myPointMap.forEachOffsetBreak(functor);
1533  }
1534  template<typename FUNCTOR>
1536  void forEachPointBreak(const GA_PointGroup *group, FUNCTOR &&functor) const
1537  {
1538  forEachOffset(functor, myPointMap, group);
1539  }
1540  template<typename FUNCTOR>
1542  void forEachPointBreak(const GA_PointGroup *group, bool complement, FUNCTOR &&functor) const
1543  {
1544  forEachOffset(functor, myPointMap, group, complement);
1545  }
1546  /// @}
1547 
1548  /// Calls functor on every active primitive offset.
1549  /// This is easiest to use with C++ lambdas, e.g.:
1550  /// detail.forEachPrimitive([&tris,&detail](GA_Offset primoff) {
1551  /// if (detail.getPrimitiveMap().getTypeId(primoff) != GA_PRIMPOLY)
1552  /// return;
1553  /// GA_OffsetListRef vertices = detail.getPrimitiveMap().getVertexList(primoff);
1554  /// if (vertices.size() == 3 && vertices.getExtraFlag())
1555  /// tris.addOffset(primoff);
1556  /// });
1557  template<typename FUNCTOR>
1559  void forEachPrimitive(FUNCTOR &&functor) const
1560  {
1561  myPrimitiveMap.forEachOffset(functor);
1562  }
1563 
1564  /// Calls functor on every primitive offset in a group.
1565  /// This is easiest to use with C++ lambdas, e.g.:
1566  /// detail.forEachPrimitive(group, [&tris,&detail](GA_Offset primoff) {
1567  /// if (detail.getPrimitiveMap().getTypeId(primoff) != GA_PRIMPOLY)
1568  /// return;
1569  /// GA_OffsetListRef vertices = detail.getPrimitiveMap().getVertexList(primoff);
1570  /// if (vertices.size() == 3 && vertices.getExtraFlag())
1571  /// tris.addOffset(primoff);
1572  /// });
1573  template<typename FUNCTOR>
1575  void forEachPrimitive(const GA_PrimitiveGroup *group, FUNCTOR &&functor) const
1576  {
1577  forEachOffset(functor, myPrimitiveMap, group);
1578  }
1579 
1580  /// Calls functor on every primitive offset in a group, (or not in a group
1581  /// if complement is true).
1582  template<typename FUNCTOR>
1584  void forEachPrimitive(const GA_PrimitiveGroup *group, bool complement, FUNCTOR &&functor) const
1585  {
1586  forEachOffset(functor, myPrimitiveMap, group, complement);
1587  }
1588 
1589  /// Like forEachPrimitive, except taking a functor that
1590  /// returns true to continue, and false to break.
1591  /// @{
1592  template<typename FUNCTOR>
1594  void forEachPrimitiveBreak(FUNCTOR &&functor) const
1595  {
1596  myPrimitiveMap.forEachOffsetBreak(functor);
1597  }
1598  template<typename FUNCTOR>
1600  void forEachPrimitiveBreak(const GA_PrimitiveGroup *group, FUNCTOR &&functor) const
1601  {
1602  forEachOffsetBreak(functor, myPrimitiveMap, group);
1603  }
1604  template<typename FUNCTOR>
1606  void forEachPrimitiveBreak(const GA_PrimitiveGroup *group, bool complement, FUNCTOR &&functor) const
1607  {
1608  forEachOffsetBreak(functor, myPrimitiveMap, group, complement);
1609  }
1610  /// @}
1611 
1612  template<typename FUNCTOR>
1613  static void forEachOffset(FUNCTOR &&functor, const GA_IndexMap &index_map, const GA_ElementGroup *group = nullptr, bool complement = false)
1614  {
1615  // Fall back to regular case if no group.
1616  if (!group)
1617  {
1618  if (!complement)
1619  index_map.forEachOffset(functor);
1620  return;
1621  }
1622 
1623  // Group order is only relevant if not complemented.
1624  if (!complement)
1625  {
1626  const GA_ElementGroupOrder *order = group->getOrdered();
1627  if (order)
1628  {
1629  for (GA_ElementGroupOrderIndex i(0), n(order->entries()); i != n; ++i)
1630  {
1631  GA_Offset off = order->getElement(i);
1632  functor(off);
1633  }
1634  return;
1635  }
1636  }
1637 
1638  // We have a group, treated as unordered.
1639  const GA_Offset veryend = index_map.offsetSize();
1640  GA_Offset off(0);
1641  while (true)
1642  {
1643  bool value;
1644  GA_Size span_size;
1645  group->getConstantSpan(off, veryend, span_size, value);
1646  if (span_size == 0)
1647  break;
1648  if (value == complement)
1649  {
1650  off += span_size;
1651  continue;
1652  }
1653  const GA_Offset span_end = off+span_size;
1654  while (true)
1655  {
1656  off = index_map.findActiveOffset(off, span_end);
1657  GA_Offset end = index_map.findInactiveOffset(off, span_end);
1658  if (off == end)
1659  break;
1660  do
1661  {
1662  functor(off);
1663  ++off;
1664  } while (off != end);
1665  }
1666  }
1667  }
1668 
1669  template<typename FUNCTOR>
1670  static void forEachOffsetBreak(FUNCTOR &&functor, const GA_IndexMap &index_map, const GA_ElementGroup *group = nullptr, bool complement = false)
1671  {
1672  // Fall back to regular case if no group.
1673  if (!group)
1674  {
1675  if (!complement)
1676  index_map.forEachOffsetBreak(functor);
1677  return;
1678  }
1679 
1680  // Group order is only relevant if not complemented.
1681  if (!complement)
1682  {
1683  const GA_ElementGroupOrder *order = group->getOrdered();
1684  if (order)
1685  {
1686  for (GA_ElementGroupOrderIndex i(0), n(order->entries()); i != n; ++i)
1687  {
1688  GA_Offset off = order->getElement(i);
1689  if (!functor(off))
1690  return;
1691  }
1692  return;
1693  }
1694  }
1695 
1696  // We have a group, treated as unordered.
1697  const GA_Offset veryend = index_map.offsetSize();
1698  GA_Offset off(0);
1699  while (true)
1700  {
1701  bool value;
1702  GA_Size span_size;
1703  group->getConstantSpan(off, veryend, span_size, value);
1704  if (span_size == 0)
1705  break;
1706  if (value == complement)
1707  {
1708  off += span_size;
1709  continue;
1710  }
1711  const GA_Offset span_end = off+span_size;
1712  while (true)
1713  {
1714  off = index_map.findActiveOffset(off, span_end);
1715  GA_Offset end = index_map.findInactiveOffset(off, span_end);
1716  if (off == end)
1717  break;
1718  do
1719  {
1720  if (!functor(off))
1721  return;
1722  ++off;
1723  } while (off != end);
1724  }
1725  }
1726  }
1727 
1728  // -------------- Range Accessors --------------------------
1729  /// Get a range of all points in the detail
1730  GA_Range getPointRange(const GA_PointGroup *group = 0) const
1731  { return GA_Range(getPointMap(), group); }
1732  /// Get a range of all primitives in the detail
1734  { return GA_Range(getPrimitiveMap(), group); }
1735 
1736  /// Get ordered point range from base_ptnum to end_ptnum, or the end
1738  GA_Index begin_ptnum,
1739  GA_Index end_ptnum = GA_INVALID_INDEX) const
1740  {
1741  GA_Range::ordered ordered;
1742  if (!GAisValid(end_ptnum))
1743  end_ptnum = GA_Index(getNumPoints());
1744  return GA_Range(getPointMap(), begin_ptnum, end_ptnum,
1745  ordered);
1746  }
1747  /// Get ordered primitive range from base_prim to end_prim, or the end
1749  GA_Index begin_prim,
1750  GA_Index end_prim = GA_INVALID_INDEX) const
1751  {
1752  GA_Range::ordered ordered;
1753  if (!GAisValid(end_prim))
1754  end_prim = GA_Index(getNumPrimitives());
1755  return GA_Range(getPrimitiveMap(),
1756  begin_prim, end_prim, ordered);
1757  }
1758 
1759  /// Get a range of all vertices in the detail
1760  GA_Range getVertexRange(const GA_VertexGroup *group = 0) const
1761  { return GA_Range(getVertexMap(), group); }
1762  /// Get a range representing the global (detail) data
1764  { return GA_Range(getGlobalMap()); }
1765 
1766  // -------------- Common Operations ------------------------
1767  /// Compute memory usage (includes all shared memory)
1768  virtual int64 getMemoryUsage(bool inclusive) const;
1769 
1770  /// Count memory usage using a UT_MemoryCounter in order to count
1771  /// shared memory correctly.
1772  /// If inclusive is true, the size of this object is counted,
1773  /// else only memory owned by this object is counted.
1774  /// If this is pointed to by the calling object, inclusive should be true.
1775  /// If this is contained in the calling object, inclusive should be false.
1776  /// (Its memory was already counted in the size of the calling object.)
1777  virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const;
1778 
1779  // Computing the bounding box. Depending on the element being iterated,
1780  // either the point or primitive bounding box will be computed. When a
1781  // P attribute argument is not present, the detail's position attribute
1782  // is used.
1783  bool enlargeBoundingBox(UT_BoundingRect &box,
1784  const GA_Range &range) const;
1785  bool enlargeBoundingBox(UT_BoundingRect &box,
1786  const GA_Range &range,
1787  const GA_Attribute *P) const;
1788  bool enlargeBoundingBox(UT_BoundingBox &box,
1789  const GA_Range &range) const;
1790  bool enlargeBoundingBox(UT_BoundingBox &box,
1791  const GA_Range &range,
1792  const GA_Attribute *P) const;
1793 
1794  /// Compute the bounding box quickly by:
1795  /// - Computing the point bounding box of "P"
1796  /// - Computing the maximum extents of all primitives
1797  /// This requires a single pass through the P attribute along with a single
1798  /// pass through primitives.
1799  void computeQuickBounds(UT_BoundingBox &box) const;
1800 
1801  /// Compute the bounding box quickly by:
1802  /// - Computing the point bounding box of "P"
1803  /// - Computing the maximum extents of all primitives
1804  /// - Count the number of each type of primitive in the detail
1805  /// This requires a single pass through the P attribute along with a single
1806  /// pass through primitives.
1807  /// The @c counts buffer will be filled with the count of each primitive
1808  /// type in the detail. The count_buf_size should be set to
1809  /// @c getPrimitiveFactory().getPrimTypeCount();
1810  void computeQuickBounds(UT_BoundingBox &box,
1811  GA_Size counts[], GA_Size count_buf_size) const;
1812 
1813  /// Create a new detail that has all the same attributes, groups, etc. but
1814  /// has no elements.
1815  /// Subclasses should look at: cloneCopyGroupsAndAttributes()
1816  virtual GA_Detail *cloneEmptyDetail(bool clone_attributes) const = 0;
1817 
1818  /// Copy groups and attribute definitions from the source detail.
1819  ///
1820  /// The caller should ensure that all attributes are cleared before calling
1821  /// this method (i.e. call clear())
1822  void cloneCopyGroupsAndAttributes(const GA_Detail &src,
1823  bool copydetailattribs = false);
1824 
1825  /// Copy all attribute values from srcoff to destoff for
1826  /// attributes accepted by filter. If no filter is specified,
1827  /// all public attributes and non-internal groups are copied.
1828  ///
1829  /// NOTE: If you're copying multiple offsets, it's *much* faster to do:
1830  /// For each attribute, copy data for all offsets;
1831  /// rather than:
1832  /// For each offset, copy data in all attributes.
1833  /// These functions are only for if the former is too awkward
1834  /// to do in some case.
1835  /// @{
1836  void copyAttributes(
1837  GA_AttributeOwner owner,
1838  GA_Offset destoff,
1839  GA_Offset srcoff,
1840  const GA_AttributeFilter *filter = nullptr);
1841  void copyAttributes(
1842  GA_AttributeOwner owner,
1843  GA_Offset destoff,
1844  const GA_Detail &srcdetail,
1845  GA_Offset srcoff,
1846  const GA_AttributeFilter *filter = nullptr);
1847  /// @}
1848 
1849  /// Copy all attribute values from srcptoff to destptoff for point
1850  /// attributes accepted by filter. If no filter is specified,
1851  /// all public attributes and non-internal groups are copied.
1854  GA_Offset destptoff,
1855  GA_Offset srcptoff,
1856  const GA_AttributeFilter *filter = nullptr)
1857  {
1858  copyAttributes(GA_ATTRIB_POINT, destptoff, srcptoff, filter);
1859  }
1860 
1861  /// Copy all attribute values from srcvtxoff to destvtxoff for vertex
1862  /// attributes accepted by filter. If no filter is specified,
1863  /// all public attributes and non-internal groups are copied.
1864  /// If ref_point_dont_copy is true, the point of srcvtxoff is
1865  /// referenced by destvtxoff, otherwise point attributes are also
1866  /// copied.
1867  /// NOTE: If you only want to copy vertex attributes, and not the
1868  /// point, call copyAttributes(GA_ATTRIB_VERTEX, ...)
1870  GA_Offset destvtxoff,
1871  GA_Offset srcvtxoff,
1872  bool ref_point_dont_copy,
1873  const GA_AttributeFilter *filter = nullptr)
1874  {
1875  GA_Offset srcptoff = vertexPoint(srcvtxoff);
1876  if (ref_point_dont_copy)
1877  setVertexPoint(destvtxoff, srcptoff);
1878  else
1879  copyPoint(vertexPoint(destvtxoff), srcptoff, filter);
1880  copyAttributes(GA_ATTRIB_VERTEX, destvtxoff, srcvtxoff, filter);
1881  }
1882 
1883  /// Merge the source detail into this detail (using default options)
1884  void baseMerge(const GA_Detail &src);
1885  /// Merge the source detail into this detail with options
1886  void baseMerge(const GA_Detail &src,
1887  GA_MergeOptions &options);
1888 
1889  /// Fast version of merge for the common case of completely replacing
1890  /// all of this detail with the source detail, using data IDs to avoid
1891  /// copying things that are the same. This does not copy private
1892  /// scope attributes (except topology) or internal groups.
1893  /// When skip is given, all processing of attributes matching the filter
1894  /// will be skipped. The result is that skipped attributes may or may not
1895  /// exist afterwards, and they also won't be initialized in any expected
1896  /// way. The assumption is that the caller will fully handle creation,
1897  /// initialization, or deletion of skipped attributes.
1898  /// If 'full_copy is true, internal groups and private attribute are also
1899  /// considered.'
1900  void replaceWith(const GA_Detail &src,
1901  const GA_AttributeFilter *skip = nullptr,
1902  bool full_copy = false);
1903 
1904  /// Fast version of merge for the case of completely replacing all of this
1905  /// detail with the points from the source detail, using data IDs to avoid
1906  /// copying things that are the same. This does not copy private
1907  /// scope attributes (except topology) or internal groups.
1908  /// It will act as if replaceWith was called and then all primitives
1909  /// were deleted, so vertex/primitive attributes will be transferred,
1910  /// but there will be no vertices or primitives.
1911  /// When skip is given, all processing of attributes matching the filter
1912  /// will be skipped. The result is that skipped attributes may or may not
1913  /// exist afterwards, and they also won't be initialized in any expected
1914  /// way. The assumption is that the caller will fully handle creation,
1915  /// initialization, or deletion of skipped attributes.
1916  void replaceWithPoints(const GA_Detail &src,
1917  const GA_AttributeFilter *skip = nullptr);
1918 
1919  /// This clears any caches that subclasses of GA_Detail may have, so that
1920  /// replacing the content of the detail doesn't cause crashes.
1921  /// NOTE: You may or may not also have to call refreshCachedHandles later
1922  /// if P or Pw might be replaced or change storage.
1923  virtual void clearCaches()
1924  {
1925  clearInstanceMatrix();
1926  getPrimitiveList().destroyStashed();
1927  }
1928 
1929  /// Merge global attributes (using default options)
1930  void mergeGlobalAttributes(const GA_Detail &src);
1931  /// Merge source global attributes using options
1932  void mergeGlobalAttributes(const GA_Detail &src,
1933  GA_MergeOptions &options);
1934 
1935  /// Clone any missing attributes from the source detail, skipping P, any
1936  /// topology, and any group attributes.
1937  void cloneMissingAttributes(const GA_Detail &src,
1938  GA_AttributeOwner owner,
1939  const GA_AttributeFilter &filter);
1940  /// Clone any missing groups from the source detail.
1941  void cloneMissingGroups(const GA_Detail &src,
1942  GA_AttributeOwner owner,
1943  const GA_AttributeFilter &filter);
1944 
1945  // -------------- Stream I/O METHODS ------------------------
1946  /// Register an IO file format
1947  bool registerIO(GA_IO *io) const
1948  { return myPrimitiveFactory.registerIO(io); }
1949 
1950  /// Find an IO class. If no name is specified, the "default" IO class will
1951  /// be returned (the one specified by HOUDINI_GEOMETRY_FORMAT).
1952  const GA_IO *findIO(const char *name = nullptr) const
1953  { return myPrimitiveFactory.findIO(name); }
1954 
1955  /// Get a list of all the IO names registered. Returns the number of names
1956  /// in the array.
1957  void getIONames(UT_StringArray &names) const
1958  { return myPrimitiveFactory.getIONames(names); }
1959 
1960  /// This class is used to return the status from I/O operations on a
1961  /// GA_Detail.
1962  class IOStatus
1963  {
1964  public:
1965  IOStatus(bool success=false)
1966  : mySuccess(success)
1967  {}
1969  : mySuccess(src.mySuccess)
1970  {}
1972 
1974  {
1975  if (this != &src)
1976  mySuccess = src.mySuccess;
1977  return *this;
1978  }
1979 
1980  /// Return a boolean for success or failure.
1981  /// true means success
1982  bool success() const { return mySuccess; }
1983 
1984  /// bool operator
1985  SYS_SAFE_BOOL operator bool() const { return mySuccess; }
1986 
1987  /// For backward compatibility in older code, you can query the status
1988  /// as an integer, 0 for success, less than zero for failure.
1989  int gbstatus() const { return mySuccess ? 0 : -1; }
1990 
1991  private:
1992  bool mySuccess;
1993  };
1994 
1995  /// Save to a given filename. An extension of .gz will enable zlib
1996  /// compression (for JSON format only)
1997  /// Options include:
1998  /// - string geo:format @n Use the IO format specified by the string
1999  /// See also the options for the stream save
2000  IOStatus save(const char *filename,
2001  const GA_SaveOptions *options,
2002  UT_StringArray *errors = 0) const;
2003 
2004  /// Save to an existing ostream. JSON format will check the options for:
2005  /// - bool geo:gzip @n Enable gzip compression for JSON (false)
2006  /// - bool geo:saveinfo @n Output optional "info" section [true]
2007  /// - string info:software - Software
2008  /// - string info:artist - Artist
2009  /// - string info:hostname - Hostname comment
2010  /// - string info:comment - Arbitrary Comment
2011  /// - any info:token - Saved in the "info" section
2012  /// - bool group:saveinternal @n Save "internal" groups (debugging)
2013  IOStatus save(std::ostream &os, bool binary,
2014  const GA_SaveOptions *options,
2015  UT_StringArray *errors = 0) const;
2016  /// @{
2017  /// Save in "hclassic" format.
2018  IOStatus saveClassic(const char *, const GA_SaveOptions *) const;
2019  IOStatus saveClassic(std::ostream &os, bool, const GA_SaveOptions *) const;
2020  /// @}
2021 
2022  /// @section JSON-GA_Detail JSON Schema: GA_Detail
2023  ///
2024  /// The JSON schema for a detail can be broken down into 5 major sections
2025  /// - Header: The global information about the detail
2026  /// - References: Topological references
2027  /// - Attributes: Attribute data for elements
2028  /// - Primitives: List of primitives in the detail
2029  /// - Groups: Groups
2030  ///
2031  /// @code
2032  /// {
2033  /// "name" : "GA_Detail-Header",
2034  /// "description" : "Storage for an entire geometry object",
2035  /// "type" : "orderedmap",
2036  /// "properties": {
2037  /// // Header section
2038  /// "file_version": {
2039  /// "type" : "string",
2040  /// "description" : "File Version",
2041  /// "optional" : true,
2042  /// },
2043  /// "info": {
2044  /// "type" : "object",
2045  /// "description" :
2046  /// "Optional tags including:
2047  /// 'software' : Software used to create geometry,
2048  /// 'artist' : Artist name,
2049  /// 'hostname' : Computer name,
2050  /// 'comment' : Arbitrary comment
2051  /// etc.",
2052  /// "optional" : true,
2053  /// }
2054  /// "pointcount": {
2055  /// "type" : "integer",
2056  /// "description" : "The number of points in the geometry",
2057  /// },
2058  /// "vertexcount": {
2059  /// "type" : "integer",
2060  /// "description" : "The number of vertices in the geometry",
2061  /// },
2062  /// "primitivecount": {
2063  /// "type" : "integer",
2064  /// "description" : "The number of primitives in the geometry",
2065  /// },
2066  ///
2067  /// // Topology section
2068  /// "topology" : {
2069  /// "type" : "orderedmap",
2070  /// "description" : "Topological information",
2071  /// "properties" : {
2072  /// "pointref" : {
2073  /// "type" : [{ "$ref" : "GA_ATITopology" }],
2074  /// "description" :
2075  /// "An list of points referenced by each
2076  /// vertex. The array of 'vertexcount' items
2077  /// must contain integer values in the range of
2078  /// (0,pointcount-1)"
2079  /// }
2080  /// }
2081  /// },
2082  ///
2083  /// // Attributes section
2084  /// "attributes": {
2085  /// "type" : { "$ref" : "GA_AttributeSet" } ,
2086  /// "description" : "Vertex attributes",
2087  /// }
2088  ///
2089  /// // Primitives section
2090  /// "primitives": {
2091  /// "type" : { "$ref" : "GA_PrimitiveList" } ,
2092  /// "description" : "An array of primitives",
2093  /// }
2094  ///
2095  /// // Groups section
2096  /// "pointgroups": {
2097  /// "type" : { "$ref" : "GA_GroupTable" },
2098  /// "description" : "The list of point groups",
2099  /// "optional" : true,
2100  /// },
2101  /// "primitivegroups": {
2102  /// "type" : { "$ref" : "GA_GroupTable" },
2103  /// "description" : "The list of primitive groups",
2104  /// "optional" : true,
2105  /// },
2106  /// "vertexgroups": {
2107  /// "type" : { "$ref" : "GA_GroupTable" },
2108  /// "description" : "The list of vertex groups",
2109  /// "optional" : true,
2110  /// },
2111  /// "edgegroups": {
2112  /// "type" : { "$ref" : "GA_GroupTable" },
2113  /// "description" : "The list of edge groups",
2114  /// "optional" : true,
2115  /// },
2116  /// },
2117  /// }
2118  /// @endcode
2119  /// @see @ref JSON_FileFormat
2120  /// @note This method uses <tt>findIO(GA_IOTable::getJSONToken())</tt> and
2121  /// uses a dynamic cast to GA_IOJSON to actually do the writing.
2122  IOStatus save(UT_JSONWriter &w, const GA_SaveOptions *opts=0) const;
2123 
2124  /// Load a geometry file
2125  IOStatus load(const char *filename,
2126  const GA_LoadOptions *opts=0,
2127  UT_StringArray *errors=0);
2128 
2129  /// Load a geometry file given a UT_IStream.
2130  IOStatus load(UT_IStream &is,
2131  const GA_LoadOptions *opts=0,
2132  UT_StringArray *errors=0);
2133 
2134  /// Load geometry from a JSON stream.
2135  /// @note This method uses <tt>findIO(GA_IOTable::getJSONToken())</tt> and
2136  /// uses a dynamic cast to GA_IOJSON to actually do the loading.
2137  IOStatus load(UT_JSONParser &p,
2138  const GA_LoadOptions *opts=0,
2139  UT_StringArray *errors=0);
2140 
2141  /// @{
2142  /// Stat a disk file rather than loading the entire geometry.
2143  /// (see @ref GA_STAT_LEVEL)
2144  /// The method cannot be static since the primitive factory is required.
2145  /// The primitive factory stores the IO table for the geometry.
2146  ///
2147  /// When performing a stat on a disk file, if the format supports it, only
2148  /// the header of the file is loaded. This means that the full
2149  /// information for the geometry isn't available. Thus, this will give
2150  /// you different information than if you run stat() on geometry that's
2151  /// fully loaded into memory.
2152  ///
2153  /// If you inspect a .geo file, you can see the information that's
2154  /// available. For example, you can get the "primcount_summary" using the
2155  /// GA_Stat::getInfoOptions() method.
2156  IOStatus statFile(const char *filename, GA_Stat &stat,
2157  uint level=0xffff,
2158  const GA_LoadOptions *opts=nullptr) const;
2159  IOStatus stat(UT_JSONParser &p, GA_Stat &stat, uint level) const;
2160  /// @}
2161 
2162  /// Private methods
2163  /// @private
2164  void batchDeletion(GA_AttributeOwner owner);
2165  /// @private
2166  void adjustArraySize(GA_AttributeOwner owner, GA_Offset size);
2167  /// @private
2168  void constructElementBlock(GA_AttributeOwner owner, GA_Offset offset, GA_Offset nelements)
2169  { myAttributes.constructElementBlock(owner, offset, nelements); }
2170  /// @private
2171  void destructElement(GA_AttributeOwner owner, GA_Offset offset)
2172  { myAttributes.destructElement(owner, offset); }
2173 
2174  /// @private mergeGrowArrays() is called during the merging process
2175  /// @b prior to the actual addition of new elements to the detail.
2176  /// At this point, attribute arrays are grown to store the incoming data
2177  void mergeGrowArrays(GA_MergeMap &map, GA_AttributeOwner owner);
2178 
2179  /// Get information about the detail.
2180  /// @param stat @n - Information about detail
2181  /// @param level @n - Mask of information to retrieve
2182  /// (see @ref GA_STAT_LEVEL)
2183  /// Note that since this method queries the geometry that's fully loaded
2184  /// into memory, you will get different information than the @c statFile()
2185  /// method.
2186  bool stat(GA_Stat &stat, uint level=0xffff) const;
2187 
2188  /// Fill out only the attribute information on the stat
2189  void statAttributes(GA_Stat &stat, uint level=0xffff) const;
2190  /// Fill out only the group information on the stat
2191  void statGroups(GA_Stat &stat, uint level=0xffff) const;
2192  /// Fill out only the volume information.
2193  virtual void statVolumes(GA_Stat &stat, uint level=0xffff) const;
2194 
2195  /// Debugging output of detail
2196  static int64 printMemory(UT_WorkBuffer &buffer,
2197  bool include_total=true,
2198  int indent=3,
2199  const char *title="Geometry Memory Tracking");
2200 
2201  /// @{
2202  /// Utility casting functions used by GA_GBMacros.h to maintain (source
2203  /// code) type compatibility with the old implementations that used the
2204  /// derived GD/GEO_PrimList objects.
2205  ///
2206  /// The first argument is used solely to infer the templatized type.
2207  /// Derived classes (GD_Detail/GEO_Detail) should contain embedded
2208  /// GB_MACRO_PRIM_TYPE typedef to specify
2209  /// the proper derived type to use for the cast.
2210  template <typename T> static inline const typename T::GB_MACRO_PRIM_TYPE *
2211  GB_MACRO_CAST(const T *, const GA_Primitive *prim)
2212  { return static_cast<const typename T::GB_MACRO_PRIM_TYPE *>(prim);}
2213  template <typename T> static inline typename T::GB_MACRO_PRIM_TYPE *
2214  GB_MACRO_CAST(const T *, GA_Primitive *prim)
2215  { return static_cast<typename T::GB_MACRO_PRIM_TYPE *>(prim); }
2216  /// @}
2217 
2219 
2220  /// @{
2221  /// @private
2222  /// Methods used by GEO primitives to save/load vertex references
2223  bool loadVertexPointReferenceH9(UT_IStream &is,
2224  GA_Offset &point_offset);
2225  bool saveVertexPointReferenceH9(std::ostream &os,
2226  int binary, GA_Offset vertex_offset) const;
2227 
2228  static bool loadAttribDataH9(UT_IStream &is, GA_Offset offset,
2230  static bool saveAttribDataH9(std::ostream &os, int binary,
2231  GA_Offset offset,
2233  char delim_ch = '(');
2234  /// Convenience methods for saving/loading both a vertex's point reference
2235  /// and its attribute values in a Houdini9 compatible style. Note that the
2236  /// load wires the vertex to the loaded point.
2237  bool loadVertexH9(UT_IStream &is, GA_Offset vertex_offset,
2238  const UT_Array<GA_AttribLoadDataH9> &vtx_l);
2239  bool saveVertexH9(std::ostream &os, int binary,
2240  GA_Offset vertex_offset,
2241  const UT_Array<GA_AttribSaveDataH9> &vtx_l)
2242  const;
2243  /// @}
2244 
2245  /// Provide access to the factory. This allows users to query information
2246  /// about factories.
2248  { return myPrimitiveFactory; }
2249 
2250  /// Refreshes handles cached in the detail. This method must be called
2251  /// after changing the storage of the P attribute.
2252  virtual void refreshCachedHandles();
2253  /// Refreshes the cached myP attribute.
2254  void refreshCachedAttributes();
2255 
2256  /// @{
2257  /// Add/Remove an attribute to the tail-initialization list.
2258  ///
2259  /// When attributes grow in size, they usually initialize their values to
2260  /// the default value. However, some attributes may not adhere to this
2261  /// rule, or due to space optimizations, may have the values set to
2262  /// non-default values. In this case, they should be added to the
2263  /// tail-initialization list. When new elements are appended to the
2264  /// detail, they will be told to re-initialize the new element. Otherwise,
2265  /// the detail will assume that the element values are at their default
2266  /// value.
2267  ///
2268  /// When removing, the method will return @c true if the attribute was a
2269  /// tail initializer.
2270  ///
2271  /// @note These methods are thread-safe
2272  /// @note DO NOT CALL THESE: Use the GA_Attribute::setTailInitialization
2273  /// instead.
2274  void addTailInitializer(GA_Attribute *attrib);
2275  bool removeTailInitializer(GA_Attribute *attrib);
2276  /// @}
2277 
2278  /// Tell all tail initialization attributes to initialize the given offset
2279  /// @note This method is not thread-safe
2282  {
2283  if (myTailInitializers)
2284  doConstructTailInitializers(owner, start, size);
2285  }
2286 
2288  { return myPrimitiveList.containsType(type); }
2290  { return myPrimitiveList.containsOnlyTypes(type); }
2292  { return myPrimitiveList.countType(type); }
2294  { return myPrimitiveList.countTypeFamily(family); }
2296  { return myPrimitiveList.
2297  hasLocalTransform(myPrimitiveFactory); }
2299  UT_Array<const GA_Primitive *> &prims) const
2300  { return myPrimitiveList.getPrimitivesOfType(type, prims); }
2301 
2302  // ------------- Primitive Type Masks ----------------------
2303 
2304  /// Returns a primitive typemask that represents all known primitive type
2305  /// by the primitive factory that is associated with this detail.
2306  GA_PrimitiveTypeMask getPrimitiveTypeMaskAll() const;
2307 
2308  /// Returns the primitive typemask that represents all primitives in this
2309  /// detail.
2310  GA_PrimitiveTypeMask getPrimitiveTypeMask(
2311  const GA_PrimitiveGroup *group = 0) const;
2312 
2313 
2314  /// Return cached attribute instance matrix pointer
2315  const GA_AttributeInstanceMatrix &getInstanceMatrix() const;
2316 
2317  /// Clear the attribute instance matrix pointer. This is called
2318  /// automatically when point attributes are added or deleted.
2319  void clearInstanceMatrix();
2320 
2321  /// This function is entirely here so that GA has a way to check if a
2322  /// GA_Detail is a GEO_Detail (true) or GD_Detail (false).
2323  bool isPrimary() const
2324  {
2325  return myPrimitiveFactory.isForPrimaryDetail();
2326  }
2327 
2328  /// Builds & acquires GPU backed buffers for topology attributes.
2329  GA_CEAttribute *getTopologyCEAttribute(
2330  GA_Topology::TopologyCE topotype,
2331  GA_StorageClass storage,
2333  int &tuplesize,
2334  bool isarray,
2335  bool read, bool write);
2336 
2337  /// Builds a new CEAttribute for the given topology. This is not
2338  /// cached internally anywhere, nor does it use any existing cache.
2339  virtual UT_UniquePtr<GA_CEAttribute> buildTopologyCEAttribute(
2340  GA_Topology::TopologyCE topotype,
2341  GA_StorageClass storage,
2343  int &tuplesize,
2344  bool isarray,
2345  bool read, bool write) const;
2346 
2347  /// All GPU buffers that have been written to will be copied back
2348  /// to the CPU & marked clean.
2349  void flushCEWriteCaches();
2350 
2351  /// Flush all GPU-backed CE attributes, clearing them from this
2352  /// geometry.
2353  void flushCECaches();
2354 
2355  /// Steal all GPU-backed CE buffers from the source detail,
2356  /// including attributes, VDBs, and volumes. NOTE: this is
2357  /// only safe to call immediately after flushing the source
2358  /// detail's write cache with flushCEWriteCache, then calling
2359  /// replaceWith.
2360  void stealCEBuffers(const GA_Detail &srcdetail);
2361 
2362  /// Copy changed/non transforming attribute values from inputgeo
2363  /// owner specifies the attribute class to act upon
2364  /// This is used by SOP_Deform/SOP_AttribVop to speed up the duplication of input gdp.
2365  void copyChangedNonTransforming(const GA_Detail *inputgeo, GA_AttributeOwner owner);
2366 
2367  static const int64 INVALID_CACHE_COUNT = -1;
2368 
2369  void incrementMetaCacheCount() { myMetaCacheCount++; }
2370  int64 getMetaCacheCount() const { return myMetaCacheCount; }
2371 
2372  /// The preferred precision for both computation and creation of
2373  /// attributes. Default precision is 32bit.
2374  GA_Precision getPreferredPrecision() const;
2375  /// Override the preferred precision. Currently will accept
2376  /// 32 and 64bit.
2377  void setPreferredPrecision(GA_Precision prec);
2378 
2379  /// @{
2380  /// @private
2381  class GA_API MantraGeometry
2382  {
2383  public:
2384  MantraGeometry() {}
2385  virtual ~MantraGeometry() {}
2386  virtual void refreshCachedHandles();
2387  };
2388  MantraGeometry *mantraGeometry()
2389  { return myMantraGeometry; }
2390  const MantraGeometry *mantraGeometry() const
2391  { return myMantraGeometry; }
2392  void setMantraGeometry(MantraGeometry *m)
2393  { myMantraGeometry = m; }
2394  /// @}
2395 
2396 protected:
2397  void doConstructTailInitializers(GA_AttributeOwner owner,
2398  GA_Offset start, GA_Offset size);
2399 
2400  bool loadPrimitivesH9(UT_IStream &is, int count,
2401  const GA_FileFormatH9::PrimTypeXlate &type_map,
2402  const UT_Array<GA_AttribLoadDataH9> &prim_attribs,
2403  const UT_Array<GA_AttribLoadDataH9> &vtx_attribs);
2404  bool savePrimitivesH9(std::ostream &os, int binary,
2405  const UT_Array<const GA_Primitive *> &list,
2406  const GA_FileFormatH9::PrimTypeXlate &type_map,
2407  const UT_Array<GA_AttribSaveDataH9> &prim_attribs,
2408  const UT_Array<GA_AttribSaveDataH9> &vx_attribs) const;
2409 
2410  /// @{
2411  /// Virtual implementation of intrinsic attributes. See GA_IntrinsicEval
2412  /// for further details.
2413  virtual GA_Size localIntrinsicTupleSize(GA_IntrinsicEval &eval) const;
2414  virtual GA_Size localGetIntrinsicS(GA_IntrinsicEval &eval,
2415  UT_String &value) const;
2416  virtual GA_Size localGetIntrinsicSA(GA_IntrinsicEval &eval,
2417  UT_StringArray &value) const;
2418  virtual GA_Size localGetIntrinsicD(GA_IntrinsicEval &eval,
2419  UT_OptionsHolder &value) const;
2420  virtual GA_Size localGetIntrinsicDA(GA_IntrinsicEval &eval,
2422  virtual GA_Size localGetIntrinsicI(GA_IntrinsicEval &eval,
2423  int64 *value, GA_Size size) const;
2424  virtual GA_Size localGetIntrinsicF(GA_IntrinsicEval &eval,
2425  fpreal64 *value, GA_Size size) const;
2426  virtual GA_Size localSetIntrinsicS(GA_IntrinsicEval &eval,
2427  const char *value);
2428  virtual GA_Size localSetIntrinsicSA(GA_IntrinsicEval &eval,
2429  const UT_StringArray &value);
2430  virtual GA_Size localSetIntrinsicSS(GA_IntrinsicEval &eval,
2431  const char **value, GA_Size size);
2432  virtual GA_Size localSetIntrinsicDA(GA_IntrinsicEval &eval,
2434  virtual GA_Size localSetIntrinsicDS(GA_IntrinsicEval &eval,
2436  virtual GA_Size localSetIntrinsicI(GA_IntrinsicEval &eval,
2437  const int64 *value, GA_Size size);
2438  virtual GA_Size localSetIntrinsicF(GA_IntrinsicEval &eval,
2439  const fpreal64 *value, GA_Size size);
2440  /// @}
2441 
2442  // Methods used by GEO when loading old style geometry files.
2443  static void finishLoadH9(
2444  const UT_Array<GA_AttribLoadDataH9> &attribs
2445  );
2446 
2447  friend class GA_AttributeSet;
2448  /// This is here just so that GA_AttributeSet::jsonSave() can call
2449  /// GEOcomputeNormals()
2450  virtual void privateComputeNormal(
2451  const GA_RWHandleV3 &normalattrib,
2452  const GA_Group *group,
2453  const float cuspangledegrees,
2454  const int method) const
2455  {}
2456  /// This is here so that GA_AttributeSet::jsonLoad() can call it
2457  /// after loading attributes, since VDB primitive loading tries to
2458  /// write to P, and we might as well have it correctly split up
2459  /// before anything might read/write it.
2460  void splitAnyFloat4P();
2461 
2462  // Allow derived classes to modify myUniqueId and myMetaCacheCount
2463  // Don't make public, as this shouldn't be used in normal cooking.
2464  // Used by GU_Detail::cloneForCache() to make separated details act
2465  // as the same detail.
2466  void setUniqueId(exint i) { myUniqueId = i; }
2467  void setMetaCacheCount(int64 i) { myMetaCacheCount=i; }
2468 
2469 private:
2470  void init(GA_Storage Pstore, bool isprimary, bool full_topology);
2471 
2472  GA_Offset newPrimitiveOffset();
2473 
2474  void clearData(bool for_deletion);
2475 
2476  /// Destroy elements. When destroying points, if the
2477  /// guarantee_no_vertex_point_references is true, we don't bother
2478  /// dereferencing the points (which speeds up the operation).
2479  GA_Size destroyElements(const GA_Range &range,
2480  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES,
2481  bool guarantee_no_vertex_point_references=false);
2482 
2483  // Try to make primitives de-reference the point
2484  bool dereferencePoint(GA_Offset point,
2485  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES);
2486  // Try to make primitives de-reference a range of points. A return value
2487  // of true means that all points in the range are no longer referenced by
2488  // primitives, while a return value of false means that some points in the
2489  // range continue to be referenced. This method may allocate a membership
2490  // query object, in which case, the caller is responsible for deleting it.
2491  bool dereferencePoints(const GA_Range &point_range,
2492  const GA_RangeMemberQuery *&point_range_query,
2493  GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES);
2494 
2495 
2496  /// Called by GA_IO during loading of optimized formats
2497  bool setLoadCounts(GA_Size npoint, GA_Size nvertex, GA_Size nprim,
2498  GA_LoadMap &load);
2499 
2500  friend class GA_IO;
2501  friend class GA_PrimitiveList;
2502 
2503  GA_PrimitiveFactory &myPrimitiveFactory;
2504  GA_IndexMap myPointMap;
2505  GA_IndexMap myVertexMap;
2506  GA_IndexMap myPrimitiveMap;
2507  GA_IndexMap myGlobalMap; // Always has a single entry
2508  GA_PrimitiveList myPrimitiveList;
2509  GA_AttributeSet myAttributes;
2510  GA_Topology myTopology;
2511  GA_Attribute *myP;
2512  /// The pre-binding of position is as float, but we rely on the
2513  /// AlmostMatch binding allowing us to query double directly.
2514  GA_RWHandleV3 myHandlePV3;
2515  GA_Attribute *myPw;
2516  ga_TailInitializeTable *myTailInitializers;
2517  MantraGeometry *myMantraGeometry;
2518  mutable GA_AttributeInstanceMatrix *myInstanceMatrix;
2519  GA_PointGroupTable myPointGroups;
2520  GA_VertexGroupTable myVertexGroups;
2521  GA_PrimitiveGroupTable myPrimitiveGroups;
2522  GA_EdgeGroupTable myEdgeGroups;
2523  exint myUniqueId;
2524 
2525 
2526  /// Checking this meta cache count and the unique ID of the
2527  /// detail is sufficient to determine whether this detail
2528  /// has been modified since it was last examined, so long as it's
2529  /// not currently being used in a cook. Any cook only needs to
2530  /// increment the meta cache count once, and only if the detail
2531  /// is actually modified, (e.g. don't need to inc if instancing).
2532  ///
2533  /// NOTE: Do not rely on the detail pointer to check for modification,
2534  /// since a different detail could happen to be allocated
2535  /// at the same address in memory.
2536  int64 myMetaCacheCount;
2537 };
2538 
2539 #endif
SIM_API const UT_StringHolder vertex
GA_Size countPrimitiveTypeFamily(GA_PrimitiveFamilyMask family) const
Definition: GA_Detail.h:2293
UT_Vector2 getPos2(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:173
virtual void clearCaches()
Definition: GA_Detail.h:1923
void stashAll()
Definition: GA_Detail.h:138
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
SYS_FORCE_INLINE void forEachPrimitiveBreak(const GA_PrimitiveGroup *group, FUNCTOR &&functor) const
Definition: GA_Detail.h:1600
GA_PointGroupTable & pointGroups()
Definition: GA_Detail.h:1176
bool isPointUsedFast(GA_Offset point) const
Definition: GA_Detail.h:723
SYS_FORCE_INLINE const GA_PrimitiveGroup * findPrimitiveGroup(const UT_StringRef &name) const
Definition: GA_Detail.h:1253
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
GA_Range primitiveRange() const
Definition: GA_Detail.h:772
const UT_Options * getIntrinsicOptions(GA_LocalIntrinsic h) const
Definition: GA_Detail.h:1439
void incrementMetaCacheCount()
Definition: GA_Detail.h:2369
bool containsLocalTransformPrimitive() const
Definition: GA_Detail.h:2295
GT_API const UT_StringHolder filename
GA_Range getPrimitiveRangeSlice(GA_Index begin_prim, GA_Index end_prim=GA_INVALID_INDEX) const
Get ordered primitive range from base_prim to end_prim, or the end.
Definition: GA_Detail.h:1748
SYS_FORCE_INLINE const GA_Attribute * findGlobalAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1055
const GA_VertexGroupTable & vertexGroups() const
Definition: GA_Detail.h:1186
SYS_FORCE_INLINE GA_Primitive * getPrimitive(GA_Offset prim_off)
Definition: GA_Detail.h:429
GA_PrimitiveGroupUPtr createDetachedPrimitiveGroup() const
Definition: GA_Detail.h:1362
SYS_FORCE_INLINE void copyPoint(GA_Offset destptoff, GA_Offset srcptoff, const GA_AttributeFilter *filter=nullptr)
Definition: GA_Detail.h:1853
GA_Attribute * createAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, const UT_Options *create_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GA_Detail.h:875
bool setLoadCounts(GA_Detail &gdp, GA_Size npoints, GA_Size nvertex, GA_Size nprimitive, GA_LoadMap &loadmap) const
SYS_FORCE_INLINE const GA_Attribute * findVertexAttribute(const UT_StringRef &name) const
Definition: GA_Detail.h:1045
GLenum GLint * range
Definition: glcorearb.h:1925
GA_Primitive GB_MACRO_PRIM_TYPE
Definition: GA_Detail.h:2218
SYS_FORCE_INLINE GA_AttributeUPtr createDetachedAttribute(GA_AttributeOwner owner, const UT_StringRef &attribtype, const UT_Options *create_args=nullptr, const GA_AttributeOptions *attribute_options=nullptr) const
Definition: GA_Detail.h:905
GA_Primitive * getPrimitiveByIndex(GA_Index prim_idx)
Definition: GA_Detail.h:438
GA_Range getVertexRange(const GA_VertexGroup *group=0) const
Get a range of all vertices in the detail.
Definition: GA_Detail.h:1760
int gbstatus() const
Definition: GA_Detail.h:1989
SYS_FORCE_INLINE void forEachPointBreak(const GA_PointGroup *group, bool complement, FUNCTOR &&functor) const
Definition: GA_Detail.h:1542
void getIONames(UT_StringArray &names) const
Definition: GA_Detail.h:1957
const GA_IndexMap & getPrimitiveMap() const
Definition: GA_Detail.h:743
SYS_FORCE_INLINE GA_Attribute * findGlobalAttribute(const UT_StringRef &name)
Definition: GA_Detail.h:1117
static T::GB_MACRO_PRIM_TYPE * GB_MACRO_CAST(const T *, GA_Primitive *prim)
Definition: GA_Detail.h:2214
GA_Size destroyVertexOffsets(const GA_Range &range)
Definition: GA_Detail.h:713
GA_PointGroup * newInternalPointGroup()
Definition: GA_Detail.h:1311
SYS_FORCE_INLINE bool isPDouble() const
Definition: GA_Detail.h:170
void constructTailInitializers(GA_AttributeOwner owner, GA_Offset start, GA_Offset size=GA_Offset(1))
Definition: GA_Detail.h:2280
Class which stores the default values for a GA_Attribute.
Definition: GA_Defaults.h:35
UT_Vector2T< float > UT_Vector2
const GA_IO * findIO(const char *name=nullptr) const
Definition: GA_Detail.h:1952
SYS_FORCE_INLINE const GA_Attribute * findVertexAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1041
GA_StorageClass
Definition: GA_Types.h:72
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
void skip(T &in, int n)
Definition: ImfXdr.h:711
const GLdouble * v
Definition: glcorearb.h:837
UT_UniquePtr< GA_VertexGroup > GA_VertexGroupUPtr
GA_Precision
Definition: GA_Types.h:87
UT_Vector4 getPos4(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:292
UT_Vector2T< fpreal64 > UT_Vector2D
GLuint start
Definition: glcorearb.h:475
GLsizei const GLfloat * value
Definition: glcorearb.h:824
GA_IndexMap & getIndexMap(GA_AttributeOwner owner)
Definition: GA_Detail.h:735
bool GAisValid(GA_Size v)
Definition: GA_Types.h:649
OffsetMarker(const GA_Detail &detail)
Definition: GA_Detail.h:763
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, fpreal x, fpreal y, fpreal z)
Set P given the x, y, z components.
Definition: GA_Detail.h:248
GA_EdgeGroup * newEdgeGroup(const UT_StringHolder &name, bool internal)
Definition: GA_Detail.h:1390
void setMantraGeometry(MantraGeometry *m)
Definition: GA_Detail.h:2392
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
UT_Vector3T< float > UT_Vector3
GA_VertexGroup * newInternalVertexGroup()
Definition: GA_Detail.h:1315
const GA_IndexMap & getGlobalMap() const
Definition: GA_Detail.h:744
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
constexpr UT_FixedVector< SYS_FixedArrayElement_t< TS >, SYS_FixedArraySize_v< TS > > UTmakeFixedVector(const TS &as) noexcept
GLboolean GLboolean g
Definition: glcorearb.h:1222
const MantraGeometry * mantraGeometry() const
Definition: GA_Detail.h:2390
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
int64 exint
Definition: SYS_Types.h:125
GLint level
Definition: glcorearb.h:108
GA_Attribute * getP()
Convenience method to access the P attribute.
Definition: GA_Detail.h:164
const GA_Primitive * getPrimitiveByIndex(GA_Index prim_idx) const
Definition: GA_Detail.h:440
GA_Range pointRange() const
Definition: GA_Detail.h:768
GA_StorageClass getIntrinsicStorage(GA_LocalIntrinsic h) const
Definition: GA_Detail.h:1435
GLdouble s
Definition: glad.h:3009
const GA_Attribute * getP() const
Definition: GA_Detail.h:165
SYS_FORCE_INLINE const GA_Attribute * findAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name) const
Definition: GA_Detail.h:1025
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeOwner owner, const UT_StringRef &name)
Definition: GA_Detail.h:1088
SYS_FORCE_INLINE GA_ElementGroupTableT< OWNER >::GROUP_TYPE * createElementGroup(const UT_StringHolder &name, bool ordered=false)
Definition: GA_Detail.h:1197
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
SYS_FORCE_INLINE const GA_Attribute * findGlobalAttribute(const UT_StringRef &name) const
Definition: GA_Detail.h:1059
SYS_FORCE_INLINE GA_Attribute * findPointAttribute(GA_AttributeScope s, const UT_StringRef &name)
Definition: GA_Detail.h:1092
Class used to map H9 geometry files to a form used by GA.
Definition: GA_AIFFileH9.h:318
Manager to keep track of global handle to name mappings.
GLint y
Definition: glcorearb.h:103
#define GA_API
Definition: GA_API.h:14
SYS_FORCE_INLINE void forEachOffset(FUNCTOR &&functor) const
Calls functor on every active offset in this index map.
Definition: GA_IndexMap.h:495
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
GA_Range vertexRange() const
Definition: GA_Detail.h:770
Abstract base class for a range membership query object.
GA_PrimitiveGroup * newInternalPrimitiveGroup()
Definition: GA_Detail.h:1319
GA_EdgeGroupTable & edgeGroups()
Definition: GA_Detail.h:1188
IOStatus & operator=(const IOStatus &src)
Definition: GA_Detail.h:1973
**But if you need a result
Definition: thread.h:613
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
Definition: GA_Detail.h:185
void setMetaCacheCount(int64 i)
Definition: GA_Detail.h:2467
static const T::GB_MACRO_PRIM_TYPE * GB_MACRO_CAST(const T *, const GA_Primitive *prim)
Definition: GA_Detail.h:2211
GA_PointGroup * newPointGroup(const UT_StringHolder &name)
Definition: GA_Detail.h:1288
GLfloat GLfloat GLfloat GLfloat v3
Definition: glcorearb.h:819
SYS_FORCE_INLINE const GA_ElementGroupTableT< OWNER >::GROUP_TYPE * findElementGroup(const UT_StringRef &name) const
Definition: GA_Detail.h:1224
SYS_FORCE_INLINE void forEachPointBreak(const GA_PointGroup *group, FUNCTOR &&functor) const
Definition: GA_Detail.h:1536
SYS_FORCE_INLINE GA_PrimitiveGroup * findPrimitiveGroup(const UT_StringRef &name)
Definition: GA_Detail.h:1263
GA_Offset pointBegin() const
Definition: GA_Detail.h:774
SYS_FORCE_INLINE GA_Attribute * findPrimitiveAttribute(GA_AttributeScope s, const UT_StringRef &name)
Definition: GA_Detail.h:1106
void read(T &in, bool &v)
Definition: ImfXdr.h:502
void setVertexPoint(GA_Offset vertex, GA_Offset ptoff)
Given a vertex, set the corresponding point offset.
Definition: GA_Detail.h:536
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
bool setPos3FromArray(const GA_Range &ptrange, const UT_Array< UT_Vector3T< T > > &positions)
Definition: GA_Detail.h:217
GA_DestroyPointMode
Definition: GA_Detail.h:642
GA_PrimitiveFamilyMask
GA_Size destroyPrimitives(const GA_Range &it, bool and_points=false)
Definition: GA_Detail.h:680
SYS_FORCE_INLINE GA_Offset vertexToPrevVertex(GA_Offset vtx) const
Definition: GA_Detail.h:583
#define GA_INVALID_OFFSET
Definition: GA_Types.h:678
GA_Size countPrimitiveType(const GA_PrimitiveTypeId &type) const
Definition: GA_Detail.h:2291
SYS_FORCE_INLINE GA_Offset findActiveOffset(GA_Offset start, GA_Offset end) const
Definition: GA_IndexMap.h:479
A range of elements in an index-map.
Definition: GA_Range.h:42
GA_PrimitiveGroup * newPrimitiveGroup(const UT_StringHolder &name)
Definition: GA_Detail.h:1296
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
int GA_GlobalIntrinsic
Definition: GA_Types.h:695
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
double fpreal64
Definition: SYS_Types.h:201
SYS_FORCE_INLINE const GA_Attribute * findPointAttribute(const UT_StringRef &name) const
Definition: GA_Detail.h:1038
SYS_FORCE_INLINE GA_VertexGroup * findVertexGroup(const UT_StringRef &name)
Definition: GA_Detail.h:1260
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
GA_Size GA_Offset
Definition: GA_Types.h:641
GA_VertexGroup * newVertexGroup(const UT_StringHolder &name, bool internal)
Definition: GA_Detail.h:1386
GA_PointGroupUPtr createDetachedPointGroup() const
Definition: GA_Detail.h:1358
SYS_FORCE_INLINE void forEachPrimitiveBreak(FUNCTOR &&functor) const
Definition: GA_Detail.h:1594
void setPos2(GA_Offset ptoff, const UT_Vector2D &pos)
Definition: GA_Detail.h:230
int GA_LocalIntrinsic
Definition: GA_Types.h:694
GA_EdgeGroup * newInternalEdgeGroup()
Definition: GA_Detail.h:1323
GA_VertexGroupTable & vertexGroups()
Definition: GA_Detail.h:1184
GA_AttributeScope
Definition: GA_Types.h:142
SYS_FORCE_INLINE const GA_Attribute * findAttribute(GA_AttributeOwner owner, const UT_StringRef &name) const
Definition: GA_Detail.h:1030
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
MantraGeometry * mantraGeometry()
Definition: GA_Detail.h:2388
SYS_FORCE_INLINE GA_Index primitiveIndex(GA_Offset offset) const
Given a primitive's data offset, return its index.
Definition: GA_Detail.h:423
void setPos4(GA_Offset ptoff, fpreal x, fpreal y, fpreal z, fpreal w)
Set P given the x, y, z, w components.
Definition: GA_Detail.h:313
UT_Vector4T< float > UT_Vector4
GA_Range getPointRange(const GA_PointGroup *group=0) const
Get a range of all points in the detail.
Definition: GA_Detail.h:1730
const GA_IndexMap & getPointMap() const
Definition: GA_Detail.h:741
GA_Offset primitiveEnd() const
Definition: GA_Detail.h:784
GLintptr offset
Definition: glcorearb.h:665
const GA_Topology & getTopology() const
Definition: GA_Detail.h:799
Definition: core.h:760
void setPos4(GA_Offset ptoff, const UT_Vector4 &pos)
Set P from a UT_Vector4.
Definition: GA_Detail.h:302
GA_Range getGlobalRange() const
Get a range representing the global (detail) data.
Definition: GA_Detail.h:1763
const GA_AttributeSet & getAttributes() const
Definition: GA_Detail.h:797
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3D &pos)
Definition: GA_Detail.h:242
static void forEachOffsetBreak(FUNCTOR &&functor, const GA_IndexMap &index_map, const GA_ElementGroup *group=nullptr, bool complement=false)
Definition: GA_Detail.h:1670
GA_PointGroup * newPointGroup(const UT_StringHolder &name, bool internal)
Definition: GA_Detail.h:1378
GA_Offset pointEnd() const
Definition: GA_Detail.h:780
void setPos4(GA_Offset ptoff, const UT_Vector4D &pos)
Definition: GA_Detail.h:307
ElementType< OWNER, true >::Class GROUP_TYPE
SYS_FORCE_INLINE const GA_Primitive * getPrimitive(GA_Offset prim_off) const
Definition: GA_Detail.h:432
GA_Size GA_ElementGroupOrderIndex
Class used to keep track of inheritance of intrinsic attribute evaluation.
GLint ref
Definition: glcorearb.h:124
#define SYS_SAFE_BOOL
Definition: SYS_Compiler.h:55
SYS_FORCE_INLINE GA_Offset appendPointBlock(GA_Size npoints)
Append new points, returning the first offset of the contiguous block.
Definition: GA_Detail.h:330
SYS_FORCE_INLINE void forEachPoint(FUNCTOR &&functor) const
Definition: GA_Detail.h:1499
SYS_FORCE_INLINE bool destroyElementGroup(GA_AttributeOwner owner, const UT_StringRef &name)
Definition: GA_Detail.h:1235
GA_EdgeGroup * newEdgeGroup(const UT_StringHolder &name)
Definition: GA_Detail.h:1300
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
GA_EdgeGroupUPtr createDetachedEdgeGroup() const
Definition: GA_Detail.h:1370
bool registerIO(GA_IO *io) const
Register an IO file format.
Definition: GA_Detail.h:1947
SYS_FORCE_INLINE const GA_PointGroup * findPointGroup(const UT_StringRef &name) const
Definition: GA_Detail.h:1247
SYS_FORCE_INLINE void forEachPrimitive(FUNCTOR &&functor) const
Definition: GA_Detail.h:1559
SYS_FORCE_INLINE void translatePoint(GA_Offset ptoff, const UT_Vector3D &delta)
Definition: GA_Detail.h:261
SYS_FORCE_INLINE GA_Offset appendVertex()
Append a vertex (for the entire detail)
Definition: GA_Detail.h:497
const GA_EdgeGroupTable & edgeGroups() const
Definition: GA_Detail.h:1190
GLuint GLuint end
Definition: glcorearb.h:475
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
bool success() const
Definition: GA_Detail.h:1982
GA_Size destroyUnusedPoints(const GA_PointGroup *ptgrp=0)
Destroy unused points. If ptgrp is given, then only within the group.
Definition: GA_Detail.h:689
SYS_FORCE_INLINE GA_Offset appendPoint()
Append a new point, returning its new data offset.
Definition: GA_Detail.h:326
GA_AttributeSet & getAttributes()
Definition: GA_Detail.h:796
bool getIntrinsicReadOnly(GA_LocalIntrinsic h) const
Definition: GA_Detail.h:1437
SYS_FORCE_INLINE void translatePoint(GA_Offset ptoff, const UT_Vector3 &delta)
Definition: GA_Detail.h:256
GA_Attribute * createStringAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, const UT_Options *create_args=nullptr, const GA_AttributeOptions *attribute_options=nullptr)
Definition: GA_Detail.h:983
SYS_FORCE_INLINE GA_Attribute * findPrimitiveAttribute(const UT_StringRef &name)
Definition: GA_Detail.h:1110
SYS_FORCE_INLINE GA_Offset pointVertex(GA_Offset point) const
Definition: GA_Detail.h:559
UT_UniquePtr< GA_PrimitiveGroup > GA_PrimitiveGroupUPtr
SYS_FORCE_INLINE GA_Offset findInactiveOffset(GA_Offset start, GA_Offset end) const
Definition: GA_IndexMap.h:473
void setUniqueId(exint i)
Definition: GA_Detail.h:2466
SYS_FORCE_INLINE GA_Attribute * findPointAttribute(const UT_StringRef &name)
Definition: GA_Detail.h:1096
SYS_FORCE_INLINE GA_ATINumericUPtr createDetachedTupleAttribute(GA_AttributeOwner owner, GA_Storage storage, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0f), const GA_AttributeOptions *attribute_options=nullptr) const
Definition: GA_Detail.h:892
IOStatus(const IOStatus &src)
Definition: GA_Detail.h:1968
const GA_PointGroupTable & pointGroups() const
Definition: GA_Detail.h:1178
GLdouble GLdouble GLint GLint order
Definition: glad.h:2676
SYS_FORCE_INLINE GA_Offset getNumPointOffsets() const
Definition: GA_Detail.h:341
long long int64
Definition: SYS_Types.h:116
SYS_FORCE_INLINE GA_Attribute * findAttribute(const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_size)
Definition: GA_Detail.h:1075
SYS_FORCE_INLINE GA_Index vertexIndex(GA_Offset offset) const
Given a vertex's data offset, return its index.
Definition: GA_Detail.h:519
Options during loading.
Definition: GA_LoadMap.h:42
SYS_FORCE_INLINE GA_Offset getNumVertexOffsets() const
Definition: GA_Detail.h:511
SYS_FORCE_INLINE GA_ElementGroupTableT< OWNER >::GROUP_TYPE * findElementGroup(const UT_StringRef &name)
Definition: GA_Detail.h:1216
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeScope scope, const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_size)
Definition: GA_Detail.h:1065
UT_Vector3T< fpreal64 > UT_Vector3D
const GA_IndexMap & getVertexMap() const
Definition: GA_Detail.h:742
HUSD_API bool eval(VtValue &val, T &ret_val)
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
Definition: GA_Detail.h:529
SYS_FORCE_INLINE GA_Attribute * findGlobalAttribute(GA_AttributeScope s, const UT_StringRef &name)
Definition: GA_Detail.h:1113
GA_Range getPointRangeSlice(GA_Index begin_ptnum, GA_Index end_ptnum=GA_INVALID_INDEX) const
Get ordered point range from base_ptnum to end_ptnum, or the end.
Definition: GA_Detail.h:1737
SYS_FORCE_INLINE GA_PointGroup * findPointGroup(const UT_StringRef &name)
Definition: GA_Detail.h:1257
GLuint const GLchar * name
Definition: glcorearb.h:786
SYS_FORCE_INLINE const GA_Attribute * findAttribute(GA_AttributeScope scope, const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_size) const
Definition: GA_Detail.h:1007
SYS_FORCE_INLINE bool destroyEdgeGroup(const UT_StringRef &name)
Definition: GA_Detail.h:1275
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:635
GA_PrimitiveList & getPrimitiveList()
Definition: GA_Detail.h:794
GLint GLenum GLint x
Definition: glcorearb.h:409
SYS_FORCE_INLINE bool destroyEdgeGroup(GA_EdgeGroup *g)
Definition: GA_Detail.h:1278
SYS_FORCE_INLINE const GA_Attribute * findPrimitiveAttribute(const UT_StringRef &name) const
Definition: GA_Detail.h:1052
GA_GlobalIntrinsic findGlobalIntrinsic(GA_LocalIntrinsic h) const
Definition: GA_Detail.h:1429
SYS_FORCE_INLINE GA_Offset vertexToNextVertex(GA_Offset vtx) const
Definition: GA_Detail.h:571
UT_Vector2D getPos2D(GA_Offset ptoff) const
Definition: GA_Detail.h:178
UT_UniquePtr< GA_Attribute > GA_AttributeUPtr
Definition: GA_Attribute.h:930
exint getUniqueId() const
Definition: GA_Detail.h:117
GA_Topology & getTopology()
Definition: GA_Detail.h:798
SYS_FORCE_INLINE void forEachPoint(const GA_PointGroup *group, FUNCTOR &&functor) const
Definition: GA_Detail.h:1511
GA_Offset getElement(GA_ElementGroupOrderIndex i) const
Will return -1 if the i'th entry is a mixed entry.
A list of primitives.
GLenum mode
Definition: glcorearb.h:99
SYS_FORCE_INLINE void forEachPrimitiveBreak(const GA_PrimitiveGroup *group, bool complement, FUNCTOR &&functor) const
Definition: GA_Detail.h:1606
SYS_FORCE_INLINE const GA_Attribute * findPrimitiveAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1048
GA_Size destroyPointOffsets(const GA_Range &range, GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES, bool guarantee_no_vertex_references=false)
Definition: GA_Detail.h:696
GLenum GLint GLint * precision
Definition: glcorearb.h:1925
GA_Attribute * createTupleAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, GA_Storage storage, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0f), const UT_Options *create_args=nullptr, const GA_AttributeOptions *attribute_options=nullptr)
Definition: GA_Detail.h:969
SYS_FORCE_INLINE GA_Index pointIndex(GA_Offset offset) const
Given a point's data offset, return its index.
Definition: GA_Detail.h:349
GA_VertexGroupUPtr createDetachedVertexGroup() const
Definition: GA_Detail.h:1366
SYS_FORCE_INLINE GA_ElementGroupTable & getElementGroupTable(GA_AttributeOwner owner)
Definition: GA_Detail.h:1163
UT_Vector3T< T > getPos3T(GA_Offset ptoff) const
Definition: GA_Detail.h:196
SYS_FORCE_INLINE GA_Size getNumVertices() const
Return the number verticies in the entire detail.
Definition: GA_Detail.h:504
GLsizeiptr size
Definition: glcorearb.h:664
GA_Size entries() const
Return the total number of entries, mixed or not.
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
SYS_FORCE_INLINE GA_Offset vertexPrimitive(GA_Offset vertex) const
Definition: GA_Detail.h:545
static const GROUP_TYPE * castGroup(const GA_ElementGroup *group)
GA_Offset vertexEnd() const
Definition: GA_Detail.h:782
GA_AttributeOwner
Definition: GA_Types.h:34
A map of string to various well defined value types.
Definition: UT_Options.h:84
Class to return information about a GA_Detail.
Definition: GA_Stat.h:50
GA_LocalIntrinsic findIntrinsic(GA_GlobalIntrinsic h) const
Definition: GA_Detail.h:1427
void clear()
Definition: GA_Detail.h:127
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
Set P from a UT_Vector3.
Definition: GA_Detail.h:237
GA_Offset vertexBegin() const
Definition: GA_Detail.h:776
SYS_FORCE_INLINE GA_AttributeUPtr createDetachedAttribute(GA_AttributeOwner owner, const GA_AttributeType &attribtype, const UT_Options *create_args=nullptr, const GA_AttributeOptions *attribute_options=nullptr) const
Definition: GA_Detail.h:917
SYS_FORCE_INLINE GA_Offset getNumPrimitiveOffsets() const
Definition: GA_Detail.h:415
constexpr UT_Vector3T< SYS_FixedArrayElement_t< TS > > UTmakeVector3T(const TS &as) noexcept
Definition: UT_Vector3.h:1313
void copyVertex(GA_Offset destvtxoff, GA_Offset srcvtxoff, bool ref_point_dont_copy, const GA_AttributeFilter *filter=nullptr)
Definition: GA_Detail.h:1869
fpreal64 fpreal
Definition: SYS_Types.h:277
SYS_FORCE_INLINE GA_Offset primitiveOffset(GA_Index index) const
Given a primitive's index (in append order), return its data offset.
Definition: GA_Detail.h:419
SYS_FORCE_INLINE GA_ElementGroupTableT< OWNER >::GROUP_TYPE * createInternalElementGroup(bool ordered=false)
Definition: GA_Detail.h:1207
SYS_FORCE_INLINE bool destroyAttribute(GA_AttributeOwner owner, const UT_StringRef &name)
Definition: GA_Detail.h:938
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:160
GLuint index
Definition: glcorearb.h:786
bool containsPrimitiveType(const GA_PrimitiveTypeId &type) const
Definition: GA_Detail.h:2287
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
SYS_FORCE_INLINE GA_Size getNumPrimitives() const
Return the number of primitives.
Definition: GA_Detail.h:408
SYS_FORCE_INLINE void forEachPoint(const GA_PointGroup *group, bool complement, FUNCTOR &&functor) const
Definition: GA_Detail.h:1520
Class used to map the GA attribute into a form for H9 geometry files.
Definition: GA_AIFFileH9.h:262
Compute an instance transform given a set of attributes.
GLuint GLfloat * val
Definition: glcorearb.h:1608
GA_PrimitiveGroup * newPrimitiveGroup(const UT_StringHolder &name, bool internal)
Definition: GA_Detail.h:1382
int64 getMetaCacheCount() const
Definition: GA_Detail.h:2370
SYS_FORCE_INLINE void forEachPointBreak(FUNCTOR &&functor) const
Definition: GA_Detail.h:1530
const GA_PrimitiveList & getPrimitiveList() const
Definition: GA_Detail.h:792
const GA_Attribute * getPwAttribute() const
Definition: GA_Detail.h:281
SYS_FORCE_INLINE bool renameAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &from_name, const UT_StringHolder &to_name)
Definition: GA_Detail.h:944
Provide options when performing a merge operation.
IOStatus(bool success=false)
Definition: GA_Detail.h:1965
#define GA_INVALID_INDEX
Definition: GA_Types.h:677
SYS_FORCE_INLINE UT_Vector3D getPos3D(GA_Offset ptoff) const
Definition: GA_Detail.h:190
GA_Size destroyPoints(const GA_Range &range, GA_DestroyPointMode mode=GA_LEAVE_PRIMITIVES, bool guarantee_no_vertex_references=false)
Definition: GA_Detail.h:703
SYS_FORCE_INLINE GA_Attribute * findAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name)
Definition: GA_Detail.h:1083
bool getPos3AsArray(const GA_Range &ptrange, UT_Array< UT_Vector3T< T > > &positions) const
Definition: GA_Detail.h:207
void destroyStashed()
Definition: GA_Detail.h:156
SYS_FORCE_INLINE void forEachPrimitive(const GA_PrimitiveGroup *group, bool complement, FUNCTOR &&functor) const
Definition: GA_Detail.h:1584
GA_PrimitiveGroupTable & primitiveGroups()
Definition: GA_Detail.h:1180
Container class for all geometry.
Definition: GA_Detail.h:96
bool isPrimary() const
Definition: GA_Detail.h:2323
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
Definition: core.h:1131
GA_Size destroyVertices(const GA_Range &range)
Definition: GA_Detail.h:715
SYS_FORCE_INLINE bool destroyAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringRef &name)
Definition: GA_Detail.h:930
SYS_FORCE_INLINE void forEachPrimitive(const GA_PrimitiveGroup *group, FUNCTOR &&functor) const
Definition: GA_Detail.h:1575
SYS_FORCE_INLINE GA_Attribute * findVertexAttribute(GA_AttributeScope s, const UT_StringRef &name)
Definition: GA_Detail.h:1099
UT_UniquePtr< GA_PointGroup > GA_PointGroupUPtr
GA_LocalIntrinsic findIntrinsic(const UT_StringRef &nm) const
Definition: GA_Detail.h:1425
virtual void privateComputeNormal(const GA_RWHandleV3 &normalattrib, const GA_Group *group, const float cuspangledegrees, const int method) const
Definition: GA_Detail.h:2450
const GA_AttributeDict & getAttributeDict(GA_AttributeOwner owner) const
Definition: GA_Detail.h:832
SYS_FORCE_INLINE GA_Offset vertexOffset(GA_Index index) const
Given a vertex's index (in append order), return its data offset.
Definition: GA_Detail.h:515
const GA_PrimitiveGroupTable & primitiveGroups() const
Definition: GA_Detail.h:1182
UT_Vector4T< fpreal64 > UT_Vector4D
GA_VertexGroup * newVertexGroup(const UT_StringHolder &name)
Definition: GA_Detail.h:1292
SYS_FORCE_INLINE const GA_Attribute * findAttribute(const UT_StringRef &name, const GA_AttributeOwner search_order[], int search_size) const
Definition: GA_Detail.h:1017
SYS_FORCE_INLINE const GA_Attribute * findPointAttribute(GA_AttributeScope s, const UT_StringRef &name) const
Definition: GA_Detail.h:1034
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
GA_Range getPrimitiveRange(const GA_PrimitiveGroup *group=0) const
Get a range of all primitives in the detail.
Definition: GA_Detail.h:1733
SYS_FORCE_INLINE const GA_VertexGroup * findVertexGroup(const UT_StringRef &name) const
Definition: GA_Detail.h:1250
void write(T &out, bool v)
Definition: ImfXdr.h:287
void setPos2(GA_Offset ptoff, const UT_Vector2 &pos)
Set P from a UT_Vector2.
Definition: GA_Detail.h:225
type
Definition: core.h:1059
Class to specify options for loading geometry.
SYS_FORCE_INLINE bool destroyElementGroup(GA_AttributeOwner owner, const char *name)
Definition: GA_Detail.h:1239
static void forEachOffset(FUNCTOR &&functor, const GA_IndexMap &index_map, const GA_ElementGroup *group=nullptr, bool complement=false)
Definition: GA_Detail.h:1613
SYS_FORCE_INLINE void forEachOffsetBreak(FUNCTOR &&functor) const
Definition: GA_IndexMap.h:528
SYS_FORCE_INLINE GA_Offset pointOffset(GA_Index index) const
Given a point's index (in append order), return its data offset.
Definition: GA_Detail.h:345
unsigned int uint
Definition: SYS_Types.h:45
bool getPrimitivesOfType(const GA_PrimitiveTypeId &type, UT_Array< const GA_Primitive * > &prims) const
Definition: GA_Detail.h:2298
GA_Storage
Definition: GA_Types.h:50
UT_UniquePtr< GA_ATINumeric > GA_ATINumericUPtr
const GA_PrimitiveFactory & getPrimitiveFactory() const
Definition: GA_Detail.h:2247
SYS_FORCE_INLINE GA_Attribute * findVertexAttribute(const UT_StringRef &name)
Definition: GA_Detail.h:1103
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:425
GA_Attribute * createTupleAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, GA_Storage storage, int tuple_size, const GA_Defaults &defaults=GA_Defaults(0.0f), const UT_Options *create_args=nullptr, const GA_AttributeOptions *attribute_options=nullptr)
Definition: GA_Detail.h:954
GA_Attribute * getPwAttribute()
Definition: GA_Detail.h:285
GLint GLsizei count
Definition: glcorearb.h:405
UT_UniquePtr< GA_EdgeGroup > GA_EdgeGroupUPtr
Definition: GA_EdgeGroup.h:466
bool containsOnlyPrimitiveTypes(const UT_Array< GA_PrimitiveTypeId > &type) const
Definition: GA_Detail.h:2289
GA_Attribute * createAttribute(GA_AttributeOwner owner, GA_AttributeScope scope, const UT_StringHolder &name, const UT_Options *create_args, const GA_AttributeOptions *attribute_options, const UT_StringRef &attribtype)
Definition: GA_Detail.h:864
const GA_IntrinsicManager & getIntrinsicManager() const
Definition: GA_Detail.h:1418
SYS_FORCE_INLINE GA_Offset offsetSize() const
Definition: GA_IndexMap.h:97
const char * getIntrinsicName(GA_LocalIntrinsic h) const
Definition: GA_Detail.h:1432
SYS_FORCE_INLINE GA_Offset appendVertexBlock(GA_Size nvertices)
Append new vertices, returning the first offset of the contiguous block.
Definition: GA_Detail.h:500
GA_Offset primitiveBegin() const
Definition: GA_Detail.h:778
GA_Attribute * createStringAttribute(GA_AttributeOwner owner, const UT_StringHolder &name, const UT_Options *create_args=nullptr, const GA_AttributeOptions *attribute_options=nullptr)
Definition: GA_Detail.h:994
SYS_FORCE_INLINE GA_Size getNumPoints() const
Return the number of points.
Definition: GA_Detail.h:334
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663
UT_Vector4D getPos4D(GA_Offset ptoff) const
Definition: GA_Detail.h:296