26 #include "GeoModelKernel/GeoShapeShift.h" 
   27 #include "GeoModelKernel/GeoShapeUnion.h" 
   28 #include "GeoModelKernel/GeoTrd.h" 
   34         return std::make_unique<Amg::Transform3D>(
trf);
 
   37 std::pair<bool, std::unique_ptr<Trk::Volume>>
 
   52         if (std::abs((
a0.cross(a1).unit()).dot(b0.cross(b1).unit())) < 1.e-3) {
 
   53             if (std::abs((
a0.cross(a1).unit()).dot(b1)) < 1.e-3)
 
   55             else if (std::abs((
a0.cross(a1).unit()).dot(b0)) < 1.e-3)
 
   61         if (std::abs(std::abs((
a0.cross(a1).unit()).dot(b0.cross(b1).unit())) -
 
   63             return std::make_pair(
false, 
nullptr);
 
   91             return std::make_pair(
true, 
nullptr);
 
   95         std::unique_ptr<Trk::Volume> overlap;
 
   97             auto spb = std::make_shared<Trk::SimplePolygonBrepVolumeBounds>(
result.xyVertices, 0.5 * (
result.maxZ - 
result.minZ));
 
  100             overlap = std::make_unique<Trk::Volume>(
makeTransform(transf), spb);
 
  102         return std::make_pair(
true, std::move(overlap));
 
  105     return std::make_pair(
false, 
nullptr);
 
  113         pgA.
xyVertices.emplace_back(vtx.x(), vtx.y());
 
  116         pgB.
xyVertices.emplace_back(vtx.x(), vtx.y());
 
  119     for (
const std::pair<double, double>& vtx : pgA.
xyVertices) {
 
  122     for (
const std::pair<double, double>& vtx : pgB.
xyVertices) {
 
  126     for (
int ia = 0; ia < pgA.
nVtx; ia++) {
 
  127         pgA.
edges.emplace_back(
 
  132         pgB.
edges.emplace_back(
 
  137     std::vector<Trk::EdgeCross> edge_cross;
 
  138     for (
int ia = 0; ia < pgA.
nVtx; ia++) {
 
  145             if (rs == 0 && rpq == 0) {
 
  157                 if (
t0 > 0 && 
t0 < 1.)
 
  158                     edge_cross.emplace_back(
 
  159                         std::make_pair(ia, 
ib), std::make_pair(
t0, -1));
 
  160                 if (
t1 > 0 && 
t1 < 1.)
 
  161                     edge_cross.emplace_back(
 
  162                         std::make_pair(ia, 
ib), std::make_pair(
t1, -1));
 
  163             } 
else if (rs != 0 && qps / rs > 0 && qps / rs < 1 &&
 
  164                        rpq / rs > 0 && rpq / rs < 1) {
 
  165                 edge_cross.emplace_back(std::make_pair(ia, 
ib),
 
  166                                    std::make_pair(qps / rs, rpq / rs));
 
  171     std::vector<Trk::EdgeCross> setVtx;
 
  172     for (
int ia = 0; ia < pgA.
nVtx; ia++) {
 
  174             setVtx.emplace_back(std::make_pair(ia, -1),
 
  175                                             std::make_pair(0., -1.));
 
  177             if (
ie.edge_id.first == ia) {
 
  178                 if (!setVtx.empty() && setVtx.back().edge_id.first == ia &&
 
  179                     setVtx.back().edge_pos.first > 
ie.edge_pos.first)
 
  180                     setVtx.insert(setVtx.end() - 1, 
ie);
 
  182                     setVtx.push_back(
ie);
 
  189             int nlow = 
ib == 0 ? pgB.
nVtx : 
ib - 1;
 
  193             while (
it != setVtx.end()) {
 
  194                 if ((*it).edge_id.second == nlow) {
 
  195                     if (itb == setVtx.end() ||
 
  196                         (*it).edge_pos.second > (*itb).edge_pos.second)
 
  203                          std::make_pair(
ib, -2),
 
  215     pgon.
nVtx = setVtx.size() < 3 ? 0 : setVtx.size();
 
  220     for (
auto vtx : setVtx) {
 
  221         if (vtx.edge_id.second == -1)
 
  223         else if (vtx.edge_id.second == -2)
 
  229                                pgA.
edges[vtx.edge_id.first].second};
 
  231             pgon.
xyVertices.emplace_back(vint.x(), vint.y());
 
  254     bool isPolygon = (box || trd || prism || spb || trdd);
 
  262     std::vector<Amg::Vector3D> vtxLocal;
 
  292         } 
else if (
swap == 2) {
 
  322             cache.
vertices.push_back(std::move(vtx));
 
  364         const std::vector<std::pair<double, double>> vtcs = prism->
xyVertices();
 
  365         for (
const auto& vtc : vtcs)
 
  366             vtxLocal.emplace_back(vtc.first, vtc.second, prism->
halflengthZ());
 
  367         cache.
nVtx = vtcs.size();
 
  370         const std::vector<std::pair<double, double>> vtcs = spb->
xyVertices();
 
  371         for (
const auto& vtc : vtcs)
 
  372             vtxLocal.emplace_back(vtc.first, vtc.second, spb->
halflengthZ());
 
  373         cache.
nVtx = vtcs.size();
 
  381         cache.
vertices.push_back(std::move(vtx));
 
  388     const std::pair<double, double>& vtx,
 
  389     const std::vector<std::pair<double, double>>& pgon) {
 
  393     size_t nv = pgon.size();
 
  394     for (
size_t i = 0, 
k = nv - 1; 
i < nv; 
k = 
i++) {
 
  395         if ((pgon[
i].
second > vtx.second) != (pgon[
k].second > vtx.second)) {
 
  396             double ctg = (pgon[
k].first - pgon[
i].first) /
 
  399                    (vtx.second - pgon[
i].second) * ctg + pgon[
i].
first);
 
  406                                     const std::pair<double, double>& 
b,
 
  410         return (
a.first * 
b.first + 
a.second * 
b.second);
 
  412     return (
a.first * 
b.second - 
a.second * 
b.first);
 
  415 std::pair<bool, std::unique_ptr<Trk::Volume>>
 
  434         if (distance_center >
 
  435             std::hypot(cylA->outerRadius(), cylA->halflengthZ()) +
 
  436                 std::hypot(cylB->outerRadius(), cylB->halflengthZ())) {
 
  437             return std::make_pair(
true, 
nullptr);
 
  447         if (std::abs((b0.cross(b1).unit()).dot(
a0.cross(a1).unit())) < 1.e-3) {
 
  448             if (std::abs((b0.cross(b1).unit()).dot(a1)) < 1.e-3)
 
  449                 pgA = polygonXY(volA, 1);  
 
  450             else if (std::abs((b0.cross(b1).unit()).dot(
a0)) < 1.e-3)
 
  451                 pgA = polygonXY(volA, 2);  
 
  456         if (std::abs(std::abs((b0.cross(b1).unit()).dot(
a0.cross(a1).unit())) -
 
  458             return std::make_pair(
false, 
nullptr);
 
  463         if (
norm.z() != 1.) {  
 
  487             return std::make_pair(
true, 
nullptr);
 
  491         std::unique_ptr<Trk::Volume> overlap{};
 
  493             auto spb = std::make_shared<Trk::SimplePolygonBrepVolumeBounds>(
result.xyVertices,
 
  497             overlap = std::make_unique<Trk::Volume>(
makeTransform(transf), spb);
 
  499         return std::make_pair(
true, std::move(overlap));
 
  502     return std::make_pair(
false, 
nullptr);