MeshLib C++ Docs
Loading...
Searching...
No Matches
MRLineObject.h
Go to the documentation of this file.
1#pragma once
2#include "MRMeshFwd.h"
3#include "MRFeatureObject.h"
4#include "MRVisualObject.h"
5
6namespace MR
7{
8
12{
13public:
17 MRMESH_API LineObject( const std::vector<Vector3f>& pointsToApprox );
18
19 LineObject( LineObject&& ) noexcept = default;
20 LineObject& operator = ( LineObject&& ) noexcept = default;
21
22 constexpr static const char* TypeName() noexcept { return "LineObject"; }
23 virtual const char* typeName() const override { return TypeName(); }
24
27 {}
28
29 std::string getClassName() const override { return "Line"; }
30 std::string getClassNameInPlural() const override { return "Lines"; }
31
32 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
33 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
34
36 MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
38 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
40 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
42 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
44 MRMESH_API void setLength( float size, ViewportId id = {} );
46 [[nodiscard]] MRMESH_API float getLength( ViewportId id = {} ) const;
47 // Returns point considered as base for the feature
48 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
49
51 [[nodiscard]] MRMESH_API Vector3f getPointA( ViewportId id = {} ) const;
53 [[nodiscard]] MRMESH_API Vector3f getPointB( ViewportId id = {} ) const;
54
55 [[deprecated( "This confusingly sets half-length. Use `setLength(halfLen * 2)` instead." )]]
56 void setSize( float halfLen, ViewportId id = {} )
57 {
58 setLength( halfLen * 2 , id );
59 }
60
61 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
62
63 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
64
65protected:
66 LineObject( const LineObject& other ) = default;
67
69 MRMESH_API virtual void swapBase_( Object& other ) override;
70
71 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
72
73 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
74 { return {}; }
75
76 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
77 { return {}; }
78
79 MRMESH_API void setupRenderObject_() const override;
80};
81
82}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:79
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:83
An interface class which allows feature objects to share setters and getters on their main properties...
Definition MRFeatureObject.h:93
Definition MRLineObject.h:12
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:30
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:76
void setSize(float halfLen, ViewportId id={})
Definition MRLineObject.h:56
MRMESH_API void setLength(float size, ViewportId id={})
updates xf to scale size
LineObject(ProtectedStruct, const LineObject &obj)
Definition MRLineObject.h:26
std::string getClassName() const override
return human readable name of subclass
Definition MRLineObject.h:29
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:73
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:23
named object in the data model
Definition MRObject.h:60
Definition MRViewportId.h:16
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:626
tl::expected< T, E > Expected
Definition MRExpected.h:59
Definition MRFeatureObject.h:78
Definition MRObject.h:253