9 #include <boost/format.hpp>
10 #include <boost/test/data/test_case.hpp>
11 #include <boost/test/tools/output_test_stream.hpp>
12 #include <boost/test/unit_test.hpp>
33 namespace tt = boost::test_tools;
42 using SrfVec = std::vector<std::shared_ptr<const Surface>>;
50 double zbase = 0,
double r = 10) {
53 double phiStep = 2 *
M_PI /
n;
54 for (
size_t i = 0; i <
n; ++i) {
55 double z = zbase + ((i % 2 == 0) ? 1 : -1) * 0.2;
59 trans.rotate(Eigen::AngleAxisd(i * phiStep + shift,
Vector3D(0, 0, 1)));
62 auto bounds = std::make_shared<const RectangleBounds>(2, 1);
64 auto transptr = std::make_shared<const Transform3D>(trans);
65 std::shared_ptr<const Surface> srf =
66 Surface::makeShared<PlaneSurface>(transptr, bounds);
77 double incl =
M_PI / 9.,
double w = 2,
81 double phiStep = 2 *
M_PI /
n;
82 for (
int i = 0; i <
n; ++i) {
87 trans.rotate(Eigen::AngleAxisd(i * phiStep + shift,
Vector3D(0, 0, 1)));
89 trans.rotate(Eigen::AngleAxisd(incl,
Vector3D(0, 0, 1)));
90 trans.rotate(Eigen::AngleAxisd(
M_PI / 2.,
Vector3D(0, 1, 0)));
92 auto bounds = std::make_shared<const RectangleBounds>(
w,
h);
94 auto transptr = std::make_shared<const Transform3D>(trans);
95 std::shared_ptr<const Surface> srf =
96 Surface::makeShared<PlaneSurface>(transptr, bounds);
108 const Transform3D& pretrans = Transform3D::Identity(),
111 for (
size_t i = 0; i <
n; ++i) {
117 trans = trans * pretrans;
119 auto bounds = std::make_shared<const RectangleBounds>(2, 1.5);
121 auto transptr = std::make_shared<const Transform3D>(trans);
122 std::shared_ptr<const Surface> srf =
123 Surface::makeShared<PlaneSurface>(transptr, bounds);
134 double z0 = -(nZ - 1) * w;
137 for (
int i = 0; i < nZ; i++) {
138 double z = i * w * 2 +
z0;
141 res.insert(res.end(), ring.begin(), ring.end());
151 os << std::fixed << std::setprecision(4);
154 for (
const auto& srfx : surfaces) {
155 std::shared_ptr<const PlaneSurface> srf =
160 for (
const auto& vtxloc : bounds->vertices()) {
163 os <<
"v " << vtx.x() <<
" " << vtx.y() <<
" " << vtx.z() <<
"\n";
168 for (
size_t i = 1; i <= bounds->vertices().size(); ++i) {
169 os <<
" " << nVtx + i;
173 nVtx += bounds->vertices().size();
180 BOOST_AUTO_TEST_SUITE(Surfaces)
185 SrfVec brl = makeBarrel(30, 7, 2, 1);
189 detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Closed>
191 detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Bound>
194 double angleShift = 2 *
M_PI / 30. / 2.;
199 auto itransform = [angleShift,
R](
const Vector2D& loc) {
200 return Vector3D(R * std::cos(loc[0] - angleShift),
201 R * std::sin(loc[0] - angleShift), loc[1]);
207 std::make_tuple(std::move(phiAxis), std::move(zAxis)));
208 sl->
fill(tgContext, brlRaw);
214 for (
const auto& srf : brl) {
216 std::vector<const Surface*> binContent = sa.
at(ctr);
218 BOOST_CHECK_EQUAL(binContent.size(), 1
u);
219 BOOST_CHECK_EQUAL(srf.get(), binContent.at(0));
222 std::vector<const Surface*> neighbors =
224 BOOST_CHECK_EQUAL(neighbors.size(), 9
u);
229 std::make_tuple(std::move(phiAxis), std::move(zAxis)));
234 for (
const auto& srf : brl) {
236 std::vector<const Surface*> binContent = sa2.
at(ctr);
238 BOOST_CHECK_EQUAL(binContent.size(), 1
u);
239 BOOST_CHECK_EQUAL(srf.get(), binContent.at(0));
245 auto bounds = std::make_shared<const RectangleBounds>(
w,
h);
246 auto transptr = std::make_shared<const Transform3D>(Transform3D::Identity());
247 auto srf = Surface::makeShared<PlaneSurface>(transptr, bounds);
251 auto binContent = sa.at(
Vector3D(42, 42, 42));
252 BOOST_CHECK_EQUAL(binContent.size(), 1
u);
253 BOOST_CHECK_EQUAL(binContent.at(0), srf.get());
254 BOOST_CHECK_EQUAL(sa.surfaces().size(), 1
u);
255 BOOST_CHECK_EQUAL(sa.surfaces().at(0), srf.get());
258 BOOST_AUTO_TEST_SUITE_END()