diff --git a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoLogVol.h b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoLogVol.h index cb3b5a3e90e3b409e71e93d3c86200360637d373..7885deaad6f984ed3f19b9be46a0a7caa867df94 100644 --- a/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoLogVol.h +++ b/GeoModelCore/GeoModelKernel/GeoModelKernel/GeoLogVol.h @@ -4,7 +4,6 @@ #ifndef GEOMODELKERNEL_GEOLOGVOL_H #define GEOMODELKERNEL_GEOLOGVOL_H - /** * @class GeoLogVol * @@ -17,7 +16,9 @@ #include "GeoModelKernel/GeoIntrusivePtr.h" #include "GeoModelKernel/GeoMaterial.h" #include <vector> - +#include <thread> +#include <shared_mutex> +#include <mutex> class GeoLogVol : public RCBase { public: @@ -35,7 +36,14 @@ class GeoLogVol : public RCBase // Returns the material of the logical volume. const GeoMaterial* getMaterial () const { - return m_material; + std::shared_lock lock{m_mutex}; + return m_material; + } + + // In some cases (gases, liquids) materials be updated? + void setMaterial (const GeoMaterial *newMaterial) const { + std::unique_lock guards{m_mutex}; + m_material = newMaterial; } protected: @@ -47,7 +55,8 @@ class GeoLogVol : public RCBase std::string m_name{}; // Material composition of this volume. - GeoIntrusivePtr<const GeoMaterial> m_material{}; + mutable GeoIntrusivePtr<const GeoMaterial> m_material{}; + mutable std::shared_mutex m_mutex{}; // Shape of this volume. GeoIntrusivePtr<const GeoShape> m_shape{}; diff --git a/GeoModelExamples/KitchenSinkPlugin/src/KitchenSinkPlugin.cxx b/GeoModelExamples/KitchenSinkPlugin/src/KitchenSinkPlugin.cxx index d1597e8ef72fb6e55c4d7d355bf637d185025ea7..e944339545b665808f19908e84c289e69c3fbd15 100644 --- a/GeoModelExamples/KitchenSinkPlugin/src/KitchenSinkPlugin.cxx +++ b/GeoModelExamples/KitchenSinkPlugin/src/KitchenSinkPlugin.cxx @@ -301,6 +301,9 @@ void KitchenSinkPlugin::create(GeoVPhysVol *world, bool /*publish*/) { ); world->add(wTransform); world->add(wPhys); + wLog->setMaterial(Stainless); + + } //--------------------------------------//