MeshLib
 
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{
11
14class MRMESH_CLASS ConeObject : public AddVisualProperties<FeatureObject,
15 DimensionsVisualizePropertyType::diameter,
16 DimensionsVisualizePropertyType::angle,
17 DimensionsVisualizePropertyType::length
18>
19{
20public:
24 MRMESH_API ConeObject( const std::vector<Vector3f>& pointsToApprox );
25
26 ConeObject( ConeObject&& ) noexcept = default;
27 ConeObject& operator = ( ConeObject&& ) noexcept = default;
28
29 constexpr static const char* TypeName() noexcept
30 {
31 return "ConeObject";
32 }
33 virtual const char* typeName() const override
34 {
35 return TypeName();
36 }
37
40 {}
41
42 virtual std::string getClassName() const override
43 {
44 return "Cone";
45 }
46
47 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
48 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
49
51 [[nodiscard]] MRMESH_API float getAngle( ViewportId id = {} ) const;
53 [[nodiscard]] MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
55 [[nodiscard]] MRMESH_API float getHeight( ViewportId id = {} ) const;
57 [[nodiscard]] MRMESH_API Vector3f getDirection( ViewportId id = {} ) const;
59 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
61 MRMESH_API void setDirection( const Vector3f& normal, ViewportId id = {} );
63 MRMESH_API void setHeight( float height, ViewportId id = {} );
65 MRMESH_API void setAngle( float angle, ViewportId id = {} );
67 [[nodiscard]] MRMESH_API float getBaseRadius( ViewportId id = {} ) const;
69 MRMESH_API void setBaseRadius( float radius, ViewportId id = {} );
70
71 // Returns point considered as base for the feature
72 [[nodiscard]] MRMESH_API virtual Vector3f getBasePoint( ViewportId id = {} ) const override;
73
74 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
75
76 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
77
78protected:
79 ConeObject( const ConeObject& other ) = default;
80
82 MRMESH_API virtual void swapBase_( Object& other ) override;
83
84 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
85
86 virtual Expected<std::future<VoidOrErrStr>> serializeModel_( const std::filesystem::path& ) const override
87 {
88 return {};
89 }
90
91 virtual VoidOrErrStr deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
92 {
93 return {};
94 }
95
96 MRMESH_API void setupRenderObject_() const override;
97
98private:
99 // Featue Radius fully controll by cone angle, but its need for speedup internal calculation (not use tan / atan from each estimation).
100 float getNormalizedRadius_( ViewportId id = {} ) const;
101};
102
103}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
angle
Definition MRObjectDimensionsEnum.h:13
Definition MRAddVisualPropertiesMixin.h:14
Definition MRConeObject.h:19
virtual MRMESH_API Vector3f getBasePoint(ViewportId id={}) const override
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
virtual Expected< std::future< VoidOrErrStr > > serializeModel_(const std::filesystem::path &) const override
Definition MRConeObject.h:86
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
MRMESH_API void setHeight(float height, ViewportId id={})
updates xf to fit cone height
virtual std::string getClassName() const override
return human readable name of subclass
Definition MRConeObject.h:42
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 MRMESH_API std::shared_ptr< Object > shallowClone() const override
virtual VoidOrErrStr deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRConeObject.h:91
ConeObject(ProtectedStruct, const ConeObject &obj)
Definition MRConeObject.h:39
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
ConeObject(ConeObject &&) noexcept=default
virtual MRMESH_API std::shared_ptr< Object > clone() const override
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