EgtGeomKernel :
- modifica a Trimming - sistemazioni estetiche varie.
This commit is contained in:
+65
-64
@@ -535,7 +535,7 @@ LineToBezierCurve( const ICurveLine* pCrvLine, int nDeg, bool bMakeRatOrNot)
|
||||
PtrOwner<ICurveBezier> pCrvBezier( CreateCurveBezier()) ;
|
||||
// rendo tutte le curve di grado 2 e razionali così posso convertire anche archi e avere tutte curve dello stesso grado e razionali
|
||||
pCrvBezier->Init( nDeg, true) ;
|
||||
if( ! pCrvBezier->FromLine( *pCrvLine))
|
||||
if ( ! pCrvBezier->FromLine( *pCrvLine))
|
||||
return nullptr ;
|
||||
if ( bMakeRatOrNot)
|
||||
pCrvBezier->MakeRational() ;
|
||||
@@ -1147,7 +1147,7 @@ FindSpan( double dU, int nDeg, const DBLVECTOR& vKnots, int& nSpan)
|
||||
return true ;
|
||||
}
|
||||
// trovo a quale span appartiene il parametro dU
|
||||
int nKnots = int( vKnots.size()) ;
|
||||
int nKnots = ssize( vKnots) ;
|
||||
if ( abs( dU - vKnots[nKnots-1]) < EPS_SMALL) {
|
||||
nSpan = nKnots - 1 - nDeg ;
|
||||
return true ;
|
||||
@@ -1173,7 +1173,7 @@ static bool
|
||||
CalcBasisFunc( double dU, int nSpan, int nDeg, const DBLVECTOR& vKnots, DBLVECTOR& vBasis)
|
||||
{
|
||||
// mi aspetto che il vettore vBasis sia di lunghezza nDeg + 1
|
||||
if ( vBasis.size() != nDeg + 1)
|
||||
if ( ssize( vBasis) != nDeg + 1)
|
||||
return false ;
|
||||
|
||||
vBasis[0] = 1 ;
|
||||
@@ -1312,7 +1312,7 @@ InterpolatePointSetWithBezier( const PNTVECTOR& vPnt, double dLinTol, double dMa
|
||||
int nItCount = 0 ;
|
||||
while ( dErr > dLinTol && nItCount < 10) {
|
||||
pCrvInt->Clear() ;
|
||||
int nPoints = int( vPnt.size()) ;
|
||||
int nPoints = ssize( vPnt) ;
|
||||
int nDeg = 3 ;
|
||||
if ( nPoints < 2)
|
||||
return nullptr ;
|
||||
@@ -1328,7 +1328,7 @@ InterpolatePointSetWithBezier( const PNTVECTOR& vPnt, double dLinTol, double dMa
|
||||
else if ( nPoints == 3) {
|
||||
// se ho solo tre punti uso un altro algoritmo
|
||||
CurveByInterp cbi ;
|
||||
for ( int i = 0 ; i < int( vPnt.size()) ; ++i)
|
||||
for ( int i = 0 ; i < ssize( vPnt) ; ++i)
|
||||
cbi.AddPoint( vPnt[i]) ;
|
||||
pCrvInt->AddCurve( cbi.GetCurve( CurveByInterp::AKIMA_CORNER, CurveByInterp::CUBIC_BEZIERS)) ;
|
||||
if ( ! IsNull( pCrvInt) && pCrvInt->IsValid())
|
||||
@@ -1360,7 +1360,7 @@ InterpolatePointSetWithBezier( const PNTVECTOR& vPnt, double dLinTol, double dMa
|
||||
}
|
||||
}
|
||||
|
||||
if ( vLen.size() != 0) {
|
||||
if ( ! vLen.empty()) {
|
||||
if ( nEnd == 0)
|
||||
nEnd = nPoints - 1 ;
|
||||
Vector3d vtStartDir = V_INVALID ;
|
||||
@@ -1402,9 +1402,9 @@ ParamByLen( const PNTVECTOR& vPnt, DBLVECTOR& vParam, int nFirst, int nLast)
|
||||
int nPoints = nLast - nFirst + 1 ;
|
||||
if ( nPoints < 2)
|
||||
return false ;
|
||||
if( ssize(vParam) == 0)
|
||||
if ( vParam.empty())
|
||||
vParam.resize( nPoints) ;
|
||||
if( vParam[nFirst] == 0 && vParam[nLast] == 1)
|
||||
if ( vParam[nFirst] == 0 && vParam[nLast] == 1)
|
||||
return true ;
|
||||
vParam[nFirst] = 0 ;
|
||||
for ( int i = nFirst + 1 ; i <= nLast ; ++i) {
|
||||
@@ -1420,8 +1420,8 @@ ParamByLen( const PNTVECTOR& vPnt, DBLVECTOR& vParam, int nFirst, int nLast)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurveBezier*
|
||||
ApproxPointSetWithSingleBezier( const PNTVECTOR& vPnt, int nFirst, int nLast, const Vector3d& vtStartDir, const Vector3d& vtEndDir,
|
||||
const DBLVECTOR& vParam)
|
||||
ApproxPointSetWithSingleBezier( const PNTVECTOR& vPnt, int nFirst, int nLast,
|
||||
const Vector3d& vtStartDir, const Vector3d& vtEndDir, const DBLVECTOR& vParam)
|
||||
{
|
||||
// cerco di approssimare un set di punti con una sola bezier cubica non razionale
|
||||
int nPoints = nLast - nFirst + 1 ;
|
||||
@@ -1435,7 +1435,7 @@ ApproxPointSetWithSingleBezier( const PNTVECTOR& vPnt, int nFirst, int nLast, co
|
||||
pCrvBez->SetControlPoint( 0, pt0) ;
|
||||
pCrvBez->SetControlPoint( 3, pt3) ;
|
||||
Eigen::Vector2d mA ;
|
||||
if( nPoints > 4) {
|
||||
if ( nPoints > 4) {
|
||||
// risoluzione sistema
|
||||
Eigen::Matrix2d mC ; mC.setZero() ;
|
||||
Eigen::Vector2d mX ; mX.setZero() ;
|
||||
@@ -1461,8 +1461,8 @@ ApproxPointSetWithSingleBezier( const PNTVECTOR& vPnt, int nFirst, int nLast, co
|
||||
}
|
||||
// l'algoritmo è fatto in modo che alpha1 e alpha2 siano positivi ( se tutto va bene)
|
||||
// io invece ho tenuto le tangenti con la direzione originale, quindi il primo dovrebbe essere positivo e il secondo negativo
|
||||
if ( mA(0) < 0 || mA(1) > 0 || nPoints < 4) {
|
||||
if( mA(0) < 0 || mA(1) > 0)
|
||||
if ( mA(0) < 0 || mA(1) > 0 || nPoints < 4) {
|
||||
if ( mA(0) < 0 || mA(1) > 0)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "valori di alfa sballati, potrebbe essere la spaziatura dismogenea tra punti")
|
||||
double dDistCorr = Dist( pt3, pt0) / 3 ;
|
||||
mA(0) = dDistCorr ;
|
||||
@@ -1480,14 +1480,15 @@ ApproxPointSetWithSingleBezier( const PNTVECTOR& vPnt, int nFirst, int nLast, co
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CalcPointSetApproxError( const PNTVECTOR& vPntOrig, const DBLVECTOR& vParam, int nFirst, int nLast, const ICurve* pCrvNew, double& dErr, int& nPointMaxErr)
|
||||
CalcPointSetApproxError( const PNTVECTOR& vPntOrig, const DBLVECTOR& vParam,
|
||||
int nFirst, int nLast, const ICurve* pCrvNew, double& dErr, int& nPointMaxErr)
|
||||
{
|
||||
dErr = 0 ;
|
||||
// calcolo l'errore di approssimazione
|
||||
for ( int i = nFirst ; i <= nLast ; ++i) {
|
||||
Point3d ptBez ; pCrvNew->GetPointD1D2( vParam[i], ICurve::Side::FROM_MINUS, ptBez) ;
|
||||
double dErrTemp = Dist( vPntOrig[i], ptBez) ;
|
||||
if( dErrTemp > dErr) {
|
||||
if ( dErrTemp > dErr) {
|
||||
dErr = dErrTemp ;
|
||||
nPointMaxErr = i ;
|
||||
}
|
||||
@@ -1498,19 +1499,20 @@ CalcPointSetApproxError( const PNTVECTOR& vPntOrig, const DBLVECTOR& vParam, int
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam, int nFirst, int nLast, const VCT3DVECTOR& vPrevDer, const VCT3DVECTOR& vNextDer, double dTol)
|
||||
FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam,
|
||||
int nFirst, int nLast, const VCT3DVECTOR& vPrevDer, const VCT3DVECTOR& vNextDer, double dTol)
|
||||
{
|
||||
ParamByLen(vPnt, vParam, nFirst, nLast) ;
|
||||
ParamByLen( vPnt, vParam, nFirst, nLast) ;
|
||||
PtrOwner<ICurveComposite> pCrvFit( CreateCurveComposite()) ;
|
||||
PtrOwner<ICurveBezier> pCrvBez( CreateCurveBezier()) ;
|
||||
double dErr = INFINITO ;
|
||||
double dErrSplit = dTol * 25 ;
|
||||
int nIter = 0 ;
|
||||
while ( dErr > dTol && nIter < 10) {
|
||||
if( dErr < INFINITO) {
|
||||
// riparametrizzo i punti
|
||||
while ( dErr > dTol && nIter < 10) {
|
||||
if ( dErr < INFINITO) {
|
||||
// riparametrizzo i punti
|
||||
for ( int i = nFirst + 1 ; i < nLast ; ++i) {
|
||||
//questo potrebbe diventare un while appena capisco di quanto si aggiusta il parametro ad ogni iterazione
|
||||
// questo potrebbe diventare un while appena capisco di quanto si aggiusta il parametro ad ogni iterazione
|
||||
double dCorr = 1 ;
|
||||
do {
|
||||
Vector3d vtDer1, vtDer2 ;
|
||||
@@ -1525,9 +1527,9 @@ FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam,
|
||||
}
|
||||
}
|
||||
|
||||
// fit della curva
|
||||
// fit della curva
|
||||
pCrvBez.Set( ApproxPointSetWithSingleBezier( vPnt, nFirst, nLast, vNextDer[nFirst], vPrevDer[nLast], vParam)) ;
|
||||
if( IsNull( pCrvBez) || ! pCrvBez->IsValid())
|
||||
if ( IsNull( pCrvBez) || ! pCrvBez->IsValid())
|
||||
return nullptr ;
|
||||
#if SAVEAPPROX
|
||||
SaveGeoObj( pCrvBez->Clone(), "D:\\Temp\\bezier\\approxWithBezier\\first_approx.nge") ;
|
||||
@@ -1535,8 +1537,8 @@ FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam,
|
||||
|
||||
int nPointMaxErr = 0 ;
|
||||
CalcPointSetApproxError( vPnt, vParam, nFirst, nLast, pCrvBez, dErr, nPointMaxErr) ;
|
||||
// se sto unendo due punti consecutivi e l'errore è oltre quello richiesto allora restituisco un segmento che unisce i punti
|
||||
if( nLast - nFirst == 1 && dErr > dTol) {
|
||||
// se sto unendo due punti consecutivi e l'errore è oltre quello richiesto allora restituisco un segmento che unisce i punti
|
||||
if ( nLast - nFirst == 1 && dErr > dTol) {
|
||||
CurveLine CL ; CL.Set( vPnt[nFirst], vPnt[nLast]) ;
|
||||
pCrvBez.Set( GetCurveBezier( CurveToBezierCurve( &CL))) ;
|
||||
dErr = 0 ;
|
||||
@@ -1544,12 +1546,12 @@ FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam,
|
||||
|
||||
++nIter ;
|
||||
bool bSplit = false ;
|
||||
if( nIter == 10 && dErr > dTol)
|
||||
if ( nIter == 10 && dErr > dTol)
|
||||
bSplit = true ;
|
||||
// se la curva di approssimazione è ancora molto lontana dalla curva originale allora divido il set di punti in due
|
||||
if ( dErr > dErrSplit || bSplit) {
|
||||
// se la curva di approssimazione è ancora molto lontana dalla curva originale allora divido il set di punti in due
|
||||
if ( dErr > dErrSplit || bSplit) {
|
||||
if ( nLast - nFirst > 1) {
|
||||
if( ! pCrvFit->AddCurve( FitWithBezier( pCrvOrig, vPnt, vParam, nFirst, nPointMaxErr, vPrevDer, vNextDer,dTol)) ||
|
||||
if ( ! pCrvFit->AddCurve( FitWithBezier( pCrvOrig, vPnt, vParam, nFirst, nPointMaxErr, vPrevDer, vNextDer,dTol)) ||
|
||||
! pCrvFit->AddCurve( FitWithBezier( pCrvOrig, vPnt, vParam, nPointMaxErr, nLast, vPrevDer, vNextDer, dTol)))
|
||||
return nullptr ;
|
||||
break ;
|
||||
@@ -1561,20 +1563,19 @@ FitWithBezier( const ICurve* pCrvOrig, const PNTVECTOR& vPnt, DBLVECTOR& vParam,
|
||||
|
||||
if ( pCrvFit->GetCurveCount() > 0)
|
||||
return Release( pCrvFit) ;
|
||||
else if ( dErr < dTol && ! IsNull( pCrvBez) && pCrvBez->IsValid())
|
||||
else if ( dErr < dTol && ! IsNull( pCrvBez) && pCrvBez->IsValid())
|
||||
return Release( pCrvBez) ;
|
||||
else
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
static int nCrvPassed = 0 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
ApproxCurveWithBezier( const ICurve* pCrv , double dTol, int nType)
|
||||
{
|
||||
|
||||
#if SAVECURVEPASSED
|
||||
static int nCrvPassed = 0 ;
|
||||
SaveGeoObj( pCrv->Clone(), "D:\\Temp\\bezier\\approxWithBezier\\CurveDaApprossimare\\"+ToString(nCrvPassed) + ".nge") ;
|
||||
++nCrvPassed ;
|
||||
#endif
|
||||
@@ -1595,7 +1596,7 @@ ApproxCurveWithBezier( const ICurve* pCrv , double dTol, int nType)
|
||||
PNTVECTOR vPnt ;
|
||||
Point3d pt ; plApprox.GetFirstPoint( pt) ;
|
||||
do {
|
||||
if ( ssize(vPnt) != 0) {
|
||||
if ( ! vPnt.empty()) {
|
||||
vPnt.push_back( Media(vPnt.back(), pt,1./3.)) ;
|
||||
vPnt.push_back( Media(vPnt.back(), pt,2./3.)) ;
|
||||
}
|
||||
@@ -1604,9 +1605,9 @@ ApproxCurveWithBezier( const ICurve* pCrv , double dTol, int nType)
|
||||
} while ( plApprox.GetNextPoint( pt)) ;
|
||||
|
||||
// calcolo la curvatura nei vari punti per identificare zone a curvatura costante
|
||||
DBLVECTOR vCrvVal( ssize(vPnt)) ;
|
||||
DBLVECTOR vCrvVal( ssize( vPnt)) ;
|
||||
DBLVECTOR vRad ( ssize( vPnt)) ;
|
||||
for( int i = 1 ; i < ssize( vPnt) - 1 ; ++i) {
|
||||
for ( int i = 1 ; i < ssize( vPnt) - 1 ; ++i) {
|
||||
Vector3d vtA = vPnt[i] - vPnt[i-1] ;
|
||||
Vector3d vtB = vPnt[i+1] - vPnt[i-1] ;
|
||||
double dR = ( vtA.Len() * vtB.Len() * ( vtA - vtB).Len()) / ( 2 * (vtA ^ vtB).Len()) ;
|
||||
@@ -1631,7 +1632,7 @@ ApproxCurveWithBezier( const ICurve* pCrv , double dTol, int nType)
|
||||
nStart = nEnd ;
|
||||
++nEnd ;
|
||||
}
|
||||
if( ssize(vConstCurv) == 0)
|
||||
if ( vConstCurv.empty())
|
||||
vConstCurv.emplace_back( 0, ssize( vPnt) - 1) ;
|
||||
|
||||
int nPoints = ssize( vPnt) ;
|
||||
@@ -1644,20 +1645,20 @@ ApproxCurveWithBezier( const ICurve* pCrv , double dTol, int nType)
|
||||
VCT3DVECTOR vNextDer ;
|
||||
ComputeAkimaTangents( false, vParam, vPnt, vPrevDer, vNextDer) ;
|
||||
//normalizzo tutte le derivate
|
||||
for( int i = 0 ; i < ssize( vPrevDer) ; ++i) {
|
||||
for ( int i = 0 ; i < ssize( vPrevDer) ; ++i) {
|
||||
vPrevDer[i].Normalize() ;
|
||||
vNextDer[i].Normalize() ;
|
||||
}
|
||||
|
||||
PtrOwner<ICurveComposite> pCCApproxTot( CreateCurveComposite()) ;
|
||||
for( INTINT iiSE : vConstCurv) {
|
||||
for ( INTINT iiSE : vConstCurv) {
|
||||
nFirst = iiSE.first ;
|
||||
nLast = iiSE.second ;
|
||||
//definisco la bezier che vado a raffinare iterativamente
|
||||
PtrOwner<ICurve> pCApprox( FitWithBezier( pCrv, vPnt, vParam, nFirst, nLast, vPrevDer, vNextDer, dTol)) ;
|
||||
if( IsNull( pCApprox) || ! pCApprox->IsValid())
|
||||
if ( IsNull( pCApprox) || ! pCApprox->IsValid())
|
||||
return nullptr ;
|
||||
if( ! pCCApproxTot->AddCurve( Release( pCApprox)))
|
||||
if ( ! pCCApproxTot->AddCurve( Release( pCApprox)))
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
@@ -1668,7 +1669,7 @@ ApproxCurveWithBezier( const ICurve* pCrv , double dTol, int nType)
|
||||
bool
|
||||
CalcApproxError( const ICurve* pCrvOri, const ICurve* pCrvNew, double& dErr, int nPoints)
|
||||
{
|
||||
if( pCrvOri == nullptr || ! pCrvOri->IsValid() || pCrvNew == nullptr || ! pCrvNew->IsValid()){
|
||||
if ( pCrvOri == nullptr || ! pCrvOri->IsValid() || pCrvNew == nullptr || ! pCrvNew->IsValid()){
|
||||
dErr = INFINITO ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1753,7 +1754,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
{
|
||||
// se con nodi extra
|
||||
if ( cnData.bExtraKnotes) {
|
||||
int nKnotesNbr = int( cnData.vU.size()) ;
|
||||
int nKnotesNbr = ssize( cnData.vU) ;
|
||||
if ( nKnotesNbr < 4)
|
||||
return false ;
|
||||
cnData.bExtraKnotes = false ;
|
||||
@@ -1767,7 +1768,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
bool bAlreadyChecked = false ;
|
||||
// se la curva è peridica verifco che effettivamente ci sia un numero di punti ripetituti uguale al grado della curva
|
||||
// wrap della curva su se stessa
|
||||
if ( cnData.bPeriodic && (int(cnData.vU.size()) > int(cnData.vCP.size()) + cnData.nDeg - 1)) {
|
||||
if ( cnData.bPeriodic && ( ssize( cnData.vU) > ssize( cnData.vCP) + cnData.nDeg - 1)) {
|
||||
bool bRepeated = true ;
|
||||
for ( int i = 0 ; i < cnData.nDeg ; ++i) {
|
||||
if ( ! AreSamePointApprox( cnData.vCP[i], cnData.vCP.end()[-cnData.nDeg + i]) ) {
|
||||
@@ -1776,11 +1777,11 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
}
|
||||
}
|
||||
bool bFirstAddedAtEnd = false ;
|
||||
if ( ! bRepeated || (bRepeated && AreSamePointApprox( cnData.vCP[0],cnData.vCP[cnData.nDeg]))){
|
||||
if ( ! bRepeated || ( bRepeated && AreSamePointApprox( cnData.vCP[0], cnData.vCP[cnData.nDeg]))) {
|
||||
// salvo il vettore dei nodi in caso mi accorga di avere tra le mani una curva unclamped
|
||||
DBLVECTOR vU = cnData.vU ;
|
||||
// se effettivamente ho dei nodi in più da togliere allora li tolgo ed eventualmente aggiungo punti di controllo
|
||||
if ( int(cnData.vU.size()) > int(cnData.vCP.size()) + cnData.nDeg - 1 ) {
|
||||
if ( ssize( cnData.vU) > ssize( cnData.vCP) + cnData.nDeg - 1 ) {
|
||||
// se il primo e l'ultimo punto non coincidono allora aggiungo il primo punto in fondo al vettore dei punti di controllo
|
||||
if ( ! AreSamePointApprox( cnData.vCP[0], cnData.vCP.back())) {
|
||||
bFirstAddedAtEnd = true ;
|
||||
@@ -1792,11 +1793,11 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
cnData.vU = DBLVECTOR( cnData.vU.begin(), cnData.vU.end() - cnData.nDeg) ;
|
||||
// controllo eventualmente anche i nodi extra
|
||||
// se ne ho due in più ne tolgo uno in cima e uno in fondo
|
||||
if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg + 1 ) { // significa che ci sono due nodi extra, uno all'inizio e uno alla fine, da togliere
|
||||
if ( ssize( cnData.vU) == ssize( cnData.vCP) + cnData.nDeg + 1) { // significa che ci sono due nodi extra, uno all'inizio e uno alla fine, da togliere
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end() - 1) ;
|
||||
}
|
||||
// se ne ho solo uno in più lo tolgo in cima
|
||||
else if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg) {
|
||||
else if ( ssize( cnData.vU) == ssize( cnData.vCP) + cnData.nDeg) {
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end()) ;
|
||||
}
|
||||
}
|
||||
@@ -1823,7 +1824,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
// recupero il vettore dei nodi
|
||||
cnData.vU = vU ;
|
||||
// verifico se ho nodi extra
|
||||
if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg + 1 ) {
|
||||
if ( ssize( cnData.vU) == ssize( cnData.vCP) + cnData.nDeg + 1 ) {
|
||||
// significa che ci sono due nodi extra:
|
||||
// se la curva ha grado maggiore di 1 e i primi due nodi sono uguali allora tolgo quelli
|
||||
if ( cnData.nDeg > 1 && abs(cnData.vU[1] - cnData.vU[0]) < EPS_SMALL) {
|
||||
@@ -1834,7 +1835,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end() - 1) ;
|
||||
}
|
||||
// se ne ho solo uno in più lo tolgo in cima
|
||||
else if ( cnData.vU.size() == int( cnData.vCP.size()) + cnData.nDeg)
|
||||
else if ( ssize( cnData.vU) == ssize( cnData.vCP) + cnData.nDeg)
|
||||
cnData.vU = vector<double>( cnData.vU.begin() + 1, cnData.vU.end()) ;
|
||||
}
|
||||
bAlreadyChecked = true ;
|
||||
@@ -1859,7 +1860,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
// qui aggiungo un controllo se la curva è collassata in un punto ( ho un polo), lascio stare
|
||||
bool bCollapsed = true ;
|
||||
Point3d ptFirst = cnData.vCP.front() ;
|
||||
for ( int i = 1 ; i < int( cnData.vCP.size()) ; ++i) {
|
||||
for ( int i = 1 ; i < ssize( cnData.vCP) ; ++i) {
|
||||
if ( ! AreSamePointApprox( ptFirst, cnData.vCP[i])) {
|
||||
bCollapsed = false ;
|
||||
break ;
|
||||
@@ -1876,7 +1877,7 @@ NurbsCurveCanonicalize( CNurbsData& cnData)
|
||||
// agli indici perché uso u_p-1 e u_(m-p+1), anziché u_p e u_m-p
|
||||
|
||||
// comincio ad aumentare la molteplictià del nodo u_m-p+1
|
||||
int nCP = int( cnData.vCP.size()) ;
|
||||
int nCP = ssize( cnData.vCP) ;
|
||||
int nU = nCP + cnData.nDeg - 1 ;
|
||||
int nDeg = cnData.nDeg ;
|
||||
PNTVECTOR vBC ;
|
||||
@@ -2072,9 +2073,9 @@ NurbsToBezierCurve( const CNurbsData& cnData)
|
||||
if ( cnData.bPeriodic || cnData.bExtraKnotes)
|
||||
return nullptr ;
|
||||
// numero dei nodi
|
||||
int nU = int( cnData.vCP.size()) + cnData.nDeg - 1 ;
|
||||
int nU = ssize( cnData.vCP) + cnData.nDeg - 1 ;
|
||||
// controllo relazione nodi - punti di controllo
|
||||
if ( nU != int( cnData.vU.size()))
|
||||
if ( nU != ssize( cnData.vU))
|
||||
return nullptr ;
|
||||
// numero degli intervalli
|
||||
int nInt = nU - 2 * cnData.nDeg + 1 ;
|
||||
@@ -2444,7 +2445,7 @@ CalcCurvesVoronoiDiagram( const CICURVEPVECTOR& vCrvC, ICURVEPOVECTOR& vCrvs, in
|
||||
PtrOwner<Voronoi> pVoronoiObj( new( std::nothrow) Voronoi()) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vCrvC.size()) ; i ++) {
|
||||
for ( int i = 0 ; i < ssize( vCrvC) ; i ++) {
|
||||
if ( ! pVoronoiObj->AddCurve( vCrvC[i]))
|
||||
return false ;
|
||||
}
|
||||
@@ -2471,7 +2472,7 @@ CalcCurvesMedialAxis( const CICURVEPVECTOR& vCrvC, ICURVEPOVECTOR& vCrvs, int nS
|
||||
PtrOwner<Voronoi> pVoronoiObj( new( std::nothrow) Voronoi()) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vCrvC.size()) ; i ++) {
|
||||
for ( int i = 0 ; i < ssize( vCrvC) ; i ++) {
|
||||
if ( ! pVoronoiObj->AddCurve( vCrvC[i]))
|
||||
return false ;
|
||||
}
|
||||
@@ -2532,7 +2533,7 @@ bool CalcOffsetCurves( const ICURVEPVECTOR& vpCrvs, ICURVEPOVECTOR& vCrvs, doubl
|
||||
PtrOwner<Voronoi> pVoronoiObj( new( std::nothrow) Voronoi()) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; i ++) {
|
||||
for ( int i = 0 ; i < ssize( vpCrvs) ; i ++) {
|
||||
if ( ! pVoronoiObj->AddCurve( vpCrvs[i]))
|
||||
return false ;
|
||||
}
|
||||
@@ -2562,7 +2563,7 @@ bool CalcFatOffsetCurves( const ICURVEPVECTOR& vpCrvs, ICURVEPOVECTOR& vCrvs, do
|
||||
PtrOwner<Voronoi> pVoronoiObj( new( std::nothrow) Voronoi()) ;
|
||||
if ( pVoronoiObj == nullptr)
|
||||
return false ;
|
||||
for ( int i = 0 ; i < int( vpCrvs.size()) ; i ++) {
|
||||
for ( int i = 0 ; i < ssize( vpCrvs) ; i ++) {
|
||||
if ( ! pVoronoiObj->AddCurve( vpCrvs[i]))
|
||||
return false ;
|
||||
}
|
||||
@@ -2596,7 +2597,7 @@ ResetCurveVoronoi( const ICurve& crvC)
|
||||
bool
|
||||
GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert)
|
||||
{
|
||||
if( ssize( vCrv) == 1)
|
||||
if ( ssize( vCrv) == 1)
|
||||
return true ;
|
||||
ChainCurves chainCrv ;
|
||||
// modifico direttamente le curve passate in input
|
||||
@@ -2616,22 +2617,22 @@ GetChainedCurves( ICRVCOMPOPOVECTOR& vCrv, double dChainTol, bool bAllowInvert)
|
||||
ICurveComposite* pFirstCrv = vCrv[abs(vIds[0]) - 1] ;
|
||||
for ( int nId : vIds) {
|
||||
bool bInvert = false ;
|
||||
if( nId < 0)
|
||||
if ( nId < 0)
|
||||
bInvert = true ;
|
||||
nId = abs( nId) - 1 ;
|
||||
if( bInvert)
|
||||
if ( bInvert)
|
||||
vCrv[nId]->Invert() ;
|
||||
if( ! pFirstCrv->AddCurve( Release( vCrv[nId]), true, dChainTol))
|
||||
if ( ! pFirstCrv->AddCurve( Release( vCrv[nId]), true, dChainTol))
|
||||
return false ;
|
||||
}
|
||||
pFirstCrv->GetEndPoint( ptStart) ;
|
||||
}
|
||||
// elimino gli elementi del vettore che non contengono più curve
|
||||
int c = ssize( vCrv) ;
|
||||
while( c > -1) {
|
||||
if( IsNull( vCrv[c]))
|
||||
while ( c > -1) {
|
||||
if ( IsNull( vCrv[c]))
|
||||
vCrv.erase( vCrv.begin() + c) ;
|
||||
--c ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ DistPointCrvBezier::DistPointCrvBezier( const Point3d& ptP, const ICurveBezier&
|
||||
// distanza non calcolata
|
||||
m_dDist = - 1 ;
|
||||
|
||||
if ( &CrvBez == nullptr || ! CrvBez.IsValid())
|
||||
if ( ! CrvBez.IsValid())
|
||||
return ;
|
||||
|
||||
// determino tolleranza di approssimazione in base a ingombro curva
|
||||
|
||||
+11
-10
@@ -23,10 +23,10 @@ using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
DistPointSurfBz::DistPointSurfBz( const Point3d& ptP, const ISurfBezier& pSrfBz)
|
||||
: m_dDist( -1), m_bIsInside( false)
|
||||
: m_dDist( -1), m_bIsInside( false), m_bIsSurfClosed( false)
|
||||
{
|
||||
// Bezier non valida
|
||||
if ( &pSrfBz == nullptr || ! pSrfBz.IsValid())
|
||||
if ( ! pSrfBz.IsValid())
|
||||
return ;
|
||||
// Calcolo la distanza
|
||||
Calculate( ptP, pSrfBz) ;
|
||||
@@ -37,9 +37,9 @@ void
|
||||
DistPointSurfBz::Calculate( const Point3d& ptP, const ISurfBezier& srfBz)
|
||||
{
|
||||
// Inizializzo distanza non calcolata
|
||||
m_dDist = - 1. ;
|
||||
m_dDist = -1 ;
|
||||
|
||||
// Controllo se la superficie è chiusa
|
||||
// Controllo se la superficie è chiusa
|
||||
m_bIsSurfClosed = srfBz.IsClosed() ;
|
||||
|
||||
// Lavoro con l'oggetto superficie trimesh di base
|
||||
@@ -49,17 +49,17 @@ DistPointSurfBz::Calculate( const Point3d& ptP, const ISurfBezier& srfBz)
|
||||
|
||||
DistPointSurfTm dpst( ptP, *pStmRef) ;
|
||||
|
||||
//recupero il punto a distanza minima sulla trimesh e lo raffino, prima di restituire distanza e punto minimo
|
||||
// recupero il punto a distanza minima sulla trimesh e lo raffino, prima di restituire distanza e punto minimo
|
||||
Point3d ptMinTm ; dpst.GetMinDistPoint( ptMinTm) ;
|
||||
int nT ; dpst.GetMinDistTriaIndex( nT) ;
|
||||
//salvo il punto corrispondente nel parametrico
|
||||
// salvo il punto corrispondente nel parametrico
|
||||
srfBz.UnprojectPointFromStm( nT, ptMinTm, m_ptParam) ;
|
||||
// salvo il punto a minima distanza sulla superficie e la normale alla superficie in quel punto
|
||||
srfBz.GetPointNrmD1D2( m_ptParam.x, m_ptParam.y, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, m_ptMinDistPoint, m_vtN) ;
|
||||
|
||||
// salvo la distanza minima
|
||||
m_dDist = Dist( ptP, m_ptMinDistPoint) ;
|
||||
// se il punto è sulla superficie
|
||||
// se il punto è sulla superficie
|
||||
if ( m_dDist < EPS_SMALL) {
|
||||
m_bIsInside = false ;
|
||||
return ;
|
||||
@@ -96,13 +96,14 @@ DistPointSurfBz::GetMinDistPoint( Point3d& ptMinDistPoint) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
DistPointSurfBz::GetParamPoint( Point3d& ptParamPoint) const
|
||||
DistPointSurfBz::GetParamsAtMinDistPoint( double& dU, double& dV) const
|
||||
{
|
||||
// Distanza non valida
|
||||
if ( m_dDist < -EPS_ZERO)
|
||||
return false ;
|
||||
// Distanza valida
|
||||
ptParamPoint = m_ptParam ;
|
||||
dU = m_ptParam.x ;
|
||||
dV = m_ptParam.y ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -116,4 +117,4 @@ DistPointSurfBz::GetNorm( Vector3d& vtN) const
|
||||
// Distanza valida
|
||||
vtN = m_vtN ;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,8 +296,8 @@ int
|
||||
IntersCurveCurve::GetInters3DCount( void)
|
||||
{
|
||||
int nCount = 0 ;
|
||||
for( int i = 0 ; i < m_nIntersCount ; ++i) {
|
||||
if( ! m_Info[i].bOverlap || ( m_Info[i].bOverlap && m_Info[i].bCBOverEq)) {
|
||||
for ( int i = 0 ; i < m_nIntersCount ; ++i) {
|
||||
if ( ! m_Info[i].bOverlap || ( m_Info[i].bOverlap && m_Info[i].bCBOverEq)) {
|
||||
if ( abs( m_Info[i].IciA[0].ptI.z - m_Info[i].IciB[0].ptI.z) < EPS_SMALL)
|
||||
++nCount ;
|
||||
}
|
||||
@@ -365,8 +365,8 @@ IntersCurveCurve::GetInt3DCrvCrvInfo( int nInd, IntCrvCrvInfo& aInfo)
|
||||
if ( nInd < 0 || nInd >= GetInters3DCount())
|
||||
return false ;
|
||||
int nCount = - 1 ;
|
||||
for( int i = 0 ; i < m_nIntersCount ; ++i) {
|
||||
if( ! m_Info[i].bOverlap || ( m_Info[i].bOverlap && m_Info[i].bCBOverEq)) {
|
||||
for ( int i = 0 ; i < m_nIntersCount ; ++i) {
|
||||
if ( ! m_Info[i].bOverlap || ( m_Info[i].bOverlap && m_Info[i].bCBOverEq)) {
|
||||
if ( abs( m_Info[i].IciA[0].ptI.z - m_Info[i].IciB[0].ptI.z) < EPS_SMALL)
|
||||
++nCount ;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ IntersCurveCurve::GetInt3DCrvCrvInfo( int nInd, IntCrvCrvInfo& aInfo)
|
||||
if ( abs( m_Info[i].IciA[0].ptI.z - m_Info[i].IciB[1].ptI.z) < EPS_SMALL)
|
||||
++nCount ;
|
||||
}
|
||||
if( nCount == nInd) {
|
||||
if ( nCount == nInd) {
|
||||
aInfo = m_Info[nInd] ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
+99
-52
@@ -19,6 +19,7 @@
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfBz.h"
|
||||
#include "/EgtDev/Include/EGkIntersPlanePlane.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
@@ -92,6 +93,8 @@ AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
Pt5ax.ptP = ptInt - vtLine1 / dLen1 * 2 * EPS_SMALL ;
|
||||
Pt5ax.vtDir1 = vPt5ax[j].vtDir1 ;
|
||||
Pt5ax.vtDir2 = vPt5ax[j].vtDir2 ;
|
||||
Pt5ax.vtDirU = vPt5ax[j].vtDirU ;
|
||||
Pt5ax.vtDirV = vPt5ax[j].vtDirV ;
|
||||
Pt5ax.dPar = ( vPt5ax[i].dPar + vPt5ax[j].dPar) / 2 ;
|
||||
Pt5ax.nFlag = P5AX_CVEX ;
|
||||
vPt5ax.insert( vPt5ax.begin() + i, Pt5ax) ;
|
||||
@@ -104,6 +107,8 @@ AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
Pt5ax.ptP = ptInt + vtLine2 / dLen2 * 2 * EPS_SMALL ;
|
||||
Pt5ax.vtDir1 = vPt5ax[i].vtDir1 ;
|
||||
Pt5ax.vtDir2 = vPt5ax[i].vtDir2 ;
|
||||
Pt5ax.vtDirU = vPt5ax[i].vtDirU ;
|
||||
Pt5ax.vtDirV = vPt5ax[i].vtDirV ;
|
||||
Pt5ax.dPar = ( vPt5ax[i].dPar + vPt5ax[j].dPar) / 2 ;
|
||||
Pt5ax.nFlag = P5AX_CVEX ;
|
||||
vPt5ax.insert( vPt5ax.begin() + i, Pt5ax) ;
|
||||
@@ -118,6 +123,8 @@ AddPointsOnCorners( PNT5AXVECTOR& vPt5ax)
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = Media( vPt5ax[i].vtDir1, vPt5ax[j].vtDir1) ; Pt5ax.vtDir1.Normalize() ;
|
||||
Pt5ax.vtDir2 = Media( vPt5ax[i].vtDir2, vPt5ax[j].vtDir2) ; Pt5ax.vtDir2.Normalize() ;
|
||||
Pt5ax.vtDirU = Media( vPt5ax[i].vtDirU, vPt5ax[j].vtDirU) ; Pt5ax.vtDirU.Normalize() ;
|
||||
Pt5ax.vtDirV = Media( vPt5ax[i].vtDirV, vPt5ax[j].vtDirV) ; Pt5ax.vtDirV.Normalize() ;
|
||||
Pt5ax.dPar = ( vPt5ax[i].dPar + vPt5ax[j].dPar) / 2 ;
|
||||
Pt5ax.nFlag = P5AX_CONC ;
|
||||
vPt5ax.insert( vPt5ax.begin() + i, Pt5ax) ;
|
||||
@@ -233,23 +240,55 @@ RemovePointsInExcess( PNT5AXVECTOR& vPt5ax, double dLinTol, double dMaxSegmLen,
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, double dPar, Point5ax& Pt5ax)
|
||||
static const SurfTriMesh*
|
||||
MyGetAuxSurf( const ISurf* pSrf)
|
||||
{
|
||||
// punto sulle supefici a minima distanza
|
||||
if ( pSrf == nullptr)
|
||||
return nullptr ;
|
||||
switch ( pSrf->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
return GetBasicSurfTriMesh( pSrf) ;
|
||||
case SRF_FLATRGN :
|
||||
return GetBasicSurfFlatRegion( pSrf)->GetAuxSurf() ;
|
||||
case SRF_BEZIER :
|
||||
return GetBasicSurfBezier( pSrf)->GetAuxSurf() ;
|
||||
default :
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
ProjectPointOnSurf( const Point3d& ptP, const CISURFPVECTOR& vpSurf, double dPar, Point5ax& Pt5ax)
|
||||
{
|
||||
// punto sulle superfici a minima distanza
|
||||
int nSurfMin = -1 ;
|
||||
int nTriaMin ;
|
||||
int nTriaMin = -1 ;
|
||||
double dUMin = -1, dVMin = -1 ;
|
||||
Point3d ptMin ;
|
||||
double dMinDist ;
|
||||
for ( int i = 0 ; i < ssize( vpStm) ; ++ i) {
|
||||
double dMinDist = NAN ;
|
||||
for ( int i = 0 ; i < ssize( vpSurf) ; ++ i) {
|
||||
// punto sulla superficie a minima distanza
|
||||
DistPointSurfTm dPS( ptP, *vpStm[i]) ;
|
||||
double dDist ;
|
||||
if ( dPS.GetDist( dDist) && ( nSurfMin == -1 || dDist < dMinDist)) {
|
||||
nSurfMin = i ;
|
||||
dPS.GetMinDistPoint( ptMin) ;
|
||||
dPS.GetMinDistTriaIndex ( nTriaMin) ;
|
||||
dMinDist = dDist ;
|
||||
int nSrfType = ( vpSurf[i] != nullptr ? vpSurf[i]->GetType() : GEO_NONE) ;
|
||||
if ( nSrfType == SRF_TRIMESH || nSrfType == SRF_FLATRGN) {
|
||||
DistPointSurfTm dPS( ptP, *MyGetAuxSurf( vpSurf[i])) ;
|
||||
double dDist ;
|
||||
if ( dPS.GetDist( dDist) && ( nSurfMin == -1 || dDist < dMinDist)) {
|
||||
nSurfMin = i ;
|
||||
dPS.GetMinDistPoint( ptMin) ;
|
||||
dPS.GetMinDistTriaIndex ( nTriaMin) ;
|
||||
dMinDist = dDist ;
|
||||
}
|
||||
}
|
||||
else if ( nSrfType == SRF_BEZIER) {
|
||||
DistPointSurfBz dPS( ptP, *GetBasicSurfBezier( vpSurf[i])) ;
|
||||
double dDist ;
|
||||
if ( dPS.GetDist( dDist) && ( nSurfMin == -1 || dDist < dMinDist)) {
|
||||
nSurfMin = i ;
|
||||
dPS.GetMinDistPoint( ptMin) ;
|
||||
dPS.GetParamsAtMinDistPoint( dUMin, dVMin) ;
|
||||
dMinDist = dDist ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,19 +296,44 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, double dPar
|
||||
if ( nSurfMin >= 0) {
|
||||
// assegno il punto
|
||||
Point3d ptInt = ptMin ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! vpStm[nSurfMin]->GetTriangle( nTriaMin, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptMin, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtN ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// calcolo gli altri dati
|
||||
int nSrfType = ( vpSurf[nSurfMin] != nullptr ? vpSurf[nSurfMin]->GetType() : GEO_NONE) ;
|
||||
if ( nSrfType == SRF_TRIMESH || nSrfType == SRF_FLATRGN) {
|
||||
// recupero superficie trimesh
|
||||
const SurfTriMesh* pSurfTm = MyGetAuxSurf( vpSurf[nSurfMin]) ;
|
||||
// calcolo la normale (si calcola smooth, in caso di errore si prende quella del triangolo)
|
||||
Triangle3dEx trTria ;
|
||||
if ( ! pSurfTm->GetTriangle( nTriaMin, trTria))
|
||||
return false ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcNormal( ptMin, trTria, vtN))
|
||||
vtN = trTria.GetN() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtN ;
|
||||
Pt5ax.vtDirU = V_NULL ;
|
||||
Pt5ax.vtDirV = V_NULL ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
}
|
||||
else if ( nSrfType == SRF_BEZIER) {
|
||||
Point3d ptSB ;
|
||||
Vector3d vtN, vtDerU, vtDerV ;
|
||||
if ( ! GetBasicSurfBezier( vpSurf[nSurfMin])->GetPointNrmD1D2( dUMin, dVMin, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS,
|
||||
ptSB, vtN, &vtDerU, &vtDerV))
|
||||
return false ;
|
||||
vtDerU.Normalize() ;
|
||||
vtDerV.Normalize() ;
|
||||
// assegno valori al punto 5assi
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtN ;
|
||||
Pt5ax.vtDirU = vtDerU ;
|
||||
Pt5ax.vtDirV = vtDerV ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
}
|
||||
// ritorno con successo
|
||||
return true ;
|
||||
}
|
||||
@@ -282,31 +346,6 @@ bool
|
||||
ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf,
|
||||
double dLinTol, double dMaxSegmLen, bool bSharpEdges, PNT5AXVECTOR& vPt5ax)
|
||||
{
|
||||
// sistemazioni per tipo di superficie
|
||||
CISRFTMPVECTOR vpSurfTm ;
|
||||
for ( int i = 0 ; i < ssize( vpSurf) ; ++ i) {
|
||||
const SurfTriMesh* pSurfTm = nullptr ;
|
||||
switch ( vpSurf[i]->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
pSurfTm = GetBasicSurfTriMesh( vpSurf[i]) ;
|
||||
break ;
|
||||
case SRF_BEZIER :
|
||||
{ double dOldLinTol = GetSurfBezierAuxSurfRefinedTol() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( GetSurfBezierTol( dLinTol)) ;
|
||||
pSurfTm = GetBasicSurfBezier( vpSurf[i])->GetAuxSurfRefined() ;
|
||||
SetSurfBezierAuxSurfRefinedTol( dOldLinTol) ;
|
||||
} break ;
|
||||
case SRF_FLATRGN :
|
||||
pSurfTm = GetBasicSurfFlatRegion( vpSurf[i])->GetAuxSurf() ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
if ( pSurfTm == nullptr)
|
||||
return false ;
|
||||
vpSurfTm.emplace_back( pSurfTm) ;
|
||||
}
|
||||
|
||||
// controllo le tolleranze
|
||||
dLinTol = max( dLinTol, LIN_TOL_MIN) ;
|
||||
dMaxSegmLen = max( dMaxSegmLen, 10 * EPS_SMALL) ;
|
||||
@@ -331,7 +370,7 @@ ProjectCurveOnSurf( const ICurve& crCrv, const CISURFPVECTOR& vpSurf,
|
||||
while ( bFound) {
|
||||
// se trovo proiezione, la salvo
|
||||
Point5ax Pt5ax ;
|
||||
if ( ProjectPointOnSurf( ptP, vpSurfTm, dPar, Pt5ax))
|
||||
if ( ProjectPointOnSurf( ptP, vpSurf, dPar, Pt5ax))
|
||||
vPt5ax.emplace_back( Pt5ax) ;
|
||||
// passo al successivo
|
||||
bFound = PL.GetNextUPoint( &dPar, &ptP) ;
|
||||
@@ -403,6 +442,8 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const Frame
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = frRefLine.VersZ() ;
|
||||
Pt5ax.vtDirU = V_NULL ;
|
||||
Pt5ax.vtDirV = V_NULL ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
@@ -557,6 +598,8 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const IGeoP
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.vtDirU = V_NULL ;
|
||||
Pt5ax.vtDirV = V_NULL ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
@@ -696,6 +739,8 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const ICurv
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtLine ;
|
||||
Pt5ax.vtDirU = V_NULL ;
|
||||
Pt5ax.vtDirV = V_NULL ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
@@ -852,6 +897,8 @@ ProjectPointOnSurf( const Point3d& ptP, const CISRFTMPVECTOR& vpStm, const SurfT
|
||||
Pt5ax.ptP = ptInt ;
|
||||
Pt5ax.vtDir1 = vtN ;
|
||||
Pt5ax.vtDir2 = vtN2 ;
|
||||
Pt5ax.vtDirU = V_NULL ;
|
||||
Pt5ax.vtDirV = V_NULL ;
|
||||
Pt5ax.dPar = dPar ;
|
||||
Pt5ax.nFlag = P5AX_STD ;
|
||||
// ritorno con successo
|
||||
|
||||
+84
-83
@@ -877,7 +877,7 @@ SurfBezier::CopyFrom( const SurfBezier& sbSrc)
|
||||
m_pTrimReg = sbSrc.m_pTrimReg->Clone() ;
|
||||
}
|
||||
#ifndef SAVEFAILEDTRIANGULATION
|
||||
if( sbSrc.GetAuxSurf() != nullptr)
|
||||
if ( sbSrc.GetAuxSurf() != nullptr)
|
||||
m_pSTM = sbSrc.GetAuxSurf()->Clone() ;
|
||||
#endif
|
||||
for ( int i = 0 ; i < int( sbSrc.m_mCCEdge.size()) ; ++i) {
|
||||
@@ -1075,7 +1075,7 @@ SurfBezier::Load( NgeReader& ngeIn)
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
GetAllPatchesIsocurves( false, vCrv) ;
|
||||
vector<IGeoObj*> vGeo ;
|
||||
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
|
||||
@@ -1898,7 +1898,7 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin, bool bUpdateEdges) cons
|
||||
Point3d ptMin = get<0>( vTrees[i]) ;
|
||||
Point3d ptMax = get<1>( vTrees[i]) ;
|
||||
Tree.SetSurf( this, ptMin, ptMax) ;
|
||||
if( ! Tree.BuildTree( dTol, dSideMin)) {
|
||||
if ( ! Tree.BuildTree( dTol, dSideMin)) {
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Bezier Surface parametric space couldn't be split in cells") ;
|
||||
return nullptr ;
|
||||
}
|
||||
@@ -3029,10 +3029,10 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
dPtStm.GetMinDistTriaIndex( nTriaIndex) ;
|
||||
// se ho trovato un nuovo triangolo, controllo che questo fosse nella lista dei triangoli equidistanti dal punto originale
|
||||
// sennò ripeto il conto con meno scostamento
|
||||
if( nTriaOld != nTriaIndex) {
|
||||
if ( nTriaOld != nTriaIndex) {
|
||||
auto iter = find( vnT.begin(), vnT.end(),nTriaIndex) ;
|
||||
int nIdTria = distance( vnT.begin(), iter) ;
|
||||
if( nIdTria > ssize( vnT) - 1) {
|
||||
if ( nIdTria > ssize( vnT) - 1) {
|
||||
ptI2 = ptI + ( ptIPrevOrNext - ptI) * 5 * EPS_SMALL ;
|
||||
DistPointSurfTm dPtStm2( ptI2, *pSurfTm) ;
|
||||
dPtStm2.GetMinDistTriaIndex( nTriaIndex) ;
|
||||
@@ -4138,7 +4138,7 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr)
|
||||
// se composita verifico che curve siano con lo stesso grado e uniformi come tipo
|
||||
bool bRat = false ;
|
||||
int nDegU = 3 ;
|
||||
if( pCrv->GetType() != CRV_COMPO) {
|
||||
if ( pCrv->GetType() != CRV_COMPO) {
|
||||
CC.AddCurve( CurveToBezierCurve( pCrv, nDegU, bRat)) ;
|
||||
}
|
||||
else {
|
||||
@@ -4151,7 +4151,7 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr)
|
||||
}
|
||||
}
|
||||
|
||||
if( CC.GetCurveCount() == 0 || ! CC.IsValid())
|
||||
if ( CC.GetCurveCount() == 0 || ! CC.IsValid())
|
||||
return false ;
|
||||
|
||||
// riempio la matrice dei punti di controllo
|
||||
@@ -5071,7 +5071,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
if ( j == vMatch1.size())
|
||||
bAdvance1 = false ;
|
||||
// se trovo che ho uno spigolo allora procedo con la gestione spigoli
|
||||
if( vEdgeSplit0[c+1] && vEdgeSplit1[j+1]) {
|
||||
if ( vEdgeSplit0[c+1] && vEdgeSplit1[j+1]) {
|
||||
// se ho uno spigolo su entrambe le curve forzo l'accoppiamento
|
||||
bAdvance0 = true ;
|
||||
bPerfectMatch = true ;
|
||||
@@ -5080,7 +5080,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
ptJoint0 = vPnt1[j+1] ;
|
||||
ptJoint1 = vPnt0[c+1] ;
|
||||
}
|
||||
else if ( (vEdgeSplit0[c+1] && ! bAdvance1) || (vEdgeSplit1[j+1] && ! bAdvance0)) {
|
||||
else if (( vEdgeSplit0[c+1] && ! bAdvance1) || (vEdgeSplit1[j+1] && ! bAdvance0)) {
|
||||
bAdvance0 = false ;
|
||||
bAdvance1 = false ;
|
||||
}
|
||||
@@ -5241,28 +5241,28 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// 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 ;
|
||||
// }
|
||||
// // 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) ;
|
||||
@@ -5292,13 +5292,13 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// 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 = c_temp - c ;
|
||||
// nPointsBetween1 = j_temp - j ;
|
||||
// }
|
||||
// else if( bAdvance0){
|
||||
// else if ( bAdvance0) {
|
||||
// pCC0.Set( CrvU0.CopyParamRange( dLastParamMatch1, c_temp + 1)) ;
|
||||
// pCC1.Set( CrvU1.CopyParamRange( dLastParamMatch0, dParam0)) ;
|
||||
// nPointsBetween0 = c_temp - c ;
|
||||
@@ -5306,7 +5306,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// if ( bIntParam0)
|
||||
// nPointsBetween1 -= 1 ;
|
||||
// }
|
||||
// else if( bAdvance1){
|
||||
// else if ( bAdvance1) {
|
||||
// pCC0.Set( CrvU0.CopyParamRange( dLastParamMatch1, dParam1)) ;
|
||||
// pCC1.Set( CrvU1.CopyParamRange( dLastParamMatch0, j_temp + 1)) ;
|
||||
// nPointsBetween0 = int( dParam1) - ( c + 1) ;
|
||||
@@ -5337,7 +5337,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// int nJBefore = j ;
|
||||
// //debug
|
||||
// while ( bSplitToAdd) {
|
||||
// if ( c0 > ssize( vdParamPos0) - 1 && c1 > ssize( vdParamPos1) - 1) {
|
||||
// if ( c0 > ssize( vdParamPos0) - 1 && c1 > ssize( vdParamPos1) - 1) {
|
||||
// LOG_DBG_ERR( GetEGkLogger(), "Surf Bez Ruled Guided: error 1 while reparametrizing some section") ;
|
||||
// return false ;
|
||||
// }
|
||||
@@ -5384,13 +5384,13 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// bSplitToAdd = ! ( c0 == ssize( vdParamPos0) - 1 && c1 == ssize( vdParamPos1) - 1) ;
|
||||
// }
|
||||
// // aggiorno i dati dell'ultima aggiunta
|
||||
// if( bAdvance0 && ! bAdvance1) {
|
||||
// if ( bAdvance0 && ! bAdvance1) {
|
||||
// ptLastPointMatch0 = vMatch0[c_temp].first ;
|
||||
// dLastParamMatch0 = vMatch0[c_temp].second ;
|
||||
// ptLastPointMatch1 = vPnt0[c_temp] ;
|
||||
// dLastParamMatch0 = c_temp ;
|
||||
// }
|
||||
// else if( ! bAdvance0 && bAdvance1) {
|
||||
// else if ( ! bAdvance0 && bAdvance1) {
|
||||
// ptLastPointMatch0 = vPnt1[j_temp] ;
|
||||
// dLastParamMatch0 = j_temp ;
|
||||
// ptLastPointMatch1 = vMatch1[j_temp].first ;
|
||||
@@ -5406,7 +5406,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// }
|
||||
}
|
||||
}
|
||||
bAdvance = ! (c >= int(vMatch0.size()) - 1 && j >= int(vMatch1.size()) - 1) ;
|
||||
bAdvance = ! ( c >= ssize( vMatch0) - 1 && j >= ssize( vMatch1) - 1) ;
|
||||
}
|
||||
|
||||
// applico effettivamente gli split
|
||||
@@ -5501,7 +5501,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
vector<IGeoObj*> vGeo ;
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
GetAllPatchesIsocurves( false, vCrv) ;
|
||||
for( int i = 0 ; i < ssize( vCrv) ; ++i) {
|
||||
for ( int i = 0 ; i < ssize( vCrv) ; ++i) {
|
||||
vGeo.push_back( vCrv[i]->Clone()) ;
|
||||
}
|
||||
vector<Color> vCol( ssize( vCrv)) ;
|
||||
@@ -5883,8 +5883,8 @@ SurfBezier::CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, c
|
||||
{
|
||||
// vCrv è il vettore delle isocurve (nel parametro V) che si vogliono forzare per la creazione della rigata tra Curve0 e Curve1
|
||||
|
||||
//controllo che siano entrambe chiuse o entrambe aperte
|
||||
if( pCurve0->IsClosed() ^ pCurve1->IsClosed())
|
||||
// controllo che siano entrambe chiuse o entrambe aperte
|
||||
if ( pCurve0->IsClosed() != pCurve1->IsClosed())
|
||||
return false ;
|
||||
|
||||
bool bClosed = pCurve0->IsClosed() ;
|
||||
@@ -5934,8 +5934,9 @@ SurfBezier::CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, c
|
||||
Point3d ptU1 = vCrv[i].second ;
|
||||
double dParam0 ; CrvU0.GetParamAtPoint( ptU0, dParam0) ;
|
||||
double dParam1 ; CrvU1.GetParamAtPoint( ptU1, dParam1) ;
|
||||
if( bClosed && (dParam0 < EPS_SMALL || nSpanU0 - dParam0 < EPS_SMALL) && (dParam1 < EPS_SMALL || nSpanU1 - dParam1 < EPS_SMALL)) {
|
||||
if( ! bFirstAdded) {
|
||||
if ( bClosed && ( dParam0 < EPS_SMALL || nSpanU0 - dParam0 < EPS_SMALL) &&
|
||||
( dParam1 < EPS_SMALL || nSpanU1 - dParam1 < EPS_SMALL)) {
|
||||
if ( ! bFirstAdded) {
|
||||
dParam0 = 0 ;
|
||||
dParam1 = 0 ;
|
||||
bFirstAdded = true ;
|
||||
@@ -5965,7 +5966,7 @@ SurfBezier::CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, c
|
||||
|
||||
dLastParam0 = 0 ;
|
||||
dLastParam1 = 0 ;
|
||||
if( vIso[0].dParam0 > 0 || vIso[0].dParam1 > 0)
|
||||
if ( vIso[0].dParam0 > 0 || vIso[0].dParam1 > 0)
|
||||
vPairs.emplace_back( 0, 0) ;
|
||||
for ( int i = 0 ; i < ssize( vIso) ; ++i) {
|
||||
const BIPOINT& pCrv = vCrv[vIso[i].nCrv] ;
|
||||
@@ -6186,7 +6187,7 @@ SurfBezier::CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, c
|
||||
vector<IGeoObj*> vGeo ;
|
||||
ICURVEPOVECTOR vCrvIso ;
|
||||
GetAllPatchesIsocurves( false, vCrvIso) ;
|
||||
for( int i = 0 ; i < ssize( vCrvIso) ; ++i) {
|
||||
for ( int i = 0 ; i < ssize( vCrvIso) ; ++i) {
|
||||
vGeo.push_back( vCrvIso[i]->Clone()) ;
|
||||
}
|
||||
vector<Color> vCol( ssize( vCrvIso)) ;
|
||||
@@ -6208,36 +6209,36 @@ SurfBezier::CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, c
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::RemoveCollapsedSpans()
|
||||
SurfBezier::RemoveCollapsedSpans( void)
|
||||
{
|
||||
double dTol = EPS_SMALL ;
|
||||
//controllo se ho delle span collassate e le rimuovo
|
||||
if( m_nSpanU > 1 || m_nSpanV > 1) {
|
||||
if ( m_nSpanU > 1 || m_nSpanV > 1) {
|
||||
CalcPoles() ;
|
||||
if( ! m_vbPole[2]) {
|
||||
if ( ! m_vbPole[2]) {
|
||||
// scorro i punti della prima riga
|
||||
INTVECTOR vnCollapsedSpan ;
|
||||
for( int i = 0 ; i < m_nSpanU ; ++i) {
|
||||
for ( int i = 0 ; i < m_nSpanU ; ++i) {
|
||||
bool bSamePoint = true ;
|
||||
Point3d ptFirst = m_vPtCtrl[m_nDegU * i] ;
|
||||
// cerco se trovo tutti i punti in U coincidenti in una delle Span
|
||||
for( int j = 1 ; j < m_nDegU + 1 && bSamePoint ; ++j) {
|
||||
if( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[m_nDegU * i + j], dTol))
|
||||
for ( int j = 1 ; j < m_nDegU + 1 && bSamePoint ; ++j) {
|
||||
if ( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[m_nDegU * i + j], dTol))
|
||||
bSamePoint = false ;
|
||||
}
|
||||
if( bSamePoint) {
|
||||
if ( bSamePoint) {
|
||||
// se trovo un'altra riga collassata do per scontato che tutta span sia collassata
|
||||
ptFirst = m_vPtCtrl[GetInd( m_nDegU * i, 1)] ;
|
||||
for( int j = 1 ; j < m_nDegU + 1 && bSamePoint ; ++j) {
|
||||
if( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[GetInd( m_nDegU * i + j, 1)], dTol))
|
||||
for ( int j = 1 ; j < m_nDegU + 1 && bSamePoint ; ++j) {
|
||||
if ( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[GetInd( m_nDegU * i + j, 1)], dTol))
|
||||
bSamePoint = false ;
|
||||
}
|
||||
if( bSamePoint)
|
||||
if ( bSamePoint)
|
||||
vnCollapsedSpan.push_back( i) ;
|
||||
}
|
||||
}
|
||||
int nOldSpanU = m_nSpanU ;
|
||||
if( ! vnCollapsedSpan.empty()) {
|
||||
if ( ! vnCollapsedSpan.empty()) {
|
||||
// cancello le span che risultano collassate
|
||||
int nNewSpanU = m_nSpanU - ssize( vnCollapsedSpan) ;
|
||||
int nNewDim = ( m_nDegU * nNewSpanU + 1) * ( m_nDegV * m_nSpanV + 1) ;
|
||||
@@ -6245,21 +6246,21 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
DBLVECTOR vNewWeight( nNewDim) ;
|
||||
int nCurrSkipInd = -1 ;
|
||||
int nCurrSkip = -1 ;
|
||||
for( int nIndV = 0 ; nIndV < m_nSpanV * m_nDegV + 1 ; ++nIndV) {
|
||||
for ( int nIndV = 0 ; nIndV < m_nSpanV * m_nDegV + 1 ; ++nIndV) {
|
||||
nCurrSkipInd = 0 ;
|
||||
nCurrSkip = vnCollapsedSpan[nCurrSkipInd] ;
|
||||
for( int i = 0 ; i < m_nSpanU ; ++i) {
|
||||
if( i != nCurrSkip) {
|
||||
for( int j = ( i - nCurrSkipInd) ==0 ? 0 : 1 ; j < m_nDegU + 1 ; ++j) {
|
||||
for ( int i = 0 ; i < m_nSpanU ; ++i) {
|
||||
if ( i != nCurrSkip) {
|
||||
for ( int j = ( i - nCurrSkipInd) ==0 ? 0 : 1 ; j < m_nDegU + 1 ; ++j) {
|
||||
vNewCtrlPnt[nIndV * ( m_nDegU * nNewSpanU + 1) + (i - nCurrSkipInd) * m_nDegU + j] = m_vPtCtrl[GetInd( m_nDegU * i + j, nIndV)] ;
|
||||
if( m_bRat) {
|
||||
if ( m_bRat) {
|
||||
vNewWeight[nIndV * ( m_nDegU * nNewSpanU + 1) + (i - nCurrSkipInd) * m_nDegU + j] = m_vWeCtrl[GetInd( m_nDegU * i + j, nIndV)] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
++nCurrSkipInd ;
|
||||
if( nCurrSkipInd > ssize( vnCollapsedSpan) - 1)
|
||||
if ( nCurrSkipInd > ssize( vnCollapsedSpan) - 1)
|
||||
nCurrSkip = -1 ;
|
||||
else
|
||||
nCurrSkip = vnCollapsedSpan[nCurrSkipInd] ;
|
||||
@@ -6270,32 +6271,32 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
// vettori dei punti e numero di span
|
||||
ISurfFlatRegion* pSFRTrim = nullptr ;
|
||||
bool bTrimmed = m_bTrimmed ;
|
||||
if( bTrimmed) {
|
||||
if ( bTrimmed) {
|
||||
pSFRTrim = GetTrimRegion() ;
|
||||
m_pTrimReg = nullptr ;
|
||||
}
|
||||
Init( m_nDegU, m_nDegV, nNewSpanU, m_nSpanV, m_bRat) ;
|
||||
m_vPtCtrl = vNewCtrlPnt ;
|
||||
if( m_bRat)
|
||||
if ( m_bRat)
|
||||
m_vWeCtrl = vNewWeight ;
|
||||
if( bTrimmed) {
|
||||
if ( bTrimmed) {
|
||||
// elimino le span di troppo dallo spazio parametrico
|
||||
PtrOwner<ISurfFlatRegion> pNewTrim( pSFRTrim->Clone()) ;
|
||||
for( int i = ssize( vnCollapsedSpan) - 1 ; i >= 0 ; --i) {
|
||||
for ( int i = ssize( vnCollapsedSpan) - 1 ; i >= 0 ; --i) {
|
||||
int nSpan = vnCollapsedSpan[i] ;
|
||||
// tolgo tutta la parte a destra della colonna da togliere
|
||||
PtrOwner<ISurfFlatRegion> pSFRCut ( GetSurfFlatRegionRectangle( ( nOldSpanU - nSpan) * SBZ_TREG_COEFF, m_nSpanV * SBZ_TREG_COEFF + 2)) ;
|
||||
if( nSpan != 0) {
|
||||
if ( nSpan != 0) {
|
||||
pSFRCut->Translate( Vector3d( nSpan * SBZ_TREG_COEFF, -1)) ;
|
||||
pNewTrim->Subtract( *pSFRCut) ;
|
||||
}
|
||||
if( pNewTrim->IsValid()) {
|
||||
if ( pNewTrim->IsValid()) {
|
||||
// ritaglio dal parametrico originale la parte a destra della colonna da eliminare e la incollo alla parte a sinistra
|
||||
PtrOwner<ISurfFlatRegion> pRightPart( pSFRTrim->Clone()) ;
|
||||
pSFRCut.Set( GetSurfFlatRegionRectangle( ( nSpan + 1) * SBZ_TREG_COEFF, m_nSpanV * SBZ_TREG_COEFF + 2)) ;
|
||||
pSFRCut->Translate( Vector3d( nSpan * SBZ_TREG_COEFF, -1)) ;
|
||||
if( pRightPart->Subtract( *pSFRCut) && pRightPart->IsValid()) {
|
||||
if( ! pNewTrim->Add( *pRightPart) || ! pNewTrim->IsValid())
|
||||
if ( pRightPart->Subtract( *pSFRCut) && pRightPart->IsValid()) {
|
||||
if ( ! pNewTrim->Add( *pRightPart) || ! pNewTrim->IsValid())
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@@ -6307,30 +6308,30 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
}
|
||||
}
|
||||
|
||||
if( ! m_vbPole[1]) {
|
||||
if ( ! m_vbPole[1]) {
|
||||
// scorro i punti della prima colonna
|
||||
INTVECTOR vnCollapsedSpan ;
|
||||
for( int i = 0 ; i < m_nSpanV ; ++i) {
|
||||
for ( int i = 0 ; i < m_nSpanV ; ++i) {
|
||||
bool bSamePoint = true ;
|
||||
Point3d ptFirst = m_vPtCtrl[GetInd( 0, i * m_nDegV)] ;
|
||||
// cerco se trovo tutti i punti in U coincidenti in una delle Span
|
||||
for( int j = 1 ; j < m_nDegV + 1 && bSamePoint ; ++j) {
|
||||
if( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[GetInd( 0, i * m_nDegV + j)], dTol))
|
||||
for ( int j = 1 ; j < m_nDegV + 1 && bSamePoint ; ++j) {
|
||||
if ( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[GetInd( 0, i * m_nDegV + j)], dTol))
|
||||
bSamePoint = false ;
|
||||
}
|
||||
if( bSamePoint) {
|
||||
if ( bSamePoint) {
|
||||
// se trovo un'altra colonna collassata do per scontato che tutta span sia collassata
|
||||
ptFirst = m_vPtCtrl[GetInd( 1, i * m_nDegV)] ;
|
||||
for( int j = 1 ; j < m_nDegV + 1 && bSamePoint ; ++j) {
|
||||
if( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[GetInd( 1, i * m_nDegV + j)], dTol))
|
||||
for ( int j = 1 ; j < m_nDegV + 1 && bSamePoint ; ++j) {
|
||||
if ( ! AreSamePointEpsilon( ptFirst, m_vPtCtrl[GetInd( 1, i * m_nDegV + j)], dTol))
|
||||
bSamePoint = false ;
|
||||
}
|
||||
if( bSamePoint)
|
||||
if ( bSamePoint)
|
||||
vnCollapsedSpan.push_back( i) ;
|
||||
}
|
||||
}
|
||||
int nOldSpanV = m_nSpanV ;
|
||||
if( ! vnCollapsedSpan.empty()) {
|
||||
if ( ! vnCollapsedSpan.empty()) {
|
||||
// cancello le span che risultano collassate
|
||||
int nNewSpanV = m_nSpanV - ssize( vnCollapsedSpan) ;
|
||||
int nNewDim = ( m_nDegU * m_nSpanU + 1) * ( m_nDegV * nNewSpanV + 1) ;
|
||||
@@ -6338,12 +6339,12 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
DBLVECTOR vNewWeight( nNewDim) ;
|
||||
int nCurrSkipInd = 0 ;
|
||||
int nCurrSkip = vnCollapsedSpan[nCurrSkipInd] ;
|
||||
for( int nIndV = 0 ; nIndV < m_nSpanV * m_nDegV + 1 ; ++nIndV) {
|
||||
if( nIndV / m_nDegV != nCurrSkip) {
|
||||
for( int i = 0 ; i < m_nSpanU ; ++i) {
|
||||
for( int j = i==0 ? 0 : 1 ; j < m_nDegU + 1 ; ++j) {
|
||||
for ( int nIndV = 0 ; nIndV < m_nSpanV * m_nDegV + 1 ; ++nIndV) {
|
||||
if ( nIndV / m_nDegV != nCurrSkip) {
|
||||
for ( int i = 0 ; i < m_nSpanU ; ++i) {
|
||||
for ( int j = i==0 ? 0 : 1 ; j < m_nDegU + 1 ; ++j) {
|
||||
vNewCtrlPnt[( nIndV - ( nCurrSkipInd * m_nDegV)) * ( m_nDegU * m_nSpanU + 1) + i * m_nDegU + j] = m_vPtCtrl[GetInd( m_nDegU * i + j, nIndV)] ;
|
||||
if( m_bRat) {
|
||||
if ( m_bRat) {
|
||||
vNewWeight[( nIndV - ( nCurrSkipInd * m_nDegV)) * ( m_nDegU * m_nSpanU + 1) + i * m_nDegU + j] = m_vWeCtrl[GetInd( m_nDegU * i + j, nIndV)] ;
|
||||
}
|
||||
}
|
||||
@@ -6352,7 +6353,7 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
else {
|
||||
nIndV += m_nDegV - 1 ;
|
||||
++nCurrSkipInd ;
|
||||
if( nCurrSkipInd > ssize( vnCollapsedSpan) - 1)
|
||||
if ( nCurrSkipInd > ssize( vnCollapsedSpan) - 1)
|
||||
nCurrSkip = -1 ;
|
||||
else
|
||||
nCurrSkip = vnCollapsedSpan[nCurrSkipInd] ;
|
||||
@@ -6362,32 +6363,32 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
// vettori dei punti e numero di span
|
||||
ISurfFlatRegion* pSFRTrim = nullptr ;
|
||||
bool bTrimmed = m_bTrimmed ;
|
||||
if( bTrimmed) {
|
||||
if ( bTrimmed) {
|
||||
pSFRTrim = GetTrimRegion() ;
|
||||
m_pTrimReg = nullptr ;
|
||||
}
|
||||
Init( m_nDegU, m_nDegV, m_nSpanU, nNewSpanV, m_bRat) ;
|
||||
m_vPtCtrl = vNewCtrlPnt ;
|
||||
if( m_bRat)
|
||||
if ( m_bRat)
|
||||
m_vWeCtrl = vNewWeight ;
|
||||
if( bTrimmed) {
|
||||
if ( bTrimmed) {
|
||||
// elimino le span di troppo dallo spazio parametrico
|
||||
PtrOwner<ISurfFlatRegion> pNewTrim( pSFRTrim->Clone()) ;
|
||||
for( int i = ssize( vnCollapsedSpan) - 1 ; i >= 0 ; --i) {
|
||||
for ( int i = ssize( vnCollapsedSpan) - 1 ; i >= 0 ; --i) {
|
||||
int nSpan = vnCollapsedSpan[i] ;
|
||||
// tolgo tutta la parte a sopra la riga da togliere
|
||||
PtrOwner<ISurfFlatRegion> pSFRCut ( GetSurfFlatRegionRectangle( m_nSpanU * SBZ_TREG_COEFF + 2, ( nOldSpanV - nSpan) * SBZ_TREG_COEFF)) ;
|
||||
if( nSpan != 0) {
|
||||
if ( nSpan != 0) {
|
||||
pSFRCut->Translate( Vector3d( -1, nSpan * SBZ_TREG_COEFF)) ;
|
||||
pNewTrim->Subtract( *pSFRCut) ;
|
||||
}
|
||||
if( pNewTrim->IsValid()) {
|
||||
if ( pNewTrim->IsValid()) {
|
||||
// ritaglio dal parametrico originale la parte sopra la riga da eliminare e la incollo alla parte sotto la riga
|
||||
PtrOwner<ISurfFlatRegion> pUpperPart( pSFRTrim->Clone()) ;
|
||||
pSFRCut.Set( GetSurfFlatRegionRectangle( m_nSpanU * SBZ_TREG_COEFF + 2, ( nSpan + 1) * SBZ_TREG_COEFF)) ;
|
||||
pSFRCut->Translate( Vector3d( -1, nSpan * SBZ_TREG_COEFF)) ;
|
||||
if( pUpperPart->Subtract( *pSFRCut) && pUpperPart->IsValid()) {
|
||||
if( ! pNewTrim->Add( *pUpperPart) || ! pNewTrim->IsValid())
|
||||
if ( pUpperPart->Subtract( *pSFRCut) && pUpperPart->IsValid()) {
|
||||
if ( ! pNewTrim->Add( *pUpperPart) || ! pNewTrim->IsValid())
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@@ -6405,7 +6406,7 @@ SurfBezier::RemoveCollapsedSpans()
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::SwapParameters()
|
||||
SurfBezier::SwapParameters( void)
|
||||
{
|
||||
// inverto il parametro U con il parametro V
|
||||
// salvo i vecchi dati
|
||||
@@ -6415,7 +6416,7 @@ SurfBezier::SwapParameters()
|
||||
int nDegV = m_nDegU ;
|
||||
bool bTrimmed = m_bTrimmed ;
|
||||
PtrOwner<ISurfFlatRegion> pSFRTRim ;
|
||||
if( m_bTrimmed) {
|
||||
if ( m_bTrimmed) {
|
||||
pSFRTRim.Set( GetTrimRegion()) ;
|
||||
m_pTrimReg = nullptr ;
|
||||
}
|
||||
@@ -6423,16 +6424,16 @@ SurfBezier::SwapParameters()
|
||||
// creo il vettore dei punti di controllo
|
||||
PNTVECTOR vNewCtrlPt( GetDim()) ;
|
||||
DBLVECTOR vNewWeight( GetDim()) ;
|
||||
for( int j = 0 ; j < m_nDegV * m_nSpanV + 1 ; ++j) {
|
||||
for( int i = 0 ; i < m_nDegU * m_nSpanU + 1 ; ++ i) {
|
||||
for ( int j = 0 ; j < m_nDegV * m_nSpanV + 1 ; ++j) {
|
||||
for ( int i = 0 ; i < m_nDegU * m_nSpanU + 1 ; ++ i) {
|
||||
vNewCtrlPt[i * ( nDegU * nSpanU + 1) + j] = m_vPtCtrl[GetInd(i,j)] ;
|
||||
if( m_bRat)
|
||||
if ( m_bRat)
|
||||
vNewWeight[i * ( nDegU * nSpanU + 1) + j] = m_vWeCtrl[GetInd(i,j)] ;
|
||||
}
|
||||
}
|
||||
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, m_bRat) ;
|
||||
if( bTrimmed) {
|
||||
if ( bTrimmed) {
|
||||
pSFRTRim->Mirror( ORIG, Vector3d(1,-1)) ;
|
||||
SetTrimRegion( *pSFRTRim) ;
|
||||
}
|
||||
@@ -6440,4 +6441,4 @@ SurfBezier::SwapParameters()
|
||||
m_vWeCtrl = vNewWeight ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -151,8 +151,8 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
PNTVECTOR GetAllControlPoints( void) const ;
|
||||
bool GetAllPatchesIsocurves( bool bUorV, ICURVEPOVECTOR& vCrv) const ;
|
||||
bool CreateByIsoParamSet( const ICurve* pCurve0, const ICurve* pCurve1, const BIPNTVECTOR& vCrv) ;
|
||||
bool RemoveCollapsedSpans() override ;
|
||||
bool SwapParameters() ;
|
||||
bool RemoveCollapsedSpans( void) override ;
|
||||
bool SwapParameters( void) ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
int GetNgeId( void) const override ;
|
||||
|
||||
@@ -36,25 +36,25 @@ class Tool
|
||||
bool SetAdditiveTool( const std::string& sToolName, double dH, double dR, double dRc, int nToolNum) ;
|
||||
bool SetToolNum( int nToolNum)
|
||||
{ m_nCurrentNum = nToolNum ; return true ; }
|
||||
int GetType() const
|
||||
int GetType( void) const
|
||||
{ return m_nType ; }
|
||||
int GetToolNum() const
|
||||
int GetToolNum( void) const
|
||||
{ return m_nCurrentNum ; }
|
||||
double GetHeigth() const
|
||||
double GetHeigth( void) const
|
||||
{ return m_dHeight ; }
|
||||
double GetTipHeigth() const
|
||||
double GetTipHeigth( void) const
|
||||
{ return m_dTipHeight ; }
|
||||
double GetRadius() const
|
||||
double GetRadius( void) const
|
||||
{ return m_dRadius ; }
|
||||
double GetTipRadius() const
|
||||
double GetTipRadius( void) const
|
||||
{ return m_dTipRadius ; }
|
||||
double GetCornRadius() const
|
||||
double GetCornRadius( void) const
|
||||
{ return m_dRCorner ; }
|
||||
double GetRefRadius() const
|
||||
double GetRefRadius( void) const
|
||||
{ return m_dRefRadius ; }
|
||||
double GetMrtChsWidth() const
|
||||
double GetMrtChsWidth( void) const
|
||||
{ return m_dMrtChsWidth ; }
|
||||
double GetMrtChsThickness() const
|
||||
double GetMrtChsThickness( void) const
|
||||
{ return m_dMrtChsThickness ; }
|
||||
const CurveComposite& GetOutline( void) const
|
||||
{ return ( m_Outline) ; }
|
||||
|
||||
@@ -461,8 +461,8 @@ Tree::Split( int nId, double dSplitValue)
|
||||
dSplitValue < cToSplit.GetTopRight().y - 10 * EPS_SMALL ;
|
||||
Point3d ptP00, ptP01, ptP10, ptP11 ;
|
||||
|
||||
if( bGoodSplitVert) {
|
||||
if( cToSplit.GetBottomRight().x - dSplitValue > dSplitValue - cToSplit.GetBottomLeft().x) {
|
||||
if ( bGoodSplitVert) {
|
||||
if ( cToSplit.GetBottomRight().x - dSplitValue > dSplitValue - cToSplit.GetBottomLeft().x) {
|
||||
GetPoint( cToSplit.GetBottomLeft().x, cToSplit.GetBottomLeft().y, ptP00) ;
|
||||
GetPoint( dSplitValue, cToSplit.GetBottomRight().y, ptP10) ;
|
||||
GetPoint( cToSplit.GetTopLeft().x, cToSplit.GetTopLeft().y, ptP01) ;
|
||||
@@ -474,12 +474,13 @@ Tree::Split( int nId, double dSplitValue)
|
||||
GetPoint( dSplitValue, cToSplit.GetTopLeft().y, ptP01) ;
|
||||
GetPoint( cToSplit.GetTopRight().x, cToSplit.GetTopRight().y, ptP11) ;
|
||||
}
|
||||
if( AreSamePointApprox( ptP00, ptP10) && AreSamePointApprox( ptP01, ptP11) &&
|
||||
( cToSplit.GetBottomRight().x - dSplitValue < SBZ_TREG_COEFF - EPS_SMALL || dSplitValue - cToSplit.GetBottomLeft().x < SBZ_TREG_COEFF - EPS_SMALL))
|
||||
if ( AreSamePointApprox( ptP00, ptP10) && AreSamePointApprox( ptP01, ptP11) &&
|
||||
( cToSplit.GetBottomRight().x - dSplitValue < SBZ_TREG_COEFF - EPS_SMALL ||
|
||||
dSplitValue - cToSplit.GetBottomLeft().x < SBZ_TREG_COEFF - EPS_SMALL))
|
||||
bGoodSplitVert = false ;
|
||||
}
|
||||
if( bGoodSplitHoriz) {
|
||||
if( cToSplit.GetTopLeft().y - dSplitValue > dSplitValue - cToSplit.GetBottomLeft().y) {
|
||||
if ( bGoodSplitHoriz) {
|
||||
if ( cToSplit.GetTopLeft().y - dSplitValue > dSplitValue - cToSplit.GetBottomLeft().y) {
|
||||
GetPoint( cToSplit.GetBottomLeft().x, cToSplit.GetBottomLeft().y, ptP00) ;
|
||||
GetPoint( cToSplit.GetBottomRight().x, cToSplit.GetBottomRight().y, ptP10) ;
|
||||
GetPoint( cToSplit.GetTopLeft().x, dSplitValue, ptP01) ;
|
||||
@@ -491,8 +492,9 @@ Tree::Split( int nId, double dSplitValue)
|
||||
GetPoint( cToSplit.GetTopLeft().x, cToSplit.GetTopLeft().y, ptP01) ;
|
||||
GetPoint( cToSplit.GetTopRight().x, cToSplit.GetTopRight().y, ptP11) ;
|
||||
}
|
||||
if( AreSamePointApprox( ptP00, ptP01) && AreSamePointApprox( ptP10, ptP11) &&
|
||||
( cToSplit.GetTopLeft().y - dSplitValue < SBZ_TREG_COEFF - EPS_SMALL || dSplitValue - cToSplit.GetBottomLeft().y < SBZ_TREG_COEFF - EPS_SMALL))
|
||||
if ( AreSamePointApprox( ptP00, ptP01) && AreSamePointApprox( ptP10, ptP11) &&
|
||||
( cToSplit.GetTopLeft().y - dSplitValue < SBZ_TREG_COEFF - EPS_SMALL ||
|
||||
dSplitValue - cToSplit.GetBottomLeft().y < SBZ_TREG_COEFF - EPS_SMALL))
|
||||
bGoodSplitHoriz = false ;
|
||||
}
|
||||
|
||||
@@ -1455,7 +1457,7 @@ Tree::GetPolygons( POLYLINEMATRIX& vvPolygons, POLYLINEMATRIX& vvPolygons3d, vec
|
||||
++ nPolyInd ;
|
||||
continue ;
|
||||
}
|
||||
else if( m_mTree[nId].m_nCollapsed != Cell::Collapsed::NO_COLLAPSE)
|
||||
else if ( m_mTree[nId].m_nCollapsed != Cell::Collapsed::NO_COLLAPSE)
|
||||
continue ;
|
||||
else {
|
||||
// vettore in cui salvo il chunk di appartenenza di ogni loop che attraversa la cella
|
||||
@@ -1980,7 +1982,7 @@ Tree::FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells
|
||||
nCells.push_back( nCell) ;
|
||||
nEdge = -2 ;
|
||||
}
|
||||
if( ssize( nCells) == 1)
|
||||
if ( ssize( nCells) == 1)
|
||||
return nCells ;
|
||||
|
||||
Vector3d vtDir ;
|
||||
@@ -2009,14 +2011,14 @@ Tree::FindCell( const Point3d& ptToAssign, const CurveLine& cl, INTVECTOR vCells
|
||||
if ( abs(vtDir.x) < 1 - EPS_SMALL/100 && abs(vtDir.y) < 1 - EPS_SMALL/100 )
|
||||
ptIntersPlus = ptIntersPlus + vtDir * EPS_SMALL ;
|
||||
// altrimenti ruoto a destra
|
||||
else if( ( nEdge == 4 && vtDir.x > 1 - EPS_SMALL / 100) || ( nEdge == 6 && vtDir.x < - 1 + EPS_SMALL / 100) ||
|
||||
else if (( nEdge == 4 && vtDir.x > 1 - EPS_SMALL / 100) || ( nEdge == 6 && vtDir.x < - 1 + EPS_SMALL / 100) ||
|
||||
( nEdge == 5 && vtDir.y > 1 - EPS_SMALL / 100) || ( nEdge == 7 && vtDir.y < - 1 + EPS_SMALL / 100)) {
|
||||
Vector3d vtDirDX = vtDir ; vtDirDX.Rotate( Z_AX, -45) ;
|
||||
ptIntersPlus = ptIntersPlus + vtDirDX * EPS_SMALL ;
|
||||
}
|
||||
// altrimenti ruoto a sinistra
|
||||
else /*if( ( nEdge == 4 && vtDir.y < - 1 + EPS_SMALL / 100) || ( nEdge == 6 && vtDir.y < 1 - EPS_SMALL / 100) ||
|
||||
( nEdge == 5 && vtDir.x > 1 - EPS_SMALL / 100) || ( nEdge == 7 && vtDir.x < - 1 + EPS_SMALL / 100)) // + tutti gli altri casi */ {
|
||||
else /*if (( nEdge == 4 && vtDir.y < - 1 + EPS_SMALL / 100) || ( nEdge == 6 && vtDir.y < 1 - EPS_SMALL / 100) ||
|
||||
( nEdge == 5 && vtDir.x > 1 - EPS_SMALL / 100) || ( nEdge == 7 && vtDir.x < - 1 + EPS_SMALL / 100)) // + tutti gli altri casi */ {
|
||||
Vector3d vtDirDX = vtDir ; vtDirDX.Rotate( Z_AX, 45) ;
|
||||
ptIntersPlus = ptIntersPlus + vtDirDX * EPS_SMALL ;
|
||||
}
|
||||
@@ -2138,7 +2140,7 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons)
|
||||
bool bLoopInside = true ;
|
||||
Point3d ptCurr ;
|
||||
int nIdPolygon = - 1;
|
||||
if( ! pCell->m_vnPolyId.empty())
|
||||
if ( ! pCell->m_vnPolyId.empty())
|
||||
nIdPolygon = pCell->m_vnPolyId[0] ;
|
||||
else
|
||||
return false ;
|
||||
@@ -2178,9 +2180,9 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons)
|
||||
}
|
||||
// se l'intersezione e la stessa della precedente allora potrei essere entrato in un loop infinito
|
||||
// se per più volte il punto di intersezione resta più o meno lo stesso allora blocco tutto
|
||||
if( AreSamePointEpsilon( vptInters.back(), ptLastInters, 10 * EPS_SMALL)) {
|
||||
if ( AreSamePointEpsilon( vptInters.back(), ptLastInters, 10 * EPS_SMALL)) {
|
||||
++ nInfiniteLoopCount ;
|
||||
if( nInfiniteLoopCount == 4) {
|
||||
if ( nInfiniteLoopCount == 4) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error Triangulating SurfBezier: infinte while loop occured in Tree::TraceLoopLabelCell")
|
||||
return false ;
|
||||
}
|
||||
@@ -2189,7 +2191,7 @@ Tree::TraceLoopLabelCell( const POLYLINEVECTOR& vplPolygons)
|
||||
// aggiorno il puntatore alla cella
|
||||
pCell = &m_mTree[nId] ;
|
||||
// recupero l'indice del poligono base associato alla cella
|
||||
if( ! pCell->m_vnPolyId.empty())
|
||||
if ( ! pCell->m_vnPolyId.empty())
|
||||
nIdPolygon = pCell->m_vnPolyId[0] ;
|
||||
else
|
||||
return false ;
|
||||
@@ -4025,7 +4027,8 @@ Tree::OnWhichEdge( int nId, const Point3d& ptToAssign, int& nEdge) const
|
||||
Point3d ptTl ( ptBL.x, ptTR.y) ;
|
||||
Point3d ptBr ( ptTR.x, ptBL.y) ;
|
||||
|
||||
if( ptToAssign.y < ptBL.y - EPS_SMALL || ptToAssign.y > ptTR.y + EPS_SMALL || ptToAssign.x < ptBL.x - EPS_SMALL || ptToAssign.x > ptTR.x + EPS_SMALL)
|
||||
if ( ptToAssign.y < ptBL.y - EPS_SMALL || ptToAssign.y > ptTR.y + EPS_SMALL ||
|
||||
ptToAssign.x < ptBL.x - EPS_SMALL || ptToAssign.x > ptTR.x + EPS_SMALL)
|
||||
return false ;
|
||||
else if ( AreSamePointXYApprox( ptToAssign, ptTR))
|
||||
nEdge = 7 ;
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#include <utility>
|
||||
|
||||
struct PairHashInt64 {
|
||||
size_t operator()(const std::pair<int64_t, int64_t>& key) const {
|
||||
size_t
|
||||
operator()( const std::pair<int64_t, int64_t>& key) const {
|
||||
size_t h1 = std::hash<int64_t>{}(key.first) ;
|
||||
size_t h2 = std::hash<int64_t>{}(key.second) ;
|
||||
return h1 ^ (h2 << 1); // Combine hashes
|
||||
@@ -33,14 +34,20 @@ struct PairHashInt64 {
|
||||
//----------------------------------------------------------------------------
|
||||
struct Inters {
|
||||
int nIn ;
|
||||
PNTVECTOR vpt ;
|
||||
int nOut ;
|
||||
PNTVECTOR vpt ;
|
||||
bool bCCW ;
|
||||
int nChunk ;
|
||||
bool bSortedbyStart ;
|
||||
// riordino le intersezioni per lato in senso antiorario dal top
|
||||
// se ho più intersezioni che entrano in un lato le riordino considerando che percorro i lati in senso antiorario a partire da ptTR
|
||||
bool operator < ( Inters& b)
|
||||
|
||||
// nIn e nOut sono flag che indicano da quale lato ho l'ingresso e l'uscita a partire dal lato top in senso antiorario
|
||||
// oltre il 3 sono le celle adiacenti in diagonale al vertice-> 4 corrisponde al ptTl e da lì in senso antiorario
|
||||
// -1 se la curva è sempre dentro la cella
|
||||
|
||||
// riordino le intersezioni per lato in senso antiorario dal top
|
||||
// se ho più intersezioni che entrano in un lato le riordino considerando che percorro i lati in senso antiorario a partire da ptTR
|
||||
bool
|
||||
operator < ( Inters& b)
|
||||
{
|
||||
// trovo in che ordine stanno i due start, tenendo conto anche della possibilità che siano vertici
|
||||
INTVECTOR vEdges = { 7, 0, 4, 1, 5, 2, 6, 3} ;
|
||||
@@ -75,7 +82,8 @@ struct Inters {
|
||||
( bEqIn && nEdgeIn == 3 && vpt[0].y < b.vpt[0].y)) ;
|
||||
}
|
||||
|
||||
static bool FirstEncounter( Inters& a, Inters& b)
|
||||
static bool
|
||||
FirstEncounter( Inters& a, Inters& b)
|
||||
{
|
||||
// riordino in base al lato toccato, o dall'uscita o dall'ingresso, che viene prima.
|
||||
// ottengo l'ordine che avrei percorrendo il bordo da ptTR e considerando i loop che incontro, indipendentemente se li incontro nel punto di uscita o ingresso
|
||||
@@ -135,18 +143,18 @@ struct Inters {
|
||||
( nPos1 == 3 && a.vpt[nFirstA].y < b.vpt[nFirstB].y) ;
|
||||
}
|
||||
|
||||
bool operator == ( Inters& b)
|
||||
bool
|
||||
operator == ( Inters& b)
|
||||
{
|
||||
return AreSamePointExact( vpt[0], b.vpt[0]) ;
|
||||
}
|
||||
bool operator != ( Inters& b)
|
||||
|
||||
bool
|
||||
operator != ( Inters& b)
|
||||
{
|
||||
return ! AreSamePointExact( vpt[0], b.vpt[0]) ;
|
||||
}
|
||||
} ;
|
||||
// nIn e nOut sono flag che indicano da quale lato ho l'ingresso e l'uscita a partire dal lato top in senso antiorario
|
||||
// oltre il 3 sono le celle adiacenti in diagonale al vertice-> 4 corrisponde al ptTl e da lì in senso antiorario
|
||||
// -1 se la curva è sempre dentro la cella
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Cell
|
||||
@@ -160,11 +168,12 @@ class Cell
|
||||
// | |
|
||||
// |_________________|
|
||||
// Edge 5 ( SW) Edge 2 (Bottom) Edge 6 ( SE)
|
||||
public:
|
||||
enum Collapsed { TO_VERIFY = -1, // da verificare
|
||||
NO_COLLAPSE = 0, // non ho coppie di lati collassati
|
||||
VERT_EDGES = 1, // coppia di lati verticali(1-3) sono collassati
|
||||
HORIZ_EDGES = 2} ; // coppia di lati verticali(0-2) sono collassati
|
||||
|
||||
public :
|
||||
enum Collapsed { TO_VERIFY = -1, // da verificare
|
||||
NO_COLLAPSE = 0, // non ho coppie di lati collassati
|
||||
VERT_EDGES = 1, // coppia di lati verticali(1-3) sono collassati
|
||||
HORIZ_EDGES = 2} ; // coppia di lati verticali(0-2) sono collassati
|
||||
|
||||
public :
|
||||
~Cell( void) {}
|
||||
@@ -336,4 +345,4 @@ class Tree
|
||||
INTVECTOR m_vnParents ; // vettore delle celle ottenute dalla divisione preliminare in singole patch
|
||||
ICRVCOMPOPOVECTOR m_vCCLoop2D ; // vettore che contiene le CurveCompo che rappresentano i loop di trim tenendo conto della divisione in celle
|
||||
std::vector<std::pair<BIPNTVECTOR, ChainCurves>> m_vCEdge2D ; // vettore che le chain che rappresentano ciò che resta degli edge originali, tenendo conto dei trim.
|
||||
} ;
|
||||
} ;
|
||||
|
||||
+177
-194
@@ -167,7 +167,7 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
PNTMATRIX vvPoints ;
|
||||
Vector3d vtTanCurr = V_INVALID, vtTanNext = V_INVALID ;
|
||||
bool bNewCurve = true ;
|
||||
int nPoints = int( vPoints.size()) ;
|
||||
int nPoints = ssize( vPoints) ;
|
||||
for ( int nP = 0 ; nP < nPoints - 2 ; ++ nP) {
|
||||
// Recupero il punto corrente e i due punti successivi
|
||||
Point3d& ptCurr = vPoints[nP] ;
|
||||
@@ -209,8 +209,8 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
// Se PolyLine originale chiusa
|
||||
if ( PL.IsClosed()) {
|
||||
// Se ho più tratti, potrei riuniore il primo con l'ultimo
|
||||
if ( int( vvPoints.size()) > 1) {
|
||||
Point3d& ptCurr = vPoints[int( vPoints.size()) - 2] ;
|
||||
if ( ssize( vvPoints) > 1) {
|
||||
Point3d& ptCurr = vPoints[ssize( vPoints) - 2] ;
|
||||
Point3d& ptNext = vPoints[0] ;
|
||||
Point3d& ptNextNext = vPoints[1] ;
|
||||
vtTanCurr = ptNext - ptCurr ; vtTanCurr.Normalize() ;
|
||||
@@ -219,19 +219,19 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
// Se dentro alla tolleranza
|
||||
if ( dCos > dCosTol) {
|
||||
// Recupero la tangenza del tratto finale dell'ultimo tratto
|
||||
Point3d& ptLast = vvPoints.back()[int( vvPoints.back().size()) - 1] ;
|
||||
Point3d& ptLastLast = vvPoints.back()[int( vvPoints.back().size()) - 2] ;
|
||||
Point3d& ptLast = vvPoints.back()[ssize( vvPoints.back()) - 1] ;
|
||||
Point3d& ptLastLast = vvPoints.back()[ssize( vvPoints.back()) - 2] ;
|
||||
Vector3d vtTanLast = ptLast - ptLastLast ; vtTanLast.Normalize() ;
|
||||
dCos = vtTanLast * vtTanCurr ;
|
||||
// Se nella tolleranza allora posso allacciare il primo e l'ultimo tratto
|
||||
if ( dCos > dCosTol) {
|
||||
for ( int i = bNewCurve ? 1 : 0 ; i < int( vvPoints[0].size()) ; ++ i)
|
||||
for ( int i = bNewCurve ? 1 : 0 ; i < ssize( vvPoints[0]) ; ++ i)
|
||||
vvPoints.back().emplace_back( vvPoints[0][i]) ;
|
||||
vvPoints.erase( vvPoints.begin()) ;
|
||||
}
|
||||
// Altrimenti sposto il punto d'inizio in ptCurr del primo tratto
|
||||
else {
|
||||
PNTVECTOR vPointsFirst ; vPointsFirst.reserve( vvPoints.front().size() + 1) ;
|
||||
PNTVECTOR vPointsFirst ; vPointsFirst.reserve( ssize( vvPoints.front()) + 1) ;
|
||||
vPointsFirst.emplace_back( ptCurr) ;
|
||||
for ( const Point3d& pt : vvPoints.front())
|
||||
vPointsFirst.emplace_back( pt) ;
|
||||
@@ -252,8 +252,8 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
// Se devo creare una curva nuova, aggiungo il tratto finale
|
||||
if ( bNewCurve) {
|
||||
vvPoints.emplace_back( PNTVECTOR{}) ;
|
||||
vvPoints.back().emplace_back( vPoints[int( vPoints.size()) - 2]) ;
|
||||
vvPoints.back().emplace_back( vPoints[int( vPoints.size()) - 1]) ;
|
||||
vvPoints.back().emplace_back( vPoints[ssize( vPoints) - 2]) ;
|
||||
vvPoints.back().emplace_back( vPoints[ssize( vPoints) - 1]) ;
|
||||
}
|
||||
}
|
||||
#if DEBUG_ANG_APPROX
|
||||
@@ -271,10 +271,10 @@ GetPointSetByAngTol( const PolyLine& PL, double dAngTol, POLYLINEVECTOR& vPL)
|
||||
#endif
|
||||
|
||||
// Converto i punti ricavati in PolyLine risultati
|
||||
for ( int i = 0 ; i < int( vvPoints.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vvPoints) ; ++ i) {
|
||||
vPL.emplace_back( PolyLine()) ;
|
||||
double dPar = -1. ;
|
||||
for ( int j = 0 ; j < int( vvPoints[i].size()) ; ++ j) {
|
||||
for ( int j = 0 ; j < ssize( vvPoints[i]) ; ++ j) {
|
||||
vPL.back().AddUPoint( ++ dPar, vvPoints[i][j]) ;
|
||||
}
|
||||
}
|
||||
@@ -580,7 +580,7 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
// Le Patch più corte della tolleranza vengono considerate invalide
|
||||
SimpleBorderVector vSimpleBorder ; vSimpleBorder.reserve( matPLPatches.size()) ;
|
||||
vector<set<double>> matPatchPar ; matPatchPar.reserve( matPLPatches.size()) ;
|
||||
for ( int i = 0 ; i < int( matPLPatches.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( matPLPatches) ; ++ i) {
|
||||
vSimpleBorder.emplace_back( SimpleBorder()) ;
|
||||
matPatchPar.emplace_back( set<double>()) ;
|
||||
for ( int j = 0 ; j < ssize( matPLPatches[i]) ; ++ j) {
|
||||
@@ -599,8 +599,8 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
}
|
||||
#if DEBUG_CHAIN_CURVES
|
||||
VC.clear() ; VT.clear() ;
|
||||
for ( int i = 0 ; i < int( vSimpleBorder.size()) ; ++ i) {
|
||||
for ( int j = 0 ; j < int( vSimpleBorder[i].size()) ; ++ j) {
|
||||
for ( int i = 0 ; i < ssize( vSimpleBorder) ; ++ i) {
|
||||
for ( int j = 0 ; j < ssize( vSimpleBorder[i]) ; ++ j) {
|
||||
VT.emplace_back( matCompoPatches[i][j].Clone()) ;
|
||||
VC.emplace_back( RED) ;
|
||||
IGeoPoint3d* ptS = CreateGeoPoint3d() ;
|
||||
@@ -720,11 +720,11 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
// Si eliminano ora tutte le Patch che si sovrappongono, in modo da ottenere solo un
|
||||
// le Patch che rappresentano il bordo esterno
|
||||
const double MAXPOINT = 10 ;
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < int( vSimpleBorder.size()) - 1 ; ++ nCurrCrv) {
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < ssize( vSimpleBorder) - 1 ; ++ nCurrCrv) {
|
||||
// Recupero la curva corrente
|
||||
SimpleBorder& CurrCurve = vSimpleBorder[nCurrCrv] ;
|
||||
// Scorro i suoi Edges
|
||||
for ( int nCurrEdge = 0 ; nCurrEdge < int( CurrCurve.size()) ; ++ nCurrEdge) {
|
||||
for ( int nCurrEdge = 0 ; nCurrEdge < ssize( CurrCurve) ; ++ nCurrEdge) {
|
||||
// Se Edge cancellato, passo al successivo
|
||||
if ( CurrCurve[nCurrEdge].bErase)
|
||||
continue ;
|
||||
@@ -732,11 +732,11 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
Point3d& ptCurrStart = CurrCurve[nCurrEdge].ptStart ;
|
||||
Point3d& ptCurrEnd = CurrCurve[nCurrEdge].ptEnd ;
|
||||
// Scorro le curve successive
|
||||
for ( int nNextCrv = nCurrCrv + 1 ; nNextCrv < int( vSimpleBorder.size()) ; ++ nNextCrv) {
|
||||
for ( int nNextCrv = nCurrCrv + 1 ; nNextCrv < ssize( vSimpleBorder) ; ++ nNextCrv) {
|
||||
// Recupero la curva successiva
|
||||
SimpleBorder& NextCurve = vSimpleBorder[nNextCrv] ;
|
||||
// Scorro i suoi Edges
|
||||
for ( int nNextEdge = 0 ; nNextEdge < int( NextCurve.size()) ; ++ nNextEdge) {
|
||||
for ( int nNextEdge = 0 ; nNextEdge < ssize( NextCurve) ; ++ nNextEdge) {
|
||||
// Se Edge cancellato, passo al successivo
|
||||
#if 0
|
||||
// Se pezze si superficie piccolissime, si rischia di eliminare tutti i
|
||||
@@ -790,11 +790,11 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
}
|
||||
|
||||
// Recupero solo i sottotratti di curva validi ( quindi che non fanno overlap tra loro)
|
||||
for ( int nCrv = 0 ; nCrv < int( vSimpleBorder.size()) ; ++ nCrv) {
|
||||
for ( int nCrv = 0 ; nCrv < ssize( vSimpleBorder) ; ++ nCrv) {
|
||||
// Recupero la curva
|
||||
SimpleBorder& CrvEdge = vSimpleBorder[nCrv] ;
|
||||
// Scorro i suoi edges
|
||||
for ( int nEdge = 0 ; nEdge < int( CrvEdge.size()) ; ++ nEdge) {
|
||||
for ( int nEdge = 0 ; nEdge < ssize( CrvEdge) ; ++ nEdge) {
|
||||
// Se edge non attivo, passo al successivo
|
||||
if ( CrvEdge[nEdge].bErase)
|
||||
continue ;
|
||||
@@ -815,15 +815,15 @@ ManagePatches( const POLYLINEVECTOR& vPLBorders, double dLinTol, double dAngTol,
|
||||
}
|
||||
}
|
||||
// Conservo solo le curve valide
|
||||
for ( int nCrv = 0 ; nCrv < int( vCompoResult.size()) ; ++ nCrv) {
|
||||
if ( IsNull( vCompoResult[nCrv]) || ! vCompoResult[nCrv]->IsValid()) {
|
||||
for ( int nCrv = 0 ; nCrv < ssize( vCompoResult) ; ++ nCrv) {
|
||||
if ( IsNull( vCompoResult[nCrv]) || ! vCompoResult[nCrv]->IsValid()) {
|
||||
vCompoResult.erase( vCompoResult.begin() + nCrv) ;
|
||||
-- nCrv ;
|
||||
}
|
||||
}
|
||||
#if DEBUG_CHAIN_CURVES // Debug per le Patch risultanti
|
||||
VT.clear() ; VC.clear() ;
|
||||
for ( int i = 0 ; i < int( vCompoResult.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoResult) ; ++ i) {
|
||||
VT.emplace_back( vCompoResult[i]->Clone()) ;
|
||||
VC.emplace_back( ORANGE) ;
|
||||
}
|
||||
@@ -854,7 +854,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
// La concatenazione parte dalla curva più lunga
|
||||
double dMaxLen = - INFINITO ;
|
||||
int nInd = 0 ;
|
||||
for ( int i = 0 ; i < int( vCompoPatches.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoPatches) ; ++ i) {
|
||||
double dLen = 0. ;
|
||||
vCompoPatches[i]->GetLength( dLen) ;
|
||||
if ( dLen > dMaxLen) {
|
||||
@@ -868,7 +868,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
// Scorro le curve
|
||||
vCompoChained.reserve( vCompoPatches.size()) ;
|
||||
BOOLVECTOR vbCrvChained( vCompoPatches.size(), false) ;
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < int( vCompoPatches.size()) ; ++ nCurrCrv) {
|
||||
for ( int nCurrCrv = 0 ; nCurrCrv < ssize( vCompoPatches) ; ++ nCurrCrv) {
|
||||
// Se curva già concatenata, passo alla successiva ( no biforcazioni ammesse -> errore )
|
||||
if ( vbCrvChained[nCurrCrv])
|
||||
continue ;
|
||||
@@ -881,7 +881,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
for ( int nU = 0 ; nU < vCompoChained.back()->GetCurveCount() ; ++ nU)
|
||||
vCompoChained.back()->SetCurveTempProp( nU, vCompoPatches[nCurrCrv]->GetTempProp( 0), 0) ;
|
||||
// Cerco tra le altre curve disponibili una candidata alla concatenazione
|
||||
for ( int nNextCrv = 0 ; nNextCrv < int( vCompoPatches.size()) ; ++ nNextCrv) {
|
||||
for ( int nNextCrv = 0 ; nNextCrv < ssize( vCompoPatches) ; ++ nNextCrv) {
|
||||
if ( nNextCrv == nCurrCrv || vbCrvChained[nNextCrv])
|
||||
continue ;
|
||||
// Recupero i suoi estremi [ sono tratti lineari, la ricerca è immediata ]
|
||||
@@ -932,7 +932,7 @@ ChainCompoPatches( ICRVCOMPOPOVECTOR& vCompoPatches, double dChainTol,
|
||||
}
|
||||
}
|
||||
// Verifico la validità delle curve ottenute
|
||||
for ( int i = 0 ; i < int( vCompoChained.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoChained) ; ++ i) {
|
||||
if ( IsNull( vCompoChained[i]) || ! vCompoChained[i]->IsValid())
|
||||
return false ;
|
||||
// Se curva al di sotto della tolleranza, la scarto
|
||||
@@ -1032,7 +1032,7 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
}
|
||||
}
|
||||
// Se non ho ottenuto esattamente due tratti, non analizzo più la curva corrente
|
||||
if ( int( vBiPntSplit.size()) != 2) {
|
||||
if ( ssize( vBiPntSplit) != 2) {
|
||||
LOG_INFO( GetEGkLogger(), "Warning in Trimming : Detected more Curves by Thick values") ;
|
||||
break ; // lascio la curva invariata
|
||||
}
|
||||
@@ -1069,10 +1069,10 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
if ( vBreakingPts.empty())
|
||||
return true ;
|
||||
// Se ho punti di rottura in comune, errore
|
||||
for ( int i = 0 ; i < int( vBreakingPts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBreakingPts) ; ++ i) {
|
||||
if ( AreSamePointEpsilon( vBreakingPts[i].first, vBreakingPts[i].second, dLinTol))
|
||||
return false ;
|
||||
for ( int j = i + 1 ; j < int( vBreakingPts.size()) ; ++ j) {
|
||||
for ( int j = i + 1 ; j < ssize( vBreakingPts) ; ++ j) {
|
||||
if ( AreSamePointEpsilon( vBreakingPts[i].first, vBreakingPts[j].first, dLinTol) ||
|
||||
AreSamePointEpsilon( vBreakingPts[i].first, vBreakingPts[j].second, dLinTol) ||
|
||||
AreSamePointEpsilon( vBreakingPts[i].second, vBreakingPts[j].first, dLinTol) ||
|
||||
@@ -1110,7 +1110,7 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
return false ;
|
||||
for ( const BIPOINT& BiPnts : vBreakingPts) {
|
||||
// Scorro i tratti ( inizialmente la curva stessa)
|
||||
for ( int i = 0 ; i < int( vCompoParts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoParts) ; ++ i) {
|
||||
// Controllo che la coppia di punti giacia su quella curva
|
||||
if ( ! vCompoParts[i]->IsPointOn( BiPnts.first, dLinTol) ||
|
||||
! vCompoParts[i]->IsPointOn( BiPnts.second, dLinTol))
|
||||
@@ -1152,7 +1152,7 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
}
|
||||
}
|
||||
// Memorizzo tutte le curve valide ottenute dai punti di rottura
|
||||
for ( int i = 0 ; i < int( vCompoParts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoParts) ; ++ i) {
|
||||
if ( ! IsNull( vCompoParts[i]) && vCompoParts[i]->IsValid())
|
||||
vCrvResult.emplace_back( Release( vCompoParts[i])) ;
|
||||
}
|
||||
@@ -1186,13 +1186,13 @@ BreakCompoPathces( ICRVCOMPOPOVECTOR& vCompoChained, double dLinTol, double dAng
|
||||
if ( ! GetPointSetByAngTol( myPL, ANG_SPLIT, vPL))
|
||||
return false ;
|
||||
// Se meno di 4 PolyLine non faccio nulla
|
||||
if ( int( vPL.size()) < 4) {
|
||||
if ( ssize( vPL) < 4) {
|
||||
LOG_INFO( GetEGkLogger(), "Warning in Trimming : Not Detected 2 Curves") ;
|
||||
return true ;
|
||||
}
|
||||
// Scorro le PolyLine e ricavo le due più corte
|
||||
INTDBLVECTOR vIndPLLen ; vIndPLLen.reserve( vPL.size()) ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vPL) ; ++ i) {
|
||||
double dLen ; vPL[i].GetLength( dLen) ;
|
||||
vIndPLLen.emplace_back( make_pair( i, dLen)) ;
|
||||
}
|
||||
@@ -1301,7 +1301,7 @@ InsertLoopsOfSurf( const ISurf* pSurf, POLYLINEVECTOR& vPL)
|
||||
return false ;
|
||||
// Li inserisco nel vettore ( come insieme di tratti lineari)
|
||||
// NB. Tengo le tolleranze molto basse per ottenere dei loop rappresentativi della geometria
|
||||
for ( int nL = 0 ; nL < int( vLoops.size()) ; ++ nL) {
|
||||
for ( int nL = 0 ; nL < ssize( vLoops) ; ++ nL) {
|
||||
if ( ! IsNull( vLoops[nL]) && vLoops[nL]->IsValid()) {
|
||||
vPL.emplace_back( PolyLine()) ;
|
||||
if ( ! vLoops[nL]->ApproxWithLines( EPS_SMALL, EPS_ANG_SMALL, ICurve::APL_STD, vPL.back()))
|
||||
@@ -1427,7 +1427,7 @@ GetSurfBorders( const CISURFPVECTOR& vSurf, const SELVECTOR& vSurfFace, double d
|
||||
// - Loop di una Superficie TriMesh
|
||||
// - Insieme di facce di una supericie TriMesh
|
||||
// Scorro il vettore delle superfici
|
||||
for ( int nS = 0 ; nS < int( vSurf.size()) ; ++ nS) {
|
||||
for ( int nS = 0 ; nS < ssize( vSurf) ; ++ nS) {
|
||||
// Recupero la superficie
|
||||
const ISurf* pSurf = vSurf[nS] ;
|
||||
if ( pSurf == nullptr)
|
||||
@@ -1440,9 +1440,9 @@ GetSurfBorders( const CISURFPVECTOR& vSurf, const SELVECTOR& vSurfFace, double d
|
||||
vFaces.push_back( SurfFace.nSub) ;
|
||||
}
|
||||
// Recupero la dimensione del vettore delle PolyLine risultati attuale
|
||||
int nSize = int( vPLBorders.size()) ;
|
||||
int nSize = ssize( vPLBorders) ;
|
||||
// Se non ho nessuna faccia e nessun triangolo da scartare, estraggo i bordi complessivi della superficie
|
||||
if ( int( vFaces.size()) == 1 && vFaces[0] == SEL_SUB_ALL) {
|
||||
if ( ssize( vFaces) == 1 && vFaces[0] == SEL_SUB_ALL) {
|
||||
if ( ! InsertLoopsOfSurf( pSurf, vPLBorders))
|
||||
return false ;
|
||||
}
|
||||
@@ -1463,7 +1463,7 @@ GetSurfBorders( const CISURFPVECTOR& vSurf, const SELVECTOR& vSurfFace, double d
|
||||
return false ;
|
||||
}
|
||||
// Associo alle nuove PolyLine ricavate l'indice della superficie corrispondente
|
||||
for ( int i = nSize ; i < int( vPLBorders.size()) ; ++ i)
|
||||
for ( int i = nSize ; i < ssize( vPLBorders) ; ++ i)
|
||||
vPLBorders[i].SetTempProp( nS, 0) ;
|
||||
}
|
||||
|
||||
@@ -1509,52 +1509,36 @@ GetBorderByExtrusion( const SurfTriMesh* pStm, double dThick, double dLinTol, do
|
||||
// Scorro i Loop
|
||||
for ( PolyLine& PLLoop : vPLLoop) {
|
||||
PolyLine PLLoopExtr ;
|
||||
// Scorro i Segmenti
|
||||
Point3d ptI, ptE ;
|
||||
double dUI, dUE ;
|
||||
bool bFound = PLLoop.GetFirstULine( &dUI, &ptI, &dUE, &ptE) ;
|
||||
// Scorro i Punti
|
||||
Point3d ptP ;
|
||||
double dU ;
|
||||
bool bFound = PLLoop.GetFirstUPoint( &dU, &ptP) ;
|
||||
double dPar = -1 ;
|
||||
bool bFirst = true ;
|
||||
while ( bFound) {
|
||||
// Recupero il TriangoloEx del tratto lineare corrente
|
||||
// Recupero il TriangoloEx associato al punto
|
||||
Triangle3dEx Tria ;
|
||||
if ( ! pStm->GetTriangle( int( dUI), Tria))
|
||||
if ( ! pStm->GetTriangle( lround( dU), Tria))
|
||||
return false ;
|
||||
// Tale Triangolo contiene le normali mediate, cerco quelle riferite ai vertici
|
||||
if ( bFirst) {
|
||||
int nTriaP = 0 ;
|
||||
for ( ; nTriaP < 3 ; ++ nTriaP) {
|
||||
if ( AreSamePointApprox( Tria.GetP( nTriaP), ptI))
|
||||
break ;
|
||||
}
|
||||
PLLoopExtr.AddUPoint( ++ dPar, ptI - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
#if DEBUG_BORDERS_BY_NORMALS
|
||||
IGeoVector3d* _vtN = CreateGeoVector3d() ; _vtN->Set( Tria.GetVertexNorm( nTriaP), ptI) ;
|
||||
VT.emplace_back( _vtN) ;
|
||||
Color _myCol = Color( abs( Tria.GetVertexNorm( nTriaP).x), abs( Tria.GetVertexNorm( nTriaP).y), abs( Tria.GetVertexNorm( nTriaP).z)) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
CurveLine _Line ; _Line.Set( ptI, ptI - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
VT.emplace_back( _Line.Clone()) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
#endif
|
||||
bFirst = false ;
|
||||
}
|
||||
// Cerco il vertice associato al punto
|
||||
int nTriaP = 0 ;
|
||||
for ( ; nTriaP < 3 ; ++ nTriaP) {
|
||||
if ( AreSamePointApprox( Tria.GetP( nTriaP), ptE))
|
||||
if ( AreSamePointApprox( Tria.GetP( nTriaP), ptP))
|
||||
break ;
|
||||
}
|
||||
PLLoopExtr.AddUPoint( ++ dPar, ptE - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
if ( nTriaP == 3)
|
||||
return false ;
|
||||
PLLoopExtr.AddUPoint( ++ dPar, ptP - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
#if DEBUG_BORDERS_BY_NORMALS
|
||||
IGeoVector3d* _vtN = CreateGeoVector3d() ; _vtN->Set( Tria.GetVertexNorm( nTriaP), ptE) ;
|
||||
IGeoVector3d* _vtN = CreateGeoVector3d() ; _vtN->Set( Tria.GetVertexNorm( nTriaP), ptP) ;
|
||||
VT.emplace_back( _vtN) ;
|
||||
Color _myCol = Color( abs( Tria.GetVertexNorm( nTriaP).x), abs( Tria.GetVertexNorm( nTriaP).y), abs( Tria.GetVertexNorm( nTriaP).z)) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
CurveLine _Line ; _Line.Set( ptE, ptE - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
CurveLine _Line ; _Line.Set( ptP, ptP - Tria.GetVertexNorm( nTriaP) * dThick) ;
|
||||
VT.emplace_back( _Line.Clone()) ;
|
||||
VC.emplace_back( _myCol) ;
|
||||
#endif
|
||||
bFound = PLLoop.GetNextULine( &dUI, &ptI, &dUE, &ptE) ;
|
||||
bFound = PLLoop.GetNextUPoint( &dU, &ptP) ;
|
||||
}
|
||||
#if DEBUG_BORDERS_BY_NORMALS
|
||||
ICurveComposite* pC = CreateCurveComposite() ;
|
||||
@@ -1562,8 +1546,9 @@ GetBorderByExtrusion( const SurfTriMesh* pStm, double dThick, double dLinTol, do
|
||||
VT.emplace_back( pC->Clone()) ;
|
||||
VC.emplace_back( AQUA) ;
|
||||
#endif
|
||||
// Loop valido con almeno 4 punti
|
||||
if ( PLLoopExtr.GetPointNbr() >= 4) {
|
||||
// Il primo e l'ultimo punto devono coincidere
|
||||
// Primo e ultimo punto devono coincidere
|
||||
PNTULIST& lPntU = PLLoopExtr.GetUPointList() ;
|
||||
Point3d ptClose = Media( lPntU.front().first, lPntU.back().first) ;
|
||||
lPntU.front().first = ptClose ;
|
||||
@@ -2071,10 +2056,10 @@ ClassifyTriangles( const SurfTriMesh& Stm, const INTVECTOR& vTBox, int nFirstTri
|
||||
// Collezione di triangoli già visitati
|
||||
unordered_set<int> setTria ; setTria.reserve( vTBox.size()) ;
|
||||
// Collezioni di triangoli da analizzare
|
||||
INTVECTOR vTria ; vTria.reserve( int( vTBox.size()) + 1) ;
|
||||
INTVECTOR vTria ; vTria.reserve( ssize( vTBox) + 1) ;
|
||||
vTria.push_back( nFirstTria) ;
|
||||
// Collezioni di adiacenze da non riguardare
|
||||
unordered_map<int, INTVECTOR> mapAdjToAvoid ; mapAdjToAvoid.reserve( int( vTBox.size() + 1)) ;
|
||||
unordered_map<int, INTVECTOR> mapAdjToAvoid ; mapAdjToAvoid.reserve( ssize( vTBox) + 1) ;
|
||||
|
||||
// Finchè ho triangoli da visitare
|
||||
while ( ! vTria.empty()) {
|
||||
@@ -2221,14 +2206,14 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
|
||||
// Per ogni Edge ricavato, conservo solo le parti interne al Box corrente
|
||||
INTVECTOR vEdgeToSave ; vEdgeToSave.reserve( vBiPnts.size()) ;
|
||||
for ( int nEdge = 0 ; nEdge < int( vBiPnts.size()) ; ++ nEdge) {
|
||||
for ( int nEdge = 0 ; nEdge < ssize( vBiPnts) ; ++ nEdge) {
|
||||
Point3d& ptL1 = vBiPnts[nEdge].first ;
|
||||
Point3d& ptL2 = vBiPnts[nEdge].second ;
|
||||
Vector3d vtDir = ptL2 - ptL1 ;
|
||||
vtDir.Normalize() ;
|
||||
INTDBLVECTOR vInters ;
|
||||
if ( IntersLineBox( ptL1, ptL2, BBoxCurr, vInters, true)) {
|
||||
if ( int( vInters.size()) == 2) {
|
||||
if ( ssize( vInters) == 2) {
|
||||
vEdgeToSave.push_back( nEdge) ;
|
||||
// Se edge sul bordo, lo spezzo
|
||||
if ( vInters[1].first == ILBT_OUT)
|
||||
@@ -2240,14 +2225,14 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
}
|
||||
unordered_set<int> setBiPntsToSave( vEdgeToSave.begin(), vEdgeToSave.end()) ;
|
||||
int nCurr = 0 ;
|
||||
for ( int i = 0 ; i < int( vBiPnts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBiPnts) ; ++ i) {
|
||||
if ( setBiPntsToSave.count( i))
|
||||
vBiPnts[nCurr ++] = vBiPnts[i] ;
|
||||
}
|
||||
vBiPnts.resize( nCurr) ;
|
||||
|
||||
#if DEBUG_FACE_SEARCH
|
||||
for ( int i = 0 ; i < int( vBiPnts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBiPnts) ; ++ i) {
|
||||
ICurveLine* pLine = CreateCurveLine() ;
|
||||
pLine->Set( vBiPnts[i].first, vBiPnts[i].second) ;
|
||||
VT.emplace_back( pLine) ;
|
||||
@@ -2259,7 +2244,7 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
// Concateno i Segmenti interni al Box corrente
|
||||
BOOLVECTOR vIndInChain ; vIndInChain.resize( vBiPnts.size(), false) ;
|
||||
vCompoChain.reserve( vBiPnts.size()) ;
|
||||
for ( int i = 0 ; i < int( vBiPnts.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vBiPnts) ; ++ i) {
|
||||
// Se già in Chain, passo al successivo
|
||||
if ( vIndInChain[i])
|
||||
continue ;
|
||||
@@ -2273,7 +2258,7 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
vCompoChain.back().AddLine( ptCurrEnd) ;
|
||||
// Punti di controllo per Biforcazioni
|
||||
PNTVECTOR vPtForks ; vPtForks.reserve( vBiPnts.size()) ;
|
||||
for ( int j = 0 ; j < int( vBiPnts.size()) ; ++ j) {
|
||||
for ( int j = 0 ; j < ssize( vBiPnts) ; ++ j) {
|
||||
// Controllo un altro Edge non in Chain, recuperando i suoi estremi
|
||||
if ( i == j || vIndInChain[j])
|
||||
continue ;
|
||||
@@ -2344,7 +2329,7 @@ GetBordersByTriaInBox( const SurfTriMesh& Stm, const BBox3d& BBoxCurr, double dL
|
||||
}
|
||||
|
||||
#if DEBUG_FACE_SEARCH
|
||||
for ( int i = 0 ; i < int( vCompoChain.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoChain) ; ++ i) {
|
||||
VT.emplace_back( vCompoChain[i].Clone()) ;
|
||||
VC.emplace_back( FUCHSIA) ;
|
||||
}
|
||||
@@ -2426,7 +2411,7 @@ CheckCurvesInBox( const SurfTriMesh& Stm, const COMPOVECTOR& vCompoChain, const
|
||||
return false ;
|
||||
|
||||
#if DEBUG_FACE_SEARCH
|
||||
for ( int _i = 0 ; _i < int( vCompoChain.size()) ; ++ _i) {
|
||||
for ( int _i = 0 ; _i < ssize( vCompoChain) ; ++ _i) {
|
||||
VT.emplace_back( vCompoChain[_i].Clone()) ;
|
||||
VC.emplace_back( PURPLE) ;
|
||||
}
|
||||
@@ -2436,7 +2421,7 @@ CheckCurvesInBox( const SurfTriMesh& Stm, const COMPOVECTOR& vCompoChain, const
|
||||
CurveComposite CompoATmp, CompoBTmp ;
|
||||
|
||||
// Se ho una sola curva, allora i bordi si sono uniti
|
||||
if ( int( vCompoChain.size()) == 1) {
|
||||
if ( ssize( vCompoChain) == 1) {
|
||||
// Approssimo la curva in Patches
|
||||
PolyLine PL ;
|
||||
if ( ! vCompoChain[0].ApproxWithLines( EPS_SMALL, EPS_ANG_SMALL, ICurve::APL_SPECIAL, PL))
|
||||
@@ -2448,14 +2433,14 @@ CheckCurvesInBox( const SurfTriMesh& Stm, const COMPOVECTOR& vCompoChain, const
|
||||
CompoBTmp.FromPolyLine( matPL[0].back()) ;
|
||||
}
|
||||
// Se due curve di bordo
|
||||
else if ( int( vCompoChain.size()) == 2) {
|
||||
else if ( ssize( vCompoChain) == 2) {
|
||||
CompoATmp = vCompoChain[0] ;
|
||||
CompoBTmp = vCompoChain[1] ;
|
||||
}
|
||||
// Se più di due, cerco le due curve più vicine
|
||||
else if ( int( vCompoChain.size()) > 2) {
|
||||
else if ( ssize( vCompoChain) > 2) {
|
||||
INTDBLVECTOR vIndSqDist ; vIndSqDist.reserve( vCompoChain.size()) ;
|
||||
for ( int nCrv = 0 ; nCrv < int( vCompoChain.size()) ; ++ nCrv) {
|
||||
for ( int nCrv = 0 ; nCrv < ssize( vCompoChain) ; ++ nCrv) {
|
||||
vIndSqDist.emplace_back( make_pair( nCrv, 0.)) ;
|
||||
if ( ! DistPointCurve( ptSel, vCompoChain[nCrv]).GetSqDist( vIndSqDist.back().second))
|
||||
return false ;
|
||||
@@ -2896,7 +2881,7 @@ CheckBordersInBox( CurveComposite& CompoA, CurveComposite& CompoB,
|
||||
return false ;
|
||||
double dMinSqDist = INFINITO ;
|
||||
int nTria = 0 ;
|
||||
for ( int nT = 0 ; nT < int( vTBox.size()) ; ++ nT) {
|
||||
for ( int nT = 0 ; nT < ssize( vTBox) ; ++ nT) {
|
||||
Triangle3d Tria ;
|
||||
if ( ! Stm.GetTriangle( vTBox[nT], Tria))
|
||||
return false ;
|
||||
@@ -2924,10 +2909,10 @@ CheckBordersInBox( CurveComposite& CompoA, CurveComposite& CompoB,
|
||||
#endif
|
||||
|
||||
// Se ottengo una sola curva, allora la striscia si è chiusa
|
||||
if ( int( vCompoChain.size()) <= 1)
|
||||
if ( ssize( vCompoChain) <= 1)
|
||||
return true ;
|
||||
// Se ottengo ancora due curve, allora la striscia non rispetta lo spessore minimo
|
||||
bBreak = ( int( vCompoChain.size()) >= 2) ;
|
||||
bBreak = ( ssize( vCompoChain) >= 2) ;
|
||||
if ( bBreak) {
|
||||
// Se devo fermare la ricerca e ho ancora CompoA e CompoB valide
|
||||
if ( bValidA && bValidB) {
|
||||
@@ -3302,7 +3287,7 @@ IsBorderACircle( const PolyLine& PL, double dLinTol, double dAngTol, Frame3d& fr
|
||||
// Per ogni coppia di punti calcolo la Distanza Massima e Minima dal centro del cerchio locale ( ORIG)
|
||||
double dSqMaxDist = 0. ;
|
||||
double dSqMinDist = INFINITO ;
|
||||
for ( int i = 0 ; i < int( floor( 0.5 * int( vPts.size()))) ; i = i + 2) {
|
||||
for ( int i = 0 ; i < ssize( vPts) / 2 ; i = i + 2) {
|
||||
double dSqLineDist = INFINITO ;
|
||||
DistPointLine( ORIG, vPts[i], vPts[i + 1]).GetSqDist( dSqLineDist) ;
|
||||
if ( dSqLineDist < dSqMinDist) {
|
||||
@@ -3562,7 +3547,7 @@ GetTrimmingFinalBorders( ICRVCOMPOPOVECTOR& vCompoBezierEdges, double dLinTol, d
|
||||
return false ;
|
||||
}
|
||||
// Se ho 1 curva, allora cerco di spezzarla
|
||||
else if ( int( vCompoBezierEdges.size()) == 1) {
|
||||
else if ( ssize( vCompoBezierEdges) == 1) {
|
||||
// Se sono presenti dei punti di rottura
|
||||
bool bOk = true ;
|
||||
if ( ! vBreakingPts.empty())
|
||||
@@ -3577,7 +3562,7 @@ GetTrimmingFinalBorders( ICRVCOMPOPOVECTOR& vCompoBezierEdges, double dLinTol, d
|
||||
LOG_INFO( GetEGkLogger(), "Warning in Trimming : Breaking curves failed") ;
|
||||
}
|
||||
// Se ho 2 curve, perfetto !
|
||||
else if ( int( vCompoBezierEdges.size()) == 2)
|
||||
else if ( ssize( vCompoBezierEdges) == 2)
|
||||
return true ;
|
||||
// Se più curve, errore
|
||||
else {
|
||||
@@ -3618,7 +3603,7 @@ GetTrimmingFinalBorders( CISURFPVECTOR& vpSurf, const SELVECTOR& vSurfFaces, dou
|
||||
|
||||
// Recupero la superficie TriMesh complessiva
|
||||
PtrOwner<const SurfTriMesh> pStm( nullptr) ;
|
||||
if ( int( vpSurf.size()) == 1) {
|
||||
if ( ssize( vpSurf) == 1) {
|
||||
const ISurf* pSurf = vpSurf[0] ;
|
||||
if ( pSurf == nullptr)
|
||||
return false ;
|
||||
@@ -3678,9 +3663,9 @@ GetTrimmingFinalBorders( CISURFPVECTOR& vpSurf, const SELVECTOR& vSurfFaces, dou
|
||||
}
|
||||
|
||||
// Restituisco le curve orientate correttamente per la creazione della superficie di Bezier
|
||||
erase_if( vCompoBezierEdges, []( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;
|
||||
}) ;
|
||||
erase_if( vCompoBezierEdges,
|
||||
[]( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;}) ;
|
||||
for ( int i = 0 ; i < ssize( vCompoBezierEdges) - 1 ; i += 2) {
|
||||
ManageRuledBorders( vCompoBezierEdges[i], vCompoBezierEdges[i+1]) ;
|
||||
// Essendo l'Offset fatto in negativo, entrambe le curve vanno invertite
|
||||
@@ -3707,7 +3692,7 @@ GetTrimmingBezierEdges( ICRVCOMPOPOVECTOR& vCompoRawEdges, double dLinTol, doubl
|
||||
|
||||
#if DEBUG_EDGES
|
||||
VC.clear() ; VT.clear() ;
|
||||
for ( int _i = 0 ; _i < int( vCompoRawEdges.size()) ; ++ _i) {
|
||||
for ( int _i = 0 ; _i < ssize( vCompoRawEdges) ; ++ _i) {
|
||||
VT.emplace_back( vCompoRawEdges[_i]->Clone()) ;
|
||||
VC.emplace_back( RED) ;
|
||||
}
|
||||
@@ -3715,7 +3700,7 @@ GetTrimmingBezierEdges( ICRVCOMPOPOVECTOR& vCompoRawEdges, double dLinTol, doubl
|
||||
|
||||
// Approssimo i bordi grezzi
|
||||
vBezierEdges.reserve( vCompoRawEdges.size()) ;
|
||||
for ( int i = 0 ; i < int( vCompoRawEdges.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCompoRawEdges) ; ++ i) {
|
||||
PtrOwner<ICurveComposite> pCompoTmp( CloneCurveComposite( vCompoRawEdges[i])) ;
|
||||
if ( IsNull( pCompoTmp) ||
|
||||
! ApproxBorder( *GetBasicCurveComposite( pCompoTmp), dMyLinTol, dMyAngTol) ||
|
||||
@@ -3726,15 +3711,15 @@ GetTrimmingBezierEdges( ICRVCOMPOPOVECTOR& vCompoRawEdges, double dLinTol, doubl
|
||||
}
|
||||
|
||||
// Restituisco le curve orientate correttamente per la creazione della superficie di Bezier
|
||||
erase_if( vBezierEdges, []( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;
|
||||
}) ;
|
||||
erase_if( vBezierEdges,
|
||||
[]( ICurveComposite* pBezierEdge) {
|
||||
return ( pBezierEdge == nullptr || ! pBezierEdge->IsValid() || pBezierEdge->GetCurveCount() == 0) ;}) ;
|
||||
for ( int i = 0 ; i < ssize( vBezierEdges) - 1 ; i += 2)
|
||||
ManageRuledBorders( vBezierEdges[i], vBezierEdges[i+1]) ;
|
||||
|
||||
#if DEBUG_EDGES
|
||||
VC.clear() ; VT.clear() ;
|
||||
for ( int _i = 0 ; _i < int( vBezierEdges.size()) ; ++ _i) {
|
||||
for ( int _i = 0 ; _i < ssize( vBezierEdges) ; ++ _i) {
|
||||
VT.emplace_back( vBezierEdges[_i]->Clone()) ;
|
||||
VC.emplace_back( ORANGE) ;
|
||||
}
|
||||
@@ -3776,7 +3761,7 @@ GetTrimmingSurfBzSyncPoints( const ICurve* pCrvEdge1, const ICurve* pCrvEdge2,
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
pSBzRuled->GetAllPatchesIsocurves( false, vCrv) ;
|
||||
vSyncPoints.reserve( vCrv.size()) ;
|
||||
for ( int i = 0 ; i < int( vCrv.size()) ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vCrv) ; ++ i) {
|
||||
if ( ! IsNull( vCrv[i]) && vCrv[i]->IsValid()) {
|
||||
#if DEBUG_SYNC_POINTS
|
||||
VT.emplace_back( vCrv[i]->Clone()) ;
|
||||
@@ -4035,14 +4020,14 @@ GetTrimmingAdjSurfs( const CISURFPVECTOR& vSurf, const CISURFPVECTOR& vOtherSurf
|
||||
// Recupero le Patch delle superfici
|
||||
SURFPATCHESVECTOR vSurfPatches ; vSurfPatches.reserve( vSurf.size() + vOtherSurf.size()) ;
|
||||
// --- Superfici Selezionate
|
||||
for ( int nS = 0 ; nS < int( vSurf.size()) ; ++ nS) {
|
||||
for ( int nS = 0 ; nS < ssize( vSurf) ; ++ nS) {
|
||||
vSurfPatches.emplace_back( SurfPatches()) ;
|
||||
vSurfPatches.back().pSurf = vSurf[nS] ;
|
||||
if ( ! CalcSurfPatch( vSurf[nS], dLinTol, dAngTol, vSurfPatches.back()))
|
||||
return false ;
|
||||
}
|
||||
// --- Altre Superfici
|
||||
for ( int nS = 0 ; nS < int( vOtherSurf.size()) ; ++ nS) {
|
||||
for ( int nS = 0 ; nS < ssize( vOtherSurf) ; ++ nS) {
|
||||
vSurfPatches.emplace_back( SurfPatches()) ;
|
||||
vSurfPatches.back().pSurf = vOtherSurf[nS] ;
|
||||
if ( ! CalcSurfPatch( vOtherSurf[nS], dLinTol, dAngTol, vSurfPatches.back()))
|
||||
@@ -4225,7 +4210,7 @@ GetTrimmingAdjSurfs( const CISURFPVECTOR& vSurf, const CISURFPVECTOR& vOtherSurf
|
||||
// della tolleranza angolare
|
||||
INTVECTOR vSurfToCheck ;
|
||||
INTSET setSurf ;
|
||||
for ( int i = 0 ; i < int( vSurf.size()) ; ++ i)
|
||||
for ( int i = 0 ; i < ssize( vSurf) ; ++ i)
|
||||
vSurfToCheck.push_back( i) ;
|
||||
|
||||
// Finchè ho una superficie da analizzare
|
||||
@@ -4341,7 +4326,7 @@ GetTrimmingAdjSurfs( const CISURFPVECTOR& vSurf, const CISURFPVECTOR& vOtherSurf
|
||||
#endif
|
||||
vSurfToCheck.emplace_back( nOtherSurf) ;
|
||||
OtherPatch.bErase = true ;
|
||||
if ( nOtherSurf >= int( vSurf.size()) &&
|
||||
if ( nOtherSurf >= ssize( vSurf) &&
|
||||
find( vIndOtherSurf.begin(), vIndOtherSurf.end(), nOtherSurf - ssize( vSurf)) == vIndOtherSurf.end())
|
||||
vIndOtherSurf.push_back( nOtherSurf - ssize( vSurf)) ;
|
||||
}
|
||||
@@ -4466,107 +4451,105 @@ GetTrimmingHoleBorders( const CISURFPVECTOR& vpSurf, const Point3d& ptRef, doubl
|
||||
|
||||
// Vedo se ci sono curve da accoppiare tra di loro
|
||||
vHoleBorders.reserve( vHoles.size()) ;
|
||||
if ( ssize( vHoles) > 1) {
|
||||
for ( int i = 0 ; i < ssize( vHoles) - 1 ; ++ i) {
|
||||
for ( int i = 0 ; i < ssize( vHoles) - 1 ; ++ i) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
continue ;
|
||||
int nIndJ = -1 ;
|
||||
// Scorro le curve successive
|
||||
for ( int j = i + 1 ; nIndJ == -1 && j < ssize( vHoles) ; ++ j) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
continue ;
|
||||
int nIndJ = -1 ;
|
||||
// Scorro le curve successive
|
||||
for ( int j = i + 1 ; nIndJ == -1 && j < ssize( vHoles) ; ++ j) {
|
||||
// Recupero la curva corrente, se non presente allora passo alla successiva
|
||||
if ( IsNull( vHoles[i].pCompoHole))
|
||||
continue ;
|
||||
// Se il tipo è differente non possono essere in coppia
|
||||
if ( vHoles[i].nType != vHoles[j].nType)
|
||||
continue ;
|
||||
// Essendo della stessa topologia, verifico i parametri
|
||||
bool bCouple = false ;
|
||||
Vector3d vtCenCen ;
|
||||
if ( vHoles[i].nType == HoleType::CIRCLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
// Se il tipo è differente non possono essere in coppia
|
||||
if ( vHoles[i].nType != vHoles[j].nType)
|
||||
continue ;
|
||||
// Essendo della stessa topologia, verifico i parametri
|
||||
bool bCouple = false ;
|
||||
Vector3d vtCenCen ;
|
||||
if ( vHoles[i].nType == HoleType::CIRCLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
}
|
||||
else if ( vHoles[i].nType == HoleType::BUTTONHOLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
abs( vHoles[i].dLen - vHoles[j].dLen) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( bCouple)
|
||||
nIndJ = j ;
|
||||
}
|
||||
else if ( vHoles[i].nType == HoleType::BUTTONHOLE) {
|
||||
bCouple = ( abs( vHoles[i].dRad - vHoles[j].dRad) < dMyEdgeLinTol &&
|
||||
abs( vHoles[i].dLen - vHoles[j].dLen) < dMyEdgeLinTol &&
|
||||
AreSameOrOppositeVectorEpsilon( vHoles[i].frCompo.VersZ(), vHoles[j].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
if ( bCouple) {
|
||||
vtCenCen = ( vHoles[i].frCompo.Orig() - vHoles[j].frCompo.Orig()) ;
|
||||
bCouple = ( vtCenCen.SqLen() > dMyEdgeLinTol * dMyEdgeLinTol) ;
|
||||
if ( bCouple) {
|
||||
bCouple = ( vtCenCen.Normalize() &&
|
||||
AreSameOrOppositeVectorEpsilon( vtCenCen, vHoles[i].frCompo.VersZ(), dMyEdgeLinTol)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( bCouple)
|
||||
nIndJ = j ;
|
||||
}
|
||||
|
||||
// Determino l'indice della curva da conservare
|
||||
int nInd = i ;
|
||||
// Se curva non in coppia, allora ho finito, altrimenti devo sceglierne una
|
||||
if ( nIndJ != -1) {
|
||||
int nIndToErase = nIndJ ;
|
||||
// Recupero i due Box
|
||||
BBox3d BBoxI ; vHoles[i].pCompoHole->GetLocalBBox( BBoxI) ;
|
||||
BBox3d BBoxJ ; vHoles[nIndJ].pCompoHole->GetLocalBBox( BBoxJ) ;
|
||||
// Recupero le Coordinate massime di ZGlob
|
||||
double dZI = BBoxI.GetMax().z ;
|
||||
double dZJ = BBoxJ.GetMax().z ;
|
||||
// Se le 2 curve hanno ZGlob massime differente tra loro
|
||||
if ( abs( dZI - dZJ) > 5. * EPS_SMALL) {
|
||||
// Tengo la Curva con ZGlob massima
|
||||
if ( dZJ > dZI)
|
||||
// Determino l'indice della curva da conservare
|
||||
int nInd = i ;
|
||||
// Se curva non in coppia, allora ho finito, altrimenti devo sceglierne una
|
||||
if ( nIndJ != -1) {
|
||||
int nIndToErase = nIndJ ;
|
||||
// Recupero i due Box
|
||||
BBox3d BBoxI ; vHoles[i].pCompoHole->GetLocalBBox( BBoxI) ;
|
||||
BBox3d BBoxJ ; vHoles[nIndJ].pCompoHole->GetLocalBBox( BBoxJ) ;
|
||||
// Recupero le Coordinate massime di ZGlob
|
||||
double dZI = BBoxI.GetMax().z ;
|
||||
double dZJ = BBoxJ.GetMax().z ;
|
||||
// Se le 2 curve hanno ZGlob massime differente tra loro
|
||||
if ( abs( dZI - dZJ) > 5. * EPS_SMALL) {
|
||||
// Tengo la Curva con ZGlob massima
|
||||
if ( dZJ > dZI)
|
||||
swap( nInd, nIndToErase) ;
|
||||
}
|
||||
// Se invece le ZGlob sono circa uguali
|
||||
else {
|
||||
// Tengo la Curva più distante dal punto di Riferimento ( se Valido)
|
||||
if ( ptRef.IsValid()) {
|
||||
double dSqDistI = INFINITO, dSqDistJ = INFINITO ;
|
||||
DistPointCurve( ptRef, *vHoles[i].pCompoHole).GetSqDist( dSqDistI) ;
|
||||
DistPointCurve( ptRef, *vHoles[nIndJ].pCompoHole).GetSqDist( dSqDistJ) ;
|
||||
if ( dSqDistJ > dSqDistI)
|
||||
swap( nInd, nIndToErase) ;
|
||||
}
|
||||
// Se invece le ZGlob sono circa uguali
|
||||
else {
|
||||
// Tengo la Curva più distante dal punto di Riferimento ( se Valido)
|
||||
if ( ptRef.IsValid()) {
|
||||
double dSqDistI = INFINITO, dSqDistJ = INFINITO ;
|
||||
DistPointCurve( ptRef, *vHoles[i].pCompoHole).GetSqDist( dSqDistI) ;
|
||||
DistPointCurve( ptRef, *vHoles[nIndJ].pCompoHole).GetSqDist( dSqDistJ) ;
|
||||
if ( dSqDistJ > dSqDistI)
|
||||
swap( nInd, nIndToErase) ;
|
||||
}
|
||||
}
|
||||
// Elimino la curva non significativa delle 2
|
||||
vHoles[nIndToErase].pCompoHole.Reset() ;
|
||||
}
|
||||
|
||||
// Imposto Estrusione alla curva nInd-esima
|
||||
Vector3d vtExtr = vHoles[nInd].frCompo.VersZ() ;
|
||||
// Se Estrusione perpendicolare a Z_AX
|
||||
if ( OrthoCompo( Z_AX, vtExtr).Len() > 1 - 5. * EPS_SMALL) {
|
||||
// Se punto di Riferimento valido
|
||||
if ( ptRef.IsValid()) {
|
||||
Vector3d vtCenCen = vHoles[nInd].frCompo.Orig() - ptRef ;
|
||||
vtCenCen.Normalize() ;
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * vtCenCen > 0.) ? vtExtr : - vtExtr) ;
|
||||
}
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( vtExtr) ;
|
||||
}
|
||||
// Se estrusione non perpendicolare a Z_AX
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * Z_AX > 0.) ? vtExtr : - vtExtr) ;
|
||||
|
||||
// Imposso Spessore alla curva nInd-esima
|
||||
vHoles[nInd].pCompoHole->SetThickness( - dMyEdgeThick) ;
|
||||
|
||||
// Memorizzo la curva nInd-esima
|
||||
vHoleBorders.emplace_back( Release( vHoles[nInd].pCompoHole)) ;
|
||||
// Elimino la curva non significativa delle 2
|
||||
vHoles[nIndToErase].pCompoHole.Reset() ;
|
||||
}
|
||||
|
||||
// Imposto Estrusione alla curva nInd-esima
|
||||
Vector3d vtExtr = vHoles[nInd].frCompo.VersZ() ;
|
||||
// Se Estrusione perpendicolare a Z_AX
|
||||
if ( OrthoCompo( Z_AX, vtExtr).Len() > 1 - 5. * EPS_SMALL) {
|
||||
// Se punto di Riferimento valido
|
||||
if ( ptRef.IsValid()) {
|
||||
Vector3d vtCenCen = vHoles[nInd].frCompo.Orig() - ptRef ;
|
||||
vtCenCen.Normalize() ;
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * vtCenCen > 0.) ? vtExtr : - vtExtr) ;
|
||||
}
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( vtExtr) ;
|
||||
}
|
||||
// Se estrusione non perpendicolare a Z_AX
|
||||
else
|
||||
vHoles[nInd].pCompoHole->SetExtrusion( ( vtExtr * Z_AX > 0.) ? vtExtr : - vtExtr) ;
|
||||
|
||||
// Imposso Spessore alla curva nInd-esima
|
||||
vHoles[nInd].pCompoHole->SetThickness( - dMyEdgeThick) ;
|
||||
|
||||
// Memorizzo la curva nInd-esima
|
||||
vHoleBorders.emplace_back( Release( vHoles[nInd].pCompoHole)) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
+3
-3
@@ -1601,9 +1601,9 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
PNTVECTOR vPntTopStartBack(3) ;
|
||||
PNTVECTOR vPntTopEndBack(3) ;
|
||||
if ( nSub > 1) {
|
||||
if( bTopIsPivot)
|
||||
if ( bTopIsPivot)
|
||||
vtDirTop = vtDirTip ;
|
||||
if( bTipIsPivot)
|
||||
if ( bTipIsPivot)
|
||||
vtDirTip = vtDirTop ;
|
||||
// determino in che modo collegare il cilindro iniziale con quello finale
|
||||
Vector3d vtTopBaseEnd = vtDirTop - (( vtDirTop * vtLe) * vtLe) ;
|
||||
@@ -1812,7 +1812,7 @@ VolZmap::Comp_5AxisMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c
|
||||
}
|
||||
}
|
||||
|
||||
if( ! bTopIsPivot) {
|
||||
if ( ! bTopIsPivot) {
|
||||
// superiori
|
||||
if ( dSide > 0) {
|
||||
PNTVECTOR vPntTop01 = cBezTopStartF1->GetAllControlPoints();
|
||||
|
||||
Reference in New Issue
Block a user