Microflow 3D  v1.0
MF::Database::GridVDB< T_VDBGridType > Class Template Reference

The GridVDB class provides some additional functionalities to standard VDB grid object. It is used for storage of sparse geometry points. More...

#include <GridVDB.h>

Public Member Functions

 GridVDB ()=default
 
 ~GridVDB ()=default
 
std::shared_ptr< T_VDBGridType > getVDBGridPtr ()
 
void setGridName (const std::string &GridName)
 Returns a VDBGrid_Ptr. More...
 
void insertMetaDataFloat (const std::string &MetaName, float value)
 Adds a grid name to a VDBGrid. More...
 
void insertMetaDataInt (const std::string &MetaName, int32_t value)
 Adds a float metadata to a VDBGrid. More...
 
void insertMetaDataDouble (const std::string &MetaName, double value)
 Adds a int metadata to a VDBGrid. More...
 
void insertMetaDataString (const std::string &MetaName, const std::string &string)
 Adds a double metadata to a VDBGrid. More...
 
template<typename T_ValueType >
const T_ValueType & getMetaData (const std::string &MetaName)
 Adds a string metadata to a VDBGrid. More...
 
void setGridToFogVolume (bool voxelizeActiveTiles=false)
 Returns the metadata of a type T_ValueType = <int>, <double>, <string> from VDBGrid. More...
 
void setGridBackgroundValue (float value)
 
T_VDBGridType getGridNewCopy ()
 Sets the background value of a VDBGrid. More...
 
void saveToVDBFile (const std::string &FileName)
 Copies of a VDBGrid. More...
 
template<typename T1_VTKArrayType >
void saveToVTIFile (const std::string &FileName, const std::string &DataName, int numComponents, float voxelSize)
 Saves data stored in VDB grid to a file. More...
 
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 data stored in MFThreads. More...
 

Static Public Member Functions

static std::shared_ptr< MF::Database::GridVDB< T_VDBGridType > > New ()
 

Detailed Description

template<class T_VDBGridType>
class MF::Database::GridVDB< T_VDBGridType >

The GridVDB class provides some additional functionalities to standard VDB grid object. It is used for storage of sparse geometry points.

In addition to basic operations od VDB grid available also in VDBGridOperations.h, the GridVDB object supports automatic data save to VDB and VTI files.

Parameters
template<classT_VDBGridType> = <openvdb::FloatGrid>, <openvdb::Int32Grid>, <openvdb::DobleGrid> etc.

Definition at line 31 of file GridVDB.h.

Constructor & Destructor Documentation

◆ GridVDB()

template<class T_VDBGridType >
MF::Database::GridVDB< T_VDBGridType >::GridVDB ( )
default

◆ ~GridVDB()

template<class T_VDBGridType >
MF::Database::GridVDB< T_VDBGridType >::~GridVDB ( )
default

Member Function Documentation

◆ getGridNewCopy()

template<class T_VDBGridType >
T_VDBGridType MF::Database::GridVDB< T_VDBGridType >::getGridNewCopy ( )
inline

Sets the background value of a VDBGrid.

Definition at line 62 of file GridVDB.h.

62 { return m_VDBGrid_Ptr->deepCopy(); };

◆ getMetaData()

template<class T_VDBGridType >
template<typename T_ValueType >
const T_ValueType& MF::Database::GridVDB< T_VDBGridType >::getMetaData ( const std::string &  MetaName)
inline

Adds a string metadata to a VDBGrid.

Definition at line 55 of file GridVDB.h.

55 { return m_VDBGrid_Ptr->template metaValue<T_ValueType>(MetaName); };

◆ getVDBGridPtr()

template<class T_VDBGridType >
std::shared_ptr<T_VDBGridType> MF::Database::GridVDB< T_VDBGridType >::getVDBGridPtr ( )
inline

Definition at line 42 of file GridVDB.h.

42 {return m_VDBGrid_Ptr;};

◆ insertMetaDataDouble()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::insertMetaDataDouble ( const std::string &  MetaName,
double  value 
)
inline

Adds a int metadata to a VDBGrid.

Definition at line 50 of file GridVDB.h.

50 {m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::DoubleMetadata(value));};

◆ insertMetaDataFloat()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::insertMetaDataFloat ( const std::string &  MetaName,
float  value 
)
inline

Adds a grid name to a VDBGrid.

Definition at line 46 of file GridVDB.h.

46 { m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::FloatMetadata(value));};

◆ insertMetaDataInt()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::insertMetaDataInt ( const std::string &  MetaName,
int32_t  value 
)
inline

Adds a float metadata to a VDBGrid.

Definition at line 48 of file GridVDB.h.

48 { m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::Int32Metadata(value));};

◆ insertMetaDataString()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::insertMetaDataString ( const std::string &  MetaName,
const std::string &  string 
)
inline

Adds a double metadata to a VDBGrid.

Definition at line 52 of file GridVDB.h.

52 {m_VDBGrid_Ptr->insertMeta(MetaName, openvdb::StringMetadata(string)); };

◆ New()

template<class T_VDBGridType >
static std::shared_ptr<MF::Database::GridVDB<T_VDBGridType> > MF::Database::GridVDB< T_VDBGridType >::New ( )
inlinestatic

Definition at line 36 of file GridVDB.h.

Referenced by MF::GB::GeometryBuildFromSTL::Clean().

36  {
37  auto newGrid_Ptr = std::make_shared<MF::Database::GridVDB<T_VDBGridType>>();
38  newGrid_Ptr->m_VDBGrid_Ptr = T_VDBGridType::create();
39  return newGrid_Ptr;
40  }

◆ saveAllDataToVTIFile()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::saveAllDataToVTIFile ( const std::shared_ptr< MF::Database::ThreadArray > &  ThreadArray_Ptr,
const std::shared_ptr< MF::Database::ConfigData > &  ConfigData_Ptr,
const std::string &  FileName 
)
inline

Saves all data specified in the case_params.cfg file to .vti file. Parameters are calculated from data stored in MFThreads.

Definition at line 76 of file GridVDB.h.

References MF::RW::VTIWriter< T_VDBGridType >::New().

77  {
78  double PhysVoxelSize = ConfigData_Ptr->getCaseFloatParam("GeometryParams.PhysicalVoxelSize");
79  auto w = MF::RW::VTIWriter<T_VDBGridType>::New(m_VDBGrid_Ptr, FileName, PhysVoxelSize);
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);
108  w->writeFile();
109  };
static std::shared_ptr< MF::RW::VTIWriter< T_VDBGridType > > New(std::shared_ptr< T_VDBGridType > VDBGrid_Ptr, const std::string &FileName, float voxelSize)
Definition: VTIWriter.h:62

◆ saveToVDBFile()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::saveToVDBFile ( const std::string &  FileName)
inline

Copies of a VDBGrid.

Definition at line 64 of file GridVDB.h.

References MF::RW::VDBWriter< T_VDBGridType >::New().

64 {auto w = MF::RW::VDBWriter<T_VDBGridType>::New(m_VDBGrid_Ptr, FileName);};
static std::shared_ptr< MF::RW::VDBWriter< T_VDBGridType > > New(const std::shared_ptr< T_VDBGridType > &Grid_Ptr, const std::string &FileName)
Definition: VDBWriter.h:40

◆ saveToVTIFile()

template<class T_VDBGridType >
template<typename T1_VTKArrayType >
void MF::Database::GridVDB< T_VDBGridType >::saveToVTIFile ( const std::string &  FileName,
const std::string &  DataName,
int  numComponents,
float  voxelSize 
)
inline

Saves data stored in VDB grid to a file.

Saves data stored in VDB grid do .vti file.

Definition at line 68 of file GridVDB.h.

References MF::RW::VTIWriter< T_VDBGridType >::New().

68  {
69  auto w = MF::RW::VTIWriter<T_VDBGridType>::New(m_VDBGrid_Ptr, FileName, voxelSize);
70  w->template addDataFromGrid<T1_VTKArrayType>(DataName,numComponents);
71  w->addNodeCoordinateFromGrid();
72  w->writeFile();
73  };
static std::shared_ptr< MF::RW::VTIWriter< T_VDBGridType > > New(std::shared_ptr< T_VDBGridType > VDBGrid_Ptr, const std::string &FileName, float voxelSize)
Definition: VTIWriter.h:62

◆ setGridBackgroundValue()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::setGridBackgroundValue ( float  value)
inline

Definition at line 60 of file GridVDB.h.

60 { openvdb::tools::changeBackground(m_VDBGrid_Ptr->tree(), value); };

◆ setGridName()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::setGridName ( const std::string &  GridName)
inline

Returns a VDBGrid_Ptr.

Definition at line 44 of file GridVDB.h.

44 { m_VDBGrid_Ptr->setName(GridName);};

◆ setGridToFogVolume()

template<class T_VDBGridType >
void MF::Database::GridVDB< T_VDBGridType >::setGridToFogVolume ( bool  voxelizeActiveTiles = false)
inline

Returns the metadata of a type T_ValueType = <int>, <double>, <string> from VDBGrid.

< Changes the VDBGrid to a FogVolume type.

Definition at line 57 of file GridVDB.h.

57  {openvdb::tools::sdfToFogVolume(m_VDBGrid_Ptr);
58  if (voxelizeActiveTiles) m_VDBGrid_Ptr->treePtr()->voxelizeActiveTiles();};

The documentation for this class was generated from the following file: