37 namespace SurfaceVisualization {
47 const std::string&
tag) {
49 auto identity = std::make_shared<Transform3D>(Transform3D::Identity());
50 std::stringstream cStream;
52 double halfPhiSector =
M_PI / 4.;
53 double centralPhi =
M_PI / 2.;
58 auto write = [&](
const std::string& path,
bool clear =
true) ->
void {
59 std::string wpath = path + tag;
63 cStream << std::setprecision(4);
64 helper.
write(cStream);
73 std::vector<std::shared_ptr<ConeSurface>> coneSurfaces;
75 double coneAlpha = 0.245;
78 double coneMaxZ = 10.;
81 std::make_shared<ConeBounds>(coneAlpha, -coneCutZ, coneMaxZ);
82 auto cone = Surface::makeShared<ConeSurface>(
identity, coneBounds);
83 coneSurfaces.push_back(cone);
85 triangulate, coneColor);
86 write(
"Surfaces_ConeSurface");
89 coneBounds = std::make_shared<ConeBounds>(coneAlpha, coneMinZ, coneMaxZ,
91 cone = Surface::makeShared<ConeSurface>(
identity, coneBounds);
92 coneSurfaces.push_back(cone);
94 triangulate, coneColor);
95 write(
"Surfaces_ConeSurfaceSector");
98 coneBounds = std::make_shared<ConeBounds>(coneAlpha, coneCutZ, coneMaxZ,
99 halfPhiSector, centralPhi);
100 cone = Surface::makeShared<ConeSurface>(
identity, coneBounds);
101 coneSurfaces.push_back(cone);
103 triangulate, coneColor);
104 write(
"Surfaces_ConeSurfaceSectorShifted");
107 std::vector<Transform3D> threeCones = {
112 for (
size_t ic = 0; ic < coneSurfaces.size(); ++ic) {
114 72, triangulate, coneColor);
116 write(
"Surfaces_All_ConeSurfaces");
121 std::vector<std::shared_ptr<CylinderSurface>> cylinderSurfaces;
123 double cylinderRadius = 5.;
124 double cylinderHalfZ = 10.;
127 auto cylinderBounds =
128 std::make_shared<CylinderBounds>(cylinderRadius, cylinderHalfZ);
130 Surface::makeShared<CylinderSurface>(
identity, cylinderBounds);
131 cylinderSurfaces.push_back(cylinder);
133 72, triangulate, cylinderColor);
134 write(
"Surfaces_CylinderSurface");
136 cylinderBounds = std::make_shared<CylinderBounds>(
137 cylinderRadius, cylinderHalfZ, halfPhiSector);
138 cylinder = Surface::makeShared<CylinderSurface>(
identity, cylinderBounds);
139 cylinderSurfaces.push_back(cylinder);
141 72, triangulate, cylinderColor);
142 write(
"Surfaces_CylinderSurfaceSector");
145 cylinderBounds = std::make_shared<CylinderBounds>(
146 cylinderRadius, cylinderHalfZ, halfPhiSector, centralPhi);
147 cylinder = Surface::makeShared<CylinderSurface>(
identity, cylinderBounds);
148 cylinderSurfaces.push_back(cylinder);
150 72, triangulate, cylinderColor);
151 write(
"Surfaces_CylinderSurfaceSectorShifted");
154 std::vector<Transform3D> threeCylinders = {
159 for (
size_t ic = 0; ic < cylinderSurfaces.size(); ++ic) {
161 threeCylinders[ic], 72, triangulate,
164 write(
"Surfaces_All_CylinderSurfaces");
169 const std::string& path) ->
void {
172 std::string bbPath = path + tag +
"_bbox";
174 auto bbBounds = std::make_shared<RectangleBounds>(rBounds);
175 auto bbSurface = Surface::makeShared<PlaneSurface>(
identity, bbBounds);
177 Transform3D::Identity(), 72, triangulate,
186 double discRmin = 5.;
187 double discRmax = 10.;
189 std::vector<std::shared_ptr<DiscSurface>> radialSurfaces;
192 auto radialBounds = std::make_shared<RadialBounds>(0., discRmax);
193 auto disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
194 radialSurfaces.push_back(disc);
196 triangulate, discColor);
197 write(
"Surfaces_DiscSurfaceFull");
200 radialBounds = std::make_shared<RadialBounds>(0., discRmax, halfPhiSector);
201 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
202 radialSurfaces.push_back(disc);
204 triangulate, discColor);
205 write(
"Surfaces_DiscSurfaceFullSector");
209 std::make_shared<RadialBounds>(0., discRmax, halfPhiSector, centralPhi);
210 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
211 radialSurfaces.push_back(disc);
213 triangulate, discColor);
214 write(
"Surfaces_DiscSurfaceFullSectorShifted");
217 radialBounds = std::make_shared<RadialBounds>(discRmin, discRmax);
218 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
219 radialSurfaces.push_back(disc);
221 triangulate, discColor);
222 write(
"Surfaces_DiscSurfaceRing");
226 std::make_shared<RadialBounds>(discRmin, discRmax, halfPhiSector);
227 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
228 radialSurfaces.push_back(disc);
230 triangulate, discColor);
231 write(
"Surfaces_DiscSurfaceRingSector");
234 radialBounds = std::make_shared<RadialBounds>(discRmin, discRmax,
235 halfPhiSector, centralPhi);
236 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
237 radialSurfaces.push_back(disc);
239 triangulate, discColor);
240 write(
"Surfaces_DiscSurfaceRingSectorShifted");
243 std::vector<Transform3D> sixDiscs = {
250 for (
size_t ir = 0; ir < radialSurfaces.size(); ++ir) {
252 72, triangulate, discColor);
254 write(
"Surfaces_All_DiscSurfaces_RadialBounds");
256 std::vector<std::shared_ptr<DiscSurface>> anomalDiscSurfaces;
259 double annulusMinPhi = 0.75;
260 double annulusMaxPhi = 1.35;
262 auto annulus = std::make_shared<AnnulusBounds>(
263 discRmin, discRmax, annulusMinPhi, annulusMaxPhi,
offset);
264 disc = Surface::makeShared<DiscSurface>(
identity, annulus);
265 anomalDiscSurfaces.push_back(disc);
267 triangulate, discAnomalColor);
268 write(
"Surfaces_DiscAnulusBounds");
270 double discTrapezoidHxRmin = 3.;
271 double discTrapezoidHxRmax = 6.;
272 auto discTrapezoid = std::make_shared<DiscTrapezoidBounds>(
273 discTrapezoidHxRmin, discTrapezoidHxRmax, discRmin, discRmax);
274 disc = Surface::makeShared<DiscSurface>(
identity, discTrapezoid);
275 anomalDiscSurfaces.push_back(disc);
277 triangulate, discAnomalColor);
278 write(
"Surfaces_DiscTrapezoidBounds");
281 std::vector<Transform3D> twoAnomalDiscs = {
284 for (
size_t id = 0;
id < anomalDiscSurfaces.size(); ++id) {
286 sixDiscs[
id], 72, triangulate, discAnomalColor);
288 write(
"Surfaces_All_DiscSurfaces_AnomalBounds");
293 std::vector<std::shared_ptr<PlaneSurface>> planarSurfaces;
296 double ellipseR0min = 2;
297 double ellipseR0max = 4;
298 double ellipseR1min = 3;
299 double ellipseR1max = 6;
300 std::string
name =
"Surfaces_PlaneSurfaceEllipse";
302 std::make_shared<EllipseBounds>(0., 0., ellipseR1min, ellipseR1max);
303 auto plane = Surface::makeShared<PlaneSurface>(
identity, ellipse);
304 planarSurfaces.push_back(plane);
306 triangulate, planeColor);
308 writeBoundingBox2D(ellipse->boundingBox(),
name);
311 name =
"Surfaces_PlaneSurfaceEllipseRing";
312 ellipse = std::make_shared<EllipseBounds>(ellipseR0min, ellipseR0max,
313 ellipseR1min, ellipseR1max);
314 plane = Surface::makeShared<PlaneSurface>(
identity, ellipse);
315 planarSurfaces.push_back(plane);
317 triangulate, planeColor);
319 writeBoundingBox2D(ellipse->boundingBox(),
name);
322 name =
"Surfaces_PlaneSurfaceEllipseRingSector";
323 ellipse = std::make_shared<EllipseBounds>(
324 ellipseR0min, ellipseR0max, ellipseR1min, ellipseR1max, halfPhiSector);
325 plane = Surface::makeShared<PlaneSurface>(
identity, ellipse);
326 planarSurfaces.push_back(plane);
328 triangulate, planeColor);
330 writeBoundingBox2D(ellipse->boundingBox(),
name);
333 name =
"Surfaces_PlaneSurfaceTriangleRegular";
334 std::vector<Vector2D> tvertices = {{-3, -1.5}, {3, -1.5}, {0, 4.5}};
335 auto triangle = std::make_shared<ConvexPolygonBounds<3>>(tvertices);
336 plane = Surface::makeShared<PlaneSurface>(
identity, triangle);
337 planarSurfaces.push_back(plane);
339 triangulate, planeColor);
341 writeBoundingBox2D(triangle->boundingBox(),
name);
344 name =
"Surfaces_PlaneSurfaceTriangleGeneral";
345 tvertices = {{-1., 4.5}, {4, 6.5}, {3, 8.5}};
346 triangle = std::make_shared<ConvexPolygonBounds<3>>(tvertices);
347 plane = Surface::makeShared<PlaneSurface>(
identity, triangle);
348 planarSurfaces.push_back(plane);
350 triangulate, planeColor);
352 writeBoundingBox2D(triangle->boundingBox(),
name);
355 name =
"Surfaces_PlaneSurfaceConvexPolygonGeneral";
356 tvertices = {{-1., 4.5}, {4, 6.5}, {6, 8.5}, {0, 10.5}, {-3, 6.2}};
357 auto dynamicpolygon =
358 std::make_shared<ConvexPolygonBounds<PolygonDynamic>>(tvertices);
359 plane = Surface::makeShared<PlaneSurface>(
identity, dynamicpolygon);
360 planarSurfaces.push_back(plane);
362 triangulate, planeColor);
364 writeBoundingBox2D(dynamicpolygon->boundingBox(),
name);
367 name =
"Surfaces_PlaneSurfaceDiamond";
368 auto diamond = std::make_shared<DiamondBounds>(3., 6., 2., 2., 4.);
369 plane = Surface::makeShared<PlaneSurface>(
identity, diamond);
370 planarSurfaces.push_back(plane);
372 triangulate, planeColor);
374 writeBoundingBox2D(diamond->boundingBox(),
name);
377 name =
"Surfaces_PlaneSurfaceRectangle";
378 auto rectangle = std::make_shared<RectangleBounds>(2., 3.);
380 planarSurfaces.push_back(plane);
382 triangulate, planeColor);
387 name =
"Surfaces_PlaneSurfaceRectangleOffcentered";
392 triangulate, planeColor);
397 name =
"Surfaces_PlaneSurfaceTrapezoid";
398 auto trapezoid = std::make_shared<TrapezoidBounds>(2., 5., 3.);
399 plane = Surface::makeShared<PlaneSurface>(
identity, trapezoid);
400 planarSurfaces.push_back(plane);
402 triangulate, planeColor);
404 writeBoundingBox2D(trapezoid->boundingBox(),
name);
407 std::vector<Transform3D> ninePlanes = {
417 for (
size_t ip = 0; ip < planarSurfaces.size(); ++ip) {
419 ninePlanes[ip], 72, triangulate, planeColor);
421 write(
"Surfaces_All_PlaneSurfaces");
427 name =
"Surfaces_StrawSurface";
428 auto tube = std::make_shared<LineBounds>(2., 20.);
429 auto straw = Surface::makeShared<StrawSurface>(
identity, tube);
431 triangulate, strawColor);
434 return cStream.str();