MeshLib C++ Docs
Loading...
Searching...
No Matches
MRObjectDistanceMap.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
5
6
7namespace MR
8{
9
13{
14public:
16 ObjectDistanceMap( ObjectDistanceMap&& ) noexcept = default;
17 ObjectDistanceMap& operator = ( ObjectDistanceMap&& ) noexcept = default;
18 virtual ~ObjectDistanceMap() = default;
19
22
23 constexpr static const char* TypeName() noexcept { return "ObjectDistanceMap"; }
24 virtual const char* typeName() const override { return TypeName(); }
25
26 MRMESH_API virtual void applyScale( float scaleFactor ) override;
27
28 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
29 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
30
31 MRMESH_API virtual std::vector<std::string> getInfoLines() const override;
32
33 std::string getClassName() const override { return "Distance Map"; }
34 std::string getClassNameInPlural() const override { return "Distance Maps"; }
35
41 const std::shared_ptr<DistanceMap>& dmap,
42 const AffineXf3f& dmap2local,
43 bool needUpdateMesh = true,
44 ProgressCallback cb = {} );
45
47 MRMESH_API std::shared_ptr<Mesh> calculateMesh( ProgressCallback cb = {} ) const;
49 MRMESH_API void updateMesh( const std::shared_ptr<Mesh>& mesh );
50
51 [[nodiscard]] const std::shared_ptr<DistanceMap>& getDistanceMap() const { return dmap_; }
52
53 [[nodiscard]] virtual bool hasModel() const override { return bool( dmap_ ); }
54
56 MRMESH_API const AffineXf3f& getToWorldParameters() const { return dmap2local_; }
57
59 [[nodiscard]] MRMESH_API virtual size_t heapBytes() const override;
60
61protected:
62 ObjectDistanceMap( const ObjectDistanceMap& other ) = default;
63
65 MRMESH_API virtual void swapBase_( Object& other ) override;
66
67 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
68
69 MRMESH_API void deserializeFields_( const Json::Value& root ) override;
70
71 MRMESH_API Expected<void> deserializeModel_( const std::filesystem::path& path, ProgressCallback progressCb = {} ) override;
72
73 MRMESH_API virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& path ) const override;
74
75private:
76 std::shared_ptr<DistanceMap> dmap_;
77 AffineXf3f dmap2local_;
78
79 const char * saveDistanceMapFormat_{ "*.raw" };
80
85 bool construct_(
86 const std::shared_ptr<DistanceMap>& dmap,
87 const AffineXf3f& dmap2local,
88 bool needUpdateMesh = true,
89 ProgressCallback cb = {} );
90
92 void setDefaultColors_();
93
95 void setDefaultSceneProperties_();
96};
97
98} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:83
Definition MRObjectDistanceMap.h:13
MRMESH_API const AffineXf3f & getToWorldParameters() const
unlike the name, actually it is the transformation from distance map in local space
Definition MRObjectDistanceMap.h:56
virtual MRMESH_API Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &path) const override
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
MRMESH_API std::shared_ptr< Mesh > calculateMesh(ProgressCallback cb={}) const
creates a grid for this object
MRMESH_API void updateMesh(const std::shared_ptr< Mesh > &mesh)
updates the grid to the current one
MRMESH_API ObjectDistanceMap()
virtual MRMESH_API std::shared_ptr< Object > clone() const override
ObjectDistanceMap(ObjectDistanceMap &&) noexcept=default
MRMESH_API Expected< void > deserializeModel_(const std::filesystem::path &path, ProgressCallback progressCb={}) override
Reads model from file.
MRMESH_API void deserializeFields_(const Json::Value &root) override
virtual MRMESH_API std::vector< std::string > getInfoLines() const override
return several info lines that can better describe the object in the UI
const std::shared_ptr< DistanceMap > & getDistanceMap() const
Definition MRObjectDistanceMap.h:51
virtual bool hasModel() const override
Definition MRObjectDistanceMap.h:53
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
virtual MRMESH_API size_t heapBytes() const override
returns the amount of memory this object occupies on heap
virtual const char * typeName() const override
Definition MRObjectDistanceMap.h:24
MRMESH_API bool setDistanceMap(const std::shared_ptr< DistanceMap > &dmap, const AffineXf3f &dmap2local, bool needUpdateMesh=true, ProgressCallback cb={})
std::string getClassNameInPlural() const override
return human readable name of subclass in plural form
Definition MRObjectDistanceMap.h:34
static constexpr const char * TypeName() noexcept
Definition MRObjectDistanceMap.h:23
ObjectDistanceMap(const ObjectDistanceMap &other)=default
std::string getClassName() const override
return human readable name of subclass
Definition MRObjectDistanceMap.h:33
virtual MRMESH_API void applyScale(float scaleFactor) override
scale object size (all point positions)
Definition MRObjectMeshHolder.h:30
named object in the data model
Definition MRObject.h:60
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
tl::expected< T, E > Expected
Definition MRExpected.h:59
Definition MRObject.h:253