37 namespace SurfaceView3DTest {
49 auto identity = Transform3::Identity();
50 std::stringstream cStream;
52 double halfPhiSector = M_PI / 4.;
53 double centralPhi = M_PI / 2.;
60 std::vector<std::shared_ptr<ConeSurface>> coneSurfaces;
62 double coneAlpha = 0.245;
65 double coneMaxZ = 10.;
68 std::make_shared<ConeBounds>(coneAlpha, -coneCutZ, coneMaxZ);
69 auto cone = Surface::makeShared<ConeSurface>(
identity, coneBounds);
70 coneSurfaces.push_back(cone);
75 helper.
write(cStream);
79 coneBounds = std::make_shared<ConeBounds>(coneAlpha, coneMinZ, coneMaxZ,
81 cone = Surface::makeShared<ConeSurface>(
identity, coneBounds);
82 coneSurfaces.push_back(cone);
87 helper.
write(cStream);
91 coneBounds = std::make_shared<ConeBounds>(coneAlpha, coneCutZ, coneMaxZ,
92 halfPhiSector, centralPhi);
93 cone = Surface::makeShared<ConeSurface>(
identity, coneBounds);
94 coneSurfaces.push_back(cone);
99 helper.
write(cStream);
103 std::vector<Transform3> threeCones = {
108 for (
size_t ic = 0; ic < coneSurfaces.size(); ++ic) {
113 helper.
write(cStream);
118 std::vector<std::shared_ptr<CylinderSurface>> cylinderSurfaces;
120 double cylinderRadius = 5.;
121 double cylinderHalfZ = 10.;
124 auto cylinderBounds =
125 std::make_shared<CylinderBounds>(cylinderRadius, cylinderHalfZ);
127 Surface::makeShared<CylinderSurface>(
identity, cylinderBounds);
128 cylinderSurfaces.push_back(cylinder);
133 helper.
write(cStream);
137 cylinderBounds = std::make_shared<CylinderBounds>(
138 cylinderRadius, cylinderHalfZ, halfPhiSector);
139 cylinder = Surface::makeShared<CylinderSurface>(
identity, cylinderBounds);
140 cylinderSurfaces.push_back(cylinder);
145 helper.
write(cStream);
149 cylinderBounds = std::make_shared<CylinderBounds>(
150 cylinderRadius, cylinderHalfZ, halfPhiSector, centralPhi);
151 cylinder = Surface::makeShared<CylinderSurface>(
identity, cylinderBounds);
152 cylinderSurfaces.push_back(cylinder);
157 helper.
write(cStream);
161 std::vector<Transform3> threeCylinders = {
166 for (
size_t ic = 0; ic < cylinderSurfaces.size(); ++ic) {
168 threeCylinders[ic], sConfig);
171 helper.
write(cStream);
180 auto bbBounds = std::make_shared<RectangleBounds>(
rBounds);
181 auto bbSurface = Surface::makeShared<PlaneSurface>(
identity, bbBounds);
183 Transform3::Identity(), sConfig);
185 helper.
write(bbPath);
186 helper.
write(cStream);
193 double discRmin = 5.;
194 double discRmax = 10.;
196 std::vector<std::shared_ptr<DiscSurface>> radialSurfaces;
199 auto radialBounds = std::make_shared<RadialBounds>(0., discRmax);
200 auto disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
201 radialSurfaces.push_back(disc);
206 helper.
write(cStream);
210 radialBounds = std::make_shared<RadialBounds>(0., discRmax, halfPhiSector);
211 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
212 radialSurfaces.push_back(disc);
217 helper.
write(cStream);
222 std::make_shared<RadialBounds>(0., discRmax, halfPhiSector, centralPhi);
223 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
224 radialSurfaces.push_back(disc);
229 helper.
write(cStream);
233 radialBounds = std::make_shared<RadialBounds>(discRmin, discRmax);
234 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
235 radialSurfaces.push_back(disc);
240 helper.
write(cStream);
245 std::make_shared<RadialBounds>(discRmin, discRmax, halfPhiSector);
246 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
247 radialSurfaces.push_back(disc);
252 helper.
write(cStream);
256 radialBounds = std::make_shared<RadialBounds>(discRmin, discRmax,
257 halfPhiSector, centralPhi);
258 disc = Surface::makeShared<DiscSurface>(
identity, radialBounds);
259 radialSurfaces.push_back(disc);
264 helper.
write(cStream);
268 std::vector<Transform3> sixDiscs = {
275 for (
size_t ir = 0; ir < radialSurfaces.size(); ++ir) {
280 helper.
write(cStream);
283 std::vector<std::shared_ptr<DiscSurface>> anomalDiscSurfaces;
285 double annulusMinPhi = 0.75;
286 double annulusMaxPhi = 1.35;
288 auto annulus = std::make_shared<AnnulusBounds>(
289 discRmin, discRmax, annulusMinPhi, annulusMaxPhi,
offset);
290 disc = Surface::makeShared<DiscSurface>(
identity, annulus);
291 anomalDiscSurfaces.push_back(disc);
296 helper.
write(cStream);
299 double discTrapezoidHxRmin = 3.;
300 double discTrapezoidHxRmax = 6.;
301 auto discTrapezoid = std::make_shared<DiscTrapezoidBounds>(
302 discTrapezoidHxRmin, discTrapezoidHxRmax, discRmin, discRmax);
303 disc = Surface::makeShared<DiscSurface>(
identity, discTrapezoid);
304 anomalDiscSurfaces.push_back(disc);
309 helper.
write(cStream);
313 std::vector<Transform3> twoAnomalDiscs = {
316 for (
size_t id = 0;
id < anomalDiscSurfaces.size(); ++
id) {
318 sixDiscs[
id], sConfig);
321 helper.
write(cStream);
326 std::vector<std::shared_ptr<PlaneSurface>> planarSurfaces;
329 double ellipseR0min = 2;
330 double ellipseR0max = 4;
331 double ellipseR1min = 3;
332 double ellipseR1max = 6;
335 std::make_shared<EllipseBounds>(0., 0., ellipseR1min, ellipseR1max);
336 auto plane = Surface::makeShared<PlaneSurface>(
identity, ellipse);
337 planarSurfaces.push_back(plane);
341 helper.
write(name + tag);
342 helper.
write(cStream);
344 writeBoundingBox2D(ellipse->boundingBox(),
name);
347 name =
"Surfaces_PlaneSurfaceEllipseRing";
348 ellipse = std::make_shared<EllipseBounds>(ellipseR0min, ellipseR0max,
349 ellipseR1min, ellipseR1max);
350 plane = Surface::makeShared<PlaneSurface>(
identity, ellipse);
351 planarSurfaces.push_back(plane);
355 helper.
write(name + tag);
356 helper.
write(cStream);
358 writeBoundingBox2D(ellipse->boundingBox(),
name);
361 name =
"Surfaces_PlaneSurfaceEllipseRingSector";
362 ellipse = std::make_shared<EllipseBounds>(
363 ellipseR0min, ellipseR0max, ellipseR1min, ellipseR1max, halfPhiSector);
364 plane = Surface::makeShared<PlaneSurface>(
identity, ellipse);
365 planarSurfaces.push_back(plane);
369 helper.
write(name + tag);
370 helper.
write(cStream);
372 writeBoundingBox2D(ellipse->boundingBox(),
name);
375 name =
"Surfaces_PlaneSurfaceTriangleRegular";
376 std::vector<Vector2> tvertices = {{-3, -1.5}, {3, -1.5}, {0, 4.5}};
377 auto triangle = std::make_shared<ConvexPolygonBounds<3>>(tvertices);
378 plane = Surface::makeShared<PlaneSurface>(
identity, triangle);
379 planarSurfaces.push_back(plane);
383 helper.
write(name + tag);
384 helper.
write(cStream);
386 writeBoundingBox2D(triangle->boundingBox(),
name);
389 name =
"Surfaces_PlaneSurfaceTriangleGeneral";
390 tvertices = {{-1., 4.5}, {4, 6.5}, {3, 8.5}};
391 triangle = std::make_shared<ConvexPolygonBounds<3>>(tvertices);
392 plane = Surface::makeShared<PlaneSurface>(
identity, triangle);
393 planarSurfaces.push_back(plane);
397 helper.
write(name + tag);
398 helper.
write(cStream);
400 writeBoundingBox2D(triangle->boundingBox(),
name);
403 name =
"Surfaces_PlaneSurfaceConvexPolygonGeneral";
404 tvertices = {{-1., 4.5}, {4, 6.5}, {6, 8.5}, {0, 10.5}, {-3, 6.2}};
405 auto dynamicpolygon =
406 std::make_shared<ConvexPolygonBounds<PolygonDynamic>>(tvertices);
407 plane = Surface::makeShared<PlaneSurface>(
identity, dynamicpolygon);
408 planarSurfaces.push_back(plane);
412 helper.
write(name + tag);
413 helper.
write(cStream);
415 writeBoundingBox2D(dynamicpolygon->boundingBox(),
name);
418 name =
"Surfaces_PlaneSurfaceDiamond";
419 auto diamond = std::make_shared<DiamondBounds>(3., 6., 2., 2., 4.);
420 plane = Surface::makeShared<PlaneSurface>(
identity, diamond);
421 planarSurfaces.push_back(plane);
425 helper.
write(name + tag);
426 helper.
write(cStream);
428 writeBoundingBox2D(diamond->boundingBox(),
name);
431 name =
"Surfaces_PlaneSurfaceRectangle";
432 auto rectangle = std::make_shared<RectangleBounds>(2., 3.);
434 planarSurfaces.push_back(plane);
438 helper.
write(name + tag);
439 helper.
write(cStream);
444 name =
"Surfaces_PlaneSurfaceRectangleOffcentered";
446 std::make_shared<RectangleBounds>(
Vector2{1., 2.},
Vector2{15., 12.});
451 helper.
write(name + tag);
452 helper.
write(cStream);
457 name =
"Surfaces_PlaneSurfaceTrapezoid";
458 auto trapezoid = std::make_shared<TrapezoidBounds>(2., 5., 3.);
459 plane = Surface::makeShared<PlaneSurface>(
identity, trapezoid);
460 planarSurfaces.push_back(plane);
464 helper.
write(name + tag);
465 helper.
write(cStream);
467 writeBoundingBox2D(trapezoid->boundingBox(),
name);
470 std::vector<Transform3> ninePlanes = {
480 for (
size_t ip = 0; ip < planarSurfaces.size(); ++ip) {
482 ninePlanes[ip], sConfig);
485 helper.
write(cStream);
490 name =
"Surfaces_StrawSurface";
491 auto tube = std::make_shared<LineBounds>(2., 20.);
492 auto straw = Surface::makeShared<StrawSurface>(
identity, tube);
496 helper.
write(name + tag);
497 helper.
write(cStream);
500 return cStream.str();