Compare commits
3 Commits
9118afdd13
...
serializat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6068b62e39 | ||
|
|
4435776484 | ||
|
|
a1c5fc2600 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -13,3 +13,6 @@ src/Python/uLib/*.pyd
|
|||||||
src/Python/uLib/*.pyc
|
src/Python/uLib/*.pyc
|
||||||
src/Python/uLib/__pycache__
|
src/Python/uLib/__pycache__
|
||||||
src/Python/uLib/.nfs*
|
src/Python/uLib/.nfs*
|
||||||
|
test_props.xml
|
||||||
|
test_props2.xml
|
||||||
|
test_boost.cpp
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ endif()
|
|||||||
|
|
||||||
# The version number.
|
# The version number.
|
||||||
set(PROJECT_VERSION_MAJOR 0)
|
set(PROJECT_VERSION_MAJOR 0)
|
||||||
set(PROJECT_VERSION_MINOR 6)
|
set(PROJECT_VERSION_MINOR 7)
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
|
|
||||||
|
|||||||
@@ -19,3 +19,76 @@ The vtkHandlerWidget should handle the transformation of the puppet internal Con
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## ACTIVATE PROPERTIES
|
||||||
|
|
||||||
|
ULIB_ACTIVATE_PROPERTIES must run after all member initialization, with the vtable pointing to the most-derived type. This is why it has to be in each constructor — in C++, virtual dispatch only works correctly after a class's vtable is installed, which happens at the start of each level's constructor body.
|
||||||
|
|
||||||
|
### Option 1 — End-of-class macro (no constructor boilerplate)
|
||||||
|
Declare a private member activator as the last member of the class. Its constructor runs after all other members, and at that point the vtable is already Derived's:
|
||||||
|
|
||||||
|
|
||||||
|
// In Property.h, add alongside ULIB_ACTIVATE_PROPERTIES:
|
||||||
|
#define ULIB_DECLARE_PROPERTIES(SelfType) \
|
||||||
|
private: \
|
||||||
|
struct _PropActivator { \
|
||||||
|
_PropActivator(SelfType* self) { \
|
||||||
|
uLib::Archive::property_register_archive ar(self); \
|
||||||
|
ar & *self; \
|
||||||
|
} \
|
||||||
|
} _prop_activator{this};
|
||||||
|
Usage in ContainerBox.h — place it just before the closing brace:
|
||||||
|
|
||||||
|
|
||||||
|
class ContainerBox : public TRS {
|
||||||
|
public:
|
||||||
|
// ... all constructors, no more ULIB_ACTIVATE_PROPERTIES(*this)
|
||||||
|
|
||||||
|
ULIB_DECLARE_PROPERTIES(ContainerBox) // ← replaces all 3 constructor calls
|
||||||
|
};
|
||||||
|
Tradeoff: Works perfectly for single-level classes. For hierarchies where multiple levels use the macro, RegisterDynamicProperty must deduplicate by name (skip if already registered). Requires one line per class in the class body, but zero lines in constructors.
|
||||||
|
|
||||||
|
### Option 2 — Lazy init via virtual InitProperties() in Object
|
||||||
|
Modify Object to call a virtual hook on first GetProperties():
|
||||||
|
|
||||||
|
|
||||||
|
// In Object.h:
|
||||||
|
class Object {
|
||||||
|
protected:
|
||||||
|
virtual void InitProperties() {} // override in derived
|
||||||
|
public:
|
||||||
|
const std::vector<PropertyBase*>& GetProperties() const {
|
||||||
|
if (!m_propertiesInitialized) {
|
||||||
|
const_cast<Object*>(this)->m_propertiesInitialized = true;
|
||||||
|
const_cast<Object*>(this)->InitProperties();
|
||||||
|
}
|
||||||
|
return m_properties;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Then a CRTP base handles the rest without any macro:
|
||||||
|
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
class PropertyObject : public Object {
|
||||||
|
protected:
|
||||||
|
void InitProperties() override {
|
||||||
|
uLib::Archive::property_register_archive ar(this);
|
||||||
|
ar & *static_cast<Derived*>(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Usage — just change the base class:
|
||||||
|
|
||||||
|
|
||||||
|
class ContainerBox : public PropertyObject<ContainerBox>, public TRS { ... };
|
||||||
|
// Nothing else needed — properties activated on first GetProperties() call
|
||||||
|
Tradeoff: Most "automatic" — pure inheritance, no constructor or class-body macros. But requires modifying Object (adding m_propertiesInitialized flag + virtual hook), and lazy init means properties aren't available until first access. Also doesn't work well with multiple inheritance (which TRS likely involves).
|
||||||
|
|
||||||
|
Option 3 — CRTP doesn't work from the base constructor
|
||||||
|
Just to be explicit: a CRTP base that calls ULIB_ACTIVATE_PROPERTIES in its own constructor won't work, because when PropertyObject<Derived>'s constructor runs, the vtable is PropertyObject<Derived>'s — Derived::serialize() hasn't been installed yet. So ar & *self calls Object::serialize() (a no-op).
|
||||||
|
|
||||||
|
Recommendation
|
||||||
|
Option 1 is the least invasive and safest. Add deduplication to RegisterDynamicProperty in Object.cpp to guard against re-registration when hierarchies stack activators, then replace every ULIB_ACTIVATE_PROPERTIES(*this) in constructors with a single ULIB_DECLARE_PROPERTIES(ClassName) at the end of the class body.
|
||||||
|
|
||||||
|
Option 2 is cleaner to use but requires changing the Object interface and has the lazy-init semantic change — only worth it if you want zero-touch activation across the entire framework.
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
|
#include <boost/archive/detail/basic_pointer_iserializer.hpp>
|
||||||
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
|
#include <boost/archive/detail/basic_pointer_oserializer.hpp>
|
||||||
|
#include <boost/archive/text_oarchive.hpp>
|
||||||
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/archive/text_iarchive.hpp>
|
#include <boost/archive/text_iarchive.hpp>
|
||||||
@@ -309,18 +311,32 @@ namespace Archive {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// XML //
|
// XML //
|
||||||
|
|
||||||
|
// ULIB_SERIALIZATION_VERSION should be get from the build system
|
||||||
|
#ifndef ULIB_SERIALIZATION_VERSION
|
||||||
|
#define ULIB_SERIALIZATION_VERSION "0.0"
|
||||||
|
#endif
|
||||||
|
|
||||||
class xml_iarchive : public boost::archive::xml_iarchive_impl<xml_iarchive> {
|
class xml_iarchive : public boost::archive::xml_iarchive_impl<xml_iarchive> {
|
||||||
typedef xml_iarchive Archive;
|
typedef xml_iarchive Archive;
|
||||||
typedef boost::archive::xml_iarchive_impl<Archive> base;
|
typedef boost::archive::xml_iarchive_impl<Archive> base;
|
||||||
|
|
||||||
|
unsigned int m_flags;
|
||||||
|
|
||||||
// give serialization implementation access to this class
|
// give serialization implementation access to this class
|
||||||
friend class boost::archive::detail::interface_iarchive<Archive>;
|
friend class boost::archive::detail::interface_iarchive<Archive>;
|
||||||
friend class boost::archive::basic_xml_iarchive<Archive>;
|
friend class boost::archive::basic_xml_iarchive<Archive>;
|
||||||
friend class boost::archive::load_access;
|
friend class boost::archive::load_access;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xml_iarchive(std::istream &is, unsigned int flags = 0)
|
xml_iarchive(std::istream &is, unsigned int flags = 0)
|
||||||
: xml_iarchive_impl<xml_iarchive>(is, flags) {}
|
: boost::archive::xml_iarchive_impl<xml_iarchive>(
|
||||||
|
is, flags | boost::archive::no_header), m_flags(flags) {
|
||||||
|
if (0 == (flags & boost::archive::no_header)) {
|
||||||
|
std::string line;
|
||||||
|
std::getline(is, line); // <?xml ... ?>
|
||||||
|
std::getline(is, line); // <!DOCTYPE ...>
|
||||||
|
std::getline(is, line); // <ulib_serialization ...>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
using basic_xml_iarchive::load_override;
|
using basic_xml_iarchive::load_override;
|
||||||
|
|
||||||
@@ -368,14 +384,31 @@ class xml_oarchive : public boost::archive::xml_oarchive_impl<xml_oarchive> {
|
|||||||
typedef xml_oarchive Archive;
|
typedef xml_oarchive Archive;
|
||||||
typedef boost::archive::xml_oarchive_impl<Archive> base;
|
typedef boost::archive::xml_oarchive_impl<Archive> base;
|
||||||
|
|
||||||
|
unsigned int m_flags;
|
||||||
|
|
||||||
// give serialization implementation access to this class
|
// give serialization implementation access to this class
|
||||||
friend class boost::archive::detail::interface_oarchive<Archive>;
|
friend class boost::archive::detail::interface_oarchive<Archive>;
|
||||||
friend class boost::archive::basic_xml_oarchive<Archive>;
|
friend class boost::archive::basic_xml_oarchive<Archive>;
|
||||||
friend class boost::archive::save_access;
|
friend class boost::archive::save_access;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
xml_oarchive(std::ostream &os, unsigned int flags = 0)
|
xml_oarchive(std::ostream &os, unsigned int flags = 0)
|
||||||
: boost::archive::xml_oarchive_impl<xml_oarchive>(os, flags) {}
|
: boost::archive::xml_oarchive_impl<xml_oarchive>(
|
||||||
|
os, flags | boost::archive::no_header), m_flags(flags) {
|
||||||
|
if (0 == (flags & boost::archive::no_header)) {
|
||||||
|
this->This()->put(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n");
|
||||||
|
this->This()->put("<!DOCTYPE ulib_serialization>\n");
|
||||||
|
this->This()->put("<ulib_serialization signature=\"serialization::archive\" ");
|
||||||
|
this->write_attribute("version", (const char *)ULIB_SERIALIZATION_VERSION);
|
||||||
|
this->This()->put(">\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~xml_oarchive() {
|
||||||
|
if (0 == (m_flags & boost::archive::no_header)) {
|
||||||
|
this->This()->put("</ulib_serialization>\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
using basic_xml_oarchive::save_override;
|
using basic_xml_oarchive::save_override;
|
||||||
|
|
||||||
@@ -397,8 +430,6 @@ public:
|
|||||||
// Do not save any human decoration string //
|
// Do not save any human decoration string //
|
||||||
// basic_text_oprimitive::save(str);
|
// basic_text_oprimitive::save(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~xml_oarchive() {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// typedef boost::archive::detail::polymorphic_oarchive_route<
|
// typedef boost::archive::detail::polymorphic_oarchive_route<
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ if(USE_CUDA)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(${libname} ${LIBRARIES})
|
target_link_libraries(${libname} ${LIBRARIES})
|
||||||
|
target_compile_definitions(${libname} PUBLIC ULIB_SERIALIZATION_VERSION="${PROJECT_VERSION}")
|
||||||
|
|
||||||
install(TARGETS ${libname}
|
install(TARGETS ${libname}
|
||||||
EXPORT "uLibTargets"
|
EXPORT "uLibTargets"
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ void Object::RegisterDynamicProperty(PropertyBase* prop) {
|
|||||||
if (prop) {
|
if (prop) {
|
||||||
for (auto* existing : d->m_DynamicProperties) {
|
for (auto* existing : d->m_DynamicProperties) {
|
||||||
if (existing == prop) return;
|
if (existing == prop) return;
|
||||||
|
if (existing->GetQualifiedName() == prop->GetQualifiedName()) return;
|
||||||
}
|
}
|
||||||
d->m_DynamicProperties.push_back(prop);
|
d->m_DynamicProperties.push_back(prop);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,7 +78,8 @@ public:
|
|||||||
Object(const Object ©);
|
Object(const Object ©);
|
||||||
virtual ~Object();
|
virtual ~Object();
|
||||||
|
|
||||||
virtual const char * GetClassName() const { return "Object"; }
|
virtual const char * GetClassName() const { return type_name(); }
|
||||||
|
virtual const char * type_name() const { return "Object"; }
|
||||||
|
|
||||||
const std::string& GetInstanceName() const;
|
const std::string& GetInstanceName() const;
|
||||||
void SetInstanceName(const std::string& name);
|
void SetInstanceName(const std::string& name);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
ObjectsContext();
|
ObjectsContext();
|
||||||
virtual ~ObjectsContext();
|
virtual ~ObjectsContext();
|
||||||
|
|
||||||
virtual const char * GetClassName() const { return "ObjectsContext"; }
|
uLibTypeMacro(ObjectsContext, Object)
|
||||||
virtual ObjectsContext* GetChildren() override { return this; }
|
virtual ObjectsContext* GetChildren() override { return this; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -54,13 +54,13 @@ public:
|
|||||||
virtual void Updated() override { ULIB_SIGNAL_EMIT(PropertyBase::Updated); }
|
virtual void Updated() override { ULIB_SIGNAL_EMIT(PropertyBase::Updated); }
|
||||||
|
|
||||||
// Serialization support for different uLib archives
|
// Serialization support for different uLib archives
|
||||||
virtual void serialize(Archive::xml_oarchive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::xml_oarchive & ar, const unsigned int version) override = 0;
|
||||||
virtual void serialize(Archive::xml_iarchive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::xml_iarchive & ar, const unsigned int version) override = 0;
|
||||||
virtual void serialize(Archive::text_oarchive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::text_oarchive & ar, const unsigned int version) override = 0;
|
||||||
virtual void serialize(Archive::text_iarchive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::text_iarchive & ar, const unsigned int version) override = 0;
|
||||||
virtual void serialize(Archive::hrt_oarchive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::hrt_oarchive & ar, const unsigned int version) override = 0;
|
||||||
virtual void serialize(Archive::hrt_iarchive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::hrt_iarchive & ar, const unsigned int version) override = 0;
|
||||||
virtual void serialize(Archive::log_archive & ar, const unsigned int version) = 0;
|
virtual void serialize(Archive::log_archive & ar, const unsigned int version) override = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -407,12 +407,32 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convenience macro to automatically activate and register all HRP members
|
* @brief Convenience macro to automatically activate and register all HRP members
|
||||||
* as uLib properties. Usage: ULIB_ACTIVATE_PROPERTIES(obj)
|
* as uLib properties. Usage: ULIB_ACTIVATE_PROPERTIES(obj)
|
||||||
*/
|
*/
|
||||||
#define ULIB_ACTIVATE_PROPERTIES(obj) \
|
#define ULIB_ACTIVATE_PROPERTIES(obj) \
|
||||||
{ uLib::Archive::property_register_archive _ar_tmp(&(obj)); _ar_tmp & (obj); }
|
{ uLib::Archive::property_register_archive _ar_tmp(&(obj)); _ar_tmp & (obj); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Declares a private member that automatically calls ULIB_ACTIVATE_PROPERTIES
|
||||||
|
* in every constructor of the class. Place this macro as the last declaration
|
||||||
|
* inside the class body (before the closing brace).
|
||||||
|
*
|
||||||
|
* Usage: ULIB_DECLARE_PROPERTIES(ClassName)
|
||||||
|
*
|
||||||
|
* This replaces per-constructor ULIB_ACTIVATE_PROPERTIES(*this) calls.
|
||||||
|
* RegisterDynamicProperty deduplicates by qualified name, so re-registration
|
||||||
|
* from inherited activators in a hierarchy is safe.
|
||||||
|
*/
|
||||||
|
#define ULIB_DECLARE_PROPERTIES(SelfType) \
|
||||||
|
private: \
|
||||||
|
struct _PropActivator { \
|
||||||
|
_PropActivator(SelfType* self) { \
|
||||||
|
uLib::Archive::property_register_archive _ar(self); \
|
||||||
|
_ar & *self; \
|
||||||
|
} \
|
||||||
|
} _prop_activator{this};
|
||||||
|
|
||||||
} // namespace Archive
|
} // namespace Archive
|
||||||
} // namespace uLib
|
} // namespace uLib
|
||||||
|
|
||||||
|
|||||||
@@ -309,6 +309,8 @@ namespace uLib {
|
|||||||
#define HRP5(name, data, units, min, max) boost::serialization::make_hrp(name, data, units).range(min, max)
|
#define HRP5(name, data, units, min, max) boost::serialization::make_hrp(name, data, units).range(min, max)
|
||||||
#define HRP6(name, data, units, default, min, max) boost::serialization::make_hrp(name, data, units).set_default(default).range(min, max)
|
#define HRP6(name, data, units, default, min, max) boost::serialization::make_hrp(name, data, units).set_default(default).range(min, max)
|
||||||
|
|
||||||
|
#define HRPE(name, data, labels) boost::serialization::make_hrp_enum(name, data, labels)
|
||||||
|
|
||||||
// LEFT FOR BACKWARD COMPATIBILITY
|
// LEFT FOR BACKWARD COMPATIBILITY
|
||||||
#define HRPU(name, units) boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), name, units)
|
#define HRPU(name, units) boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), name, units)
|
||||||
|
|
||||||
@@ -349,7 +351,7 @@ using boost::serialization::make_hrp_enum;
|
|||||||
#define ULIB_SERIALIZE_OBJECT(_Ob, ...) \
|
#define ULIB_SERIALIZE_OBJECT(_Ob, ...) \
|
||||||
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, __VA_ARGS__)
|
_ULIB_DETAIL_UNINTRUSIVE_SERIALIZE_OBJECT(_Ob, __VA_ARGS__)
|
||||||
#define AR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
#define AR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
||||||
#define HR(_name) _ULIB_DETAIL_UNINTRUSIVE_AR_(_name)
|
#define HR(_name) _ULIB_DETAIL_UNINTRUSIVE_HR_(_name)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ULIB_SERIALIZE_ACCESS \
|
#define ULIB_SERIALIZE_ACCESS \
|
||||||
@@ -362,14 +364,14 @@ using boost::serialization::make_hrp_enum;
|
|||||||
#define ULIB_CLASS_EXPORT_OBJECT_KEY(_FullNamespaceClass) \
|
#define ULIB_CLASS_EXPORT_OBJECT_KEY(_FullNamespaceClass) \
|
||||||
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
BOOST_CLASS_EXPORT_KEY(_FullNamespaceClass)
|
||||||
|
|
||||||
#define _SERIALIZE_IMPL_SEQ \
|
#define _SERIALIZE_IMPL_SEQ \
|
||||||
(uLib::Archive::text_iarchive)(uLib::Archive::text_oarchive)( \
|
(uLib::Archive::text_iarchive) \
|
||||||
uLib::Archive:: \
|
(uLib::Archive::text_oarchive) \
|
||||||
hrt_iarchive)(uLib::Archive:: \
|
(uLib::Archive::hrt_iarchive) \
|
||||||
hrt_oarchive)(uLib::Archive:: \
|
(uLib::Archive::hrt_oarchive) \
|
||||||
xml_iarchive)(uLib::Archive:: \
|
(uLib::Archive::xml_iarchive) \
|
||||||
xml_oarchive)(uLib::Archive:: \
|
(uLib::Archive::xml_oarchive) \
|
||||||
log_archive)
|
(uLib::Archive::log_archive)
|
||||||
|
|
||||||
/** Solving virtual class check problem */
|
/** Solving virtual class check problem */
|
||||||
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(_Base, _Derived) \
|
#define _ULIB_DETAIL_SPECIALIZE_IS_VIRTUAL_BASE(_Base, _Derived) \
|
||||||
@@ -549,7 +551,8 @@ using boost::serialization::make_hrp_enum;
|
|||||||
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
void serialize_parents(ArchiveT &ar, _Ob &ob, const unsigned int v) { \
|
||||||
/* PP serialize */ BOOST_PP_SEQ_FOR_EACH( \
|
/* PP serialize */ BOOST_PP_SEQ_FOR_EACH( \
|
||||||
_UNAR_OP, ob, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
_UNAR_OP, ob, BOOST_PP_TUPLE_TO_SEQ((__VA_ARGS__))); \
|
||||||
/* MPL serialize */ /*uLib::mpl::for_each<_Ob::BaseList>(uLib::detail::Serializable::serialize_baseobject<_Ob,ArchiveT>(ob,ar) );*/ } \
|
/* MPL serialize */ /*uLib::mpl::for_each<_Ob::BaseList> \
|
||||||
|
(uLib::detail::Serializable::serialize_baseobject<_Ob,ArchiveT>(ob,ar) );*/ }\
|
||||||
template <class ArchiveT> \
|
template <class ArchiveT> \
|
||||||
inline void load_construct_data(ArchiveT &ar, _Ob *ob, \
|
inline void load_construct_data(ArchiveT &ar, _Ob *ob, \
|
||||||
const unsigned int file_version) { \
|
const unsigned int file_version) { \
|
||||||
@@ -572,10 +575,18 @@ using boost::serialization::make_hrp_enum;
|
|||||||
_SERIALIZE_IMPL_SEQ) \
|
_SERIALIZE_IMPL_SEQ) \
|
||||||
template <class ArchiveT> \
|
template <class ArchiveT> \
|
||||||
void boost::serialization::access2<_Ob>::save_override( \
|
void boost::serialization::access2<_Ob>::save_override( \
|
||||||
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
ArchiveT &ar, _Ob &ob, const unsigned int version)
|
||||||
|
|
||||||
|
|
||||||
#define _ULIB_DETAIL_UNINTRUSIVE_AR_(name) \
|
#define _ULIB_DETAIL_UNINTRUSIVE_AR_(name) \
|
||||||
boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name), ob.name)
|
boost::serialization::make_nvp(BOOST_PP_STRINGIZE(name), ob.name)
|
||||||
|
#define _ULIB_DETAIL_UNINTRUSIVE_HR_(name) \
|
||||||
|
boost::serialization::make_hrp(BOOST_PP_STRINGIZE(name), ob.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -76,8 +76,9 @@ public:
|
|||||||
|
|
||||||
ULIB_SERIALIZABLE_OBJECT(TestObject2)
|
ULIB_SERIALIZABLE_OBJECT(TestObject2)
|
||||||
ULIB_SERIALIZE_OBJECT(TestObject2, TestObject) {
|
ULIB_SERIALIZE_OBJECT(TestObject2, TestObject) {
|
||||||
// std::cout << "Serializing TestObject2" << std::endl;
|
std::cout << "Serializing TestObject2" << std::endl;
|
||||||
ar & boost::serialization::make_hrp("value2", ob.m_Value2, "mm").set_default(1.);
|
// ar & boost::serialization::make_hrp("value2", ob.m_Value2, "mm").set_default(1.);
|
||||||
|
ar & HRP("value2", ob.m_Value2, "mm").set_default(1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ using namespace uLib;
|
|||||||
|
|
||||||
class TestObject : public Object {
|
class TestObject : public Object {
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(TestObject, Object)
|
||||||
TestObject() : Object(),
|
TestObject() : Object(),
|
||||||
IntProp(this, "IntProp", 10),
|
IntProp(this, "IntProp", 10),
|
||||||
StringProp(this, "StringProp", "Initial")
|
StringProp(this, "StringProp", "Initial")
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual const char* GetClassName() const override { return "TestObject"; }
|
|
||||||
|
|
||||||
Property<int> IntProp;
|
Property<int> IntProp;
|
||||||
Property<std::string> StringProp;
|
Property<std::string> StringProp;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ using namespace uLib;
|
|||||||
|
|
||||||
class TestObject : public Object {
|
class TestObject : public Object {
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(TestObject, Object)
|
||||||
TestObject() : Object() {}
|
TestObject() : Object() {}
|
||||||
|
|
||||||
virtual const char* GetClassName() const override { return "TestObject"; }
|
|
||||||
|
|
||||||
// Use new typedefs
|
// Use new typedefs
|
||||||
StringProperty StringProp = StringProperty(this, "StringProp", "Initial");
|
StringProperty StringProp = StringProperty(this, "StringProp", "Initial");
|
||||||
IntProperty IntProp = IntProperty(this, "IntProp", 42);
|
IntProperty IntProp = IntProperty(this, "IntProp", 42);
|
||||||
|
|||||||
@@ -39,13 +39,11 @@ namespace uLib {
|
|||||||
|
|
||||||
|
|
||||||
class DetectorChamber : public ContainerBox {
|
class DetectorChamber : public ContainerBox {
|
||||||
|
|
||||||
typedef ContainerBox BaseClass;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(DetectorChamber, ContainerBox)
|
||||||
|
|
||||||
virtual const char * GetClassName() const { return "DetectorChamber"; }
|
|
||||||
|
|
||||||
DetectorChamber() : BaseClass() {
|
DetectorChamber() : BaseClass() {
|
||||||
m_ProjectionPlane.origin = HPoint3f(0, 0, 0);
|
m_ProjectionPlane.origin = HPoint3f(0, 0, 0);
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ namespace Geant {
|
|||||||
class EmitterPrimary : public G4VUserPrimaryGeneratorAction, public AffineTransform
|
class EmitterPrimary : public G4VUserPrimaryGeneratorAction, public AffineTransform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(EmitterPrimary, Object)
|
||||||
virtual const char* GetClassName() const override { return "Geant.EmitterPrimary"; }
|
|
||||||
|
|
||||||
EmitterPrimary();
|
EmitterPrimary();
|
||||||
virtual ~EmitterPrimary();
|
virtual ~EmitterPrimary();
|
||||||
@@ -47,8 +46,7 @@ class EmitterPrimary : public G4VUserPrimaryGeneratorAction, public AffineTransf
|
|||||||
class SkyPlaneEmitterPrimary : public EmitterPrimary
|
class SkyPlaneEmitterPrimary : public EmitterPrimary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(SkyPlaneEmitterPrimary, EmitterPrimary)
|
||||||
virtual const char* GetClassName() const override { return "Geant.SkyPlaneEmitterPrimary"; }
|
|
||||||
|
|
||||||
SkyPlaneEmitterPrimary();
|
SkyPlaneEmitterPrimary();
|
||||||
virtual ~SkyPlaneEmitterPrimary();
|
virtual ~SkyPlaneEmitterPrimary();
|
||||||
@@ -69,8 +67,7 @@ class SkyPlaneEmitterPrimary : public EmitterPrimary
|
|||||||
class CylinderEmitterPrimary : public EmitterPrimary
|
class CylinderEmitterPrimary : public EmitterPrimary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(CylinderEmitterPrimary, EmitterPrimary)
|
||||||
virtual const char* GetClassName() const override { return "Geant.CylinderEmitterPrimary"; }
|
|
||||||
|
|
||||||
CylinderEmitterPrimary();
|
CylinderEmitterPrimary();
|
||||||
virtual ~CylinderEmitterPrimary();
|
virtual ~CylinderEmitterPrimary();
|
||||||
@@ -98,8 +95,7 @@ class CylinderEmitterPrimary : public EmitterPrimary
|
|||||||
class QuadMeshEmitterPrimary : public EmitterPrimary
|
class QuadMeshEmitterPrimary : public EmitterPrimary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(QuadMeshEmitterPrimary, EmitterPrimary)
|
||||||
virtual const char* GetClassName() const override { return "Geant.QuadMeshEmitterPrimary"; }
|
|
||||||
|
|
||||||
QuadMeshEmitterPrimary();
|
QuadMeshEmitterPrimary();
|
||||||
virtual ~QuadMeshEmitterPrimary();
|
virtual ~QuadMeshEmitterPrimary();
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ class SteppingAction;
|
|||||||
class GeantEvent : public Object {
|
class GeantEvent : public Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(GeantEvent, Object)
|
||||||
virtual const char* GetClassName() const override { return "Geant.GeantEvent"; }
|
|
||||||
|
|
||||||
/// A single interaction step along the muon path.
|
/// A single interaction step along the muon path.
|
||||||
struct Delta {
|
struct Delta {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ private:
|
|||||||
|
|
||||||
class Material : public Object {
|
class Material : public Object {
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(Material, Object)
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
Undefined = 0,
|
Undefined = 0,
|
||||||
@@ -68,8 +69,6 @@ public:
|
|||||||
Gas
|
Gas
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual const char* GetClassName() const override { return "Geant.Material"; }
|
|
||||||
|
|
||||||
Material();
|
Material();
|
||||||
Material(const char *name);
|
Material(const char *name);
|
||||||
~Material();
|
~Material();
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ class EmitterPrimary;
|
|||||||
|
|
||||||
class Scene : public Object {
|
class Scene : public Object {
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(Scene, Object)
|
||||||
virtual const char* GetClassName() const override { return "Geant.Scene"; }
|
|
||||||
|
|
||||||
Scene();
|
Scene();
|
||||||
~Scene();
|
~Scene();
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ namespace Geant {
|
|||||||
|
|
||||||
class Solid : public Object {
|
class Solid : public Object {
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(Solid, Object)
|
||||||
virtual const char* GetClassName() const override { return "Geant.Solid"; }
|
|
||||||
|
|
||||||
Solid();
|
Solid();
|
||||||
Solid(const char *name);
|
Solid(const char *name);
|
||||||
@@ -93,10 +92,8 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
class TessellatedSolid : public Solid {
|
class TessellatedSolid : public Solid {
|
||||||
typedef Solid BaseClass;
|
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(TessellatedSolid, Solid)
|
||||||
virtual const char* GetClassName() const override { return "Geant.TessellatedSolid"; }
|
|
||||||
|
|
||||||
TessellatedSolid();
|
TessellatedSolid();
|
||||||
TessellatedSolid(const char *name);
|
TessellatedSolid(const char *name);
|
||||||
@@ -120,11 +117,9 @@ private :
|
|||||||
|
|
||||||
|
|
||||||
class BoxSolid : public Solid {
|
class BoxSolid : public Solid {
|
||||||
typedef Solid BaseClass;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
uLibTypeMacro(BoxSolid, Solid)
|
||||||
virtual const char* GetClassName() const override { return "Geant.BoxSolid"; }
|
|
||||||
|
|
||||||
BoxSolid(const char *name = "");
|
BoxSolid(const char *name = "");
|
||||||
BoxSolid(const char *name, ContainerBox *box);
|
BoxSolid(const char *name, ContainerBox *box);
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ Assembly::Assembly()
|
|||||||
m_BBoxMax(Vector3f::Zero()),
|
m_BBoxMax(Vector3f::Zero()),
|
||||||
m_ShowBoundingBox(false),
|
m_ShowBoundingBox(false),
|
||||||
m_GroupSelection(true) {
|
m_GroupSelection(true) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Assembly::Assembly(const Assembly ©)
|
Assembly::Assembly(const Assembly ©)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace uLib {
|
|||||||
class Assembly : public ObjectsContext, public TRS {
|
class Assembly : public ObjectsContext, public TRS {
|
||||||
public:
|
public:
|
||||||
uLibTypeMacro(Assembly, ObjectsContext, TRS)
|
uLibTypeMacro(Assembly, ObjectsContext, TRS)
|
||||||
virtual const char *GetClassName() const override { return "Assembly"; }
|
|
||||||
|
|
||||||
Assembly();
|
Assembly();
|
||||||
Assembly(const Assembly ©);
|
Assembly(const Assembly ©);
|
||||||
@@ -113,6 +113,8 @@ private:
|
|||||||
bool m_GroupSelection;
|
bool m_GroupSelection;
|
||||||
bool m_InUpdated = false;
|
bool m_InUpdated = false;
|
||||||
std::map<Object*, Connection> m_ChildConnections;
|
std::map<Object*, Connection> m_ChildConnections;
|
||||||
|
|
||||||
|
ULIB_DECLARE_PROPERTIES(Assembly)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace uLib
|
} // namespace uLib
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "Geometry.h"
|
#include "Geometry.h"
|
||||||
#include "Core/Object.h"
|
#include "Core/Object.h"
|
||||||
#include "Core/Property.h"
|
#include "Core/Property.h"
|
||||||
|
#include "Core/Serializable.h"
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
#include "Math/Transform.h"
|
#include "Math/Transform.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -48,16 +49,11 @@ namespace uLib {
|
|||||||
*/
|
*/
|
||||||
class ContainerBox : public TRS {
|
class ContainerBox : public TRS {
|
||||||
|
|
||||||
public:
|
|
||||||
uLibTypeMacro(ContainerBox, TRS)
|
uLibTypeMacro(ContainerBox, TRS)
|
||||||
|
ULIB_SERIALIZE_ACCESS
|
||||||
|
ULIB_DECLARE_PROPERTIES(ContainerBox)
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "ContainerBox"; }
|
public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PROPERTIES //
|
|
||||||
|
|
||||||
Vector3f Size;
|
|
||||||
Vector3f Origin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor.
|
* @brief Default constructor.
|
||||||
@@ -67,7 +63,6 @@ public:
|
|||||||
: m_LocalT(this), // BaseClass is Parent of m_LocalTransform
|
: m_LocalT(this), // BaseClass is Parent of m_LocalTransform
|
||||||
Size(1.0f, 1.0f, 1.0f),
|
Size(1.0f, 1.0f, 1.0f),
|
||||||
Origin(0.0f, 0.0f, 0.0f) {
|
Origin(0.0f, 0.0f, 0.0f) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
this->Sync();
|
this->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +74,6 @@ public:
|
|||||||
: m_LocalT(this),
|
: m_LocalT(this),
|
||||||
Size(size),
|
Size(size),
|
||||||
Origin(0.0f, 0.0f, 0.0f) {
|
Origin(0.0f, 0.0f, 0.0f) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
this->Sync();
|
this->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,13 +86,12 @@ public:
|
|||||||
TRS(copy),
|
TRS(copy),
|
||||||
Size(copy.Size),
|
Size(copy.Size),
|
||||||
Origin(copy.Origin) {
|
Origin(copy.Origin) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
this->Sync();
|
this->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* @brief Serialization template for property registration and persistence.
|
// * @brief Serialization template for property registration and persistence.
|
||||||
*/
|
// */
|
||||||
template <class ArchiveT>
|
template <class ArchiveT>
|
||||||
void serialize(ArchiveT & ar, const unsigned int version) {
|
void serialize(ArchiveT & ar, const unsigned int version) {
|
||||||
ar & HRP(Size);
|
ar & HRP(Size);
|
||||||
@@ -236,9 +229,13 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Vector3f Size;
|
||||||
|
Vector3f Origin;
|
||||||
AffineTransform m_LocalT;
|
AffineTransform m_LocalT;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace uLib
|
} // namespace uLib
|
||||||
|
|
||||||
|
|
||||||
#endif // CONTAINERBOX_H
|
#endif // CONTAINERBOX_H
|
||||||
|
|||||||
@@ -41,8 +41,10 @@ namespace uLib {
|
|||||||
*/
|
*/
|
||||||
class Cylinder : public TRS {
|
class Cylinder : public TRS {
|
||||||
|
|
||||||
public:
|
|
||||||
uLibTypeMacro(Cylinder, TRS)
|
uLibTypeMacro(Cylinder, TRS)
|
||||||
|
ULIB_DECLARE_PROPERTIES(Cylinder)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PROPERTIES
|
* @brief PROPERTIES
|
||||||
@@ -51,22 +53,20 @@ public:
|
|||||||
float Height;
|
float Height;
|
||||||
int Axis;
|
int Axis;
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "Cylinder"; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default constructor. Aligns with Y by default.
|
* @brief Default constructor. Aligns with Y by default.
|
||||||
*/
|
*/
|
||||||
Cylinder() : m_LocalT(this), Radius(1.0), Height(1.0), Axis(1) {
|
Cylinder() : m_LocalT(this), Radius(1.0), Height(1.0), Axis(1) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
this->Sync();
|
this->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor with radius and height.
|
* @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) {
|
: m_LocalT(this), Radius(radius), Height(height), Axis(axis) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
this->Sync();
|
this->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
Cylinder(const Cylinder ©)
|
Cylinder(const Cylinder ©)
|
||||||
: m_LocalT(this), TRS(copy), Radius(copy.Radius), Height(copy.Height), Axis(copy.Axis) {
|
: m_LocalT(this), TRS(copy), Radius(copy.Radius), Height(copy.Height), Axis(copy.Axis) {
|
||||||
ULIB_ACTIVATE_PROPERTIES(*this);
|
|
||||||
this->Sync();
|
this->Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,10 +83,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
template <class ArchiveT>
|
template <class ArchiveT>
|
||||||
void serialize(ArchiveT & ar, const unsigned int version) {
|
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(Radius);
|
||||||
ar & HRP(Height);
|
ar & HRP(Height);
|
||||||
ar & HRP(Axis);
|
ar & boost::serialization::make_hrp_enum("Axis", Axis, {"X", "Y", "Z"});
|
||||||
|
ar & NVP("TRS", boost::serialization::base_object<TRS>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the radius of the cylinder */
|
/** Sets the radius of the cylinder */
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
uLibTypeMacro(Geometry, Object)
|
uLibTypeMacro(Geometry, Object)
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "Geometry"; }
|
|
||||||
|
|
||||||
virtual void SetParent(Geometry* p) { m_Parent = p; }
|
virtual void SetParent(Geometry* p) { m_Parent = p; }
|
||||||
virtual Geometry* GetParent() const { return m_Parent; }
|
virtual Geometry* GetParent() const { return m_Parent; }
|
||||||
@@ -93,7 +93,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
uLibTypeMacro(LinearGeometry, Geometry)
|
uLibTypeMacro(LinearGeometry, Geometry)
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "LinearGeometry"; }
|
|
||||||
|
|
||||||
virtual bool IsLinear() const override { return true; }
|
virtual bool IsLinear() const override { return true; }
|
||||||
virtual bool IsPure() const override { return true; }
|
virtual bool IsPure() const override { return true; }
|
||||||
@@ -162,7 +162,7 @@ public:
|
|||||||
uLibTypeMacro(CylindricalGeometry, LinearGeometry)
|
uLibTypeMacro(CylindricalGeometry, LinearGeometry)
|
||||||
CylindricalGeometry() {}
|
CylindricalGeometry() {}
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "CylindricalGeometry"; }
|
|
||||||
|
|
||||||
virtual bool IsPure() const override { return false; }
|
virtual bool IsPure() const override { return false; }
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public:
|
|||||||
uLibTypeMacro(SphericalGeometry, LinearGeometry)
|
uLibTypeMacro(SphericalGeometry, LinearGeometry)
|
||||||
SphericalGeometry() {}
|
SphericalGeometry() {}
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "SphericalGeometry"; }
|
|
||||||
|
|
||||||
virtual bool IsPure() const override { return false; }
|
virtual bool IsPure() const override { return false; }
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ public:
|
|||||||
uLibTypeMacro(ToroidalGeometry, LinearGeometry)
|
uLibTypeMacro(ToroidalGeometry, LinearGeometry)
|
||||||
ToroidalGeometry(float Rtor) : m_Rtor(Rtor) {}
|
ToroidalGeometry(float Rtor) : m_Rtor(Rtor) {}
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "ToroidalGeometry"; }
|
|
||||||
|
|
||||||
virtual bool IsPure() const override { return false; }
|
virtual bool IsPure() const override { return false; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
SUBDIRS = .
|
|
||||||
|
|
||||||
include $(top_srcdir)/Common.am
|
|
||||||
|
|
||||||
library_includedir = $(includedir)/libmutom-${PACKAGE_VERSION}/Math
|
|
||||||
library_include_HEADERS = ContainerBox.h \
|
|
||||||
Dense.h \
|
|
||||||
Geometry.h \
|
|
||||||
Transform.h \
|
|
||||||
StructuredData.h\
|
|
||||||
StructuredGrid.h\
|
|
||||||
VoxImage.h \
|
|
||||||
VoxRaytracer.h \
|
|
||||||
Utils.h \
|
|
||||||
VoxImageFilter.h\
|
|
||||||
VoxImageFilter.hpp \
|
|
||||||
VoxImageFilterLinear.hpp \
|
|
||||||
VoxImageFilterMedian.hpp \
|
|
||||||
VoxImageFilterABTrim.hpp \
|
|
||||||
VoxImageFilterBilateral.hpp \
|
|
||||||
VoxImageFilterThreshold.hpp \
|
|
||||||
VoxImageFilter2ndStat.hpp \
|
|
||||||
VoxImageFilterCustom.hpp \
|
|
||||||
Accumulator.h \
|
|
||||||
TriangleMesh.h
|
|
||||||
|
|
||||||
|
|
||||||
_MATH_SOURCES = \
|
|
||||||
VoxRaytracer.cpp \
|
|
||||||
StructuredData.cpp \
|
|
||||||
StructuredGrid.cpp \
|
|
||||||
VoxImage.cpp \
|
|
||||||
TriangleMesh.cpp \
|
|
||||||
Dense.cpp
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
noinst_LTLIBRARIES = libmutommath.la
|
|
||||||
libmutommath_la_SOURCES = ${_MATH_SOURCES}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ class Polydata : public Object {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const char * GetClassName() const { return "Polydata"; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class QuadMesh : public TRS
|
|||||||
public:
|
public:
|
||||||
uLibTypeMacro(QuadMesh, TRS)
|
uLibTypeMacro(QuadMesh, TRS)
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "QuadMesh"; }
|
|
||||||
|
|
||||||
void PrintSelf(std::ostream &o);
|
void PrintSelf(std::ostream &o);
|
||||||
|
|
||||||
|
|||||||
@@ -188,9 +188,12 @@ public:
|
|||||||
typedef Eigen::Affine3f AffineMatrix;
|
typedef Eigen::Affine3f AffineMatrix;
|
||||||
|
|
||||||
class TRS : public AffineTransform {
|
class TRS : public AffineTransform {
|
||||||
|
|
||||||
public:
|
|
||||||
uLibTypeMacro(TRS, AffineTransform)
|
uLibTypeMacro(TRS, AffineTransform)
|
||||||
|
ULIB_SERIALIZE_ACCESS
|
||||||
|
// ULIB_DECLARE_PROPERTIES(TRS)
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
Vector3f position = Vector3f::Zero();
|
Vector3f position = Vector3f::Zero();
|
||||||
Vector3f rotation = Vector3f::Zero();
|
Vector3f rotation = Vector3f::Zero();
|
||||||
@@ -259,6 +262,7 @@ public:
|
|||||||
ar & HRPU(rotation, "rad");
|
ar & HRPU(rotation, "rad");
|
||||||
ar & HRP(scaling);
|
ar & HRP(scaling);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AffineMatrix GetAffineMatrix() const {
|
AffineMatrix GetAffineMatrix() const {
|
||||||
AffineMatrix m = AffineMatrix::Identity();
|
AffineMatrix m = AffineMatrix::Identity();
|
||||||
@@ -273,12 +277,26 @@ public:
|
|||||||
Matrix4f GetMatrix() const {
|
Matrix4f GetMatrix() const {
|
||||||
return this->GetAffineMatrix().matrix();
|
return this->GetAffineMatrix().matrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& os, const TRS& trs) {
|
||||||
|
os << trs.position << " " << trs.rotation << " " << trs.scaling;
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline std::istream& operator>>(std::istream& is, TRS& trs) {
|
||||||
|
is >> trs.position >> trs.rotation >> trs.scaling;
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
} // uLib
|
} // uLib
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class TriangleMesh : public TRS
|
|||||||
public:
|
public:
|
||||||
uLibTypeMacro(TriangleMesh, TRS)
|
uLibTypeMacro(TriangleMesh, TRS)
|
||||||
|
|
||||||
virtual const char * GetClassName() const override { return "TriangleMesh"; }
|
|
||||||
|
|
||||||
void PrintSelf(std::ostream &o);
|
void PrintSelf(std::ostream &o);
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Abstract {
|
|||||||
class VoxImage : public uLib::StructuredGrid {
|
class VoxImage : public uLib::StructuredGrid {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const char * GetClassName() const { return "VoxImage"; }
|
|
||||||
|
|
||||||
typedef uLib::StructuredGrid BaseClass;
|
typedef uLib::StructuredGrid BaseClass;
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class VoxImageFilter : public Abstract::VoxImageFilter, public Object {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual const char * GetClassName() const { return "VoxImageFilter"; }
|
|
||||||
|
|
||||||
VoxImageFilter(const Vector3i &size);
|
VoxImageFilter(const Vector3i &size);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class vtkObjectsContext; // forward
|
|||||||
*/
|
*/
|
||||||
class Assembly : public Puppet {
|
class Assembly : public Puppet {
|
||||||
public:
|
public:
|
||||||
virtual const char *GetClassName() const override { return "Vtk.Assembly"; }
|
uLibTypeMacro(Assembly, Puppet)
|
||||||
|
|
||||||
Assembly(uLib::Assembly *content);
|
Assembly(uLib::Assembly *content);
|
||||||
virtual ~Assembly();
|
virtual ~Assembly();
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
#include "Vtk/Math/vtkCylinder.h"
|
#include "Vtk/Math/vtkCylinder.h"
|
||||||
#include "Vtk/Math/vtkAssembly.h"
|
#include "Vtk/Math/vtkAssembly.h"
|
||||||
#include "Vtk/Math/vtkVoxImage.h"
|
#include "Vtk/Math/vtkVoxImage.h"
|
||||||
|
|
||||||
#include "HEP/Detectors/vtkDetectorChamber.h"
|
#include "HEP/Detectors/vtkDetectorChamber.h"
|
||||||
|
#include "HEP/Geant/vtkBoxSolid.h"
|
||||||
|
|
||||||
#include <vtkAssembly.h>
|
#include <vtkAssembly.h>
|
||||||
#include <vtkPropCollection.h>
|
#include <vtkPropCollection.h>
|
||||||
@@ -127,6 +129,9 @@ Puppet* vtkObjectsContext::CreatePuppet(uLib::Object* obj) {
|
|||||||
} else if (auto* assembly = dynamic_cast<uLib::Assembly*>(obj)) {
|
} else if (auto* assembly = dynamic_cast<uLib::Assembly*>(obj)) {
|
||||||
return new Assembly(assembly);
|
return new Assembly(assembly);
|
||||||
}
|
}
|
||||||
|
else if (auto* box = dynamic_cast<uLib::Geant::BoxSolid*>(obj)) {
|
||||||
|
return new vtkBoxSolid(box);
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback if we don't know the exact class but it might be a context itself
|
// Fallback if we don't know the exact class but it might be a context itself
|
||||||
if (auto subCtx = dynamic_cast<uLib::ObjectsContext*>(obj)) {
|
if (auto subCtx = dynamic_cast<uLib::ObjectsContext*>(obj)) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Vtk {
|
|||||||
*/
|
*/
|
||||||
class vtkObjectsContext : public Puppet {
|
class vtkObjectsContext : public Puppet {
|
||||||
public:
|
public:
|
||||||
virtual const char* GetClassName() const override { return "vtkObjectsContext"; }
|
uLibTypeMacro(vtkObjectsContext, Puppet)
|
||||||
vtkObjectsContext(uLib::ObjectsContext *context);
|
vtkObjectsContext(uLib::ObjectsContext *context);
|
||||||
virtual ~vtkObjectsContext();
|
virtual ~vtkObjectsContext();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user