/*////////////////////////////////////////////////////////////////////////////// // CMT Cosmic Muon Tomography project ////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova All rights reserved Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it > ------------------------------------------------------------------ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. //////////////////////////////////////////////////////////////////////////////*/ #ifndef SOLID_H #define SOLID_H #include "Core/Object.h" #include "Geant/Matter.h" #include #include "Math/ContainerBox.h" #include "Math/Dense.h" #include "Math/TriangleMesh.h" class G4Material; class G4LogicalVolume; class G4TessellatedSolid; class G4Box; namespace uLib { namespace Geant { class Solid : public Object { public: uLibTypeMacro(Solid, Object) Solid(); Solid(const char *name); virtual ~Solid(); void SetNistMaterial(const char *name); void SetMaterial(G4Material *material); void SetSizeUnit(const char *unit); // Implementiamo SetParent qui, per tutti. virtual void SetParent(Solid *parent); // Setters per la posizione (necessari per il piazzamento) void SetTransform(Matrix4f transform); uLibGetMacro(Material, G4Material *) uLibGetSetMacro(Logical, G4LogicalVolume *) uLibGetSetMacro(Physical, G4VPhysicalVolume *) virtual G4VSolid* GetG4Solid() const { return nullptr; } inline const char *GetName() const { return m_Logical ? m_Logical->GetName().c_str() : m_Name.c_str(); } template < typename Ar > void serialize(Ar &ar, const unsigned int version) { ar & m_Name; } protected: std::string m_Name; G4Material *m_Material; G4LogicalVolume *m_Logical; G4VPhysicalVolume *m_Physical; // <-- Memorizza l'oggetto posizionato G4ThreeVector *m_Position; // <-- Offset rispetto al centro del padre G4RotationMatrix* m_Rotation; // <-- Rotazione rispetto al padre }; class TessellatedSolid : public Solid { public: uLibTypeMacro(TessellatedSolid, Solid) TessellatedSolid(); TessellatedSolid(const char *name); void SetMesh(TriangleMesh &mesh); uLibGetMacro(Solid, G4TessellatedSolid *) virtual G4VSolid* GetG4Solid() const override { return (G4VSolid*)m_Solid; } const TriangleMesh& GetMesh() const { return m_Mesh; } public slots: void Update(); private : TriangleMesh m_Mesh; G4TessellatedSolid *m_Solid; }; class BoxSolid : public Solid { public: uLibTypeMacro(BoxSolid, Solid) BoxSolid(const char *name = ""); BoxSolid(const char *name, ContainerBox *box); virtual G4VSolid* GetG4Solid() const override { return (G4VSolid*)m_Solid; } ContainerBox* GetObject() const { return m_ContainerBox; } template < typename Ar > void serialize(Ar &ar, const unsigned int version) { ar & boost::serialization::base_object(*this); ar & m_ContainerBox; } public slots: void Update(); private: ContainerBox *m_ContainerBox; G4Box *m_Solid; }; } // namespace Geant } // namespace uLib #endif // SOLID_H