13 #ifndef __GA_Primitive__
14 #define __GA_Primitive__
16 #define GA_PRIMITIVE_VERTEXLIST 1
61 template <
typename T>
class UT_Array;
63 template<
typename T,
bool B>
class GA_EdgeT;
76 #define GA_NO_OVERRIDE
80 #define GA_DECLARE_INTRINSICS(OVERRIDE) \
81 static GA_IntrinsicManager::Registrar \
82 registerIntrinsics(GA_PrimitiveDefinition &); \
83 virtual GA_Size localIntrinsicTupleSize(const GA_IntrinsicEval &) const \
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;
134 {
return getTypeDef().getToken(); }
142 {
return *myDetail; }
152 {
return myDetail->primitiveIndex(myOffset); }
157 {
return myDetail->getPrimitiveMap(); }
161 {
return getMapIndex(); }
170 {
return myDetail->isPrimary(); }
178 {
return getTypeDef().getId(); }
180 {
return getTypeDef().getFamilyMask(); }
182 {
return ((getFamilyMask() & family_mask) != 0); }
186 {
return getTypeDef().hasLocalTransform(); }
190 virtual void getLocalTransform(
UT_Matrix3D &matrix)
const;
196 virtual void getLocalTransform4(
UT_Matrix4D &matrix)
const;
199 virtual void setLocalTransform(
const UT_Matrix3D &matrix);
205 {
return primCompatMaskFromTypeId(getTypeId().
get()); }
211 return sizeof(*this) + getBaseMemoryUsage();
234 return myVertexList.size();
242 UT_ASSERT_P(primvertexnum >= 0 && primvertexnum < myVertexList.size());
243 return myVertexList.get(primvertexnum);
248 return getDetail().vertexIndex(getVertexOffset(primvertexnum));
255 {
return getDetail().vertexPoint(getVertexOffset(i)); }
262 getDetail().setVertexPoint(getVertexOffset(i), ptoff);
269 {
return getDetail().pointIndex(getPointOffset(i)); }
275 {
return getDetail().getPos3(getPointOffset(i)); }
278 {
return getDetail().getPos3D(getPointOffset(i)); }
279 template <
typename T>
281 {
return getDetail().getPos3T<
T>(getPointOffset(i)); }
287 { getDetail().setPos3(getPointOffset(i), pos); }
290 { getDetail().setPos3(getPointOffset(i), pos); }
296 {
return getDetail().getPos4(getPointOffset(i)); }
299 {
return getDetail().getPos4D(getPointOffset(i)); }
305 { getDetail().setPos4(getPointOffset(i), pos); }
308 { getDetail().setPos4(getPointOffset(i), pos); }
313 return GA_Range(getDetail(), getMapOffset(),
321 return GA_Range(getDetail(), getMapOffset(),
331 GA_Size nvtx = getVertexCount();
332 for (
GA_Size i = 0; i < nvtx; ++i)
334 if (getPointOffset(i) == ptoff)
346 virtual bool hasEdge(
const GA_Edge &edge)
const;
425 virtual GA_DereferenceStatus dereferencePoint(
GA_Offset point,
426 bool dry_run=
false) = 0;
427 virtual GA_DereferenceStatus dereferencePoints(
429 bool dry_run=
false) = 0;
446 virtual bool enlargeVisibleBoundingBox(
475 virtual bool isDegenerate()
const = 0;
492 copySubclassData(src);
580 virtual bool saveSharedLoadData(
585 virtual bool registerSharedLoadData(
592 virtual bool saveH9(std::ostream &os,
bool binary,
604 {
return getTypeDef().getIntrinsicManager(); }
613 {
return getIntrinsicManager().getLocalHandle(nm); }
615 {
return getIntrinsicManager().getLocalHandle(h); }
617 {
return getIntrinsicManager().getGlobalHandle(h); }
620 {
return getIntrinsicManager().getName(h); }
624 {
return getIntrinsicManager().getCollapseSingletons(h); }
626 {
return getIntrinsicManager().getStorage(h); }
628 {
return getIntrinsicManager().getReadOnly(h); }
630 {
return getIntrinsicManager().getOptions(h); }
728 virtual int isVisible()
const;
731 virtual unsigned getNumSecondaryDetails()
const;
762 bool isPointListTrivial()
const;
767 template<
typename FUNCTOR>
771 myVertexList.forEach(functor);
778 template<
typename FUNCTOR>
782 const GA_ATITopology *vtx_to_pt = myDetail->getTopology().getPointRef();
783 myVertexList.forEach([vtx_to_pt,&functor](
GA_Offset vtx){
784 functor(vtx_to_pt->
getLink(vtx));
789 void *
data =
nullptr)
const
791 for (
GA_Size i = 0,
n = getVertexCount(); i <
n; ++i)
793 if (apply(getVertexOffset(i),
data))
808 virtual void stashed(
bool beingstashed,
832 void setNumVertices(
GA_Size nvertices);
847 return myVertexList.getMemoryUsage(
false);
857 void copyVertexListForMerge(
914 return myPrimitiveList.
getTypeId(primoff);
976 po[pageoff] = vertices;
981 prim_array[primoff]->myVertexList = vertices;
997 po[pageoff] = vertices;
1002 prim_array[primoff]->myVertexList = vertices;
1018 po[pageoff] = std::move(vertices);
1023 prim_array[primoff]->myVertexList = std::move(vertices);
1047 return prim_array[primoff]->getVertexCount();
1065 return p[pageoff].
get(i);
1067 return p->trivialStart() + p->size()*pageoff + i;
1072 return prim_array[primoff]->getVertexOffset(i);
1084 return myPrimitiveTypes.
get(primoff);
1089 return prim_array[primoff]->getTypeId().get();
1108 return reinterpret_cast<const GA_OffsetList*
>(p)->getExtraFlag();
1113 return prim_array[primoff]->myVertexList.getExtraFlag();
1128 return p[pageoff].setExtraFlag(closed);
1133 return prim_array[primoff]->myVertexList.setExtraFlag(closed);
SIM_API const UT_StringHolder vertex
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
A class to manage an ordered array which has fixed offset handles.
virtual void flushCECaches()
SYS_FORCE_INLINE const GA_IndexMap & getIndexMap() const
Gets the index map for primitives in the detail containing this primitive.
SYS_FORCE_INLINE bool isPageConstant(UT_PageNum pagenum) const
Returns true iff the specified page is constant-compressed.
Definition of a geometry attribute.
SYS_FORCE_INLINE GA_Offset getPrimitiveVertexOffset(GA_Offset primoff, GA_Size i) const
UT_ASSERT_COMPILETIME(BRAY_EVENT_MAXFLAGS<=32)
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
SYS_FORCE_INLINE void setClosedFlag(GA_Offset primoff, bool closed)
SYS_FORCE_INLINE GA_Detail & getDetail() const
virtual void clearForDeletion()
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3D &pos) const
Used to pass options and map offset values during saving.
GA_OffsetList * hardenVertexListPage(GA_PageNum pagenum)
const GA_IndexMap & getPrimitiveMap() const
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
GA_LocalIntrinsic findIntrinsic(const UT_StringRef &nm) const
virtual fpreal calcPerimeter() const
SYS_FORCE_INLINE GA_Offset getLink(GA_Offset ai) const
SYS_FORCE_INLINE int getPrimitiveTypeId(GA_Offset primoff) const
void copyUnwiredForMerge(const GA_Primitive *src, const GA_MergeMap &map)
SYS_FORCE_INLINE GA_Index getVertexIndex(GA_Size primvertexnum) const
bool hasLocalTransform() const
Whether the primitive has a transform associated with it.
bool getIntrinsicReadOnly(GA_LocalIntrinsic h) const
GA_LocalIntrinsic findIntrinsic(GA_GlobalIntrinsic h) const
virtual void copySubclassData(const GA_Primitive *source)
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
const GLuint GLenum const void * binary
SYS_FORCE_INLINE IDX_T size() const
bool isOffsetVacant(GA_Offset offset) const
SYS_FORCE_INLINE bool getExtraFlag() const
Synonym for isClosed()
GA_PrimitiveFamilyMask getFamilyMask() const
The merge map keeps track of information when merging details.
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
SYS_FORCE_INLINE DEST_DATA_T get(IDX_T i, exint component=0) const
void reverse(I begin, I end)
SYS_FORCE_INLINE const GA_PrimitiveTypeId & getTypeId() const
Class used to map H9 geometry files to a form used by GA.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Manager to keep track of global handle to name mappings.
Class which writes ASCII or binary JSON streams.
Abstract base class for a range membership query object.
GLfloat GLfloat GLfloat v2
UT_Function< bool(const GA_Edge &edge)> GA_IterateEdgesFunc
GA_ListTypeRef< GA_Size, GA_Offset > GA_OffsetListRef
virtual int64 getMemoryUsage() const
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
exint GA_Size
Defines the bit width for index and offset types in GA.
SYS_FORCE_INLINE int64 getBaseMemoryUsage() const
Report approximate memory usage for myVertexList for subclasses.
SYS_FORCE_INLINE GA_PageOff GAgetPageOff(GA_Offset v)
bool isFamily(unsigned family_mask) const
SYS_FORCE_INLINE bool getPrimitiveClosedFlag(GA_Offset primoff) const
SYS_FORCE_INLINE UT_Vector4D getPos4D(GA_Size i) const
#define GA_INVALID_OFFSET
GA_OffsetList myVertexList
A range of elements in an index-map.
SYS_FORCE_INLINE GA_Size getVertexCount(GA_Offset primoff) const
SYS_FORCE_INLINE UT_Vector3D getPos3D(GA_Size i) const
const GA_IntrinsicManager & getIntrinsicManager() const
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Class used to keep track of inheritance of intrinsic attribute evaluation.
SYS_FORCE_INLINE GA_OffsetListRef getVertexList(GA_Offset primoff) const
virtual GA_PrimCompat::TypeMask getPrimitiveId() const
GA_Range getPointRange(bool harden=false) const
SYS_FORCE_INLINE GA_OffsetListRef getPrimitiveVertexList(GA_Offset primoff) const
SYS_FORCE_INLINE GA_PageNum GAgetPageNum(GA_Offset v)
GLsizei GLsizei GLchar * source
GA_GlobalIntrinsic findGlobalIntrinsic(GA_LocalIntrinsic h) const
UT_Function< bool(GA_Size, GA_Size)> GA_IterateEdgesByVertexFunc
Provide a JSON interface to a primitive.
SYS_FORCE_INLINE void forEachPoint(FUNCTOR &&functor) const
virtual fpreal calcArea() const
SYS_FORCE_INLINE bool isVertexListTrivial() const
SYS_FORCE_INLINE UT_Vector4 getPos4(GA_Size i) const
virtual bool supportsHedge() const
Defragmentation of IndexMaps.
#define SYS_DEPRECATED_HDK(__V__)
bool getIntrinsicCollapseSingletons(GA_LocalIntrinsic h) const
std::function< T > UT_Function
GLboolean GLboolean GLboolean b
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
const NotVoidType * getPageData(UT_PageNum pagenum) const
SYS_FORCE_INLINE GA_Index getPointIndex(GA_Size i) const
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3 &pos) const
const char * getIntrinsicName(GA_LocalIntrinsic h) const
SYS_FORCE_INLINE bool getClosedFlag(GA_Offset primoff) const
bool vertexApply(bool(*apply)(GA_Offset vtx, void *), void *data=nullptr) const
SYS_FORCE_INLINE void setPos4(GA_Size i, const UT_Vector4 &pos) const
GLfloat GLfloat GLfloat GLfloat h
bool isPointUsed(GA_Offset ptoff) const
A map of string to various well defined value types.
SYS_FORCE_INLINE GA_Index getMapIndex() const
Gets the index of this primitive in the detail containing it.
const UT_Options * getIntrinsicOptions(GA_LocalIntrinsic h) const
virtual fpreal calcVolume(const UT_Vector3 &refpt) const
GA_StorageClass getIntrinsicStorage(GA_LocalIntrinsic h) const
virtual void getAdjacentBoundaryVertices(GA_Offset vtx, GA_Offset &prev_vtx, GA_Offset &next_vtx) const
UT_Vector3T< T > getPos3T(GA_Size i) const
SYS_FORCE_INLINE void setPos4(GA_Size i, const UT_Vector4D &pos) const
SYS_FORCE_INLINE void forEachVertex(FUNCTOR &&functor) const
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
Class used to map the GA attribute into a form for H9 geometry files.
void(* GA_EdgeApplyFunc)(const GA_Primitive &prim, GA_Offset pt_a, GA_Offset pt_b, void *data)
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
virtual void stealCEBuffers(const GA_Primitive *src)
Steal the underlying CE buffer from the source.
SYS_FORCE_INLINE void setPrimitiveClosedFlag(GA_Offset primoff, bool closed)
SYS_FORCE_INLINE ToType get(FromType index) const
Get the the value at the index.
Container class for all geometry.
GLubyte GLubyte GLubyte GLubyte w
SYS_FORCE_INLINE GA_Size getPrimitiveVertexCount(GA_Offset primoff) const
Definition of a geometric primitive.
const char * getTypeName() const
GA_Range getVertexRange(bool harden=false) const
Get a range of all the vertices accessed by the primitive.
SYS_FORCE_INLINE void setVertexList(GA_Offset primoff, const GA_OffsetListRef &vertices)
SYS_FORCE_INLINE GA_Primitive(GA_Detail &detail, GA_Offset offset=GA_INVALID_OFFSET)
void(* GA_EdgeApplyIndexFunc)(const GA_Primitive &prim, GA_Size v1, GA_Size v2, void *data)
virtual GA_Offset releaseVertex(GA_Offset vtx)
virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
SYS_FORCE_INLINE int getTypeId(GA_Offset primoff) const
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)
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Offset primoff, GA_Size i) const