MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMarchingCubes.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
5#include "MRVoxelsVolume.h"
8#include "MRMesh/MRExpected.h"
9#include <climits>
10
11namespace MR
12{
15
16
19using VoxelPointPositioner = std::function<Vector3f( const Vector3f&, const Vector3f&, float, float, float )>;
20
22{
24 Vector3f origin;
25
28
30 float iso{ 0.0f };
31
33 bool lessInside{ false };
34
37
42
44 int maxVertices = INT_MAX;
45
58
60 std::function<void()> freeVolume;
61
63 MR_BIND_PREFER_UNLOCK_GIL_WHEN_USED_AS_PARAM
64};
65
67MRVOXELS_API Expected<Mesh> marchingCubes( const SimpleVolume& volume, const MarchingCubesParams& params = {} );
69
73
75MRVOXELS_API Expected<Mesh> marchingCubes( const VdbVolume& volume, const MarchingCubesParams& params = {} );
77
81
83MRVOXELS_API Expected<Mesh> marchingCubes( const SimpleBinaryVolume& volume, const MarchingCubesParams& params = {} );
84MRVOXELS_API Expected<TriMesh> marchingCubesAsTriMesh( const SimpleBinaryVolume& volume, const MarchingCubesParams& params = {} );
85
95{
96public:
99 MRVOXELS_API explicit MarchingCubesByParts( const Vector3i & dims, const MarchingCubesParams& params, int layersPerBlock = 0 );
100
104
107
109 MRVOXELS_API int nextZ() const;
110
112 MRVOXELS_API Expected<void> addPart( const SimpleVolume& part );
113
116
117private:
118 struct Impl;
119 std::unique_ptr<Impl> impl_;
120};
121
122}
#define MRVOXELS_API
see explanation in MRMesh/MRMeshFwd.h
Definition MRVoxelsFwd.h:14
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:753
std::function< void()> freeVolume
this optional function is called when volume is no longer needed to deallocate it and reduce peak mem...
Definition MRMarchingCubes.h:60
MarchingCubesByParts & operator=(MarchingCubesByParts &&s) noexcept
Vector3f origin
origin point of voxels box in 3D space with output mesh
Definition MRMarchingCubes.h:24
double volume(const MeshTopology &topology, const VertCoords &points, const FaceBitSet *region=nullptr)
MRVOXELS_CLASS SimpleVolumeMinMax
Definition MRVoxelsFwd.h:35
Expected< void > addPart(const SimpleVolume &part)
adds one more part of volume into consideration, with first z=nextZ()
MarchingCubesByParts(MarchingCubesByParts &&s) noexcept
int maxVertices
if the mesh exceeds this number of vertices, an error returns
Definition MRMarchingCubes.h:44
MRVOXELS_CLASS FunctionVolume
Definition MRVoxelsFwd.h:46
Expected< Mesh > marchingCubes(const SimpleVolume &volume, const MarchingCubesParams &params={})
makes Mesh from SimpleVolume with given settings using Marching Cubes algorithm
tl::expected< T, E > Expected
Definition MRExpected.h:31
Expected< TriMesh > finalize()
finishes processing and outputs produced trimesh
MarchingCubesByParts(const Vector3i &dims, const MarchingCubesParams &params, int layersPerBlock=0)
Expected< TriMesh > marchingCubesAsTriMesh(const SimpleVolume &volume, const MarchingCubesParams &params={})
int nextZ() const
the last z-layer of the previous part and the first z-layer of the next part
enum MR::MarchingCubesParams::CachingMode cachingMode
CachingMode
Definition MRMarchingCubes.h:49
VoxelPointPositioner positioner
Definition MRMarchingCubes.h:41
ProgressCallback cb
progress callback
Definition MRMarchingCubes.h:27
bool lessInside
should be false for dense volumes, and true for distance volume
Definition MRMarchingCubes.h:33
int layersPerBlock() const
the number of z-slices of the volume in the blocks
float iso
target iso-value of the surface to be extracted from volume
Definition MRMarchingCubes.h:30
std::function< Vector3f(const Vector3f &, const Vector3f &, float, float, float)> VoxelPointPositioner
Definition MRMarchingCubes.h:19
Vector< VoxelId, FaceId > * outVoxelPerFaceMap
optional output map FaceId->VoxelId
Definition MRMarchingCubes.h:36
@ Automatic
Definition MRMarchingCubes.h:52
@ None
don't cache any data
Definition MRMarchingCubes.h:54
@ Normal
allocates 2 full slices per parallel thread
Definition MRMarchingCubes.h:56
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRMarchingCubes.h:22