15 auto STLGrid = std::make_unique<MF::RW::STLReaderTyti>(fileName, verbose);
18 static openvdb::math::Transform::Ptr transformer = {
19 openvdb::math::Transform::createLinearTransform(voxelSize)};
23 const std::vector<tyti::stl::vec3> in_vertices;
24 const double in_voxelSize;
26 MeshAdapter(tyti::stl::basic_solid<float> &grid,
const double voxelSize) : in_vertices(grid.vertices), in_voxelSize(voxelSize) {}
27 size_t pointCount()
const {
return in_vertices.size(); }
28 size_t vertexCount(
size_t n)
const {
return 3; }
29 size_t vertexCount()
const {
return 3; }
30 size_t polygonCount()
const {
return pointCount() / vertexCount(); }
33 void getIndexSpacePoint(
size_t n,
size_t v, openvdb::Vec3d &pos)
const {
34 const size_t offset = 3 * n + v;
35 const openvdb::Vec3d &vertex = {in_vertices[offset].data[0], in_vertices[offset].data[1],
36 in_vertices[offset].data[2]};
37 pos = transformer->worldToIndexCellCentered(vertex).asVec3d();
42 const MeshAdapter mesh_adapter(STLGrid->getSTLGrid_ref().first, voxelSize);
44 m_VDBGridPtr = openvdb::tools::meshToVolume<openvdb::FloatGrid, MeshAdapter>(mesh_adapter, *transformer, 3.0, 3.0);
openvdb::FloatGrid::Ptr readSTLGrid(const std::string &fileName, double voxelSize, bool verbose=false)
Reads .stl file with tyti stl reader.