31#include "TGeoBoolNode.h"
32#include "TGeoCompositeShape.h"
33#include "TGeoManager.h"
34#include "TGeoMatrix.h"
36#include "TGeoVolume.h"
38bool RootGM::Placement::fgIncludeAssembliesInNames =
true;
39char RootGM::Placement::fgNameSeparator =
'%';
40char RootGM::Placement::fgNamePrefix =
'&';
48 bool includeAssembliesInNames)
53 fgIncludeAssembliesInNames = includeAssembliesInNames;
62 return fgIncludeAssembliesInNames;
70 fgNameSeparator = nameSeparator;
78 fgNamePrefix = namePrefix;
86 return fgNameSeparator;
108 fVGMMatrix(transformation),
124 fGeoNode = gGeoManager->GetTopNode();
131 TGeoMatrix* totalMatrix = transformation;
135 totalMatrix = ComposeMatrix(volume, motherVolume, transformation);
136 totalMatrix->SetName(name.data());
137 totalMatrix->RegisterYourself();
143 TGeoVolume* geoMotherVolume =
147 geoMotherVolume->AddNode(geoVolume, copyNo, totalMatrix);
150 fGeoNode = geoMotherVolume->GetNode(geoMotherVolume->GetNdaughters() - 1);
179 TGeoVolume* geoMotherVolume =
189 geoMotherVolume->GetShape()->GetAxisRange(iAxis, xlo, xhi);
190 Double_t start = xlo + offset;
193 geoMotherVolume->Divide(name.data(), iAxis, nofItems, start, width);
196 fGeoNode = geoMotherVolume->GetNode(geoMotherVolume->GetNdaughters() - 1);
214 if (volume) fName = volume->
Name();
218 fVGMMatrix = node->GetMatrix();
222 node->GetOverlaps(novlp);
224 std::cerr <<
"*** Warning: node with overlaps ***" << std::endl
225 <<
"*** Overlaps may not be supported in exported geometry!!! ***"
227 <<
" Volume: " << volume->
Name()
228 <<
" in mother: " << motherVolume->
Name()
229 <<
" (TGeoNode name: " << node->GetName() <<
")" << std::endl;
238 TGeoNode* node, std::vector<const TGeoNode*> assemblyNodes)
244 fAssemblyNodes(assemblyNodes)
248 if (volume) fName = volume->
Name();
252 fVGMMatrix = node->GetMatrix();
282TGeoMatrix* RootGM::Placement::ComposeMatrix(
VGM::IVolume* volume,
283 VGM::IVolume* motherVolume, TGeoMatrix* transformation)
const
287 TGeoHMatrix motherTransform;
292 TGeoHMatrix displacement(
294 motherTransform = motherTransform * displacement;
299 TGeoHMatrix solidTransform;
304 TGeoHMatrix displacement(
306 solidTransform = solidTransform * displacement;
311 TGeoHMatrix totalTransform =
312 motherTransform.Inverse() * TGeoHMatrix(*transformation) * solidTransform;
314 return new TGeoHMatrix(totalTransform);
328 const TGeoPatternFinder* finder = fGeoNode->GetMotherVolume()->GetFinder();
344 if (fgIncludeAssembliesInNames) {
345 for (
unsigned i = 0; i < fAssemblyNodes.size(); i++) {
346 if (i == 0) name += fgNamePrefix;
347 name += fAssemblyNodes[i]->GetName();
348 name += fgNameSeparator;
351 name += fName.c_str();
360 return fGeoNode->GetNumber();
368 TGeoHMatrix transform3D;
369 if (fGeoNode->GetVolume()->GetShape()->IsComposite()) {
372 transform3D = TGeoHMatrix(*(fGeoNode->GetMatrix())) *
376 transform3D = fGeoNode->GetMatrix();
383 transform3D = TGeoHMatrix(*fVGMMatrix);
387 for (
unsigned i = fAssemblyNodes.size(); i > 0; i--) {
388 TGeoMatrix* matrixAN = fAssemblyNodes[i - 1]->GetMatrix();
389 TGeoHMatrix transformAN(*matrixAN);
390 transform3D = transformAN * transform3D;
398 const TGeoNode* motherNode =
399 fAssemblyNodes.size() ? fAssemblyNodes[0] : fGeoNode;
400 TGeoVolume* motherVolume = motherNode ? motherNode->GetMotherVolume() : 0;
402 if (motherVolume && motherVolume->GetShape()->IsComposite()) {
409 transform3D.SetBit(TGeoMatrix::kGeoRegistered,
false);
416 double& width,
double& offset,
double& halfGap)
const
419 const TGeoPatternFinder* finder = fGeoNode->GetMotherVolume()->GetFinder();
420 if (!finder)
return false;
424 nofItems = finder->GetNdiv();
425 Double_t start = finder->GetStart();
427 fGeoNode->GetMotherVolume()->GetShape()->GetAxisRange(
429 offset = start - xlo;
430 width = finder->GetStep();
443 std::vector<VGM::Transform>& ,
444 std::vector<VGM::IVolume*>& )
const
449 std::cout <<
"Please implement RootGM::Placement::ParameterisedPlacementData "
450 "if you need to use it!"
virtual VGM::IVolume * Volume() const
Return the associated volume.
virtual VGM::IVolume * Mother() const
Return the associated mother volume.
VPlacement(VGM::IVolume *volume, VGM::IVolume *motherVolume)
static PlacementMap * Instance()
void AddPlacement(VGM::IPlacement *, TGeoNode *)
Placement(const std::string &name, int copyNo, VGM::IVolume *volume, VGM::IVolume *motherVolume, TGeoMatrix *transformation)
static bool GetIncludeAssembliesInNames()
static void SetNamePrefix(char namePrefix)
virtual VGM::Transform Transformation() const
Return the 3D transformation (if simple placement).
static void SetNameSeparator(char nameSeparator)
static char GetNamePrefix()
virtual VGM::PlacementType Type() const
Return the type of this placement.
static void SetIncludeAssembliesInNames(bool includeAssembliesInNames)
virtual std::string Name() const
Return the name of this placement.
static char GetNameSeparator()
virtual bool ParameterisedPlacementData(std::vector< VGM::Transform > &transforms, std::vector< VGM::IVolume * > &volumes) const
Fill the parameterised placement data if relevant and return true; return false if not parameterised ...
virtual int CopyNo() const
Return the copy number of this placement.
virtual bool MultiplePlacementData(VGM::Axis &axis, int &nofItems, double &width, double &offset, double &halfGap) const
Fill the multiple placement data if relevant and return true; return false if not multiple placement.
static double AxisUnit(VGM::Axis axis)
Return Root unit for the given axis in VGM units.
static VolumeMap * Instance()
TGeoVolume * GetVolume(VGM::IVolume *iVolume) const
The VGM interface to displaced solids.
virtual ISolid * ConstituentSolid() const =0
Return the constituent solid.
virtual Transform Displacement() const =0
Return the 3D displacement of the constituent solid.
The VGM interface to solids.
virtual SolidType Type() const =0
Return the type of this solid.
The VGM interface to volumes.
virtual ISolid * Solid() const =0
Return the associated solid.
virtual std::string Name() const =0
Return the name of this volume.
TGeoHMatrix CompositeLeftTransform(TGeoShape *shape)
TGeoMatrix * CreateTransform(const VGM::Transform &transform)
VGM::Axis Axis(const TGeoPatternFinder *finder)
VGM::Transform Transform(const TGeoMatrix &matrix)
std::vector< double > Transform