65 #ifdef TIMING_BUILDBLOCK
70 #define TIMING_LOG(msg) \
71 printf(msg ": %f milliseconds\n", 1000*timer.stop()); \
76 #define TIMING_LOG(msg)
79 using namespace HDK_Sample;
177 float signedvol = -(v3-
v0).
dot(
cross(v1-v0, v2-v0));
235 if (count == PT_PER_TET)
266 if (count == PT_PER_TET)
280 namespace HDK_Sample {
282 using namespace UT::Literal;
311 case geo_TBJ_VERTEX:
return theKWVertex;
312 case geo_TBJ_ENTRIES:
break;
323 return tet(pr)->saveVertexArray(w, map);
324 case geo_TBJ_ENTRIES:
336 case geo_TBJ_ENTRIES:
348 return tet(pr)->loadVertexArray(p, map);
349 case geo_TBJ_ENTRIES:
362 case geo_TBJ_ENTRIES:
375 case geo_TBJ_ENTRIES:
398 return tetrahedronJSON();
419 for (
int i = 0; i < nvertex; i++)
422 vtxoffs[i] +=
GA_Size(startvtxoff);
428 if (nvertex < PT_PER_TET)
538 vtx_to_prim->
setLink(vtxoff+i, primoff);
548 for (
GA_Size i = 0; i < npts; i++)
558 class geo_SetTopoPrimsParallel
561 geo_SetTopoPrimsParallel(
565 : myTopology(topology)
566 , myStartPrim(startprim)
567 , myStartVtx(startvtx)
576 GA_Size relativestart = start - myStartVtx;
577 GA_Size relativeend = end - myStartVtx;
586 myTopology->setLink(start++, tet);
591 for (; tet != endtet; ++tet)
594 myTopology->setLink(start++, tet);
601 myTopology->setLink(start++, tet);
622 const int *tetpointnumbers)
629 const GA_Offset endpt = startpt + npoints;
639 const GA_Offset endvtx = startvtx + nvertices;
648 geo_SetTopoMappedParallel<int>(vertexToPoint, startpt, startvtx, tetpointnumbers));
658 geo_SetTopoPrimsParallel(vertexToPrim, startprim, startvtx));
673 if (pointToVertex && vertexToNext && vertexToPrev)
697 geo_NextPrevParallel<int>(map.
getArray(), map.
size(), tetpointnumbers, nextvtxarray.
getArray(), prevvtxarray.
getArray(), startvtx, startpt, pointToVertex, vertexToPrev, lock));
705 geo_Pt2VtxTopoParallel<int>(pointToVertex, map.
getArray(), map.
size(), tetpointnumbers, startvtx, startpt));
716 geo_LinkToposParallel<int>(vertexToNext, vertexToPrev, nextvtxarray.
getArray(), prevvtxarray.
getArray(), startvtx));
726 geoNewPrimTetraBlock(
732 bool allowed_to_parallelize)
734 if (allowed_to_parallelize && nprimitives >= 4*
GA_PAGE_SIZE)
741 GA_Primitive **pprims = new_prims+(primoff-start_offset);
743 for ( ; primoff != endprimoff; ++primoff, ++pprims)
750 GA_Offset endprimoff(start_offset + nprimitives);
751 for (
GA_Offset primoff(start_offset); primoff != endprimoff; ++primoff, ++new_prims)
772 geoNewPrimTetraBlock,
782 #ifndef TETRA_GR_PRIMITIVE
790 const int hook_priority = 0;
794 theDefinition->
getId(),
845 geo_buildPoly(
this, gdp, 0, 1, 2, parms);
846 geo_buildPoly(
this, gdp, 1, 3, 2, parms);
847 geo_buildPoly(
this, gdp, 1, 0, 3, parms);
848 prim = geo_buildPoly(
this, gdp, 0, 2, 3, parms);
885 float tmax,
float ,
float *
distance,
887 int,
float *,
float *,
int)
const
899 if (distance) *distance =
dist;
900 if (pos) *pos = org + dist * dir;
int intersectRay(const UT_Vector3T< T > &org, const UT_Vector3T< T > &dir, T tmax=1E17F, T *distance=0, UT_Vector3T< T > *nml=0) const
void UTparallelSort(RandomAccessIterator begin, RandomAccessIterator end, const Compare &compare)
static void registerMyself(GA_PrimitiveFactory *factory)
GA_VertexWrangler & getVertex()
bool saveField(const GA_Primitive *pr, int i, UT_JSONWriter &w, const GA_SaveMap &map) const override
bool saveVertexArray(UT_JSONWriter &w, const GA_SaveMap &map) const
GA_API const UT_StringHolder dist
GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0) override
#define GA_START_INTRINSIC_DEF(CLASS, NUM_INTRINSICS)
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET) override
void copyAttributeValues(GA_Offset dest, GA_Offset src)
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
UT_Vector3D computeNormalD() const override
static GEO_PrimTetra * build(GA_Detail *gdp, bool appendpts=true)
Optional build function.
virtual void copyPrimitive(const GEO_Primitive *src)=0
void setHasLocalTransform(bool x)
Set whether the primitive is has a transform associated with it.
Used to pass options and map offset values during saving.
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
Iteration over a range of elements.
GA_ElementWranglerCache & getGroupWranglers()
bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &hlist, fpreal u, fpreal v, uint du, uint dv) const override
Evalaute a point given a u,v coordinate (with derivatives)
UT_Vector3 computeNormal() const override
int64 getMemoryUsage() const override
Report approximate memory usage.
virtual void copySubclassData(const GA_Primitive *source)
bool blockAdvance(GA_Offset &start, GA_Offset &end)
const UT_StringHolder & getKeyword(int i) const override
UT_Vector3T< float > UT_Vector3
bool deletePrimitive(GA_Primitive &prim, bool and_points=false)
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
void setTrivial(ToType startvalue, GA_Size size)
Makes the list a trivial list with the specified start value and size.
int detachPoints(GA_PointGroup &grp) override
GLuint GLsizei GLsizei * length
JSON reader class which handles parsing of JSON or bJSON files.
void setCapacity(exint new_capacity)
SYS_FORCE_INLINE GEO_Detail * getParent() const
Class which writes ASCII or binary JSON streams.
GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false) override
Abstract base class for a range membership query object.
**But if you need a result
void normal(NormalComp &output) const override
GLfloat GLfloat GLfloat v2
GEO_PrimTetra * tet(GA_Primitive *p) const
template void UTparallelForLightItems(const UT_BlockedRange< GA_Size > &, const GEO_PrimTetra::geo_SetVertexListsParallel &, const bool)
GLfloat GLfloat GLfloat GLfloat v3
bool getBBox(UT_BoundingBox *bbox) const override
int getEntries() const override
Return the number of data fields in the primitive private schema.
#define GA_INTRINSIC_I(CLASS, ID, NAME, EVAL)
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.
void copySubclassData(const GA_Primitive *source) override
#define GA_INVALID_OFFSET
GA_OffsetList myVertexList
A range of elements in an index-map.
void set(FromType index, ToType value)
Set the index to the value.
static GA_Offset buildBlock(GA_Detail *detail, const GA_Offset startpt, const GA_Size npoints, const GA_Size ntets, const int *tetpointnumbers)
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
GA_PrimitiveDefinition * registerDefinition(const UT_StringHolder &name, GA_PrimitiveBlockConstructor construct, GA_PrimitiveFamilyMask mask=GA_FAMILY_NONE, const UT_StringHolder &label=UT_StringHolder(), const UT_StringHolder &icon=UT_StringHolder())
static DM_RenderTable * getTable()
Hook has no special behaviour.
const GA_IndexMap & getPointMap() const
The primitive render hook which creates GR_PrimTetra objects.
GA_Iterator begin() const
void newGeometryPrim(GA_PrimitiveFactory *factory)
#define GA_INTRINSIC_S(CLASS, ID, NAME, EVAL)
SIM_DerScalar length() const
GA_Offset appendPrimitiveBlock(const GA_PrimitiveTypeId &type, GA_Size nprimitives)
Append a contiguous block of primitives by GA_PrimitiveTypeId.
const GA_PrimitiveJSON * getJSON() const override
fpreal calcPerimeter() const override
SYS_FORCE_INLINE GA_Offset appendPointBlock(GA_Size npoints)
Append new points, returning the first offset of the contiguous block.
SYS_FORCE_INLINE const GA_ATITopology * getVertexNextRef() const
GT_API const UT_StringHolder topology
static const UT_StringHolder theEmptyString
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
bool loadField(GA_Primitive *pr, int i, UT_JSONParser &p, const UT_JSONValue &v, const GA_LoadMap &map) const override
GLsizei GLsizei GLchar * source
GEO_PrimTetra(GA_Detail &d, GA_Offset offset)
void copyPrimitive(const GEO_Primitive *src) override
Provide a JSON interface to a primitive.
~geo_PrimTetraJSON() override
A handle to simplify manipulation of multiple attributes.
GA_Offset getVertexOffset(GA_Size load_index) const
Map the load_index to the actual vertex number in the detail.
UT_Vector3T< fpreal64 > UT_Vector3D
const GA_IndexMap & getVertexMap() const
static const GA_PrimitiveTypeId & theTypeId()
Allows you to find out what this primitive type was named.
void addPointRefToGroup(GA_PointGroup &grp) const
bool loadField(GA_Primitive *pr, int i, UT_JSONParser &p, const GA_LoadMap &map) const override
GA_ElementWranglerCache & getWranglers()
Returns a GA_ElementWranglerCache using mySourceDetail and myDestDetail.
static void registerPrimitive(const GA_PrimitiveTypeId &id)
Register the GT collector.
void countMemory(UT_MemoryCounter &counter) const override
void enlargeBounds(const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
SYS_FORCE_INLINE const GA_ATITopology * getPrimitiveRef() const
GA_PrimCompat::TypeMask toType() const
const GEO_PrimTetra * tet(const GA_Primitive *p) const
void copyVertex(GEO_Vertex dest, const GEO_Vertex &src, int shallow=0) const
void add(const GA_Primitive *prim)
GA_Topology & getTopology()
const GA_PrimitiveDefinition * lookupDefinition(const UT_StringRef &name) const
fpreal calcArea() const override
int64 parseUniformArray(T *data, int64 len)
SYS_FORCE_INLINE bool containsOffset(GA_Offset offset) const
void countUnshared(size_t size)
SYS_FORCE_INLINE const GA_PrimitiveTypeId & getId() const
The unique ID assigned by the GA_PrimitiveFactory.
SYS_FORCE_INLINE const GA_ATITopology * getVertexPrevRef() const
int intersectRay(const UT_Vector3 &o, const UT_Vector3 &d, float tmax=1E17F, float tol=1E-12F, float *distance=0, UT_Vector3 *pos=0, UT_Vector3 *nml=0, int accurate=0, float *u=0, float *v=0, int ignoretrim=1) const override
GEO_Primitive * convertNew(GEO_ConvertParms &parms) override
GA_Primitive * appendPrimitive(const GA_PrimitiveTypeId &type)
Append a primitive by GA_PrimitiveTypeId.
~GEO_PrimTetra() override
SYS_FORCE_INLINE const GA_ATITopology * getVertexRef() const
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false) override
void zeroElement(GA_AttributeOwner downer, GA_Offset dest) const
Zero an attribute. This is equivalent to a weighted sum of 0 elements.
SYS_FORCE_INLINE void initBounds()
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
Class to store JSON objects as C++ objects.
bool registerGEOHook(GUI_PrimitiveHook *hook, GA_PrimitiveTypeId geo_type, int priority, GUI_PrimitiveHookFlags flags=GUI_HOOK_FLAG_NONE, int hook_ver=GUI_PRIMITIVE_HOOK_VERSION)
Register a geometry primitive render hook Register a primitive hook that uses a GEO_Primitive as its ...
SYS_FORCE_INLINE ToType get(FromType index) const
Get the the value at the index.
Container class for all geometry.
bool jsonVertexArray(UT_JSONWriter &w, const GA_SaveMap &save) const
Save the offsets by doing the mapping to the vertices in the save map.
GLubyte GLubyte GLubyte GLubyte w
Definition of a geometric primitive.
bool loadVertexArray(UT_JSONParser &p, const GA_LoadMap &map)
GA_PrimitiveGroup * getDeletePrimitives(GEO_Detail *gdp=nullptr)
virtual bool contains(GA_Offset) const =0
SIM_API const UT_StringHolder distance
void copyValue(GA_AttributeOwner downer, GA_Offset doffset, GA_AttributeOwner sowner, GA_Offset soffset, Cache *cache=0) const
Automatically expand attribute data pages for threading.
GEO_API const TypeMask GEOPRIMPOLY
bool isDegenerate() const override
static GA_IntrinsicManager::Registrar registerIntrinsics(GA_PrimitiveDefinition &defn)
void countBaseMemory(UT_MemoryCounter &counter) const
SYS_FORCE_INLINE const GA_ATITopology * getPointRef() const
GA_PrimitiveWrangler & getPrimitive()
UT_Vector3 baryCenter() const override
bool saveField(const GA_Primitive *pr, int i, UT_JSONValue &v, const GA_SaveMap &map) const override
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
bool isEqual(int i, const GA_Primitive *p0, const GA_Primitive *p1) const override
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
GEO_Primitive * copy(int preserve_shared_pts=0) const override
#define GA_END_INTRINSIC_DEF(CLASS, BASECLASS)
GA_API const UT_StringHolder area
SYS_FORCE_INLINE GA_Offset appendVertexBlock(GA_Size nvertices)
Append new vertices, returning the first offset of the contiguous block.
static GEO_PrimPoly * build(GA_Detail *gdp, GA_Size nvertices, bool open=false, bool appendpts=true)
fpreal calcVolume(const UT_Vector3 &refpt) const override
SYS_FORCE_INLINE void setLink(GA_Offset ai, GA_Offset v)