9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
28 #include <boost/format.hpp>
34 namespace tt = boost::test_tools;
43 using SrfVec = std::vector<std::shared_ptr<const Surface>>;
51 double zbase = 0,
double r = 10) {
54 double phiStep = 2 *
M_PI /
n;
55 for (
size_t i = 0; i <
n; ++i) {
56 double z = zbase + ((i % 2 == 0) ? 1 : -1) * 0.2;
60 trans.rotate(Eigen::AngleAxisd(i * phiStep + shift,
Vector3D(0, 0, 1)));
63 auto bounds = std::make_shared<const RectangleBounds>(2, 1);
64 std::shared_ptr<const Surface> srf =
65 Surface::makeShared<PlaneSurface>(trans, bounds);
76 double incl =
M_PI / 9.,
double w = 2,
80 double phiStep = 2 *
M_PI /
n;
81 for (
int i = 0; i <
n; ++i) {
86 trans.rotate(Eigen::AngleAxisd(i * phiStep + shift,
Vector3D(0, 0, 1)));
88 trans.rotate(Eigen::AngleAxisd(incl,
Vector3D(0, 0, 1)));
89 trans.rotate(Eigen::AngleAxisd(
M_PI / 2.,
Vector3D(0, 1, 0)));
91 auto bounds = std::make_shared<const RectangleBounds>(w,
h);
92 std::shared_ptr<const Surface> srf =
93 Surface::makeShared<PlaneSurface>(trans, bounds);
105 const Transform3D& pretrans = Transform3D::Identity(),
108 for (
size_t i = 0; i <
n; ++i) {
114 trans = trans * pretrans;
116 auto bounds = std::make_shared<const RectangleBounds>(2, 1.5);
118 std::shared_ptr<const Surface> srf =
119 Surface::makeShared<PlaneSurface>(trans, bounds);
130 double z0 = -(nZ - 1) * w;
133 for (
int i = 0; i < nZ; i++) {
134 double z = i * w * 2 + z0;
137 res.insert(res.end(), ring.begin(), ring.end());
147 os << std::fixed << std::setprecision(4);
150 for (
const auto& srfx : surfaces) {
151 std::shared_ptr<const PlaneSurface> srf =
156 for (
const auto& vtxloc : bounds->vertices()) {
159 os <<
"v " << vtx.x() <<
" " << vtx.y() <<
" " << vtx.z() <<
"\n";
164 for (
size_t i = 1; i <= bounds->vertices().size(); ++i) {
165 os <<
" " << nVtx + i;
169 nVtx += bounds->vertices().size();
176 BOOST_AUTO_TEST_SUITE(Surfaces)
181 SrfVec brl = makeBarrel(30, 7, 2, 1);
185 detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Closed>
187 detail::Axis<detail::AxisType::Equidistant, detail::AxisBoundaryType::Bound>
190 double angleShift = 2 *
M_PI / 30. / 2.;
195 auto itransform = [angleShift,
R](
const Vector2D& loc) {
197 R * std::sin(loc[0] - angleShift), loc[1]);
200 auto sl = std::make_unique<
203 std::make_tuple(std::move(phiAxis), std::move(zAxis)));
204 sl->
fill(tgContext, brlRaw);
210 for (
const auto& srf : brl) {
212 std::vector<const Surface*> binContent = sa.
at(ctr);
214 BOOST_CHECK_EQUAL(binContent.size(), 1
u);
215 BOOST_CHECK_EQUAL(srf.get(), binContent.at(0));
218 std::vector<const Surface*> neighbors =
220 BOOST_CHECK_EQUAL(neighbors.size(), 9
u);
222 auto sl2 = std::make_unique<
225 std::make_tuple(std::move(phiAxis), std::move(zAxis)));
230 for (
const auto& srf : brl) {
232 std::vector<const Surface*> binContent = sa2.
at(ctr);
234 BOOST_CHECK_EQUAL(binContent.size(), 1
u);
235 BOOST_CHECK_EQUAL(srf.get(), binContent.at(0));
241 auto bounds = std::make_shared<const RectangleBounds>(w,
h);
242 auto srf = Surface::makeShared<PlaneSurface>(Transform3D::Identity(), bounds);
246 auto binContent = sa.at(
Vector3D(42, 42, 42));
247 BOOST_CHECK_EQUAL(binContent.size(), 1
u);
248 BOOST_CHECK_EQUAL(binContent.at(0), srf.get());
249 BOOST_CHECK_EQUAL(sa.surfaces().size(), 1
u);
250 BOOST_CHECK_EQUAL(sa.surfaces().at(0), srf.get());
253 BOOST_AUTO_TEST_SUITE_END()