Skip to content

Commit

Permalink
feat: Add GeoSimplePolygonBrep to GeoModelToDetectorVolume (#3713)
Browse files Browse the repository at this point in the history
This PR adds back in the conversion method for `GeoSimplePolygonBrep` to `DetectorVolume`. This somehow got removed during a refactoring.

Also included is a small bug fix that didn't propagate the volume transformation correctly for `GeoShapeShift` objects.

Tagging @junggjo9 @paulgessinger @noemina
  • Loading branch information
Matthewharri authored Oct 11, 2024
1 parent c175666 commit 05c2168
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ Volume convertVolume(const Transform3& trf, const GeoShape& shape) {
const GeoBox* box = dynamic_cast<const GeoBox*>(&shape);
bounds = std::make_shared<CuboidVolumeBounds>(
box->getXHalfLength(), box->getYHalfLength(), box->getZHalfLength());
} else if (shape.typeID() == GeoSimplePolygonBrep::getClassTypeID()) {
const GeoSimplePolygonBrep* brep =
dynamic_cast<const GeoSimplePolygonBrep*>(&shape);
double xmin{0}, xmax{0}, ymin{0}, ymax{0}, zmin{0}, zmax{0};
brep->extent(xmin, ymin, zmin, xmax, ymax, zmax);
bounds = std::make_shared<CuboidVolumeBounds>(
(xmax - xmin) / 2, (ymax - ymin) / 2, (zmax - zmin) / 2);
} else if (shape.typeID() == GeoTrd::getClassTypeID()) {
const GeoTrd* trd = dynamic_cast<const GeoTrd*>(&shape);
double x1 = trd->getXHalfLength1();
Expand Down Expand Up @@ -117,9 +124,10 @@ Volume convertVolume(const Transform3& trf, const GeoShape& shape) {
dynamic_cast<const GeoShapeShift*>(&shape);
const GeoShape* shapeOp = shiftShape->getOp();
newTrf = trf * shiftShape->getX();
return convertVolume(trf, *shapeOp);
return convertVolume(newTrf, *shapeOp);
} else {
throw std::runtime_error("FATAL: Unsupported GeoModel shape");
throw std::runtime_error("FATAL: Unsupported GeoModel shape: " +
shape.type());
}
return Volume(newTrf, bounds);
}
Expand Down

0 comments on commit 05c2168

Please sign in to comment.