EgtGeomKernel :

- IntersCurveCurve: eliminata le intersezioni puntuali rimanenti vicine a overlap; corretto scorrimento delle intersezioni durante il merge.
This commit is contained in:
Daniele Bariletti
2026-03-19 12:57:11 +01:00
parent 42c5ffb014
commit de4165889a
2 changed files with 49 additions and 30 deletions
+48 -30
View File
@@ -19,12 +19,13 @@
#include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGkHashGrids2d.h"
#include <algorithm>
#include <ranges>
using namespace std ;
//--------------------------- Local functions --------------------------------
static bool CompatibleParamA( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
bool bCrvAClosed, double dCrvASpan) ;
bool bCrvAClosed, double dCrvASpan, bool bOrderedOnB = false) ;
static bool CompatibleParamB( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
bool bCrvBClosed, double dCrvBSpan, bool bOrderedOnB = false) ;
static void MediaParamPoints( IntCrvInfo& Ici1, IntCrvInfo& Ici2, const ICurveComposite& crvCompo) ;
@@ -261,8 +262,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
abs( m_Info[i].IciA[0].dU - m_Info[j].IciA[0].dU) < EPS_PARAM &&
abs( m_Info[i].IciA[1].dU - m_Info[j].IciA[1].dU) < EPS_PARAM) {
// cancello entrambe
EraseOtherInfo( i, j) ;
EraseCurrentInfo( i, j) ;
EraseBothInfo( i, j) ;
}
// caso DET-(NULL) -> (NULL)-DET per prima curva
else if ( m_Info[j].IciA[kj].nPrevTy != ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
@@ -382,8 +382,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
// cancello entrambe
EraseOtherInfo( i, j) ;
EraseCurrentInfo( i, j) ;
EraseBothInfo( i, j) ;
}
// caso NULL-DET -> NULL-DET per prima curva con NULL-NULL -> NULL-NULL su seconda curva
else if ( m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy != ICCT_NULL &&
@@ -391,8 +390,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
// cancello entrambe
EraseOtherInfo( i, j) ;
EraseCurrentInfo( i, j) ;
EraseBothInfo( i, j) ;
}
// caso NULL-NULL per corrente di prima curva
else if ( m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
@@ -434,15 +432,14 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
// verifico se precedente e corrente si riferiscono alla stessa intersezione (10 * EPS_SMALL)
if ( AreSamePointXYEpsilon( m_Info[j].IciA[kj].ptI, m_Info[i].IciA[ki].ptI, 10 * EPS_SMALL) &&
AreSamePointXYEpsilon( m_Info[j].IciB[kj].ptI, m_Info[i].IciB[ki].ptI, 10 * EPS_SMALL) &&
CompatibleParamA( m_Info[j], m_Info[i], bCrvAClosed, dCrvASpan) &&
CompatibleParamA( m_Info[j], m_Info[i], bCrvAClosed, dCrvASpan, true) &&
CompatibleParamB( m_Info[j], m_Info[i], bCrvBClosed, dCrvBSpan, true)) {
// caso entrambi Overlap ma di tipo opposto e sullo stesso tratto
if ( m_Info[i].bOverlap && m_Info[j].bOverlap && m_Info[i].bCBOverEq != m_Info[j].bCBOverEq &&
abs( m_Info[i].IciB[0].dU - m_Info[j].IciB[0].dU) < EPS_PARAM &&
abs( m_Info[i].IciB[1].dU - m_Info[j].IciB[1].dU) < EPS_PARAM) {
// cancello entrambe
EraseOtherInfo( i, j) ;
EraseCurrentInfo( i, j) ;
EraseBothInfo( i, j) ;
}
// caso DET-(NULL) -> (NULL)-DET per seconda curva
else if ( m_Info[j].IciB[kj].nPrevTy != ICCT_NULL && m_Info[j].IciB[kj].nNextTy == ICCT_NULL &&
@@ -538,8 +535,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
// cancello entrambe
EraseOtherInfo( i, j) ;
EraseCurrentInfo( i, j) ;
EraseBothInfo( i, j) ;
}
// caso NULL-DET -> NULL-DET per seconda curva con NULL-NULL -> NULL-NULL su prima curva
else if ( m_Info[j].IciB[kj].nPrevTy == ICCT_NULL && m_Info[j].IciB[kj].nNextTy != ICCT_NULL &&
@@ -547,8 +543,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
m_Info[j].IciA[kj].nPrevTy == ICCT_NULL && m_Info[j].IciA[kj].nNextTy == ICCT_NULL &&
m_Info[i].IciA[ki].nPrevTy == ICCT_NULL && m_Info[i].IciA[ki].nNextTy == ICCT_NULL) {
// cancello entrambe
EraseOtherInfo( i, j) ;
EraseCurrentInfo( i, j) ;
EraseBothInfo( i, j) ;
}
// caso NULL-NULL per corrente di seconda curva
else if ( m_Info[i].IciB[ki].nPrevTy == ICCT_NULL && m_Info[i].IciB[ki].nNextTy == ICCT_NULL) {
@@ -812,7 +807,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
}
// faccio il merge se ho trasformato delle intersezioni in overlap
for ( int i : vNewOverlap)
for ( int i : views::reverse( vNewOverlap))
MergeNewOverlap( i, true) ;
vNewOverlap.clear() ;
@@ -848,7 +843,7 @@ IntersCrvCompoCrvCompo::IntersCrvCompoCrvCompo( const ICurveComposite& CCompoA,
}
// faccio il merge se ho trasformato delle intersezioni in overlap
for ( int i : vNewOverlap)
for ( int i : views::reverse( vNewOverlap))
MergeNewOverlap( i, false) ;
}
else {
@@ -1081,13 +1076,27 @@ bool
IntersCrvCompoCrvCompo::EraseOtherInfo( int& nIndCurr, int& nIndOther)
{
m_Info.erase( m_Info.begin() + nIndOther) ;
if ( nIndOther < nIndCurr)
-- nIndCurr ;
-- nIndCurr ;
-- nIndOther ;
-- m_nNumInters ;
return true ;
}
//----------------------------------------------------------------------------
bool
IntersCrvCompoCrvCompo::EraseBothInfo( int& nIndCurr, int& nIndOther)
{
m_Info.erase( m_Info.begin() + nIndOther) ;
-- nIndCurr ;
-- nIndOther ;
-- m_nNumInters ;
m_Info.erase( m_Info.begin() + nIndCurr) ;
if ( nIndCurr != -1)
-- nIndCurr ;
-- m_nNumInters ;
return true ;
}
//----------------------------------------------------------------------------
// Global functions
//----------------------------------------------------------------------------
@@ -1235,11 +1244,20 @@ OrderNonManifoldInters( ICCIVECTOR& Info, const ICurve& CurveA, const ICurve& Cu
//----------------------------------------------------------------------------
static bool
CompatibleParamA( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
bool bCrvAClosed, double dCrvASpan)
bool bCrvAClosed, double dCrvASpan, bool bOrderedOnB)
{
int k = ( Icci1.bOverlap ? 1 : 0) ; // del precedente si prende il secondo se overlap
if ( abs( Icci1.IciA[k].dU - Icci2.IciA[0].dU) > 0.1 * SPAN_PARAM &&
( ! bCrvAClosed || abs( abs( Icci1.IciA[k].dU - Icci2.IciA[0].dU) - dCrvASpan) > 0.1 * SPAN_PARAM))
int ki = 0 ;
int kj = 0 ;
if ( ! bOrderedOnB) {
ki = 0 ;
kj = Icci1.bOverlap ? 1 : 0 ;
}
else {
ki = Icci2.bOverlap && ! Icci2.bCBOverEq ? 1 : 0 ;
kj = Icci1.bOverlap && Icci1.bCBOverEq ? 1 : 0 ;
}
if ( abs( Icci1.IciA[kj].dU - Icci2.IciA[ki].dU) > 0.1 * SPAN_PARAM &&
( ! bCrvAClosed || abs( abs( Icci1.IciA[kj].dU - Icci2.IciA[ki].dU) - dCrvASpan) > 0.1 * SPAN_PARAM))
return false ;
return true ;
}
@@ -1249,19 +1267,19 @@ static bool
CompatibleParamB( const IntCrvCrvInfo& Icci1, const IntCrvCrvInfo& Icci2,
bool bCrvBClosed, double dCrvBSpan, bool bOrderedOnB)
{
int j = 0 ;
int k = 0 ;
int ki = 0 ;
int kj = 0 ;
if ( ! bOrderedOnB) {
j = 0 ;
k = Icci1.bOverlap ? 1 : 0 ;
ki = 0 ;
kj = Icci1.bOverlap ? 1 : 0 ;
}
else {
j = Icci2.bOverlap && ! Icci2.bCBOverEq ? 1 : 0 ;
k = Icci1.bOverlap && Icci1.bCBOverEq ? 1 : 0 ;
ki = Icci2.bOverlap && ! Icci2.bCBOverEq ? 1 : 0 ;
kj = Icci1.bOverlap && Icci1.bCBOverEq ? 1 : 0 ;
}
if ( abs( Icci1.IciB[k].dU - Icci2.IciB[j].dU) > 0.1 * SPAN_PARAM &&
( ! bCrvBClosed || abs( abs( Icci1.IciB[k].dU - Icci2.IciB[j].dU) - dCrvBSpan) > 0.1 * SPAN_PARAM))
if ( abs( Icci1.IciB[kj].dU - Icci2.IciB[ki].dU) > 0.1 * SPAN_PARAM &&
( ! bCrvBClosed || abs( abs( Icci1.IciB[kj].dU - Icci2.IciB[ki].dU) - dCrvBSpan) > 0.1 * SPAN_PARAM))
return false ;
return true ;
}
+1
View File
@@ -43,6 +43,7 @@ class IntersCrvCompoCrvCompo
bool bAutoInters, bool bClosed, int nCurvesNbr) ;
bool EraseCurrentInfo( int& nIndCurr, int& nIndOther) ;
bool EraseOtherInfo( int& nIndCurr, int& nIndOther) ;
bool EraseBothInfo( int& nIndCurr, int& nIndOther) ;
bool CalcSide( int j, int i,const ICurve* pThisCrv, const ICurve* pOtherCrv, bool bCrvAOrB, int& nType) ;
bool MergeNewOverlap( int i, bool bCrvAOrB) ;