11 #ifndef __GEO_PrimVolume__
12 #define __GEO_PrimVolume__
38 pos *= myInverseXform;
43 fpreal zscale = (1 - pos.
z()) * 0.5
f;
44 fpreal taperx = 1 + (-1 + myTaperX) * zscale;
45 fpreal tapery = 1 + (-1 + myTaperY) * zscale;
79 fpreal zscale = (1 - pos.
z()) * 0.5
f;
80 fpreal taperx = 1 + (-1 + myTaperX) * zscale;
81 fpreal tapery = 1 + (-1 + myTaperY) * zscale;
104 return myInverseXform*0.5;
107 pos *= myInverseXform;
109 float zscale = (1 - pos.
z()) * 0.5
f;
110 float taperx = 1 + (-1 + myTaperX) * zscale;
111 float tapery = 1 + (-1 + myTaperY) * zscale;
120 0.5f * (myTaperX - 1.f) * pos.
x() / (taperx * taperx),
121 0.5
f * (myTaperY - 1.
f) * pos.
y() / (tapery * tapery),
124 return myInverseXform*tapergrad*0.5;
145 float zscale = (1 - pos.
z()) * 0.5
f;
146 float taperx = 1 + (-1 + myTaperX) * zscale;
147 float tapery = 1 + (-1 + myTaperY) * zscale;
156 0.5f * (1.f - myTaperX) * pos.
x(),
157 0.5f * (1.f - myTaperY) * pos.
y(),
160 return 2.f*tapergrad*myXform;
180 for (i = 0; i < 8; i++)
201 for (i = 0; i < 8; i++)
236 SamplingType sampling_type,
270 void save(std::ostream &os,
bool binary =
false)
const;
276 myCenter.assign(0, 0, 0);
278 myInverseXform.identity();
316 float u,
float v=0,
float w=0)
const override;
345 std::ostream &os,
bool binary,
376 static const int theSharedVoxelMagic=(
'V'<<24)|(
'o'<<16)|(
'x'<<8)|(
'l');
386 allocateSharedDataLoader();
436 bool dry_run=
false)
override;
438 bool dry_run=
false)
override;
445 float ulength,
float vlength,
446 float &uparm,
float &vparm)
const override;
448 float ulength,
float vlength,
449 float &uparm,
float &vparm,
450 float tolerance)
const override;
453 float uparm,
float vparm,
454 float &ulength,
float &vlength)
const override;
462 #if GA_PRIMITIVE_VERTEXLIST
477 void assignVertex(
GA_Offset new_vtx,
bool update_topology);
480 void stashed(
bool beingstashed,
487 myInverseXform.invert();
500 void getInverseTransform4(
UT_Matrix4 &matx)
const;
513 bool isWorldAxisAligned()
const;
557 return myVoxelHandle;
583 bool isIndexInside(
int x,
int y,
int z)
const;
589 bool posToIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
607 fpreal getValueAtIndex(
int ix,
int iy,
int iz)
const;
608 void getValuesAtIndices(
float *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
609 void getValuesAtIndices(
int *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
613 void getRes(
int &rx,
int &ry,
int &rz)
const;
616 fpreal getVoxelDiameter()
const;
623 fpreal calcPositiveDensity()
const;
626 fpreal calcMinimum()
const;
627 fpreal calcMaximum()
const;
628 fpreal calcAverage()
const;
633 bool isSDF()
const {
return myIsSDF; }
637 bool computeHeightFieldProperties(
int &a1,
int &a2,
int &axis,
fpreal &
scale)
const;
646 fpreal getBorderValue()
const;
649 fpreal getCompressionTolerance()
const;
650 void setCompressionTolerance(
fpreal tol);
682 : myVoxels(src.myVoxels)
683 , myBorder(src.myBorder)
687 , myEntries(src.myEntries)
692 myVoxels = src.myVoxels;
693 myBorder = src.myBorder;
697 myEntries = src.myEntries;
704 if (index >= 0 && index < myEntries)
708 index = (index -
x) / myXres;
710 index = (index -
y) / myYres;
712 return (*myVoxels)(
x,
y,
z);
719 bool atEnd()
const {
return myCurr >= myEntries; }
731 : myVoxels(prim.getVoxelHandle())
734 prim.
getRes(myXres, myYres, myZres);
736 myEntries = myXres*myYres*myZres;
740 exint myCurr, myEntries;
741 int myXres, myYres, myZres;
787 #if !GA_PRIMITIVE_VERTEXLIST
791 #if !GA_PRIMITIVE_VERTEXLIST
830 float u,
float v = 0,
831 unsigned du=0,
unsigned dv=0)
const override
849 #if !GA_PRIMITIVE_VERTEXLIST
861 fpreal myTaperX, myTaperY;
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
virtual void flushCECaches()
serialize getSerialize() const
GLboolean GLboolean GLboolean b
Definition of a geometry attribute.
GEO_VolumeVis getVisualization() const
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
GLint GLint GLsizei GLint border
virtual UT_Vector3 baryCenter() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
virtual void clearForDeletion()
UT_VoxelArrayHandleF myVoxelHandle
GLenum GLenum GLenum GLenum GLenum scale
Used to pass options and map offset values during saving.
bool loadVoxelDataH9(UT_IStream &is, UT_VoxelArrayWriteHandleF voxels, int version)
bool isFullyLoaded() const
virtual UT_Vector3D computeNormalD() const =0
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
virtual void copySubclassData(const GA_Primitive *source)
void setVisOptions(const GEO_VolumeOptions &vis)
int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const override
const GLuint GLenum const void * binary
fpreal calcVolume(const UT_Vector3 &) const override
UT_Vector3T< float > UT_Vector3
SYS_FORCE_INLINE UT_Vector3 getPos3() const
serialize & operator=(const serialize &src)
virtual bool saveSharedLoadData(UT_JSONWriter &w, GA_SaveMap &save, GA_GeometryIndex *geo_index) const
constexpr SYS_FORCE_INLINE T & z() noexcept
fpreal getVisDensity() const
const GEO_VolumeOptions & getVisOptions() const
static GA_PrimitiveFamilyMask buildFamilyMask()
void reverse() override
Reverse the order of vertices.
GA_Offset vertexPoint() const
GA_SharedDataHandlePtr mySharedVoxelData
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
SYS_FORCE_INLINE GA_Offset getVertexOffset() const
JSON reader class which handles parsing of JSON or bJSON files.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *P) const override
Class which writes ASCII or binary JSON streams.
Abstract base class for a range membership query object.
virtual bool savePrivateH9(std::ostream &os, bool binary) const
fpreal calcArea() const override
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
void read(T &in, bool &v)
virtual void swapVertexOffsets(const GA_Defragment &defrag)
virtual void unitToUnitLengthPair(float uparm, float vparm, float &ulength, float &vlength) const
void wireVertex(GA_Offset vertex, GA_Offset point)
virtual bool loadH9(UT_IStream &is, const UT_Array< GA_AttribLoadDataH9 > &prim_attribs, const UT_Array< GA_AttribLoadDataH9 > &vtx_attribs)
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimVolume &d)
GLubyte GLubyte GLubyte GLubyte w
virtual bool isDegenerate() const =0
Is the primitive degenerate.
virtual bool enlargeBoundingSphere(UT_BoundingSphere &b, const GA_Attribute *P) const
const UT_Matrix3 & getTransform() const
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
virtual void setLocalTransform(const UT_Matrix3D &matrix)
Set the local transform. The default implementation does nothing.
Class to load shared data.
virtual int evaluateInteriorPointV4(UT_Vector4 &pos, fpreal u, fpreal v, fpreal w=0) const
UT_VoxelArrayHandleF & getMyVoxelHandle() const
Gets the handle to our voxels.
void setTransform(const UT_Matrix3 &m)
bool hasBorrowedCEGrid() const
GLsizei GLsizei GLchar * source
const UT_Matrix3 & getInverseTransform() const
Converts from world space to local space.
virtual const GA_PrimitiveJSON * getJSON() const =0
fpreal getVoxel(exint index) const
Random access of a voxel value.
Provide a JSON interface to a primitive.
void setBorrowedCEGrid(CE_Grid *grid)
GLdouble GLdouble GLdouble z
fpreal getBorderValue() const
A handle to simplify manipulation of multiple attributes.
Defragmentation of IndexMaps.
void enlargeBounds(const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
SYS_FORCE_INLINE void setPos3(const UT_Vector3 &pos)
bool mySharedDataHandleLoaded
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
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3 &pos) const
serialize(const serialize &src)
virtual void unitLengthToUnitPair(float ulength, float vlength, float &uparm, float &vparm) const
GT_API const UT_StringHolder version
virtual bool evaluateBaryCenterRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map) const
virtual bool evaluateInteriorPointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v, fpreal w=0) const
CE_Grid * getCEGrid(bool read, bool write) const
virtual void transform(const UT_Matrix4 &)
virtual void enlargePointBounds(UT_BoundingBox &box) const
virtual void getLocalTransform(UT_Matrix3D &matrix) const
virtual bool loadPrivateH9(UT_IStream &is)
GLsizei const GLint box[]
void setVertexPoint(GA_Offset pt)
virtual int detachPoints(GA_PointGroup &grp)=0
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
virtual bool getBBox(UT_BoundingBox *bbox) const =0
SYS_FORCE_INLINE void initBounds()
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
virtual void stealCEBuffers(const GA_Primitive *src)
Steal the underlying CE buffer from the source.
Class to store JSON objects as C++ objects.
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
virtual void addToBSphere(UT_BoundingSphere *bsphere) const
SYS_FORCE_INLINE GA_Offset getPointOffset() const
GLint GLenum GLboolean GLsizei stride
constexpr SYS_FORCE_INLINE T & y() noexcept
void write(T &out, bool v)
virtual bool registerSharedLoadData(int load_data_type, GA_SharedDataHandlePtr item)
void getRes(int &rx, int &ry, int &rz) const
Returns the resolution of the voxel array.
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
UT_VoxelArrayHandleF getHandleToVoxelsWithoutLoading() const
constexpr SYS_FORCE_INLINE T & x() noexcept