MeshLib Documentation
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 virtual std::string getClassName() const override { return "Distance Map"; }
33
39 const std::shared_ptr<DistanceMap>& dmap,
40 const AffineXf3f& dmap2local,
41 bool needUpdateMesh = true,
42 ProgressCallback cb = {} );
43
45 MRMESH_API std::shared_ptr<Mesh> calculateMesh( ProgressCallback cb = {} ) const;
47 MRMESH_API void updateMesh( const std::shared_ptr<Mesh>& mesh );
48
49 [[nodiscard]] const std::shared_ptr<DistanceMap>& getDistanceMap() const { return dmap_; }
50
51 [[nodiscard]] virtual bool hasModel() const override { return bool( dmap_ ); }
52
54 MRMESH_API const AffineXf3f& getToWorldParameters() const { return dmap2local_; }
55
57 [[nodiscard]] MRMESH_API virtual size_t heapBytes() const override;
58
59protected:
60 ObjectDistanceMap( const ObjectDistanceMap& other ) = default;
61
63 MRMESH_API virtual void swapBase_( Object& other ) override;
64
65 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
66
67 MRMESH_API void deserializeFields_( const Json::Value& root ) override;
68
69 MRMESH_API Expected<void> deserializeModel_( const std::filesystem::path& path, ProgressCallback progressCb = {} ) override;
70
71 MRMESH_API virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& path ) const override;
72
73private:
74 std::shared_ptr<DistanceMap> dmap_;
75 AffineXf3f dmap2local_;
76
77 const char * saveDistanceMapFormat_{ "*.raw" };
78
83 bool construct_(
84 const std::shared_ptr<DistanceMap>& dmap,
85 const AffineXf3f& dmap2local,
86 bool needUpdateMesh = true,
87 ProgressCallback cb = {} );
88
90 void setDefaultColors_();
91
93 void setDefaultSceneProperties_();
94};
95
96} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
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:54
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:49
virtual bool hasModel() const override
Definition MRObjectDistanceMap.h:51
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 std::string getClassName() const override
return human readable name of subclass
Definition MRObjectDistanceMap.h:32
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={})
static constexpr const char * TypeName() noexcept
Definition MRObjectDistanceMap.h:23
ObjectDistanceMap(const ObjectDistanceMap &other)=default
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:576
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:58
Definition MRObject.h:246