24 const std::array<Acts::Vector3D, 8>& vertices) noexcept(
false)
25 : m_vertices(vertices) {
30 const std::array<double, GenericCuboidVolumeBounds::eSize>&
33 for (
size_t iv = 0; iv < 8; ++iv) {
42 constexpr std::array<size_t, 6> vtxs = {0, 4, 0, 1, 2, 1};
45 for (
size_t i = 1; i < 6; i++) {
47 if (std::signbit(dot) != ref) {
59 std::vector<std::shared_ptr<const Acts::Surface>>
62 std::vector<std::shared_ptr<const Acts::Surface>> surfaces;
67 for (
size_t i = 0; i < 8; i++) {
73 auto make_surface = [&](
const auto&
a,
const auto&
b,
const auto&
c,
81 if ((cog -
d).dot(normal) > 0) {
86 normal += Vector3D::Zero();
94 vol2srf = (Eigen::Quaternion<double>().setFromTwoVectors(
95 normal, Vector3D::UnitZ()));
106 std::vector<Vector2D> vertices({{a_l.x(), a_l.y()},
109 {d_l.x(), d_l.y()}});
111 auto polyBounds = std::make_shared<const ConvexPolygonBounds<4>>(vertices);
113 auto srfTrf = std::make_shared<Transform3D>(vol2srf.inverse());
114 if (transform !=
nullptr) {
115 *srfTrf = (*transform) * (*srfTrf);
118 auto srf = Surface::makeShared<PlaneSurface>(std::move(srfTrf), polyBounds);
120 surfaces.push_back(std::move(srf));
123 make_surface(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
124 make_surface(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
125 make_surface(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
126 make_surface(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
127 make_surface(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
128 make_surface(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);
134 std::ostream& sl)
const {
135 sl <<
"Acts::GenericCuboidVolumeBounds: vertices (x, y, z) =\n";
136 for (
size_t i = 0; i < 8; i++) {
140 sl <<
"[" << m_vertices[i].transpose() <<
"]";
150 for (
size_t i = 0; i < 8; i++) {
151 cog += m_vertices[i];
158 auto handle_face = [&](
const auto&
a,
const auto&
b,
const auto&
c,
164 if ((cog - a).dot(normal) < 0) {
170 normal += Vector3D::Zero();
174 throw(std::invalid_argument(
175 "GenericCuboidBounds: Four points do not lie on the same plane!"));
183 handle_face(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
184 handle_face(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
185 handle_face(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
186 handle_face(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
187 handle_face(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
188 handle_face(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);
192 std::vector<double> rvalues;
193 rvalues.reserve(eSize);
194 for (
size_t iv = 0; iv < 8; ++iv) {
195 for (
size_t ic = 0; ic < 3; ++ic) {
196 rvalues.push_back(m_vertices[iv][ic]);
204 const Volume* entity)
const {
208 if (trf !=
nullptr) {
212 vmin = transform * m_vertices[0];
213 vmax = transform * m_vertices[0];
215 for (
size_t i = 1; i < 8; i++) {
216 Vector3D vtx = transform * m_vertices[i];
217 vmin = vmin.cwiseMin(vtx);
218 vmax = vmax.cwiseMax(vtx);
221 return {entity, vmin - envelope, vmax + envelope};
226 auto draw_face = [&](
const auto&
a,
const auto&
b,
const auto&
c,
228 helper.
face(std::vector<Vector3D>(
229 {transform *
a, transform *
b, transform *
c, transform *
d}));
232 draw_face(m_vertices[0], m_vertices[1], m_vertices[2], m_vertices[3]);
233 draw_face(m_vertices[4], m_vertices[5], m_vertices[6], m_vertices[7]);
234 draw_face(m_vertices[0], m_vertices[3], m_vertices[7], m_vertices[4]);
235 draw_face(m_vertices[1], m_vertices[2], m_vertices[6], m_vertices[5]);
236 draw_face(m_vertices[2], m_vertices[3], m_vertices[7], m_vertices[6]);
237 draw_face(m_vertices[1], m_vertices[0], m_vertices[4], m_vertices[5]);