27 constexpr static const
char*
StaticTypeName() noexcept {
return "ObjectVoxels"; }
30 constexpr static const char*
StaticClassName() noexcept {
return "Voxel Volume"; }
39 const std::shared_ptr<Mesh>&
surface()
const {
return data_.mesh; }
42 const VdbVolume&
vdbVolume()
const {
return vdbVolume_; };
48 [[nodiscard]]
virtual bool hasModel()
const override {
return bool( vdbVolume_.data ); }
52 {
return vdbVolume_.dims; }
58 {
return histogram_; }
61 {
return vdbVolume_.voxelSize; }
167 } shadingType{ ShadingType::None };
174 } lutType{ LutType::Rainbow };
190 } alphaType{ AlphaType::Constant };
240 int maxSurfaceVertices_{ 5'000'000 };
241 VdbVolume vdbVolume_;
242 float isoValue_{0.0f};
243 bool dualMarchingCubes_{
true};
245 Histogram histogram_;
246 mutable std::optional<Box3i> activeBounds_;
247 mutable std::optional<size_t> activeVoxels_;
249 const char * serializeFormat_ =
nullptr;
252 VolumeIndexer indexer_ = VolumeIndexer( vdbVolume_.dims );
253 Vector3f reverseVoxelSize_;
255 void updateHistogram_(
float min,
float max, ProgressCallback cb = {} );
259 void setDefaultColors_();
262 void setDefaultSceneProperties_();
#define MRVOXELS_API
see explanation in MRMesh/MRMeshFwd.h
Definition MRVoxelsFwd.h:14
#define MRVOXELS_CLASS
Definition MRVoxelsFwd.h:18
wrapper class that helps mrbind to avoid excess MRVDBFloatGrid.h includes
Definition MRFloatGrid.h:21
Definition MRHistogram.h:13
named object in the data model
Definition MRObject.h:62
Definition MRVolumeIndexer.h:65
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:753
Vector3i getCoordinateByVoxelId(VoxelId id) const
virtual std::string classNameInPlural() const override
Definition MRObjectVoxels.h:34
float max
maximum colored value (voxels with higher values are transparent)
Definition MRObjectVoxels.h:180
ShadingType
shading model
Definition MRObjectVoxels.h:163
virtual std::shared_ptr< Object > shallowClone() const override
virtual void applyScale(float scaleFactor) override
scale object size (all point positions)
const Vector3i & dimensions() const
Returns dimensions of voxel objects.
Definition MRObjectVoxels.h:51
VdbVolume & varVdbVolume()
Definition MRObjectVoxels.h:43
enum MR::ObjectVoxels::VolumeRenderingParams::LutType Rainbow
std::unique_ptr< SimpleVolume > getVolumeRenderingData() const
move volume rendering data to caller: basically used in RenderVolumeObject
Definition MRObjectVoxels.h:154
const Vector3f & voxelSize() const
Definition MRObjectVoxels.h:60
const VoxelBitSet & getVolumeRenderActiveVoxels() const
get active (visible) voxels
Definition MRObjectVoxels.h:130
const char * serializeFormat() const
returns overriden file extension used to serialize voxels inside this object, nullptr means defaultSe...
Definition MRObjectVoxels.h:219
void setVolumeRenderActiveVoxels(const VoxelBitSet &activeVoxels)
set active (visible) voxels (using only in Volume Rendering mode)
bool isVolumeRenderingEnabled() const
Definition MRObjectVoxels.h:148
void setDefaultSerializeVoxelsFormat(std::string newFormat)
const VolumeRenderingParams & getVolumeRenderingParams() const
Definition MRObjectVoxels.h:194
const Box3i & getActiveBounds() const
virtual Expected< bool > setIsoValue(float iso, ProgressCallback cb={}, bool updateSurface=true)
const VoxelBitSet & getSelectedVoxels() const
Definition MRObjectVoxels.h:126
MRVOXELS_CLASS SimpleVolumeMinMax
Definition MRVoxelsFwd.h:35
bool getDualMarchingCubes() const
returns true if the iso-surface is built using Dual Marching Cubes algorithm or false if using Standa...
Definition MRObjectVoxels.h:108
virtual void swapSignals_(Object &other) override
Expected< std::shared_ptr< Mesh > > recalculateIsoSurface(float iso, ProgressCallback cb={}) const
Calculates and return new mesh or error message.
static constexpr const char * StaticClassNameInPlural() noexcept
Definition MRObjectVoxels.h:33
float getIsoValue() const
Returns current iso value.
Definition MRObjectVoxels.h:54
uint8_t alphaLimit
Definition MRObjectVoxels.h:191
std::shared_ptr< Mesh > updateIsoSurface(std::shared_ptr< Mesh > mesh)
const std::shared_ptr< Mesh > & surface() const
Returns iso surface, empty if iso value is not set.
Definition MRObjectVoxels.h:39
IsoSurfaceChangedSignal isoSurfaceChangedSignal
Definition MRObjectVoxels.h:230
void construct(const FloatGrid &grid, const Vector3f &voxelSize, const std::optional< Vector2f > &minmax={})
Signal< void()> IsoSurfaceChangedSignal
signal about Iso-surface changes (from updateIsoSurface)
Definition MRObjectVoxels.h:229
void setVolumeRenderingParams(const VolumeRenderingParams ¶ms)
const VdbVolume & vdbVolume() const
Return VdbVolume.
Definition MRObjectVoxels.h:42
virtual std::vector< std::string > getInfoLines() const override
return several info lines that can better describe the object in the UI
void construct(const VdbVolume &vdbVolume)
Clears all internal data and then creates grid and calculates histogram (surface is not built,...
Histogram recalculateHistogram(std::optional< Vector2f > minmax, ProgressCallback cb={}) const
Calculates and returns new histogram.
void selectVoxels(const VoxelBitSet &selectedVoxels)
Definition MRObjectVoxels.h:127
VoxelId getVoxelIdByCoordinate(const Vector3i &coord) const
virtual void invalidateActiveBoundsCaches()
Call this function in main thread post processing if you call setActiveBounds from progress bar threa...
const FloatGrid & grid() const
Returns Float grid which contains voxels data, see more on openvdb::FloatGrid.
Definition MRObjectVoxels.h:46
VoxelBitSet volumeRenderActiveVoxels_
Definition MRObjectVoxels.h:266
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &path) const override
enum MR::ObjectVoxels::VolumeRenderingParams::ShadingType None
ObjectMeshData data_
Definition MRObjectMeshHolder.h:281
void setSerializeFormat(const char *newFormat)
VdbVolume updateVdbVolume(VdbVolume vdbVolume)
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
const VolumeIndexer & getVolumeIndexer() const
Returns indexer with more options.
Definition MRObjectVoxels.h:142
Expected< void > deserializeModel_(const std::filesystem::path &path, ProgressCallback progressCb={}) override
Reads model from file.
FilterType
Definition MREnums.h:12
tl::expected< T, E > Expected
Definition MRExpected.h:31
bool prepareDataForVolumeRendering(ProgressCallback cb={}) const
VoxelId getVoxelIdByPoint(const Vector3f &point) const
virtual bool hasVisualRepresentation() const override
mesh object can be seen if the mesh has at least one edge
void construct(const SimpleVolumeMinMax &simpleVolumeMinMax, ProgressCallback cb={}, bool normalPlusGrad=false)
static constexpr const char * StaticClassName() noexcept
Definition MRObjectVoxels.h:30
static constexpr const char * StaticTypeName() noexcept
Definition MRObjectVoxels.h:27
Histogram updateHistogram(Histogram histogram)
int getMaxSurfaceVertices() const
gets top limit on the number of vertices in the iso-surface
Definition MRObjectVoxels.h:202
const std::string & defaultSerializeVoxelsFormat()
virtual std::string className() const override
Definition MRObjectVoxels.h:31
FilterType volumeFilterType
volume texture smoothing
Definition MRObjectVoxels.h:160
void updateHistogramAndSurface(ProgressCallback cb={})
void setMaxSurfaceVertices(int maxVerts)
sets top limit on the number of vertices in the iso-surface
float min
minimum colored value (voxels with lower values are transparent)
Definition MRObjectVoxels.h:178
Signal< void()> VoxelsChangedSignal
triggered by changes to voxels data
Definition MRObjectVoxels.h:233
virtual std::shared_ptr< Object > clone() const override
bool operator==(const VolumeRenderingParams &) const =default
ObjectVoxels(ProtectedStruct, const ObjectVoxels &obj)
Definition MRObjectVoxels.h:213
void enableVolumeRendering(bool on)
LutType
coloring type
Definition MRObjectVoxels.h:170
VoxelBitSet selectedVoxels_
Definition MRObjectVoxels.h:265
virtual const char * typeName() const override
Definition MRObjectVoxels.h:28
float samplingStep
Definition MRObjectVoxels.h:183
virtual void setDualMarchingCubes(bool on, bool updateSurface=true, ProgressCallback cb={})
enum MR::ObjectVoxels::VolumeRenderingParams::AlphaType Constant
bool volumeRendering_
Definition MRObjectVoxels.h:269
size_t activeVoxels() const
returns cached information about the number of active voxels
virtual void setVoxelPointPositioner(VoxelPointPositioner positioner)
set voxel point positioner for Marching Cubes (only for Standard Marching Cubes)
Definition MRObjectVoxels.h:113
virtual void setDirtyFlags(uint32_t mask, bool invalidateCaches=true) override
void deserializeFields_(const Json::Value &root) override
double volume() const
returns cached volume of space surrounded by the mesh, which is valid only if mesh is closed
Color oneColor
color that is used for OneColor mode
Definition MRObjectVoxels.h:176
Expected< std::shared_ptr< Mesh > > recalculateIsoSurface(const VdbVolume &volume, float iso, ProgressCallback cb={}) const
Same as above, but takes external volume.
void construct(const SimpleVolume &simpleVolume, const std::optional< Vector2f > &minmax={}, ProgressCallback cb={}, bool normalPlusGrad=false)
ObjectVoxels(const ObjectVoxels &other)=default
virtual void swapBase_(Object &other) override
swaps this object with other
virtual void setActiveBounds(const Box3i &activeBox, ProgressCallback cb={}, bool updateSurface=true)
const Histogram & histogram() const
Returns histogram.
Definition MRObjectVoxels.h:57
const std::shared_ptr< const Mesh > & mesh() const
Definition MRObjectMeshHolder.h:56
std::function< Vector3f(const Vector3f &, const Vector3f &, float, float, float)> VoxelPointPositioner
Definition MRMarchingCubes.h:19
VoxelsChangedSignal voxelsChangedSignal
Definition MRObjectVoxels.h:234
static constexpr Color white() noexcept
Definition MRColor.h:28
AlphaType
type of alpha function on texture
Definition MRObjectVoxels.h:186
void resetFrontColor() override
reset basic object colors to their default values from the current theme
virtual bool hasModel() const override
Definition MRObjectVoxels.h:48
virtual void serializeFields_(Json::Value &root) const override
@ AlphaGradient
Definition MRObjectVoxels.h:166
@ ValueGradient
Definition MRObjectVoxels.h:165
@ other
Angle, normally float. Measure in radians.
Definition MRFeatureObject.h:27
@ Linear
Definition MREnums.h:13
@ OneColor
Definition MRObjectVoxels.h:173
@ GrayShades
Definition MRObjectVoxels.h:171
@ LinearIncreasing
Definition MRObjectVoxels.h:188
@ LinearDecreasing
Definition MRObjectVoxels.h:189
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
struct to control volume rendering texture
Definition MRObjectVoxels.h:158
Definition MRObject.h:284
Definition MRUniquePtr.h:15