11 #ifndef __GEO_PrimVolume__
12 #define __GEO_PrimVolume__
63 float u,
float v=0,
float w=0)
const override;
92 std::ostream &os,
bool binary,
108 bool loadStorageType(
const char *storagename);
124 static const int theSharedVoxelMagic=(
'V'<<24)|(
'o'<<16)|(
'x'<<8)|(
'l');
134 allocateSharedDataLoader();
184 bool dry_run=
false)
override;
186 bool dry_run=
false)
override;
193 float ulength,
float vlength,
194 float &uparm,
float &vparm)
const override;
196 float ulength,
float vlength,
197 float &uparm,
float &vparm,
198 float tolerance)
const override;
201 float uparm,
float vparm,
202 float &ulength,
float &vlength)
const override;
210 #if GA_PRIMITIVE_VERTEXLIST
225 void assignVertex(
GA_Offset new_vtx,
bool update_topology);
228 void stashed(
bool beingstashed,
234 void setTupleSize(
int comps);
240 void setStoresIntegers(
bool ints);
245 StorageType getStorageType()
const;
248 void setStorageType(StorageType store);
252 {
return getTupleSize() == 1 && getStoresIntegers() ==
false; }
271 void getInverseTransform4(
UT_Matrix4 &matx)
const;
284 bool isWorldAxisAligned()
const;
296 template <
typename T>
337 return getVoxelHandle();
344 template <
typename BASE>
347 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
348 return getVoxelHandleV4();
349 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
350 return getVoxelHandleV3();
351 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
352 return getVoxelHandleV2();
353 if constexpr (SYS_IsSame_v<float, BASE>)
354 return getVoxelHandleF();
355 if constexpr (SYS_IsSame_v<int64, BASE>)
356 return getVoxelHandleI();
359 template <
typename BASE>
366 template <
typename BASE>
369 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
370 return getVoxelWriteHandleV4();
371 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
372 return getVoxelWriteHandleV3();
373 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
374 return getVoxelWriteHandleV2();
375 if constexpr (SYS_IsSame_v<float, BASE>)
376 return getVoxelWriteHandleF();
377 if constexpr (SYS_IsSame_v<int64, BASE>)
378 return getVoxelWriteHandleI();
385 template <
typename BASE =
float>
388 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
389 return myVoxelHandleP;
390 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
391 return myVoxelHandleV;
392 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
393 return myVoxelHandleU;
394 if constexpr (SYS_IsSame_v<float, BASE>)
395 return myVoxelHandleF;
396 if constexpr (SYS_IsSame_v<int64, BASE>)
397 return myVoxelHandleI;
404 return getVoxelWriteHandle();
416 template <
typename OP>
417 void dispatchToReadHandle(OP&
op)
const;
426 template <
typename OP>
427 void dispatchToWriteHandle(OP&
op,
bool force_load);
429 template <
typename OP>
431 { dispatch(getStorageType(), op); }
433 template <
typename OP>
438 case VOLUME_TYPE_FLOAT:
op((
float) 0);
break;
441 case VOLUME_TYPE_VECTOR4:
op(
UT_Vector4(0,0,0,0));
break;
442 case VOLUME_TYPE_INTEGER:
op((
int64) 0);
break;
463 template <
typename T>
468 bool isIndexInside(
int x,
int y,
int z)
const;
470 template <
typename T>
471 bool isIndexInside(
int x,
int y,
int z,
476 bool posToIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
501 template <
typename TYPE>
504 return getValueByType<TYPE>(pos, getVoxelHandleByType<TYPE>());
506 template <
typename TYPE>
509 if constexpr (SYSisSame<TYPE, float>())
516 localpos = toVoxelSpace(pos);
519 return (*vox)(localpos);
524 fpreal getValueAtIndex(
int ix,
int iy,
int iz)
const;
525 void getValuesAtIndices(
float *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
526 void getValuesAtIndices(
int *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
527 void getValuesAtIndices(
double *
f,
int stride,
const exint *ix,
const exint *iy,
const exint *iz,
int num)
const;
530 void getRes(
int &rx,
int &ry,
int &rz)
const;
534 fpreal getVoxelDiameter()
const;
541 fpreal calcPositiveDensity()
const;
544 fpreal calcMinimum()
const;
545 fpreal calcMaximum()
const;
546 fpreal calcAverage()
const;
551 bool isSDF()
const {
return myIsSDF; }
555 bool computeHeightFieldProperties(
int &a1,
int &a2,
int &axis,
fpreal &
scale)
const;
564 fpreal getBorderValue(
int component = 0)
const;
568 fpreal getCompressionTolerance()
const;
569 void setCompressionTolerance(
fpreal tol);
592 template <
typename T>
603 if (index >= 0 && index < myEntries)
605 exint tuple = index % myTupleSize;
607 index /= myTupleSize;
610 index = (index -
x) / myXres;
612 index = (index -
y) / myYres;
629 bool atEnd()
const {
return myCurr >= myEntries; }
641 : myVoxels(prim.getVoxelHandleByType<
T>())
644 prim.
getRes(myXres, myYres, myZres);
647 myEntries = myXres*myYres*myZres * myTupleSize;
652 exint myCurr = 0, myEntries = 0;
653 int myXres = 0, myYres = 0, myZres = 0;
660 template <
typename T>
727 #if !GA_PRIMITIVE_VERTEXLIST
731 #if !GA_PRIMITIVE_VERTEXLIST
792 float u,
float v = 0,
793 unsigned du=0,
unsigned dv=0)
const override
811 #if !GA_PRIMITIVE_VERTEXLIST
823 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
GLenum GLuint GLenum GLsizei const GLchar * buf
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
GLenum GLuint GLsizei bufsize
virtual UT_Vector3 baryCenter() const
UT_SharedPtr< IMX_Layer > getIMXLayer(bool read, bool write) const
UT_COWHandle< UT_VoxelArray< BASE > > getHandleToVoxelsWithoutLoading() const
virtual void copyPrimitive(const GEO_Primitive *src)=0
void initIMXLayer(IMX_Layer &layer, bool data_too=false) const
virtual void clearForDeletion()
Used to pass options and map offset values during saving.
bool loadVoxelDataH9(UT_IStream &is, UT_VoxelArrayWriteHandleF voxels, int version)
bool isFullyLoaded() const
UT_Vector2T< float > UT_Vector2
UT_VoxelArrayHandleV4 myVoxelHandleP
TYPE getValueByType(const UT_Vector3 &pos, const UT_VoxelArrayReadHandle< TYPE > &vox) const
virtual UT_Vector3D computeNormalD() const =0
getFileOption("OpenEXR:storage") storage
UT_VoxelArrayHandleV2 & getMyVoxelHandleV2() const
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
virtual void copySubclassData(const GA_Primitive *source)
GLsizei const GLfloat * value
void setVisOptions(const GEO_VolumeOptions &vis)
bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *p) const override
bool myCEGridAuthoritative
static void dispatch(StorageType storage, const OP &op)
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
GLdouble GLdouble GLdouble z
SYS_FORCE_INLINE UT_Vector3 getPos3() const
virtual bool saveSharedLoadData(UT_JSONWriter &w, GA_SaveMap &save, GA_GeometryIndex *geo_index) const
fpreal getVisDensity() const
void resetAndAllocateHandles()
UT_COWReadHandle< UT_VoxelArray< BASE > > getVoxelReadHandleByType() 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)
Class which writes ASCII or binary JSON streams.
Abstract base class for a range membership query object.
GEO_API const char * GEOgetVolumeStorageTypeToken(GEO_PrimVolume::StorageType type)
Returns string token from the StorageType enum value.
virtual bool savePrivateH9(std::ostream &os, bool binary) const
int getTupleSize() const
Returns the number of components (or the tuple size) for this volume.
fpreal calcArea() const override
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
UT_VoxelArrayHandleV4 & getMyVoxelHandleV4() const
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.
UT_VoxelArrayHandleV3 myVoxelHandleV
#define GA_INVALID_OFFSET
serializeT & operator++()
__hostdev__ float getValue(uint32_t i) const
UT_VoxelArrayWriteHandleF getVoxelWriteHandleF()
GLenum GLuint GLint GLint layer
friend std::ostream & operator<<(std::ostream &os, const GEO_PrimVolume &d)
virtual bool isDegenerate() const =0
Is the primitive degenerate.
fpreal getVisTiles() const
virtual bool enlargeBoundingSphere(UT_BoundingSphere &b, const GA_Attribute *P) const
const UT_Matrix3 & getTransform() const
GA_API const UT_StringHolder scale
UT_VoxelArrayHandleV3 & getMyVoxelHandleV3() 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.
GLint GLint GLsizei GLint GLenum GLenum type
UT_VoxelArrayHandleF & getMyVoxelHandleF() const
Gets the handle to our voxels.
UT_Vector4T< float > UT_Vector4
TYPE getValueByType(const UT_Vector3 &pos) const
Class to load shared data.
serializeT< float > serialize
virtual int evaluateInteriorPointV4(UT_Vector4 &pos, fpreal u, fpreal v, fpreal w=0) const
GEO_VolumeTypeInfo getTypeInfo() const
void setTransform(const UT_Matrix3 &m)
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
bool hasBorrowedCEGrid() const
const UT_Matrix3 & getInverseTransform() const
Converts from world space to local space.
GLint GLint GLsizei GLint GLenum format
virtual const GA_PrimitiveJSON * getJSON() const =0
GLsizei GLsizei GLchar * source
Provide a JSON interface to a primitive.
GLint GLenum GLboolean GLsizei stride
UT_COWWriteHandle< UT_VoxelArray< BASE > > getVoxelWriteHandleByType()
void setBorrowedCEGrid(CE_Grid *grid)
A handle to simplify manipulation of multiple attributes.
Defragmentation of IndexMaps.
bool getStoresIntegers() const
Returns true if this volume stores integers.
GLboolean GLboolean GLboolean b
serializeT< T > getSerializeByType() const
bool saveH9(std::ostream &os, bool binary, const UT_Array< GA_AttribSaveDataH9 > &prim_attribs, const UT_Array< GA_AttribSaveDataH9 > &vtx_attribs) const override
fpreal getBorderValue(int component=0) const
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
UT_COWHandle< UT_VoxelArray< BASE > > getVoxelHandleByType() const
UT_VoxelArrayHandleF getVoxelHandleF() const
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
#define SCALAR(T)
Simplify checking for scalar types.
bool myIMXLayerAuthoritative
virtual bool loadPrivateH9(UT_IStream &is)
UT_VoxelArrayHandleF myVoxelHandleF
void setVertexPoint(GA_Offset pt)
virtual int detachPoints(GA_PointGroup &grp)=0
GLint GLint GLsizei GLint border
fpreal getVoxel(exint index) const
Random access of a voxel value.
static const UT_Array< GA_AttribSaveDataH9 > & theEmptySaveAttribs
Convience objects to pass as arguments to saveH9()/loadH9().
UT_SharedPtr< IMX_Layer > myIMXLayer
If this is not null, then the data on it is clean.
virtual bool getBBox(UT_BoundingBox *bbox) const =0
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
void setVisTiles(fpreal tiles)
virtual void addToBSphere(UT_BoundingSphere *bsphere) const
void setTypeInfo(GEO_VolumeTypeInfo info)
SYS_FORCE_INLINE GA_Offset getPointOffset() const
GLubyte GLubyte GLubyte GLubyte w
void setBorrowedIMXLayer(const UT_SharedPtr< IMX_Layer > &l)
UT_VoxelArrayHandleV2 myVoxelHandleU
UT_VoxelArrayHandleI myVoxelHandleI
virtual bool registerSharedLoadData(int load_data_type, GA_SharedDataHandlePtr item)
UT_VoxelArrayHandleI & getMyVoxelHandleI() const
void getRes(int &rx, int &ry, int &rz) const
Returns the resolution of the voxel array.
GEO_API GEO_PrimVolume::StorageType GEOgetVolumeStorageTypeEnum(const char *token, GEO_PrimVolume::StorageType def)
void dispatch(const OP &op) const
bool isScalarVolume() const
True if this is a traditional scalar volume.
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)