refactor: standardize object type identification using uLibTypeMacro and update serialization macros
This commit is contained in:
@@ -26,7 +26,6 @@ Assembly::Assembly()
|
||||
m_BBoxMax(Vector3f::Zero()),
|
||||
m_ShowBoundingBox(false),
|
||||
m_GroupSelection(true) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
}
|
||||
|
||||
Assembly::Assembly(const Assembly ©)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace uLib {
|
||||
class Assembly : public ObjectsContext, public TRS {
|
||||
public:
|
||||
uLibTypeMacro(Assembly, ObjectsContext, TRS)
|
||||
virtual const char *GetClassName() const override { return "Assembly"; }
|
||||
|
||||
|
||||
Assembly();
|
||||
Assembly(const Assembly ©);
|
||||
@@ -113,6 +113,8 @@ private:
|
||||
bool m_GroupSelection;
|
||||
bool m_InUpdated = false;
|
||||
std::map<Object*, Connection> m_ChildConnections;
|
||||
|
||||
ULIB_DECLARE_PROPERTIES(Assembly)
|
||||
};
|
||||
|
||||
} // namespace uLib
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "Geometry.h"
|
||||
#include "Core/Object.h"
|
||||
#include "Core/Property.h"
|
||||
#include "Core/Serializable.h"
|
||||
#include "Math/Dense.h"
|
||||
#include "Math/Transform.h"
|
||||
#include <utility>
|
||||
@@ -48,16 +49,11 @@ namespace uLib {
|
||||
*/
|
||||
class ContainerBox : public TRS {
|
||||
|
||||
public:
|
||||
uLibTypeMacro(ContainerBox, TRS)
|
||||
ULIB_SERIALIZE_ACCESS
|
||||
ULIB_DECLARE_PROPERTIES(ContainerBox)
|
||||
|
||||
virtual const char * GetClassName() const override { return "ContainerBox"; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// PROPERTIES //
|
||||
|
||||
Vector3f Size;
|
||||
Vector3f Origin;
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Default constructor.
|
||||
@@ -67,7 +63,6 @@ public:
|
||||
: m_LocalT(this), // BaseClass is Parent of m_LocalTransform
|
||||
Size(1.0f, 1.0f, 1.0f),
|
||||
Origin(0.0f, 0.0f, 0.0f) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
@@ -79,7 +74,6 @@ public:
|
||||
: m_LocalT(this),
|
||||
Size(size),
|
||||
Origin(0.0f, 0.0f, 0.0f) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
@@ -92,13 +86,12 @@ public:
|
||||
TRS(copy),
|
||||
Size(copy.Size),
|
||||
Origin(copy.Origin) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Serialization template for property registration and persistence.
|
||||
*/
|
||||
// /**
|
||||
// * @brief Serialization template for property registration and persistence.
|
||||
// */
|
||||
template <class ArchiveT>
|
||||
void serialize(ArchiveT & ar, const unsigned int version) {
|
||||
ar & HRP(Size);
|
||||
@@ -236,9 +229,13 @@ private:
|
||||
|
||||
|
||||
private:
|
||||
Vector3f Size;
|
||||
Vector3f Origin;
|
||||
AffineTransform m_LocalT;
|
||||
|
||||
};
|
||||
|
||||
} // namespace uLib
|
||||
|
||||
|
||||
#endif // CONTAINERBOX_H
|
||||
|
||||
@@ -41,8 +41,10 @@ namespace uLib {
|
||||
*/
|
||||
class Cylinder : public TRS {
|
||||
|
||||
public:
|
||||
uLibTypeMacro(Cylinder, TRS)
|
||||
ULIB_DECLARE_PROPERTIES(Cylinder)
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief PROPERTIES
|
||||
@@ -51,22 +53,20 @@ public:
|
||||
float Height;
|
||||
int Axis;
|
||||
|
||||
virtual const char * GetClassName() const override { return "Cylinder"; }
|
||||
|
||||
|
||||
/**
|
||||
* @brief Default constructor. Aligns with Y by default.
|
||||
*/
|
||||
Cylinder() : m_LocalT(this), Radius(1.0), Height(1.0), Axis(1) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructor with radius and height.
|
||||
*/
|
||||
Cylinder(float radius, float height, int axis = 1)
|
||||
Cylinder(float radius, float height, int axis = 1)
|
||||
: m_LocalT(this), Radius(radius), Height(height), Axis(axis) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
@@ -75,7 +75,6 @@ public:
|
||||
*/
|
||||
Cylinder(const Cylinder ©)
|
||||
: m_LocalT(this), TRS(copy), Radius(copy.Radius), Height(copy.Height), Axis(copy.Axis) {
|
||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
||||
this->Sync();
|
||||
}
|
||||
|
||||
@@ -84,10 +83,10 @@ public:
|
||||
*/
|
||||
template <class ArchiveT>
|
||||
void serialize(ArchiveT & ar, const unsigned int version) {
|
||||
ar & boost::serialization::make_nvp("TRS", boost::serialization::base_object<TRS>(*this));
|
||||
ar & HRP(Radius);
|
||||
ar & HRP(Height);
|
||||
ar & HRP(Axis);
|
||||
ar & boost::serialization::make_hrp_enum("Axis", Axis, {"X", "Y", "Z"});
|
||||
ar & HRP("TRS", boost::serialization::base_object<TRS>(*this));
|
||||
}
|
||||
|
||||
/** Sets the radius of the cylinder */
|
||||
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
public:
|
||||
uLibTypeMacro(Geometry, Object)
|
||||
|
||||
virtual const char * GetClassName() const override { return "Geometry"; }
|
||||
|
||||
|
||||
virtual void SetParent(Geometry* p) { m_Parent = p; }
|
||||
virtual Geometry* GetParent() const { return m_Parent; }
|
||||
@@ -93,7 +93,7 @@ protected:
|
||||
public:
|
||||
uLibTypeMacro(LinearGeometry, Geometry)
|
||||
|
||||
virtual const char * GetClassName() const override { return "LinearGeometry"; }
|
||||
|
||||
|
||||
virtual bool IsLinear() const override { return true; }
|
||||
virtual bool IsPure() const override { return true; }
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
uLibTypeMacro(CylindricalGeometry, LinearGeometry)
|
||||
CylindricalGeometry() {}
|
||||
|
||||
virtual const char * GetClassName() const override { return "CylindricalGeometry"; }
|
||||
|
||||
|
||||
virtual bool IsPure() const override { return false; }
|
||||
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
uLibTypeMacro(SphericalGeometry, LinearGeometry)
|
||||
SphericalGeometry() {}
|
||||
|
||||
virtual const char * GetClassName() const override { return "SphericalGeometry"; }
|
||||
|
||||
|
||||
virtual bool IsPure() const override { return false; }
|
||||
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
uLibTypeMacro(ToroidalGeometry, LinearGeometry)
|
||||
ToroidalGeometry(float Rtor) : m_Rtor(Rtor) {}
|
||||
|
||||
virtual const char * GetClassName() const override { return "ToroidalGeometry"; }
|
||||
|
||||
|
||||
virtual bool IsPure() const override { return false; }
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Polydata : public Object {
|
||||
|
||||
public:
|
||||
|
||||
virtual const char * GetClassName() const { return "Polydata"; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class QuadMesh : public TRS
|
||||
public:
|
||||
uLibTypeMacro(QuadMesh, TRS)
|
||||
|
||||
virtual const char * GetClassName() const override { return "QuadMesh"; }
|
||||
|
||||
|
||||
void PrintSelf(std::ostream &o);
|
||||
|
||||
|
||||
@@ -188,9 +188,12 @@ public:
|
||||
typedef Eigen::Affine3f AffineMatrix;
|
||||
|
||||
class TRS : public AffineTransform {
|
||||
|
||||
public:
|
||||
|
||||
uLibTypeMacro(TRS, AffineTransform)
|
||||
ULIB_SERIALIZE_ACCESS
|
||||
// ULIB_DECLARE_PROPERTIES(TRS)
|
||||
|
||||
public:
|
||||
|
||||
Vector3f position = Vector3f::Zero();
|
||||
Vector3f rotation = Vector3f::Zero();
|
||||
@@ -259,6 +262,7 @@ public:
|
||||
ar & HRPU(rotation, "rad");
|
||||
ar & HRP(scaling);
|
||||
}
|
||||
|
||||
|
||||
AffineMatrix GetAffineMatrix() const {
|
||||
AffineMatrix m = AffineMatrix::Identity();
|
||||
@@ -273,6 +277,10 @@ public:
|
||||
Matrix4f GetMatrix() const {
|
||||
return this->GetAffineMatrix().matrix();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class TriangleMesh : public TRS
|
||||
public:
|
||||
uLibTypeMacro(TriangleMesh, TRS)
|
||||
|
||||
virtual const char * GetClassName() const override { return "TriangleMesh"; }
|
||||
|
||||
|
||||
void PrintSelf(std::ostream &o);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Abstract {
|
||||
class VoxImage : public uLib::StructuredGrid {
|
||||
public:
|
||||
|
||||
virtual const char * GetClassName() const { return "VoxImage"; }
|
||||
|
||||
|
||||
typedef uLib::StructuredGrid BaseClass;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class VoxImageFilter : public Abstract::VoxImageFilter, public Object {
|
||||
|
||||
public:
|
||||
|
||||
virtual const char * GetClassName() const { return "VoxImageFilter"; }
|
||||
|
||||
|
||||
VoxImageFilter(const Vector3i &size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user