MeshLib Documentation
Loading...
Searching...
No Matches
MRVolumeSegment.h
Go to the documentation of this file.
1#pragma once
2#include "MRVoxelsFwd.h"
3
4#include "MRMesh/MRVector3.h"
5#include "MRMesh/MRExpected.h"
6#include "MRVoxelsVolume.h"
7#include "MRMesh/MRBitSet.h"
9#include <string>
10
11namespace MR
12{
13
26MRVOXELS_API Expected<MR::Mesh> meshFromVoxelsMask( const VdbVolume& volume, const VoxelBitSet& mask );
27
42
51MRVOXELS_API Expected<MR::Mesh> segmentVolume( const VdbVolume& volume, const std::vector<std::pair<Vector3f, Vector3f>>& pairs,
53
55
66{
67public:
68 MRVOXELS_API VolumeSegmenter( const VdbVolume& volume );
69
76
78 MRVOXELS_API void addPathSeeds( const VoxelMetricParameters& metricParameters, SeedType seedType, float exponentModifier = -1.0f );
79
81 MRVOXELS_API void setSeeds( const std::vector<Vector3i>& seeds, SeedType seedType );
82
84 MRVOXELS_API void addSeeds( const std::vector<Vector3i>& seeds, SeedType seedType );
85
87 MRVOXELS_API const std::vector<Vector3i>& getSeeds( SeedType seedType ) const;
88
90 MRVOXELS_API Expected<VoxelBitSet> segmentVolume( float segmentationExponentModifier = 3000.0f, int voxelsExpansion = 25, ProgressCallback cb = {} );
91
93 MRVOXELS_API Expected<MR::Mesh> createMeshFromSegmentation( const VoxelBitSet& segmentation ) const;
94
96 MRVOXELS_API const Vector3i& getVolumePartDimensions() const;
97
99 MRVOXELS_API const Vector3i& getMinVoxel() const;
100private:
101 const VdbVolume& volume_;
102
103 SimpleVolumeMinMax 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}
#define MRVOXELS_API
Definition MRVoxelsFwd.h:13
Class for voxels segmentation.
Definition MRVolumeSegment.h:66
MRVOXELS_API Expected< VoxelBitSet > segmentVolume(float segmentationExponentModifier=3000.0f, int voxelsExpansion=25, ProgressCallback cb={})
Segments volume, return inside part segmentation (VoxelBitSet in space of VolumePart)
MRVOXELS_API Expected< MR::Mesh > createMeshFromSegmentation(const VoxelBitSet &segmentation) const
Returns mesh of given segment.
MRVOXELS_API const Vector3i & getMinVoxel() const
Min voxel of volume part box in whole volume space, filled after segmentation.
MRVOXELS_API const Vector3i & getVolumePartDimensions() const
Dimensions of volume part, filled after segmentation.
MRVOXELS_API void addSeeds(const std::vector< Vector3i > &seeds, SeedType seedType)
Adds new seeds to stored.
SeedType
Definition MRVolumeSegment.h:71
@ Inside
Definition MRVolumeSegment.h:72
@ Count
Definition MRVolumeSegment.h:74
@ Outside
Definition MRVolumeSegment.h:73
MRVOXELS_API void setSeeds(const std::vector< Vector3i > &seeds, SeedType seedType)
Reset seeds with given ones.
MRVOXELS_API VolumeSegmenter(const VdbVolume &volume)
MRVOXELS_API const std::vector< Vector3i > & getSeeds(SeedType seedType) const
Return currently stored seeds.
MRVOXELS_API void addPathSeeds(const VoxelMetricParameters &metricParameters, SeedType seedType, float exponentModifier=-1.0f)
Builds path with given parameters, marks result as seedType seeds.
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:576
MRVOXELS_API Expected< MR::Mesh > meshFromVoxelsMask(const VdbVolume &volume, const VoxelBitSet &mask)
Creates mesh from voxels mask.
MRVOXELS_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:8
tl::expected< T, E > Expected
Definition MRExpected.h:58
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