MeshLib Documentation
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
23 {
24 return "PlaneObject";
25 }
26 virtual const char* typeName() const override
27 {
28 return TypeName();
29 }
30
33 {}
34
35 virtual std::string getClassName() const override
36 {
37 return "Plane";
38 }
39
40 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
41 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
42
44 [[nodiscard]] MRMESH_API Vector3f getNormal( ViewportId id = {} ) const;
46 [[nodiscard]] MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
48 MRMESH_API void setNormal( const Vector3f& normal, ViewportId id = {} );
50 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
52 MRMESH_API void setSize( float size, ViewportId id = {} );
54 [[nodiscard]] MRMESH_API float getSize( ViewportId id = {} ) const;
55
56 [[nodiscard]] MRMESH_API float getSizeX( ViewportId id = {} ) const;
57 [[nodiscard]] MRMESH_API float getSizeY( ViewportId id = {} ) const;
59 [[nodiscard]] MRMESH_API Matrix3f calcLocalBasis( ViewportId id = {} ) const;
60
61 MRMESH_API void setSizeX( float size, ViewportId id = {} );
62 MRMESH_API void setSizeY( float size, ViewportId id = {} );
63
64 // Returns point considered as base for the feature
65 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
66
67 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
68
69 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
70
71protected:
72 PlaneObject( const PlaneObject& other ) = default;
73
75 MRMESH_API virtual void swapBase_( Object& other ) override;
76
77 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
78
79 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
80 {
81 return {};
82 }
83
84 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
85 {
86 return {};
87 }
88
89 MRMESH_API void setupRenderObject_() const override;
90
91private:
92 void orientateFollowMainAxis_( ViewportId id = {} );
93 void setupPlaneSize2DByOriginalPoints_( const std::vector<Vector3f>& pointsToApprox );
94};
95
96}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
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:60
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:79
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:84
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
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
MRMESH_API void setSizeX(float size, ViewportId id={})
MRMESH_API Vector3f getCenter(ViewportId id={}) const
calculates center from xf
PlaneObject(PlaneObject &&) noexcept=default
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.
virtual std::string getClassName() const override
return human readable name of subclass
Definition MRPlaneObject.h:35
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:576
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:58
Definition MRFeatureObject.h:78
Definition MRObject.h:246