MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMarkedVoxelSlice.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRViewerFwd.h"
4#ifndef MRVIEWER_NO_VOXELS
5
6#include "MRImGuiImage.h"
7#include <MRMesh/MRColor.h>
8#include <MRMesh/MRVector3.h>
9#include <MRMesh/MRBitSet.h>
10#include <MRMesh/MRBox.h>
13
14namespace MR
15{
18
19
22{
23public:
24 struct Mark
25 {
27 VoxelBitSet mask;
28 };
29
30 MRVIEWER_API MarkedVoxelSlice( const ObjectVoxels& voxels );
31
33
36 VoxelBitSet& getMask( MaskType type ) { return params_.marks[type].mask; }
38 const VoxelBitSet& getMask( MaskType type ) const { return params_.marks[type].mask; }
40 void setMask( const VoxelBitSet& mask, MaskType type ) { params_.marks[type].mask = mask; forceUpdate(); }
41
43 const Color& getColor( MaskType type ) const { return params_.marks[type].color; }
44 void setColor( const Color& color, MaskType type ) { params_.marks[type].color = color; forceUpdate(); }
45
46
49 Mark& getMark( MaskType type ) { return params_.marks[type]; }
51 const Mark& getMark( MaskType type ) const { return params_.marks[type]; }
53 void setMark( const Mark& mark, MaskType type ) { params_.marks[type] = mark; forceUpdate(); }
54
58 std::vector<Mark>& getCustomBackgroundMarks() { return params_.customBackgroundMarks; }
59 const std::vector<Mark>& getCustomBackgroundMarks() const { return params_.customBackgroundMarks; }
61 void setCustomBackgroundMarks( const std::vector<Mark>& backgroundMarks ) { params_.customBackgroundMarks = backgroundMarks; forceUpdate(); }
62
66 std::vector<Mark>& getCustomForegroundMarks() { return params_.customForegroundMarks; }
67 const std::vector<Mark>& getCustomForegroundMarks() const { return params_.customForegroundMarks; }
69 void setCustomForegroundMarks( const std::vector<Mark>& foregroundMarks ) { params_.customForegroundMarks = foregroundMarks; forceUpdate(); }
70
71
73 SlicePlane getActivePlane() const { return params_.activePlane; }
74 void setActivePlane( SlicePlane plane ) { params_.activePlane = plane; forceUpdate(); }
75
76 const Vector3i& getActiveVoxel() const { return params_.activeVoxel; }
77 void setActiveVoxel( const Vector3i& voxel ) { params_.activeVoxel = voxel; forceUpdate(); }
78
80 float getMin() const { return params_.min; }
81 void setMin( float min ) { params_.min = min; forceUpdate(); }
82 float getMax() const { return params_.max; }
83 void setMax( float max ) { params_.max = max; forceUpdate(); }
84
86 const Box3i& getActiveBox() const { return params_.activeBox; }
88 void setActiveBox( const Box3i& box ) { params_.activeBox = box; forceUpdate(); }
89
92 {
95 std::vector<Mark> customBackgroundMarks;
96 std::vector<Mark> customForegroundMarks;
98 Vector3i activeVoxel;
102 float min{0.0f};
104 float max{0.0f};
108 std::optional<Color> inactiveVoxelColor;
109 };
110
112 const Parameters& getParameters() const { return params_; }
114 void setParameters( const Parameters& params ) { params_ = params; forceUpdate(); }
115
117 MRVIEWER_API void forceUpdate();
118
119private:
120 FloatGrid grid_;
121 Vector3i dims_;
122
123 Parameters params_;
124
125};
126
127}
128
129#endif
wrapper class that helps mrbind to avoid excess MRVDBFloatGrid.h includes
Definition MRFloatGrid.h:21
Definition MRImGuiImage.h:18
ImGui visualization of a slice from voxel object and seed marks on it.
Definition MRMarkedVoxelSlice.h:22
Definition MRObjectVoxels.h:20
void setActivePlane(SlicePlane plane)
Definition MRMarkedVoxelSlice.h:74
void setCustomBackgroundMarks(const std::vector< Mark > &backgroundMarks)
Sets background colors and masks(VoxelBitSet of whole voxel object) of given type,...
Definition MRMarkedVoxelSlice.h:61
const Color & getColor(MaskType type) const
Colors of slice marks controls, setters update texture.
Definition MRMarkedVoxelSlice.h:43
void setParameters(const Parameters &params)
Set all parameters as one structure, updates texture.
Definition MRMarkedVoxelSlice.h:114
SlicePlane getActivePlane() const
Active plane (YZ, ZX or XY) controls, setters update texture.
Definition MRMarkedVoxelSlice.h:73
const Box3i & getActiveBox() const
Returns current active box of slice.
Definition MRMarkedVoxelSlice.h:86
SlicePlane activePlane
Slice plane.
Definition MRMarkedVoxelSlice.h:106
void setCustomForegroundMarks(const std::vector< Mark > &foregroundMarks)
Sets foreground colors and masks(VoxelBitSet of whole voxel object) of given type,...
Definition MRMarkedVoxelSlice.h:69
std::optional< Color > inactiveVoxelColor
if inactiveVoxelColor is set to some color then it will be blended with inactive voxel's color
Definition MRMarkedVoxelSlice.h:108
void setMask(const VoxelBitSet &mask, MaskType type)
Sets mask(VoxelBitSet of whole voxel object) of given type, updates texture.
Definition MRMarkedVoxelSlice.h:40
Mark & getMark(MaskType type)
Definition MRMarkedVoxelSlice.h:49
const Vector3i & getActiveVoxel() const
Definition MRMarkedVoxelSlice.h:76
std::vector< Mark > & getCustomBackgroundMarks()
Definition MRMarkedVoxelSlice.h:58
VoxelBitSet & getMask(MaskType type)
Definition MRMarkedVoxelSlice.h:36
void setActiveVoxel(const Vector3i &voxel)
Definition MRMarkedVoxelSlice.h:77
const std::vector< Mark > & getCustomForegroundMarks() const
Definition MRMarkedVoxelSlice.h:67
const VoxelBitSet & getMask(MaskType type) const
Returns mask(VoxelBitSet of whole voxel object) of given type.
Definition MRMarkedVoxelSlice.h:38
float getMax() const
Definition MRMarkedVoxelSlice.h:82
std::vector< Mark > customForegroundMarks
Definition MRMarkedVoxelSlice.h:96
static constexpr Color yellow() noexcept
Definition MRColor.h:34
std::vector< Mark > & getCustomForegroundMarks()
Definition MRMarkedVoxelSlice.h:66
Vector3i activeVoxel
Current voxel.
Definition MRMarkedVoxelSlice.h:98
void setMark(const Mark &mark, MaskType type)
Sets color and mask(VoxelBitSet of whole voxel object) of given type, updates texture.
Definition MRMarkedVoxelSlice.h:53
MRVIEWER_API void forceUpdate()
Set current slice with marks to texture, do not abuse this.
const std::vector< Mark > & getCustomBackgroundMarks() const
Definition MRMarkedVoxelSlice.h:59
Box3i activeBox
Active box, set as ObjectVoxels active box in constructor.
Definition MRMarkedVoxelSlice.h:100
static constexpr Color red() noexcept
Definition MRColor.h:31
float min
Minimum dense to show black.
Definition MRMarkedVoxelSlice.h:102
Color color
Definition MRMarkedVoxelSlice.h:26
float max
Maximum dense to show white.
Definition MRMarkedVoxelSlice.h:104
const Parameters & getParameters() const
Get all parameters as one structure.
Definition MRMarkedVoxelSlice.h:112
std::array< Mark, size_t(MaskType::Count)> marks
Base marks.
Definition MRMarkedVoxelSlice.h:94
static constexpr Color blue() noexcept
Definition MRColor.h:33
float getMin() const
Slice normalization parameters, setters update texture.
Definition MRMarkedVoxelSlice.h:80
void setMin(float min)
Definition MRMarkedVoxelSlice.h:81
void setActiveBox(const Box3i &box)
Updates active box of slice, do not affect ObjectVoxels, updates texture.
Definition MRMarkedVoxelSlice.h:88
MRVIEWER_API MarkedVoxelSlice(const ObjectVoxels &voxels)
std::vector< Mark > customBackgroundMarks
Definition MRMarkedVoxelSlice.h:95
const Mark & getMark(MaskType type) const
Returns color and mask(VoxelBitSet of whole voxel object) of given type.
Definition MRMarkedVoxelSlice.h:51
void setColor(const Color &color, MaskType type)
Definition MRMarkedVoxelSlice.h:44
void setMax(float max)
Definition MRMarkedVoxelSlice.h:83
MaskType
Definition MRMarkedVoxelSlice.h:32
VoxelBitSet mask
Definition MRMarkedVoxelSlice.h:27
@ Inside
Definition MRMarkedVoxelSlice.h:32
@ Outside
Definition MRMarkedVoxelSlice.h:32
@ Count
Definition MRMarkedVoxelSlice.h:32
@ Segment
Definition MRMarkedVoxelSlice.h:32
SlicePlane
Plane of slice in which to find path.
Definition MRVoxelPath.h:29
@ XY
= 2 cause main axis is z - [2]
Definition MRVoxelPath.h:32
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12
Definition MRMarkedVoxelSlice.h:25
Parameters of slice.
Definition MRMarkedVoxelSlice.h:92