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_NonCopyable.h>
35 #include <UT/UT_VectorTypes.h>
36 #include <SYS/SYS_Inline.h>
37 #include <SYS/SYS_Types.h>
38 
39 #include <functional>
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 
73 using GA_IterateEdgesFunc = std::function<bool(const GA_Edge &edge)>;
74 using GA_IterateEdgesByVertexFunc = std::function<bool(GA_Size, GA_Size)>;
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 
214  /// Count memory usage using a UT_MemoryCounter in order to count
215  /// shared memory correctly.
216  /// NOTE: This should always include sizeof(*this).
217  virtual void countMemory(UT_MemoryCounter &counter) const;
218 
219  /// @{
220  /// This method is called when the vertex index map is being defragmented.
221  /// Since the defragmentation process moves vertex offsets, primitives need
222  /// to update their references with the new values. @code
223  /// new_vtx_offset = defrag.mapOffset(new_vtx_offset);
224  /// myOffsetList.swapOffsetValues(defrag);
225  /// myOffsetMatrix.swapOffsetValues(defrag);
226  /// @endcode
227  virtual void swapVertexOffsets(const GA_Defragment &defrag);
228  /// @}
229 
230  /// Return the number of vertices used by this primitive
233  {
234  return myVertexList.size();
235  }
236 
237  /// Given an vertex number (into the primitive's vertex list), return the
238  /// vertex offset.
240  GA_Offset getVertexOffset(GA_Size primvertexnum) const
241  {
242  UT_ASSERT_P(primvertexnum >= 0 && primvertexnum < myVertexList.size());
243  return myVertexList.get(primvertexnum);
244  }
246  GA_Index getVertexIndex(GA_Size primvertexnum) const
247  {
248  return getDetail().vertexIndex(getVertexOffset(primvertexnum));
249  }
250 
251  /// Given a vertex number (into the primitive's vertex list), return the
252  /// point offset.
255  { return getDetail().vertexPoint(getVertexOffset(i)); }
256 
257  /// Given a vertex number (into the primitive's vertex list), set the
258  /// corresponding point offset.
261  {
262  getDetail().getTopology().wireVertexPoint(getVertexOffset(i), ptoff);
263  }
264 
265  /// Given a vertex number (into the primitive's vertex list), return its
266  /// point index number.
269  { return getDetail().pointIndex(getPointOffset(i)); }
270 
271  /// Given a vertex number (into the primitive's vertex list), return its
272  /// point's position.
275  { return getDetail().getPos3(getPointOffset(i)); }
276 
277  /// Given a vertex number (into the primitive's vertex list),
278  /// move the point to the specified position.
280  void setPos3(GA_Size i, const UT_Vector3 &pos) const
281  { getDetail().setPos3(getPointOffset(i), pos); }
282 
283  /// Given a vertex number (into the primitive's vertex list), return its
284  /// point's position.
287  { return getDetail().getPos4(getPointOffset(i)); }
288 
289  /// Given a vertex number (into the primitive's vertex list),
290  /// move the point to the specified position.
292  void setPos4(GA_Size i, const UT_Vector4 &pos) const
293  { getDetail().setPos4(getPointOffset(i), pos); }
294 
295  /// Get a range of all the vertices accessed by the primitive
296  GA_Range getVertexRange(bool harden=false) const
297  {
298  return GA_Range(getDetail(), getMapOffset(),
300  harden);
301  }
302  /// Get a range of all the points accessed by the primitive. Note, the
303  /// range may visit points multiple times.
304  GA_Range getPointRange(bool harden=false) const
305  {
306  return GA_Range(getDetail(), getMapOffset(),
308  harden);
309  }
310 
311  /// Return whether a point is referenced by a primitive. This simply
312  /// iterates over the vertices, checking if any vertices reference the
313  /// point.
314  bool isPointUsed(GA_Offset ptoff) const
315  {
316  GA_Size nvtx = getVertexCount();
317  for (GA_Size i = 0; i < nvtx; ++i)
318  {
319  if (getPointOffset(i) == ptoff)
320  return true;
321  }
322  return false;
323  }
324 
325  /// Add all points referenced by the primitive to the given group. This
326  /// defaults to iterating over the vertices and adding their referenced
327  /// points.
328  void addPointRefToGroup(GA_PointGroup &grp) const;
329 
330  /// Method to determine if a primitive has an edge (undirected).
331  virtual bool hasEdge(const GA_Edge &edge) const;
332 
333 
334  /// Calls apply for each directed edge in this primitive
335  /// @deprecated Use @c iterateEdges instead.
336  SYS_DEPRECATED_HDK_REPLACE(16.0, iterateEdges)
337  void edgeApply(GA_EdgeApplyFunc apply, void *data = nullptr) const;
338 
339  /// Calls apply for each directed edge in this primitive
340  /// @deprecated Use @c iterateEdgesByVertex instead.
341  SYS_DEPRECATED_HDK_REPLACE(16.0, iterateEdgesByVertex)
342  void edgeApplyIndex(GA_EdgeApplyIndexFunc apply, void *data = nullptr) const;
343 
344  /// Calls @c apply_func for each directed edge on the primitive.
345  /// If the @c apply_func function returns @c false, then the
346  /// traversal will be stopped.
347  virtual void iterateEdges(GA_IterateEdgesFunc apply_func) const
348  {
349  // Default implementation does nothing.
350  // Re-implemented by relevant primitives.
351  }
352 
353  /// Calls @c apply_func for each directed edge on the primitive,
354  /// passing in the @c GA_Size primitive vertex index for each point on the
355  /// edge. If the @c apply_func function returns @c false, then the
356  /// traversal will be stopped.
357  virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
358  {
359  // Default implementation does nothing.
360  // Re-implemented by relevant primitives.
361  }
362 
363  /// Calls edgeApplyIndex to find the vertices within this primitive,
364  /// corresponding with the first undirected edge between ptoff0 and ptoff1.
365  /// If the edge is not in this primitive, vtx0 and vtx1 will not be
366  /// written-to, and the function will return false.
367  /// When written, vtx0->vtx1 will always be the direction the edge
368  /// appears in this primitive, which may be *opposite* ptoff0->ptoff1.
369  bool findEdgePoints(GA_Offset ptoff0, GA_Offset ptoff1,
370  GA_Size &vtx0, GA_Size &vtx1) const;
371 
372  /// The return status of @c dereferencePoint()
373  /// - GA_DEREFERENCE_FAIL @n
374  /// The primitive cannot detach itself from the points and thus the
375  /// points cannot be deleted. It's possible that the primitive may be
376  /// destroyed in this case if the user specified this behaviour (see
377  /// GA_Detail::GA_DestroyPointMode).
378  /// - GA_DEREFERENCE_OK @n
379  /// The primitive has detached the points and is still valid.
380  /// - GA_DEREFERENCE_DEGENERATE @n
381  /// The primitive has detached the points but is now degenerate.
382  /// - GA_DEREFERENCE_DESTROY @n
383  /// The primitive has detached the points and should now be destroyed.
385  {
390  };
391  /// Before points are deleted, all primitives referencing the points will
392  /// be notified using @c dereferencePoint or @c dereferencePoints. These
393  /// methods should return the appropriate DeferefenceStatus.
394  /// @example
395  /// A quadric primitive will return
396  /// - GA_DEREFERENCE_OK @n
397  /// If it's point is not in the point group
398  /// - GA_DEREFERENCE_DESTROY @n
399  /// If it destroyed its vertex
400  /// A hull primitive will return
401  /// - GA_DEREFERENCE_OK @n
402  /// If a full row or column was dereferenced
403  /// - GA_DEREFERENCE_DEGENERATE @n
404  /// If a full row/column was dereferenced, leaving a degenerate
405  /// primitive.
406  /// - GA_DEREFERENCE_FAIL @n
407  /// If a single point from within the hull cannot be dereferenced
408  /// The @c dry_run parameter will prevent the point from actually being
409  /// detached.
410  virtual GA_DereferenceStatus dereferencePoint(GA_Offset point,
411  bool dry_run=false) = 0;
412  virtual GA_DereferenceStatus dereferencePoints(
413  const GA_RangeMemberQuery &pt_q,
414  bool dry_run=false) = 0;
415 
416  /// @{
417  /// Enlarge a bounding box by the bounding box of the primitive. A
418  /// return value of false indicates an error in the operation, most
419  /// likely an invalid P. By default, these methods simply enlarge the
420  /// bounding box based on the vertices.
421  virtual bool enlargeBoundingBox(UT_BoundingRect &b,
422  const GA_Attribute *P) const;
423  virtual bool enlargeBoundingBox(UT_BoundingBox &b,
424  const GA_Attribute *P) const;
425  /// @}
426  /// Enlarge a bounding sphere to encompass the primitive. A return value
427  /// of false indicates an error in the operation, most likely an invalid
428  /// P. By default, this method simply enlarges the bounding box based on
429  /// the vertices.
430  virtual bool enlargeBoundingSphere(UT_BoundingSphere &b,
431  const GA_Attribute *P) const;
432 
433  /// Enlarge a point bounding box for implicit primitive bounds. If a
434  /// primitive (such as a sphere) has a bounding box larger than its point
435  /// hull, then it should implement this method. Otherwise, it can rely on
436  /// the default behaviour.
437  ///
438  /// NOTE: If you make a custom primitive type whose bounding box may be
439  /// larger than the bounding box of the points referenced by
440  /// vertices of the primitive, you must override this function
441  /// in order for the detail's bounding box to be correctly computed.
442  /// It does not suffice to override GEO_Primitive::getBBox(), since
443  /// GA_Detail::computeQuickBounds will find the point bounding box
444  /// of the entire detail, and then call enlargePointBounds
445  /// on all primitives except polygons, tetrahedra, polysoups,
446  /// and other primitive types that are known in advance to not
447  /// exceed their point bounding boxes.
448  virtual void enlargePointBounds(UT_BoundingBox &box) const;
449 
450  /// Is the primitive degenerate
451  virtual bool isDegenerate() const = 0;
452 
453  /// Copy the specified primitive as part of the merge. The source
454  /// primitive will be of the same type.
455  ///
456  /// Since the vertex offsets will change for the merged geometry, the map
457  /// should be used to lookup the new vertex offsets. For example
458  /// @code
459  /// map.mapDestFromSource( GA_ATTRIB_VERTEX, source_vertex );
460  /// @endcode
461  ///
462  /// @see GA_MergeMap
464  const GA_Primitive *src, const GA_MergeMap &map)
465  {
466  UT_ASSERT(src != this);
467  copyVertexListForMerge(src->myVertexList, map);
468  copySubclassData(src);
469  }
470 
471  /// Copy all subclass data from source to this.
472  ///
473  /// The vertex lists of source and this must already be equivalent
474  /// in some manner, though possibly referring to different vertices.
475  ///
476  /// If some subclass data is dependent on the vertex list contents,
477  /// (such as GEO_PrimPolySoup::myPolygonVertexList),
478  /// it should be mapped based on the correspondence between the two.
479  /// GEO_PrimPolySoup is currently the only primitive type with this
480  /// sort of dependence, so it's probably best not to add more.
481  ///
482  /// NOTE: This must be safe to call on different primitives
483  /// in parallel at the same time.
484  virtual void copySubclassData(const GA_Primitive *source)
485  {
486  UT_ASSERT_P(source != nullptr);
487  UT_ASSERT_P(source != this);
488  UT_ASSERT_P(source->getTypeId() == getTypeId());
489  UT_ASSERT_P(myVertexList.size() == source->myVertexList.size());
490  UT_ASSERT_P(myVertexList.getExtraFlag() == source->myVertexList.getExtraFlag());
491  };
492 
493  /// This method returns the JSON interface for saving/loading the primitive
494  /// If the method returns a NULL pointer, then the primitive will @b not
495  /// be saved to geometry files (and thus cannot be loaded).
496  virtual const GA_PrimitiveJSON *getJSON() const = 0;
497 
498  /// Some primitives can have common/shared data between different
499  /// instances of the primitives. This method is invoked during the save
500  /// process to save data. The method requires you to save two objects
501  /// sequentially (the data is stored in a list) for each shared key:
502  /// - The primitive typedef name. This is used at load time to find the
503  /// definition which knows how to load the data.
504  /// - The data required to represent the shared object. This is
505  /// typically a list or map containing the type of data, the key value
506  /// (used for loading) and the actual object data.
507  ///
508  /// If there are multiple shared data pointers, the array can continue with name/value pairs.
509  ///
510  /// For example, you might have something like: @code
511  /// const char *key = makeKeyForSharedPtr(ptr);
512  /// bool ok = true;
513  /// if (!save.hasSavedSharedData(key))
514  /// {
515  /// save.setSavedSharedData(key); // Flag this data as saved
516  /// ok = ok && w.jsonStringToken(getTypeName());
517  /// ok = ok && w.jsonBeginArray();
518  /// ok = ok && w.jsonStringToken("datatype");
519  /// ok = ok && w.jsonStringToken(key);
520  /// ok = ok && saveSharedData(ptr);
521  /// ok = ok && w.jsonEndArray();
522  /// }
523  /// return ok;
524  /// @endcode
525  /// Then in the primitive JSON, you'd likely want to have two fields, one
526  /// for the shared data pointer, the other for an expanded version of the
527  /// data. The @c shouldSaveField() method would be something like: @code
528  /// if (index == SHARED_DATA_KEY)
529  /// return save.hasSavedSharedData(key);
530  /// if (index == EXPANDED_DATA_KEY)
531  /// return !save.hasSavedSharedData(key);
532  /// @endcode
533  ///
534  /// Then the saveField() method of the primitive JSON would look something
535  /// like: @code
536  /// switch (index)
537  /// {
538  /// case SHARED_DATA_KEY:
539  /// UT_ASSERT(save.hasSaveSharedData(key));
540  /// return w.jsonString(key);
541  /// case EXPANDED_DATA_KEY:
542  /// UT_ASSERT(!save.hasSaveSharedData(key));
543  /// return saveSharedData(ptr);
544  /// }
545  /// @endcode
546  ///
547  /// During the loading process, you can just get the shared data from the
548  /// load map. @code
549  /// MySharedDataContainer *data;
550  /// data = load.sharedLoadDataAs<MySharedDataContainer>(key);
551  /// if (data)
552  /// setSharedPointer(data->getSharedData();
553  /// else
554  /// return false;
555  /// @endcode
556  virtual bool saveSharedLoadData(
557  UT_JSONWriter &w,
558  GA_SaveMap &save,
559  GA_GeometryIndex *geo_index) const;
560 
561  virtual bool registerSharedLoadData(
562  int load_data_type,
564 
565  virtual bool loadH9(UT_IStream &is,
566  const UT_Array<GA_AttribLoadDataH9> &prim_attribs,
567  const UT_Array<GA_AttribLoadDataH9> &vtx_attribs);
568  virtual bool saveH9(std::ostream &os, bool binary,
569  const UT_Array<GA_AttribSaveDataH9> &prim_attribs,
570  const UT_Array<GA_AttribSaveDataH9> &vtx_attribs)
571  const;
572 
573  // ------------ Intrinsic interface ------------
574  /// Get the intrinsic manager for primitive intrinsics.
575  /// All primitives have at least the following intrinsics:
576  /// - "string typename" @n The type name of the primitive
577  /// - "int typeid" @n The type id (may change per run)
578  /// - "int vertexcount" @n The number of vertices in the primitive
580  { return getTypeDef().getIntrinsicManager(); }
581 
582  /// @{
583  /// Query properties of the primitive intrinsic.
584  /// Note that the tuple size calls the virtual method since the tuple size
585  /// may be dynamic (i.e. basis knot vector)
586  GA_LocalIntrinsic findIntrinsic(const char *nm) const
587  { return getIntrinsicManager().getLocalHandle(nm); }
589  { return getIntrinsicManager().getLocalHandle(h); }
591  { return getIntrinsicManager().getGlobalHandle(h); }
592 
594  { return getIntrinsicManager().getName(h); }
595  GA_Size getIntrinsicTupleSize(GA_LocalIntrinsic h) const;
597  { return getIntrinsicManager().getStorage(h); }
599  { return getIntrinsicManager().getReadOnly(h); }
601  { return getIntrinsicManager().getOptions(h); }
602  /// @}
603 
604  /// @{
605  /// Get the value of a primitive intrinsic.
606  /// These methods return the number of items retrieved.
607  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_String &val) const;
608  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_StringArray &val) const;
609  GA_Size getIntrinsic(GA_LocalIntrinsic h, UT_OptionsHolder &val) const;
611  GA_Size getIntrinsic(GA_LocalIntrinsic h, int64 *v, GA_Size size) const;
612  GA_Size getIntrinsic(GA_LocalIntrinsic h, fpreal64 *v, GA_Size sz) const;
613  /// @}
614 
615  /// @{
616  /// Get the value of a primitive intrinsic.
617  /// Returns false if not the right type or not found.
618  /// Always will clear out the provided value.
619  bool getIntrinsic(GA_LocalIntrinsic h, float &v) const;
620  bool getIntrinsic(GA_LocalIntrinsic h, int &v) const;
621  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector2 &v) const;
622  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector3 &v) const;
623  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector4 &v) const;
624  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix2 &v) const;
625  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix3 &v) const;
626  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix4 &v) const;
627  bool getIntrinsic(GA_LocalIntrinsic h, double &v) const;
628  bool getIntrinsic(GA_LocalIntrinsic h, int64 &v) const;
629  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector2D &v) const;
630  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector3D &v) const;
631  bool getIntrinsic(GA_LocalIntrinsic h, UT_Vector4D &v) const;
632  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix2D &v) const;
633  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix3D &v) const;
634  bool getIntrinsic(GA_LocalIntrinsic h, UT_Matrix4D &v) const;
635 
636  /// @}
637 
638  /// @{
639  /// Set intrinsic attributes. This will fail if the intrinsic is read-only.
640  /// These methods return the number of items set.
641  GA_Size setIntrinsic(GA_LocalIntrinsic h, const char *value);
642  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_StringArray &value);
643  GA_Size setIntrinsic(GA_LocalIntrinsic h, const char **val, GA_Size s);
644  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_OptionsHolder &value);
646  GA_Size setIntrinsic(GA_LocalIntrinsic h, const UT_OptionsHolder *value, GA_Size s);
647  GA_Size setIntrinsic(GA_LocalIntrinsic h, const int64 val);
648  GA_Size setIntrinsic(GA_LocalIntrinsic h, const fpreal64 val);
649  GA_Size setIntrinsic(GA_LocalIntrinsic h, const int64 *val, GA_Size sz);
650  GA_Size setIntrinsic(GA_LocalIntrinsic h, const fpreal64 *v, GA_Size sz);
651  /// @}
652 
653  /// Private interface
654  /// The clearForDeletion() method is called just prior to the detail being
655  /// cleared out. This allows the primitive to simplify its data structures,
656  /// knowing that topology doesn't need to be maintained (i.e. unwiring all
657  /// vertices);
658  virtual void clearForDeletion() {}
659 
660  /// Return the next and previous vertex on the "boundary" of the primitive
661  /// (as understood by the primitive) relative to a given vertex. These are
662  /// needed to maintain half-edge topology attributes.
663  /// They must be implemented for primitives that realize a notion of a
664  /// boundary composed of one or more closed cycles of vertices if we want
665  /// to be able to use hedges to quickly move from such a primitive to
666  /// another sharing an edge with it. A GA_INVALID_OFFSET for prev_vtx or
667  /// next_vtx means that either the primitive doesn't care about hedges,
668  /// the input vertex is not a boundary vertex in the primitive (or not a
669  /// vertex at all), or vtx is at an end of a boundary (e.g. open polys).
671  GA_Offset &prev_vtx,
672  GA_Offset &next_vtx) const
673  { prev_vtx = next_vtx = GA_INVALID_OFFSET; }
674 
675  /// Primitives that implement getAdjacentBoundaryVertices must respond true
676  /// to supportsHedge().
677  virtual bool supportsHedge() const
678  { return false; }
679 
680  /// Release the given vertex. This is equivalent to deleting a vertex
681  /// without modifying its topology attributes. In other words, the primitive
682  /// doesn't use the vertex anymore, but the vertex stays wired to the
683  /// primitive and to the point it was wired to. The intended use is with
684  /// stealVertex methods, so that the same vertex can be aquired by another
685  /// primitive, thus maintaining its offset number and attributes The return
686  /// value is the vertex offset (same as input) if successful and
687  /// GA_INVALID_OFFSET otherwise.
689  { return GA_INVALID_OFFSET; }
690 
691 
692  /// Backward compatible methods for GD library
693  /// Determine whether the primitive is visisble on the interval of the
694  /// parent surface. Partial visiblity should return true as well.
695  /// @return
696  /// - @c 0: Not visible on parent surface
697  /// - @c 1: Full visibility (@b default)
698  /// - @c 2: Partial visibility
699  virtual int isVisible() const;
700 
701  /// A primitive may support any number of secondary details.
702  virtual unsigned getNumSecondaryDetails() const;
703  virtual const GA_Detail *getSecondaryDetail(GA_Index i) const;
704  virtual GA_Detail *getSecondaryDetail(GA_Index i);
705 
706  GA_Index getNumSecondary(GA_Index detail) const;
707  const GA_Primitive *getSecondaryByIndex(GA_Index detail, GA_Index i) const;
708  GA_Primitive *getSecondaryByIndex(GA_Index detail, GA_Index i);
709  const GA_Primitive *getSecondaryByOffset(GA_Index detail,
710  GA_Offset o) const;
711  GA_Primitive *getSecondaryByOffset(GA_Index detail, GA_Offset o);
712 
713  /// @{
714  /// Primitives must provide these methods
715  virtual void reverse() = 0;
716  /// @}
717 
718  /// @{
719  /// Measure the primitive.
720  virtual fpreal calcVolume(const UT_Vector3 &refpt) const
721  { return 0; }
722  virtual fpreal calcArea() const { return 0; }
723  virtual fpreal calcPerimeter() const { return 0; }
724  /// @}
725 
726  /// A trivial vertex list is a uniform ascending list, so
727  /// getFastVertexOffset(i) == getFastVertexOffset(0) + i
729  bool isVertexListTrivial() const { return myVertexList.isTrivial(); }
730  /// A trivial point list is doubly-trivial:
731  /// getPointOffset(i) == getPointOffset(0) + i
732  /// This requires testing every point so is slower than isVertexListTrivial.
733  bool isPointListTrivial() const;
734 
735  /// Calls a functor (e.g. a lambda) for each vertex offset in this
736  /// primitive, in the order they occur in the vertex list.
737  /// This is optimized to only check triviality once.
738  template<typename FUNCTOR>
740  void forEachVertex(FUNCTOR &&functor) const
741  {
742  myVertexList.forEach(functor);
743  }
744 
745  /// Calls a functor (e.g. a lambda) for each point offset in this
746  /// primitive, in the order they occur in the vertex list.
747  /// This is optimized to only check triviality once and only look up
748  /// the vertex-to-point topology attribute once.
749  template<typename FUNCTOR>
751  void forEachPoint(FUNCTOR &&functor) const
752  {
753  const GA_ATITopology *vtx_to_pt = myDetail->getTopology().getPointRef();
754  myVertexList.forEach([vtx_to_pt,&functor](GA_Offset vtx){
755  functor(vtx_to_pt->getLink(vtx));
756  });
757  }
758 
759  bool vertexApply(bool(*apply)(GA_Offset vtx, void *),
760  void *data = nullptr) const
761  {
762  for (GA_Size i = 0, n = getVertexCount(); i < n; ++i)
763  {
764  if (apply(getVertexOffset(i), data))
765  return true;
766  }
767  return false;
768  }
769 
770  /// Stash (deactivate) or unstash (reactivate) the primitive.
771  ///
772  /// Stashing a primitive will set its offset to that specified, typically
773  /// GA_INVALID_OFFSET. Primitives are only stashed as part of clearing a
774  /// detail, so there is no need to explicitly deallocate vertices. It is
775  /// safe to delete a stashed primitive.
776  ///
777  /// Unstashing a primitive will re-register that primitive with its parent
778  /// detail at the specified offset (or a new offset if GA_INVALID_OFFSET).
779  virtual void stashed(bool beingstashed,
781 
782  /// Copy any modified caches from the GPU back to CPU cache.
783  virtual void flushCEWriteCaches() {}
784 
785  /// Copy any modified caches from the GPU to CPU. Then delete the GPU
786  /// cache.
787  virtual void flushCECaches() {}
788 
789  static SYS_FORCE_INLINE
792  {
794  if (type_id < GA_PrimCompat::TypeMaskBits)
795  m = (GA_PrimCompat::value_type)1 << type_id;
796  return GA_PrimCompat::TypeMask(m);
797  }
798 
799 protected:
800  void setNumVertices(GA_Size nvertices);
801 
802  /// allocateVertex() will call wireVertex() if the point given is not -1
803  GA_Offset allocateVertex(GA_Offset point=GA_INVALID_OFFSET);
804  void destroyVertex(GA_Offset vertex);
805  void wireVertex(GA_Offset vertex, GA_Offset point);
806 
807  /// Create the topological binding between preallocated vertex and
808  /// primitive.
809  void registerVertex(GA_Offset vertex);
810 
811  /// Report approximate memory usage for myVertexList for subclasses.
814  {
815  return myVertexList.getMemoryUsage(false);
816  }
817 
818  /// This is called by the subclasses to count the
819  /// memory used by myVertexList
820  void countBaseMemory(UT_MemoryCounter &counter) const;
821 
822  /// This is the implementation of this level of copyUnwiredForMerge,
823  /// and enables GA_PrimitiveList to set the vertex list without a
824  /// source primitive.
825  void copyVertexListForMerge(
826  const GA_OffsetListRef &src_vertices, const GA_MergeMap &map);
827 
828  /// @{
829  /// Implementation of intrinsic attributes. See GA_IntrinsicEval
830  /// for further details. See GA_IntrinsicMacros.h for implementation of
831  /// intrinsics.
832  /// @note When implementing support for string intrinsic attributes, please
833  /// ensure to implement for @b all methods (localGetIntrinsicS,
834  /// localGetIntrinsicSA for reading and localSetIntrinsicSA,
835  /// localSetIntrinsicSS for writing). You should do this even if the
836  /// string tuple size is 1.
838  /// @}
839 
840 private:
841 
843  void unstashImpl(GA_Offset offset)
844  {
845  UT_ASSERT_P(myVertexList.size() == 0);
846  myOffset = offset;
847  }
848 
849  friend class GA_PrimitiveList;
850 
851  GA_Detail *myDetail;
852  GA_Offset myOffset;
853 protected:
855 };
856 
860 {
861  return myPrimitiveList.getVertexList(primoff);
862 }
863 
865 GA_Size
867 {
868  return myPrimitiveList.getVertexCount(primoff);
869 }
870 
872 GA_Offset
874 {
875  return myPrimitiveList.getVertexOffset(primoff, i);
876 }
877 
879 int
881 {
882  return myPrimitiveList.getTypeId(primoff);
883 }
884 
886 bool
888 {
889  return myPrimitiveList.getClosedFlag(primoff);
890 }
891 
893 void
895 {
896  myPrimitiveList.setClosedFlag(primoff, closed);
897 }
898 
899 #if COMPRESSED_PRIM_LIST
903 {
904  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
905  const GA_Primitive *const*prim_array = myList;
906  if (!prim_array)
907  {
908  GA_PageNum pagenum = GAgetPageNum(primoff);
909  GA_PageOff pageoff = GAgetPageOff(primoff);
910  auto p = myVertexLists.getPageData(pagenum);
911  UT_ASSERT_COMPILETIME(2*sizeof(*p) == sizeof(GA_OffsetListRef));
912  auto po = reinterpret_cast<const GA_OffsetListRef*>(p);
913  if (myVertexLists.isPageConstant(pagenum))
914  {
915  exint size = po->size();
916  return GA_OffsetListRef(po->trivialStart() + size*pageoff, size, po->getExtraFlag());
917  }
918  else
919  {
920  return po[pageoff];
921  }
922  }
923  else
924  {
925  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
926  return GA_OffsetListRef(prim_array[primoff]->myVertexList);
927  }
928 }
929 
931 void
933 {
934  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
935  GA_Primitive *const*prim_array = myList;
936  if (!prim_array)
937  {
938  UT_ASSERT_P(GAisValid(primoff) && primoff < myVertexLists.size());
939  GA_PageNum pagenum = GAgetPageNum(primoff);
940  GA_PageOff pageoff = GAgetPageOff(primoff);
941  auto po = hardenVertexListPage(pagenum);
942  // NOTE: This does increment the ref count on any non-trivial list,
943  // so it's not a problem if vertices is really a
944  // GA_OffsetList somewhere up the call stack.
945  po[pageoff] = vertices;
946  }
947  else
948  {
949  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
950  prim_array[primoff]->myVertexList = vertices;
951  }
952 }
953 
955 void
957 {
958  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
959  GA_Primitive *const*prim_array = myList;
960  if (!prim_array)
961  {
962  UT_ASSERT_P(GAisValid(primoff) && primoff < myVertexLists.size());
963  GA_PageNum pagenum = GAgetPageNum(primoff);
964  GA_PageOff pageoff = GAgetPageOff(primoff);
965  auto po = hardenVertexListPage(pagenum);
966  po[pageoff] = vertices;
967  }
968  else
969  {
970  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
971  prim_array[primoff]->myVertexList = vertices;
972  }
973 }
974 
976 void
978 {
979  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
980  GA_Primitive *const*prim_array = myList;
981  if (!prim_array)
982  {
983  UT_ASSERT_P(GAisValid(primoff) && primoff < myVertexLists.size());
984  GA_PageNum pagenum = GAgetPageNum(primoff);
985  GA_PageOff pageoff = GAgetPageOff(primoff);
986  auto po = hardenVertexListPage(pagenum);
987  po[pageoff] = std::move(vertices);
988  }
989  else
990  {
991  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
992  prim_array[primoff]->myVertexList = std::move(vertices);
993  }
994 }
995 
997 GA_Size
999 {
1000  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1001  const GA_Primitive *const*prim_array = myList;
1002  if (!prim_array)
1003  {
1004  GA_PageNum pagenum = GAgetPageNum(primoff);
1005  UT_ASSERT_COMPILETIME(2*sizeof(int64) == sizeof(GA_OffsetList));
1006  auto p = reinterpret_cast<const GA_OffsetList*>(myVertexLists.getPageData(pagenum));
1007  if (!myVertexLists.isPageConstant(pagenum))
1008  {
1009  p += GAgetPageOff(primoff);
1010  }
1011  return p->size();
1012  }
1013  else
1014  {
1015  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1016  return prim_array[primoff]->getVertexCount();
1017  }
1018 }
1019 
1021 GA_Offset
1023 {
1024  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1025  const GA_Primitive *const*prim_array = myList;
1026  if (!prim_array)
1027  {
1028  GA_PageNum pagenum = GAgetPageNum(primoff);
1029  GA_PageOff pageoff = GAgetPageOff(primoff);
1030  UT_ASSERT_COMPILETIME(2*sizeof(int64) == sizeof(GA_OffsetList));
1031  auto p = reinterpret_cast<const GA_OffsetList*>(myVertexLists.getPageData(pagenum));
1032  if (!myVertexLists.isPageConstant(pagenum))
1033  {
1034  return p[pageoff].get(i);
1035  }
1036  return p->trivialStart() + p->size()*pageoff + i;
1037  }
1038  else
1039  {
1040  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1041  return prim_array[primoff]->getVertexOffset(i);
1042  }
1043 }
1044 
1046 int
1048 {
1049  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1050  const GA_Primitive *const*prim_array = myList;
1051  if (!prim_array)
1052  {
1053  return myPrimitiveTypes.get(primoff);
1054  }
1055  else
1056  {
1057  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1058  return prim_array[primoff]->getTypeId().get();
1059  }
1060 }
1061 
1063 bool
1065 {
1066  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1067  const GA_Primitive *const*prim_array = myList;
1068  if (!prim_array)
1069  {
1070  GA_PageNum pagenum = GAgetPageNum(primoff);
1071  auto p = myVertexLists.getPageData(pagenum);
1072  if (!myVertexLists.isPageConstant(pagenum))
1073  {
1074  p += 2*GAgetPageOff(primoff);
1075  }
1076  UT_ASSERT_COMPILETIME(2*sizeof(*p) == sizeof(GA_OffsetList));
1077  return reinterpret_cast<const GA_OffsetList*>(p)->getExtraFlag();
1078  }
1079  else
1080  {
1081  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1082  return prim_array[primoff]->myVertexList.getExtraFlag();
1083  }
1084 }
1085 
1087 void
1089 {
1090  UT_ASSERT_P(!myDetail.getPrimitiveMap().isOffsetVacant(primoff));
1091  GA_Primitive *const*prim_array = myList;
1092  if (!prim_array)
1093  {
1094  GA_PageNum pagenum = GAgetPageNum(primoff);
1095  auto p = hardenVertexListPage(pagenum);
1096  GA_PageOff pageoff = GAgetPageOff(primoff);
1097  return p[pageoff].setExtraFlag(closed);
1098  }
1099  else
1100  {
1101  UT_ASSERT_P(GAisValid(primoff) && primoff < GA_Offset(getMyListSize()));
1102  return prim_array[primoff]->myVertexList.setExtraFlag(closed);
1103  }
1104 }
1105 #else
1109 {
1110  return GA_OffsetListRef(myList[off]->myVertexList);
1111 }
1112 
1114 GA_Size
1116 {
1117  return myList[off]->getVertexCount();
1118 }
1119 
1121 GA_Offset
1123 {
1124  return myList[primoff]->getVertexOffset(i);
1125 }
1126 
1128 int
1130 {
1131  return myList[off]->getTypeId().get();
1132 }
1133 
1135 void
1137 {
1138  list = myList[off]->myVertexList;
1139 }
1140 
1142 bool
1144 {
1145  return myList[off]->myVertexList.getExtraFlag();
1146 }
1147 
1149 void
1150 GA_PrimitiveList::setClosedFlag(GA_Offset primoff, bool closed)
1151 {
1152  return myList[primoff]->myVertexList.setExtraFlag(closed);
1153 }
1154 #endif
1155 
1156 #endif
GLdouble s
Definition: glew.h:1390
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
Definition: GA_Primitive.h:783
A class to manage an ordered array which has fixed offset handles.
Definition: GA_IndexMap.h:63
virtual void flushCECaches()
Definition: GA_Primitive.h:787
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:196
SYS_FORCE_INLINE GA_Offset getPrimitiveVertexOffset(GA_Offset primoff, GA_Size i) const
Definition: GA_Primitive.h:873
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
Definition: GA_Primitive.h:254
SYS_FORCE_INLINE void setClosedFlag(GA_Offset primoff, bool closed)
GA_LocalIntrinsic findIntrinsic(const char *nm) const
Definition: GA_Primitive.h:586
GLsizeiptr size
Definition: glew.h:1681
GLenum src
Definition: glew.h:2410
SYS_FORCE_INLINE GA_Detail & getDetail() const
Definition: GA_Primitive.h:141
virtual void clearForDeletion()
Definition: GA_Primitive.h:658
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:686
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Definition: GA_Primitive.h:232
GA_Size GA_PageOff
Definition: GA_Types.h:643
virtual fpreal calcPerimeter() const
Definition: GA_Primitive.h:723
SYS_FORCE_INLINE GA_Offset getLink(GA_Offset ai) const
SYS_FORCE_INLINE int getPrimitiveTypeId(GA_Offset primoff) const
Definition: GA_Primitive.h:880
void copyUnwiredForMerge(const GA_Primitive *src, const GA_MergeMap &map)
Definition: GA_Primitive.h:463
SYS_FORCE_INLINE GA_Index getVertexIndex(GA_Size primvertexnum) const
Definition: GA_Primitive.h:246
bool hasLocalTransform() const
Whether the primitive has a transform associated with it.
Definition: GA_Primitive.h:185
GA_StorageClass
Definition: GA_Types.h:71
bool getIntrinsicReadOnly(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:598
GA_LocalIntrinsic findIntrinsic(GA_GlobalIntrinsic h) const
Definition: GA_Primitive.h:588
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:484
GLuint const GLfloat * val
Definition: glew.h:2794
bool GAisValid(GA_Size v)
Definition: GA_Types.h:647
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
SYS_FORCE_INLINE IDX_T size() const
Definition: UT_PageArray.h:868
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:260
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:493
void reverse(I begin, I end)
Definition: pugixml.cpp:7190
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
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:317
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Definition: GA_Primitive.h:80
Manager to keep track of global handle to name mappings.
const GLdouble * m
Definition: glew.h:9124
#define GA_API
Definition: GA_API.h:12
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
Abstract base class for a range membership query object.
const GLdouble * v
Definition: glew.h:1391
#define GA_NO_OVERRIDE
Definition: GA_Primitive.h:76
GA_ListTypeRef< GA_Size, GA_Offset > GA_OffsetListRef
virtual int64 getMemoryUsage() const
Definition: GA_Primitive.h:209
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
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:233
SYS_FORCE_INLINE int64 getBaseMemoryUsage() const
Report approximate memory usage for myVertexList for subclasses.
Definition: GA_Primitive.h:813
GA_PageOff GAgetPageOff(GA_Offset v)
Definition: GA_Types.h:658
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:887
#define GA_INVALID_OFFSET
Definition: GA_Types.h:676
GA_OffsetList myVertexList
Definition: GA_Primitive.h:854
A range of elements in an index-map.
Definition: GA_Range.h:42
int GA_GlobalIntrinsic
Definition: GA_Types.h:693
SYS_FORCE_INLINE GA_Size getVertexCount(GA_Offset primoff) const
Definition: GA_Primitive.h:998
double fpreal64
Definition: SYS_Types.h:201
GA_Size GA_Offset
Definition: GA_Types.h:639
int GA_LocalIntrinsic
Definition: GA_Types.h:692
const GA_IntrinsicManager & getIntrinsicManager() const
Definition: GA_Primitive.h:579
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Definition: GA_Primitive.h:274
GLfloat GLfloat GLfloat v2
Definition: glew.h:1856
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:902
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
virtual GA_PrimCompat::TypeMask getPrimitiveId() const
Definition: GA_Primitive.h:204
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:134
GA_Range getPointRange(bool harden=false) const
Definition: GA_Primitive.h:304
const GLuint GLenum const void * binary
Definition: glew.h:3502
SYS_FORCE_INLINE GA_OffsetListRef getPrimitiveVertexList(GA_Offset primoff) const
Definition: GA_Primitive.h:859
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
GA_GlobalIntrinsic findGlobalIntrinsic(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:590
Provide a JSON interface to a primitive.
void
Definition: png.h:1083
SYS_FORCE_INLINE void forEachPoint(FUNCTOR &&functor) const
Definition: GA_Primitive.h:751
GLsizei n
Definition: glew.h:4040
virtual fpreal calcArea() const
Definition: GA_Primitive.h:722
SYS_FORCE_INLINE bool isVertexListTrivial() const
Definition: GA_Primitive.h:729
SYS_FORCE_INLINE UT_Vector4 getPos4(GA_Size i) const
Definition: GA_Primitive.h:286
std::function< bool(const GA_Edge &edge)> GA_IterateEdgesFunc
Definition: GA_Primitive.h:73
long long int64
Definition: SYS_Types.h:116
virtual bool supportsHedge() const
Definition: GA_Primitive.h:677
SYS_FORCE_INLINE int get() const
Defragmentation of IndexMaps.
Definition: GA_Defragment.h:45
GLfloat GLfloat GLfloat GLfloat h
Definition: glew.h:8011
#define SYS_DEPRECATED_HDK(__V__)
std::function< bool(GA_Size, GA_Size)> GA_IterateEdgesByVertexFunc
Definition: GA_Primitive.h:74
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:633
const NotVoidType * getPageData(UT_PageNum pagenum) const
SYS_FORCE_INLINE GA_Index getPointIndex(GA_Size i) const
Definition: GA_Primitive.h:268
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3 &pos) const
Definition: GA_Primitive.h:280
const char * getIntrinsicName(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:593
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:759
SYS_FORCE_INLINE void setPos4(GA_Size i, const UT_Vector4 &pos) const
Definition: GA_Primitive.h:292
GLdouble GLdouble GLdouble b
Definition: glew.h:9122
GLfloat GLfloat p
Definition: glew.h:16321
bool isPointUsed(GA_Offset ptoff) const
Definition: GA_Primitive.h:314
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:600
virtual fpreal calcVolume(const UT_Vector3 &refpt) const
Definition: GA_Primitive.h:720
GA_StorageClass getIntrinsicStorage(GA_LocalIntrinsic h) const
Definition: GA_Primitive.h:596
GLuint counter
Definition: glew.h:2740
virtual void getAdjacentBoundaryVertices(GA_Offset vtx, GA_Offset &prev_vtx, GA_Offset &next_vtx) const
Definition: GA_Primitive.h:670
fpreal64 fpreal
Definition: SYS_Types.h:277
SYS_FORCE_INLINE void setExtraFlag(bool v)
Synonym for setClosed(bool)
SYS_FORCE_INLINE void forEachVertex(FUNCTOR &&functor) const
Definition: GA_Primitive.h:740
GA_Size GA_PageNum
Definition: GA_Types.h:642
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:261
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:240
SYS_FORCE_INLINE void setPrimitiveClosedFlag(GA_Offset primoff, bool closed)
Definition: GA_Primitive.h:894
SYS_FORCE_INLINE ToType get(FromType index) const
Get the the value at the index.
Container class for all geometry.
Definition: GA_Detail.h:95
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
SYS_FORCE_INLINE GA_Size getPrimitiveVertexCount(GA_Offset primoff) const
Definition: GA_Primitive.h:866
Definition of a geometric primitive.
#define const
Definition: zconf.h:214
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:296
SYS_FORCE_INLINE void setVertexList(GA_Offset primoff, const GA_OffsetListRef &vertices)
Definition: GA_Primitive.h:932
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
GLsizei const GLfloat * value
Definition: glew.h:1849
virtual GA_Offset releaseVertex(GA_Offset vtx)
Definition: GA_Primitive.h:688
GLfloat GLfloat v1
Definition: glew.h:1852
GLuint GLenum matrix
Definition: glew.h:14742
virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
Definition: GA_Primitive.h:357
SYS_FORCE_INLINE int getTypeId(GA_Offset primoff) const
GA_PageNum GAgetPageNum(GA_Offset v)
Definition: GA_Types.h:654
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:791
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Offset primoff, GA_Size i) const
GLintptr offset
Definition: glew.h:1682