MeshLib
 
Loading...
Searching...
No Matches
MRVDBConversions.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#ifndef MRMESH_NO_OPENVDB
5#include "MRMeshPart.h"
7#include "MRAffineXf3.h"
8#include "MRExpected.h"
9#include "MRBox.h"
10#include <climits>
11#include <string>
12
13namespace MR
14{
15
16// closed surface is required
17// surfaceOffset - number voxels around surface to calculate distance in (should be positive)
18// returns null if was canceled by progress callback
20 const Vector3f& voxelSize, float surfaceOffset = 3,
21 ProgressCallback cb = {} );
22
23// does not require closed surface, resulting grid cannot be used for boolean operations,
24// surfaceOffset - the number of voxels around surface to calculate distance in (should be positive)
25// returns null if was canceled by progress callback
27 const Vector3f& voxelSize, float surfaceOffset = 3,
28 ProgressCallback cb = {} );
29
30// Parameters structure for meshToVolume function
32{
33 // Conversion type
34 enum class Type
35 {
36 Signed, // only closed meshes can be converted with signed type
37 Unsigned // this type leads to shell like iso-surfaces
38 } type{ Type::Unsigned };
39 float surfaceOffset{ 3.0 }; // the number of voxels around surface to calculate distance in (should be positive)
41 AffineXf3f worldXf; // mesh initial transform
42 AffineXf3f* outXf{ nullptr }; // optional output: xf to original mesh (respecting worldXf)
44};
45
46// eval min max value from FloatGrid
47MRMESH_API void evalGridMinMax( const FloatGrid& grid, float& min, float& max );
48
49// convert mesh to volume in (0,0,0)-(dim.x,dim.y,dim.z) grid box
51
52// fills VdbVolume data from FloatGrid (does not fill voxels size, cause we expect it outside)
54
55// make FloatGrid from SimpleVolume
56// make copy of data
57// grid can be used to make iso-surface later with gridToMesh function
58MRMESH_API FloatGrid simpleVolumeToDenseGrid( const SimpleVolume& simpleVolume, ProgressCallback cb = {} );
59MRMESH_API VdbVolume simpleVolumeToVdbVolume( const SimpleVolume& simpleVolume, ProgressCallback cb = {} );
60
61// make SimpleVolume from VdbVolume
62// make copy of data
64 const VdbVolume& vdbVolume, const Box3i& activeBox = Box3i(), ProgressCallback cb = {} );
65// make normalized SimpleVolume from VdbVolume
66// make copy of data
68 const VdbVolume& vdbVolume, const Box3i& activeBox = Box3i(), ProgressCallback cb = {} );
69// make SimpleVolumeU16 from VdbVolume
70// performs mapping from [vdbVolume.min, vdbVolume.max] to nonnegative range of uint16_t
72 const VdbVolume& vdbVolume, const Box3i& activeBox = Box3i(), ProgressCallback cb = {} );
73
76{
80 float isoValue = 0;
82 float adaptivity = 0;
84 int maxFaces = INT_MAX;
86 int maxVertices = INT_MAX;
90};
91
94
98
100{
103
105 std::shared_ptr<IFastWindingNumber> fwn;
106
110
113
116};
117
121 const MakeSignedByWindingNumberSettings & settings );
122
124{
126 float voxelSize = 0;
127
129 float offsetA = 0;
130
132 float offsetB = 0;
133
135 float adaptivity = 0;
136
138 std::shared_ptr<IFastWindingNumber> fwn;
139
143
146
149};
150
154
155} //namespace MR
156#endif
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:589
Definition MRCameraOrientationPlugin.h:7
MRMESH_API Expected< Mesh > doubleOffsetVdb(const MeshPart &mp, const DoubleOffsetSettings &settings)
MRMESH_API Expected< VdbVolume > meshToVolume(const Mesh &mesh, const MeshToVolumeParams &params={})
MRMESH_API VdbVolume floatGridToVdbVolume(FloatGrid grid)
MRMESH_API Expected< SimpleVolume > vdbVolumeToSimpleVolumeNorm(const VdbVolume &vdbVolume, const Box3i &activeBox=Box3i(), ProgressCallback cb={})
MRMESH_API void evalGridMinMax(const FloatGrid &grid, float &min, float &max)
MRMESH_API Expected< SimpleVolumeU16 > vdbVolumeToSimpleVolumeU16(const VdbVolume &vdbVolume, const Box3i &activeBox=Box3i(), ProgressCallback cb={})
std::shared_ptr< OpenVdbFloatGrid > FloatGrid
Definition MRMesh/MRMeshFwd.h:537
tl::expected< T, E > Expected
Definition MRExpected.h:49
MRMESH_API Expected< SimpleVolume > vdbVolumeToSimpleVolume(const VdbVolume &vdbVolume, const Box3i &activeBox=Box3i(), ProgressCallback cb={})
MRMESH_API VdbVolume simpleVolumeToVdbVolume(const SimpleVolume &simpleVolume, ProgressCallback cb={})
MRMESH_API VoidOrErrStr makeSignedByWindingNumber(FloatGrid &grid, const Vector3f &voxelSize, const Mesh &refMesh, const MakeSignedByWindingNumberSettings &settings)
MRMESH_API FloatGrid meshToDistanceField(const MeshPart &mp, const AffineXf3f &xf, const Vector3f &voxelSize, float surfaceOffset=3, ProgressCallback cb={})
MRMESH_API Expected< Mesh > gridToMesh(const FloatGrid &grid, const GridToMeshSettings &settings)
converts OpenVDB Grid into mesh using Dual Marching Cubes algorithm
MRMESH_API FloatGrid simpleVolumeToDenseGrid(const SimpleVolume &simpleVolume, ProgressCallback cb={})
MRMESH_API FloatGrid meshToLevelSet(const MeshPart &mp, const AffineXf3f &xf, const Vector3f &voxelSize, float surfaceOffset=3, ProgressCallback cb={})
Expected< void > VoidOrErrStr
return type for a void function that can produce an error string
Definition MRExpected.h:60
Definition MRVDBConversions.h:124
std::shared_ptr< IFastWindingNumber > fwn
defines particular implementation of IFastWindingNumber interface that will compute windings....
Definition MRVDBConversions.h:138
float voxelSize
the size of voxel in intermediate voxel grid representation
Definition MRVDBConversions.h:126
float offsetB
the amount of second offset
Definition MRVDBConversions.h:132
float windingNumberThreshold
Definition MRVDBConversions.h:142
ProgressCallback progress
to report algorithm's progress and to cancel it
Definition MRVDBConversions.h:148
float adaptivity
in [0; 1] - ratio of combining small triangles into bigger ones (curvature can be lost on high values...
Definition MRVDBConversions.h:135
float offsetA
the amount of first offset
Definition MRVDBConversions.h:129
float windingNumberBeta
determines the precision of fast approximation: the more the better, minimum value is 1
Definition MRVDBConversions.h:145
parameters of OpenVDB Grid to Mesh conversion using Dual Marching Cubes algorithm
Definition MRVDBConversions.h:76
bool relaxDisorientedTriangles
Definition MRVDBConversions.h:87
float adaptivity
adaptivity - [0.0;1.0] ratio of combining small triangles into bigger ones (curvature can be lost on ...
Definition MRVDBConversions.h:82
int maxVertices
if the mesh exceeds this number of vertices, an error returns
Definition MRVDBConversions.h:86
int maxFaces
if the mesh exceeds this number of faces, an error returns
Definition MRVDBConversions.h:84
ProgressCallback cb
to receive progress and request cancellation
Definition MRVDBConversions.h:89
Vector3f voxelSize
the size of each voxel in the grid
Definition MRVDBConversions.h:78
float isoValue
layer of grid with this value would be converted in mesh; isoValue can be negative only in level set ...
Definition MRVDBConversions.h:80
Definition MRVDBConversions.h:100
ProgressCallback progress
to report algorithm's progress and to cancel it
Definition MRVDBConversions.h:115
float windingNumberThreshold
Definition MRVDBConversions.h:109
std::shared_ptr< IFastWindingNumber > fwn
defines particular implementation of IFastWindingNumber interface that will compute windings....
Definition MRVDBConversions.h:105
float windingNumberBeta
determines the precision of fast approximation: the more the better, minimum value is 1
Definition MRVDBConversions.h:112
AffineXf3f meshToGridXf
defines the mapping from mesh reference from to grid reference frame
Definition MRVDBConversions.h:102
Definition MRMesh/MRMeshPart.h:11
Definition MRVDBConversions.h:32
AffineXf3f worldXf
Definition MRVDBConversions.h:41
AffineXf3f * outXf
Definition MRVDBConversions.h:42
Type
Definition MRVDBConversions.h:35
Vector3f voxelSize
Definition MRVDBConversions.h:40
enum MR::MeshToVolumeParams::Type Unsigned
float surfaceOffset
Definition MRVDBConversions.h:39
ProgressCallback cb
Definition MRVDBConversions.h:43
Definition MRMesh/MRMesh.h:23
static constexpr Vector3 diagonal(float a) noexcept
Definition MRMesh/MRVector3.h:32