1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/// @file PlacedMultiUnion.cpp
/// @author Mihaela Gheata (mihaela.gheata@cern.ch)
#include "VecGeom/volumes/MultiUnion.h"
#ifndef VECCORE_CUDA
#ifdef VECGEOM_GEANT4
#include "G4MultiUnion.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "G4Transform3D.hh"
#endif
#endif // VECCORE_CUDA
namespace vecgeom {
inline namespace VECGEOM_IMPL_NAMESPACE {
VECCORE_ATT_HOST_DEVICE
void PlacedMultiUnion::PrintType() const
{
printf("PlacedMultiUnion");
}
void PlacedMultiUnion::PrintType(std::ostream &s) const
{
s << "PlacedMultiUnion";
}
#ifndef VECCORE_CUDA
VPlacedVolume const *PlacedMultiUnion::ConvertToUnspecialized() const
{
return new SimpleMultiUnion(GetLabel().c_str(), GetLogicalVolume(), GetTransformation());
}
#ifdef VECGEOM_GEANT4
G4VSolid const *PlacedMultiUnion::ConvertToGeant4() const
{
G4MultiUnion *munion = new G4MultiUnion("g4multiunion");
const UnplacedMultiUnion *unplaced = GetUnplacedVolume();
for (size_t i = 0; i < unplaced->GetNumberOfSolids(); ++i) {
G4VSolid *g4solid = (G4VSolid *)unplaced->GetNode(i)->ConvertToGeant4();
assert(g4solid && "Cannot convert component to Geant4 solid");
auto trans = unplaced->GetNode(i)->GetTransformation();
// Vector3D<double> point(1, 1, 1);
// Vector3D<double> pnew = trans->Transform(point);
const double *rotm = trans->Rotation();
G4RotationMatrix g4rot(G4ThreeVector(rotm[0], rotm[3], rotm[6]), G4ThreeVector(rotm[1], rotm[4], rotm[7]),
G4ThreeVector(rotm[2], rotm[5], rotm[8]));
G4Transform3D g4trans(g4rot, G4ThreeVector(trans->Translation(0), trans->Translation(1), trans->Translation(2)));
// G4ThreeVector global(1, 1, 1);
// G4ThreeVector local = g4trans.inverse()*G4Point3D(global);
munion->AddNode(*g4solid, g4trans);
}
munion->Voxelize();
return munion;
}
#endif
#endif // VECCORE_CUDA
} // End impl namespace
#ifdef VECCORE_CUDA
VECGEOM_DEVICE_INST_PLACED_VOLUME_ALLSPEC(SpecializedMultiUnion)
#endif
} // End global namespace
|