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