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;
108 for (i = 0; i < 8; i++)
129 for (i = 0; i < 8; i++)
164 SamplingType sampling_type,
198 void save(std::ostream &os,
bool binary =
false)
const;
204 myCenter.assign(0, 0, 0);
206 myInverseXform.identity();
244 float u,
float v=0,
float w=0)
const override;
272 std::ostream &os,
bool binary,
303 static const int theSharedVoxelMagic=(
'V'<<24)|(
'o'<<16)|(
'x'<<8)|(
'l');
313 allocateSharedDataLoader();
363 bool dry_run=
false)
override;
365 bool dry_run=
false)
override;
372 float ulength,
float vlength,
373 float &uparm,
float &vparm)
const override;
375 float ulength,
float vlength,
376 float &uparm,
float &vparm,
377 float tolerance)
const override;
380 float uparm,
float vparm,
381 float &ulength,
float &vlength)
const override;
389 #if GA_PRIMITIVE_VERTEXLIST
404 void assignVertex(
GA_Offset new_vtx,
bool update_topology);
407 void stashed(
bool beingstashed,
414 myInverseXform.invert();
427 void getInverseTransform4(
UT_Matrix4 &matx)
const;
440 bool isWorldAxisAligned()
const;
482 return myVoxelHandle;
508 bool isIndexInside(
int x,
int y,
int z)
const;
514 bool posToIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
532 fpreal getValueAtIndex(
int ix,
int iy,
int iz)
const;
533 void getValuesAtIndices(
float *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
534 void getValuesAtIndices(
int *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
538 void getRes(
int &rx,
int &ry,
int &rz)
const;
541 fpreal getVoxelDiameter()
const;
548 fpreal calcPositiveDensity()
const;
551 fpreal calcMinimum()
const;
552 fpreal calcMaximum()
const;
553 fpreal calcAverage()
const;
558 bool isSDF()
const {
return myIsSDF; }
562 bool computeHeightFieldProperties(
int &a1,
int &a2,
int &axis,
fpreal &
scale)
const;
571 fpreal getBorderValue()
const;
574 fpreal getCompressionTolerance()
const;
575 void setCompressionTolerance(
fpreal tol);
607 : myVoxels(src.myVoxels)
608 , myBorder(src.myBorder)
612 , myEntries(src.myEntries)
617 myVoxels = src.myVoxels;
618 myBorder = src.myBorder;
622 myEntries = src.myEntries;
629 if (index >= 0 && index < myEntries)
633 index = (index -
x) / myXres;
635 index = (index -
y) / myYres;
637 return (*myVoxels)(
x,
y,
z);
644 bool atEnd()
const {
return myCurr >= myEntries; }
656 : myVoxels(prim.getVoxelHandle())
659 prim.
getRes(myXres, myYres, myZres);
661 myEntries = myXres*myYres*myZres;
665 exint myCurr, myEntries;
666 int myXres, myYres, myZres;
701 #if !GA_PRIMITIVE_VERTEXLIST
705 #if !GA_PRIMITIVE_VERTEXLIST
744 float u,
float v = 0,
745 unsigned du=0,
unsigned dv=0)
const override
763 #if !GA_PRIMITIVE_VERTEXLIST
775 fpreal myTaperX, myTaperY;
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
virtual void flushCECaches()
serialize getSerialize() const
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
virtual UT_Vector3 baryCenter() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
virtual void clearForDeletion()
UT_VoxelArrayHandleF myVoxelHandle
Used to pass options and map offset values during saving.
bool loadVoxelDataH9(UT_IStream &is, UT_VoxelArrayWriteHandleF voxels, int version)
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
virtual void copySubclassData(const GA_Primitive *source)
GLuint const GLfloat * val
void setVisOptions(const GEO_VolumeOptions &vis)
GLenum GLenum GLenum GLenum GLenum scale
int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const override
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
fpreal getVisDensity() const
const GEO_VolumeOptions & getVisOptions() const
static GA_PrimitiveFamilyMask buildFamilyMask()
void reverse() override
Reverse the order of vertices.
GA_Offset vertexPoint() const
GLsizei GLsizei GLchar * source
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)
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
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
UT_VoxelArrayHandleF & getMyVoxelHandle() const
Gets the handle to our voxels.
void setTransform(const UT_Matrix3 &m)
bool hasBorrowedCEGrid() const
GLint GLenum GLsizei GLint GLsizei const void * data
const GLuint GLenum const void * binary
GLint GLint GLsizei GLsizei GLsizei GLint border
const UT_Matrix3 & getInverseTransform() const
Converts from world space to local space.
GLubyte GLubyte GLubyte GLubyte w
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)
fpreal getBorderValue() const
A handle to simplify manipulation of multiple attributes.
virtual int getBBox(UT_BoundingBox *bbox) const =0
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 &)
GLdouble GLdouble GLdouble b
virtual void enlargePointBounds(UT_BoundingBox &box) const
virtual void getLocalTransform(UT_Matrix3D &matrix) const
virtual bool loadPrivateH9(UT_IStream &is)
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().
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
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
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