7 #include <GeoModelKernel/GeoBox.h>
8 #include <GeoModelKernel/GeoTrd.h>
9 #include <GeoModelKernel/GeoSimplePolygonBrep.h>
11 #include <GeoModelKernel/GeoTube.h>
13 #include <GeoModelKernel/GeoShapeUnion.h>
14 #include <GeoModelKernel/GeoShapeIntersection.h>
15 #include <GeoModelKernel/GeoShapeSubtraction.h>
16 #include <GeoModelKernel/GeoShapeShift.h>
18 #include <GeoModelKernel/GeoTransform.h>
20 #include <GeoModelKernel/GeoVolumeCursor.h>
22 #include <GeoModelHelpers/GeoShapeUtils.h>
23 #include <GeoModelHelpers/printVolume.h>
24 #include <GeoModelHelpers/TransformToStringConverter.h>
35 MuonGeoUtilityTool::~MuonGeoUtilityTool() =
default;
37 const GeoShape* MuonGeoUtilityTool::extractShape(
const PVConstLink& physVol)
const {
38 return extractShape(physVol->getLogVol()->getShape());
40 const GeoShape* MuonGeoUtilityTool::extractShape(
const GeoShape* inShape)
const {
42 if (inShape->typeID() == GeoShapeShift::getClassTypeID()) {
43 const auto shift = dynamic_pointer_cast<const GeoShapeShift>(compressShift(inShape));
46 <<
". Continue navigation "<<printGeoShape(shift));
47 return extractShape(shift->getOp());
49 if (inShape->typeID() == GeoShapeSubtraction::getClassTypeID()){
51 "Shape is a subtraction. Extract the basic shape. Continue navigation "<<inShape);
52 const GeoShapeSubtraction* subtract =
static_cast<const GeoShapeSubtraction*
>(inShape);
53 return extractShape(subtract->getOpA());
57 std::string MuonGeoUtilityTool::dumpShape(
const GeoShape* shape)
const {
return printGeoShape(shape); }
58 std::string MuonGeoUtilityTool::dumpVolume(
const PVConstLink& physVol)
const {
return printVolume(physVol); }
59 const GeoAlignableTransform* MuonGeoUtilityTool::findAlignableTransform(
const PVConstLink& physVol)
const {
60 PVConstLink
parent{physVol->getParent()}, child{physVol};
62 const GeoGraphNode *
const * node1 =
parent->findChildNode(child);
63 const GeoGraphNode *
const * fence =
parent->getChildNode(0);
66 if (
dynamic_cast<const GeoVPhysVol*
>(
node)) {
69 const GeoAlignableTransform* alignTrans{
dynamic_cast<const GeoAlignableTransform*
>(
node)};
75 parent = child->getParent();
80 std::vector<MuonGeoUtilityTool::physVolWithTrans> MuonGeoUtilityTool::findAllLeafNodesByName(
const PVConstLink& physVol,
const std::string& volumeName)
const {
81 return getAllSubVolumes(physVol,[&volumeName](
const physVolWithTrans& child){
82 return child.volume->getLogVol()->
getName() == volumeName || child.nodeName == volumeName;
85 std::vector<const GeoShape*> MuonGeoUtilityTool::getComponents(
const GeoShape* booleanShape)
const {
86 return getBooleanComponents(booleanShape);
89 std::vector<Amg::Vector2D> MuonGeoUtilityTool::polygonEdges(
const GeoSimplePolygonBrep& polygon)
const {
90 std::vector<Amg::Vector2D> polygonEdges{};
91 polygonEdges.reserve(polygon.getNVertices());
92 for (
unsigned int i = 0;
i < polygon.getNVertices(); ++
i) {
93 polygonEdges.emplace_back(polygon.getXVertex(
i), polygon.getYVertex(
i));
99 std::vector<Amg::Vector3D> MuonGeoUtilityTool::shapeEdges(
const GeoShape* shape,
101 return getPolyShapeEdges(shape, refTrf);