MeshLib Documentation
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 virtual std::string getClassName() const override { return "Line"; }
30
31 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
32 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
33
35 MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
37 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
39 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
41 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
43 MRMESH_API void setLength( float size, ViewportId id = {} );
45 [[nodiscard]] MRMESH_API float getLength( ViewportId id = {} ) const;
46 // Returns point considered as base for the feature
47 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
48
50 [[nodiscard]] MRMESH_API Vector3f getPointA( ViewportId id = {} ) const;
52 [[nodiscard]] MRMESH_API Vector3f getPointB( ViewportId id = {} ) const;
53
54 [[deprecated( "This confusingly sets half-length. Use `setLength(halfLen * 2)` instead." )]]
55 void setSize( float halfLen, ViewportId id = {} )
56 {
57 setLength( halfLen * 2 , id );
58 }
59
60 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
61
62 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
63
64protected:
65 LineObject( const LineObject& other ) = default;
66
68 MRMESH_API virtual void swapBase_( Object& other ) override;
69
70 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
71
72 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
73 { return {}; }
74
75 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
76 { return {}; }
77
78 MRMESH_API void setupRenderObject_() const override;
79};
80
81}
#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
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.
LineObject(const LineObject &other)=default
LineObject(LineObject &&) noexcept=default
virtual std::string getClassName() const override
return human readable name of subclass
Definition MRLineObject.h:29
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:75
void setSize(float halfLen, ViewportId id={})
Definition MRLineObject.h:55
MRMESH_API void setLength(float size, ViewportId id={})
updates xf to scale size
LineObject(ProtectedStruct, const LineObject &obj)
Definition MRLineObject.h:26
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:72
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:576
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:58
Definition MRFeatureObject.h:78
Definition MRObject.h:246