20 #ifndef __GEO_Hull_H__
21 #define __GEO_Hull_H__
41 template<
typename T,
bool B>
class GA_EdgeT;
55 int saveBinary( std::ostream &os )
const;
64 dupTop = 0; dupLeft = 0;
65 dupBottom = 0; dupRight = 0;
66 breakThread = 0; breakBridge = 0;
96 {
return( (h_edge==p.
h_edge) &&
102 {
return !(*
this == p); }
129 #if !GA_PRIMITIVE_VERTEXLIST
142 virtual int evaluateBreakpoint(
int uidx,
int vidx,
144 int du=0,
int dv=0)
const = 0;
150 unsigned du,
unsigned dv)
const
151 {
return evaluateIndexRefMap(u, v, result_vtx, hlist, du, dv); }
153 unsigned du=0,
unsigned dv=0)
const
154 {
return evaluateIndexV4(iu, iv, pos, du, dv); }
161 void normal(NormalComp &output)
const override;
162 void normal(NormalCompD &output)
const override;
168 float v = 0,
float w = 0)
const override;
173 virtual int evaluateNormal(
float u,
float v,
UT_Vector3 &nml)
const;
174 virtual int normalIndex(
float iu,
float iv,
UT_Vector3 &nml)
const;
176 virtual int uMinValidIndex()
const;
177 virtual int uMaxValidIndex()
const;
178 virtual int vMinValidIndex()
const;
179 virtual int vMaxValidIndex()
const;
198 #if !GA_PRIMITIVE_VERTEXLIST
204 virtual void reverseU();
205 virtual void reverseV();
209 virtual int cycleU(
int amount,
int = 1);
210 virtual int cycleV(
int amount,
int = 1);
213 int setRowCol(
int r,
int c);
214 virtual int insertRow(
unsigned int beforeWhich,
bool appendPts=
true);
217 #if GA_PRIMITIVE_VERTEXLIST
218 return insertRow(myRows, appendPts);
220 return insertRow(myVertexMatx.getRows(), appendPts);
223 virtual int insertCol(
unsigned int beforeWhich,
bool appendPts=
true);
226 #if GA_PRIMITIVE_VERTEXLIST
227 return insertCol(myCols, appendPts);
229 return insertCol(myVertexMatx.getCols(), appendPts);
233 virtual int deleteRow(
unsigned int which);
234 virtual int deleteCol(
unsigned int which);
247 GA_Offset point,
bool dry_run=
false)
override;
256 {
return subdivideURefMap(u, map); }
258 {
return subdivideUFloat(u); }
260 {
return subdivideVRefMap(u, map); }
262 {
return subdivideVFloat(u); }
264 virtual void subdivide(
int numdivs,
GA_PointGroup *ptgroup=0);
271 virtual int warpU(
float u,
const UT_Vector3 &delta,
273 float sharpness = 0.0
f,
float bias = -1.0
f) = 0;
274 virtual int warpV(
float v,
const UT_Vector3 &delta,
276 float sharpness = 0.0
f,
float bias = -1.0
f) = 0;
279 float usharpness = 0.0
f,
float vsharpness = 0.
f,
280 float ubias = -1.0
f,
float vbias = -1.0
f) = 0;
286 int warpAlongNormal (
float u,
float v,
float distance,
288 float usharpness,
float vsharpness,
289 float ubias,
float vbias,
303 float bias = 0.5
f,
float tolerance = 1.0
f,
306 float bias = 0.5
f,
float tolerance = 1.0
f,
313 virtual int refineU(
float k,
317 virtual int refineU (
float k,
int i=1);
318 virtual int refineV(
float k,
321 virtual int refineV (
float k,
int i=1);
326 { spanRefineURefMap(map, numdivs); }
328 { spanRefineUInt(numdivs); }
331 { spanRefineVRefMap(map, numdivs); }
333 { spanRefineVInt(numdivs); }
338 int mult=0,
float tol=1e-4
f,
340 {
return unrefineURefMap(kidx, h, mult,
345 {
return unrefineUFloat(kidx, mult, tol,
348 int mult=0,
float tol=1e-4
f,
350 {
return unrefineVRefMap(kidx, h, mult,
355 {
return unrefineVFloat(kidx, mult, tol,
360 virtual void fixSeamsU();
361 virtual void fixSeamsV();
365 bool rowColTexture(
const GA_RWHandleV3 &txth,
bool ptattrib);
369 #if GA_PRIMITIVE_VERTEXLIST
372 {
return (
int)myVertexMatx.getRows(); }
376 #if GA_PRIMITIVE_VERTEXLIST
379 {
return (
int)myVertexMatx.getCols(); }
412 const
GEO_Vertex getVertexElement(
unsigned int r,
unsigned int c) const;
414 #if GA_PRIMITIVE_VERTEXLIST
421 if (r >= getNumRows() || c >= getNumCols())
423 #if GA_PRIMITIVE_VERTEXLIST
426 return myVertexMatx(r, c);
437 if (r >= getNumRows() || c >= getNumCols())
443 return vertexPoint(r, c);
464 return exint(getNumRows()) *
exint(getNumCols());
468 if (r >= getNumRows() || c >= getNumCols())
474 #if !GA_PRIMITIVE_VERTEXLIST
475 void beginVertex(const_iterator &i)
const override;
476 void nextVertex(const_iterator &i)
const override;
484 const char *getSurfaceTypeName()
const;
485 bool setSurfaceTypeName(
const char *
name);
493 bool setWrapU(
bool dowrap);
494 bool setWrapV(
bool dowrap);
497 virtual void wrapU(
int rounded = 1,
int preserveShape = 0);
498 virtual void openU(
int preserveShape = 0,
int safe = 0);
499 virtual void wrapV(
int rounded = 1,
int preserveShape = 0);
500 virtual void openV(
int preserveShape = 0,
int safe = 0);
502 virtual bool isClampedU()
const;
503 virtual bool isClampedV()
const;
509 virtual int unrollU(
int append_pts = 1);
510 virtual int unrollV(
int append_pts = 1);
517 #if !GA_PRIMITIVE_VERTEXLIST
519 void *
data =
nullptr)
const override;
525 #if !GA_PRIMITIVE_VERTEXLIST
531 #if GA_PRIMITIVE_VERTEXLIST
538 void stashed(
bool beingstashed,
545 virtual int loftU(
int newcount,
int start=-1,
int stop=-1) = 0;
546 virtual int loftV(
int newcount,
int start=-1,
int stop=-1) = 0;
552 float &uunit,
float &vunit)
const override;
555 float &ureal,
float &vreal)
const override;
560 virtual void unitToRealDomain(
float u_unit,
float v_unit,
561 float &u_real,
float &v_real)
const;
562 virtual void realToUnitDomain(
float u_real,
float v_real,
563 float &u_unit,
float &v_unit)
const;
568 virtual void unitToRealSequenceU(
float *uunit,
float *ureal,
570 virtual void unitToRealSequenceV(
float *vunit,
float *vreal,
577 int *pr1,
int *pc1)
const;
581 int *pr1,
int *pc1)
const;
592 void sampleEndsU(
int n);
593 void sampleEndsV(
int n);
597 virtual void validURange(
float &ua,
float &ub)
const;
598 virtual void validVRange(
float &va,
float &vb)
const;
599 virtual void validUInterval(
int &
a,
int &
b)
const;
600 virtual void validVInterval(
int &
a,
int &
b)
const;
604 float getIndices(
float c,
int &c1,
int &c2,
605 int maxIndex,
int wrap)
const;
613 float *u0,
float *
u1,
614 float *
v0,
float *
v1)
override;
617 float uvDist(
float u1,
float v1,
float u2,
float v2)
const override;
619 virtual void weights(
unsigned short onOff);
625 template <
typename S>
648 , myRowP1((row+1 == hull.getNumRows()) ? 0 : (row+1))
649 , myColP1((col+1 == hull.getNumCols()) ? 0 : (col+1))
654 {
return myHull.getVertexOffset((i >= 2) ? myRowP1 : myRow, (i==1 || i==2) ? myColP1 : myCol); }
656 {
return myHull.getPointOffset((i >= 2) ? myRowP1 : myRow, (i==1 || i==2) ? myColP1 : myCol); }
658 {
return myHull.getPos3((i >= 2) ? myRowP1 : myRow, (i==1 || i==2) ? myColP1 : myCol); }
664 for (
GA_Size i = 0; i < getFastVertexCount(); ++i)
680 #if !GA_PRIMITIVE_VERTEXLIST
684 template <
typename T,
typename NORMALCOMP>
685 void internalComputeNormal(NORMALCOMP &output)
const;
686 template <
typename T>
688 template <
typename T>
690 template <
typename T>
691 fpreal internalCalcArea()
const;
692 template <
typename T>
693 fpreal internalCalcPerimeter()
const;
695 void cycleOffsetListRows(
int shift);
696 void cycleOffsetListCols(
int shift);
725 virtual bool savePrivateH9(std::ostream &os,
bool binary)
const = 0;
726 virtual bool loadPrivateH9(
UT_IStream &is) = 0;
727 virtual bool saveExtraH9 (std::ostream &os,
bool binary)
const = 0;
728 virtual bool loadExtraH9 (
UT_IStream &is) = 0;
732 virtual bool validate()
const = 0;
736 float getLRIndex(
float c,
int &c1,
int &c2,
737 int minIndex,
int maxIndex,
int wrap)
const;
743 #if GA_PRIMITIVE_VERTEXLIST
750 #if !GA_PRIMITIVE_VERTEXLIST
755 #if GA_PRIMITIVE_VERTEXLIST
757 GA_Size matrixIndex(
int r,
int c)
const
760 return r*
exint(myCols) +
c;
778 unsigned du,
unsigned dv)
const;
779 virtual int evaluateIndexV4(
float iu,
float iv,
UT_Vector4 &pos,
780 unsigned du=0,
unsigned dv=0)
const;
783 virtual int subdivideUFloat(
float u);
785 virtual int subdivideVFloat(
float u);
790 virtual void spanRefineUInt(
int numdivs=1) = 0;
793 virtual void spanRefineVInt(
int numdivs=1) = 0;
796 int mult=0,
float tol=1e-4
f,
798 virtual int unrefineUFloat(
int kidx,
int mult = 0,
802 int mult=0,
float tol=1e-4
f,
804 virtual int unrefineVFloat(
int kidx,
int mult = 0,
808 #if !GA_PRIMITIVE_VERTEXLIST
SYS_FORCE_INLINE void setPos3(unsigned int r, unsigned int c, const UT_Vector3 &pos) const
fpreal calcPerimeter() const override
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
bool findEdgePoints(GA_Offset ptoff0, GA_Offset ptoff1, GA_Size &vtx0, GA_Size &vtx1) const
void spanRefineU(GA_AttributeRefMap &map, int numdivs=1)
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
virtual UT_Vector3 baryCenter() const
SYS_FORCE_INLINE GA_Detail & getDetail() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
SYS_FORCE_INLINE GA_Index getVertexIndex(unsigned int r, unsigned int c) const
virtual void clearForDeletion()
Used to pass options and map offset values during saving.
void spanRefineU(int numdivs=1)
SYS_FORCE_INLINE GA_Size getVertexCount() const
Return the number of vertices used by this primitive.
int unrefineU(int kidx, GA_AttributeRefMap &h, int mult=0, float tol=1e-4f, GA_PointGroup *delgroup=0)
GA_OffsetMatrix myVertexMatx
GEO_Vertex getVertexElement(GA_Size i) const
virtual UT_Vector3D computeNormalD() const =0
virtual void computeInteriorPointWeights(UT_Array< GA_Offset > &vtxlist, UT_Array< float > &weightlist, fpreal u, fpreal v, fpreal w) const
#define SYS_DEPRECATED_PUSH_DISABLE()
UT_Vector4 getPos4(GA_Offset ptoff) const
The ptoff passed is the point offset.
#define SYS_DEPRECATED_POP_DISABLE()
virtual void copySubclassData(const GA_Primitive *source)
SYS_FORCE_INLINE GA_Size getFastVertexCount() const
int unrefineU(int kidx, int mult=0, float tol=1e-4F, GA_PointGroup *delgroup=0)
const GLuint GLenum const void * binary
fpreal calcVolume(const UT_Vector3 &) const override
static GA_PrimitiveFamilyMask buildFamilyMask()
SYS_FORCE_INLINE GA_Size getFastVertexCount() const
GEO_SurfaceType surfaceType
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
SYS_FORCE_INLINE GA_Offset getVertexOffset(unsigned int r, unsigned int c) const
SYS_FORCE_INLINE GA_Index getPointIndex(unsigned int r, unsigned int c) const
SYS_FORCE_INLINE void initHullData(int rows, int cols, bool wrapv, bool wrapu)
GLboolean GLboolean GLboolean GLboolean a
int appendCol(bool appendPts=true)
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
JSON reader class which handles parsing of JSON or bJSON files.
void reverse() override=0
Reverse the order of vertices.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
SYS_FORCE_INLINE GA_Offset getPointOffset(unsigned int r, unsigned int c) const
Class which writes ASCII or binary JSON streams.
SYS_FORCE_INLINE void setPos4(unsigned int r, unsigned int c, const UT_Vector4 &pos) const
Abstract base class for a range membership query object.
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Offset ptoff) const
The ptoff passed is the point offset.
SYS_FORCE_INLINE bool isClosed() const
GLfloat GLfloat GLfloat v2
UT_Function< bool(const GA_Edge &edge)> GA_IterateEdgesFunc
int unrefineV(int kidx, int mult=0, float tol=1e-4F, GA_PointGroup *delgroup=0)
virtual int parametricBBox(float u, float v, float *u0, float *u1, float *v0, float *v1)
fpreal calcArea() const override
virtual void realToUnitPair(float ureal, float vreal, float &uunit, float &vunit) const
void setVertexPoint(GA_Offset vertex, GA_Offset ptoff)
Given a vertex, set the corresponding point offset.
SYS_FORCE_INLINE bool GAisValid(GA_Size v)
virtual void swapVertexOffsets(const GA_Defragment &defrag)
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_Offset getPointOffset(GA_Size i) const
virtual bool loadH9(UT_IStream &is, const UT_Array< GA_AttribLoadDataH9 > &prim_attribs, const UT_Array< GA_AttribLoadDataH9 > &vtx_attribs)
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
virtual void normal(NormalComp &output) const =0
bool evaluateIndex(fpreal u, fpreal v, GA_Offset result_vtx, GA_AttributeRefMap &hlist, unsigned du, unsigned dv) const
GEO_SurfaceType getSurfaceType() const
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GLsizei GLboolean transpose
vint4 blend(const vint4 &a, const vint4 &b, const vbool4 &mask)
bool hasEdge(const GA_Edge &edge) const override
Method to determine if a primitive has an edge (undirected).
Poly(const GEO_Hull &hull, const exint row, const exint col)
void setPos4(GA_Offset ptoff, const UT_Vector4 &pos)
Set P from a UT_Vector4.
SIM_DerScalar length() const
friend std::ostream & operator<<(std::ostream &os, const GEO_Hull &d)
virtual UT_Vector3D baryCenterD() const
int evaluateIndex(float iu, float iv, UT_Vector4 &pos, unsigned du=0, unsigned dv=0) const
SYS_FORCE_INLINE int getNumRows() const
GLsizei GLsizei GLchar * source
UT_Function< bool(GA_Size, GA_Size)> GA_IterateEdgesByVertexFunc
bool operator==(const GEO_SubHullPart &p) const
int appendRow(bool appendPts=true)
void setVertexPoint(unsigned int r, unsigned int c, GA_Offset pt)
A handle to simplify manipulation of multiple attributes.
virtual void iterateEdges(GA_IterateEdgesFunc apply_func) const
SYS_FORCE_INLINE GA_Index vertexIndex(GA_Offset offset) const
Given a vertex's data offset, return its index.
virtual float uvDist(float u1, float v1, float u2, float v2) const
Defragmentation of IndexMaps.
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
void addPointRefToGroup(GA_PointGroup &grp) const
GLuint const GLchar * name
#define SYS_DEPRECATED_HDK(__V__)
bool operator!=(const GEO_SubHullPart &p) const
GLboolean GLboolean GLboolean b
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
virtual bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const
void spanRefineV(int numdivs=1)
virtual bool evaluateBaryCenterRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map) const
SYS_FORCE_INLINE GA_Index pointIndex(GA_Offset offset) const
Given a point's data offset, return its index.
virtual bool vertexApply(bool(*apply)(GA_Offset vtx, void *), void *data=0) const
GLfloat GLfloat GLfloat GLfloat h
int subdivideU(float u, GA_AttributeRefMap &map)
void spanRefineV(GA_AttributeRefMap &map, int numdivs=1)
virtual int detachPoints(GA_PointGroup &grp)=0
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Size r, GA_Size c) const
SYS_FORCE_INLINE void setPos3(GA_Offset ptoff, const UT_Vector3 &pos)
Set P from a UT_Vector3.
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
virtual bool getBBox(UT_BoundingBox *bbox) const =0
virtual void unitToRealPair(float uunit, float vunit, float &ureal, float &vreal) const
SYS_FORCE_INLINE UT_Vector3 getPos3(unsigned int r, unsigned int c) const
virtual int evaluateNormalVector(UT_Vector3 &nml, float u, float v=0, float w=0) const
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
#define GA_PRIMITIVE_VERTEXLIST
GLdouble GLdouble GLdouble top
virtual void addToBSphere(UT_BoundingSphere *bsphere) const
SYS_FORCE_INLINE void setPointOffset(unsigned int r, unsigned int c, GA_Offset ptoff) const
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Container class for all geometry.
GLubyte GLubyte GLubyte GLubyte w
SYS_FORCE_INLINE int getNumCols() const
SYS_FORCE_INLINE UT_StorageMathFloat_t< T > normalize() noexcept
GLenum GLenum GLsizei void * row
ImageBuf OIIO_API warp(const ImageBuf &src, const Imath::M33f &M, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ImageBuf::WrapMode wrap=ImageBuf::WrapDefault, ROI roi={}, int nthreads=0)
int unrefineV(int kidx, GA_AttributeRefMap &h, int mult=0, float tol=1e-4f, GA_PointGroup *delgroup=0)
SIM_API const UT_StringHolder distance
SYS_FORCE_INLINE void normal(const UT_Vector3T< T > &va, const UT_Vector3T< T > &vb)
void countBaseMemory(UT_MemoryCounter &counter) const
UT_RefMatrix< GEO_SubHullPart > mat
SIM_DerVector3 cross(const SIM_DerVector3 &lhs, const SIM_DerVector3 &rhs)
virtual void iterateEdgesByVertex(GA_IterateEdgesByVertexFunc apply_func) const
GA_Size findVertex(GA_Offset vtx) const
return the index of a vertex within our vertex list
SYS_FORCE_INLINE UT_Vector4 getPos4(unsigned int r, unsigned int c) const
GEO_Hull(GA_Detail *d, GA_Offset offset=GA_INVALID_OFFSET)
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
int subdivideV(float u, GA_AttributeRefMap &map)
GA_API const UT_StringHolder area
void setSurfaceType(GEO_SurfaceType t)
SYS_FORCE_INLINE GA_Offset getFastVertexOffset(GA_Size i) const
static const UT_Vector3T< S > quadNormal(const UT_Vector3T< S > &p1, const UT_Vector3T< S > &p2, const UT_Vector3T< S > &p3, const UT_Vector3T< S > &p4)