MeshLib C++ Docs
Loading...
Searching...
No Matches
MRConeObject.h
Go to the documentation of this file.
1#pragma once
2
5#include "MRMeshFwd.h"
6#include "MRFeatureObject.h"
7#include "MRVisualObject.h"
8
9namespace MR
10{
13
14
17class MRMESH_CLASS ConeObject : public AddVisualProperties<FeatureObject,
18 DimensionsVisualizePropertyType::diameter,
19 DimensionsVisualizePropertyType::angle,
20 DimensionsVisualizePropertyType::length
21>
22{
23public:
25 MRMESH_API ConeObject();
27 MRMESH_API ConeObject( const std::vector<Vector3f>& pointsToApprox );
28
29 ConeObject( ConeObject&& ) noexcept = default;
30 ConeObject& operator = ( ConeObject&& ) noexcept = default;
31
32 constexpr static const char* StaticTypeName() noexcept { return "ConeObject"; }
33 virtual const char* typeName() const override { return StaticTypeName(); }
34
35 constexpr static const char* StaticClassName() noexcept { return "Cone"; }
36 virtual std::string className() const override { return StaticClassName(); }
37
38 constexpr static const char* StaticClassNameInPlural() noexcept { return "Cones"; }
39 virtual std::string classNameInPlural() const override { return StaticClassNameInPlural(); }
40
43 {}
44
45 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
46 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
47
49 [[nodiscard]] MRMESH_API float getAngle( ViewportId id = {} ) const;
51 [[nodiscard]] MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
53 [[nodiscard]] MRMESH_API float getHeight( ViewportId id = {} ) const;
55 [[nodiscard]] MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
57 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
59 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
61 MRMESH_API void setHeight( float height, ViewportId id = {} );
63 MRMESH_API void setAngle( float angle, ViewportId id = {} );
65 [[nodiscard]] MRMESH_API float getBaseRadius( ViewportId id = {} ) const;
67 MRMESH_API void setBaseRadius( float radius, ViewportId id = {} );
68
70 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
71
72 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
73
74 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
75
76protected:
77 ConeObject( const ConeObject& other ) = default;
78
80 MRMESH_API virtual void swapBase_( Object& other ) override;
81
82 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
83
84 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
85 {
86 return {};
87 }
88
89 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
90 {
91 return {};
92 }
93
94 MRMESH_API void setupRenderObject_() const override;
95
96private:
98 float getNormalizedRadius_( ViewportId id = {} ) const;
99};
100
101}
Definition MRAddVisualPropertiesMixin.h:17
Definition MRConeObject.h:22
named object in the data model
Definition MRObject.h:62
Definition MRViewportId.h:16
virtual MRMESH_API Vector3f getBasePoint(ViewportId id={}) const override
Returns point considered as base for the feature.
MRMESH_API float getHeight(ViewportId id={}) const
calculates cone height from xf
MRMESH_API void setDirection(const Vector3f &normal, ViewportId id={})
updates xf to fit main axis
MRMESH_API void setAngle(float angle, ViewportId id={})
updates xf to fit given cone angle. It is an angle betweeh main axis and side
static constexpr const char * StaticClassName() noexcept
Definition MRConeObject.h:35
virtual std::string className() const override
Definition MRConeObject.h:36
angle
Definition MRObjectDimensionsEnum.h:16
MRMESH_API void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center. Center is the apex of the cone.
MRMESH_API ConeObject()
Creates simple Cone object with center in zero and radius - 1.
ConeObject(const ConeObject &other)=default
MRMESH_API Vector3f getDirection(ViewportId id={}) const
calculates main axis direction from xf
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
MRMESH_API void setupRenderObject_() const override
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRConeObject.h:89
tl::expected< T, E > Expected
Definition MRExpected.h:31
MRMESH_API void setHeight(float height, ViewportId id={})
updates xf to fit cone height
virtual const char * typeName() const override
Definition MRConeObject.h:33
MRMESH_API Vector3f getCenter(ViewportId id={}) const
calculates center from xf. Center is the apex of the cone.
MRMESH_API float getBaseRadius(ViewportId id={}) const
Computes the base base radius from the xf.
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,...
virtual std::string classNameInPlural() const override
Definition MRConeObject.h:39
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
virtual Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRConeObject.h:84
ConeObject(ProtectedStruct, const ConeObject &obj)
Definition MRConeObject.h:42
MRMESH_API ConeObject(const std::vector< Vector3f > &pointsToApprox)
Finds best Cone to approx given points.
MRMESH_API FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
MRMESH_API float getAngle(ViewportId id={}) const
calculates cone angle from xf. It is an angle betweeh main axis and side.
MRMESH_API void setBaseRadius(float radius, ViewportId id={})
Updates the xf for the new base radius.
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
static constexpr const char * StaticClassNameInPlural() noexcept
Definition MRConeObject.h:38
ConeObject(ConeObject &&) noexcept=default
virtual MRMESH_API std::shared_ptr< Object > clone() const override
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRFeatureObject.h:81
Definition MRObject.h:284