EgtGeomKernel :

- aggiornamento versione di RuledSmooth.
- aggiunta controlli.
- prima versione della regolarizzazione di curve bezier composte.
This commit is contained in:
Daniele Bariletti
2026-04-16 09:41:22 +02:00
parent 4bc8590ce9
commit 02cb8a0d3c
3 changed files with 448 additions and 192 deletions
+43 -52
View File
@@ -83,6 +83,8 @@
using namespace std ;
bool RegolarizeBorders( const ICurve* pCrv1, const ICurve* pCrv2, ISurfBezier* pSurfBz, double dTol) ;
// Vettori e Matrici di Curve Composite
typedef vector<CurveComposite> COMPOVECTOR ;
typedef vector<COMPOVECTOR> COMPOMATRIX ;
@@ -3959,7 +3961,7 @@ GetTrimmingSurfBzSyncPoints( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
#endif
// Definisco la superficie di Bezier rigata
PtrOwner<SurfBezier> pSBzRuled( GetBasicSurfBezier( GetSurfBezierRuled( pCompoEdge1, pCompoEdge2, ISurfBezier::RLT_B_MINDIST_PLUS, dMyLinTol))) ;
PtrOwner<SurfBezier> pSBzRuled( GetBasicSurfBezier( GetSurfBezierRuledSmooth( pCompoEdge1, pCompoEdge2, 10))) ;
if ( IsNull( pSBzRuled) || ! pSBzRuled->IsValid())
return false ;
@@ -4967,12 +4969,12 @@ typedef vector<PntInfo> PNTINFOVECTOR ;
//------------------------------------------------------------------------------
// Funzione per la regolarizzazione delle curve di bordo di una lavorazione di trim
// Le curve vengono modificate entro una data tolleranza, in modo che
bool
static bool
RegolarizeBorders( const ICurve* pCrv1, const ICurve* pCrv2, ISurfBezier* pSurfBz, double dTol)
{
#if DEBUG_SMOOTH_CURVATURE
VT.push_back( pSurfBz->Clone()) ;
VT.push_back( pCrv1->Clone()) ;
#endif
// le due curve sono compo di bezier, e tutte le sottocurve sono dello stesso grado (3)
PNTINFOVECTOR vPntInfo ;
@@ -5008,65 +5010,54 @@ RegolarizeBorders( const ICurve* pCrv1, const ICurve* pCrv2, ISurfBezier* pSurfB
for ( int i = 0 ; i < ssize( vPntInfo) ; ++i) {
if ( nCurrSide == 0)
nCurrSide = vPntInfo[i].nSide ;
int j = i == ssize( vPntInfo) ? 0 : i + 1 ;
if ( i > 2 && vPntInfo[i].nSide != nCurrSide && vPntInfo[i].nSide != 0) {
if ( c == 2 && vPntInfo[i].nSide != nCurrSide) {
// ho trovato due punti a cavallo di una giunzione che formano localmente un cambio di concavità da evitare
Vector3d vtMove ;
if ( vPntInfo[i].dDist > EPS_SMALL)
vtMove = vPntInfo[i].vtN * vPntInfo[i].dDist * 2 ;
else
vtMove = vPntInfo[i].vtN * vPntInfo[i-1].dDist * 2 ;
vPntInfo[i].pt = vPntInfo[i].pt + vtMove ;
}
//devo modificare sicuramente due curve
int k = i / 3 ;
if ( i % 3 == 0)
--k ;
// aggiungo la prima curva
CurveBezier cbPrev ;
cbPrev.Init( 3,false) ;
cbPrev.SetControlPoint( 0, vPntInfo[k*3].pt) ;
cbPrev.SetControlPoint( 0, vPntInfo[k*3+1].pt) ;
cbPrev.SetControlPoint( 0, vPntInfo[k*3+2].pt) ;
cbPrev.SetControlPoint( 0, vPntInfo[k*3+3].pt) ;
CC.AddCurve( cbPrev) ;
//aggiungo la seconda curva
CurveBezier cbNext ;
cbNext.Init( 3,false) ;
cbNext.SetControlPoint( 0, vPntInfo[k*3+3].pt) ;
cbNext.SetControlPoint( 0, vPntInfo[k*3+4].pt) ;
cbNext.SetControlPoint( 0, vPntInfo[k*3+5].pt) ;
cbNext.SetControlPoint( 0, vPntInfo[k*3+6].pt) ;
CC.AddCurve( cbNext) ;
int nFirst = i ;
int nSecond = nFirst == ssize( vPntInfo) ? 0 : nFirst + 1 ;
int nThird = nSecond == ssize( vPntInfo) ? 0 : nSecond + 1 ;
int nFourth = nThird == ssize( vPntInfo) ? 0 : nThird + 1 ;
if ( i > 2 && vPntInfo[nFirst].nSide != nCurrSide && vPntInfo[nFirst].nSide != 0) {
// devo verificare anche che sia uguale ai due successivi
if ( ( vPntInfo[nFirst].nSide == vPntInfo[nSecond].nSide || vPntInfo[nSecond].nSide == 0) &&
( vPntInfo[nFirst].nSide == vPntInfo[nThird].nSide || vPntInfo[nThird].nSide == 0)) {
// se il successivo al terzetto è diverso ho un terzetto anomalo da aggiustare
// altrimenti ho un cambio naturale di concavità
if ( vPntInfo[nFirst].nSide != vPntInfo[nFourth].nSide) {
// modifico due curve
CurveComposite CCToApprox ;
int nCurrSub = nFirst / 3 ;
if ( nFirst % 3 == 0)
--nCurrSub ;
CCToApprox.AddCurve( pCC1->CopyParamRange( nCurrSub, nCurrSub + 2)) ;
Vector3d vtStart ; pCC1->GetStartDir( vtStart) ;
Vector3d vtEnd ; pCC1->GetEndDir( vtEnd) ;
PtrOwner<ICurve> pCrvApprox( ApproxCurveWithBezier( &CCToApprox, dTol, vtStart, vtEnd)) ;
if ( ! IsNull( pCrvApprox))
CC.AddCurve( Release( pCrvApprox)) ;
else
return false ;
c = 0 ;
i = k + 6 ;
nCurrSide = vPntInfo[i].nSide ;
// scavalco i punti delle curve che ho appena modificato
i += 6 ;
}
c = 0 ;
nCurrSide = vPntInfo[i].nSide ;
}
else
++c ;
}
else {
++c ;
if ( i % 3 == 0)
CC.AddCurve( pCC1->GetCurve( i / 3)->Clone()) ;
if ( i != 0 && i % 3 == 0)
CC.AddCurve( pCC1->GetCurve( i / 3 - 1)->Clone()) ;
}
}
PtrOwner<ISurfBezier> pSB( CreateSurfBezier()) ;
pSB->CreateSmoothRuledByTwoCurves( pCrv1, pCrv2, 10) ;
//PtrOwner<ISurfBezier> pSB( CreateSurfBezier()) ;
//pSB->CreateSmoothRuledByTwoCurves( pCrv1, pCrv2, 10) ;
#if DEBUG_SMOOTH_CURVATURE
VT.push_back( pSB->Clone()) ;
VT.push_back( CC.Clone()) ;
VT.push_back( pSurfBz->Clone()) ;
SaveGeoObj( VT, "D:\\Temp\\bezier\\ruled\\smoothness\\regolarized.nge") ;
#endif
return true ;
}
//------------------------------------------------------------------------------
// Funzione per la regolarizzazione LOCALMENTE una curva di bordo
// Le curve vengono modificate entro una data tolleranza, in modo che
bool
RegolarizeBordersLocally( ICurve* pCrv, ISurfBezier* pSurfBz, double dTol)
{
return true ;
}