MeshLib
 
Loading...
Searching...
No Matches
MRVolumeSegment.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#ifndef MRMESH_NO_OPENVDB
4#include "MRVector3.h"
5#include "MRExpected.h"
6#include "MRVoxelsVolume.h"
7#include "MRBitSet.h"
9#include <string>
10
11namespace MR
12{
13
26MRMESH_API Expected<MR::Mesh> meshFromVoxelsMask( const VdbVolume& volume, const VoxelBitSet& mask );
27
42
51MRMESH_API Expected<MR::Mesh> segmentVolume( const VdbVolume& volume, const std::vector<std::pair<Vector3f, Vector3f>>& pairs,
53
55
66{
67public:
68 MRMESH_API VolumeSegmenter( const VdbVolume& volume );
69
76
78 MRMESH_API void addPathSeeds( const VoxelMetricParameters& metricParameters, SeedType seedType, float exponentModifier = -1.0f );
79
81 MRMESH_API void setSeeds( const std::vector<Vector3i>& seeds, SeedType seedType );
82
84 MRMESH_API void addSeeds( const std::vector<Vector3i>& seeds, SeedType seedType );
85
87 MRMESH_API const std::vector<Vector3i>& getSeeds( SeedType seedType ) const;
88
90 MRMESH_API Expected<VoxelBitSet> segmentVolume( float segmentationExponentModifier = 3000.0f, int voxelsExpansion = 25, ProgressCallback cb = {} );
91
93 MRMESH_API Expected<MR::Mesh> createMeshFromSegmentation( const VoxelBitSet& segmentation ) const;
94
97
100private:
101 const VdbVolume& volume_;
102
103 SimpleVolume volumePart_;
104
105 Vector3i minVoxel_;
106 Vector3i maxVoxel_;
107
108 std::array<std::vector<Vector3i>, size_t( SeedType::Count )> seeds_;
109 std::array<VoxelBitSet, size_t( SeedType::Count )> seedsInVolumePartSpace_;
110
111 bool seedsChanged_{true};
112
113 void setupVolumePart_( int voxelsExpansion );
114};
115
117
118}
119#endif
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Class for voxels segmentation.
Definition MRVolumeSegment.h:66
MRMESH_API const Vector3i & getVolumePartDimensions() const
Dimensions of volume part, filled after segmentation.
MRMESH_API VolumeSegmenter(const VdbVolume &volume)
MRMESH_API void addSeeds(const std::vector< Vector3i > &seeds, SeedType seedType)
Adds new seeds to stored.
MRMESH_API void setSeeds(const std::vector< Vector3i > &seeds, SeedType seedType)
Reset seeds with given ones.
MRMESH_API const std::vector< Vector3i > & getSeeds(SeedType seedType) const
Return currently stored seeds.
SeedType
Definition MRVolumeSegment.h:71
@ Inside
Definition MRVolumeSegment.h:72
@ Count
Definition MRVolumeSegment.h:74
@ Outside
Definition MRVolumeSegment.h:73
MRMESH_API void addPathSeeds(const VoxelMetricParameters &metricParameters, SeedType seedType, float exponentModifier=-1.0f)
Builds path with given parameters, marks result as seedType seeds.
MRMESH_API Expected< MR::Mesh > createMeshFromSegmentation(const VoxelBitSet &segmentation) const
Returns mesh of given segment.
MRMESH_API const Vector3i & getMinVoxel() const
Min voxel of volume part box in whole volume space, filled after segmentation.
MRMESH_API Expected< VoxelBitSet > segmentVolume(float segmentationExponentModifier=3000.0f, int voxelsExpansion=25, ProgressCallback cb={})
Segments volume, return inside part segmentation (VoxelBitSet in space of VolumePart)
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:589
MRMESH_API Expected< MR::Mesh > meshFromVoxelsMask(const VdbVolume &volume, const VoxelBitSet &mask)
Creates mesh from voxels mask.
MRMESH_API Expected< MR::Mesh > segmentVolume(const VdbVolume &volume, const std::vector< std::pair< Vector3f, Vector3f > > &pairs, const VolumeSegmentationParameters &params=VolumeSegmentationParameters())
Simple segment volume.
Definition MRCameraOrientationPlugin.h:7
tl::expected< T, E > Expected
Definition MRExpected.h:49
Parameters for volume segmentation.
Definition MRVolumeSegment.h:34
int voxelsExpansion
Segment box expansion (only part of volume are segmented, this parameter shows how much to expand thi...
Definition MRVolumeSegment.h:40
float segmentationExponentModifier
Exponent modifier of graph cutting metric (volume presents graph with seeds, this graph are min cut)
Definition MRVolumeSegment.h:38
float buildPathExponentModifier
Exponent modifier of path building metric (paths are built between voxel pairs and then marked as too...
Definition MRVolumeSegment.h:36
Parameters for building metric function.
Definition MRVoxelPath.h:38