MeshLib C++ Docs
Loading...
Searching...
No Matches
MRPlaneObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include "MRFeatureObject.h"
5
6namespace MR
7{
8
12{
13public:
17 MRMESH_API PlaneObject( const std::vector<Vector3f>& pointsToApprox );
18
19 PlaneObject( PlaneObject&& ) noexcept = default;
20 PlaneObject& operator = ( PlaneObject&& ) noexcept = default;
21
22 constexpr static const char* TypeName() noexcept { return "PlaneObject"; }
23 virtual const char* typeName() const override { return TypeName(); }
24
25 constexpr static const char* ClassName() noexcept { return "Plane"; }
26 virtual std::string className() const override { return ClassName(); }
27
28 constexpr static const char* ClassNameInPlural() noexcept { return "Planes"; }
29 virtual std::string classNameInPlural() const override { return ClassNameInPlural(); }
30
33 {}
34
35 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
36 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
37
39 [[nodiscard]] MRMESH_API Vector3f getNormal( ViewportId id = {} ) const;
41 [[nodiscard]] MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
43 MRMESH_API void setNormal( const Vector3f& normal, ViewportId id = {} );
45 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
47 MRMESH_API void setSize( float size, ViewportId id = {} );
49 [[nodiscard]] MRMESH_API float getSize( ViewportId id = {} ) const;
50
51 [[nodiscard]] MRMESH_API float getSizeX( ViewportId id = {} ) const;
52 [[nodiscard]] MRMESH_API float getSizeY( ViewportId id = {} ) const;
54 [[nodiscard]] MRMESH_API Matrix3f calcLocalBasis( ViewportId id = {} ) const;
55
56 MRMESH_API void setSizeX( float size, ViewportId id = {} );
57 MRMESH_API void setSizeY( float size, ViewportId id = {} );
58
59 // Returns point considered as base for the feature
60 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
61
62 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
63
64 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
65
66protected:
67 PlaneObject( const PlaneObject& other ) = default;
68
70 MRMESH_API virtual void swapBase_( Object& other ) override;
71
72 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
73
74 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
75 {
76 return {};
77 }
78
79 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
80 {
81 return {};
82 }
83
84 MRMESH_API void setupRenderObject_() const override;
85
86private:
87 void orientateFollowMainAxis_( ViewportId id = {} );
88 void setupPlaneSize2DByOriginalPoints_( const std::vector<Vector3f>& pointsToApprox );
89};
90
91}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:84
An interface class which allows feature objects to share setters and getters on their main properties...
Definition MRFeatureObject.h:93
named object in the data model
Definition MRObject.h:62
Definition MRPlaneObject.h:12
MRMESH_API float getSize(ViewportId id={}) const
calculates plane size from xf
MRMESH_API Vector3f getNormal(ViewportId id={}) const
calculates normal from xf
MRMESH_API void setupRenderObject_() const override
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRPlaneObject.h:74
virtual MRMESH_API const std::vector< FeatureObjectSharedProperty > & getAllSharedProperties() const override
Create and generate list of bounded getters and setters for the main properties of feature object,...
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRPlaneObject.h:79
MRMESH_API PlaneObject(const std::vector< Vector3f > &pointsToApprox)
Finds best plane to approx given points.
MRMESH_API float getSizeY(ViewportId id={}) const
virtual MRMESH_API std::shared_ptr< Object > clone() const override
virtual const char * typeName() const override
Definition MRPlaneObject.h:23
MRMESH_API Matrix3f calcLocalBasis(ViewportId id={}) const
calculates normalized directions of X,Y axis of the plane and normal as Z
static constexpr const char * ClassNameInPlural() noexcept
Definition MRPlaneObject.h:28
PlaneObject(const PlaneObject &other)=default
static constexpr const char * ClassName() noexcept
Definition MRPlaneObject.h:25
MRMESH_API float getSizeX(ViewportId id={}) const
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
MRMESH_API void setSize(float size, ViewportId id={})
updates xf to scale size
MRMESH_API void setNormal(const Vector3f &normal, ViewportId id={})
updates xf to fit given normal
virtual std::string className() const override
Definition MRPlaneObject.h:26
MRMESH_API void setSizeX(float size, ViewportId id={})
MRMESH_API Vector3f getCenter(ViewportId id={}) const
calculates center from xf
PlaneObject(PlaneObject &&) noexcept=default
virtual std::string classNameInPlural() const override
Definition MRPlaneObject.h:29
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
MRMESH_API FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
MRMESH_API PlaneObject()
Creates simple plane object.
PlaneObject(ProtectedStruct, const PlaneObject &obj)
Definition MRPlaneObject.h:32
MRMESH_API void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center
MRMESH_API void setSizeY(float size, ViewportId id={})
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
virtual MRMESH_API Vector3f getBasePoint(ViewportId id={}) const override
Definition MRViewportId.h:16
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:729
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:25
Definition MRFeatureObject.h:78
Definition MRObject.h:279