11 #ifndef __GEO_PrimVolume__
12 #define __GEO_PrimVolume__
64 float u,
float v=0,
float w=0)
const override;
93 std::ostream &os,
bool binary,
109 bool loadStorageType(
const char *storagename);
125 static const int theSharedVoxelMagic=(
'V'<<24)|(
'o'<<16)|(
'x'<<8)|(
'l');
135 allocateSharedDataLoader();
185 bool dry_run=
false)
override;
187 bool dry_run=
false)
override;
194 float ulength,
float vlength,
195 float &uparm,
float &vparm)
const override;
197 float ulength,
float vlength,
198 float &uparm,
float &vparm,
199 float tolerance)
const override;
202 float uparm,
float vparm,
203 float &ulength,
float &vlength)
const override;
211 #if GA_PRIMITIVE_VERTEXLIST
226 void assignVertex(
GA_Offset new_vtx,
bool update_topology);
229 void stashed(
bool beingstashed,
235 void setTupleSize(
int comps);
241 void setStoresIntegers(
bool ints);
246 StorageType getStorageType()
const;
249 void setStorageType(StorageType store);
253 {
return getTupleSize() == 1 && getStoresIntegers() ==
false; }
272 void getInverseTransform4(
UT_Matrix4 &matx)
const;
285 bool isWorldAxisAligned()
const;
297 template <
typename T>
338 return getVoxelHandle();
345 template <
typename BASE>
348 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
349 return getVoxelHandleV4();
350 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
351 return getVoxelHandleV3();
352 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
353 return getVoxelHandleV2();
354 if constexpr (SYS_IsSame_v<float, BASE>)
355 return getVoxelHandleF();
356 if constexpr (SYS_IsSame_v<int64, BASE>)
357 return getVoxelHandleI();
360 template <
typename BASE>
367 template <
typename BASE>
370 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
371 return getVoxelWriteHandleV4();
372 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
373 return getVoxelWriteHandleV3();
374 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
375 return getVoxelWriteHandleV2();
376 if constexpr (SYS_IsSame_v<float, BASE>)
377 return getVoxelWriteHandleF();
378 if constexpr (SYS_IsSame_v<int64, BASE>)
379 return getVoxelWriteHandleI();
386 template <
typename BASE =
float>
389 if constexpr (SYS_IsSame_v<UT_Vector4, BASE>)
390 return myVoxelHandleP;
391 if constexpr (SYS_IsSame_v<UT_Vector3, BASE>)
392 return myVoxelHandleV;
393 if constexpr (SYS_IsSame_v<UT_Vector2, BASE>)
394 return myVoxelHandleU;
395 if constexpr (SYS_IsSame_v<float, BASE>)
396 return myVoxelHandleF;
397 if constexpr (SYS_IsSame_v<int64, BASE>)
398 return myVoxelHandleI;
405 return getVoxelWriteHandle();
417 template <
typename OP>
418 void dispatchToReadHandle(OP&
op)
const;
427 template <
typename OP>
428 void dispatchToWriteHandle(OP&
op,
bool force_load);
430 template <
typename OP>
432 { dispatch(getStorageType(), op); }
434 template <
typename OP>
439 case VOLUME_TYPE_FLOAT:
op((
float) 0);
break;
442 case VOLUME_TYPE_VECTOR4:
op(
UT_Vector4(0,0,0,0));
break;
443 case VOLUME_TYPE_INTEGER:
op((
int64) 0);
break;
464 template <
typename T>
469 bool isIndexInside(
int x,
int y,
int z)
const;
471 template <
typename T>
472 bool isIndexInside(
int x,
int y,
int z,
477 bool posToIndex(
UT_Vector3 pos,
int &
x,
int &
y,
int &
z)
const;
502 template <
typename TYPE>
505 return getValueByType<TYPE>(pos, getVoxelHandleByType<TYPE>());
507 template <
typename TYPE>
510 if constexpr (SYSisSame<TYPE, float>())
517 localpos = toVoxelSpace(pos);
520 return (*vox)(localpos);
525 fpreal getValueAtIndex(
int ix,
int iy,
int iz)
const;
526 void getValuesAtIndices(
float *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
527 void getValuesAtIndices(
int *
f,
int stride,
const int *ix,
const int *iy,
const int *iz,
int num)
const;
528 void getValuesAtIndices(
double *
f,
int stride,
const exint *ix,
const exint *iy,
const exint *iz,
int num)
const;
531 void getRes(
int &rx,
int &ry,
int &rz)
const;
535 fpreal getVoxelDiameter()
const;
542 fpreal calcPositiveDensity()
const;
545 fpreal calcMinimum(
int channel = 0)
const;
546 fpreal calcMaximum(
int channel = 0)
const;
547 fpreal calcAverage(
int channel = 0)
const;
548 exint calcMinimumI(
int channel = 0)
const;
549 exint calcMaximumI(
int channel = 0)
const;
554 bool isSDF()
const {
return myIsSDF; }
558 bool computeHeightFieldProperties(
int &a1,
int &a2,
int &axis,
fpreal &
scale)
const;
567 fpreal getBorderValue(
int component = 0)
const;
571 bool hasWindow()
const;
590 void createDefaultWindow();
605 fpreal getCompressionTolerance()
const;
606 void setCompressionTolerance(
fpreal tol);
629 template <
typename T>
640 if (index >= 0 && index < myEntries)
642 exint tuple = index % myTupleSize;
644 index /= myTupleSize;
647 index = (index -
x) / myXres;
649 index = (index -
y) / myYres;
666 bool atEnd()
const {
return myCurr >= myEntries; }
678 : myVoxels(prim.getVoxelHandleByType<
T>())
681 prim.
getRes(myXres, myYres, myZres);
684 myEntries = myXres*myYres*myZres * myTupleSize;
689 exint myCurr = 0, myEntries = 0;
690 int myXres = 0, myYres = 0, myZres = 0;
697 template <
typename T>
776 #if !GA_PRIMITIVE_VERTEXLIST
780 #if !GA_PRIMITIVE_VERTEXLIST
847 float u,
float v = 0,
848 unsigned du=0,
unsigned dv=0)
const override
866 #if !GA_PRIMITIVE_VERTEXLIST
878 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()
UT_Vector3D myWindowVoxelScale
#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
GA_API const UT_StringHolder rot
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
virtual void clearCECaches()
Clear all caches from the GPU, without copying any data to the CPU.
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.
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.
UT_Vector3D myDisplayWindowSize
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
GA_API const UT_StringHolder parms
#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
bool getLayerCameraParms(UT_CameraParms &parms, UT_Vector3D &pos, UT_Matrix3D &rot) const
GLint GLint GLsizei GLint border
UT_Vector3D myDisplayWindowOffset
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
virtual void copyCEBuffers(const GA_Primitive *src)
Copy the underlying CE buffer from the source.
void setBorrowedIMXLayer(const UT_SharedPtr< IMX_Layer > &l)
UT_VoxelArrayHandleV2 myVoxelHandleU
UT_Vector3D myDataWindowOffset
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)
size_t UTformatBuffer(char *buf, size_t bufsize, const GEO_PrimVolume::StorageType &v)