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{
9
13{
14public:
18 MRMESH_API LineObject( const std::vector<Vector3f>& pointsToApprox );
19
20 LineObject( LineObject&& ) noexcept = default;
21 LineObject& operator = ( LineObject&& ) noexcept = default;
22
23 constexpr static const char* TypeName() noexcept { return "LineObject"; }
24 virtual const char* typeName() const override { return TypeName(); }
25
28 {}
29
30 std::string getClassName() const override { return "Line"; }
31 std::string getClassNameInPlural() const override { return "Lines"; }
32
33 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
34 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
35
37 MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
39 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
41 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
43 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
45 MRMESH_API void setLength( float size, ViewportId id = {} );
47 [[nodiscard]] MRMESH_API float getLength( ViewportId id = {} ) const;
48 // Returns point considered as base for the feature
49 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
50
52 [[nodiscard]] MRMESH_API Vector3f getPointA( ViewportId id = {} ) const;
54 [[nodiscard]] MRMESH_API Vector3f getPointB( ViewportId id = {} ) const;
55
56 [[deprecated( "This confusingly sets half-length. Use `setLength(halfLen * 2)` instead." )]]
57 MR_BIND_IGNORE void setSize( float halfLen, ViewportId id = {} )
58 {
59 setLength( halfLen * 2 , id );
60 }
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 LineObject( const LineObject& 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 { return {}; }
76
77 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
78 { return {}; }
79
80 MRMESH_API void setupRenderObject_() const override;
81};
82
83}
#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
Definition MRLineObject.h:13
MRMESH_API Vector3f getDirection(ViewportId id={}) const
calculates direction from xf
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
MRMESH_API float getLength(ViewportId id={}) const
calculates line size from xf
MRMESH_API Vector3f getPointA(ViewportId id={}) const
Returns the starting point, aka center - dir * len/2.
std::string getClassNameInPlural() const override
return human readable name of subclass in plural form
Definition MRLineObject.h:31
MR_BIND_IGNORE void setSize(float halfLen, ViewportId id={})
Definition MRLineObject.h:57
LineObject(const LineObject &other)=default
LineObject(LineObject &&) noexcept=default
MRMESH_API Vector3f getCenter(ViewportId id={}) const
calculates center from xf
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
MRMESH_API LineObject(const std::vector< Vector3f > &pointsToApprox)
Finds best plane to approx given points.
MRMESH_API void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center
MRMESH_API void setupRenderObject_() const override
MRMESH_API FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
virtual MRMESH_API std::shared_ptr< Object > clone() const override
MRMESH_API LineObject()
Creates simple plane object.
MRMESH_API void setDirection(const Vector3f &normal, ViewportId id={})
updates xf to fit given normal
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRLineObject.h:77
MRMESH_API void setLength(float size, ViewportId id={})
updates xf to scale size
LineObject(ProtectedStruct, const LineObject &obj)
Definition MRLineObject.h:27
std::string getClassName() const override
return human readable name of subclass
Definition MRLineObject.h:30
virtual MRMESH_API Vector3f getBasePoint(ViewportId id={}) const override
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRLineObject.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,...
MRMESH_API Vector3f getPointB(ViewportId id={}) const
Returns the finishing point, aka center + dir * len/2.
virtual const char * typeName() const override
Definition MRLineObject.h:24
named object in the data model
Definition MRObject.h:62
Definition MRViewportId.h:16
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:728
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:25
std::array< Vector3f, 3 > MR_BIND_IGNORE
Definition MRMeshBuilderTypes.h:10
Definition MRFeatureObject.h:78
Definition MRObject.h:274