13 #include <openvdb/openvdb.h> 30 template<
class T_VDBGr
idType>
36 static std::shared_ptr<MF::Database::GridVDB<T_VDBGridType>>
New() {
37 auto newGrid_Ptr = std::make_shared<MF::Database::GridVDB<T_VDBGridType>>();
38 newGrid_Ptr->m_VDBGrid_Ptr = T_VDBGridType::create();
44 inline void setGridName(
const std::string &GridName) { m_VDBGrid_Ptr->setName(GridName);};
46 inline void insertMetaDataFloat(
const std::string &MetaName,
float value) { m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::FloatMetadata(value));};
48 inline void insertMetaDataInt(
const std::string &MetaName, int32_t value) { m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::Int32Metadata(value));};
50 inline void insertMetaDataDouble(
const std::string &MetaName,
double value) {m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::DoubleMetadata(value));};
52 inline void insertMetaDataString(
const std::string &MetaName,
const std::string &
string) {m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::StringMetadata(
string)); };
54 template <
typename T_ValueType>
55 const T_ValueType &
getMetaData(
const std::string &MetaName) {
return m_VDBGrid_Ptr->template metaValue<T_ValueType>(MetaName); };
57 inline void setGridToFogVolume(
bool voxelizeActiveTiles =
false) {openvdb::tools::sdfToFogVolume(m_VDBGrid_Ptr);
58 if (voxelizeActiveTiles) m_VDBGrid_Ptr->treePtr()->voxelizeActiveTiles();};
67 template<
typename T1_VTKArrayType>
68 void saveToVTIFile(
const std::string &FileName,
const std::string &DataName,
int numComponents,
float voxelSize) {
70 w->template addDataFromGrid<T1_VTKArrayType>(DataName,numComponents);
71 w->addNodeCoordinateFromGrid();
76 void saveAllDataToVTIFile(
const std::shared_ptr<MF::Database::ThreadArray> & ThreadArray_Ptr,
const std::shared_ptr<MF::Database::ConfigData>& ConfigData_Ptr,
77 const std::string &FileName) {
78 double PhysVoxelSize = ConfigData_Ptr->getCaseFloatParam(
"GeometryParams.PhysicalVoxelSize");
80 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.NodeID_Save"))
81 w->addNodeIDFromGrid();
82 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.NodeUidThread_Save"))
83 w->addUidThreadFromThread(ThreadArray_Ptr);
84 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.NodeType_Save"))
85 w->addNodeTypeFromThread(ThreadArray_Ptr);
86 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.NodeCoordinate_Save"))
87 w->addNodeCoordinateFromThread(ThreadArray_Ptr);
88 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.VelocityLB_Save"))
89 w->addVelocityLBFromThread(ThreadArray_Ptr);
90 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.RhoLB_Save"))
91 w->addRhoLBFromThread(ThreadArray_Ptr);
92 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.RhoPhys_Save"))
93 w->addRhoPhysFromThread(ThreadArray_Ptr);
94 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.PressurePhys_Save"))
95 w->addPressPhysFromThread(ThreadArray_Ptr);
96 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.VelocityPhys_Save"))
97 w->addVelocityPhysFromThread(ThreadArray_Ptr);
98 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.FQ19_Save"))
99 w->addFQ19FromThread(ThreadArray_Ptr);
100 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.PropagationDirections_Save"))
101 w->addPropagationDirFromThread(ThreadArray_Ptr);
102 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.InitialVelocityLB_Save"))
103 w->addInitialVelocityLBFromThread(ThreadArray_Ptr);
104 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.InitialRhoLB_Save"))
105 w->addInitialRhoLBFromThread(ThreadArray_Ptr);
106 if (ConfigData_Ptr->getCaseBooleanParam(
"VTKFileParams.ThreadsNamed_Save"))
107 w->addNodeThreadsByNameThread(ThreadArray_Ptr);
112 std::shared_ptr<T_VDBGridType> m_VDBGrid_Ptr;
void insertMetaDataFloat(const std::string &MetaName, float value)
Adds a grid name to a VDBGrid.
void insertMetaDataInt(const std::string &MetaName, int32_t value)
Adds a float metadata to a VDBGrid.
void setGridName(const std::string &GridName)
Returns a VDBGrid_Ptr.
static std::shared_ptr< MF::Database::GridVDB< T_VDBGridType > > New()
void saveAllDataToVTIFile(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr, const std::shared_ptr< MF::Database::ConfigData > &ConfigData_Ptr, const std::string &FileName)
Saves all data specified in the case_params.cfg file to .vti file. Parameters are calculated from dat...
void setGridToFogVolume(bool voxelizeActiveTiles=false)
Returns the metadata of a type T_ValueType = <int>, <double>, <string> from VDBGrid.
void setGridBackgroundValue(float value)
void insertMetaDataDouble(const std::string &MetaName, double value)
Adds a int metadata to a VDBGrid.
void insertMetaDataString(const std::string &MetaName, const std::string &string)
Adds a double metadata to a VDBGrid.
T_VDBGridType getGridNewCopy()
Sets the background value of a VDBGrid.
The GridVDB class provides some additional functionalities to standard VDB grid object. It is used for storage of sparse geometry points.
const T_ValueType & getMetaData(const std::string &MetaName)
Adds a string metadata to a VDBGrid.
static std::shared_ptr< MF::RW::VDBWriter< T_VDBGridType > > New(const std::shared_ptr< T_VDBGridType > &Grid_Ptr, const std::string &FileName)
static std::shared_ptr< MF::RW::VTIWriter< T_VDBGridType > > New(std::shared_ptr< T_VDBGridType > VDBGrid_Ptr, const std::string &FileName, float voxelSize)
void saveToVTIFile(const std::string &FileName, const std::string &DataName, int numComponents, float voxelSize)
Saves data stored in VDB grid to a file.
std::shared_ptr< T_VDBGridType > getVDBGridPtr()
void saveToVDBFile(const std::string &FileName)
Copies of a VDBGrid.