EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PolyhedronSurfacesTests.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PolyhedronSurfacesTests.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2017-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
12 
13 // Helper
15 
16 // The class to test
17 #include "Acts/Geometry/Extent.hpp"
19 
20 // Cone surface
23 
24 // Cylinder surface
27 
28 // Disc Surface
33 
34 // Plane Surface
41 
42 // Straw Surface
45 #include "Acts/Utilities/Units.hpp"
47 
48 #include <fstream>
49 #include <tuple>
50 #include <utility>
51 #include <vector>
52 
53 namespace Acts {
54 
55 using namespace UnitLiterals;
56 
57 using IdentifiedPolyhedron = std::tuple<std::string, bool, Polyhedron>;
58 
59 namespace Test {
60 
61 // Create a test context
63 
64 std::vector<std::tuple<std::string, bool, unsigned int>> testModes = {
65  {"", false, 72}, {"Triangulate", true, 72}, {"Extremas", false, 1}};
66 
67 auto transform = std::make_shared<Transform3D>(Transform3D::Identity());
68 
69 BOOST_AUTO_TEST_SUITE(Surfaces)
70 
71 
72 BOOST_AUTO_TEST_CASE(ConeSurfacePolyhedrons) {
73  double hzpmin = 10_mm;
74  double hzpos = 35_mm;
75  double hzneg = -20_mm;
76  double alpha = 0.234;
77  double phiSector = 0.358;
78 
79  for (const auto& mode : testModes) {
80  unsigned int segments = std::get<unsigned int>(mode);
81  std::string modename = std::get<std::string>(mode);
82  bool modetrg = std::get<bool>(mode);
83 
85  auto cone = std::make_shared<ConeBounds>(alpha, 0_mm, hzpos);
86  auto oneCone = Surface::makeShared<ConeSurface>(transform, cone);
87  auto oneConePh = oneCone->polyhedronRepresentation(tgContext, segments);
88  size_t expectedFaces = segments < 4 ? 4 : segments;
89  BOOST_CHECK_EQUAL(oneConePh.faces.size(), expectedFaces);
90  BOOST_CHECK_EQUAL(oneConePh.vertices.size(), expectedFaces + 1);
91  // Check the extent in space
92  double r = hzpos * std::tan(alpha);
93  auto extent = oneConePh.extent();
94  CHECK_CLOSE_ABS(extent.ranges[binX].first, -r, 1e-6);
95  CHECK_CLOSE_ABS(extent.ranges[binX].second, r, 1e-6);
96  CHECK_CLOSE_ABS(extent.ranges[binY].first, -r, 1e-6);
97  CHECK_CLOSE_ABS(extent.ranges[binY].second, r, 1e-6);
98  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0_mm, 1e-6);
99  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
100  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0_mm, 1e-6);
101  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hzpos, 1e-6);
102 
104  auto conePiece = std::make_shared<ConeBounds>(alpha, hzpmin, hzpos);
105  auto oneConePiece = Surface::makeShared<ConeSurface>(transform, conePiece);
106  auto oneConePiecePh =
107  oneConePiece->polyhedronRepresentation(tgContext, segments);
108  expectedFaces = segments < 4 ? 4 : segments;
109  // Check the extent in space
110  double rmin = hzpmin * std::tan(alpha);
111  extent = oneConePiecePh.extent();
112  CHECK_CLOSE_ABS(extent.ranges[binX].first, -r, 1e-6);
113  CHECK_CLOSE_ABS(extent.ranges[binX].second, r, 1e-6);
114  CHECK_CLOSE_ABS(extent.ranges[binY].first, -r, 1e-6);
115  CHECK_CLOSE_ABS(extent.ranges[binY].second, r, 1e-6);
116  CHECK_CLOSE_ABS(extent.ranges[binR].first, rmin, 1e-6);
117  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
118  CHECK_CLOSE_ABS(extent.ranges[binZ].first, hzpmin, 1e-6);
119  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hzpos, 1e-6);
120 
121  // The full cone on both sides
122  auto coneBoth = std::make_shared<ConeBounds>(alpha, hzneg, hzpos);
123  auto twoCones = Surface::makeShared<ConeSurface>(transform, coneBoth);
124  auto twoConesPh = twoCones->polyhedronRepresentation(tgContext, segments);
125  expectedFaces = segments < 4 ? 8 : 2 * segments;
126  BOOST_CHECK_EQUAL(twoConesPh.faces.size(), expectedFaces);
127  BOOST_CHECK_EQUAL(twoConesPh.vertices.size(), expectedFaces + 1);
128  extent = twoConesPh.extent();
129  CHECK_CLOSE_ABS(extent.ranges[binX].first, -r, 1e-6);
130  CHECK_CLOSE_ABS(extent.ranges[binX].second, r, 1e-6);
131  CHECK_CLOSE_ABS(extent.ranges[binY].first, -r, 1e-6);
132  CHECK_CLOSE_ABS(extent.ranges[binY].second, r, 1e-6);
133  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0_mm, 1e-6);
134  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
135  CHECK_CLOSE_ABS(extent.ranges[binZ].first, hzneg, 1e-6);
136  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hzpos, 1e-6);
137 
138  // A centered sectoral cone on both sides
139  auto sectoralBoth =
140  std::make_shared<ConeBounds>(alpha, hzneg, hzpos, phiSector, 0.);
141  auto sectoralCones =
142  Surface::makeShared<ConeSurface>(transform, sectoralBoth);
143  auto sectoralConesPh =
144  sectoralCones->polyhedronRepresentation(tgContext, segments);
145  extent = sectoralConesPh.extent();
146  CHECK_CLOSE_ABS(extent.ranges[binX].second, r, 1e-6);
147  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0_mm, 1e-6);
148  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
149  CHECK_CLOSE_ABS(extent.ranges[binZ].first, hzneg, 1e-6);
150  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hzpos, 1e-6);
151  }
152 }
153 
155 BOOST_AUTO_TEST_CASE(CylinderSurfacePolyhedrons) {
156  double r = 25_mm;
157  double hZ = 35_mm;
158 
159  double phiSector = 0.458;
160  double averagePhi = -1.345;
161 
162  for (const auto& mode : testModes) {
163  unsigned int segments = std::get<unsigned int>(mode);
164  std::string modename = std::get<std::string>(mode);
165  bool modetrg = std::get<bool>(mode);
166 
167  size_t expectedFaces = segments < 4 ? 4 : segments;
168  size_t expectedVertices = segments < 4 ? 8 : 2 * segments;
169 
171  auto cylinder = std::make_shared<CylinderBounds>(r, hZ);
172  auto fullCylinder =
173  Surface::makeShared<CylinderSurface>(transform, cylinder);
174  auto fullCylinderPh =
175  fullCylinder->polyhedronRepresentation(tgContext, segments);
176 
177  BOOST_CHECK_EQUAL(fullCylinderPh.faces.size(), expectedFaces);
178  BOOST_CHECK_EQUAL(fullCylinderPh.vertices.size(), expectedVertices);
179  // Check the extent in space
180  auto extent = fullCylinderPh.extent();
181  CHECK_CLOSE_ABS(extent.ranges[binX].first, -r, 1e-6);
182  CHECK_CLOSE_ABS(extent.ranges[binX].second, r, 1e-6);
183  CHECK_CLOSE_ABS(extent.ranges[binY].first, -r, 1e-6);
184  CHECK_CLOSE_ABS(extent.ranges[binY].second, r, 1e-6);
185  CHECK_CLOSE_ABS(extent.ranges[binR].first, r, 1e-6);
186  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
187  CHECK_CLOSE_ABS(extent.ranges[binZ].first, -hZ, 1e-6);
188  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hZ, 1e-6);
189 
191  auto sectorCentered = std::make_shared<CylinderBounds>(r, phiSector, hZ);
192  auto centerSectoredCylinder =
193  Surface::makeShared<CylinderSurface>(transform, sectorCentered);
194  auto centerSectoredCylinderPh =
195  centerSectoredCylinder->polyhedronRepresentation(tgContext, segments);
196 
197  // Check the extent in space
198  extent = centerSectoredCylinderPh.extent();
199  CHECK_CLOSE_ABS(extent.ranges[binX].first, r * std::cos(phiSector), 1e-6);
200  CHECK_CLOSE_ABS(extent.ranges[binX].second, r, 1e-6);
201  CHECK_CLOSE_ABS(extent.ranges[binY].first, -r * std::sin(phiSector), 1e-6);
202  CHECK_CLOSE_ABS(extent.ranges[binY].second, r * std::sin(phiSector), 1e-6);
203  CHECK_CLOSE_ABS(extent.ranges[binR].first, r, 1e-6);
204  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
205  CHECK_CLOSE_ABS(extent.ranges[binZ].first, -hZ, 1e-6);
206  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hZ, 1e-6);
207 
209  auto sectorShifted =
210  std::make_shared<CylinderBounds>(r, averagePhi, phiSector, hZ);
211  auto shiftedSectoredCylinder =
212  Surface::makeShared<CylinderSurface>(transform, sectorShifted);
213  auto shiftedSectoredCylinderPh =
214  shiftedSectoredCylinder->polyhedronRepresentation(tgContext, segments);
215 
216  // Check the extent in space
217  extent = shiftedSectoredCylinderPh.extent();
218  CHECK_CLOSE_ABS(extent.ranges[binR].first, r, 1e-6);
219  CHECK_CLOSE_ABS(extent.ranges[binR].second, r, 1e-6);
220  CHECK_CLOSE_ABS(extent.ranges[binZ].first, -hZ, 1e-6);
221  CHECK_CLOSE_ABS(extent.ranges[binZ].second, hZ, 1e-6);
222  }
223 }
224 
226 BOOST_AUTO_TEST_CASE(DiscSurfacePolyhedrons) {
227  double innerR = 10_mm;
228  double outerR = 25_mm;
229 
230  double phiSector = 0.345;
231  double averagePhi = -1.0;
232 
233  double cphi = std::cos(phiSector);
234  double sphi = std::sin(phiSector);
235 
236  std::pair<Vector3D, Vector3D> lineA = {
237  Vector3D(0., 0., 0.), Vector3D(outerR * cphi, outerR * sphi, 0.)};
238  std::pair<Vector3D, Vector3D> lineB = {
239  Vector3D(0., 0., 0.), Vector3D(outerR * cphi, -outerR * sphi, 0.)};
240 
241  double minPhi = averagePhi - phiSector;
242  double maxPhi = averagePhi + phiSector;
243  lineA = {Vector3D(0., 0., 0.),
244  Vector3D(outerR * std::cos(minPhi), outerR * std::sin(minPhi), 0.)};
245  lineB = {Vector3D(0., 0., 0.),
246  Vector3D(outerR * std::cos(maxPhi), outerR * std::sin(maxPhi), 0.)};
247 
248  for (const auto& mode : testModes) {
249  unsigned int segments = std::get<unsigned int>(mode);
250  std::string modename = std::get<std::string>(mode);
251  bool modetrg = std::get<bool>(mode);
252 
253  // Full disc
254  auto disc = std::make_shared<RadialBounds>(0_mm, outerR);
255  auto fullDisc = Surface::makeShared<DiscSurface>(transform, disc);
256  auto fullDiscPh = fullDisc->polyhedronRepresentation(tgContext, segments);
257 
258  unsigned int expectedVertices = segments > 4 ? segments : 4;
259  unsigned int expectedFaces = 1;
260 
261  BOOST_CHECK_EQUAL(fullDiscPh.faces.size(), expectedFaces);
262  BOOST_CHECK_EQUAL(fullDiscPh.vertices.size(), expectedVertices);
263 
264  auto extent = fullDiscPh.extent();
265  CHECK_CLOSE_ABS(extent.ranges[binX].first, -outerR, 1e-6);
266  CHECK_CLOSE_ABS(extent.ranges[binX].second, outerR, 1e-6);
267  CHECK_CLOSE_ABS(extent.ranges[binY].first, -outerR, 1e-6);
268  CHECK_CLOSE_ABS(extent.ranges[binY].second, outerR, 1e-6);
269  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0., 1e-6);
270  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
271  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
272  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
273 
274  // Ring disc
275  auto radial = std::make_shared<RadialBounds>(innerR, outerR);
276  auto radialDisc = Surface::makeShared<DiscSurface>(transform, radial);
277  auto radialPh = radialDisc->polyhedronRepresentation(tgContext, segments);
278  extent = radialPh.extent();
279  CHECK_CLOSE_ABS(extent.ranges[binX].first, -outerR, 1e-6);
280  CHECK_CLOSE_ABS(extent.ranges[binX].second, outerR, 1e-6);
281  CHECK_CLOSE_ABS(extent.ranges[binY].first, -outerR, 1e-6);
282  CHECK_CLOSE_ABS(extent.ranges[binY].second, outerR, 1e-6);
283  CHECK_CLOSE_ABS(extent.ranges[binR].first, innerR, 1e-6);
284  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
285  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
286  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
287 
288  // Sectoral disc - around 0.
289  auto sector = std::make_shared<RadialBounds>(0., outerR, phiSector);
290  auto sectorDisc = Surface::makeShared<DiscSurface>(transform, sector);
291  auto sectorPh = sectorDisc->polyhedronRepresentation(tgContext, segments);
292  extent = sectorPh.extent();
293  CHECK_CLOSE_ABS(extent.ranges[binX].first, 0., 1e-6);
294  CHECK_CLOSE_ABS(extent.ranges[binX].second, outerR, 1e-6);
295  CHECK_CLOSE_ABS(extent.ranges[binY].first, -outerR * std::sin(phiSector),
296  1e-6);
297  CHECK_CLOSE_ABS(extent.ranges[binY].second, outerR * std::sin(phiSector),
298  1e-6);
299  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0., 1e-6);
300  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
301  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
302  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
303 
304  // Sectoral ring - around 0.
305  auto sectorRing = std::make_shared<RadialBounds>(innerR, outerR, phiSector);
306  auto sectorRingDisc =
307  Surface::makeShared<DiscSurface>(transform, sectorRing);
308  auto sectorRingDiscPh =
309  sectorRingDisc->polyhedronRepresentation(tgContext, segments);
310  extent = sectorRingDiscPh.extent();
311  CHECK_CLOSE_ABS(extent.ranges[binX].first, innerR * std::cos(phiSector),
312  1e-6);
313  CHECK_CLOSE_ABS(extent.ranges[binX].second, outerR, 1e-6);
314  CHECK_CLOSE_ABS(extent.ranges[binY].first, -outerR * std::sin(phiSector),
315  1e-6);
316  CHECK_CLOSE_ABS(extent.ranges[binY].second, outerR * std::sin(phiSector),
317  1e-6);
318  CHECK_CLOSE_ABS(extent.ranges[binR].first, innerR, 1e-6);
319  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
320  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
321  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
322 
323  // Sectoral disc - shifted
324  auto sectorRingShifted =
325  std::make_shared<RadialBounds>(innerR, outerR, averagePhi, phiSector);
326  auto sectorRingDiscShifted =
327  Surface::makeShared<DiscSurface>(transform, sectorRingShifted);
328  auto sectorRingDiscShiftedPh =
329  sectorRingDiscShifted->polyhedronRepresentation(tgContext, segments);
330  extent = sectorRingDiscShiftedPh.extent();
331  CHECK_CLOSE_ABS(extent.ranges[binR].first, innerR, 1e-6);
332  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
333  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
334  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
335 
336  // Trapezoid for a disc
337  double halfXmin = 10_mm;
338  double halfXmax = 20_mm;
339  auto trapezoidDisc = std::make_shared<DiscTrapezoidBounds>(
340  halfXmin, halfXmax, innerR, outerR, 0.);
341  auto trapezoidDiscSf =
342  Surface::makeShared<DiscSurface>(transform, trapezoidDisc);
343  auto trapezoidDiscSfPh =
344  trapezoidDiscSf->polyhedronRepresentation(tgContext, segments);
345  extent = trapezoidDiscSfPh.extent();
346  CHECK_CLOSE_ABS(extent.ranges[binR].first, innerR, 1e-6);
347  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
348  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
349  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
350 
351  auto trapezoidDiscShifted = std::make_shared<DiscTrapezoidBounds>(
352  halfXmin, halfXmax, innerR, outerR, averagePhi);
353  auto trapezoidDiscShiftedSf =
354  Surface::makeShared<DiscSurface>(transform, trapezoidDiscShifted);
355  auto trapezoidDiscShiftedSfPh =
356  trapezoidDiscShiftedSf->polyhedronRepresentation(tgContext, segments);
357  extent = trapezoidDiscShiftedSfPh.extent();
358  CHECK_CLOSE_ABS(extent.ranges[binR].first, innerR, 1e-6);
359  CHECK_CLOSE_ABS(extent.ranges[binR].second, outerR, 1e-6);
360  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
361  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
362 
363  double minRadius = 7.;
364  double maxRadius = 12.;
365  double minPhiA = 0.75;
366  double maxPhiA = 1.4;
367 
368  Vector2D offset(-2., 2.);
369 
370  auto annulus = std::make_shared<AnnulusBounds>(minRadius, maxRadius,
371  minPhiA, maxPhiA, offset);
372  auto annulusDisc = Surface::makeShared<DiscSurface>(transform, annulus);
373  auto annulusDiscPh =
374  annulusDisc->polyhedronRepresentation(tgContext, segments);
375  }
376 }
377 
379 BOOST_AUTO_TEST_CASE(PlaneSurfacePolyhedrons) {
380  double rhX = 10_mm;
381  double rhY = 25_mm;
382  double shiftY = 50_mm;
383  auto rectangular = std::make_shared<RectangleBounds>(rhX, rhY);
384 
385  // Special test for shifted plane to check rMin/rMax
386  Vector3D shift(0., shiftY, 0.);
387  auto shiftedTransform =
388  std::make_shared<Transform3D>(Transform3D::Identity());
389  shiftedTransform->pretranslate(shift);
390  auto shiftedPlane =
391  Surface::makeShared<PlaneSurface>(shiftedTransform, rectangular);
392  auto shiftedPh = shiftedPlane->polyhedronRepresentation(tgContext, 1);
393  auto shiftedExtent = shiftedPh.extent();
394  // Let's check the extent
395  CHECK_CLOSE_ABS(shiftedExtent.ranges[binX].first, -rhX, 1e-6);
396  CHECK_CLOSE_ABS(shiftedExtent.ranges[binX].second, rhX, 1e-6);
397  CHECK_CLOSE_ABS(shiftedExtent.ranges[binY].first, -rhY + shiftY, 1e-6);
398  CHECK_CLOSE_ABS(shiftedExtent.ranges[binY].second, rhY + shiftY, 1e-6);
399 
400  for (const auto& mode : testModes) {
401  unsigned int segments = std::get<unsigned int>(mode);
402  std::string modename = std::get<std::string>(mode);
403  bool modetrg = std::get<bool>(mode);
404 
406  auto rectangularPlane =
407  Surface::makeShared<PlaneSurface>(transform, rectangular);
408  auto rectangularPh =
409  rectangularPlane->polyhedronRepresentation(tgContext, segments);
410  auto extent = rectangularPh.extent();
411  CHECK_CLOSE_ABS(extent.ranges[binX].first, -rhX, 1e-6);
412  CHECK_CLOSE_ABS(extent.ranges[binX].second, rhX, 1e-6);
413  CHECK_CLOSE_ABS(extent.ranges[binY].first, -rhY, 1e-6);
414  CHECK_CLOSE_ABS(extent.ranges[binY].second, rhY, 1e-6);
415  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0., 1e-6);
416  CHECK_CLOSE_ABS(extent.ranges[binR].second,
417  std::sqrt(rhX * rhX + rhY * rhY), 1e-6);
418  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
419  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
420  BOOST_CHECK(rectangularPh.vertices.size() == 4);
421  BOOST_CHECK(rectangularPh.faces.size() == 1);
422  std::vector<size_t> expectedRect = {0, 1, 2, 3};
423  BOOST_CHECK(rectangularPh.faces[0] == expectedRect);
424 
426  double thX1 = 10_mm;
427  double thX2 = 25_mm;
428  double thY = 35_mm;
429 
430  auto trapezoid = std::make_shared<TrapezoidBounds>(thX1, thX2, thY);
431  auto trapezoidalPlane =
432  Surface::makeShared<PlaneSurface>(transform, trapezoid);
433  auto trapezoidalPh =
434  trapezoidalPlane->polyhedronRepresentation(tgContext, segments);
435  extent = trapezoidalPh.extent();
436 
437  double thX = std::max(thX1, thX2);
438  CHECK_CLOSE_ABS(extent.ranges[binX].first, -thX, 1e-6);
439  CHECK_CLOSE_ABS(extent.ranges[binX].second, thX, 1e-6);
440  CHECK_CLOSE_ABS(extent.ranges[binY].first, -thY, 1e-6);
441  CHECK_CLOSE_ABS(extent.ranges[binY].second, thY, 1e-6);
442  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0., 1e-6);
443  CHECK_CLOSE_ABS(extent.ranges[binR].second,
444  std::sqrt(thX * thX + thY * thY), 1e-6);
445  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
446  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
447  BOOST_CHECK(trapezoidalPh.vertices.size() == 4);
448  BOOST_CHECK(trapezoidalPh.faces.size() == 1);
449  std::vector<size_t> expectedTra = {0, 1, 2, 3};
450  BOOST_CHECK(trapezoidalPh.faces[0] == expectedTra);
451 
453  double rMaxX = 30_mm;
454  double rMaxY = 40_mm;
455  auto ellipse = std::make_shared<EllipseBounds>(0., 0., rMaxX, rMaxY);
456  auto ellipsoidPlane = Surface::makeShared<PlaneSurface>(transform, ellipse);
457  auto ellispoidPh =
458  ellipsoidPlane->polyhedronRepresentation(tgContext, segments);
459  extent = ellispoidPh.extent();
460  CHECK_CLOSE_ABS(extent.ranges[binX].first, -rMaxX, 1e-6);
461  CHECK_CLOSE_ABS(extent.ranges[binX].second, rMaxX, 1e-6);
462  CHECK_CLOSE_ABS(extent.ranges[binY].first, -rMaxY, 1e-6);
463  CHECK_CLOSE_ABS(extent.ranges[binY].first, -rMaxY, 1e-6);
464  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0., 1e-6);
465  CHECK_CLOSE_ABS(extent.ranges[binR].second, rMaxY, 1e-6);
466  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
467  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
468 
469  double rMinX = 10_mm;
470  double rMinY = 20_mm;
471  auto ellipseRing =
472  std::make_shared<EllipseBounds>(rMinX, rMaxX, rMinY, rMaxY);
473  auto ellipsoidRingPlane =
474  Surface::makeShared<PlaneSurface>(transform, ellipseRing);
475  auto ellispoidRingPh =
476  ellipsoidRingPlane->polyhedronRepresentation(tgContext, segments);
477 
478  extent = ellispoidPh.extent();
479  CHECK_CLOSE_ABS(extent.ranges[binX].first, -rMaxX, 1e-6);
480  CHECK_CLOSE_ABS(extent.ranges[binX].second, rMaxX, 1e-6);
481  CHECK_CLOSE_ABS(extent.ranges[binY].first, -rMaxY, 1e-6);
482  CHECK_CLOSE_ABS(extent.ranges[binY].first, rMinX, 1e-6);
483  CHECK_CLOSE_ABS(extent.ranges[binR].second, rMaxY, 1e-6);
484  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
485  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
486 
488  std::vector<Vector2D> vtxs = {
489  Vector2D(-40_mm, -10_mm), Vector2D(-10_mm, -30_mm),
490  Vector2D(30_mm, -20_mm), Vector2D(10_mm, 20_mm),
491  Vector2D(-20_mm, 50_mm), Vector2D(-30_mm, 30_mm)};
492 
493  auto sextagon = std::make_shared<ConvexPolygonBounds<6>>(vtxs);
494  auto sextagonPlane = Surface::makeShared<PlaneSurface>(transform, sextagon);
495  auto sextagonPlanePh =
496  sextagonPlane->polyhedronRepresentation(tgContext, segments);
497 
499  double hMinX = 10_mm;
500  double hMedX = 20_mm;
501  double hMaxX = 15_mm;
502  double hMinY = 40_mm;
503  double hMaxY = 50_mm;
504  auto diamond =
505  std::make_shared<DiamondBounds>(hMinX, hMedX, hMaxX, hMinY, hMaxY);
506  auto diamondPlane = Surface::makeShared<PlaneSurface>(transform, diamond);
507  auto diamondPh =
508  diamondPlane->polyhedronRepresentation(tgContext, segments);
509  BOOST_CHECK(diamondPh.vertices.size() == 6);
510  BOOST_CHECK(diamondPh.faces.size() == 1);
511  extent = diamondPh.extent();
512  CHECK_CLOSE_ABS(extent.ranges[binX].first, -hMedX, 1e-6);
513  CHECK_CLOSE_ABS(extent.ranges[binX].second, hMedX, 1e-6);
514  CHECK_CLOSE_ABS(extent.ranges[binY].first, -hMinY, 1e-6);
515  CHECK_CLOSE_ABS(extent.ranges[binY].second, hMaxY, 1e-6);
516  CHECK_CLOSE_ABS(extent.ranges[binR].first, 0., 1e-6);
517  CHECK_CLOSE_ABS(extent.ranges[binR].second,
518  std::sqrt(hMaxX * hMaxX + hMaxY * hMaxY), 1e-6);
519  CHECK_CLOSE_ABS(extent.ranges[binZ].first, 0., 1e-6);
520  CHECK_CLOSE_ABS(extent.ranges[binZ].second, 0., 1e-6);
521  }
522 }
523 
524 BOOST_AUTO_TEST_SUITE_END()
525 
526 } // namespace Test
527 
528 } // namespace Acts