MeshLib C++ Docs
Loading...
Searching...
No Matches
MRVDBConversions.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
4
5#include "MRMesh/MRMeshPart.h"
8#include "MRMesh/MRExpected.h"
9#include "MRMesh/MRBox.h"
10#include <climits>
11#include <string>
12#include <optional>
13
14namespace MR
15{
18
19
23MRVOXELS_API FloatGrid meshToLevelSet( const MeshPart& mp, const AffineXf3f& xf,
24 const Vector3f& voxelSize, float surfaceOffset = 3,
25 ProgressCallback cb = {} );
26
30MRVOXELS_API FloatGrid meshToDistanceField( const MeshPart& mp, const AffineXf3f& xf,
31 const Vector3f& voxelSize, float surfaceOffset = 3,
32 ProgressCallback cb = {} );
33
36{
38 enum class Type
39 {
40 Signed,
42 } type{ Type::Unsigned };
43 float surfaceOffset{ 3.0 };
44 Vector3f voxelSize = Vector3f::diagonal( 1.0f );
45 AffineXf3f worldXf;
46 AffineXf3f* outXf{ nullptr };
47 ProgressCallback cb;
48};
49
51MRVOXELS_API void evalGridMinMax( const FloatGrid& grid, float& min, float& max );
52
56MRVOXELS_API Expected<VdbVolume> meshToDistanceVdbVolume( const MeshPart& mp, const MeshToVolumeParams& params = {} );
57
62MRVOXELS_API Expected<VdbVolume> meshToVolume( const MeshPart& mp, const MeshToVolumeParams& params = {} );
63
65MRVOXELS_API VdbVolume floatGridToVdbVolume( FloatGrid grid );
66
71MRVOXELS_API FloatGrid simpleVolumeToDenseGrid( const SimpleVolume& simpleVolume, float background = 0.0f, ProgressCallback cb = {} );
73MRVOXELS_API VdbVolume simpleVolumeToVdbVolume( const SimpleVolumeMinMax& simpleVolume, ProgressCallback cb = {} );
74
78MRVOXELS_API VdbVolume functionVolumeToVdbVolume( const FunctionVolume& functoinVolume, ProgressCallback cb = {} );
79
85template <typename AccessorOrGrid>
87 AccessorOrGrid& gridAccessor,
88 const Vector3i& minCoord, const SimpleVolume& simpleVolume, ProgressCallback cb = {}
89 );
90
94 const VdbVolume& vdbVolume, const Box3i& activeBox = Box3i(), ProgressCallback cb = {} );
101 const VdbVolume& vdbVolume, const Box3i& activeBox = Box3i(), std::optional<MinMaxf> sourceScale = {}, ProgressCallback cb = {} );
108 const VdbVolume& vdbVolume, const Box3i& activeBox = Box3i(), std::optional<MinMaxf> sourceScale = {}, ProgressCallback cb = {} );
109
112{
114 Vector3f voxelSize;
116 float isoValue = 0;
118 float adaptivity = 0;
120 int maxFaces = INT_MAX;
122 int maxVertices = INT_MAX;
125 ProgressCallback cb;
126};
127
129MRVOXELS_API Expected<Mesh> gridToMesh( const FloatGrid& grid, const GridToMeshSettings & settings );
130
133MRVOXELS_API Expected<Mesh> gridToMesh( FloatGrid&& grid, const GridToMeshSettings & settings );
134
136{
138 AffineXf3f meshToGridXf;
139
141 std::shared_ptr<IFastWindingNumber> fwn;
142
146
149
151 ProgressCallback progress;
152};
153
155MRVOXELS_API Expected<void> makeSignedByWindingNumber( FloatGrid& grid, const Vector3f& voxelSize, const Mesh& refMesh,
156 const MakeSignedByWindingNumberSettings & settings );
157
159{
161 float voxelSize = 0;
162
164 float offsetA = 0;
165
167 float offsetB = 0;
168
170 float adaptivity = 0;
171
173 std::shared_ptr<IFastWindingNumber> fwn;
174
178
181
183 ProgressCallback progress;
184};
185
188MRVOXELS_API Expected<Mesh> doubleOffsetVdb( const MeshPart& mp, const DoubleOffsetSettings & settings );
189
190}
wrapper class that helps mrbind to avoid excess MRVDBFloatGrid.h includes
Definition MRFloatGrid.h:21
MRVOXELS_API Expected< SimpleVolumeMinMax > vdbVolumeToSimpleVolume(const VdbVolume &vdbVolume, const Box3i &activeBox=Box3i(), ProgressCallback cb={})
AffineXf3f worldXf
Definition MRVDBConversions.h:45
bool relaxDisorientedTriangles
Definition MRVDBConversions.h:123
std::shared_ptr< IFastWindingNumber > fwn
defines particular implementation of IFastWindingNumber interface that will compute windings....
Definition MRVDBConversions.h:173
AffineXf3f * outXf
mesh initial transform
Definition MRVDBConversions.h:46
MRVOXELS_API Expected< SimpleVolumeMinMaxU16 > vdbVolumeToSimpleVolumeU16(const VdbVolume &vdbVolume, const Box3i &activeBox=Box3i(), std::optional< MinMaxf > sourceScale={}, ProgressCallback cb={})
float voxelSize
the size of voxel in intermediate voxel grid representation
Definition MRVDBConversions.h:161
MRVOXELS_API FloatGrid meshToDistanceField(const MeshPart &mp, const AffineXf3f &xf, const Vector3f &voxelSize, float surfaceOffset=3, ProgressCallback cb={})
float adaptivity
adaptivity - [0.0;1.0] ratio of combining small triangles into bigger ones (curvature can be lost on ...
Definition MRVDBConversions.h:118
ProgressCallback progress
to report algorithm's progress and to cancel it
Definition MRVDBConversions.h:151
MRVOXELS_API VdbVolume floatGridToVdbVolume(FloatGrid grid)
fills VdbVolume data from FloatGrid (does not fill voxels size, cause we expect it outside)
Type
Conversion type.
Definition MRVDBConversions.h:39
MRVOXELS_API VdbVolume simpleVolumeToVdbVolume(const SimpleVolumeMinMax &simpleVolume, ProgressCallback cb={})
set the simpleVolume.min as the background value
Vector3f voxelSize
the number of voxels around surface to calculate distance in (should be positive)
Definition MRVDBConversions.h:44
float offsetB
the amount of second offset
Definition MRVDBConversions.h:167
int maxVertices
if the mesh exceeds this number of vertices, an error returns
Definition MRVDBConversions.h:122
MRVOXELS_API Expected< VdbVolume > meshToVolume(const MeshPart &mp, const MeshToVolumeParams &params={})
tl::expected< T, E > Expected
Definition MRExpected.h:31
float windingNumberThreshold
Definition MRVDBConversions.h:177
MRVOXELS_API void evalGridMinMax(const FloatGrid &grid, float &min, float &max)
eval min max value from FloatGrid
ProgressCallback progress
to report algorithm's progress and to cancel it
Definition MRVDBConversions.h:183
float windingNumberThreshold
Definition MRVDBConversions.h:145
MRVOXELS_API Expected< SimpleVolumeMinMax > vdbVolumeToSimpleVolumeNorm(const VdbVolume &vdbVolume, const Box3i &activeBox=Box3i(), std::optional< MinMaxf > sourceScale={}, ProgressCallback cb={})
enum MR::MeshToVolumeParams::Type Unsigned
MRVOXELS_API Expected< VdbVolume > meshToDistanceVdbVolume(const MeshPart &mp, const MeshToVolumeParams &params={})
MRVOXELS_API FloatGrid simpleVolumeToDenseGrid(const SimpleVolume &simpleVolume, float background=0.0f, ProgressCallback cb={})
MRVOXELS_API Expected< Mesh > doubleOffsetVdb(const MeshPart &mp, const DoubleOffsetSettings &settings)
float surfaceOffset
Definition MRVDBConversions.h:43
std::shared_ptr< IFastWindingNumber > fwn
defines particular implementation of IFastWindingNumber interface that will compute windings....
Definition MRVDBConversions.h:141
float windingNumberBeta
determines the precision of fast approximation: the more the better, minimum value is 1
Definition MRVDBConversions.h:148
MRVOXELS_API void putSimpleVolumeInDenseGrid(AccessorOrGrid &gridAccessor, const Vector3i &minCoord, const SimpleVolume &simpleVolume, ProgressCallback cb={})
Copy given simpleVolume into the grid, starting at minCoord Instantiated for AccessorOrGrid in { open...
int maxFaces
if the mesh exceeds this number of faces, an error returns
Definition MRVDBConversions.h:120
float adaptivity
in [0; 1] - ratio of combining small triangles into bigger ones (curvature can be lost on high values...
Definition MRVDBConversions.h:170
AffineXf3f meshToGridXf
defines the mapping from mesh reference from to grid reference frame
Definition MRVDBConversions.h:138
float offsetA
the amount of first offset
Definition MRVDBConversions.h:164
MRVOXELS_API VdbVolume functionVolumeToVdbVolume(const FunctionVolume &functoinVolume, ProgressCallback cb={})
ProgressCallback cb
to receive progress and request cancellation
Definition MRVDBConversions.h:125
Vector3f voxelSize
the size of each voxel in the grid
Definition MRVDBConversions.h:114
ProgressCallback cb
optional output: xf to original mesh (respecting worldXf)
Definition MRVDBConversions.h:47
float isoValue
layer of grid with this value would be converted in mesh; isoValue can be negative only in level set ...
Definition MRVDBConversions.h:116
MRVOXELS_API Expected< Mesh > gridToMesh(const FloatGrid &grid, const GridToMeshSettings &settings)
converts OpenVDB Grid into mesh using Dual Marching Cubes algorithm
MRVOXELS_API FloatGrid meshToLevelSet(const MeshPart &mp, const AffineXf3f &xf, const Vector3f &voxelSize, float surfaceOffset=3, ProgressCallback cb={})
MRVOXELS_API Expected< void > makeSignedByWindingNumber(FloatGrid &grid, const Vector3f &voxelSize, const Mesh &refMesh, const MakeSignedByWindingNumberSettings &settings)
set signs for unsigned distance field grid using generalized winding number computed at voxel grid po...
float windingNumberBeta
determines the precision of fast approximation: the more the better, minimum value is 1
Definition MRVDBConversions.h:180
@ Unsigned
only closed meshes can be converted with signed type
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRVDBConversions.h:159
parameters of OpenVDB Grid to Mesh conversion using Dual Marching Cubes algorithm
Definition MRVDBConversions.h:112
Definition MRVDBConversions.h:136
Parameters structure for meshToVolume function.
Definition MRVDBConversions.h:36
Definition MRMesh.h:23