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{
10
11
14class MRMESH_CLASS PlaneObject : public FeatureObject
15{
16public:
18 MRMESH_API PlaneObject();
20 MRMESH_API PlaneObject( const std::vector<Vector3f>& pointsToApprox );
21
22 PlaneObject( PlaneObject&& ) noexcept = default;
23 PlaneObject& operator = ( PlaneObject&& ) noexcept = default;
24
25 constexpr static const char* StaticTypeName() noexcept { return "PlaneObject"; }
26 virtual const char* typeName() const override { return StaticTypeName(); }
27
28 constexpr static const char* StaticClassName() noexcept { return "Plane"; }
29 virtual std::string className() const override { return StaticClassName(); }
30
31 constexpr static const char* StaticClassNameInPlural() noexcept { return "Planes"; }
32 virtual std::string classNameInPlural() const override { return StaticClassNameInPlural(); }
33
36 {}
37
38 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
39 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
40
42 [[nodiscard]] MRMESH_API Vector3f getNormal( ViewportId id = {} ) const;
44 [[nodiscard]] MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
46 MRMESH_API void setNormal( const Vector3f& normal, ViewportId id = {} );
48 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
50 MRMESH_API void setSize( float size, ViewportId id = {} );
52 [[nodiscard]] MRMESH_API float getSize( ViewportId id = {} ) const;
53
54 [[nodiscard]] MRMESH_API float getSizeX( ViewportId id = {} ) const;
55 [[nodiscard]] MRMESH_API float getSizeY( ViewportId id = {} ) const;
57 [[nodiscard]] MRMESH_API Matrix3f calcLocalBasis( ViewportId id = {} ) const;
58
59 MRMESH_API void setSizeX( float size, ViewportId id = {} );
60 MRMESH_API void setSizeY( float size, ViewportId id = {} );
61
63 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
64
65 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
66
67 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
68
69protected:
70 PlaneObject( const PlaneObject& other ) = default;
71
73 MRMESH_API virtual void swapBase_( Object& other ) override;
74
75 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
76
77 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
78 {
79 return {};
80 }
81
82 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
83 {
84 return {};
85 }
86
87 MRMESH_API void setupRenderObject_() const override;
88
89private:
90 void orientateFollowMainAxis_( ViewportId id = {} );
91 void setupPlaneSize2DByOriginalPoints_( const std::vector<Vector3f>& pointsToApprox );
92};
93
94}
An interface class which allows feature objects to share setters and getters on their main properties...
Definition MRFeatureObject.h:96
named object in the data model
Definition MRObject.h:62
Definition MRPlaneObject.h:15
Definition MRViewportId.h:16
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:77
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:82
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:26
MRMESH_API Matrix3f calcLocalBasis(ViewportId id={}) const
calculates normalized directions of X,Y axis of the plane and normal as Z
PlaneObject(const PlaneObject &other)=default
MRMESH_API float getSizeX(ViewportId id={}) const
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
tl::expected< T, E > Expected
Definition MRExpected.h:31
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:29
MRMESH_API void setSizeX(float size, ViewportId id={})
MRMESH_API Vector3f getCenter(ViewportId id={}) const
calculates center from xf
PlaneObject(PlaneObject &&) noexcept=default
static constexpr const char * StaticClassName() noexcept
Definition MRPlaneObject.h:28
static constexpr const char * StaticClassNameInPlural() noexcept
Definition MRPlaneObject.h:31
virtual std::string classNameInPlural() const override
Definition MRPlaneObject.h:32
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:35
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
Returns point considered as base for the feature.
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRFeatureObject.h:81
Definition MRObject.h:284