MeshLib C++ Docs
Loading...
Searching...
No Matches
MRObjectDistanceMap.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
5#include "MRHeapBytes.h"
6
7
8namespace MR
9{
12
13
17{
18public:
20 ObjectDistanceMap( ObjectDistanceMap&& ) noexcept = default;
21 ObjectDistanceMap& operator = ( ObjectDistanceMap&& ) noexcept = default;
22 virtual ~ObjectDistanceMap() = default;
23
26
27 constexpr static const char* StaticTypeName() noexcept { return "ObjectDistanceMap"; }
28 virtual const char* typeName() const override { return StaticTypeName(); }
29
30 constexpr static const char* StaticClassName() noexcept { return "Distance Map"; }
31 virtual std::string className() const override { return StaticClassName(); }
32
33 constexpr static const char* StaticClassNameInPlural() noexcept { return "Distance Maps"; }
34 virtual std::string classNameInPlural() const override { return StaticClassNameInPlural(); }
35
36 MRMESH_API virtual void applyScale( float scaleFactor ) override;
37
38 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
39 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
40
41 MRMESH_API virtual std::vector<std::string> getInfoLines() const override;
42
48 const std::shared_ptr<DistanceMap>& dmap,
49 const AffineXf3f& dmap2local,
50 bool needUpdateMesh = true,
51 ProgressCallback cb = {} );
52
54 MRMESH_API std::shared_ptr<Mesh> calculateMesh( ProgressCallback cb = {} ) const;
56 MRMESH_API void updateMesh( const std::shared_ptr<Mesh>& mesh );
57
58 [[nodiscard]] const std::shared_ptr<DistanceMap>& getDistanceMap() const { return dmap_; }
59
60 [[nodiscard]] virtual bool hasModel() const override { return bool( dmap_ ); }
61
63 MRMESH_API const AffineXf3f& getToWorldParameters() const { return dmap2local_; }
64
66 [[nodiscard]] MRMESH_API virtual size_t heapBytes() const override;
67
69 MRMESH_API void resetFrontColor() override;
70protected:
72
74 MRMESH_API virtual void swapBase_( Object& other ) override;
75
76 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
77
78 MRMESH_API void deserializeFields_( const Json::Value& root ) override;
79
80 MRMESH_API Expected<void> deserializeModel_( const std::filesystem::path& path, ProgressCallback progressCb = {} ) override;
81
82 MRMESH_API virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& path ) const override;
83private:
84 std::shared_ptr<DistanceMap> dmap_;
85 AffineXf3f dmap2local_;
86
87 const char * saveDistanceMapFormat_{ ".raw" };
88
93 bool construct_(
94 const std::shared_ptr<DistanceMap>& dmap,
95 const AffineXf3f& dmap2local,
96 bool needUpdateMesh = true,
97 ProgressCallback cb = {} );
98
100 void setDefaultColors_();
101
103 void setDefaultSceneProperties_();
104};
105
106}
#define MRMESH_API
Definition MRMeshFwd.h:85
#define MRMESH_CLASS
Definition MRMeshFwd.h:92
named object in the data model
Definition MRObject.h:61
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:759
static constexpr const char * StaticClassNameInPlural() noexcept
Definition MRObjectDistanceMap.h:33
virtual void serializeFields_(Json::Value &root) const override
virtual void applyScale(float scaleFactor) override
scale object size (all point positions)
virtual std::string className() const override
Definition MRObjectDistanceMap.h:31
virtual size_t heapBytes() const override
returns the amount of memory this object occupies on heap
static constexpr const char * StaticClassName() noexcept
Definition MRObjectDistanceMap.h:30
ObjectDistanceMap(ObjectDistanceMap &&) noexcept=default
void resetFrontColor() override
reset basic object colors to their default values from the current theme
void deserializeFields_(const Json::Value &root) override
void updateMesh(const std::shared_ptr< Mesh > &mesh)
updates the grid to the current one
virtual void swapBase_(Object &other) override
swaps this object with other
tl::expected< T, E > Expected
Definition MRExpected.h:31
Expected< void > deserializeModel_(const std::filesystem::path &path, ProgressCallback progressCb={}) override
Reads model from file.
static constexpr const char * StaticTypeName() noexcept
Definition MRObjectDistanceMap.h:27
const std::shared_ptr< DistanceMap > & getDistanceMap() const
Definition MRObjectDistanceMap.h:58
virtual bool hasModel() const override
Definition MRObjectDistanceMap.h:60
virtual std::vector< std::string > getInfoLines() const override
return several info lines that can better describe the object in the UI
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &path) const override
virtual const char * typeName() const override
Definition MRObjectDistanceMap.h:28
bool setDistanceMap(const std::shared_ptr< DistanceMap > &dmap, const AffineXf3f &dmap2local, bool needUpdateMesh=true, ProgressCallback cb={})
virtual std::shared_ptr< Object > clone() const override
virtual std::string classNameInPlural() const override
Definition MRObjectDistanceMap.h:34
ObjectDistanceMap(const ObjectDistanceMap &other)=default
virtual std::shared_ptr< Object > shallowClone() const override
const std::shared_ptr< const Mesh > & mesh() const
Definition MRObjectMeshHolder.h:66
std::shared_ptr< Mesh > calculateMesh(ProgressCallback cb={}) const
creates a grid for this object
const AffineXf3f & getToWorldParameters() const
unlike the name, actually it is the transformation from distance map in local space
Definition MRObjectDistanceMap.h:63
@ other
Angle, normally float. Measure in radians.
Definition MRFeatureObject.h:27
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRObject.h:289