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
15{
16public:
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}
#define MRMESH_API
Definition MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMeshFwd.h:87
named object in the data model
Definition MRObject.h:62
Definition MRViewportId.h:16
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:753
virtual const std::vector< FeatureObjectSharedProperty > & getAllSharedProperties() const override
Create and generate list of bounded getters and setters for the main properties of feature object,...
void setNormal(const Vector3f &normal, ViewportId id={})
updates xf to fit given normal
float getSizeX(ViewportId id={}) const
void setSize(float size, ViewportId id={})
updates xf to scale size
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRPlaneObject.h:77
void setSizeX(float size, ViewportId id={})
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRPlaneObject.h:82
virtual Vector3f getBasePoint(ViewportId id={}) const override
Returns point considered as base for the feature.
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
Vector3f getNormal(ViewportId id={}) const
calculates normal from xf
static constexpr const char * StaticTypeName() noexcept
Definition MRPlaneObject.h:25
float getSizeY(ViewportId id={}) const
virtual const char * typeName() const override
Definition MRPlaneObject.h:26
float getSize(ViewportId id={}) const
calculates plane size from xf
PlaneObject(const PlaneObject &other)=default
FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
void setupRenderObject_() const override
tl::expected< T, E > Expected
Definition MRExpected.h:31
virtual void swapBase_(Object &other) override
swaps this object with other
Matrix3f calcLocalBasis(ViewportId id={}) const
calculates normalized directions of X,Y axis of the plane and normal as Z
virtual std::string className() const override
Definition MRPlaneObject.h:29
void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center
PlaneObject(PlaneObject &&) noexcept=default
static constexpr const char * StaticClassName() noexcept
Definition MRPlaneObject.h:28
PlaneObject()
Creates simple plane object.
static constexpr const char * StaticClassNameInPlural() noexcept
Definition MRPlaneObject.h:31
virtual std::string classNameInPlural() const override
Definition MRPlaneObject.h:32
virtual void serializeFields_(Json::Value &root) const override
FeatureObject(int numDimensions)
numDimensions is 0 for points, 1 for lines, 2 for surface meshes. We don't use 3 at the moment.
PlaneObject(const std::vector< Vector3f > &pointsToApprox)
Finds best plane to approx given points.
virtual std::shared_ptr< Object > shallowClone() const override
PlaneObject(ProtectedStruct, const PlaneObject &obj)
Definition MRPlaneObject.h:35
void setSizeY(float size, ViewportId id={})
virtual std::shared_ptr< Object > clone() const override
Vector3f normal(const MeshTopology &topology, const VertCoords &points, FaceId f)
computes triangular face normal from its vertices
Definition MRMeshMath.h:224
Vector3f getCenter(ViewportId id={}) const
calculates center from xf
@ other
Angle, normally float. Measure in radians.
Definition MRFeatureObject.h:27
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRFeatureObject.h:81
Definition MRObject.h:284