27#include "TGeoBoolNode.h"
28#include "TGeoCompositeShape.h"
29#include "TGeoHalfSpace.h"
30#include "TGeoMatrix.h"
35const std::string RootGM::DisplacedSolid::fgkNameExtension =
"_displ";
39 const std::string& name,
VGM::ISolid* solid, TGeoMatrix* displacement)
41 VGM::IDisplacedSolid(),
44 fConstituentSolid(solid)
56 std::string newName = name;
59 displacement->SetName(newName.data());
60 displacement->RegisterYourself();
62 TGeoBoolNode* boolNode =
new TGeoUnion(rootSolid, rootSolid, displacement, 0);
64 fCompositeShape =
new TGeoCompositeShape(newName.data(), boolNode);
72 VGM::IDisplacedSolid(),
81 const Double_t* origin = box->GetOrigin();
83 std::cerr <<
" RootGM::DisplacedSolid::DisplacedSolid: " << std::endl;
84 std::cerr <<
" Cannot create displaced solid from a box without offset."
86 std::cerr <<
" (TGeoBBox name = " << box->GetName() <<
")" << std::endl;
87 std::cerr <<
"*** Error: Aborting execution ***" << std::endl;
92 std::string newName = std::string(box->GetName()) + fgkNameExtension;
99 TGeoMatrix* displacement =
100 new TGeoTranslation(origin[0], origin[1], origin[2]);
101 displacement->SetName(newName.data());
102 displacement->RegisterYourself();
104 TGeoBoolNode* boolNode =
new TGeoUnion(box, box, displacement, 0);
106 fCompositeShape =
new TGeoCompositeShape(newName.data(), boolNode);
115 VGM::IDisplacedSolid(),
125 std::string newName = std::string(halfSpace->GetName()) + fgkNameExtension;
128 double size = 1.0e03;
130 TGeoBBox* box =
new TGeoBBox(
"bigBox", size, size, size);
135 Double_t* point = halfSpace->GetPoint();
136 Double_t* norm = halfSpace->GetNorm();
157 TGeoRotation* rotation =
new TGeoRotation();
158 rotation->SetMatrix(rot);
165 Double_t newOrigin[3];
166 rotation->LocalToMaster(origin, newOrigin);
167 for (Int_t i = 0; i < 3; i++) newOrigin[i] = newOrigin[i] + point[i];
170 TGeoMatrix* displacement =
171 new TGeoCombiTrans(newOrigin[0], newOrigin[1], newOrigin[2], rotation);
172 displacement->SetName(newName.data());
173 displacement->RegisterYourself();
175 TGeoBoolNode* boolNode =
new TGeoUnion(box, box, displacement, 0);
177 fCompositeShape =
new TGeoCompositeShape(newName.data(), boolNode);
213 return fCompositeShape->GetName();
222 return fConstituentSolid;
232 TGeoBoolNode* boolNode = fCompositeShape->GetBoolNode();
234 TGeoMatrix* matrixB = boolNode->GetLeftMatrix();
235 TGeoHMatrix transformB(*matrixB);
VGM implementation for Root box solid.
virtual std::string Name() const
Return the name of this solid.
virtual ~DisplacedSolid()
virtual VGM::ISolid * ConstituentSolid() const
Return the constituent solid.
virtual VGM::Transform Displacement() const
Return the 3D displacement of the constituent solid.
DisplacedSolid(const std::string &name, VGM::ISolid *solid, TGeoMatrix *displacement)
TGeoShape * GetSolid(VGM::ISolid *iSolid) const
void AddSolidInRootMapOnly(VGM::ISolid *, TGeoShape *)
void AddSolid(VGM::ISolid *, TGeoShape *)
void AddSolidInVGMMapOnly(VGM::ISolid *, TGeoShape *)
static SolidMap * Instance()
The VGM interface to solids.
void fromToRotation(double from[3], double to[3], double mtx[3][3])
VGM::Transform Transform(const TGeoMatrix &matrix)
std::vector< double > Transform