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{
16
19{
20public:
21 struct Mark
22 {
24 VoxelBitSet mask;
25 };
26
27 MRVIEWER_API MarkedVoxelSlice( const ObjectVoxels& voxels );
28
30
31 // Needed to avoid VoxelBitSet copy
32 // ensure using forceUpdate() after chaging this reference
33 VoxelBitSet& getMask( MaskType type ) { return params_.marks[type].mask; }
34 // Returns mask(VoxelBitSet of whole voxel object) of given type
35 const VoxelBitSet& getMask( MaskType type ) const { return params_.marks[type].mask; }
36 // Sets mask(VoxelBitSet of whole voxel object) of given type, updates texture
37 void setMask( const VoxelBitSet& mask, MaskType type ) { params_.marks[type].mask = mask; forceUpdate(); }
38
39 // Colors of slice marks controls, setters update texture
40 const Color& getColor( MaskType type ) const { return params_.marks[type].color; }
41 void setColor( const Color& color, MaskType type ) { params_.marks[type].color = color; forceUpdate(); }
42
43
44 // Needed to avoid VoxelBitSet copy
45 // ensure using forceUpdate() after chaging this reference
46 Mark& getMark( MaskType type ) { return params_.marks[type]; }
47 // Returns color and mask(VoxelBitSet of whole voxel object) of given type
48 const Mark& getMark( MaskType type ) const { return params_.marks[type]; }
49 // Sets color and mask(VoxelBitSet of whole voxel object) of given type, updates texture
50 void setMark( const Mark& mark, MaskType type ) { params_.marks[type] = mark; forceUpdate(); }
51
52 // Needed to avoid VoxelBitSet copy
53 // ensure using forceUpdate() after chaging this reference
54 // returns background colors and masks(VoxelBitSet of whole voxel object)
55 std::vector<Mark>& getCustomBackgroundMarks() { return params_.customBackgroundMarks; }
56 const std::vector<Mark>& getCustomBackgroundMarks() const { return params_.customBackgroundMarks; }
57 // Sets background colors and masks(VoxelBitSet of whole voxel object) of given type, updates texture
58 void setCustomBackgroundMarks( const std::vector<Mark>& backgroundMarks ) { params_.customBackgroundMarks = backgroundMarks; forceUpdate(); }
59
60 // Needed to avoid VoxelBitSet copy
61 // ensure using forceUpdate() after chaging this reference
62 // returns foreground colors and masks(VoxelBitSet of whole voxel object)
63 std::vector<Mark>& getCustomForegroundMarks() { return params_.customForegroundMarks; }
64 const std::vector<Mark>& getCustomForegroundMarks() const { return params_.customForegroundMarks; }
65 // Sets foreground colors and masks(VoxelBitSet of whole voxel object) of given type, updates texture
66 void setCustomForegroundMarks( const std::vector<Mark>& foregroundMarks ) { params_.customForegroundMarks = foregroundMarks; forceUpdate(); }
67
68
69 // Active plane (YZ, ZX or XY) controls, setters update texture
70 SlicePlane getActivePlane() const { return params_.activePlane; }
71 void setActivePlane( SlicePlane plane ) { params_.activePlane = plane; forceUpdate(); }
72
73 const Vector3i& getActiveVoxel() const { return params_.activeVoxel; }
74 void setActiveVoxel( const Vector3i& voxel ) { params_.activeVoxel = voxel; forceUpdate(); }
75
76 // Slice normalization parameters, setters update texture
77 float getMin() const { return params_.min; }
78 void setMin( float min ) { params_.min = min; forceUpdate(); }
79 float getMax() const { return params_.max; }
80 void setMax( float max ) { params_.max = max; forceUpdate(); }
81
82 // Returns current active box of slice
83 const Box3i& getActiveBox() const { return params_.activeBox; }
84 // Updates active box of slice, do not affect ObjectVoxels, updates texture
85 void setActiveBox( const Box3i& box ) { params_.activeBox = box; forceUpdate(); }
86
87 // Parameters of slice
89 {
90 // Base marks
92 std::vector<Mark> customBackgroundMarks;
93 std::vector<Mark> customForegroundMarks;
94 // Current voxel
95 Vector3i activeVoxel;
96 // Active box, set as ObjectVoxels active box in constructor
97 Box3i activeBox;
98 // Minimum dense to show black
99 float min{0.0f};
100 // Maximum dense to show white
101 float max{0.0f};
102 // Slice plane
104 // if inactiveVoxelColor is set to some color then it will be blended with inactive voxel's color
105 std::optional<Color> inactiveVoxelColor;
106 };
107
108 // Get all parameters as one structure
109 const Parameters& getParameters() const { return params_; }
110 // Set all parameters as one structure, updates texture
111 void setParameters( const Parameters& params ) { params_ = params; forceUpdate(); }
112
113 // Set current slice with marks to texture, do not abuse this
114 MRVIEWER_API void forceUpdate();
115
116private:
117 FloatGrid grid_;
118 Vector3i dims_;
119
120 Parameters params_;
121
122};
123
124} //namespace MR
125
126#endif
wrapper class that helps mrbind to avoid excess MRVDBFloatGrid.h includes
Definition MRVoxels/MRFloatGrid.h:21
Definition MRImGuiImage.h:14
ImGui visualization of a slice from voxel object and seed marks on it.
Definition MRMarkedVoxelSlice.h:19
void setActivePlane(SlicePlane plane)
Definition MRMarkedVoxelSlice.h:71
void setCustomBackgroundMarks(const std::vector< Mark > &backgroundMarks)
Definition MRMarkedVoxelSlice.h:58
const Color & getColor(MaskType type) const
Definition MRMarkedVoxelSlice.h:40
void setParameters(const Parameters &params)
Definition MRMarkedVoxelSlice.h:111
SlicePlane getActivePlane() const
Definition MRMarkedVoxelSlice.h:70
const Box3i & getActiveBox() const
Definition MRMarkedVoxelSlice.h:83
void setCustomForegroundMarks(const std::vector< Mark > &foregroundMarks)
Definition MRMarkedVoxelSlice.h:66
void setMask(const VoxelBitSet &mask, MaskType type)
Definition MRMarkedVoxelSlice.h:37
Mark & getMark(MaskType type)
Definition MRMarkedVoxelSlice.h:46
const Vector3i & getActiveVoxel() const
Definition MRMarkedVoxelSlice.h:73
std::vector< Mark > & getCustomBackgroundMarks()
Definition MRMarkedVoxelSlice.h:55
VoxelBitSet & getMask(MaskType type)
Definition MRMarkedVoxelSlice.h:33
void setActiveVoxel(const Vector3i &voxel)
Definition MRMarkedVoxelSlice.h:74
const std::vector< Mark > & getCustomForegroundMarks() const
Definition MRMarkedVoxelSlice.h:64
const VoxelBitSet & getMask(MaskType type) const
Definition MRMarkedVoxelSlice.h:35
float getMax() const
Definition MRMarkedVoxelSlice.h:79
std::vector< Mark > & getCustomForegroundMarks()
Definition MRMarkedVoxelSlice.h:63
void setMark(const Mark &mark, MaskType type)
Definition MRMarkedVoxelSlice.h:50
MRVIEWER_API void forceUpdate()
const std::vector< Mark > & getCustomBackgroundMarks() const
Definition MRMarkedVoxelSlice.h:56
const Parameters & getParameters() const
Definition MRMarkedVoxelSlice.h:109
float getMin() const
Definition MRMarkedVoxelSlice.h:77
void setMin(float min)
Definition MRMarkedVoxelSlice.h:78
void setActiveBox(const Box3i &box)
Definition MRMarkedVoxelSlice.h:85
MRVIEWER_API MarkedVoxelSlice(const ObjectVoxels &voxels)
const Mark & getMark(MaskType type) const
Definition MRMarkedVoxelSlice.h:48
void setColor(const Color &color, MaskType type)
Definition MRMarkedVoxelSlice.h:41
void setMax(float max)
Definition MRMarkedVoxelSlice.h:80
MaskType
Definition MRMarkedVoxelSlice.h:29
@ Inside
Definition MRMarkedVoxelSlice.h:29
@ Outside
Definition MRMarkedVoxelSlice.h:29
@ Count
Definition MRMarkedVoxelSlice.h:29
@ Segment
Definition MRMarkedVoxelSlice.h:29
Definition MRObjectVoxels.h:17
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
Definition MRCameraOrientationPlugin.h:8
Definition MRMesh/MRColor.h:9
static constexpr Color yellow() noexcept
Definition MRMesh/MRColor.h:31
static constexpr Color red() noexcept
Definition MRMesh/MRColor.h:28
static constexpr Color blue() noexcept
Definition MRMesh/MRColor.h:30
Definition MRMarkedVoxelSlice.h:22
Color color
Definition MRMarkedVoxelSlice.h:23
VoxelBitSet mask
Definition MRMarkedVoxelSlice.h:24
Definition MRMarkedVoxelSlice.h:89
SlicePlane activePlane
Definition MRMarkedVoxelSlice.h:103
std::optional< Color > inactiveVoxelColor
Definition MRMarkedVoxelSlice.h:105
std::vector< Mark > customForegroundMarks
Definition MRMarkedVoxelSlice.h:93
Vector3i activeVoxel
Definition MRMarkedVoxelSlice.h:95
Box3i activeBox
Definition MRMarkedVoxelSlice.h:97
float min
Definition MRMarkedVoxelSlice.h:99
float max
Definition MRMarkedVoxelSlice.h:101
std::array< Mark, size_t(MaskType::Count)> marks
Definition MRMarkedVoxelSlice.h:91
std::vector< Mark > customBackgroundMarks
Definition MRMarkedVoxelSlice.h:92