13 #ifndef __GEO_PrimHexahedron__
14 #define __GEO_PrimHexahedron__
29 #define FACE_PER_HEX 6
30 #define EDGE_PER_HEX 12
49 myVertexList = vertex_list;
92 GA_Offset point,
bool dry_run=
false)
override;
117 {
return getFastVertexOffset(index); }
135 const int *
f = fastFaceIndices(faceno);
164 return hex_faceidx[faceno];
180 const int *
indices = fastFaceIndices(quad);
181 v0 = fastVertexOffset(indices[0]);
182 v1 = fastVertexOffset(indices[1]);
183 v2 = fastVertexOffset(indices[2]);
184 v3 = fastVertexOffset(indices[3]);
190 {
return rawEdgeCount(); }
209 e0 = edgeidx[edgeno][0];
210 e1 = edgeidx[edgeno][1];
218 {
return GAisValid(findSharedHex(faceno)); }
221 {
return findSharedHex(faceno); }
228 if (fastVertexOffset(i) == vtx)
return i;
235 if (vertexPoint(i) == pt)
return i;
260 {
return myHex.getFastVertexOffset(myF[i]); }
262 {
return getFastVertexOffset(i); }
264 {
return myHex.getPointOffset(myF[i]); }
266 {
return myHex.getPos3(myF[i]); }
272 const int *
const myF;
283 void normal(NormalComp &output)
const override;
284 void normal(NormalCompD &output)
const override;
295 static void rawComputeInteriorPointWeights(
303 vtxlist, weightlist, u,
v,
w); }
313 myCoefficients[0] = pos[0];
314 myCoefficients[1] = pos[1] - pos[0];
315 myCoefficients[2] = pos[2] - pos[0];
316 myCoefficients[3] = pos[3] - pos[1] - pos[2] + pos[0];
317 myCoefficients[4] = pos[4] - pos[0];
318 myCoefficients[5] = pos[5] - pos[4] - pos[1] + pos[0];
319 myCoefficients[6] = pos[6] - pos[4] - pos[2] + pos[0];
320 myCoefficients[7] = pos[7] - pos[6] - pos[5] + pos[4] - pos[3] + pos[2] + pos[1] - pos[0];
324 for(
int i = 1; i < 8; ++i)
332 return myCoefficients[0] + unitToHexTranslated(u);
340 constexpr
static float GRID_LOWER_TOL = 1e-4;
341 constexpr
static float GRID_UPPER_TOL = GRID_LOWER_TOL + 1;
343 constexpr
static int maxIterations = 100;
346 for (
int i = 0; i < maxIterations; ++i)
368 J(0,0) = cx; J(0,1) = cy; J(0,2) = cz;
371 J(0,0) = J00; J(0,1) = J01; J(0,2) = J02;
372 J(1,0) = cx; J(1,1) = cy; J(1,2) = cz;
375 J(1,0) = J10; J(1,1) = J11; J(1,2) = J12;
376 J(2,0) = cx; J(2,1) = cy; J(2,2) = cz;
382 for (
int j = 0;
j < 3; ++
j)
399 auto dfd0 = myCoefficients[1] +
400 myCoefficients[3] * u[1] +
401 myCoefficients[5] * u[2] +
402 myCoefficients[7] * u[1] * u[2];
404 auto dfd1 = myCoefficients[2] +
405 myCoefficients[3] * u[0] +
406 myCoefficients[6] * u[2] +
407 myCoefficients[7] * u[0] * u[2];
409 auto dfd2 = myCoefficients[4] +
410 myCoefficients[5] * u[0] +
411 myCoefficients[6] * u[1] +
412 myCoefficients[7] * u[0] * u[1];
422 return myCoefficients[1] * u[0] +
423 myCoefficients[2] * u[1] +
424 myCoefficients[3] * u[0] * u[1] +
425 myCoefficients[4] * u[2] +
426 myCoefficients[5] * u[0] * u[2] +
427 myCoefficients[6] * u[1] * u[2] +
428 myCoefficients[7] * u[0] * u[1] * u[2];
436 void allocateVertices();
438 template <
typename T>
440 template <
typename T>
442 template <
typename T>
443 fpreal internalCalcArea()
const;
444 template <
typename T>
445 fpreal internalCalcPerimeter()
const;
451 virtual
bool validate() const;
470 friend class GU_PrimitiveFactory;
constexpr SYS_FORCE_INLINE T length2() const noexcept
fpreal calcPerimeter() const override
static SYS_FORCE_INLINE const int * fastFaceIndices(GA_Size faceno)
GLsizei GLenum const void * indices
SYS_FORCE_INLINE GA_Detail & getDetail() const
Used to pass options and map offset values during saving.
void computeInteriorPointWeights(UT_Array< GA_Offset > &vtxlist, UT_Array< float > &weightlist, fpreal u, fpreal v, fpreal w) const overridefinal
SYS_FORCE_INLINE GEO_PrimHexahedron(GA_Detail *gdp, GA_Offset offset, const GA_OffsetListRef &vertex_list)
bool SYSisFinite(fpreal64 f)
fpreal calcVolume(const UT_Vector3 &) const override
constexpr SYS_FORCE_INLINE T & z() noexcept
GA_Offset getPointOffset(GA_Size i) const
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
JSON reader class which handles parsing of JSON or bJSON files.
SYS_FORCE_INLINE GEO_Detail * getParent() const
void reverse() override=0
Reverse the order of vertices.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
SYS_FORCE_INLINE GA_Size getFastVertexCount() const
Class which writes ASCII or binary JSON streams.
Abstract base class for a range membership query object.
GLfloat GLfloat GLfloat v2
GLfloat GLfloat GLfloat GLfloat v3
SYS_FORCE_INLINE GEO_PrimHexahedron(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
NOTE: This constructor should only be called via GU_PrimitiveFactory.
virtual int64 getMemoryUsage() const
fpreal calcArea() const override
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
GA_Size getVertexCount() const
void wireVertex(GA_Offset vertex, GA_Offset point)
SYS_FORCE_INLINE GA_Offset getFastVertexOffset(GA_Size index) const
exint GA_Size
Defines the bit width for index and offset types in GA.
GA_Size find(GA_Offset pt) const
TLHex(const UT_Vector3 pos[8])
#define GA_INVALID_OFFSET
virtual void normal(NormalComp &output) const =0
static int rawFaceIndices(const GA_Detail *gdp, GA_Offset offset, GA_Size faceno, UT_Array< int > &vtxlist)
virtual bool isDegenerate() const =0
Is the primitive degenerate.
bool hexToUnit(UT_Vector3 &u, const UT_Vector3 &p) const
UT_Vector3D computeNormalD() const override
UT_Matrix3T< float > UT_Matrix3
virtual int evaluateInteriorPointV4(UT_Vector4 &pos, fpreal u, fpreal v, fpreal w=0) const
GA_Size getEdgeCount() const override
The number of edges in this volume.
static GA_Size rawVertexCount(const GA_Detail *gdp=nullptr, GA_Offset=GA_INVALID_OFFSET)
static GA_Size rawFaceCount(const GA_Detail *gdp=nullptr, GA_Offset offset=GA_INVALID_OFFSET)
Return the topology of the hexahedron.
GA_Offset getVertexOffset(GA_Size i) const
int getFaceIndices(GA_Size faceno, UT_Array< int > &vtxlist) const override
Returns the indices to the vertices, not the vertex offsets!
virtual void countMemory(UT_MemoryCounter &counter) const
Face(const GEO_PrimHexahedron &tet, int face)
static GA_PrimitiveDefinition * theDefinition
GA_Offset getFastVertexOffset(GA_Size i) const
virtual const GA_PrimitiveJSON * getJSON() const =0
Provide a JSON interface to a primitive.
GA_Size getFaceCount() const override
The number of faces that make up this volume.
GA_Size getFastVertexCount() const
A handle to simplify manipulation of multiple attributes.
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
int getFaceIndexCount(GA_Size faceno) const override
Returns the number of indices in specified face.
static GA_Size rawEdgeCount(const GA_Detail *gdp=nullptr, GA_Offset=GA_INVALID_OFFSET)
static void rawEdgeIndices(const GA_Detail *gdp, GA_Offset offset, GA_Size edgeno, int &e0, int &e1)
GA_Offset findSharedFace(GA_Size faceno) const override
void enlargeBounds(const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
UT_Matrix3 getJacobian(const UT_Vector3 &u) const
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
UT_Vector3T< T > size() const
void getQuadVertexOffsets(GA_Size quad, GA_Offset &v0, GA_Offset &v1, GA_Offset &v2, GA_Offset &v3) const
Get the vertex offsets of the specified quad.
exint entries() const
Alias of size(). size() is preferred.
virtual bool evaluateInteriorPointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v, fpreal w=0) const
void assign(T xx=0.0f, T yy=0.0f, T zz=0.0f)
Set the values of the vector components.
virtual int detachPoints(GA_PointGroup &grp)=0
UT_Vector3 unitToHex(const UT_Vector3 &u) const
SYS_FORCE_INLINE GA_Offset getMapOffset() const
Gets the offset of this primitive in the detail containing it.
SYS_FORCE_INLINE void initBounds()
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
Container class for all geometry.
virtual GEO_Primitive * convert(GEO_ConvertParms &parms, GA_PointGroup *usedpts=0)=0
GLubyte GLubyte GLubyte GLubyte w
static int rawFaceIndexCount(const GA_Detail *gdp, GA_Offset offset, GA_Size faceno)
GA_Size findVertex(GA_Offset vtx) const
UT_Vector3 computeNormal() const override
Return a normal vector for the primitive.
Definition of a geometric primitive.
void clear()
Resets list to an empty list.
virtual const GA_PrimitiveDefinition & getTypeDef() const =0
constexpr SYS_FORCE_INLINE T & y() noexcept
SYS_FORCE_INLINE GA_Offset fastVertexOffset(GA_Size index) const
void setVertexPoint(int i, GA_Offset pt)
SYS_FORCE_INLINE bool isFaceShared(GA_Size faceno) const
virtual GEO_Primitive * convertNew(GEO_ConvertParms &parms)=0
void getEdgeIndices(GA_Size edgeno, int &e0, int &e1) const override
SYS_FORCE_INLINE FromType size() const
Returns the number of used elements in the list (always <= capacity())
UT_Vector3 getPos3(GA_Size i) const
constexpr SYS_FORCE_INLINE T & x() noexcept