MeshLib Documentation
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
30
31 virtual std::string getClassName() const override { return "Sphere"; }
32
33 MRMESH_API virtual std::shared_ptr<Object> clone() const override;
34 MRMESH_API virtual std::shared_ptr<Object> shallowClone() const override;
35
37 MRMESH_API float getRadius( ViewportId id = {} ) const;
39 MRMESH_API Vector3f getCenter( ViewportId id = {} ) const;
41 MRMESH_API void setRadius( float radius, ViewportId id = {} );
43 MRMESH_API void setCenter( const Vector3f& center, ViewportId id = {} );
44
45 MRMESH_API virtual const std::vector<FeatureObjectSharedProperty>& getAllSharedProperties() const override;
46
47 [[nodiscard]] MRMESH_API FeatureObjectProjectPointResult projectPoint( const Vector3f& point, ViewportId id = {} ) const override;
48
49protected:
50 SphereObject( const SphereObject& other ) = default;
51
53 MRMESH_API virtual void swapBase_( Object& other ) override;
54
55 MRMESH_API virtual void serializeFields_( Json::Value& root ) const override;
56
57 virtual Expected<std::future<Expected<void>>> serializeModel_( const std::filesystem::path& ) const override
58 { return {}; }
59
60 virtual Expected<void> deserializeModel_( const std::filesystem::path&, ProgressCallback ) override
61 { return {}; }
62
63 MRMESH_API void setupRenderObject_() const override;
64};
65
66}
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
#define MRMESH_CLASS
Definition MRMesh/MRMeshFwd.h:50
Definition MRAddVisualPropertiesMixin.h:14
named object in the data model
Definition MRObject.h:60
Definition MRSphereObject.h:15
SphereObject(const SphereObject &other)=default
virtual MRMESH_API std::shared_ptr< Object > clone() const override
virtual std::string getClassName() const override
return human readable name of subclass
Definition MRSphereObject.h:31
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:60
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
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
SphereObject(ProtectedStruct, const SphereObject &obj)
Definition MRSphereObject.h:29
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:57
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:576
Definition MRCameraOrientationPlugin.h:8
tl::expected< T, E > Expected
Definition MRExpected.h:58
Definition MRFeatureObject.h:78
Definition MRObject.h:246