EgtGeomKernel :

- correzioni alle rigate bezier.
This commit is contained in:
Daniele Bariletti
2026-02-17 14:41:37 +01:00
parent da7ebd6f61
commit 233f64e68f
+74 -44
View File
@@ -1077,7 +1077,7 @@ SurfBezier::Load( NgeReader& ngeIn)
ICURVEPOVECTOR vCrv ;
GetAllPatchesIsocurves( false, vCrv) ;
vGeo.clear() ;
for( int i = 0 ; i < ssize(vCrv) ; ++i)
for ( int i = 0 ; i < ssize(vCrv) ; ++i)
vGeo.push_back( vCrv[i]->Clone()) ;
SaveGeoObj( vGeo, "D:\\Temp\\bezier\\ruled\\rebuild\\isoCrv.nge") ;
#endif
@@ -5149,10 +5149,10 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
INTINTVECTOR vMismatch1 ;
//double dMaxDist = Dist( vPnt0[0], vPnt1[0]) / 20 ;
double dMaxDist = Dist( vPnt0[0], vPnt1[0]) / 3 ;
for( int i = 0 ; i < ssize( vMatch0) ; ++i) {
if( ! AreSamePointEpsilon( vMatch0[i].first, vMatch0b[i].first, dMaxDist)) {
for ( int i = 0 ; i < ssize( vMatch0) ; ++i) {
if ( ! AreSamePointEpsilon( vMatch0[i].first, vMatch0b[i].first, dMaxDist)) {
int c = i + 1 ;
while( ! AreSamePointEpsilon( vMatch0[c].first, vMatch0b[c].first, dMaxDist))
while ( ! AreSamePointEpsilon( vMatch0[c].first, vMatch0b[c].first, dMaxDist))
++c ;
vMismatch0.emplace_back( i, c) ;
i = c ;
@@ -5160,8 +5160,8 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
}
// faccio un merge di regioni adiacenti di mismatch
int nCurr = 0, nNext = 1 ;
while( nNext < ssize( vMismatch0)) {
if( vMismatch0[nNext].first - vMismatch0[nCurr].second < 2 + EPS_SMALL) {
while ( nNext < ssize( vMismatch0)) {
if ( vMismatch0[nNext].first - vMismatch0[nCurr].second < 2 + EPS_SMALL) {
vMismatch0[nCurr].second = vMismatch0[nNext].second ;
}
else {
@@ -5172,18 +5172,18 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
}
vMismatch0.resize( nCurr + 1) ;
for( int i = 0 ; i < ssize( vMatch1) ; ++i) {
if( ! AreSamePointEpsilon( vMatch1[i].first, vMatch1b[i].first, dMaxDist)) {
for ( int i = 0 ; i < ssize( vMatch1) ; ++i) {
if ( ! AreSamePointEpsilon( vMatch1[i].first, vMatch1b[i].first, dMaxDist)) {
int c = i + 1 ;
while( ! AreSamePointEpsilon( vMatch1[c].first, vMatch1b[c].first, dMaxDist))
while ( ! AreSamePointEpsilon( vMatch1[c].first, vMatch1b[c].first, dMaxDist))
++c ;
vMismatch1.emplace_back( i, c) ;
i = c ;
}
}
nCurr = 0, nNext = 1 ;
while( nNext < ssize( vMismatch1)) {
if( vMismatch1[nNext].first - vMismatch1[nCurr].second < 2 + EPS_SMALL) {
while ( nNext < ssize( vMismatch1)) {
if ( vMismatch1[nNext].first - vMismatch1[nCurr].second < 2 + EPS_SMALL) {
vMismatch1[nCurr].second = vMismatch1[nNext].second ;
}
else {
@@ -5223,12 +5223,12 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
return false ;
}
// aggiorno il contatore delle eventuali zone di mismatch
if( ssize( vMismatch0) > 0) {
while( m0 < ssize( vMismatch0) - 1 && c > vMismatch0[m0].second)
if ( ssize( vMismatch0) > 0) {
while ( m0 < ssize( vMismatch0) - 1 && c > vMismatch0[m0].second)
++m0 ;
}
if( ssize( vMismatch1) > 0) {
while( m1 < ssize( vMismatch1) - 1 && j > vMismatch1[m1].second)
if ( ssize( vMismatch1) > 0) {
while ( m1 < ssize( vMismatch1) - 1 && j > vMismatch1[m1].second)
++m1 ;
}
@@ -5281,6 +5281,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
dParam1 = c + 1 ;
ptJoint0 = vPnt1[j+1] ;
ptJoint1 = vPnt0[c+1] ;
bMismatch = false ;
}
else if ( ( vEdgeSplit0[c] && ! bAdvance1) || (vEdgeSplit1[j] && ! bAdvance0)) {
// da una parte ho uno spigolo e dall'altra non posso avanzare
@@ -5429,7 +5430,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
}
}
if( ( ! vEdgeSplit0[c] && ! vEdgeSplit1[j]) || bMismatch) {
if ( ( ! vEdgeSplit0[c] && ! vEdgeSplit1[j]) || bMismatch) {
// non ci sono riferimenti per fare un match, quindi li cerco io
///////////OLD VRESION
@@ -5448,28 +5449,29 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
// identifico la zona in cui ho il mismatch e parametrizzo localmente
//conto quanti punti ho nel mezzo
bool bEndOnEdge = false ;
int c_temp = c, j_temp = j ;
if( ! bMismatch) {
if ( ! bMismatch) {
c_temp = c, j_temp = j ;
bAdvance0 = true ;
bAdvance1 = true ;
int nParam0, nParam1 ;
while( bAdvance0) {
while ( bAdvance0) {
dParam0 = vMatch0[c_temp].second ;
nParam0 = int( round( dParam0)) ;
dParam1 = vMatch1[nParam0].second ;
nParam1 = int( round( dParam1)) ;
if( abs( nParam1 - c_temp) <= 2)
if ( abs( nParam1 - c_temp) <= 2)
bAdvance0 = false ;
else
++ c_temp ;
}
while( bAdvance1) {
while ( bAdvance1) {
dParam1 = vMatch1[j_temp].second ;
nParam1 = int( round( dParam1)) ;
dParam0 = vMatch0[nParam1].second ;
nParam0 = int( round( dParam0)) ;
if( abs( nParam0 - j_temp) <= 2)
if ( abs( nParam0 - j_temp) <= 2)
bAdvance1 = false ;
else
++ j_temp ;
@@ -5479,17 +5481,30 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
// cerco se ho degli spigoli nella zona di mismatch
// se ne ho definisco una regione compresa tra un estremo( start o end) e uno spigolo (presente su entrambe le curve)
INTVECTOR vnEdges0, vnEdges1 ;
for( int i = vMismatch0[m0].first ; i < vMismatch0[m0].second ; ++i) {
if ( vEdgeSplit0[i])
vnEdges0.push_back(i) ;
if ( ssize( vMismatch0) > 0 && bMismatch0) {
for ( int i = max( vMismatch0[m0].first, c) ; i < vMismatch0[m0].second ; ++i) {
if ( vEdgeSplit0[i])
vnEdges0.push_back(i) ;
}
}
for( int i = vMismatch1[m1].first ; i < vMismatch1[m1].second ; ++i) {
if ( vEdgeSplit1[i])
vnEdges1.push_back(i) ;
if ( ssize( vMismatch1) > 0 && bMismatch1) {
for ( int i = max( vMismatch1[m1].first, j) ; i < vMismatch1[m1].second ; ++i) {
if ( vEdgeSplit1[i])
vnEdges1.push_back(i) ;
}
}
// se ho degli edge che non matchano tra loro semplicemente tratto tutta la regione di mismatch insieme
if( ssize( vnEdges0) != ssize( vnEdges1) || ssize( vnEdges0) == 0 || ssize( vnEdges1) == 0) {
if( bMismatch0) {
if ( ssize( vnEdges0) != ssize( vnEdges1) || ssize( vnEdges0) == 0 || ssize( vnEdges1) == 0) {
if ( bMismatch0 && bMismatch1) {
int c_temp0 = vMismatch0[m0].second ;
int j_temp0 = int( vMatch0[c_temp0].second) ;
int j_temp1 = vMismatch1[m1].second ;
int c_temp1 = int( vMatch1[j_temp1].second) ;
c_temp = max( c_temp0, c_temp1) ;
j_temp = max( j_temp0, j_temp1) ;
}
else if ( bMismatch0) {
c_temp = vMismatch0[m0].second ;
j_temp = int( vMatch0[c_temp].second) ;
}
@@ -5503,9 +5518,12 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
// definisco gli estremi della zona da riparametrizzare
// controllo se ho già matchato parte della zona di mismatch
// cerco la coppia successiva alla corrente per determinare la zona su cui lavorare ora
for( int i = 0 ; i < ssize( vnEdges0) ; ++i) {
if( c == vnEdges0[i]) {
if( i < ssize( vnEdges0) - 1) {
bEndOnEdge = true ;
bool bAtHalfwayEdge = false ;
for ( int i = 0 ; i < ssize( vnEdges0) ; ++i) {
if ( c == vnEdges0[i]) {
bAtHalfwayEdge = true ;
if ( i < ssize( vnEdges0) - 1) {
c_temp = vnEdges0[i+1] ;
j_temp = vnEdges1[i+1] ;
}
@@ -5515,7 +5533,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
j_temp = int( vMatch0[c_temp].second) ;
++m0 ;
}
else if( bMismatch1) {
else if ( bMismatch1) {
j_temp = vMismatch1[m1].second ;
c_temp = int( vMatch1[j_temp].second) ;
++m1 ;
@@ -5524,6 +5542,12 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
break ;
}
}
// se non avevo già affrontato la prima parte allora setto come fine della prima zona il primo edge che incontrerò
if ( ! bAtHalfwayEdge) {
c_temp = vnEdges0[0] ;
j_temp = vnEdges1[0] ;
}
}
}
@@ -5533,7 +5557,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
-- c_temp ;
// se non sono avanzato, allora mi basta accoppiare i due punti in questione
if( c_temp == c || j_temp == j) {
if ( c_temp == c && j_temp == j) {
++c ;
++j ;
vPairs.emplace_back( c + nSplit0, j + nSplit1) ;
@@ -5545,34 +5569,40 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
// se sono dovuto avanzare per trovare delle coppie che tornano a matchare allora ho effettivamente trovato una zona di mismatch
else {
// determino quale delle due coppie è il confine effettivo con la zona di mismatch e quale sarà la prima dopo il mismamtch
dParam0 = vMatch0[c_temp].second ;
dParam1 = vMatch1[j_temp].second ;
bAdvance0 = dParam0 < j_temp + 1 + EPS_SMALL ;
bAdvance1 = dParam1 < c_temp + 1 + EPS_SMALL ;
if ( ! bEndOnEdge) {
dParam0 = vMatch0[c_temp].second ;
dParam1 = vMatch1[j_temp].second ;
bAdvance0 = dParam0 < j_temp + 1 + EPS_SMALL ;
bAdvance1 = dParam1 < c_temp + 1 + EPS_SMALL ;
}
else {
bAdvance0 = true ;
bAdvance1 = true ;
}
PtrOwner<ICurve> pCC0 ;
PtrOwner<ICurve> pCC1 ;
int nPointsBetween0 = 0 ;
int nPointsBetween1 = 0 ;
if( bAdvance0 && bAdvance1) {
if ( bAdvance0 && bAdvance1) {
pCC0.Set( CrvU0.CopyParamRange( dLastParamMatch1, c_temp + 1)) ;
pCC1.Set( CrvU1.CopyParamRange( dLastParamMatch0, j_temp + 1)) ;
nPointsBetween0 = int( c_temp + 1 - floor( dLastParamMatch1) - 1) ;
nPointsBetween1 = int( j_temp + 1 - floor( dLastParamMatch0) - 1) ;
}
else if( bAdvance0){
else if ( bAdvance0){
pCC0.Set( CrvU0.CopyParamRange( dLastParamMatch1, c_temp + 1)) ;
pCC1.Set( CrvU1.CopyParamRange( dLastParamMatch0, dParam0)) ;
nPointsBetween0 = int( c_temp + 1 - floor( dLastParamMatch1) - 1) ;
nPointsBetween1 = int( ceil( dParam0) - floor( dLastParamMatch0) - 1) ;
}
else if( bAdvance1){
else if ( bAdvance1) {
pCC0.Set( CrvU0.CopyParamRange( dLastParamMatch1, dParam1)) ;
pCC1.Set( CrvU1.CopyParamRange( dLastParamMatch0, j_temp + 1)) ;
nPointsBetween0 = int( ceil( dParam1) - floor( dLastParamMatch1) - 1) ;
nPointsBetween1 = int( j_temp + 1 - floor( dLastParamMatch0) - 1) ;
}
if( IsNull(pCC0) || ! pCC0->IsValid() || IsNull(pCC1) || ! pCC1->IsValid()) {
if ( IsNull( pCC0) || ! pCC0->IsValid() || IsNull( pCC1) || ! pCC1->IsValid()) {
LOG_DBG_ERR( GetEGkLogger(), "RLT_B_MINDIST_PLUS: failed attempt to identify mismatch region, type0") ;
return false ;
}
@@ -5580,7 +5610,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
double dLen0 ; pCC0->GetLength( dLen0) ;
double dLen1 ; pCC1->GetLength( dLen1) ;
if( nPointsBetween0 < 0 || nPointsBetween1 < 0) {
if ( nPointsBetween0 < 0 || nPointsBetween1 < 0) {
LOG_DBG_ERR( GetEGkLogger(), "RLT_B_MINDIST_PLUS: failed attempt to identify mismatch region, type1") ;
return false ;
}
@@ -5611,7 +5641,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
return false ;
}
// se ho una corrispondenza tra punti ( e non sono alla fine del tratto) allora non aggiungo split
if ( abs( vdParamPos0[c0] - vdParamPos1[c1]) < EPS_PARAM && vdParamPos0[c0] < 1) {
if ( abs( vdParamPos0[c0] - vdParamPos1[c1]) < EPS_SMALL && vdParamPos0[c0] < 1) {
++c ;
++j ;
vPairs.emplace_back( c + nSplit0, j + nSplit1) ;