MeshLib
 
Loading...
Searching...
No Matches
MRCylinderObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRFeatureObject.h"
6#include "MRMeshFwd.h"
7#include "MRVisualObject.h"
8
9namespace MR
10{
11
14class MRMESH_CLASS CylinderObject : public AddVisualProperties<FeatureObject,
15 DimensionsVisualizePropertyType::diameter,
16 DimensionsVisualizePropertyType::length
17>
18{
19public:
23 MRMESH_API CylinderObject( const std::vector<Vector3f>& pointsToApprox );
24
25 CylinderObject( CylinderObject&& ) noexcept = default;
26 CylinderObject& operator = ( CylinderObject&& ) noexcept = default;
27
28 constexpr static const char* TypeName() noexcept
29 {
30 return "CylinderObject";
31 }
32 virtual const char* typeName() const override
33 {
34 return TypeName();
35 }
36
40
41 virtual std::string getClassName() const override
42 {
43 return "Cylinder";
44 }
45
46 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
47 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
48
50 MRMESH_API float getRadius( ViewportId id = {} ) const;
54 MRMESH_API void setRadius( float radius, ViewportId id = {} );
56 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
60 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
62 MRMESH_API float getLength( ViewportId id = {} ) const;
64 MRMESH_API void setLength( float length, ViewportId id = {} );
65
66 // Returns point considered as base for the feature
67 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
68
69 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
70
71 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
72
73protected:
74 CylinderObject( const CylinderObject& other ) = default;
75
77 MRMESH_API virtual void swapBase_( Object& other ) override;
78
79 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
80
81 virtual Expected<std::future<VoidOrErrStr>> serializeModel_( const std::filesystem::path& ) const override
82 {
83 return {};
84 }
85
86 virtual VoidOrErrStr deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
87 {
88 return {};
89 }
90
91 MRMESH_API void setupRenderObject_() const override;
92};
93
94}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
length
Definition MRObjectDimensionsEnum.h:14
Definition MRAddVisualPropertiesMixin.h:14
Definition MRCylinderObject.h:18
CylinderObject(const CylinderObject &other)=default
MRMESH_API Vector3f getDirection(ViewportId id={}) const
calculates main axis direction from xf
MRMESH_API void setLength(float length, ViewportId id={})
updates xf to fit cylinder length
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 getCenter(ViewportId id={}) const
calculates center from xf
virtual Expected< std::future< VoidOrErrStr > > serializeModel_(const std::filesystem::path &) const override
Definition MRCylinderObject.h:81
virtual VoidOrErrStr deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRCylinderObject.h:86
CylinderObject(CylinderObject &&) noexcept=default
MRMESH_API void setRadius(float radius, ViewportId id={})
updates xf to fit given radius
virtual const char * typeName() const override
Definition MRCylinderObject.h:32
MRMESH_API float getLength(ViewportId id={}) const
calculates cylinder length from xf
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
MRMESH_API void setDirection(const Vector3f &normal, ViewportId id={})
updates xf to fit main axis
virtual MRMESH_API std::shared_ptr< Object > clone() const override
MRMESH_API float getRadius(ViewportId id={}) const
calculates radius from xf
virtual MRMESH_API Vector3f getBasePoint(ViewportId id={}) const override
MRMESH_API FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
MRMESH_API void setupRenderObject_() const override
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
MRMESH_API void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
MRMESH_API CylinderObject(const std::vector< Vector3f > &pointsToApprox)
Finds best Cylinder to approx given points.
CylinderObject(ProtectedStruct, const CylinderObject &obj)
Definition MRCylinderObject.h:38
MRMESH_API CylinderObject()
Creates simple Cylinder object with center in zero and radius - 1.
virtual std::string getClassName() const override
return human readable name of subclass
Definition MRCylinderObject.h:41
named object in the data model
Definition MRObject.h:60
Definition MRViewportId.h:16
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:589
Definition MRCameraOrientationPlugin.h:7
tl::expected< T, E > Expected
Definition MRExpected.h:49
Expected< void > VoidOrErrStr
return type for a void function that can produce an error string
Definition MRExpected.h:60
Definition MRFeatureObject.h:78
Definition MRObject.h:246