EgtGeomKernel :
- correzione alla rigata minDist con superficie Bezier.
This commit is contained in:
+142
-85
@@ -3474,7 +3474,7 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V
|
||||
continue ;
|
||||
// se la curva oltrepassa l'asse allora mi fermo, se tocca l'asse, ma resta dallo stesso lato, allora vado avanti
|
||||
if ( iccInfo.IciA->nPrevTy != iccInfo.IciA->nNextTy)
|
||||
return nullptr ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3867,100 +3867,153 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
PNTIVECTOR vPnt0Match, vPnt1Match ;
|
||||
bool bCommonPoint = false ;
|
||||
AssociatePolyLinesMinDistPoints( plU0, plU1, vPnt0Match, vPnt1Match, bCommonPoint) ;
|
||||
// mi basta scorrere il vettore vPnt1Match che mi dice che punti devo aggiungere della prima isocurva
|
||||
nCount0 = 0 ;
|
||||
|
||||
// devo contare il numero di ripetizioni dei match nel mezzo delle curve, perché aumentano il numero di span della superficie!!
|
||||
int nRep0 = 0 ;
|
||||
int nIndMatch = 0 ;
|
||||
int nIndMatchNext = 0 ;
|
||||
// scorro gli estremi delle sottocurve della curva 1
|
||||
for ( int i = 0 ; i < int( vPnt1Match.size() - 1) ; ++i) {
|
||||
nIndMatch = vPnt1Match[i].second ;
|
||||
nIndMatchNext = vPnt1Match[i+1].second ;
|
||||
if ( nIndMatch == nSpanU0)
|
||||
break ;
|
||||
const ICurveBezier* pSubCrv0 ;
|
||||
if ( nIndMatch == nIndMatchNext) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nIndMatch)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( 0)) ;
|
||||
else
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( 0), pSubCrv0->GetControlWeight( 0)) ;
|
||||
}
|
||||
++ nCount0 ;
|
||||
}
|
||||
else {
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch ; ++k) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nIndMatch + k)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j ) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
else
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j), pSubCrv0->GetControlWeight( j)) ;
|
||||
}
|
||||
++ nCount0 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// controllo di aver aggiunto anche gli ultimi punti
|
||||
int nInd = nIndMatchNext < nSpanU0 ? nIndMatchNext : nIndMatchNext - 1 ;
|
||||
while ( nCount0 < nSpanU) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nInd)) ;
|
||||
for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = nInd < nSpanU0 - 1 ? j : nDegU ;
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( nPoint)) ;
|
||||
else
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( nPoint), pSubCrv0->GetControlWeight( nPoint)) ;
|
||||
}
|
||||
++ nCount0 ;
|
||||
if ( nInd < nSpanU0 - 1)
|
||||
++ nInd ;
|
||||
}
|
||||
nCount1 = 0 ;
|
||||
for ( int i = 0 ; i < int( vPnt0Match.size() - 1) ; ++i) {
|
||||
nIndMatch = vPnt0Match[i].second ;
|
||||
nIndMatchNext = vPnt0Match[i+1].second ;
|
||||
if ( nIndMatch == nSpanU1)
|
||||
break ;
|
||||
const ICurveBezier* pSubCrv1 ;
|
||||
if ( nIndMatch != nIndMatchNext)
|
||||
nRep0 += nIndMatchNext - nIndMatch - 1;
|
||||
}
|
||||
// reinizializzo la superficie con il nuovo numero di span in U
|
||||
nSpanU = nSpanU0 + nRep0 ;
|
||||
nSecondRowInd = nDegU * nSpanU + 1 ;
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
|
||||
// come riferimento tengo i match identificati dalla curva 0
|
||||
nCount0 = 0 ;
|
||||
nCount1 = 0 ;
|
||||
|
||||
// scorro gli estremi delle sottocurve della curva 1
|
||||
for ( int i = 0 ; i < int( vPnt0Match.size() - 1) ; ++i) {
|
||||
nIndMatch = vPnt0Match[i].second ;
|
||||
nIndMatchNext = vPnt0Match[i+1].second ;
|
||||
const ICurveBezier* pSubCrv0 ;
|
||||
if ( nIndMatch == nIndMatchNext) {
|
||||
pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if( ! bRat1)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( 0)) ;
|
||||
else
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( 0), pSubCrv1->GetControlWeight( 0)) ;
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
else
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j), pSubCrv0->GetControlWeight( j)) ;
|
||||
}
|
||||
++ nCount1 ;
|
||||
++ nCount0 ;
|
||||
// ripeto l'ultimo punto aggiunto alla riga 2
|
||||
//int nInd = nIndMatch == nSpanU1 ? nIndMatch - 1 : nIndMatch ;
|
||||
int nInd = nIndMatch - 1 ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU1->GetCurve( nInd)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = nCount1 == 0 ? 0 : nDegU ;
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv0->GetControlPoint( nPoint)) ;
|
||||
else
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv0->GetControlPoint( nPoint), pSubCrv0->GetControlWeight( nPoint)) ;
|
||||
}
|
||||
++nCount1 ;
|
||||
}
|
||||
else {
|
||||
// ripeto l'ultimo punto aggiunto per il numero di curve balzate della seconda curva - 1
|
||||
// aggiungo una sottocurva dalla prima curva
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch - 1 ; ++k) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i != 0 ? i - 1 : i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = nCount0 == 0 ? 0 : nDegU ;
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( nPoint)) ;
|
||||
else
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( nPoint), pSubCrv0->GetControlWeight( nPoint)) ;
|
||||
}
|
||||
++ nCount0 ;
|
||||
}
|
||||
// aggiungo una sottocurva dalla prima curva
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
else
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j), pSubCrv0->GetControlWeight( j)) ;
|
||||
}
|
||||
++ nCount0 ;
|
||||
|
||||
|
||||
// aggiungo tutte le sottocurve che ho balzato della seconda
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch ; ++k) {
|
||||
pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch + k)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if( ! bRat1)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( j)) ;
|
||||
else
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( j), pSubCrv1->GetControlWeight( j)) ;
|
||||
pSubCrv0 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch + k)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j ) {
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
else
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv0->GetControlPoint( j), pSubCrv0->GetControlWeight( j)) ;
|
||||
}
|
||||
++ nCount1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// controllo di aver aggiunto anche gli ultimi punti
|
||||
nInd = nIndMatchNext < nSpanU1 ? nIndMatchNext : nIndMatchNext - 1 ;
|
||||
while ( nCount1 < nSpanU) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nInd)) ;
|
||||
for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = nInd < nSpanU1 - 1 ? j : nDegU ;
|
||||
if( ! bRat1)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( nPoint)) ;
|
||||
else
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( nPoint), pSubCrv1->GetControlWeight( nPoint)) ;
|
||||
}
|
||||
++ nCount1 ;
|
||||
if ( nInd < nSpanU1 - 1)
|
||||
++ nInd ;
|
||||
}
|
||||
|
||||
//// // QUESTO PEZZO E' DA SISTEMARE
|
||||
//// controllo di aver aggiunto anche gli ultimi punti
|
||||
//int nInd = nIndMatchNext < nSpanU0 ? nIndMatchNext : nIndMatchNext - 1 ;
|
||||
//while ( nCount0 < nSpanU) {
|
||||
// const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nInd)) ;
|
||||
// for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
// int nPoint = nInd < nSpanU0 - 1 ? j : nDegU ;
|
||||
// if ( ! bRat0)
|
||||
// SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( nPoint)) ;
|
||||
// else
|
||||
// SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( nPoint), pSubCrv0->GetControlWeight( nPoint)) ;
|
||||
// }
|
||||
// ++ nCount0 ;
|
||||
// if ( nInd < nSpanU0 - 1)
|
||||
// ++ nInd ;
|
||||
//}
|
||||
|
||||
//for ( int i = 0 ; i < int( vPnt0Match.size() - 1) ; ++i) {
|
||||
// nIndMatch = vPnt0Match[i].second ;
|
||||
// nIndMatchNext = vPnt0Match[i+1].second ;
|
||||
// if ( nIndMatch == nSpanU1)
|
||||
// break ;
|
||||
// const ICurveBezier* pSubCrv1 ;
|
||||
// if ( nIndMatch == nIndMatchNext) {
|
||||
// pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch)) ;
|
||||
// for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
// if( ! bRat1)
|
||||
// SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( 0)) ;
|
||||
// else
|
||||
// SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( 0), pSubCrv1->GetControlWeight( 0)) ;
|
||||
// }
|
||||
// ++ nCount1 ;
|
||||
// }
|
||||
// else {
|
||||
// for( int k = 0 ; k < nIndMatchNext - nIndMatch ; ++k) {
|
||||
// pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch + k)) ;
|
||||
// for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
// if( ! bRat1)
|
||||
// SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( j)) ;
|
||||
// else
|
||||
// SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( j), pSubCrv1->GetControlWeight( j)) ;
|
||||
// }
|
||||
// ++ nCount1 ;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//// controllo di aver aggiunto anche gli ultimi punti
|
||||
//nInd = nIndMatchNext < nSpanU1 ? nIndMatchNext : nIndMatchNext - 1 ;
|
||||
//while ( nCount1 < nSpanU) {
|
||||
// const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nInd)) ;
|
||||
// for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
// int nPoint = nInd < nSpanU1 - 1 ? j : nDegU ;
|
||||
// if( ! bRat1)
|
||||
// SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( nPoint)) ;
|
||||
// else
|
||||
// SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( nPoint), pSubCrv1->GetControlWeight( nPoint)) ;
|
||||
// }
|
||||
// ++ nCount1 ;
|
||||
// if ( nInd < nSpanU1 - 1)
|
||||
// ++ nInd ;
|
||||
//}
|
||||
}
|
||||
|
||||
if ( nRuledType == RLT_B_ISOPAR) {
|
||||
@@ -4080,10 +4133,10 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
|
||||
}
|
||||
// spezzo le curve di bezier dove è necessario aggiungere dei punti // parametrizzo le curve sulla lunghezza
|
||||
// spezzo le curve di bezier dove è necessario aggiungere dei punti
|
||||
else if ( nRuledType == RLT_B_MINDIST_PLUS ) { // probabilmente se questo funziona bene non serve la modilità ISOPARM_SMOOTH
|
||||
// scorro la prima curva e per ogni punto di fine sottocurva cerco il minDistPoint sull'altra curva, che poi spezzo in quel punto
|
||||
// se trovo un punto già sufficientemente vicino allora non spezzo nessuna sottocurva
|
||||
// scorro la prima curva e per ogni punto di fine sottocurva cerco il minDistPoint sull'altra curva
|
||||
// in quel punto la curva verrà spezzata, a meno che non si trovi una joint già sufficientemente vicina
|
||||
|
||||
int nAtStart1 = 0 ;
|
||||
int nAtEnd1 = 0 ;
|
||||
@@ -4127,6 +4180,8 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
nSpanU = max( nSpanU0, nSpanU1) ;
|
||||
|
||||
// se la differenza tra il numero di span delle due curve non è colmata dalla ripetizione dello start o dello'end allora devo tenere conto anche
|
||||
// delle addJoint che non hanno fatto nulla ( perché chieste di splittare la curva troppo vicino ad un punto già esistente di split, magari in un caso anche di multimatch per lo stesso punto)
|
||||
if ( (nSpanU0 > nSpanU1 && nSpanU0 != nSpanU1 + nAtStart1 + nAtEnd1) ||
|
||||
(nSpanU0 < nSpanU1 && nSpanU1 != nSpanU0 + nAtStart0 + nAtEnd0))
|
||||
return false ;
|
||||
@@ -4192,10 +4247,12 @@ SurfBezier::FindMatchByParam( const PolyLine& pl0, const PolyLine& pl1, INTVECTO
|
||||
// valuto il limite dell'area di influenza dei punti della curva con meno punti
|
||||
// per i punti intermedi il limite è la metà tra i punti
|
||||
// per il primo e l'ultimo punto aumento il peso di quest'ultimi nel calcolo della media
|
||||
double dW = 2./3. ;
|
||||
//double dW = 1./2. ;
|
||||
if ( i == 0)
|
||||
vSplit.push_back( (i * (1./3.) + ( i + 1) * ( 2./3.)) / ( nMin - 1)) ;
|
||||
vSplit.push_back( (i * (1- dW) + ( i + 1) * dW) / ( nMin - 1)) ;
|
||||
else if ( i == nMin - 2)
|
||||
vSplit.push_back( (i * (2./3.) + ( i + 1) * ( 1./3.)) / ( nMin - 1)) ;
|
||||
vSplit.push_back( (i * dW + ( i + 1) * ( 1 - dW)) / ( nMin - 1)) ;
|
||||
else
|
||||
vSplit.push_back( ( 2. * i + 1) / (2 * ( nMin - 1))) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user