MeshLib C++ Docs
Loading...
Searching...
No Matches
MRLineObject.h
Go to the documentation of this file.
1#pragma once
2#include "MRPch/MRBindingMacros.h"
3#include "MRMeshFwd.h"
4#include "MRFeatureObject.h"
5#include "MRVisualObject.h"
6
7namespace MR
8{
11
12
16{
17public:
21 MRMESH_API LineObject( const std::vector<Vector3f>& pointsToApprox );
22
23 LineObject( LineObject&& ) noexcept = default;
24 LineObject& operator = ( LineObject&& ) noexcept = default;
25
26 constexpr static const char* StaticTypeName() noexcept { return "LineObject"; }
27 virtual const char* typeName() const override { return StaticTypeName(); }
28
29 constexpr static const char* StaticClassName() noexcept { return "Line"; }
30 virtual std::string className() const override { return StaticClassName(); }
31
32 constexpr static const char* StaticClassNameInPlural() noexcept { return "Lines"; }
33 virtual std::string classNameInPlural() const override { return StaticClassNameInPlural(); }
34
37 {}
38
39 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
40 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
41
43 MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
44
46 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
47
49 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
50
52 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
53
55 MRMESH_API void setLength( float size, ViewportId id = {} );
56
58 MRMESH_API void setPoints( const Vector3f& a, const Vector3f& b, ViewportId id = {} );
59
61 [[nodiscard]] MRMESH_API float getLength( ViewportId id = {} ) const;
62
64 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
65
67 [[nodiscard]] MRMESH_API Vector3f getPointA( ViewportId id = {} ) const;
68
70 [[nodiscard]] MRMESH_API Vector3f getPointB( ViewportId id = {} ) const;
71
72 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
73
74 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
75
76protected:
77 LineObject( const LineObject& other ) = default;
78
80 MRMESH_API virtual void swapBase_( Object& other ) override;
81
82 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
83
84 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
85 { return {}; }
86
87 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
88 { return {}; }
89
90 MRMESH_API void setupRenderObject_() const override;
91};
92
93}
#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
static constexpr const char * StaticClassName() noexcept
Definition MRLineObject.h:29
float getLength(ViewportId id={}) const
calculates line size from xf
void setLength(float size, ViewportId id={})
updates xf to scale size
ImVec2 size(const ViewportRectangle &rect)
Definition MRViewport.h:32
static constexpr const char * StaticClassNameInPlural() noexcept
Definition MRLineObject.h:32
virtual std::string className() const override
Definition MRLineObject.h:30
void setPoints(const Vector3f &a, const Vector3f &b, ViewportId id={})
updates xf for line visually to go from point a to point b
virtual const std::vector< FeatureObjectSharedProperty > & getAllSharedProperties() const override
Create and generate list of bounded getters and setters for the main properties of feature object,...
LineObject(const LineObject &other)=default
LineObject(LineObject &&) noexcept=default
virtual Vector3f getBasePoint(ViewportId id={}) const override
Returns point considered as base for the feature.
virtual std::shared_ptr< Object > shallowClone() const override
tl::expected< T, E > Expected
Definition MRExpected.h:31
void setupRenderObject_() const override
Vector3f getDirection(ViewportId id={}) const
calculates direction from xf
void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center
LineObject(const std::vector< Vector3f > &pointsToApprox)
Finds best plane to approx given points.
virtual std::shared_ptr< Object > clone() const override
FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
virtual std::string classNameInPlural() const override
Definition MRLineObject.h:33
virtual void serializeFields_(Json::Value &root) const override
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRLineObject.h:87
FeatureObject(int numDimensions)
numDimensions is 0 for points, 1 for lines, 2 for surface meshes. We don't use 3 at the moment.
void setDirection(const Vector3f &normal, ViewportId id={})
updates xf to fit given normal
LineObject(ProtectedStruct, const LineObject &obj)
Definition MRLineObject.h:36
LineObject()
Creates simple plane object.
Vector3f getPointB(ViewportId id={}) const
Returns the finishing point, aka center + dir * len/2.
static constexpr const char * StaticTypeName() noexcept
Definition MRLineObject.h:26
Vector3f getCenter(ViewportId id={}) const
calculates center from xf
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRLineObject.h:84
Vector3f normal(const MeshTopology &topology, const VertCoords &points, FaceId f)
computes triangular face normal from its vertices
Definition MRMeshMath.h:224
virtual void swapBase_(Object &other) override
swaps this object with other
virtual const char * typeName() const override
Definition MRLineObject.h:27
Vector3f getPointA(ViewportId id={}) const
Returns the starting point, aka center - dir * len/2.
@ 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