From 5e42cf86c401f7b34b3a59b6fec8b677bbe27e8b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 22 Mar 2021 14:35:58 +0000 Subject: [PATCH] EgtGeomKernel : - correzione calcolo intersezioni Linea-Box. --- IntersLineBox.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/IntersLineBox.cpp b/IntersLineBox.cpp index d4a2ce6..64b5b86 100644 --- a/IntersLineBox.cpp +++ b/IntersLineBox.cpp @@ -94,17 +94,22 @@ IntersLineBox( const Point3d& ptL, const Vector3d& vtL, double dLen, const BBox3 for ( size_t j = 1 ; j < vInters.size() ; ) { // intersezione precedente size_t i = j - 1 ; - // se hanno lo stesso parametro - if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { - // se sono uguali, elimino la seconda - if ( vInters[i].first == vInters[j].first) { + // se sono dello stesso tipo, elimino una delle due + if ( vInters[i].first == vInters[j].first) { + // se entranti elimino la prima + if ( vInters[i].first == ILBT_IN || vInters[i].first == ILBT_TG_INI) + vInters.erase( vInters.begin() + i) ; + // altrimenti la seconda + else vInters.erase( vInters.begin() + j) ; - if ( i > 0) - -- j ; - continue ; - } + if ( i > 0) + -- j ; + continue ; + } + // se hanno lo stesso parametro + else if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { // se una entrante e l'altra uscente, cambio in touch ed elimino la seconda - else if ( ( vInters[i].first == ILBT_IN && vInters[j].first == ILBT_OUT) || + if ( ( vInters[i].first == ILBT_IN && vInters[j].first == ILBT_OUT) || ( vInters[i].first == ILBT_OUT && vInters[j].first == ILBT_IN)) { vInters[i].first = ILBT_TOUCH ; vInters.erase( vInters.begin() + j) ;