MeshLib C++ Docs
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 { return "CylinderObject"; }
29 virtual const char* typeName() const override { return TypeName(); }
30
31 constexpr static const char* ClassName() noexcept { return "Cylinder"; }
32 virtual std::string className() const override { return ClassName(); }
33
34 constexpr static const char* ClassNameInPlural() noexcept { return "Cylinders"; }
35 virtual std::string classNameInPlural() const override { return ClassNameInPlural(); }
36
40
41 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
42 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
43
45 MRMESH_API float getRadius( ViewportId id = {} ) const;
47 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
49 MRMESH_API void setRadius( float radius, ViewportId id = {} );
51 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
53 MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
55 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
57 MRMESH_API float getLength( ViewportId id = {} ) const;
59 MRMESH_API void setLength( float length, ViewportId id = {} );
60
61 // Returns point considered as base for the feature
62 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
63
64 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
65
66 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
67
68protected:
69 CylinderObject( const CylinderObject& other ) = default;
70
72 MRMESH_API virtual void swapBase_( Object& other ) override;
73
74 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
75
76 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
77 {
78 return {};
79 }
80
81 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
82 {
83 return {};
84 }
85
86 MRMESH_API void setupRenderObject_() const override;
87};
88
89}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:84
length
Definition MRObjectDimensionsEnum.h:14
Definition MRAddVisualPropertiesMixin.h:14
Definition MRCylinderObject.h:18
CylinderObject(const CylinderObject &other)=default
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRCylinderObject.h:81
static constexpr const char * ClassName() noexcept
Definition MRCylinderObject.h:31
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
CylinderObject(CylinderObject &&) noexcept=default
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRCylinderObject.h:76
MRMESH_API void setRadius(float radius, ViewportId id={})
updates xf to fit given radius
virtual const char * typeName() const override
Definition MRCylinderObject.h:29
MRMESH_API float getLength(ViewportId id={}) const
calculates cylinder length from xf
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
virtual std::string className() const override
Definition MRCylinderObject.h:32
static constexpr const char * ClassNameInPlural() noexcept
Definition MRCylinderObject.h:34
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
virtual std::string classNameInPlural() const override
Definition MRCylinderObject.h:35
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.
named object in the data model
Definition MRObject.h:62
Definition MRViewportId.h:16
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:729
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:25
Definition MRFeatureObject.h:78
Definition MRObject.h:279