23 const std::array<Acts::Vector3D, 8>& vertices) noexcept(
false)
24 : m_vertices(vertices) {
29 const std::array<double, GenericCuboidVolumeBounds::eSize>&
32 for (
size_t iv = 0; iv < 8; ++iv) {
41 constexpr std::array<size_t, 6> vtxs = {0, 4, 0, 1, 2, 1};
44 for (
size_t i = 1; i < 6; i++) {
46 if (std::signbit(dot) != ref) {
65 for (
size_t i = 0; i < 8; i++) {
71 auto make_surface = [&](
const auto& a,
const auto& b,
const auto&
c,
72 const auto&
d) ->
void {
76 const Vector3D ab = b - a, ac = c - a;
77 Vector3D normal = ab.cross(ac).normalized();
85 vol2srf = (Eigen::Quaternion<double>().setFromTwoVectors(
86 normal, Vector3D::UnitZ()));
97 std::vector<Vector2D> vertices({{a_l.x(), a_l.y()},
100 {d_l.x(), d_l.y()}});
102 auto polyBounds = std::make_shared<const ConvexPolygonBounds<4>>(vertices);
103 auto srfTrf = transform * vol2srf.inverse();
104 auto srf = Surface::makeShared<PlaneSurface>(srfTrf, polyBounds);
109 make_surface(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
110 make_surface(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
111 make_surface(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
112 make_surface(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
113 make_surface(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
114 make_surface(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);
120 std::ostream& sl)
const {
121 sl <<
"Acts::GenericCuboidVolumeBounds: vertices (x, y, z) =\n";
122 for (
size_t i = 0; i < 8; i++) {
126 sl <<
"[" << m_vertices[i].transpose() <<
"]";
136 for (
size_t i = 0; i < 8; i++) {
137 cog += m_vertices[i];
144 auto handle_face = [&](
const auto& a,
const auto& b,
const auto&
c,
147 const Vector3D ab = b - a, ac = c - a;
148 Vector3D normal = ab.cross(ac).normalized();
150 if ((cog - a).dot(normal) < 0) {
156 normal += Vector3D::Zero();
160 throw(std::invalid_argument(
161 "GenericCuboidBounds: Four points do not lie on the same plane!"));
164 m_normals[idx] = normal;
169 handle_face(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
170 handle_face(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
171 handle_face(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
172 handle_face(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
173 handle_face(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
174 handle_face(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);
178 std::vector<double> rvalues;
179 rvalues.reserve(eSize);
180 for (
size_t iv = 0; iv < 8; ++iv) {
181 for (
size_t ic = 0; ic < 3; ++ic) {
182 rvalues.push_back(m_vertices[iv][ic]);
190 const Volume* entity)
const {
194 if (trf !=
nullptr) {
198 vmin = transform * m_vertices[0];
199 vmax = transform * m_vertices[0];
201 for (
size_t i = 1; i < 8; i++) {
203 vmin = vmin.cwiseMin(vtx);
204 vmax = vmax.cwiseMax(vtx);
207 return {entity, vmin - envelope, vmax + envelope};
212 auto draw_face = [&](
const auto& a,
const auto& b,
const auto&
c,
214 helper.
face(std::vector<Vector3D>(
215 {transform * a, transform * b, transform *
c, transform *
d}));
218 draw_face(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
219 draw_face(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
220 draw_face(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
221 draw_face(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
222 draw_face(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
223 draw_face(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);