Skip to content

Commit 62a5336

Browse files
authored
refactor: simplify volume drawing and lower case variables (acts-project#1962)
1 parent 56aff8b commit 62a5336

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

Core/include/Acts/Visualization/GeometryView3D.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ struct GeometryView3D {
4545
/// @param surface The surface to be drawn
4646
/// @param gctx The geometry context for which it is drawn
4747
/// @param transform An option additional transform
48-
/// @param ViewConfig The drawing configuration
48+
/// @param viewConfig The drawing configuration
4949
static void drawSurface(IVisualization3D& helper, const Surface& surface,
5050
const GeometryContext& gctx,
5151
const Transform3& transform = Transform3::Identity(),
52-
const ViewConfig& ViewConfig = s_viewSensitive);
52+
const ViewConfig& viewConfig = s_viewSensitive);
5353

5454
/// Helper method to draw SurfaceArray objects
5555
///
@@ -103,15 +103,14 @@ struct GeometryView3D {
103103
/// @param [in,out] helper The visualization helper
104104
/// @param volume The DetectorVolume to be drawn
105105
/// @param gctx The geometry context for which it is drawn
106-
/// @param drawSurfaces switches on/off the drawing of the volumes' surfaces
107106
/// @param transform An option additional transform
108107
/// @param connected The config for connected portals
109108
/// @param unconnected The config for unconnected portals
110109
/// @param viewConfig The drawing configuration
111110
static void drawDetectorVolume(
112111
IVisualization3D& helper,
113112
const Acts::Experimental::DetectorVolume& volume,
114-
const GeometryContext& gctx, bool drawSurfaces,
113+
const GeometryContext& gctx,
115114
const Transform3& transform = Transform3::Identity(),
116115
const ViewConfig& connected = ViewConfig({0, 255, 0}),
117116
const ViewConfig& unconnected = ViewConfig({255, 0, 0}),

Core/src/Visualization/GeometryView3D.cpp

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <unistd.h>
2929

3030
namespace {
31+
3132
std::string joinPaths(const std::string& a, const std::string& b) {
3233
if (b.substr(0, 1) == "/" || a.empty()) {
3334
return b;
@@ -50,13 +51,13 @@ std::string getWorkingDirectory() {
5051

5152
void Acts::GeometryView3D::drawPolyhedron(IVisualization3D& helper,
5253
const Polyhedron& polyhedron,
53-
const ViewConfig& ViewConfig) {
54-
if (ViewConfig.visible) {
55-
if (not ViewConfig.triangulate) {
56-
helper.faces(polyhedron.vertices, polyhedron.faces, ViewConfig.color);
54+
const ViewConfig& viewConfig) {
55+
if (viewConfig.visible) {
56+
if (not viewConfig.triangulate) {
57+
helper.faces(polyhedron.vertices, polyhedron.faces, viewConfig.color);
5758
} else {
5859
helper.faces(polyhedron.vertices, polyhedron.triangularMesh,
59-
ViewConfig.color);
60+
viewConfig.color);
6061
}
6162
}
6263
}
@@ -65,13 +66,13 @@ void Acts::GeometryView3D::drawSurface(IVisualization3D& helper,
6566
const Surface& surface,
6667
const GeometryContext& gctx,
6768
const Transform3& transform,
68-
const ViewConfig& ViewConfig) {
69+
const ViewConfig& viewConfig) {
6970
Polyhedron surfaceHedron =
70-
surface.polyhedronRepresentation(gctx, ViewConfig.nSegments);
71+
surface.polyhedronRepresentation(gctx, viewConfig.nSegments);
7172
if (not transform.isApprox(Transform3::Identity())) {
7273
surfaceHedron.move(transform);
7374
}
74-
drawPolyhedron(helper, surfaceHedron, ViewConfig);
75+
drawPolyhedron(helper, surfaceHedron, viewConfig);
7576
}
7677

7778
void Acts::GeometryView3D::drawSurfaceArray(
@@ -191,42 +192,23 @@ void Acts::GeometryView3D::drawPortal(IVisualization3D& helper,
191192

192193
void Acts::GeometryView3D::drawDetectorVolume(
193194
IVisualization3D& helper, const Experimental::DetectorVolume& volume,
194-
const GeometryContext& gctx, bool drawSurfaces, const Transform3& transform,
195+
const GeometryContext& gctx, const Transform3& transform,
195196
const ViewConfig& connected, const ViewConfig& unconnected,
196197
const ViewConfig& viewConfig) {
198+
// draw the surfaces of the mother volume
199+
for (auto surface : volume.surfaces()) {
200+
drawSurface(helper, *surface, gctx, transform, viewConfig);
201+
}
202+
197203
// draw the envelope first
198-
auto portals = volume.portals();
199-
for (auto portal : portals) {
204+
for (auto portal : volume.portals()) {
200205
drawPortal(helper, *portal, gctx, transform, connected, unconnected);
201206
}
202207

203-
// draw the surfaces of the mother volume
204-
if (drawSurfaces) {
205-
auto surfaces = volume.surfaces();
206-
for (auto surface : surfaces) {
207-
drawSurface(helper, *surface, gctx, transform, viewConfig);
208-
}
209-
}
210-
// recurse if there are subvolumes, otherwise draw the portals and the
211-
// surfaces if tag is true
212-
auto subvolumes = volume.volumes();
213-
for (auto subvolume : subvolumes) {
214-
if (!subvolume->volumes().empty()) {
215-
drawDetectorVolume(helper, *subvolume, gctx, drawSurfaces, transform,
216-
connected, unconnected, viewConfig);
217-
} else {
218-
auto sub_portals = subvolume->portals();
219-
for (auto sub_portal : sub_portals) {
220-
drawPortal(helper, *sub_portal, gctx, transform, connected,
221-
unconnected);
222-
}
223-
if (drawSurfaces) {
224-
auto sub_surfaces = subvolume->surfaces();
225-
for (auto sub_surface : sub_surfaces) {
226-
drawSurface(helper, *sub_surface, gctx, transform, viewConfig);
227-
}
228-
}
229-
}
208+
// recurse if there are subvolumes
209+
for (auto subvolume : volume.volumes()) {
210+
drawDetectorVolume(helper, *subvolume, gctx, transform, connected,
211+
unconnected, viewConfig);
230212
}
231213
}
232214

0 commit comments

Comments
 (0)