Microflow 3D  v1.0
StlMesher.h
Go to the documentation of this file.
1 // ==============================================================================================
2 // Microflow 3D, http://www.microflow.pwr.edu.pl/
3 // Created by Roman Szafran on 15.03.19.
4 // Copyright (c) 2019 Wroclaw University of Science and Technology.
5 // Distributed under the Apache License, Version 2.0. You may obtain a copy of the License at
6 // http://www.apache.org/licenses/LICENSE-2.0 or see accompanying file license.txt.
7 // Redistributions of source code must retain the above copyright and license notice.
8 // ==============================================================================================
9 
10 #pragma once
11 
12 #include <iostream>
13 
14 #include <openvdb/openvdb.h>
15 #include <openvdb/tools/MeshToVolume.h>
16 #include <openvdb/tools/ChangeBackground.h>
17 #include <openvdb/tools/LevelSetUtil.h>
18 #include <openvdb/tools/Composite.h>
19 
20 #include "STLReader.h"
21 #include "VDBWriter.h"
22 
23 namespace MF {
24  namespace GB {
25 
27  class StlMesher {
28  public:
29  StlMesher() = default;
30  ~StlMesher() = default;
31 
32  static std::shared_ptr<MF::GB::StlMesher> New(const std::string &fileName, const double voxelSize, const bool verbose = false) {
33  auto StlMesher_Ptr = std::make_shared<MF::GB::StlMesher>();
34  StlMesher_Ptr->m_VDBGridPtr = StlMesher_Ptr->readSTLGrid(fileName, voxelSize, verbose);
35  return StlMesher_Ptr;
36  };
37 
38  openvdb::FloatGrid::Ptr readSTLGrid(const std::string &fileName, double voxelSize, bool verbose = false);
39 
40  inline openvdb::FloatGrid::Ptr getVDBGrid_Ptr() { return m_VDBGridPtr; }
41 
42  private:
43  openvdb::FloatGrid::Ptr m_VDBGridPtr;
44  };
45 
46  } /* namespace GB */
47 } /* namespase MF */
48 
~StlMesher()=default
openvdb::FloatGrid::Ptr readSTLGrid(const std::string &fileName, double voxelSize, bool verbose=false)
Reads .stl file with tyti stl reader.
Definition: StlMesher.cpp:12
static std::shared_ptr< MF::GB::StlMesher > New(const std::string &fileName, const double voxelSize, const bool verbose=false)
Definition: StlMesher.h:32
StlMesher()=default
openvdb::FloatGrid::Ptr getVDBGrid_Ptr()
Returns VDBGrid shared Ptr.
Definition: StlMesher.h:40
Converts surface mesh to volumetric grid with constant voxelSize spacing.
Definition: StlMesher.h:27