File indexing completed on 2025-03-13 09:29:32
0001 #ifndef VECGEOM_VOLUMES_TPLACEDTBOOLEANMINUS_H_
0002 #define VECGEOM_VOLUMES_TPLACEDTBOOLEANMINUS_H_
0003
0004 #include "VecGeom/base/Cuda.h"
0005 #include "VecGeom/base/Global.h"
0006
0007 #include "VecGeom/volumes/PlacedVolume.h"
0008 #include "VecGeom/volumes/UnplacedVolume.h"
0009 #include "VecGeom/volumes/kernel/TBooleanMinusImplementation.h"
0010 #include "VecGeom/volumes/TUnplacedBooleanMinusVolume.h"
0011
0012 #ifdef VECGEOM_ROOT
0013 #include "TGeoShape.h"
0014 #include "TGeoVolume.h"
0015 #include "TGeoCompositeShape.h"
0016 #include "TGeoBoolNode.h"
0017 #include "TGeoMatrix.h"
0018 #include "TGeoManager.h"
0019 #endif
0020
0021 #ifdef VECGEOM_GEANT4
0022 #include "G4SubtractionSolid.hh"
0023 #include "G4ThreeVector.hh"
0024 #endif
0025
0026 namespace VECGEOM_NAMESPACE {
0027
0028 class TPlacedBooleanMinusVolume : public VPlacedVolume {
0029
0030 typedef TUnplacedBooleanMinusVolume UnplacedVol_t;
0031
0032 public:
0033 #ifndef VECCORE_CUDA
0034
0035 TPlacedBooleanMinusVolume(char const *const label, LogicalVolume const *const logicalVolume,
0036 Transformation3D const *const transformation, PlacedBox const *const boundingBox)
0037 : VPlacedVolume(label, logicalVolume, transformation, boundingBox)
0038 {
0039 }
0040
0041 TPlacedBooleanMinusVolume(LogicalVolume const *const logicalVolume, Transformation3D const *const transformation,
0042 PlacedBox const *const boundingBox)
0043 : TPlacedBooleanMinusVolume("", logicalVolume, transformation, boundingBox)
0044 {
0045 }
0046
0047 #else
0048
0049 VECCORE_ATT_DEVICE TPlacedBooleanMinusVolume(LogicalVolume const *const logicalVolume,
0050 Transformation3D const *const transformation,
0051 PlacedBox const *const boundingBox, const int id)
0052 : VPlacedVolume(logicalVolume, transformation, boundingBox, id)
0053 {
0054 }
0055
0056 #endif
0057
0058 virtual ~TPlacedBooleanMinusVolume() {}
0059
0060 VECCORE_ATT_HOST_DEVICE
0061 UnplacedVol_t const *GetUnplacedVolume() const
0062 {
0063 return static_cast<UnplacedVol_t const *>(GetLogicalVolume()->unplaced_volume());
0064 }
0065
0066 VECCORE_ATT_HOST_DEVICE
0067 virtual void PrintType() const {};
0068
0069
0070 virtual int MemorySize() const { return sizeof(*this); }
0071
0072 #ifdef VECGEOM_CUDA_INTERFACE
0073 virtual VPlacedVolume *CopyToGpu(LogicalVolume const *const logical_volume,
0074 Transformation3D const *const transformation, VPlacedVolume *const gpu_ptr) const;
0075 virtual VPlacedVolume *CopyToGpu(LogicalVolume const *const logical_volume,
0076 Transformation3D const *const transformation) const;
0077 #endif
0078
0079
0080
0081 #ifndef VECGEOM_CUDA
0082 virtual VPlacedVolume const *ConvertToUnspecialized() const { return this; }
0083
0084 #ifdef VECGEOM_ROOT
0085 virtual TGeoShape const *ConvertToRoot() const
0086 {
0087 VPlacedVolume const *left = GetUnplacedVolume()->fLeftVolume;
0088 VPlacedVolume const *right = GetUnplacedVolume()->fRightVolume;
0089 Transformation3D const *leftm = left->transformation();
0090 Transformation3D const *rightm = right->transformation();
0091 TGeoSubtraction *node = new TGeoSubtraction(const_cast<TGeoShape *>(left->ConvertToRoot()),
0092 const_cast<TGeoShape *>(right->ConvertToRoot()),
0093 leftm->ConvertToTGeoMatrix(), rightm->ConvertToTGeoMatrix());
0094 return new TGeoCompositeShape("RootComposite", node);
0095 }
0096 #endif
0097 #ifdef VECGEOM_GEANT4
0098 virtual G4VSolid const *ConvertToGeant4() const
0099 {
0100 VPlacedVolume const *left = GetUnplacedVolume()->fLeftVolume;
0101 VPlacedVolume const *right = GetUnplacedVolume()->fRightVolume;
0102 Transformation3D const *rightm = right->transformation();
0103 return new G4SubtractionSolid(
0104 GetLabel(), const_cast<G4VSolid *>(left->ConvertToGeant4()), const_cast<G4VSolid *>(right->ConvertToGeant4()),
0105 0, G4ThreeVector(rightm->Translation(0), rightm->Translation(1), rightm->Translation(2)));
0106 }
0107 #endif
0108 #endif
0109
0110 };
0111
0112 }
0113
0114 #endif