HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_Primitive.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_Primitive.h (GA Library, C++)
7  *
8  * COMMENTS: Interface for primitives.
9  */
10 
11 #pragma once
12 
13 #ifndef __GA_Primitive__
14 #define __GA_Primitive__
15 
16 #define GA_PRIMITIVE_VERTEXLIST 1
17 
18 #include "GA_API.h"
19 #include "GA_Detail.h"
20 #include "GA_IntrinsicManager.h"
21 #include "GA_OffsetList.h"
22 #include "GA_PrimCompat.h"
23 #include "GA_PrimitiveDefinition.h"
24 #include "GA_PrimitiveFamilyMask.h"
25 #include "GA_PrimitiveTypeId.h"
26 #include "GA_SharedDataHandle.h"
27 #include "GA_SharedLoadData.h"
28 #include "GA_Range.h"
29 #include "GA_Topology.h"
30 #include "GA_Types.h"
31 
32 #include <UT/UT_BoundingBox.h>
33 #include <UT/UT_BoundingRect.h>
34 #include <UT/UT_Function.h>
35 #include <UT/UT_NonCopyable.h>
36 #include <UT/UT_VectorTypes.h>
37 #include <SYS/SYS_Inline.h>
38 #include <SYS/SYS_Types.h>
39 
40 #include <iosfwd>
41 #include <stddef.h>
42 
45 class GA_Attribute;
46 class GA_Defragment;
47 class GA_Detail;
48 class GA_IntrinsicEval;
49 class GA_MergeMap;
50 class GA_PrimitiveJSON;
51 class GA_PrimitiveList;
53 class GA_GeometryIndex;
54 
55 class UT_BoundingSphere;
56 class UT_IStream;
57 class UT_MemoryCounter;
58 class UT_Options;
59 class UT_String;
60 class UT_StringArray;
61 template <typename T> class UT_Array;
62 
63 template<typename T, bool B> class GA_EdgeT;
65 
66 
67 class GA_Primitive;
68 typedef void (* GA_EdgeApplyFunc)(const GA_Primitive &prim,
69  GA_Offset pt_a, GA_Offset pt_b, void *data);
70 typedef void (* GA_EdgeApplyIndexFunc)(const GA_Primitive &prim,
71  GA_Size v1, GA_Size v2, void *data);
72 
75 
76 #define GA_NO_OVERRIDE
77 
78 /// Declare intrinsic callback functions in header file. See
79 /// GA_IntrinsicMacros.h for macros to help implement intrinsics.
80 #define GA_DECLARE_INTRINSICS(OVERRIDE) \
81  static GA_IntrinsicManager::Registrar \
82  registerIntrinsics(GA_PrimitiveDefinition &); \
83  virtual GA_Size localIntrinsicTupleSize(const GA_IntrinsicEval &) const \
84  OVERRIDE; \
85  virtual GA_Size localGetIntrinsicI(const GA_IntrinsicEval &, \
86  int64 *, GA_Size) const OVERRIDE; \
87  virtual GA_Size localGetIntrinsicF(const GA_IntrinsicEval &, \
88  fpreal64 *, GA_Size) const OVERRIDE; \
89  virtual GA_Size localGetIntrinsicS(const GA_IntrinsicEval &, \
90  UT_String &) const OVERRIDE; \
91  virtual GA_Size localGetIntrinsicSA(const GA_IntrinsicEval &, \
92  UT_StringArray &) const OVERRIDE; \
93  virtual GA_Size localGetIntrinsicD(const GA_IntrinsicEval &, \
94  UT_OptionsHolder &) const OVERRIDE; \
95  virtual GA_Size localGetIntrinsicDA(const GA_IntrinsicEval &, \
96  UT_Array<UT_OptionsHolder> &) const OVERRIDE; \
97  virtual GA_Size localSetIntrinsicI(const GA_IntrinsicEval &, \
98  const int64 *, GA_Size) OVERRIDE; \
99  virtual GA_Size localSetIntrinsicF(const GA_IntrinsicEval &, \
100  const fpreal64 *, GA_Size) OVERRIDE; \
101  virtual GA_Size localSetIntrinsicSS(const GA_IntrinsicEval &, \
102  const char **, GA_Size) OVERRIDE; \
103  virtual GA_Size localSetIntrinsicSA(const GA_IntrinsicEval &, \
104  const UT_StringArray &) OVERRIDE; \
105  virtual GA_Size localSetIntrinsicDS(const GA_IntrinsicEval &, \
106  const UT_OptionsHolder *, GA_Size) OVERRIDE; \
107  virtual GA_Size localSetIntrinsicDA(const GA_IntrinsicEval &, \
108  const UT_Array<UT_OptionsHolder> &) OVERRIDE;
109 
111 {
112 protected:
113  /// NOTE: The constructor should only be called from subclass
114  /// constructors.
117  : myDetail(&detail)
118  , myOffset(offset)
119  {}
120 
121 public:
122  /// NOTE: The destructor should only be called from subclass
123  /// destructors; only GA_PrimitiveList should be calling
124  /// delete on GA_Primitive pointers.
125  virtual ~GA_Primitive()
126  {
127  // The detail should have already deleted the vertices, and
128  // myVertexList is automatically cleaned up in its destructor.
129  }
130 
131  virtual const GA_PrimitiveDefinition &getTypeDef() const = 0;
132 
133  const char *getTypeName() const
134  { return getTypeDef().getToken(); }
135 
136  /// Gets the detail containing this primitive.
137  ///
138  /// FIXME: This should return a const detail, and a non-const version should
139  /// return a non-const detail.
142  { return *myDetail; }
143 
144  /// Gets the offset of this primitive in the detail containing it.
147  { return myOffset; }
148 
149  /// Gets the index of this primitive in the detail containing it.
152  { return myDetail->primitiveIndex(myOffset); }
153 
154  /// Gets the index map for primitives in the detail containing this primitive.
156  const GA_IndexMap &getIndexMap() const
157  { return myDetail->getPrimitiveMap(); }
158 
159  SYS_DEPRECATED_HDK(13.0)
160  GA_Index getNum() const
161  { return getMapIndex(); }
162 
163  /// For defragmentation, we need to update the offset
164  void swapOffsetValue(const GA_Defragment &defrag);
165 
166  /// Returns true if the primitive is part of a 3D geometry detail
167  /// (GEO_Detail), and false if it is part of a 2D geometry detail
168  /// (GD_Detail) for trim/projection curves.
169  bool isPrimary() const
170  { return myDetail->isPrimary(); }
171 
172  // FIXME: Switch this back to SYS_FORCE_INLINE when Microsoft fixes
173  // Visual Studio bug report ID 2154929.
174  // It seems to be fixed in Update 3, so I updated the define,
175  // but we haven't switched our builds over yet from Update 1.
178  { return getTypeDef().getId(); }
180  { return getTypeDef().getFamilyMask(); }
181  bool isFamily(unsigned family_mask) const
182  { return ((getFamilyMask() & family_mask) != 0); }
183 
184  /// Whether the primitive has a transform associated with it
185  bool hasLocalTransform() const
186  { return getTypeDef().hasLocalTransform(); }
187  /// Return the local transform matrix for the primitive. Some primitives
188  /// don't store transforms (see @c hasLocalTransform()). The default
189  /// behaviour is to make the transform an identity.
190  virtual void getLocalTransform(UT_Matrix3D &matrix) const;
191 
192  /// Return the local transform matrix for the primitive, but with the
193  /// translates specified by the position of the first vertex of the
194  /// primitive. This only includes the local transform and the translate
195  /// due to the point position.
196  virtual void getLocalTransform4(UT_Matrix4D &matrix) const;
197 
198  /// Set the local transform. The default implementation does nothing.
199  virtual void setLocalTransform(const UT_Matrix3D &matrix);
200 
201  /// @deprecated This method is only for transitional backward compatibility
202  /// for the HDK and will be removed in a future release.
203  /// TODO: Should be pure virtual here, overwritten at GEO_Primitive.
205  { return primCompatMaskFromTypeId(getTypeId().get()); }
206 
207  /// Report approximate memory usage, including sizeof(*this) and
208  /// any shared memory.
209  virtual int64 getMemoryUsage() const
210  {
211  return sizeof(*this) + getBaseMemoryUsage();
212  }
213  virtual int64 getDeviceMemoryUsage() const
214  {
215  return 0;
216  }
217 
218  /// Count memory usage using a UT_MemoryCounter in order to count
219  /// shared memory correctly.
220  /// NOTE: This should always include sizeof(*this).
221  virtual void countMemory(UT_MemoryCounter &counter) const;
222 
223  /// @{
224  /// This method is called when the vertex index map is being defragmented.
225  /// Since the defragmentation process moves vertex offsets, primitives need
226  /// to update their references with the new values. @code
227  /// new_vtx_offset = defrag.mapOffset(new_vtx_offset);
228  /// myOffsetList.swapOffsetValues(defrag);
229  /// myOffsetMatrix.swapOffsetValues(defrag);
230  /// @endcode
231  virtual void swapVertexOffsets(const GA_Defragment &defrag);
232  /// @}
233 
234  /// Return the number of vertices used by this primitive
237  {
238  return myVertexList.size();
239  }
240 
241  /// Given an vertex number (into the primitive's vertex list), return the
242  /// vertex offset.
244  GA_Offset getVertexOffset(GA_Size primvertexnum) const
245  {
246  UT_ASSERT_P(primvertexnum >= 0 && primvertexnum < myVertexList.size());
247  return myVertexList.get(primvertexnum);
248  }
250  GA_Index getVertexIndex(GA_Size primvertexnum) const
251  {
252  return getDetail().vertexIndex(getVertexOffset(primvertexnum));
253  }
254 
255  /// Given a vertex number (into the primitive's vertex list), return the
256  /// point offset.
259  { return getDetail().vertexPoint(getVertexOffset(i)); }
260 
261  /// Given a vertex number (into the primitive's vertex list), set the
262  /// corresponding point offset.
265  {
266  getDetail().setVertexPoint(getVertexOffset(i), ptoff);
267  }
268 
269  /// Given a vertex number (into the primitive's vertex list), return its
270  /// point index number.
273  { return getDetail().pointIndex(getPointOffset(i)); }
274 
275  /// Given a vertex number (into the primitive's vertex list), return its
276  /// point's position.
279  { return getDetail().getPos3(getPointOffset(i)); }
282  { return getDetail().getPos3D(getPointOffset(i)); }
283  template <typename T>
285  { return getDetail().getPos3T<T>(getPointOffset(i)); }
286 
287  /// Given a vertex number (into the primitive's vertex list),
288  /// move the point to the specified position.
290  void setPos3(GA_Size i, const UT_Vector3 &pos) const
291  { getDetail().setPos3(getPointOffset(i), pos); }
293  void setPos3(GA_Size i, const UT_Vector3D &pos) const
294  { getDetail().setPos3(getPointOffset(i), pos); }
295 
296  /// Given a vertex number (into the primitive's vertex list), return its
297  /// point's position.
300  { return getDetail().getPos4(getPointOffset(i)); }
303  { return getDetail().getPos4D(getPointOffset(i)); }
304 
305  /// Given a vertex number (into the primitive's vertex list),
306  /// move the point to the specified position.
308  void setPos4(GA_Size i, const UT_Vector4 &pos) const
309  { getDetail().setPos4(getPointOffset(i), pos); }
311  void setPos4(GA_Size i, const UT_Vector4D &pos) const
312  { getDetail().setPos4(getPointOffset(i), pos); }
313 
314  /// Get a range of all the vertices accessed by the primitive
315  GA_Range getVertexRange(bool harden=false) const
316  {
317  return GA_Range(getDetail(), getMapOffset(),
319  harden);
320  }
321  /// Get a range of all the points accessed by the primitive. Note, the
322  /// range may visit points multiple times.
323  GA_Range getPointRange(bool harden=false) const
324  {
325  return GA_Range(getDetail(), getMapOffset(),
327  harden);
328  }
329 
330  /// Return whether a point is referenced by a primitive. This simply
331  /// iterates over the vertices, checking if any vertices reference the
332  /// point.
333  bool isPointUsed(GA_Offset ptoff) const
334  {
335  GA_Size nvtx = getVertexCount();
336  for (GA_Size i = 0; i < nvtx; ++i)
337  {
338  if (getPointOffset(i) == ptoff)
339  return true;
340  }
341  return false;
342  }
343 
344  /// Add all points referenced by the primitive to the given group. This
345  /// defaults to iterating over the vertices and adding their referenced
346  /// points.
347  void addPointRefToGroup(GA_PointGroup &grp) const;
348 
349  /// Method to determine if a primitive has an edge (undirected).
350  virtual bool hasEdge(const GA_Edge &edge) const;
351 
352 
353  /// Calls apply for each directed edge in this primitive
354  /// @deprecated Use @c iterateEdges instead.
355  SYS_DEPRECATED_HDK_REPLACE(16.0, iterateEdges)
356  void edgeApply(GA_EdgeApplyFunc apply, void *data = nullptr) const;
357 
358  /// Calls apply for each directed edge in this primitive
359  /// @deprecated Use @c iterateEdgesByVertex instead.
360  SYS_DEPRECATED_HDK_REPLACE(16.0, iterateEdgesByVertex)
361  void edgeApplyIndex(GA_EdgeApplyIndexFunc apply, void *data = nullptr) const;
362 
363  /// Calls @c apply_func for each directed edge on the primitive.
364  /// If the @c apply_func function returns @c false, then the
365  /// traversal will be stopped.
366  virtual void iterateEdges(GA_IterateEdgesFunc apply_func) const
367  {
368  // Default implementation does nothing.
369  // Re-implemented by relevant primitives.
370  }
371 
372  /// Calls @c apply_func for each directed edge on the primitive,
373  /// passing in the @c GA_Size primitive vertex index for each point on the
374  /// edge. If the @c apply_func function returns @c false, then the
375  /// traversal will be stopped.
376  virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
377  {
378  // Default implementation does nothing.
379  // Re-implemented by relevant primitives.
380  }
381 
382  /// Calls edgeApplyIndex to find the vertices within this primitive,
383  /// corresponding with the first undirected edge between ptoff0 and ptoff1.
384  /// If the edge is not in this primitive, vtx0 and vtx1 will not be
385  /// written-to, and the function will return false.
386  /// When written, vtx0->vtx1 will always be the direction the edge
387  /// appears in this primitive, which may be *opposite* ptoff0->ptoff1.
388  bool findEdgePoints(GA_Offset ptoff0, GA_Offset ptoff1,
389  GA_Size &vtx0, GA_Size &vtx1) const;
390 
391  /// The return status of @c dereferencePoint()
392  /// - GA_DEREFERENCE_FAIL @n
393  /// The primitive cannot detach itself from the points and thus the
394  /// points cannot be deleted. It's possible that the primitive may be
395  /// destroyed in this case if the user specified this behaviour (see
396  /// GA_Detail::GA_DestroyPointMode).
397  /// - GA_DEREFERENCE_OK @n
398  /// The primitive has detached the points and is still valid.
399  /// - GA_DEREFERENCE_DEGENERATE @n
400  /// The primitive has detached the points but is now degenerate.
401  /// - GA_DEREFERENCE_DESTROY @n
402  /// The primitive has detached the points and should now be destroyed.
404  {
409  };
410  /// Before points are deleted, all primitives referencing the points will
411  /// be notified using @c dereferencePoint or @c dereferencePoints. These
412  /// methods should return the appropriate DeferefenceStatus.
413  /// @example
414  /// A quadric primitive will return
415  /// - GA_DEREFERENCE_OK @n
416  /// If it's point is not in the point group
417  /// - GA_DEREFERENCE_DESTROY @n
418  /// If it destroyed its vertex
419  /// A hull primitive will return
420  /// - GA_DEREFERENCE_OK @n
421  /// If a full row or column was dereferenced
422  /// - GA_DEREFERENCE_DEGENERATE @n
423  /// If a full row/column was dereferenced, leaving a degenerate
424  /// primitive.
425  /// - GA_DEREFERENCE_FAIL @n
426  /// If a single point from within the hull cannot be dereferenced
427  /// The @c dry_run parameter will prevent the point from actually being
428  /// detached.
429  virtual GA_DereferenceStatus dereferencePoint(GA_Offset point,
430  bool dry_run=false) = 0;
431  virtual GA_DereferenceStatus dereferencePoints(
432  const GA_RangeMemberQuery &pt_q,
433  bool dry_run=false) = 0;
434 
435  /// @{
436  /// Enlarge a bounding box by the bounding box of the primitive. A
437  /// return value of false indicates an error in the operation, most
438  /// likely an invalid P. By default, these methods simply enlarge the
439  /// bounding box based on the vertices.
440  virtual bool enlargeBoundingBox(UT_BoundingRect &b,
441  const GA_Attribute *P) const;
442  virtual bool enlargeBoundingBox(UT_BoundingBox &b,
443  const GA_Attribute *P) const;
444  /// @}
445 
446  /// Enlarge a bounding box by the visible bounding box of the primitive.
447  ///
448  /// A return value of false indicates an error in the operation, most
449  /// likely an invalid P. By default, it merely calls enlargeBoundingBox()
450  virtual bool enlargeVisibleBoundingBox(
451  UT_BoundingBox &b,
452  const GA_Attribute *P) const;
453 
454  /// Enlarge a bounding sphere to encompass the primitive. A return value
455  /// of false indicates an error in the operation, most likely an invalid
456  /// P. By default, this method simply enlarges the bounding box based on
457  /// the vertices.
458  virtual bool enlargeBoundingSphere(UT_BoundingSphere &b,
459  const GA_Attribute *P) const;
460 
461  /// Enlarge a point bounding box for implicit primitive bounds. If a
462  /// primitive (such as a sphere) has a bounding box larger than its point
463  /// hull, then it should implement this method. Otherwise, it can rely on
464  /// the default behaviour.
465  ///
466  /// NOTE: If you make a custom primitive type whose bounding box may be
467  /// larger than the bounding box of the points referenced by
468  /// vertices of the primitive, you must override this function
469  /// in order for the detail's bounding box to be correctly computed.
470  /// It does not suffice to override GEO_Primitive::getBBox(), since
471  /// GA_Detail::computeQuickBounds will find the point bounding box
472  /// of the entire detail, and then call enlargePointBounds
473  /// on all primitives except polygons, tetrahedra, polysoups,
474  /// and other primitive types that are known in advance to not
475  /// exceed their point bounding boxes.
476  virtual void enlargePointBounds(UT_BoundingBox &box) const;
477 
478  /// Is the primitive degenerate
479  virtual bool isDegenerate() const = 0;
480 
481  /// Copy the specified primitive as part of the merge. The source
482  /// primitive will be of the same type.
483  ///
484  /// Since the vertex offsets will change for the merged geometry, the map
485  /// should be used to lookup the new vertex offsets. For example
486  /// @code
487  /// map.mapDestFromSource( GA_ATTRIB_VERTEX, source_vertex );
488  /// @endcode
489  ///
490  /// @see GA_MergeMap
492  const GA_Primitive *src, const GA_MergeMap &map)
493  {
494  UT_ASSERT(src != this);
495  copyVertexListForMerge(src->myVertexList, map);
496  copySubclassData(src);
497  }
498 
499  /// Copy all subclass data from source to this.
500  ///
501  /// The vertex lists of source and this must already be equivalent
502  /// in some manner, though possibly referring to different vertices.
503  ///
504  /// If some subclass data is dependent on the vertex list contents,
505  /// (such as GEO_PrimPolySoup::myPolygonVertexList),
506  /// it should be mapped based on the correspondence between the two.
507  /// GEO_PrimPolySoup is currently the only primitive type with this
508  /// sort of dependence, so it's probably best not to add more.
509  ///
510  /// NOTE: This must be safe to call on different primitives
511  /// in parallel at the same time.
512  virtual void copySubclassData(const GA_Primitive *source)
513  {
514  UT_ASSERT_P(source != nullptr);
515  UT_ASSERT_P(source != this);
516  UT_ASSERT_P(source->getTypeId() == getTypeId());
517  UT_ASSERT_P(myVertexList.size() == source->myVertexList.size());
518  UT_ASSERT_P(myVertexList.getExtraFlag() == source->myVertexList.getExtraFlag());
519  };
520 
521  /// This method returns the JSON interface for saving/loading the primitive
522  /// If the method returns a NULL pointer, then the primitive will @b not
523  /// be saved to geometry files (and thus cannot be loaded).
524  virtual const GA_PrimitiveJSON *getJSON() const = 0;
525 
526  /// Some primitives can have common/shared data between different
527  /// instances of the primitives. This method is invoked during the save
528  /// process to save data. The method requires you to save two objects
529  /// sequentially (the data is stored in a list) for each shared key:
530  /// - The primitive typedef name. This is used at load time to find the
531  /// definition which knows how to load the data.
532  /// - The data required to represent the shared object. This is
533  /// typically a list or map containing the type of data, the key value
534  /// (used for loading) and the actual object data.
535  ///
536  /// If there are multiple shared data pointers, the array can continue with name/value pairs.
537  ///
538  /// For example, you might have something like: @code
539  /// const char *key = makeKeyForSharedPtr(ptr);
540  /// bool ok = true;
541  /// if (!save.hasSavedSharedData(key))
542  /// {
543  /// save.setSavedSharedData(key); // Flag this data as saved
544  /// ok = ok && w.jsonStringToken(getTypeName());
545  /// ok = ok && w.jsonBeginArray();
546  /// ok = ok && w.jsonStringToken("datatype");
547  /// ok = ok && w.jsonStringToken(key);
548  /// ok = ok && saveSharedData(ptr);
549  /// ok = ok && w.jsonEndArray();
550  /// }
551  /// return ok;
552  /// @endcode
553  /// Then in the primitive JSON, you'd likely want to have two fields, one
554  /// for the shared data pointer, the other for an expanded version of the
555  /// data. The @c shouldSaveField() method would be something like: @code
556  /// if (index == SHARED_DATA_KEY)
557  /// return save.hasSavedSharedData(key);
558  /// if (index == EXPANDED_DATA_KEY)
559  /// return !save.hasSavedSharedData(key);
560  /// @endcode
561  ///
562  /// Then the saveField() method of the primitive JSON would look something
563  /// like: @code
564  /// switch (index)
565  /// {
566  /// case SHARED_DATA_KEY:
567  /// UT_ASSERT(save.hasSaveSharedData(key));
568  /// return w.jsonString(key);
569  /// case EXPANDED_DATA_KEY:
570  /// UT_ASSERT(!save.hasSaveSharedData(key));
571  /// return saveSharedData(ptr);
572  /// }
573  /// @endcode
574  ///
575  /// During the loading process, you can just get the shared data from the
576  /// load map. @code
577  /// MySharedDataContainer *data;
578  /// data = load.sharedLoadDataAs<MySharedDataContainer>(key);
579  /// if (data)
580  /// setSharedPointer(data->getSharedData();
581  /// else
582  /// return false;
583  /// @endcode
584  virtual bool saveSharedLoadData(
585  UT_JSONWriter &w,
586  GA_SaveMap &save,
587  GA_GeometryIndex *geo_index) const;
588 
589  virtual bool registerSharedLoadData(
590  int load_data_type,
592 
593  virtual bool loadH9(UT_IStream &is,
594  const UT_Array<GA_AttribLoadDataH9> &prim_attribs,
595  const UT_Array<GA_AttribLoadDataH9> &vtx_attribs);
596  virtual bool saveH9(std::ostream &os, bool binary,
597  const UT_Array<GA_AttribSaveDataH9> &prim_attribs,
598  const UT_Array<GA_AttribSaveDataH9> &vtx_attribs)
599  const;
600 
601  // ------------ Intrinsic interface ------------
602  /// Get the intrinsic manager for primitive intrinsics.
603  /// All primitives have at least the following intrinsics:
604  /// - "string typename" @n The type name of the primitive
605  /// - "int typeid" @n The type id (may change per run)
606  /// - "int vertexcount" @n The number of vertices in the primitive
608  { return getTypeDef().getIntrinsicManager(); }
609 
610  /// @{
611  /// Query properties of the primitive intrinsic.
612  /// Note that the tuple size calls the virtual method since the tuple size
613  /// may be dynamic (i.e. basis knot vector). This also means that to know
614  /// whether a single component tuple should collapse to a scalar value, you
615  /// need to call the getIntrinsicCollapseSingletons method.
617  { return getIntrinsicManager().getLocalHandle(nm); }
619  { return getIntrinsicManager().getLocalHandle(h); }
621  { return getIntrinsicManager().getGlobalHandle(h); }
622 
624  { return getIntrinsicManager().getName(h); }
625  GA_Size getIntrinsicTupleSize(GA_LocalIntrinsic h) const;
627  GA_LocalIntrinsic h) const
628  { return getIntrinsicManager().getCollapseSingletons(h); }
630  { return getIntrinsicManager().getStorage(h); }
632  { return getIntrinsicManager().getReadOnly(h); }
634  { return getIntrinsicManager().getOptions(h); }
635  /// @}
636 
637  /// @{
638  /// Get the value of a primitive intrinsic.
639  /// These methods return the number of items retrieved.
640  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_String &val) const;
641  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_StringArray &val) const;
642  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_OptionsHolder &val) const;
644  GA_Size getIntrinsic(GA_LocalIntrinsic h, int64 *v, GA_Size size) const;
645  GA_Size getIntrinsic(GA_LocalIntrinsic h, fpreal64 *v, GA_Size sz) const;
646  /// @}
647 
648  /// @{
649  /// Get the value of a primitive intrinsic.
650  /// Returns false if not the right type or not found.
651  /// Always will clear out the provided value.
652  bool getIntrinsic(GA_LocalIntrinsic h, float &v) const;
653  bool getIntrinsic(GA_LocalIntrinsic h, int &v) const;
654  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector2 &v) const;
655  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector3 &v) const;
656  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector4 &v) const;
657  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix2 &v) const;
658  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix3 &v) const;
659  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix4 &v) const;
660  bool getIntrinsic(GA_LocalIntrinsic h, double &v) const;
661  bool getIntrinsic(GA_LocalIntrinsic h, int64 &v) const;
662  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector2D &v) const;
663  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector3D &v) const;
664  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector4D &v) const;
665  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix2D &v) const;
666  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix3D &v) const;
667  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix4D &v) const;
668 
669  /// @}
670 
671  /// @{
672  /// Set intrinsic attributes. This will fail if the intrinsic is read-only.
673  /// These methods return the number of items set.
674  GA_Size setIntrinsic(GA_LocalIntrinsic h, const char *value);
675  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_StringArray &value);
676  GA_Size setIntrinsic(GA_LocalIntrinsic h, const char **val, GA_Size s);
677  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_OptionsHolder &value);
679  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_OptionsHolder *value, GA_Size s);
680  GA_Size setIntrinsic(GA_LocalIntrinsic h, const int64 val);
681  GA_Size setIntrinsic(GA_LocalIntrinsic h, const fpreal64 val);
682  GA_Size setIntrinsic(GA_LocalIntrinsic h, const int64 *val, GA_Size sz);
683  GA_Size setIntrinsic(GA_LocalIntrinsic h, const fpreal64 *v, GA_Size sz);
684  /// @}
685 
686  /// Private interface
687  /// The clearForDeletion() method is called just prior to the detail being
688  /// cleared out. This allows the primitive to simplify its data structures,
689  /// knowing that topology doesn't need to be maintained (i.e. unwiring all
690  /// vertices);
691  virtual void clearForDeletion() {}
692 
693  /// Return the next and previous vertex on the "boundary" of the primitive
694  /// (as understood by the primitive) relative to a given vertex. These are
695  /// needed to maintain half-edge topology attributes.
696  /// They must be implemented for primitives that realize a notion of a
697  /// boundary composed of one or more closed cycles of vertices if we want
698  /// to be able to use hedges to quickly move from such a primitive to
699  /// another sharing an edge with it. A GA_INVALID_OFFSET for prev_vtx or
700  /// next_vtx means that either the primitive doesn't care about hedges,
701  /// the input vertex is not a boundary vertex in the primitive (or not a
702  /// vertex at all), or vtx is at an end of a boundary (e.g. open polys).
704  GA_Offset &prev_vtx,
705  GA_Offset &next_vtx) const
706  { prev_vtx = next_vtx = GA_INVALID_OFFSET; }
707 
708  /// Primitives that implement getAdjacentBoundaryVertices must respond true
709  /// to supportsHedge().
710  virtual bool supportsHedge() const
711  { return false; }
712 
713  /// Release the given vertex. This is equivalent to deleting a vertex
714  /// without modifying its topology attributes. In other words, the primitive
715  /// doesn't use the vertex anymore, but the vertex stays wired to the
716  /// primitive and to the point it was wired to. The intended use is with
717  /// stealVertex methods, so that the same vertex can be aquired by another
718  /// primitive, thus maintaining its offset number and attributes The return
719  /// value is the vertex offset (same as input) if successful and
720  /// GA_INVALID_OFFSET otherwise.
722  { return GA_INVALID_OFFSET; }
723 
724 
725  /// Backward compatible methods for GD library
726  /// Determine whether the primitive is visisble on the interval of the
727  /// parent surface. Partial visiblity should return true as well.
728  /// @return
729  /// - @c 0: Not visible on parent surface
730  /// - @c 1: Full visibility (@b default)
731  /// - @c 2: Partial visibility
732  virtual int isVisible() const;
733 
734  /// A primitive may support any number of secondary details.
735  virtual unsigned getNumSecondaryDetails() const;
736  virtual const GA_Detail *getSecondaryDetail(GA_Index i) const;
737  virtual GA_Detail *getSecondaryDetail(GA_Index i);
738 
739  GA_Index getNumSecondary(GA_Index detail) const;
740  const GA_Primitive *getSecondaryByIndex(GA_Index detail, GA_Index i) const;
741  GA_Primitive *getSecondaryByIndex(GA_Index detail, GA_Index i);
742  const GA_Primitive *getSecondaryByOffset(GA_Index detail,
743  GA_Offset o) const;
744  GA_Primitive *getSecondaryByOffset(GA_Index detail, GA_Offset o);
745 
746  /// @{
747  /// Primitives must provide these methods
748  virtual void reverse() = 0;
749  /// @}
750 
751  /// @{
752  /// Measure the primitive.
753  virtual fpreal calcVolume(const UT_Vector3 &refpt) const
754  { return 0; }
755  virtual fpreal calcArea() const { return 0; }
756  virtual fpreal calcPerimeter() const { return 0; }
757  /// @}
758 
759  /// A trivial vertex list is a uniform ascending list, so
760  /// getFastVertexOffset(i) == getFastVertexOffset(0) + i
762  bool isVertexListTrivial() const { return myVertexList.isTrivial(); }
763  /// A trivial point list is doubly-trivial:
764  /// getPointOffset(i) == getPointOffset(0) + i
765  /// This requires testing every point so is slower than isVertexListTrivial.
766  bool isPointListTrivial() const;
767 
768  /// Calls a functor (e.g. a lambda) for each vertex offset in this
769  /// primitive, in the order they occur in the vertex list.
770  /// This is optimized to only check triviality once.
771  template<typename FUNCTOR>
773  void forEachVertex(FUNCTOR &&functor) const
774  {
775  myVertexList.forEach(functor);
776  }
777 
778  /// Calls a functor (e.g. a lambda) for each point offset in this
779  /// primitive, in the order they occur in the vertex list.
780  /// This is optimized to only check triviality once and only look up
781  /// the vertex-to-point topology attribute once.
782  template<typename FUNCTOR>
784  void forEachPoint(FUNCTOR &&functor) const
785  {
786  const GA_ATITopology *vtx_to_pt = myDetail->getTopology().getPointRef();
787  myVertexList.forEach([vtx_to_pt,&functor](GA_Offset vtx){
788  functor(vtx_to_pt->getLink(vtx));
789  });
790  }
791 
792  bool vertexApply(bool(*apply)(GA_Offset vtx, void *),
793  void *data = nullptr) const
794  {
795  for (GA_Size i = 0, n = getVertexCount(); i < n; ++i)
796  {
797  if (apply(getVertexOffset(i), data))
798  return true;
799  }
800  return false;
801  }
802 
803  /// Stash (deactivate) or unstash (reactivate) the primitive.
804  ///
805  /// Stashing a primitive will set its offset to that specified, typically
806  /// GA_INVALID_OFFSET. Primitives are only stashed as part of clearing a
807  /// detail, so there is no need to explicitly deallocate vertices. It is
808  /// safe to delete a stashed primitive.
809  ///
810  /// Unstashing a primitive will re-register that primitive with its parent
811  /// detail at the specified offset (or a new offset if GA_INVALID_OFFSET).
812  virtual void stashed(bool beingstashed,
814 
815  /// Copy any modified caches from the GPU back to CPU cache.
816  virtual void flushCEWriteCaches() {}
817 
818  /// Copy any modified caches from the GPU to CPU. Then delete the GPU
819  /// cache.
820  virtual void flushCECaches() {}
821 
822  /// Steal the underlying CE buffer from the source.
823  virtual void stealCEBuffers(const GA_Primitive *src) {}
824 
825  static SYS_FORCE_INLINE
828  {
830  if (type_id < GA_PrimCompat::TypeMaskBits)
831  m = (GA_PrimCompat::value_type)1 << type_id;
832  return GA_PrimCompat::TypeMask(m);
833  }
834 
835 protected:
836  void setNumVertices(GA_Size nvertices);
837 
838  /// allocateVertex() will call wireVertex() if the point given is not -1
839  GA_Offset allocateVertex(GA_Offset point=GA_INVALID_OFFSET);
840  void destroyVertex(GA_Offset vertex);
841  void wireVertex(GA_Offset vertex, GA_Offset point);
842 
843  /// Create the topological binding between preallocated vertex and
844  /// primitive.
845  void registerVertex(GA_Offset vertex);
846 
847  /// Report approximate memory usage for myVertexList for subclasses.
850  {
851  return myVertexList.getMemoryUsage(false);
852  }
853 
854  /// This is called by the subclasses to count the
855  /// memory used by myVertexList
856  void countBaseMemory(UT_MemoryCounter &counter) const;
857 
858  /// This is the implementation of this level of copyUnwiredForMerge,
859  /// and enables GA_PrimitiveList to set the vertex list without a
860  /// source primitive.
861  void copyVertexListForMerge(
862  const GA_OffsetListRef &src_vertices, const GA_MergeMap &map);
863 
864  /// @{
865  /// Implementation of intrinsic attributes. See GA_IntrinsicEval
866  /// for further details. See GA_IntrinsicMacros.h for implementation of
867  /// intrinsics.
868  /// @note When implementing support for string intrinsic attributes, please
869  /// ensure to implement for @b all methods (localGetIntrinsicS,
870  /// localGetIntrinsicSA for reading and localSetIntrinsicSA,
871  /// localSetIntrinsicSS for writing). You should do this even if the
872  /// string tuple size is 1.
874  /// @}
875 
876 private:
877 
879  void unstashImpl(GA_Offset offset)
880  {
881  UT_ASSERT_P(myVertexList.size() == 0);
882  myOffset = offset;
883  }
884 
885  friend class GA_PrimitiveList;
886 
887  GA_Detail *myDetail;
888  GA_Offset myOffset;
889 protected:
891 };
892 
896 {
897  return myPrimitiveList.getVertexList(primoff);
898 }
899 
901 GA_Size
903 {
904  return myPrimitiveList.getVertexCount(primoff);
905 }
906 
908 GA_Offset
910 {
911  return myPrimitiveList.getVertexOffset(primoff, i);
912 }
913 
915 int
917 {
918  return myPrimitiveList.getTypeId(primoff);
919 }
920 
922 bool
924 {
925  return myPrimitiveList.getClosedFlag(primoff);
926 }
927 
929 void
931 {
932  myPrimitiveList.setClosedFlag(primoff, closed);
933 }
934 
938 {
939  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
940  const GA_Primitive *const*prim_array = myList;
941  if (!prim_array)
942  {
943  GA_PageNum pagenum = GAgetPageNum(primoff);
944  GA_PageOff pageoff = GAgetPageOff(primoff);
945  auto p = myVertexLists.getPageData(pagenum);
946  UT_ASSERT_COMPILETIME(2*sizeof(*p) == sizeof(GA_OffsetListRef));
947  auto po = reinterpret_cast<const GA_OffsetListRef*>(p);
948  if (myVertexLists.isPageConstant(pagenum))
949  {
950  exint size = po->size();
951  return GA_OffsetListRef(po->trivialStart() + size*pageoff, size, po->getExtraFlag());
952  }
953  else
954  {
955  return po[pageoff];
956  }
957  }
958  else
959  {
960  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
961  return GA_OffsetListRef(prim_array[primoff]->myVertexList);
962  }
963 }
964 
966 void
968 {
969  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
970  GA_Primitive *const*prim_array = myList;
971  if (!prim_array)
972  {
973  UT_ASSERT_P(GAisValid(primoff) && primoff < myVertexLists.size());
974  GA_PageNum pagenum = GAgetPageNum(primoff);
975  GA_PageOff pageoff = GAgetPageOff(primoff);
976  auto po = hardenVertexListPage(pagenum);
977  // NOTE: This does increment the ref count on any non-trivial list,
978  // so it's not a problem if vertices is really a
979  // GA_OffsetList somewhere up the call stack.
980  po[pageoff] = vertices;
981  }
982  else
983  {
984  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
985  prim_array[primoff]->myVertexList = vertices;
986  }
987 }
988 
990 void
992 {
993  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
994  GA_Primitive *const*prim_array = myList;
995  if (!prim_array)
996  {
997  UT_ASSERT_P(GAisValid(primoff) && primoff < myVertexLists.size());
998  GA_PageNum pagenum = GAgetPageNum(primoff);
999  GA_PageOff pageoff = GAgetPageOff(primoff);
1000  auto po = hardenVertexListPage(pagenum);
1001  po[pageoff] = vertices;
1002  }
1003  else
1004  {
1005  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1006  prim_array[primoff]->myVertexList = vertices;
1007  }
1008 }
1009 
1011 void
1013 {
1014  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1015  GA_Primitive *const*prim_array = myList;
1016  if (!prim_array)
1017  {
1018  UT_ASSERT_P(GAisValid(primoff) && primoff < myVertexLists.size());
1019  GA_PageNum pagenum = GAgetPageNum(primoff);
1020  GA_PageOff pageoff = GAgetPageOff(primoff);
1021  auto po = hardenVertexListPage(pagenum);
1022  po[pageoff] = std::move(vertices);
1023  }
1024  else
1025  {
1026  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1027  prim_array[primoff]->myVertexList = std::move(vertices);
1028  }
1029 }
1030 
1032 GA_Size
1034 {
1035  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1036  const GA_Primitive *const*prim_array = myList;
1037  if (!prim_array)
1038  {
1039  GA_PageNum pagenum = GAgetPageNum(primoff);
1040  UT_ASSERT_COMPILETIME(2*sizeof(int64) == sizeof(GA_OffsetList));
1041  auto p = reinterpret_cast<const GA_OffsetList*>(myVertexLists.getPageData(pagenum));
1042  if (!myVertexLists.isPageConstant(pagenum))
1043  {
1044  p += GAgetPageOff(primoff);
1045  }
1046  return p->size();
1047  }
1048  else
1049  {
1050  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1051  return prim_array[primoff]->getVertexCount();
1052  }
1053 }
1054 
1056 GA_Offset
1058 {
1059  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1060  const GA_Primitive *const*prim_array = myList;
1061  if (!prim_array)
1062  {
1063  GA_PageNum pagenum = GAgetPageNum(primoff);
1064  GA_PageOff pageoff = GAgetPageOff(primoff);
1065  UT_ASSERT_COMPILETIME(2*sizeof(int64) == sizeof(GA_OffsetList));
1066  auto p = reinterpret_cast<const GA_OffsetList*>(myVertexLists.getPageData(pagenum));
1067  if (!myVertexLists.isPageConstant(pagenum))
1068  {
1069  return p[pageoff].get(i);
1070  }
1071  return p->trivialStart() + p->size()*pageoff + i;
1072  }
1073  else
1074  {
1075  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1076  return prim_array[primoff]->getVertexOffset(i);
1077  }
1078 }
1079 
1081 int
1083 {
1084  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1085  const GA_Primitive *const*prim_array = myList;
1086  if (!prim_array)
1087  {
1088  return myPrimitiveTypes.get(primoff);
1089  }
1090  else
1091  {
1092  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1093  return prim_array[primoff]->getTypeId().get();
1094  }
1095 }
1096 
1098 bool
1100 {
1101  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1102  const GA_Primitive *const*prim_array = myList;
1103  if (!prim_array)
1104  {
1105  GA_PageNum pagenum = GAgetPageNum(primoff);
1106  auto p = myVertexLists.getPageData(pagenum);
1107  if (!myVertexLists.isPageConstant(pagenum))
1108  {
1109  p += 2*GAgetPageOff(primoff);
1110  }
1111  UT_ASSERT_COMPILETIME(2*sizeof(*p) == sizeof(GA_OffsetList));
1112  return reinterpret_cast<const GA_OffsetList*>(p)->getExtraFlag();
1113  }
1114  else
1115  {
1116  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1117  return prim_array[primoff]->myVertexList.getExtraFlag();
1118  }
1119 }
1120 
1122 void
1124 {
1125  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1126  GA_Primitive *const*prim_array = myList;
1127  if (!prim_array)
1128  {
1129  GA_PageNum pagenum = GAgetPageNum(primoff);
1130  auto p = hardenVertexListPage(pagenum);
1131  GA_PageOff pageoff = GAgetPageOff(primoff);
1132  return p[pageoff].setExtraFlag(closed);
1133  }
1134  else
1135  {
1136  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1137  return prim_array[primoff]->myVertexList.setExtraFlag(closed);
1138  }
1139 }
1140 
1141 #endif
SIM_API const UT_StringHolder vertex
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
Definition: GA_Primitive.h:816
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
virtual void flushCECaches()
Definition: GA_Primitive.h:820
SYS_FORCE_INLINE const GA_IndexMap & getIndexMap() const
Gets the index map for primitives in the detail containing this primitive.
Definition: GA_Primitive.h:156
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
SYS_FORCE_INLINE GA_Offset getPrimitiveVertexOffset(GA_Offset primoff, GA_Size i) const
Definition: GA_Primitive.h:909
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
Definition: GA_Primitive.h:258
SYS_FORCE_INLINE void setClosedFlag(GA_Offset primoff, bool closed)
SYS_FORCE_INLINE GA_Detail & getDetail() const
Definition: GA_Primitive.h:141
virtual void clearForDeletion()
Definition: GA_Primitive.h:691
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3D &pos) const
Definition: GA_Primitive.h:293
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
GA_OffsetList * hardenVertexListPage(GA_PageNum pagenum)
const GA_IndexMap & getPrimitiveMap() const
Definition: GA_Detail.h:746
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Definition: GA_Primitive.h:236
GA_Size GA_PageOff
Definition: GA_Types.h:650
GA_LocalIntrinsic findIntrinsic(const UT_StringRef &nm) const
Definition: GA_Primitive.h:616
virtual fpreal calcPerimeter() const
Definition: GA_Primitive.h:756
SYS_FORCE_INLINE GA_Offset getLink(GA_Offset ai) const
SYS_FORCE_INLINE int getPrimitiveTypeId(GA_Offset primoff) const
Definition: GA_Primitive.h:916
void copyUnwiredForMerge(const GA_Primitive *src, const GA_MergeMap &map)
Definition: GA_Primitive.h:491
SYS_FORCE_INLINE GA_Index getVertexIndex(GA_Size primvertexnum) const
Definition: GA_Primitive.h:250
void
Definition: png.h:1083
bool hasLocalTransform() const
Whether the primitive has a transform associated with it.
Definition: GA_Primitive.h:185
GA_StorageClass
Definition: GA_Types.h:73
GLboolean * data
Definition: glcorearb.h:131
bool getIntrinsicReadOnly(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:631
const GLdouble * v
Definition: glcorearb.h:837
GA_LocalIntrinsic findIntrinsic(GA_GlobalIntrinsic h) const
Definition: GA_Primitive.h:618
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:512
GLsizei const GLfloat * value
Definition: glcorearb.h:824
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
SYS_FORCE_INLINE IDX_T size() const
Definition: UT_PageArray.h:842
bool isOffsetVacant(GA_Offset offset) const
SYS_FORCE_INLINE bool getExtraFlag() const
Synonym for isClosed()
GA_PrimitiveFamilyMask getFamilyMask() const
Definition: GA_Primitive.h:179
virtual ~GA_Primitive()
Definition: GA_Primitive.h:125
The merge map keeps track of information when merging details.
Definition: GA_MergeMap.h:53
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
Definition: GA_Primitive.h:264
int64 exint
Definition: SYS_Types.h:125
SYS_FORCE_INLINE DEST_DATA_T get(IDX_T i, exint component=0) const
Definition: UT_PageArray.h:487
GLdouble s
Definition: glad.h:3009
PUGI__FN void reverse(I begin, I end)
Definition: pugixml.cpp:7458
SYS_FORCE_INLINE const GA_PrimitiveTypeId & getTypeId() const
Definition: GA_Primitive.h:177
Class used to map H9 geometry files to a form used by GA.
Definition: GA_AIFFileH9.h:318
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Definition: GA_Primitive.h:80
Manager to keep track of global handle to name mappings.
#define GA_API
Definition: GA_API.h:14
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
Abstract base class for a range membership query object.
#define GA_NO_OVERRIDE
Definition: GA_Primitive.h:76
GLfloat GLfloat GLfloat v2
Definition: glcorearb.h:818
UT_Function< bool(const GA_Edge &edge)> GA_IterateEdgesFunc
Definition: GA_Primitive.h:73
GA_ListTypeRef< GA_Size, GA_Offset > GA_OffsetListRef
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
Definition: GA_Types.h:655
uint64 value_type
Definition: GA_PrimCompat.h:29
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:236
SYS_FORCE_INLINE int64 getBaseMemoryUsage() const
Report approximate memory usage for myVertexList for subclasses.
Definition: GA_Primitive.h:849
SYS_FORCE_INLINE GA_PageOff GAgetPageOff(GA_Offset v)
Definition: GA_Types.h:669
bool isFamily(unsigned family_mask) const
Definition: GA_Primitive.h:181
GA_PrimitiveFamilyMask
SYS_FORCE_INLINE bool getPrimitiveClosedFlag(GA_Offset primoff) const
Definition: GA_Primitive.h:923
SYS_FORCE_INLINE UT_Vector4D getPos4D(GA_Size i) const
Definition: GA_Primitive.h:302
#define GA_INVALID_OFFSET
Definition: GA_Types.h:687
GA_OffsetList myVertexList
Definition: GA_Primitive.h:890
A range of elements in an index-map.
Definition: GA_Range.h:42
int GA_GlobalIntrinsic
Definition: GA_Types.h:704
SYS_FORCE_INLINE GA_Size getVertexCount(GA_Offset primoff) const
double fpreal64
Definition: SYS_Types.h:201
SYS_FORCE_INLINE UT_Vector3D getPos3D(GA_Size i) const
Definition: GA_Primitive.h:281
GA_Size GA_Offset
Definition: GA_Types.h:646
int GA_LocalIntrinsic
Definition: GA_Types.h:703
const GA_IntrinsicManager & getIntrinsicManager() const
Definition: GA_Primitive.h:607
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Definition: GA_Primitive.h:278
GLdouble n
Definition: glcorearb.h:2008
GLintptr offset
Definition: glcorearb.h:665
Class used to keep track of inheritance of intrinsic attribute evaluation.
SYS_FORCE_INLINE GA_OffsetListRef getVertexList(GA_Offset primoff) const
Definition: GA_Primitive.h:937
virtual GA_PrimCompat::TypeMask getPrimitiveId() const
Definition: GA_Primitive.h:204
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
GA_Range getPointRange(bool harden=false) const
Definition: GA_Primitive.h:323
SYS_FORCE_INLINE GA_OffsetListRef getPrimitiveVertexList(GA_Offset primoff) const
Definition: GA_Primitive.h:895
SYS_FORCE_INLINE GA_PageNum GAgetPageNum(GA_Offset v)
Definition: GA_Types.h:664
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
GA_GlobalIntrinsic findGlobalIntrinsic(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:620
UT_Function< bool(GA_Size, GA_Size)> GA_IterateEdgesByVertexFunc
Definition: GA_Primitive.h:74
Provide a JSON interface to a primitive.
SYS_FORCE_INLINE void forEachPoint(FUNCTOR &&functor) const
Definition: GA_Primitive.h:784
virtual fpreal calcArea() const
Definition: GA_Primitive.h:755
SYS_FORCE_INLINE bool isVertexListTrivial() const
Definition: GA_Primitive.h:762
SYS_FORCE_INLINE UT_Vector4 getPos4(GA_Size i) const
Definition: GA_Primitive.h:299
long long int64
Definition: SYS_Types.h:116
virtual bool supportsHedge() const
Definition: GA_Primitive.h:710
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
#define SYS_DEPRECATED_HDK(__V__)
bool getIntrinsicCollapseSingletons(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:626
std::function< T > UT_Function
Definition: UT_Function.h:37
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
const NotVoidType * getPageData(UT_PageNum pagenum) const
virtual int64 getDeviceMemoryUsage() const
Definition: GA_Primitive.h:213
SYS_FORCE_INLINE GA_Index getPointIndex(GA_Size i) const
Definition: GA_Primitive.h:272
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3 &pos) const
Definition: GA_Primitive.h:290
const char * getIntrinsicName(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:623
SYS_FORCE_INLINE bool getClosedFlag(GA_Offset primoff) const
A list of primitives.
bool vertexApply(bool(*apply)(GA_Offset vtx, void *), void *data=nullptr) const
Definition: GA_Primitive.h:792
SYS_FORCE_INLINE void setPos4(GA_Size i, const UT_Vector4 &pos) const
Definition: GA_Primitive.h:308
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
bool isPointUsed(GA_Offset ptoff) const
Definition: GA_Primitive.h:333
A map of string to various well defined value types.
Definition: UT_Options.h:84
SYS_FORCE_INLINE GA_Index getMapIndex() const
Gets the index of this primitive in the detail containing it.
Definition: GA_Primitive.h:151
const UT_Options * getIntrinsicOptions(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:633
virtual fpreal calcVolume(const UT_Vector3 &refpt) const
Definition: GA_Primitive.h:753
GA_StorageClass getIntrinsicStorage(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:629
virtual void getAdjacentBoundaryVertices(GA_Offset vtx, GA_Offset &prev_vtx, GA_Offset &next_vtx) const
Definition: GA_Primitive.h:703
fpreal64 fpreal
Definition: SYS_Types.h:278
UT_Vector3T< T > getPos3T(GA_Size i) const
Definition: GA_Primitive.h:284
SYS_FORCE_INLINE void setPos4(GA_Size i, const UT_Vector4D &pos) const
Definition: GA_Primitive.h:311
SYS_FORCE_INLINE void forEachVertex(FUNCTOR &&functor) const
Definition: GA_Primitive.h:773
GA_Size GA_PageNum
Definition: GA_Types.h:649
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
Definition: GA_Primitive.h:146
Class used to map the GA attribute into a form for H9 geometry files.
Definition: GA_AIFFileH9.h:262
GLfloat GLfloat v1
Definition: glcorearb.h:817
GLuint GLfloat * val
Definition: glcorearb.h:1608
void(* GA_EdgeApplyFunc)(const GA_Primitive &prim, GA_Offset pt_a, GA_Offset pt_b, void *data)
Definition: GA_Primitive.h:68
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
Definition: GA_Primitive.h:244
virtual void stealCEBuffers(const GA_Primitive *src)
Steal the underlying CE buffer from the source.
Definition: GA_Primitive.h:823
SYS_FORCE_INLINE void setPrimitiveClosedFlag(GA_Offset primoff, bool closed)
Definition: GA_Primitive.h:930
SYS_FORCE_INLINE ToType get(FromType index) const
Get the the value at the index.
Container class for all geometry.
Definition: GA_Detail.h:96
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
SYS_FORCE_INLINE GA_Size getPrimitiveVertexCount(GA_Offset primoff) const
Definition: GA_Primitive.h:902
Definition of a geometric primitive.
bool isPrimary() const
Definition: GA_Primitive.h:169
const char * getTypeName() const
Definition: GA_Primitive.h:133
GA_Range getVertexRange(bool harden=false) const
Get a range of all the vertices accessed by the primitive.
Definition: GA_Primitive.h:315
SYS_FORCE_INLINE void setVertexList(GA_Offset primoff, const GA_OffsetListRef &vertices)
Definition: GA_Primitive.h:967
SYS_FORCE_INLINE GA_Primitive(GA_Detail &detail, GA_Offset offset=GA_INVALID_OFFSET)
Definition: GA_Primitive.h:116
void(* GA_EdgeApplyIndexFunc)(const GA_Primitive &prim, GA_Size v1, GA_Size v2, void *data)
Definition: GA_Primitive.h:70
virtual GA_Offset releaseVertex(GA_Offset vtx)
Definition: GA_Primitive.h:721
virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
Definition: GA_Primitive.h:376
SYS_FORCE_INLINE int getTypeId(GA_Offset primoff) const
Definition: format.h:1821
SYS_FORCE_INLINE FromType size() const
Returns the number of used elements in the list (always <= capacity())
static SYS_FORCE_INLINE GA_PrimCompat::TypeMask primCompatMaskFromTypeId(int type_id)
Definition: GA_Primitive.h:827
GLenum src
Definition: glcorearb.h:1793
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Offset primoff, GA_Size i) const