27 #include <type_traits>
31 const std::array<Acts::Vector3, 8>&
vertices) noexcept(
false)
37 const std::array<double, GenericCuboidVolumeBounds::BoundValues::eSize>&
40 for (
size_t iv = 0; iv < 8; ++iv) {
49 constexpr std::array<size_t, 6> vtxs = {0, 4, 0, 1, 2, 1};
52 for (
size_t i = 1;
i < 6;
i++) {
54 if (std::signbit(dot) !=
ref) {
56 if (std::abs(dot) > tol) {
73 for (
size_t i = 0;
i < 8;
i++) {
79 auto make_surface = [&](
const auto&
a,
const auto&
b,
const auto&
c,
80 const auto& d) ->
void {
85 Vector3 normal = ab.cross(ac).normalized();
97 vol2srf = (Eigen::Quaternion<Transform3::Scalar>().setFromTwoVectors(
98 normal, Vector3::UnitZ()));
109 std::vector<Vector2>
vertices({{a_l.x(), a_l.y()},
112 {d_l.x(), d_l.y()}});
114 auto polyBounds = std::make_shared<const ConvexPolygonBounds<4>>(
vertices);
115 auto srfTrf = transform * vol2srf.inverse();
116 auto srf = Surface::makeShared<PlaneSurface>(srfTrf, polyBounds);
121 make_surface(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
122 make_surface(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
123 make_surface(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
124 make_surface(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
125 make_surface(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
126 make_surface(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);
132 std::ostream& sl)
const {
133 sl <<
"Acts::GenericCuboidVolumeBounds: vertices (x, y, z) =\n";
134 for (
size_t i = 0;
i < 8;
i++) {
138 sl <<
"[" << m_vertices[
i].transpose() <<
"]";
148 for (
size_t i = 0;
i < 8;
i++) {
149 cog += m_vertices[
i];
156 auto handle_face = [&](
const auto&
a,
const auto&
b,
const auto&
c,
160 Vector3 normal = ab.cross(ac).normalized();
162 if ((cog - a).dot(normal) < 0) {
168 normal += Vector3::Zero();
171 if (std::abs((a - d).dot(normal)) > 1
e-6) {
172 throw(std::invalid_argument(
173 "GenericCuboidBounds: Four points do not lie on the same plane!"));
176 m_normals[
idx] = normal;
181 handle_face(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
182 handle_face(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
183 handle_face(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
184 handle_face(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
185 handle_face(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
186 handle_face(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);
190 std::vector<double> rvalues;
191 rvalues.reserve(BoundValues::eSize);
192 for (
size_t iv = 0; iv < 8; ++iv) {
193 for (
size_t ic = 0; ic < 3; ++ic) {
194 rvalues.push_back(m_vertices[iv][ic]);
202 const Volume* entity)
const {
206 if (trf !=
nullptr) {
210 vmin = transform * m_vertices[0];
211 vmax = transform * m_vertices[0];
213 for (
size_t i = 1;
i < 8;
i++) {
214 Vector3 vtx = transform * m_vertices[
i];
215 vmin = vmin.cwiseMin(vtx);
216 vmax = vmax.cwiseMax(vtx);
219 return {entity, vmin - envelope, vmax + envelope};
224 auto draw_face = [&](
const auto&
a,
const auto&
b,
const auto&
c,
226 helper.
face(std::vector<Vector3>(
227 {transform *
a, transform *
b, transform *
c, transform * d}));
230 draw_face(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
231 draw_face(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
232 draw_face(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
233 draw_face(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
234 draw_face(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
235 draw_face(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);