MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSphereObject.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 SphereObject : public AddVisualProperties<FeatureObject, DimensionsVisualizePropertyType::diameter>
15{
16public:
20 MRMESH_API SphereObject( const std::vector<Vector3f>& pointsToApprox );
21
22 SphereObject( SphereObject&& ) noexcept = default;
23 SphereObject& operator = ( SphereObject&& ) noexcept = default;
24
25 constexpr static const char* TypeName() noexcept { return "SphereObject"; }
26 virtual const char* typeName() const override {return TypeName(); }
27
28 constexpr static const char* ClassName() noexcept { return "Sphere"; }
29 virtual std::string className() const override { return ClassName(); }
30
31 constexpr static const char* ClassNameInPlural() noexcept { return "Spheres"; }
32 virtual std::string classNameInPlural() const override { return ClassNameInPlural(); }
33
36
37 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
38 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
39
41 MRMESH_API float getRadius( ViewportId id = {} ) const;
43 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
45 MRMESH_API void setRadius( float radius, ViewportId id = {} );
47 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
48
49 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
50
51 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
52
53protected:
54 SphereObject( const SphereObject& other ) = default;
55
57 MRMESH_API virtual void swapBase_( Object& other ) override;
58
59 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
60
61 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
62 { return {}; }
63
64 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
65 { return {}; }
66
67 MRMESH_API void setupRenderObject_() const override;
68};
69
70}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:84
Definition MRAddVisualPropertiesMixin.h:14
named object in the data model
Definition MRObject.h:62
Definition MRSphereObject.h:15
SphereObject(const SphereObject &other)=default
virtual std::string classNameInPlural() const override
Definition MRSphereObject.h:32
virtual MRMESH_API std::shared_ptr< Object > clone() const override
virtual const char * typeName() const override
Definition MRSphereObject.h:26
MRMESH_API void setRadius(float radius, ViewportId id={})
updates xf to fit given radius
MRMESH_API SphereObject(const std::vector< Vector3f > &pointsToApprox)
Finds best sphere to approx given points.
SphereObject(SphereObject &&) noexcept=default
virtual Expected< void > deserializeModel_(const std::filesystem::path &, ProgressCallback) override
Reads model from file.
Definition MRSphereObject.h:64
MRMESH_API FeatureObjectProjectPointResult projectPoint(const Vector3f &point, ViewportId id={}) const override
MRMESH_API void setCenter(const Vector3f &center, ViewportId id={})
updates xf to fit given center
MRMESH_API Vector3f getCenter(ViewportId id={}) const
calculates center from xf
static constexpr const char * ClassNameInPlural() noexcept
Definition MRSphereObject.h:31
virtual MRMESH_API void serializeFields_(Json::Value &root) const override
virtual MRMESH_API void swapBase_(Object &other) override
swaps this object with other
MRMESH_API void setupRenderObject_() const override
static constexpr const char * ClassName() noexcept
Definition MRSphereObject.h:28
SphereObject(ProtectedStruct, const SphereObject &obj)
Definition MRSphereObject.h:35
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 Expected< std::future< Expected< void > > > serializeModel_(const std::filesystem::path &) const override
Definition MRSphereObject.h:61
virtual std::string className() const override
Definition MRSphereObject.h:29
MRMESH_API SphereObject()
Creates simple sphere object with center in zero and radius - 1.
virtual MRMESH_API std::shared_ptr< Object > shallowClone() const override
MRMESH_API float getRadius(ViewportId id={}) const
calculates radius from xf
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