diff --git a/ArcPntDirTgCurve.cpp b/ArcPntDirTgCurve.cpp index 9c2a9ad..b5d2d0a 100644 --- a/ArcPntDirTgCurve.cpp +++ b/ArcPntDirTgCurve.cpp @@ -297,7 +297,7 @@ GetArcPntDirTgBezier( const Point3d& ptP, const Vector3d& vtDir, const CurveBezi return nullptr ; // calcolo la circonferenza tangente a questa approssimazione Point3d ptTg ; - PtrOwner pCrv( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg))) ; + PtrOwner pCrv( GetArcPntDirTgCurve( ptP, vtDir, *pCrvCompo, ptNear, vtN, &ptTg)) ; if ( IsNull( pCrv)) return nullptr ; // porto il punto di tangenza della circonferenza esattamente sulla curva di Bezier @@ -330,7 +330,7 @@ GetArcPntDirTgCompo( const Point3d& ptP, const Vector3d& vtDir, const CurveCompo pCrv = crvCompo.GetNextCurve()) { // recupero la circonferenza tangente alla curva elementare Point3d ptTg ; - PtrOwner pCrvTmp( GetCurve( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg))) ; + PtrOwner pCrvTmp( GetArcPntDirTgCurve( ptP, vtDir, *pCrv, ptNear, vtN, &ptTg)) ; if ( IsNull( pCrvTmp)) continue ; // verifico se è la più vicina al punto desiderato diff --git a/BiArcs.cpp b/BiArcs.cpp index 0906fc3..f98eed1 100644 --- a/BiArcs.cpp +++ b/BiArcs.cpp @@ -14,10 +14,10 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "BiArcs.h" +#include "CurveLine.h" #include "CurveArc.h" +#include "CurveComposite.h" #include "/EgtDev/Include/EGkAngle.h" -#include "/EgtDev/Include/EGkCurveLine.h" -#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkArcSpecial.h" #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EgtNumUtils.h" @@ -50,7 +50,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir return nullptr ; // preparo la curva composita per i biarchi - PtrOwner pBiArc( CreateCurveComposite()) ; + PtrOwner pBiArc( CreateBasicCurveComposite()) ; if ( IsNull( pBiArc)) return nullptr ; @@ -95,7 +95,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, 0.5)) ; } else { - CurveArc* pArc = GetBasicCurveArc( pJCrv) ; + const CurveArc* pArc = GetBasicCurveArc( pJCrv) ; if ( pArc == nullptr) return nullptr ; double dU = -1 ; @@ -172,7 +172,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD // se rotazione nulla, allora segmento di retta tra i due punti if ( abs( dAngDeg) < EPS_ANG_SMALL) { - PtrOwner pLine( CreateCurveLine()) ; + PtrOwner pLine( CreateBasicCurveLine()) ; if ( IsNull( pLine) || ! pLine->Set( ptP0, ptP1)) return nullptr ; // inverto per avere parametrizzazione crescente allontanandosi da Dir0 e avvicinandosi a Dir1 @@ -194,7 +194,7 @@ CalcJCurve( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dD Vector3d vtStart = ptP0 - ptCen ; double dRad, dAngStart ; vtStart.ToSpherical( &dRad, nullptr, &dAngStart) ; - PtrOwner pArc( CreateCurveArc()) ; + PtrOwner pArc( CreateBasicCurveArc()) ; if ( IsNull( pArc) || ! pArc->SetXY( ptCen, dRad, dAngStart, dAngDeg, ( ptP1.z - ptP0.z))) return nullptr ; double dDirStartDeg = dAngStart + ( dAngDeg > 0 ? ANG_RIGHT : - ANG_RIGHT) ; diff --git a/CalcPocketing.cpp b/CalcPocketing.cpp index e485509..9c53141 100644 --- a/CalcPocketing.cpp +++ b/CalcPocketing.cpp @@ -15,10 +15,11 @@ #include "stdafx.h" #include "DllMain.h" #include "GeoConst.h" -#include "CurveArc.h" -#include "BiArcs.h" #include "CurveLine.h" -#include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "CurveArc.h" +#include "CurveComposite.h" +#include "BiArcs.h" +#include "SurfFlatRegion.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkCalcPocketing.h" @@ -30,7 +31,6 @@ #include "EgtDev/Include/EGkLinePntTgCurve.h" #include - using namespace std ; //---------------------------------------------------------------------------- @@ -43,15 +43,14 @@ enum { POCKET_ZIGZAG = 0, POCKET_SPIRALOUT = 3 } ; // variabili d'appoggio ( per non passare troppi parametri tra le funzioni secondarie) -int TYPE ; -double RAD ; -bool SMOOTH ; +static int s_nType = 0 ; +static double s_dRad = 0 ; +static bool s_bSmooth = false ; //---------------------------------------------------------------------------- static bool AdjustContourStart( ICurveComposite* pCompo) { - // creo un vettore di indici che definisce l'ordine delle curve chiuse in base alla lunghezza INTVECTOR vInd ; vInd.reserve( pCompo->GetCurveCount()) ; @@ -109,9 +108,8 @@ AdjustContourStart( ICurveComposite* pCompo) static bool ModifyCurveToSmoothed( ICurveComposite* pCrv, double dRightLen, double dLeftLen, bool bAsParam) { - // se non richiesto non faccio nulla - if ( ! SMOOTH) + if ( ! s_bSmooth) return true ; // controllo parametri @@ -237,7 +235,7 @@ ModifyCurveToSmoothed( ICurveComposite* pCrv, double dRightLen, double dLeftLen, } // creo la curva che restituirò - PtrOwner pCrvCO_temp( CreateCurveComposite()) ; + PtrOwner pCrvCO_temp( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCO_temp)) return false ; Point3d ptArcHelp, ptFirstPoint ; @@ -353,22 +351,22 @@ CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, ICRVCOMPOPOVECTOR } // creo la retta che li unisce - PtrOwner pCompoLine( CreateCurveComposite()) ; - if ( ! pCompoLine->AddPoint( ptStart) || ! pCompoLine->AddLine( ptEnd)) + PtrOwner pCompoLine( CreateBasicCurveComposite()) ; + if ( ! pCompoLine->AddPoint( ptStart) || ! pCompoLine->AddLine( ptEnd)) return false ; pCompoLine->SetExtrusion( vtExtr) ; // la porto in locale al riferimento della svuotatura CurveLocal LineLoc( pCompoLine, GLOB_FRM, frLoc) ; // ... per le intersezioni // creo la nuova curva formata dai tratti di linee INTERNI alle isole e dai tratti sul bordo degli offset - PtrOwner pCompo( pCompoLine->Clone()) ; + PtrOwner pCompo( pCompoLine->Clone()) ; if ( IsNull( pCompo) ) return false ; if ( ! pCompo->LocToLoc( GLOB_FRM, frLoc) ) return false; // memorizzo il tratto lineare nel caso qualche operazione fallisse - PtrOwner pCompoHelp( pCompoLine->Clone()) ; + PtrOwner pCompoHelp( pCompoLine->Clone()) ; if ( IsNull( pCompoHelp)) return false ; if ( ! pCompoHelp->LocToLoc( GLOB_FRM, frLoc)) @@ -381,9 +379,10 @@ CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, ICRVCOMPOPOVECTOR intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ; if ( ! pCompoHelp->Clear()) return false ; - - for ( int j = 0 ; j < int( ccClass.size()) ; ++j ) { // per ogni intersezione j con l'offset dell'isola i - if ( ccClass[j].nClass == CRVC_OUT) { // se ho intersezione spezzo il segmento + // per ogni intersezione j con l'offset dell'isola i + for ( int j = 0 ; j < int( ccClass.size()) ; ++j ) { + // se ho intersezione spezzo il segmento + if ( ccClass[j].nClass == CRVC_OUT) { Point3d ptS ; pCompo->GetPointD1D2( ccClass[j].dParS, ICurve::FROM_PLUS, ptS) ; double dOffS ; @@ -393,14 +392,13 @@ CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, ICRVCOMPOPOVECTOR double dOffE ; vOffIslands[i]->GetParamAtPoint( ptE, dOffE) ; // recupero i due possibili percorsi e uso il più corto - PtrOwner pCrvA( GetCurve( vOffIslands[i]->CopyParamRange( dOffS, dOffE))) ; - PtrOwner pCrvB( GetCurve( vOffIslands[i]->CopyParamRange( dOffE, dOffS))) ; - - if ( IsNull( pCrvA) || IsNull( pCrvB) ) + PtrOwner pCrvA( vOffIslands[i]->CopyParamRange( dOffS, dOffE)) ; + PtrOwner pCrvB( vOffIslands[i]->CopyParamRange( dOffE, dOffS)) ; + if ( IsNull( pCrvA) || IsNull( pCrvB)) return false ; double dLenA ; pCrvA->GetLength( dLenA) ; double dLenB ; pCrvB->GetLength( dLenB) ; - if ( dLenA < dLenB ) { + if ( dLenA < dLenB) { pCompoHelp->AddCurve( Release( pCrvA)) ; } else { @@ -408,14 +406,14 @@ CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, ICRVCOMPOPOVECTOR pCompoHelp->AddCurve( Release( pCrvB)) ; } } - else { // se non interseco + // se non interseco + else { pCompoHelp->AddCurve( pCompo->CopyParamRange( ccClass[j].dParS, ccClass[j].dParE)) ; } } pCompo->Clear() ; pCompo->AddCurve( pCompoHelp->Clone()) ; - } // riporto pCompo nel sistema di riferimento originale @@ -424,7 +422,6 @@ CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, ICRVCOMPOPOVECTOR pCrvLink->AddCurve( Release( pCompo)) ; return true ; - } //----------------------------------------------------------------------------- @@ -444,30 +441,30 @@ ModifyBiArc( ICurve* pBiArcLink, double dToll, ICurveComposite* pNewBiArc) pBiArcLink->GetDomain( dUS, dUE) ; // prendo i due archi della curva BiArco - PtrOwner pArc1( GetCurve( pBiArcLink->CopyParamRange( dUS, ( dUS + dUE) / 2))) ; - PtrOwner pArc2( GetCurve( pBiArcLink->CopyParamRange(( dUS + dUE ) / 2, dUE))) ; + PtrOwner pArc1( pBiArcLink->CopyParamRange( dUS, ( dUS + dUE) / 2)) ; + PtrOwner pArc2( pBiArcLink->CopyParamRange(( dUS + dUE ) / 2, dUE)) ; if ( IsNull( pArc1) || ! pArc1->IsValid() || IsNull( pArc2) || ! pArc2->IsValid()) return false ; // primo pezzo pArc1->GetDomain( dUS, dUE) ; - PtrOwner pArc1A( GetCurve( pArc1->CopyParamRange( dUS, dUS + ( dUE - dUS ) * dToll))) ; // Arc1 - PtrOwner pArc1B( GetCurve( pArc1->CopyParamRange( dUE - ( dUE - dUS ) * dToll, dUE))) ; // Arc2 + PtrOwner pArc1A( pArc1->CopyParamRange( dUS, dUS + ( dUE - dUS ) * dToll)) ; // Arc1 + PtrOwner pArc1B( pArc1->CopyParamRange( dUE - ( dUE - dUS ) * dToll, dUE)) ; // Arc2 Point3d pt1A, pt1B ; pArc1A->GetEndPoint( pt1A) ; pArc1B->GetStartPoint( pt1B) ; - PtrOwner pLine1( CreateCurveLine()) ; - pLine1->Set( pt1A, pt1B) ; // Linea + PtrOwner pLine1( CreateBasicCurveLine()) ; + pLine1->Set( pt1A, pt1B) ; // secondo pezzo pArc2->GetDomain( dUS, dUE) ; - PtrOwner pArc2A( GetCurve( pArc2->CopyParamRange( dUS, dUS + ( dUE - dUS ) * dToll))) ; // Arc1 - PtrOwner pArc2B( GetCurve( pArc2->CopyParamRange( dUE - ( dUE - dUS ) * dToll, dUE))) ; // Arc2 + PtrOwner pArc2A( pArc2->CopyParamRange( dUS, dUS + ( dUE - dUS ) * dToll)) ; // Arc1 + PtrOwner pArc2B( pArc2->CopyParamRange( dUE - ( dUE - dUS ) * dToll, dUE)) ; // Arc2 Point3d pt2A, pt2B ; pArc2A->GetEndPoint( pt2A) ; pArc2B->GetStartPoint( pt2B) ; - PtrOwner pLine2( CreateCurveLine()) ; - pLine2->Set( pt2A, pt2B) ; // Linea + PtrOwner pLine2( CreateBasicCurveLine()) ; + pLine2->Set( pt2A, pt2B) ; // ricostruisco il nuovo link if ( ! pNewBiArc->AddCurve( Release( pArc1A)) || @@ -487,9 +484,8 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P const Vector3d& vtEnd, double dParMeet, ICRVCOMPOPOVECTOR& vOffIslands, ICurveComposite* pCrvLink) { - // se senza smusso, ritorno tratto lineare - if ( ! SMOOTH) + if ( ! s_bSmooth) return CalcBoundedLink( ptStart, ptEnd, vOffIslands, pCrvLink) ; // creo il BiArc che unisce i due punti @@ -500,7 +496,7 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P if ( dParMeet != 0) pBiArcLink.Set( GetBiArc( ptStart, -dAngStart, ptEnd, -dAngEnd, dParMeet)) ; else { - PtrOwner pCrvCir( CreateCurveArc()) ; + PtrOwner pCrvCir( CreateBasicCurveArc()) ; if ( IsNull( pCrvCir)) return false ; pCrvCir->SetCPAN( Media( ptStart, ptEnd), ptStart, - 360, 0, Z_AX) ; @@ -515,7 +511,7 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P double dLenBiArc ; pBiArcLink->GetLength( dLenBiArc) ; if ( dLenBiArc > 200 * 1000 * EPS_SMALL) { - PtrOwner pCrvNewBiArcS( CreateCurveComposite()) ; + PtrOwner pCrvNewBiArcS( CreateBasicCurveComposite()) ; ModifyBiArc( pBiArcLink, 0.2, pCrvNewBiArcS) ; pBiArcLink.Set( pCrvNewBiArcS) ; } @@ -536,10 +532,10 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ; if ( ! pCompoHelp->Clear()) return false ; - - for ( int j = 0 ; j < int( ccClass.size()) ; ++ j) { // per ogni intersezione j con l'offset dell'isola i - - if ( ccClass[j].nClass == CRVC_OUT && ccClass.size() > 1) { // se ho intersezione spezzo il segmento + // per ogni intersezione j con l'offset dell'isola i + for ( int j = 0 ; j < int( ccClass.size()) ; ++ j) { + // se ho intersezione spezzo il segmento + if ( ccClass[j].nClass == CRVC_OUT && ccClass.size() > 1) { Point3d ptS ; pCompo->GetPointD1D2( ccClass[j].dParS, ICurve::FROM_PLUS, ptS) ; double dOffS ; @@ -549,8 +545,8 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P double dOffE ; vOffIslands[i]->GetParamAtPoint( ptE, dOffE, 1500 * EPS_SMALL) ; // recupero i due possibili percorsi e uso il più corto - PtrOwner pCrvA( GetCurve( vOffIslands[i]->CopyParamRange( dOffS, dOffE))) ; - PtrOwner pCrvB( GetCurve( vOffIslands[i]->CopyParamRange( dOffE, dOffS))) ; + PtrOwner pCrvA( vOffIslands[i]->CopyParamRange( dOffS, dOffE)) ; + PtrOwner pCrvB( vOffIslands[i]->CopyParamRange( dOffE, dOffS)) ; if ( IsNull( pCrvA) || IsNull( pCrvB)) return CalcBoundedLink( ptStart, ptEnd, vOffIslands, pCrvLink) ; @@ -575,7 +571,8 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P return CalcBoundedLink( ptStart, ptEnd, vOffIslands, pCrvLink) ; } } - else { // se non interseco + // se non interseco + else { if ( ! pCompoHelp->AddCurve( pCompo->CopyParamRange( ccClass[j].dParS, ccClass[j].dParE))) return CalcBoundedLink( ptStart, ptEnd, vOffIslands, pCrvLink) ; } @@ -585,7 +582,6 @@ CalcBoundedSmootedLink( const Point3d& ptStart, const Vector3d& vtStart, const P if ( ! pCompo->AddCurve( pCompoHelp->Clone())) if ( ! CalcBoundedLink( ptStart, ptEnd, vOffIslands, pCrvLink)) return false ; - } // se il BiArco è troppo piccolo allora lo approssimo con un segmento @@ -618,7 +614,7 @@ CutCurveToConnect( ICurveComposite* pCrvS, ICurveComposite* pCrvE, ICRVCOMPOPOVE pCrvLink->Clear() ; // curva finale da restituire - PtrOwner ptCrvFinal( CreateCurveComposite()) ; + PtrOwner ptCrvFinal( CreateBasicCurveComposite()) ; if ( IsNull( ptCrvFinal)) return false ; @@ -645,8 +641,8 @@ CutCurveToConnect( ICurveComposite* pCrvS, ICurveComposite* pCrvE, ICRVCOMPOPOVE if ( vFirstOffset[i]->IsPointOn( ptES) && vFirstOffset[i]->IsPointOn( ptEE)) dLenPercE = 0 ; } - double dLStepS = dLenPercS < EPS_SMALL ? 0. : RAD ; - double dLStepE = dLenPercE < EPS_SMALL ? 0. : RAD ; + double dLStepS = ( dLenPercS < EPS_SMALL ? 0. : s_dRad) ; + double dLStepE = ( dLenPercE < EPS_SMALL ? 0. : s_dRad) ; dLenE = 0 ; // calcolo i possibili BiArchi tra le due curve @@ -656,7 +652,7 @@ CutCurveToConnect( ICurveComposite* pCrvS, ICurveComposite* pCrvE, ICRVCOMPOPOVE while ( nIter < nMaxIter) { // calcolo il BiArco - PtrOwner ptBiArc( CreateCurveComposite()) ; + PtrOwner ptBiArc( CreateBasicCurveComposite()) ; if ( ! CalcBoundedSmootedLink( ptSE, vS, ptES, vE, 0.5, vFirstOffset, ptBiArc) || ptBiArc->GetCurveCount() == 0) return false ; @@ -701,7 +697,6 @@ CutCurveToConnect( ICurveComposite* pCrvS, ICurveComposite* pCrvE, ICRVCOMPOPOVE pCrvE_clone->GetStartDir( vE) ; ++ nIter ; - } pCrvLink->AddCurve( ptCrvFinal->Clone()) ; // ultimo arco valido trovato @@ -716,12 +711,12 @@ GetUnclearedRegion( ICRVCOMPOPOVECTOR& vFirstOffs, ICRVCOMPOPOVECTOR& vCrvs, ICU { // controllo dei parametri - if ( vFirstOffs.size() == 0 || ( int)vCrvs.size() < ( int)vFirstOffs.size()) + if ( vFirstOffs.empty() || vCrvs.size() < vFirstOffs.size()) return false ; pSrfToCut->Clear() ; // 1) creo la regione esterna - PtrOwner pSrfExtern( CreateSurfFlatRegion()) ; + PtrOwner pSrfExtern( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSrfExtern)) return false ; @@ -736,24 +731,24 @@ GetUnclearedRegion( ICRVCOMPOPOVECTOR& vFirstOffs, ICRVCOMPOPOVECTOR& vCrvs, ICU } // 2) Creo la regione svuotata dal Tool negli Offset, nei Links e sia dagli Offsets che dai Links - PtrOwner pSrfTool_Offs( CreateSurfFlatRegion()) ; - PtrOwner pSrfTool_Links( CreateSurfFlatRegion()) ; - PtrOwner pSrfTool( CreateSurfFlatRegion()) ; + PtrOwner pSrfTool_Offs( CreateBasicSurfFlatRegion()) ; + PtrOwner pSrfTool_Links( CreateBasicSurfFlatRegion()) ; + PtrOwner pSrfTool( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSrfTool_Offs) || IsNull( pSrfTool_Links) || IsNull( pSrfTool)) return false ; // creo un vettore che conterrà solamente i Link percorsi fino ad Ora ICRVCOMPOPOVECTOR vLinks_done ; - for ( int i = TYPE == POCKET_SPIRALIN ? 0 : ( int)vCrvs.size() - 1 ; - TYPE == POCKET_SPIRALIN ? i < int( vCrvs.size()) : i >= 0 ; - TYPE == POCKET_SPIRALIN ? ++ i : -- i) { + for ( int i = ( s_nType == POCKET_SPIRALIN ? 0 : ( int)vCrvs.size() - 1) ; + ( s_nType == POCKET_SPIRALIN ? i < int( vCrvs.size()) : i >= 0) ; + ( s_nType == POCKET_SPIRALIN ? ++ i : -- i)) { // ================= LINK ================================ - if ( i <= ( int)vLinks.size() && ! IsNull( vLinks[i]) && vLinks[i]->IsValid()) { + if ( i <= int( vLinks.size()) && ! IsNull( vLinks[i]) && vLinks[i]->IsValid()) { // prendo il Link i-esimo come composita ( potrebbe essere tratto lineare) - PtrOwner pCompoLink_i( CreateCurveComposite()) ; + PtrOwner pCompoLink_i( CreateBasicCurveComposite()) ; if ( IsNull( pCompoLink_i)) return false ; pCompoLink_i->AddCurve( vLinks[i]->Clone()) ; @@ -762,10 +757,10 @@ GetUnclearedRegion( ICRVCOMPOPOVECTOR& vFirstOffs, ICRVCOMPOPOVECTOR& vCrvs, ICU PtrOwner pCrvLink_i( vLinks[i]->Clone()) ; if ( IsNull( pCrvLink_i)) return false ; - PtrOwner pSrfToolRegLinki( GetSurfFlatRegionFromFatCurve( Release( pCrvLink_i), RAD + 5 * EPS_SMALL, false, false)) ; + PtrOwner pSrfToolRegLinki( GetSurfFlatRegionFromFatCurve( Release( pCrvLink_i), s_dRad + 5 * EPS_SMALL, false, false)) ; if ( ! IsNull( pSrfToolRegLinki)) { if ( ! pSrfTool_Links->IsValid() || pSrfTool_Links->GetChunkCount() == 0) - pSrfTool_Links.Set( pSrfToolRegLinki) ; + pSrfTool_Links.Set( GetBasicSurfFlatRegion( pSrfToolRegLinki)) ; else pSrfTool_Links->Add( *pSrfToolRegLinki) ; } @@ -779,13 +774,13 @@ GetUnclearedRegion( ICRVCOMPOPOVECTOR& vFirstOffs, ICRVCOMPOPOVECTOR& vCrvs, ICU // ================== OFFSET ============================= // aggiorno la superficie svuotata - PtrOwner pCrvOffs_i( CloneCurveComposite( vCrvs[i])) ; + PtrOwner pCrvOffs_i( CloneBasicCurveComposite( vCrvs[i])) ; if ( IsNull( pCrvOffs_i)) return false ; - PtrOwner pSrfToolRegOffi( GetSurfFlatRegionFromFatCurve( Release( pCrvOffs_i) , RAD + 5 * EPS_SMALL, false, false)) ; + PtrOwner pSrfToolRegOffi( GetSurfFlatRegionFromFatCurve( Release( pCrvOffs_i) , s_dRad + 5 * EPS_SMALL, false, false)) ; if ( ! IsNull( pSrfToolRegOffi)) { if ( ! pSrfTool_Offs->IsValid() || pSrfTool_Offs->GetChunkCount() == 0) - pSrfTool_Offs.Set( Release( pSrfToolRegOffi)) ; + pSrfTool_Offs.Set( GetBasicSurfFlatRegion( Release( pSrfToolRegOffi))) ; else pSrfTool_Offs->Add( *pSrfToolRegOffi) ; } @@ -811,15 +806,15 @@ RemoveFirstLoopFromSfr( ISurfFlatRegion* pSrfOrig) if ( pSrfOrig == nullptr) return true ; // superficie da restituire - PtrOwner pSrfRes( CreateSurfFlatRegion()) ; + PtrOwner pSrfRes( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSrfRes)) return false ; // scorro tutti i chunk tranne il primo ( escludo quindi il primo chunk) for ( int c = 1 ; c < pSrfOrig->GetChunkCount() ; ++ c) { - PtrOwner pSrfHelp( CreateSurfFlatRegion()) ; + PtrOwner pSrfHelp( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSrfHelp)) return false ; - PtrOwner pCrvMiniChunkBorder( GetCurveComposite( pSrfOrig->GetLoop( c, 0))) ; + PtrOwner pCrvMiniChunkBorder( GetBasicCurveComposite( pSrfOrig->GetLoop( c, 0))) ; pSrfHelp->AddExtLoop( pCrvMiniChunkBorder->Clone()) ; if ( c == 1) pSrfRes.Set( pSrfHelp->Clone()) ; @@ -848,7 +843,7 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT return false ; // curva che l'utensile dovrà seguire per svuotare la regione e curva di ingombro del tool - PtrOwner pCrvStepByStepPath( CreateCurveComposite()) ; + PtrOwner pCrvStepByStepPath( CreateBasicCurveComposite()) ; if ( IsNull( pCrvStepByStepPath)) return false ; @@ -868,9 +863,9 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT nIter++ ; PtrOwner pSrfBiggerChunk( pSrfChunkToCutClone->CloneChunk( 0)) ; - if( IsNull( pSrfBiggerChunk)) + if ( IsNull( pSrfBiggerChunk)) return false ; - if( ! pSrfBiggerChunk->IsValid()) + if ( ! pSrfBiggerChunk->IsValid()) break ; double dAreaExt ; @@ -889,28 +884,30 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT break ; // creo la superficie che racchiude il mio tool - PtrOwner pCrvToolShape( CreateCurveArc()) ; + PtrOwner pCrvToolShape( CreateBasicCurveArc()) ; if ( IsNull( pCrvToolShape)) return false ; - pCrvToolShape->SetXY( ptC, RAD + 5 * EPS_SMALL) ; - PtrOwner pSrfTool( CreateSurfFlatRegion()) ; + pCrvToolShape->SetXY( ptC, s_dRad + 5 * EPS_SMALL) ; + PtrOwner pSrfTool( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSrfTool) || ! pSrfTool->AddExtLoop( Release( pCrvToolShape)) || - ! pSrfTool->IsValid()) + ! pSrfTool->IsValid()) break ; - PtrOwner pSrfTest( CloneSurfFlatRegion( pSrfBiggerChunk)) ; - if( IsNull( pSrfTest)) + PtrOwner pSrfTest( CloneBasicSurfFlatRegion( pSrfBiggerChunk)) ; + if ( IsNull( pSrfTest)) return false ; pSrfTest->Subtract( *pSrfTool) ; - if( IsNull( pSrfTest) || ! pSrfTest->IsValid() || ! pSrfTest->GetArea( dArea) || dArea < 10 * EPS_SMALL || - bForceCentroid) { - if ( nIter == 1) { // se prima iterazione -> ritorno il centroide con punto + if ( IsNull( pSrfTest) || ! pSrfTest->IsValid() || ! pSrfTest->GetArea( dArea) || dArea < 10 * EPS_SMALL || + bForceCentroid) { + // se prima iterazione -> ritorno il centroide con punto + if ( nIter == 1) { nOptFlag = 1 ; ptCentroid = ptC ; return true ; } - else { // se non sono alla prima iterazione -> memorizzo il centroide nel vettore + // se non sono alla prima iterazione -> memorizzo il centroide nel vettore + else { // controllo di non aver trovato un centroide già inserito ( per simmetria del chunk) for ( int cen = 0 ; cen < int( vPtCentroid.size()) ; ++ cen) { if ( AreSamePointApprox( vPtCentroid[cen], ptC)) { @@ -920,7 +917,7 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT } vPtCentroid.push_back( ptC) ; pSrfChunkToCutClone->Subtract( *pSrfTool) ; - if( IsNull( pSrfChunkToCutClone) || ! pSrfChunkToCutClone->IsValid()) + if ( IsNull( pSrfChunkToCutClone) || ! pSrfChunkToCutClone->IsValid()) break ; continue ; } @@ -940,7 +937,7 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT continue ; } - PtrOwner pCrvMedAx( CreateCurveComposite()) ; + PtrOwner pCrvMedAx( CreateBasicCurveComposite()) ; if ( IsNull( pCrvMedAx)) return false ; if ( ! pCrvMedAx->FromPolyLine( PlMedAx)) { @@ -972,7 +969,7 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT } // 3) guardo quale regione svuoto con questa curva - PtrOwner pSrfRemoved( GetSurfFlatRegionFromFatCurve( Release( pCrvMedAx), RAD + 5 * EPS_SMALL, false, false)) ; + PtrOwner pSrfRemoved( GetSurfFlatRegionFromFatCurve( Release( pCrvMedAx), s_dRad + 5 * EPS_SMALL, false, false)) ; if ( IsNull( pSrfRemoved) || ! pSrfRemoved->IsValid()) break ; @@ -985,13 +982,14 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT } // se entrambi i vettori sono vuoti l'area originaria era più piccola di 10 * EPS_SMALL -> non faccio nulla - if (( int)vCrvCoMedAxi.size() == 0 && ( int)vPtCentroid.size() == 0) { + if ( vCrvCoMedAxi.empty() && vPtCentroid.empty()) { nOptFlag = 0 ; return true ; } // ora collego la varie curve medial Axis trovate tra loro (ottenendo quindi una curva che svuota tutta la regione) - PtrOwner pCrvCoBackLink( CreateCurveComposite()) ; // curva che collega primo e ultimo medial Axis + // curva che collega primo e ultimo medial Axis + PtrOwner pCrvCoBackLink( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCoBackLink)) return false ; Point3d ptSOriginal, ptEOriginal ; @@ -1015,7 +1013,7 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT ! vCrvCoMedAxi[i-1]->GetEndDir( vtS)) return false ; - PtrOwner pCrvLink( CreateCurveComposite()) ; + PtrOwner pCrvLink( CreateBasicCurveComposite()) ; if ( IsNull( pCrvLink)) return false ; @@ -1025,13 +1023,12 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT if ( ! pCrvPath->AddCurve( pCrvLink->Clone()) || ! pCrvPath->AddCurve( vCrvCoMedAxi[i]->Clone())) return false ; - } - if ( ! AreSamePointEpsilon( ptEOriginal, ptSOriginal, EPS_SMALL)) - if ( ! CalcBoundedSmootedLink( ptEOriginal, vtEOriginal, ptSOriginal, vtSOriginal, 0.5, vOffsFirstCurve, pCrvCoBackLink)) - if ( ! CalcBoundedLink( ptEOriginal, ptSOriginal, vOffsFirstCurve, pCrvCoBackLink)) - return false ; + if ( ! AreSamePointEpsilon( ptEOriginal, ptSOriginal, EPS_SMALL) && + ! CalcBoundedSmootedLink( ptEOriginal, vtEOriginal, ptSOriginal, vtSOriginal, 0.5, vOffsFirstCurve, pCrvCoBackLink) && + ! CalcBoundedLink( ptEOriginal, ptSOriginal, vOffsFirstCurve, pCrvCoBackLink)) + return false ; // se ho trovato dei centroidi li unisco nei punti più vicini a questo percorso for ( int i = 0 ; i < int( vPtCentroid.size()) ; ++ i) { @@ -1045,10 +1042,10 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT if ( ! pCrvPath->GetParamAtPoint( ptClosestOnPath, dU)) return false ; - PtrOwner pCrvA( GetCurveComposite( pCrvPath->CopyParamRange( 0, dU))) ; + PtrOwner pCrvA( GetBasicCurveComposite( pCrvPath->CopyParamRange( 0, dU))) ; if ( IsNull( pCrvA)) return false ; - PtrOwner pCrvB( GetCurveComposite( pCrvPath->CopyParamRange( dU, pCrvPath->GetCurveCount()))) ; + PtrOwner pCrvB( GetBasicCurveComposite( pCrvPath->CopyParamRange( dU, pCrvPath->GetCurveCount()))) ; if ( IsNull( pCrvB)) return false ; @@ -1058,17 +1055,17 @@ RemoveExtraPartByMedialAxis( const ISurfFlatRegion* pChunkToCut, ICRVCOMPOPOVECT return false ; // 4) collego i due punti (centroide e punto più vicino alla curva) - PtrOwner pCrvPath1( CreateCurveComposite()) ; + PtrOwner pCrvPath1( CreateBasicCurveComposite()) ; if ( IsNull( pCrvPath1)) return false ; - if ( ! CalcBoundedSmootedLink( ptClosestOnPath, vtTanCpt, vPtCentroid[i], vtTanCpt, 0, vOffsFirstCurve, pCrvPath1)) - if ( ! CalcBoundedLink( ptClosestOnPath, vPtCentroid[i], vOffsFirstCurve, pCrvPath1)) - return false ; + if ( ! CalcBoundedSmootedLink( ptClosestOnPath, vtTanCpt, vPtCentroid[i], vtTanCpt, 0, vOffsFirstCurve, pCrvPath1) && + ! CalcBoundedLink( ptClosestOnPath, vPtCentroid[i], vOffsFirstCurve, pCrvPath1)) + return false ; pCrvPath->Clear() ; pCrvPath->AddCurve( Release( pCrvA)) ; - if( ! pCrvPath->AddCurve( Release( pCrvPath1))) + if ( ! pCrvPath->AddCurve( Release( pCrvPath1))) return false ; pCrvPath->AddCurve( Release( pCrvB)) ; } @@ -1086,9 +1083,8 @@ static bool CutOffsetToClosestPoint( ICRVCOMPOPOVECTOR& vCurves, const Point3d& ptFocus, ICurveComposite* pCrv1, ICurveComposite* pCrv2, int& nIndex) { - // controllo di avere almeno un offset... - if (( int)vCurves.size() == 0) + if ( vCurves.empty()) return false ; // variabili iniziali @@ -1101,10 +1097,10 @@ CutOffsetToClosestPoint( ICRVCOMPOPOVECTOR& vCurves, const Point3d& ptFocus, Point3d ptCL ; // scorro tutti gli offset ad eccezione del primo ( a meno di averne uno solo ) - for ( int j = ( int)vCurves.size() == 1 ? 0 : 1 ; j < int( vCurves.size()) ; ++ j) { + for ( int j = ( int( vCurves.size()) == 1 ? 0 : 1) ; j < int( vCurves.size()) ; ++ j) { // non ho offset nulli, però controllo... - if( IsNull( vCurves[j])) + if ( IsNull( vCurves[j])) continue ; // prendo il punto più vicino @@ -1194,7 +1190,7 @@ static bool CutCurveByOffsets( ICurveComposite* pCurve, ICRVCOMPOPOVECTOR& vOffs) { // controllo parametri ingresso - if (( int)vOffs.size() == 0) + if ( vOffs.empty()) return true ; // vettore di curve ausiliario @@ -1242,8 +1238,8 @@ CutCurveByOffsets( ICurveComposite* pCurve, ICRVCOMPOPOVECTOR& vOffs) { Point3d ptE ; pCompo->GetPointD1D2( ccClass[j].dParE, ICurve::FROM_MINUS, ptE) ; double dOffE ; vOffOrig[i]->GetParamAtPoint( ptE, dOffE) ; // recupero i due possibili percorsi e uso il più corto - PtrOwner pCrvA( GetCurve( vOffOrig[i]->CopyParamRange( dOffS, dOffE))) ; - PtrOwner pCrvB( GetCurve( vOffOrig[i]->CopyParamRange( dOffE, dOffS))) ; + PtrOwner pCrvA( vOffOrig[i]->CopyParamRange( dOffS, dOffE)) ; + PtrOwner pCrvB( vOffOrig[i]->CopyParamRange( dOffE, dOffS)) ; if ( IsNull( pCrvA) || IsNull( pCrvB)) return false ; @@ -1314,7 +1310,8 @@ GetNewCurvetWithCentroid( const ICurveComposite* pCrvH1, const ICurveComposite* Point3d ptS, ptE = ptC ; Vector3d vtTanS, vtTanE ; - if ( bCir) { // creo una circonferenza + // creo una circonferenza + if ( bCir) { // prendo il punto iniziale if ( pCrvH1 == nullptr || pCrvH1->GetFirstCurve() == nullptr) { if ( ! pCrvH2->GetStartPoint( ptS)) @@ -1355,7 +1352,8 @@ GetNewCurvetWithCentroid( const ICurveComposite* pCrvH1, const ICurveComposite* if ( ! pCrvNewCurve->AddCurve(( pCrvH2->Clone()))) // aggiungo la fine return false ; } - else { // creo un BiArco + // creo un BiArco + else { // prendo il vettore tangente e il punto iniziale if ( pCrvH1 == nullptr || pCrvH1->GetFirstCurve() == nullptr) { @@ -1411,13 +1409,13 @@ ManageSmoothAndAutoInters( ICurveComposite* pCrv, ICurveComposite* pCrvPath, ICu while ( ! bFound && nIter < 45) { vTanE.Rotate( Z_AX, 90 - nIter) ; // vettore perpendicolare PtrOwner pLine( CreateCurveLine()) ; - pLine->SetPVL( ptHS, vTanE, ( 2. * RAD) / 3 - 5 * EPS_SMALL) ; // segmento uscente + pLine->SetPVL( ptHS, vTanE, ( 2 * s_dRad) / 3 - 5 * EPS_SMALL) ; // segmento uscente CRVCVECTOR ccClass ; IntersCurveCurve intCC( *pLine, *pCrv) ; intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ; if (( int)ccClass.size() > 1) // se intersezione con parte precedente inverto la direzione - pLine->SetPVL( ptHS, - vTanE, ( 2. * RAD) / 3 - 5 * EPS_SMALL) ; + pLine->SetPVL( ptHS, - vTanE, ( 2 * s_dRad) / 3 - 5 * EPS_SMALL) ; if ( IsNull( pLine) || ! pLine->IsValid()) break ; @@ -1709,7 +1707,7 @@ RemoveExtraParts( ISurfFlatRegion* pSrfToCut, ICRVCOMPOPOVECTOR& vOffs, ICRVCOMP ICRVCOMPOPOVECTOR& vOffsFirstCurve, ICURVEPOVECTOR& vLinks) { - if ( pSrfToCut == nullptr || ( int)vOffs.size() == 0) + if ( pSrfToCut == nullptr || vOffs.empty()) return true ; // ciclo tutti i chunk della regione da tagliare @@ -1951,7 +1949,7 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm dOffs += dStep ; // se devo usare un Offset più piccolo... else if ( ! bSmallRad) - dOffs += ( nIter == 0 ? dRad : dRad) ; // superfluo, effettivamente non ho l'offset radiale + dOffs += dRad ; // altrimenti ho finito la regione da svuotare... else break ; @@ -1960,7 +1958,7 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm } // se non ho trovato curve di Offset allora esco - if (( int)vOffs.size() == 0) + if ( vOffs.empty()) return true ; // cambio il punto iniziale della prima Curva di Offset @@ -1970,7 +1968,7 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm ICRVCOMPOPOVECTOR vOffsClosedCurves( vOffs.size()) ; // vettore con tutte le curve di Offset Chiuse for ( int i = 0 ; i < int( vOffs.size()) ; ++ i) { if ( i != 0) { - ModifyCurveToSmoothed( vOffs[i], RAD / 8, RAD/8, false) ; + ModifyCurveToSmoothed( vOffs[i], s_dRad / 8, s_dRad / 8, false) ; vOffs[i]->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ; } vOffsClosedCurves[i].Set( vOffs[i]->Clone()) ; @@ -1980,7 +1978,7 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm for ( int i = 0 ; i < int( vOffsFirstCurve.size()) ; ++ i) { if ( i != 0) - ModifyCurveToSmoothed( vOffsFirstCurve[i], RAD/8, RAD/8, false) ; + ModifyCurveToSmoothed( vOffsFirstCurve[i], s_dRad / 8, s_dRad / 8, false) ; vOffsFirstCurve[i]->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL) ; } @@ -2043,7 +2041,7 @@ CalcSpiral( const ISurfFlatRegion* pSrfPock, double dRad, double dStep, bool bSm PtrOwner pOff_i1( CloneCurveComposite( vOffs[i + 1])) ; // cerco di tagliare le curve e di raccordarle ( -> ottenendo il collegamento) // NB. se la curva di offset è la prima, non devo tagliarla, accorcio solo le successive ( se non bordi di isole) ... - if ( ! SMOOTH || ! CutCurveToConnect( vOffs[i], vOffs[i+1], vOffsClosedCurves, vOffsFirstCurve, pCrvTest, i == 0 ? 0 : 0.01, 0.01, 2)) { + if ( ! s_bSmooth || ! CutCurveToConnect( vOffs[i], vOffs[i+1], vOffsClosedCurves, vOffsFirstCurve, pCrvTest, ( i == 0 ? 0 : 0.01), 0.01, 2)) { // se non sono riuscito ad accorcirle, ritorno alla configurazione iniziale PtrOwner pCrvLink( CreateCurveComposite()) ; if ( IsNull( pCrvLink)) @@ -2169,9 +2167,8 @@ CheckSimpleOverlap( const ICurve* pCrv, const ICurveComposite* pCrvOri, int& nSt static bool CalcZigZagLink( ICurveComposite* pCrv1, ICurveComposite* pCrv2, ICurveComposite* pCrvLink) { - // se non richiesto, esco - if ( ! SMOOTH) + if ( ! s_bSmooth) return true ; // controllo dei parametri @@ -2255,8 +2252,8 @@ CalcZigZagLink( ICurveComposite* pCrv1, ICurveComposite* pCrv2, ICurveComposite* pCrvTempLink->GetLastCurve()->GetLength( dLenI_e) ; // raccordo pSeg1 con pCrvLink - double dTollLeft = 1 - ( dLen1 - ( ( 2 * RAD) / 16)) / dLen1 ; // % parametro sinistro per smusso - double dTollRight = ( ( 2 * RAD) / 16) / dLenI_s ; // % parametro destro di smusso + double dTollLeft = 1 - ( dLen1 - ( ( 2 * s_dRad) / 16)) / dLen1 ; // % parametro sinistro per smusso + double dTollRight = ( ( 2 * s_dRad) / 16) / dLenI_s ; // % parametro destro di smusso PtrOwner pCrv_Seg1_Isl( CreateCurveComposite()) ; // curva unione di pSeg1 e pCrvLink smussata pCrv_Seg1_Isl->AddCurve( pCrvH1->Clone()) ; pCrv_Seg1_Isl->AddCurve( pCrvTempLink->Clone()) ; @@ -2266,8 +2263,8 @@ CalcZigZagLink( ICurveComposite* pCrv1, ICurveComposite* pCrv2, ICurveComposite* double dUS_1IH, dUE_1IH, dToTLen ; pCrv_Seg1_Isl->GetDomain( dUS_1IH, dUE_1IH) ; // dominio della curva smussata tra pSeg1 e PCrvLink pCrv_Seg1_Isl->GetLength( dToTLen) ; // nuova lunghezza della curva smussata tra pSeg1 e pCrvLink - dTollLeft = 1 - ( dLenI_e - ( ( 2 * RAD) / 16)) / dLenI_e ; // % paramtro sinistro per smusso - dTollRight = ( ( 2 * RAD) / 16) / dLen2 ; // % parametro destro per smusso + dTollLeft = 1 - ( dLenI_e - ( ( 2 * s_dRad) / 16)) / dLenI_e ; // % paramtro sinistro per smusso + dTollRight = ( ( 2 * s_dRad) / 16) / dLen2 ; // % parametro destro per smusso PtrOwner pCrv_smoothed( CreateCurveComposite()) ; // curva unione del primo smusso con pSeg2 pCrv_smoothed->AddCurve( pCrv_Seg1_Isl->Clone()) ; pCrv_smoothed->AddCurve( pCrvH2->Clone()) ; @@ -2384,7 +2381,7 @@ CalcZigZag( const ISurfFlatRegion* pSrfZigZag, ICRVCOMPOPOVECTOR& vpCrvs, double if ( ! bFromInfill) ptStart.Set( ptMin.x - EXP_LEN, ptMin.y + 10 * EPS_SMALL + i * dYStep, ptMin.z + dDimZ) ; else { - double dShift = ( i == 0) ? 10 * EPS_SMALL : (( i == nYStep) ? - 10 * EPS_SMALL : 0.) ; + double dShift = ( i == 0 ? 10 * EPS_SMALL : ( i == nYStep ? - 10 * EPS_SMALL : 0.)) ; ptStart.Set( ptMin.x - EXP_LEN, ptMin.y + dShift + i * dYStep, ptMin.z + dDimZ) ; } if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN)) @@ -2973,10 +2970,12 @@ CalcPocketing( const ISurfFlatRegion *pSfr, double dRad, double dStep, double dA dStep < EPS_SMALL || ( nType != POCKET_ZIGZAG && nType != POCKET_ONEWAY && nType != POCKET_SPIRALIN && nType != POCKET_SPIRALOUT)) return false ; - vCrvCompoRes.clear() ; // pulizia vettore delle curve elementari - TYPE = nType ; - RAD = dRad ; - SMOOTH = bSmooth ; + // pulizia vettore delle curve elementari + vCrvCompoRes.clear() ; + // assegno dati di modulo + s_nType = nType ; + s_dRad = dRad ; + s_bSmooth = bSmooth ; // calcolo delle curve elementari della superficie switch ( nType) { @@ -3164,7 +3163,7 @@ AdjustLinkDifferentY( const ICurve* pCrvSegPrec, const ICurve* pCrvSegSucc, cons PtrOwner pSfrTrap_c( CloneSurfFlatRegion( pSfrTrap)) ; if ( IsNull( pSfrTrap_c)) return false ; - if ( ! pSfrTrap->Offset( - RAD / 5, ICurve::OFF_CHAMFER)) + if ( ! pSfrTrap->Offset( - s_dRad / 5, ICurve::OFF_CHAMFER)) pSfrTrap.Set( Release( pSfrTrap_c)) ; // se il Link interseca questa regione, allora va eliminato @@ -3249,7 +3248,7 @@ AdjustLinkZigZagInfill( ICurveComposite* pCrvCompo, ICRVCOMPOPOVECTOR& vNewCrv) } } // se non ho mai trovato link non validi, lascio la curva invariata - if ( int( vIntervals.size()) == 0) + if ( vIntervals.empty()) vNewCrv.emplace_back( CloneCurveComposite( pCrvCompo)) ; else { // per ogni intervallo... @@ -3271,8 +3270,8 @@ CalcZigZagInfill( const ISurfFlatRegion* pSfr, double dStep, bool bSmooth, bool if ( pSfr == nullptr || ! pSfr->IsValid() || dStep < EPS_SMALL) return false ; vCrvCompoRes.clear() ; - SMOOTH = false ; - RAD = dStep * 0.5 ; + s_bSmooth = false ; + s_dRad = dStep / 2 ; // vettore con i percorsi a ZigZag ICRVCOMPOPOVECTOR vpCrvs ; @@ -3292,7 +3291,7 @@ CalcZigZagInfill( const ISurfFlatRegion* pSfr, double dStep, bool bSmooth, bool for ( int u = 0 ; u < int( vpCrvs.size()) ; ++ u) vCrvFinal.emplace_back( Release( vpCrvs[u])) ; vpCrvs.clear() ; - // sistemo le curve ottenute, aggiustando i Links + // sistemo le curve ottenute, aggiustando i Links for ( int u = 0 ; u < int( vCrvFinal.size()) ; ++ u) { ICRVCOMPOPOVECTOR vNewCrv ; if ( ! AdjustLinkZigZagInfill( vCrvFinal[u], vNewCrv)) @@ -3305,12 +3304,12 @@ CalcZigZagInfill( const ISurfFlatRegion* pSfr, double dStep, bool bSmooth, bool // inserisco i percorsi da ritornare for ( int u = 0 ; u < int( vpCrvs.size()) ; ++ u) { if ( bSmooth) { - SMOOTH = true ; - ModifyCurveToSmoothed( vpCrvs[u], RAD / 16, RAD / 16, false) ; + s_bSmooth = true ; + ModifyCurveToSmoothed( vpCrvs[u], s_dRad / 16, s_dRad / 16, false) ; } vCrvCompoRes.emplace_back( Release( vpCrvs[u])) ; } } return true ; -} \ No newline at end of file +} diff --git a/CurveAux.cpp b/CurveAux.cpp index c5ada0e..21fb59e 100644 --- a/CurveAux.cpp +++ b/CurveAux.cpp @@ -722,7 +722,7 @@ NurbsToBezierCurve( const CNurbsData& cnData) // se 1 solo intervallo, la Nurbs è già una curva di Bezier if ( nInt == 1) { // creo la curva di Bezier - PtrOwner pCrvBez( CreateCurveBezier()) ; + PtrOwner pCrvBez( CreateBasicCurveBezier()) ; if ( IsNull( pCrvBez)) return nullptr ; // la inizializzo @@ -746,7 +746,7 @@ NurbsToBezierCurve( const CNurbsData& cnData) } // altrimenti è equivalente ad una curva composita, la creo - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCompo)) return nullptr ; @@ -808,7 +808,7 @@ NurbsToBezierCurve( const CNurbsData& cnData) } // costruisco la curva di Bezier e la inserisco nella curva composita - PtrOwner pCrvBez( CreateCurveBezier()) ; + PtrOwner pCrvBez( CreateBasicCurveBezier()) ; if ( IsNull( pCrvBez)) return nullptr ; // se precedente saltata @@ -870,7 +870,7 @@ NurbsToBezierCurve( const CNurbsData& cnData) // se la curva ha grado 1, manca da aggiungere l'ultimo tratto if ( cnData.nDeg == 1 ) { // costruisco la curva di Bezier e la inserisco nella curva composita - PtrOwner pCrvBez( CreateCurveBezier()) ; + PtrOwner pCrvBez( CreateBasicCurveBezier()) ; if ( ! pCrvBez->Init( cnData.nDeg, cnData.bRat)) return nullptr ; if ( ! cnData.bRat) { diff --git a/CurveByInterp.cpp b/CurveByInterp.cpp index c8dd9da..efb254e 100644 --- a/CurveByInterp.cpp +++ b/CurveByInterp.cpp @@ -14,10 +14,10 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "CalcDerivate.h" +#include "CurveBezier.h" +#include "CurveComposite.h" #include "/EgtDev/Include/EGkCurveByInterp.h" -#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkBiArcs.h" -#include "/EgtDev/Include/EGkCurveBezier.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -63,7 +63,7 @@ CurveByInterp::GetCurve( int nMethod, int nType) // se richiesti biarchi if ( nType == BIARCS) { // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCompo)) return nullptr ; // ciclo sugli intervalli @@ -83,13 +83,13 @@ CurveByInterp::GetCurve( int nMethod, int nType) // se richieste curve di Bezier cubiche if ( nType == CUBIC_BEZIERS) { // creo la curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCompo)) return nullptr ; // ciclo sugli intervalli for ( int i = 1 ; i < int( m_vPnt.size()) ; ++ i) { // creo una curva di Bezier cubica per ogni intervallo - PtrOwner pCBez( CreateCurveBezier()) ; + PtrOwner pCBez( CreateBasicCurveBezier()) ; if ( IsNull( pCBez)) return nullptr ; pCBez->Init( 3, false) ; diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 9cd0b45..11ca192 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -371,7 +371,7 @@ CurveComposite::FromPolyLine( const PolyLine& PL) if ( AreSamePointApprox( ptIni, ptFin)) continue ; // creo il segmento di retta - PtrOwner pCrvLine( CreateCurveLine()) ; + PtrOwner pCrvLine( CreateBasicCurveLine()) ; if ( IsNull( pCrvLine)) return false ; // assegno i punti estremi diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index bc5922c..5057e77 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/ExtText.cpp b/ExtText.cpp index 4e90304..e91b061 100644 --- a/ExtText.cpp +++ b/ExtText.cpp @@ -884,7 +884,7 @@ ExtText::GetAuxSurf( void) const // per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale for ( const auto& pSfr : lstSfr) { // recupero la superficie trimesh - PtrOwner pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ; + PtrOwner pStm( GetBasicSurfFlatRegion( pSfr)->CalcAuxSurf( LIN_TOL_STD, ANG_TOL_STD_DEG)) ; if ( pStm != nullptr) { Triangle3d Tria ; int nT = pStm->GetFirstTriangle( Tria) ; diff --git a/FontNfe.cpp b/FontNfe.cpp index a230b43..3427a4c 100644 --- a/FontNfe.cpp +++ b/FontNfe.cpp @@ -16,8 +16,8 @@ #include "FontNfe.h" #include "FontAux.h" #include "FontConst.h" +#include "GdbIterator.h" #include "/EgtDev/Include/EGkGeomDB.h" -#include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkCurveComposite.h" @@ -81,21 +81,19 @@ NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic, if ( ! m_pGDB->Load( sFont)) return false ; // recupero i parametri generali del font (devono essere nel gruppo 1) - PtrOwner pIter( CreateGdbIterator( m_pGDB)) ; - if ( IsNull( pIter)) + GdbIterator iIter( m_pGDB) ; + if ( ! iIter.GoTo( 1)) return false ; - if ( ! pIter->GoTo( 1)) - return false ; - if ( ! pIter->GetInfo( NFE_H, m_dH) || - ! pIter->GetInfo( NFE_HCAP, m_dHCap) || - ! pIter->GetInfo( NFE_HX, m_dHx) || - ! pIter->GetInfo( NFE_ASC, m_dAsc) || - ! pIter->GetInfo( NFE_DESC, m_dDesc) || - ! pIter->GetInfo( NFE_ADV, m_dAdv)) + if ( ! iIter.GetInfo( NFE_H, m_dH) || + ! iIter.GetInfo( NFE_HCAP, m_dHCap) || + ! iIter.GetInfo( NFE_HX, m_dHx) || + ! iIter.GetInfo( NFE_ASC, m_dAsc) || + ! iIter.GetInfo( NFE_DESC, m_dDesc) || + ! iIter.GetInfo( NFE_ADV, m_dAdv)) return false ; if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL) return false ; - if ( ! pIter->GetInfo( NFE_ITALIC, m_dItalicShearCoeff)) + if ( ! iIter.GetInfo( NFE_ITALIC, m_dItalicShearCoeff)) m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ; // aggiorno la path del font m_sFont = sFontUp ; @@ -161,11 +159,6 @@ NfeFont::GetXBox( const string& sText, int nInsPos, bool bCapOrBound, BBox3d& b3 if ( m_pGDB == nullptr || m_sFont.empty()) return false ; - // creo un iteratore - PtrOwner pIter( CreateGdbIterator( m_pGDB)) ; - if ( IsNull( pIter)) - return false ; - // calcolo i fattori di scala double dScaY = m_dHeight / m_dHCap ; double dScaX = dScaY * m_dRatio ; @@ -229,9 +222,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const return false ; // creo un iteratore - PtrOwner pIter( CreateGdbIterator( m_pGDB)) ; - if ( IsNull( pIter)) - return false ; + GdbIterator iIter( m_pGDB) ; // calcolo i fattori di scala double dScaY = m_dHeight / m_dHCap ; @@ -265,9 +256,9 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP) nGroup = NFE_ERR_CHAR ; // ciclo sulle entità geometriche del carattere - bool bIter = pIter->GoToFirstInGroup( nGroup) ; + bool bIter = iIter.GoToFirstInGroup( nGroup) ; while ( bIter) { - const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; + const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ; if ( pCrv != nullptr) { // copio la curva (trasformando eventuali archi in CurveBezier) ICurve* pCrvNew = CurveToNoArcsCurve( pCrv) ; @@ -281,7 +272,7 @@ NfeFont::GetOutline( const string& sText, int nInsPos, ICURVEPLIST& lstPC) const // inserisco in lista la nuova curva lstPC.push_back( pCrvNew) ; } - bIter = pIter->GoToNext() ; + bIter = iIter.GoToNext() ; } // recupero lo spostamento per il prossimo carattere double dAdvance ; @@ -314,9 +305,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub return false ; // creo un iteratore - PtrOwner pIter( CreateGdbIterator( m_pGDB)) ; - if ( IsNull( pIter)) - return false ; + GdbIterator iIter( m_pGDB) ; // controllo valore tolleranza lineare if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight) @@ -354,9 +343,9 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP) nGroup = NFE_ERR_CHAR ; // ciclo sulle entità geometriche del carattere - bool bIter = pIter->GoToFirstInGroup( nGroup) ; + bool bIter = iIter.GoToFirstInGroup( nGroup) ; while ( bIter) { - const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; + const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ; if ( pCrv != nullptr) { // copia temporanea della curva (trasformando eventuali archi in CurveBezier) PtrOwner pCrvNew( CurveToNoArcsCurve( pCrv)) ; @@ -371,7 +360,7 @@ NfeFont::ApproxWithLines( const string& sText, int nInsPos, double dLinTol, doub lstPL.emplace_back() ; pCrvNew->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, lstPL.back()) ; } - bIter = pIter->GoToNext() ; + bIter = iIter.GoToNext() ; } // recupero lo spostamento per il prossimo carattere double dAdvance ; @@ -400,9 +389,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl return false ; // creo un iteratore - PtrOwner pIter( CreateGdbIterator( m_pGDB)) ; - if ( IsNull( pIter)) - return false ; + GdbIterator iIter( m_pGDB) ; // controllo valore tolleranza lineare if ( dLinTol > FNT_MAX_LINTOL_TO_H * m_dHeight) @@ -440,9 +427,9 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) != GDB_TY_GROUP) nGroup = NFE_ERR_CHAR ; // ciclo sulle entità geometriche del carattere - bool bIter = pIter->GoToFirstInGroup( nGroup) ; + bool bIter = iIter.GoToFirstInGroup( nGroup) ; while ( bIter) { - const ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ; + const ICurve* pCrv = GetCurve( iIter.GetGeoObj()) ; if ( pCrv != nullptr) { // copia temporanea della curva (trasformando eventuali archi in CurveBezier) PtrOwner pCrvNew( CurveToNoArcsCurve( pCrv)) ; @@ -457,7 +444,7 @@ NfeFont::ApproxWithArcs( const string& sText, int nInsPos, double dLinTol, doubl lstPA.emplace_back() ; pCrv->ApproxWithArcs( dLinTol, dAngTolDeg, lstPA.back()) ; } - bIter = pIter->GoToNext() ; + bIter = iIter.GoToNext() ; } // recupero lo spostamento per il prossimo carattere double dAdvance ; @@ -484,11 +471,6 @@ NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECT if ( m_pGDB == nullptr || m_sFont.empty()) return false ; - // creo un iteratore - PtrOwner pIter( CreateGdbIterator( m_pGDB)) ; - if ( IsNull( pIter)) - return false ; - // calcolo i fattori di scala double dScaY = m_dHeight / m_dHCap ; double dScaX = dScaY * m_dRatio ; diff --git a/FontOs.cpp b/FontOs.cpp index 4bda957..1006509 100644 --- a/FontOs.cpp +++ b/FontOs.cpp @@ -16,15 +16,15 @@ #include "FontOs.h" #include "FontAux.h" #include "FontConst.h" +#include "CurveLine.h" +#include "CurveBezier.h" +#include "CurveComposite.h" #include "SurfFlatRegion.h" #include "GeoConst.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkCurve.h" #include "/EgtDev/Include/EGkCurveAux.h" -#include "/EgtDev/Include/EGkCurveComposite.h" -#include "/EgtDev/Include/EGkCurveLine.h" -#include "/EgtDev/Include/EGkCurveBezier.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" @@ -730,7 +730,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC if ( pHeader->dwType == TT_POLYGON_TYPE) { // creo curva composita - PtrOwner pCCompo( CreateCurveComposite()) ; + PtrOwner pCCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCCompo)) return false ; @@ -823,7 +823,7 @@ OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const return false ; // creo retta, la imposto e la inserisco nella curva composita - PtrOwner pCLine( CreateCurveLine()) ; + PtrOwner pCLine( CreateBasicCurveLine()) ; if ( IsNull( pCLine)) return false ; if ( ! pCLine->Set( ptStart, ptEnd)) @@ -844,7 +844,7 @@ OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo, return false ; // creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita - PtrOwner pCBezier( CreateCurveBezier()) ; + PtrOwner pCBezier( CreateBasicCurveBezier()) ; if ( IsNull( pCBezier)) return false ; if ( ! pCBezier->Init( 2, false) || diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index 1f47f22..7e66517 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -242,7 +242,7 @@ GetSurfTriMeshByRevolve( const ICurve* pCurve, const Point3d& ptAx, const Vector PL.Invert() ; } // creo e setto la superficie trimesh - PtrOwner pSTM( CreateSurfTriMesh()) ; + PtrOwner pSTM( CreateBasicSurfTriMesh()) ; if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, ANG_FULL, dStepRotDeg, 0)) return nullptr ; // se superficie risultante chiusa, verifico che la normale sia verso l'esterno @@ -281,7 +281,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto return nullptr ; } // creo e setto la superficie trimesh - PtrOwner pSTM( CreateSurfTriMesh()) ; + PtrOwner pSTM( CreateBasicSurfTriMesh()) ; if ( IsNull( pSTM) || ! pSTM->CreateByScrewing( PL, ptAx, vtAx, dAngRotDeg, dStepRotDeg, dMove)) return nullptr ; // se richiesti caps @@ -294,7 +294,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto // se sezione chiusa e piatta e non rivoluzione, posso aggiungere i tappi if ( bSectClosedFlat && ! bRevolved) { // aggiungo il cap sull'inizio - PtrOwner pSci( CreateSurfTriMesh()) ; + PtrOwner pSci( CreateBasicSurfTriMesh()) ; if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL)) return nullptr ; pSTM->DoSewing( *pSci) ; @@ -304,7 +304,7 @@ GetSurfTriMeshByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vecto vtMove *= dMove ; PL.Translate( vtMove) ; PL.Rotate( ptAx, vtAx, dAngRotDeg) ; - PtrOwner pSce( CreateSurfTriMesh()) ; + PtrOwner pSce( CreateBasicSurfTriMesh()) ; if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL)) return nullptr ; pSce->Invert() ; @@ -383,13 +383,13 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL)) return nullptr ; // aggiungo il cap sull'inizio - PtrOwner pSci( CreateSurfTriMesh()) ; + PtrOwner pSci( CreateBasicSurfTriMesh()) ; if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0])) return nullptr ; pSci->Invert() ; pSTM->DoSewing( *pSci) ; // aggiungo il cap sulla fine - PtrOwner pSce( CreateSurfTriMesh()) ; + PtrOwner pSce( CreateBasicSurfTriMesh()) ; if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1])) return nullptr ; pSce->Invert() ; @@ -410,7 +410,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, PLStart.AddUPoint( 1, ptStart + dDimH / 2 * vtStart) ; PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dDimV * vtNorm) ; PLStart.AddUPoint( 3, ptStart - dDimV * vtNorm) ; - PtrOwner pSci( CreateSurfTriMesh()) ; + PtrOwner pSci( CreateBasicSurfTriMesh()) ; if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0)) return nullptr ; pSci->Invert() ; @@ -426,7 +426,7 @@ GetSurfTriMeshSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, PLEnd.AddUPoint( 1, ptEnd + dDimH / 2 * vtEnd) ; PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dDimV * vtNorm) ; PLEnd.AddUPoint( 3, ptEnd - dDimV * vtNorm) ; - PtrOwner pSce( CreateSurfTriMesh()) ; + PtrOwner pSce( CreateBasicSurfTriMesh()) ; if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0)) return nullptr ; pSce->Invert() ; @@ -551,12 +551,12 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL)) return nullptr ; // calcolo il cap sull'inizio - PtrOwner pSci( CreateSurfTriMesh()) ; + PtrOwner pSci( CreateBasicSurfTriMesh()) ; if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0])) return nullptr ; pSci->Invert() ; // calcolo il cap sulla fine - PtrOwner pSce( CreateSurfTriMesh()) ; + PtrOwner pSce( CreateBasicSurfTriMesh()) ; if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1])) return nullptr ; pSce->Invert() ; @@ -581,7 +581,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub PLStart.AddUPoint( 3, ptStart + dDimH / 2 * vtStart - ( dDimV - dBevelV) * vtNorm) ; PLStart.AddUPoint( 4, ptStart + ( dDimH / 2 - dBevelH) * vtStart - dDimV * vtNorm) ; PLStart.AddUPoint( 5, ptStart - dDimV * vtNorm) ; - PtrOwner pSci( CreateSurfTriMesh()) ; + PtrOwner pSci( CreateBasicSurfTriMesh()) ; if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0)) return nullptr ; pSci->Invert() ; @@ -599,7 +599,7 @@ GetSurfTriMeshBeveledRectSwept( double dDimH, double dDimV, double dBevelH, doub PLEnd.AddUPoint( 3, ptEnd + dDimH / 2 * vtEnd - ( dDimV - dBevelV) * vtNorm) ; PLEnd.AddUPoint( 4, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd - dDimV * vtNorm) ; PLEnd.AddUPoint( 5, ptEnd - dDimV * vtNorm) ; - PtrOwner pSce( CreateSurfTriMesh()) ; + PtrOwner pSce( CreateBasicSurfTriMesh()) ; if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0)) return nullptr ; pSce->Invert() ; @@ -669,7 +669,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d if ( ! PL.ToLoc( frStart) || ! PL.Flatten()) return nullptr ; // calcolo la superficie - PtrOwner pSTM( CreateSurfTriMesh()) ; + PtrOwner pSTM( CreateBasicSurfTriMesh()) ; if ( IsNull( pSTM)) return nullptr ; // salvo tolleranza lineare usata @@ -711,7 +711,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL)) return nullptr ; // aggiungo il cap sull'inizio - PtrOwner pSci( CreateSurfTriMesh()) ; + PtrOwner pSci( CreateBasicSurfTriMesh()) ; if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL)) return nullptr ; pSci->ToGlob( frStart) ; @@ -724,7 +724,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d pGuide->GetEndDir( vtEnd) ; frEnd.Set( ptEnd, -vtEnd, vtEnd ^ vtNorm) ; // aggiungo il cap sulla fine - PtrOwner pSce( CreateSurfTriMesh()) ; + PtrOwner pSce( CreateBasicSurfTriMesh()) ; if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL)) return nullptr ; pSce->Invert() ; @@ -751,7 +751,7 @@ GetSurfTriMeshRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol) if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL)) return nullptr ; // creo e setto la superficie trimesh - PtrOwner pSTM( CreateSurfTriMesh()) ; + PtrOwner pSTM( CreateBasicSurfTriMesh()) ; if ( IsNull( pSTM) || ! pSTM->CreateByPointCurve( ptP, PL)) return nullptr ; // salvo tolleranza lineare usata @@ -776,7 +776,7 @@ GetSurfTriMeshRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, do if ( ! pCurve2->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL2)) return nullptr ; // creo e setto la superficie trimesh - PtrOwner pSTM( CreateSurfTriMesh()) ; + PtrOwner pSTM( CreateBasicSurfTriMesh()) ; if ( IsNull( pSTM) || ! pSTM->CreateByTwoCurves( PL1, PL2, nType)) return nullptr ; // salvo tolleranza lineare usata diff --git a/StmStandard.cpp b/StmStandard.cpp index e0eaa79..3bf1bc2 100644 --- a/StmStandard.cpp +++ b/StmStandard.cpp @@ -255,7 +255,7 @@ GetSurfTriMeshPlaneInBox( const Plane3d& plPlane, const BBox3d& b3Box, bool bOnE if ( ! Polyg.FromPlaneTrimmedWithBox( plPlane, b3Box.GetMin(), b3Box.GetMax(), bOnEq, bOnCt)) return nullptr ; // creo la trimesh con questo contorno - PtrOwner pStm( CreateSurfTriMesh()) ; + PtrOwner pStm( CreateBasicSurfTriMesh()) ; if ( IsNull( pStm) || ! pStm->CreateByFlatContour( Polyg.GetPolyLine())) return nullptr ; // restituisco la superficie diff --git a/SubtractProjectedFacesOnStmFace.cpp b/SubtractProjectedFacesOnStmFace.cpp index b459a18..cc290c0 100644 --- a/SubtractProjectedFacesOnStmFace.cpp +++ b/SubtractProjectedFacesOnStmFace.cpp @@ -15,7 +15,8 @@ #include "stdafx.h" #include "DllMain.h" #include "GeoConst.h" -#include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "CurveComposite.h" +#include "SurfFlatRegion.h" #include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" @@ -31,7 +32,7 @@ using namespace std ; //---------------------------------------------------------------------------- static bool -ImproveCurve( ICurveComposite* pCrvCompo, const Frame3d frface, const Plane3d plFace, bool& bSkip) +ImproveCurve( CurveComposite* pCrvCompo, const Frame3d frface, const Plane3d plFace, bool& bSkip) { // controllo dei parametri if ( pCrvCompo == nullptr || ! pCrvCompo->IsValid() || @@ -115,7 +116,7 @@ GetSfrByStm( const ISurfTriMesh* pStm, ISurfFlatRegion* pSfr, const Plane3d plFa for ( int i = 0 ; i < ( int)vPl.size() ; ++ i) { // recupero la curva composita PolyLine PL = vPl[i] ; - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; pCrvCompo->FromPolyLine( PL) ; // sistemazione varie per la curva ( per creare i loops della FlatRegion) @@ -231,7 +232,7 @@ SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveCom } // curva finale da resitutire ( da semplice Curve a CurveComposite) - PtrOwner pCrvFinal( CreateCurveComposite()) ; + PtrOwner pCrvFinal( CreateBasicCurveComposite()) ; if ( IsNull( pCrvFinal)) return false ; @@ -252,7 +253,7 @@ SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveCom else pCrv->GetParamAtPoint( ptCrvOriE, dUProjE, dToll) ; - PtrOwner pCrvRange( GetCurveComposite( pCrv->CopyParamRange( dUProjS, dUProjE))) ; + PtrOwner pCrvRange( GetBasicCurveComposite( pCrv->CopyParamRange( dUProjS, dUProjE))) ; if ( ! IsNull( pCrvRange) && pCrvRange->IsValid()) { int nProp0 = 0 ; pCrvOriRange->GetCurveTempProp( u, nProp0, 0) ; int nProp1 = -1 ; pCrvOriRange->GetCurveTempProp( u, nProp1, 1) ; @@ -267,7 +268,7 @@ SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveCom } // controllo che la CurveComposite ottenuta sia valida e coerente rispetto all'originale ... - if ( ! IsNull( pCrvFinal) && pCrvFinal->GetCurveCount() > 0 && pCrvFinal->IsValid()) { + if ( pCrvFinal->GetCurveCount() > 0 && pCrvFinal->IsValid()) { Point3d ptSCheck ; Point3d ptECheck ; pCrvFinal->GetStartPoint( ptSCheck) ; pCrvFinal->GetEndPoint( ptECheck) ; @@ -280,12 +281,12 @@ SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveCom // ritorno la curva modificata if ( nStat != 2) { pCrvFinal->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ; - PtrOwner pCrvToReturn( CreateCurveComposite()) ; + PtrOwner pCrvToReturn( CreateBasicCurveComposite()) ; if ( IsNull( pCrvToReturn)) return false ; // primo tratto di curva della Composita iniziale - PtrOwner pCrvA( GetCurveComposite( pCrvCheck->CopyParamRange( 0, nInd))) ; + PtrOwner pCrvA( GetBasicCurveComposite( pCrvCheck->CopyParamRange( 0, nInd))) ; if ( ! IsNull( pCrvA) && pCrvA->GetCurveCount() > 0 && pCrvA->IsValid()) { if ( ! pCrvToReturn->AddCurve( Release( pCrvA))) { nStat = 2 ; @@ -299,7 +300,7 @@ SetTmpPropByOverlap( ICurveComposite* pCrvCheck, const int nInd, const ICurveCom } // ultimo tratto di curva della Composita iniziale - PtrOwner pCrvB( GetCurveComposite( pCrvCheck->CopyParamRange( nInd + 1, pCrvCheck->GetCurveCount()))) ; + PtrOwner pCrvB( GetBasicCurveComposite( pCrvCheck->CopyParamRange( nInd + 1, pCrvCheck->GetCurveCount()))) ; if ( ! IsNull( pCrvB) && pCrvB->GetCurveCount() > 0 && pCrvB->IsValid()) if( ! pCrvToReturn->AddCurve( Release( pCrvB))) { nStat = 2 ; @@ -346,7 +347,7 @@ GetOCCrvsWithProps( const ISurfTriMesh& StmOrig, int nFaceInd, ICRVCOMPOPOVECTOR return false ; // creo la curva a partire dai loop for ( int i = 0 ; i < int( vPL.size()) ; i++) { - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( vPL[i]) || ! pCrvCompo->IsValid()) return false ; // imposto a 0 tutti i lati della pCrvCompo @@ -409,7 +410,7 @@ SewNewStmFacesWithTmpProps( const ISurfFlatRegion& SfrOCCurves, const Plane3d pl for ( int c = 0 ; c < SfrOCCurves.GetChunkCount() ; ++ c) { for ( int l = 0 ; l < SfrOCCurves.GetLoopCount( c) ; ++ l) { // ricavo il Loop - PtrOwner pCrvCompoLoop( ConvertCurveToComposite( SfrOCCurves.GetLoop( c, l))) ; + PtrOwner pCrvCompoLoop( ConvertCurveToBasicComposite( SfrOCCurves.GetLoop( c, l))) ; if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid()) return false ; // scorro le sue sottocurve @@ -462,7 +463,7 @@ AddClosedEdges( const ISurfTriMesh& StmOrig, int nFaceInd, const ISurfFlatRegion for ( int c = 0 ; c < pSfrOrig.GetChunkCount() ; ++ c) { for ( int l = 0 ; l < pSfrOrig.GetLoopCount( c) ; ++ l) { // ricavo la curva composita associata al loop corrente - PtrOwner pCrvCompoLoop( ConvertCurveToComposite( pSfrOrig.GetLoop( c, l))) ; + PtrOwner pCrvCompoLoop( ConvertCurveToBasicComposite( pSfrOrig.GetLoop( c, l))) ; if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid()) return false ; // scorro ogni curva del loop ottenuto @@ -562,7 +563,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP return false ; // superficie finale della proeizione - PtrOwner pSfr_proj( CreateSurfFlatRegion()) ; + PtrOwner pSfr_proj( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSfr_proj)) return false ; bool bExistProj = false ; // flag per indicare se almeno un triangolo è stato proiettato @@ -571,7 +572,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP for ( int t = 0 ; t < nVStm_size ; ++ t) { // TriMesh da proiettare - PtrOwner pStm_CurrProj( CloneSurfTriMesh( vStmOthers[t])) ; + PtrOwner pStm_CurrProj( CloneBasicSurfTriMesh( vStmOthers[t])) ; if ( IsNull( pStm_CurrProj) || ! pStm_CurrProj->IsValid()) return false ; @@ -579,7 +580,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP // proeizione non fa overlap con quello della faccia selezionata // scorro tutte le facce da proiettare - PtrOwner pStmForProj_noPerpFaces( CreateSurfTriMesh()) ; + PtrOwner pStmForProj_noPerpFaces( CreateBasicSurfTriMesh()) ; StmFromTriangleSoup StmFts ; StmFts.Start() ; for ( int f = 0 ; f < pStm_CurrProj->GetFacetCount() ; ++ f) { Vector3d vtN_curr ; @@ -590,7 +591,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP return false ; // se non c'è OverlapXY tra i due Box3D, la trascuro if ( BBoxSelFace.OverlapsXY( BBoxFace_f)) { - PtrOwner pStm_Currface( pStm_CurrProj->CloneFacet( f)) ; + PtrOwner pStm_Currface( pStm_CurrProj->CloneFacet( f)) ; if ( IsNull( pStm_Currface) || ! pStm_Currface->IsValid()) return false ; Triangle3d Tria ; @@ -605,7 +606,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP } } StmFts.End() ; - pStmForProj_noPerpFaces.Set( StmFts.GetSurf()) ; + pStmForProj_noPerpFaces.Set( GetBasicSurfTriMesh( StmFts.GetSurf())) ; // se la nuova superficie da proittare non contiene nulla, allora passo alla successiva if ( ! pStmForProj_noPerpFaces->IsValid()) continue ; @@ -633,7 +634,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP SurfFlatRegionByContours sfrBCProj_face ; bool bValidCurrProj = false ; for ( int i = 0 ; i < int( vPL.size()) ; ++ i) { - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCompo)) return false ; pCrvCompo->FromPolyLine( vPL[i]) ; @@ -662,7 +663,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP // la sommo alla regione di proeizione globale if ( ! pSfr_proj->IsValid() || pSfr_proj->GetChunkCount() == 0) - pSfr_proj.Set( Release( pSfr_proj_faceCurr)) ; + pSfr_proj.Set( GetBasicSurfFlatRegion( Release( pSfr_proj_faceCurr))) ; else if ( ! pSfr_proj->Add( *pSfr_proj_faceCurr)) return false ; @@ -673,7 +674,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP return true ; // FlatRegion associata alla faccia della TriMesh selezionata - PtrOwner pSfr_face( CreateSurfFlatRegion()) ; + PtrOwner pSfr_face( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSfr_face) || ! GetSfrByStm( pStm_face, pSfr_face, plFace) || ! pSfr_face->IsValid()) return false ; // per sicurezza controllo la coerenza con le normali ( per fare la sottrazione) @@ -681,7 +682,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP pSfr_face->Invert() ; // superficie finale da restituire - PtrOwner pStm_final( CreateSurfTriMesh()) ; + PtrOwner pStm_final( CreateBasicSurfTriMesh()) ; if ( IsNull( pStm_final)) return false ; @@ -711,7 +712,7 @@ SubtractProjectedFacesOnStmFace( const ISurfTriMesh& Stm, int nFaceInd, ISURFTMP } // riconverto la FlatRegion in TriMesh ( per restituirla) - const ISurfTriMesh* pStm_tmp = pSfr_face->GetAuxSurf() ; + const SurfTriMesh* pStm_tmp = pSfr_face->GetAuxSurf() ; if ( pStm_tmp == nullptr || ! pStm_tmp->IsValid()) return false ; pStm_final.Set( pStm_tmp->Clone()) ; diff --git a/SurfAux.cpp b/SurfAux.cpp index dcbc4cf..4b582bf 100644 --- a/SurfAux.cpp +++ b/SurfAux.cpp @@ -19,10 +19,10 @@ #include "CurveArc.h" #include "CurveBezier.h" #include "CurveComposite.h" +#include "SurfBezier.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EGkSurf.h" #include "/EgtDev/Include/EGkSurfAux.h" -#include "/EgtDev/Include/EGkSurfBezier.h" using namespace std ; @@ -478,7 +478,7 @@ NurbsToBezierSurface(const SNurbsSurfData& snData) nCPV_ref = snData.nDegV * nc + 1 ; // finalmente setto la superficie di bezier totale divisa in nb patch in U e nc patch in V - PtrOwner pSrfBz( CreateSurfBezier()) ; + PtrOwner pSrfBz( CreateBasicSurfBezier()) ; if ( IsNull( pSrfBz)) return nullptr ; pSrfBz->Init(snData.nDegU, snData.nDegV, nb, nc, snData.bRat) ; @@ -497,4 +497,4 @@ NurbsToBezierSurface(const SNurbsSurfData& snData) } } return Release( pSrfBz) ; -} \ No newline at end of file +} diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index d0b7568..3a48d94 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -41,7 +41,7 @@ GEOOBJ_REGISTER( SRF_TRIMESH, NGE_S_TRM, SurfTriMesh) ; //---------------------------------------------------------------------------- SurfTriMesh::SurfTriMesh( void) : m_nStatus( TO_VERIFY), m_dLinTol( STM_STD_LIN_TOL), m_dBoundaryAng( STM_STD_BOUNDARY_ANG), - m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bOriented( false), m_bClosed( false), m_bFaceted( false), + m_dSmoothAng( STM_STD_SMOOTH_ANG), m_bOriented( false), m_bClosed( false), m_bFaceted( false), m_bFacEdged( false), m_nTimeStamp( 0), m_nTempProp{0,0}, m_dTempParam{0.0,0.0}, m_nMaxTFlag( 0), m_nParts( -1), m_pHGrd3d( nullptr) { m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ; @@ -64,7 +64,7 @@ SurfTriMesh::Init( int nNumVert, int nNumTria, int nNumFacet) // se superficie vuota if ( nNumVert == 0 && nNumTria == 0 && nNumFacet == 0) return true ; - // verifico validit� parametri + // verifico validità parametri if ( nNumVert < 3 || nNumTria < 1) return false ; // prealloco la memoria @@ -94,6 +94,7 @@ SurfTriMesh::Clear( void) m_bOriented = false ; m_bClosed = false ; m_bFaceted = false ; + m_bFacEdged = false ; m_vVert.clear() ; m_vTria.clear() ; m_vFacet.clear() ; @@ -127,17 +128,22 @@ SurfTriMesh::AddVertex( const Point3d& ptVert, const double dU, const double dV) bool SurfTriMesh::MoveVertex( int nInd, const Point3d& ptNewVert) { - // verifico validit� indice + // verifico validità indice if ( nInd < 0 || nInd >= int( m_vVert.size())) return false ; - // verifico non sia gi� cancellato + // verifico non sia già cancellato if ( m_vVert[nInd].nIdTria == SVT_DEL) return false ; + // se non c'è spostamento, posso uscire + if ( AreSamePointExact( m_vVert[nInd].ptP, ptNewVert)) + return true ; // sposto il vertice m_vVert[nInd].ptP = ptNewVert ; // imposto ricalcolo m_nStatus = TO_VERIFY ; m_nParts = - 1 ; + m_bFaceted = false ; + m_bFacEdged = false ; m_OGrMgr.Reset() ; ResetHashGrids3d() ; // per aggiornare completamente la superficie chiamare DoCompacting @@ -255,14 +261,14 @@ SurfTriMesh::RemoveTriangle( int nId) // verifico esistenza del triangolo if ( nId < 0 || nId >= GetTriangleSize()) return false ; - // verifico se gi� cancellato + // verifico se già cancellato if ( m_vTria[nId].nIdVert[0] == SVT_DEL) return true ; // aggiorno eventuali riferimenti dei vertici for ( int i = 0 ; i < 3 ; ++ i) { // indice vertice int nV = m_vTria[nId].nIdVert[i] ; - // se vertice non c'� passo al prossimo + // se vertice non c'è passo al prossimo if ( nV < 0 || nV >= int( m_vVert.size())) continue ; if ( m_vVert[nV].nIdTria == nId) { @@ -280,7 +286,7 @@ SurfTriMesh::RemoveTriangle( int nId) for ( int i = 0 ; i < 3 ; ++ i) { // indice triangolo adiacente int nAdjT = m_vTria[nId].nIdAdjac[i] ; - // se triangolo adiacente non c'� passo al prossimo + // se triangolo adiacente non c'è passo al prossimo if ( nAdjT == SVT_NULL || m_vTria[nAdjT].nIdVert[0] == SVT_DEL) continue ; // ne sistemo la contro-adiacenza @@ -291,9 +297,10 @@ SurfTriMesh::RemoveTriangle( int nId) } // dichiaro cancellato il triangolo m_vTria[nId].nIdVert[0] = SVT_DEL ; - // invalido calcolo facce + // invalido calcolo facce e loro bordi m_bFaceted = false ; - // invalido calcolo connettivit� + m_bFacEdged = false ; + // invalido calcolo connettività m_nParts = - 1 ; return true ; } @@ -359,7 +366,7 @@ SurfTriMesh::GetCentroid( Point3d& ptCen) const // la superficie deve essere validata if ( m_nStatus != OK) return false ; - // se la superficie � chiusa, calcolo il centroide del solido + // se la superficie è chiusa, calcolo il centroide del solido if ( IsClosed()) { // applico le formule di R. Nurnberg Imperial College London ad ogni faccia Triangle3d Tria ; @@ -498,13 +505,6 @@ SurfTriMesh::GetFirstVertex( Point3d& ptP) const return GetNextVertex( SVT_NULL, ptP) ; } -//---------------------------------------------------------------------------- -int -SurfTriMesh::GetFirstVertexParam( int nId, double& dU, double& dV) const -{ - return GetNextVertexParam( SVT_NULL, dU, dV) ; -} - //---------------------------------------------------------------------------- int SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const @@ -513,8 +513,8 @@ SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const do { nId ++ ; } while ( nId < GetVertexSize() && m_vVert[nId].nIdTria == SVT_DEL) ; - // se oltrepassata fine - if ( nId >= GetVertexSize()) + // se indice non valido + if ( nId < 0 || nId >= GetVertexSize()) return SVT_NULL ; // recupero i dati ptP = m_vVert[nId].ptP ; @@ -522,24 +522,6 @@ SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const return nId ; } -//---------------------------------------------------------------------------- -int -SurfTriMesh::GetNextVertexParam( int nId, double& dU, double& dV) const -{ - // cerco il primo successivo valido - do { - nId ++ ; - } while ( nId < GetVertexSize() && m_vVert[nId].nIdTria == SVT_DEL) ; - // se oltrepassata fine - if ( nId >= GetVertexSize()) - return SVT_NULL ; - // recupero i dati - dU = m_vVert[nId].dU ; - dV = m_vVert[nId].dV ; - // ritorno indice triangolo corrente - return nId ; -} - //---------------------------------------------------------------------------- bool SurfTriMesh::GetTriangle( int nId, int nIdVert[3]) const @@ -569,8 +551,8 @@ SurfTriMesh::GetNextTriangle( int nId, int nIdVert[3]) const do { nId ++ ; } while ( nId < GetTriangleSize() && m_vTria[nId].nIdVert[0] == SVT_DEL) ; - // se oltrepassata fine - if ( nId >= GetTriangleSize()) + // se indice non valido + if ( nId < 0 || nId >= GetTriangleSize()) return SVT_NULL ; // recupero i dati nIdVert[0] = m_vTria[nId].nIdVert[0] ; @@ -611,8 +593,8 @@ SurfTriMesh::GetNextTriangle( int nId, Triangle3d& Tria) const do { nId ++ ; } while ( nId < GetTriangleSize() && m_vTria[nId].nIdVert[0] == SVT_DEL) ; - // se oltrepassata fine - if ( nId >= GetTriangleSize()) + // se indice non valido + if ( nId < 0 || nId >= GetTriangleSize()) return SVT_NULL ; // recupero i dati Tria.Set( m_vVert[m_vTria[nId].nIdVert[0]].ptP, @@ -657,8 +639,8 @@ SurfTriMesh::GetNextTriangle( int nId, Triangle3dEx& Tria) const do { nId ++ ; } while ( nId < GetTriangleSize() && m_vTria[nId].nIdVert[0] == SVT_DEL) ; - // se oltrepassata fine - if ( nId >= GetTriangleSize()) + // se indice non valido + if ( nId < 0 || nId >= GetTriangleSize()) return SVT_NULL ; // recupero i dati Tria.Set( m_vVert[m_vTria[nId].nIdVert[0]].ptP, @@ -772,13 +754,13 @@ SurfTriMesh::GetTriangleBoundaryEdges( int nId, TriFlags3d& TFlags) const for ( int i = 0 ; i < 3 ; ++ i) { // indice triangolo adiacente al lato int nT = m_vTria[nId].nIdAdjac[i] ; - // se gi� definite le facce, verifico indice faccia + // se già definite le facce, verifico indice faccia if ( m_bFaceted) { TFlags.bFlag[i] = ( nT == SVT_NULL || m_vTria[nId].nIdFacet != m_vTria[nT].nIdFacet) ; } // altrimenti verifico con le normali else - // se non c'� triangolo adiacente o se forma un angolo oltre il limite, il lato � un contorno + // se non c'è triangolo adiacente o se forma un angolo oltre il limite, il lato è un contorno TFlags.bFlag[i] = ( nT == SVT_NULL || m_vTria[nId].vtN * m_vTria[nT].vtN < m_dCosBndAng) ; } @@ -1131,78 +1113,9 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& GetBBox( frBox, b3Box) ; frOCS.Translate( b3Box.GetMin().z * frOCS.VersZ()) ; -#if 0 - // *** 1� Sfruttando le adiacenze *** - // Non funziona perch� genera loop con anelli - // Copio la superficie - PtrOwner pStm( Clone()) ; - if ( IsNull( pStm)) - return false ; - - // Elimino i triangoli con normale non equiversa alla direzione scelta - for ( int i = 0 ; i < int( pStm->m_vTria.size()) ; ++ i) { - // se gi� cancellato, passo oltre - if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL) - continue ; - // verifico la normale - if ( pStm->m_vTria[i].vtN * vtVers < EPS_ZERO) - pStm->RemoveTriangle( i) ; - } - // dichiaro facce non calcolate - pStm->m_bFaceted = false ; - - // Proietto la superficie - pStm->Scale( frOCS, 1, 1, 0) ; - - // Recupero i loop della nuova superficie - POLYLINEVECTOR vMyPL ; - if ( pStm->GetLoops( vMyPL)) { - // calcolo la regione della superficie proiettata - bool bOk = true ; - PtrOwner pSfr ; - for ( int i = 0 ; i < int( vMyPL.size()) && bOk ; ++ i) { - // Regione di un loop - PtrOwner pSfrPart( GetSurfFlatRegionFromPolyLine( vMyPL[i])) ; - if ( ! IsNull( pSfrPart)) { - pSfrPart->Offset( dTol, ICurve::OFF_FILLET) ; - if ( IsNull( pSfr)) - if ( pSfrPart->GetNormVersor() * vtVers > 0) - bOk = pSfr.Set( pSfrPart) ; - else - bOk = false ; - else { - if ( pSfrPart->GetNormVersor() * vtVers > 0) - bOk = pSfr->Add( *pSfrPart) ; - else { - pSfrPart->Invert() ; - bOk = pSfr->Subtract( *pSfrPart) ; - } - } - } - else - bOk = false ; - } - // Verifico esistenza della regione - if ( bOk && ! IsNull( pSfr)) { - // Effettuo contro-offset - pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ; - // Recupero i contorni della regione - for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) { - for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) { - PolyLine PL ; - if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) - vPL.emplace_back( PL) ; - } - } - return true ; - } - } - vPL.clear() ; -#endif - - // *** 2� Mediante unione delle regioni dei triangoli proiettati *** + // Ottengo la Silhouette come unione delle regioni dei triangoli proiettati // calcolo la regione dei triangoli proiettati - PtrOwner pSfr ; + PtrOwner pSfr ; Triangle3d Tria ; int nT = GetFirstTriangle( Tria) ; while ( nT != SVT_NULL) { @@ -1210,7 +1123,7 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& if ( ( ( bAllTria && abs( Tria.GetN() * vtVers) > EPS_ZERO) || ( ! bAllTria && Tria.GetN() * vtVers > EPS_ZERO)) && Tria.Scale( frOCS, 1, 1, 0) && Tria.GetSqMinHeight() > SQ_EPS_SMALL) { - PtrOwner pSfrTria( GetSurfFlatRegionFromTriangle( Tria)) ; + PtrOwner pSfrTria( GetBasicSurfFlatRegion( GetSurfFlatRegionFromTriangle( Tria))) ; if ( ! IsNull( pSfrTria)) { if ( bAllTria && Tria.GetN() * vtVers < 0) pSfrTria->Invert() ; @@ -1287,9 +1200,11 @@ SurfTriMesh::CopyFrom( const SurfTriMesh& stmSrc) m_bOriented = stmSrc.m_bOriented ; m_bClosed = stmSrc.m_bClosed ; m_bFaceted = stmSrc.m_bFaceted ; + m_bFacEdged = stmSrc.m_bFacEdged ; m_vVert = stmSrc.m_vVert ; m_vTria = stmSrc.m_vTria ; m_vFacet = stmSrc.m_vFacet ; + m_vFacEdge = stmSrc.m_vFacEdge ; m_nTimeStamp = stmSrc.m_nTimeStamp ; m_nTempProp[0] = stmSrc.m_nTempProp[0] ; m_nTempProp[1] = stmSrc.m_nTempProp[1] ; @@ -1332,7 +1247,7 @@ SurfTriMesh::Dump( string& sOut, bool bMM, const char* szNewLine) const // segnalo eventuale incongruenza di orientamento if ( ! m_bOriented) sOut += string( "Inconsistent Orientation") + szNewLine ; - // segnalo numero di parti se pi� di una + // segnalo numero di parti se più di una int nParts = GetPartCount() ; if ( nParts > 1) sOut += string( "Parts =") + ToString( nParts) + szNewLine ; @@ -1562,7 +1477,7 @@ SurfTriMesh::Validate( bool bCorrect) // Verifico che i triangoli riferiti dalle facce esistano for ( int i = 0 ; i < GetFacetSize() && m_nStatus == OK && m_bFaceted ; ++ i) { - // verifico validit� triangolo riferito + // verifico validità triangolo riferito if ( m_vFacet[i] <= SVT_NULL || m_vFacet[i] >= GetTriangleSize() || m_vTria[ m_vFacet[i]].nIdVert[0] == SVT_DEL) @@ -1717,7 +1632,7 @@ SurfTriMesh::AdjustAdjacencies( void) bool SurfTriMesh::AdjustOrientations( void) { - // se non ci sono almeno 2 triangoli � inutile fare test + // se non ci sono almeno 2 triangoli è inutile fare test if ( m_vTria.size() < 2) { m_bOriented = true ; return true ; @@ -1761,7 +1676,7 @@ SurfTriMesh::AdjustTriaOrientation( TRINTDEQUE& S3iQ) S3iQ.pop_front() ; // assegno time stamp al triangolo m_vTria[nT].nTemp = m_nTimeStamp ; - // se c'� triangolo di riferimento, devo verificare se da invertire + // se c'è triangolo di riferimento, devo verificare se da invertire if ( nRefT != SVT_NULL) { // cerco indice half-edge in comune int nE = 0 ; @@ -1779,7 +1694,7 @@ SurfTriMesh::AdjustTriaOrientation( TRINTDEQUE& S3iQ) bool bOk = true ; for ( int j = 0 ; j < 3 ; ++ j) { int nAdjT = m_vTria[nT].nIdAdjac[j] ; - // se non c'� adiacenza o va sul triangolo di provenienza + // se non c'è adiacenza o va sul triangolo di provenienza if ( nAdjT == SVT_NULL || nAdjT == nRefT) ; // la verifico @@ -1834,15 +1749,16 @@ SurfTriMesh::TestSealing( void) bool SurfTriMesh::AdjustTopology( void) { - // se non � rimasto alcunch� di valido, pulisco tutto ed esco + // se non è rimasto alcunché di valido, pulisco tutto ed esco if ( GetVertexCount() < 3 || GetTriangleCount() < 1) { Clear() ; m_bOriented = true ; m_bClosed = true ; return true ; } - // dichiaro sfaccettatura da ricalcolare + // dichiaro sfaccettatura e relativi bordi da ricalcolare m_bFaceted = false ; + m_bFacEdged = false ; // invalido calcolo connessione m_nParts = - 1 ; // verifica indici @@ -1851,7 +1767,7 @@ SurfTriMesh::AdjustTopology( void) // verifica adiacenze if ( ! AdjustAdjacencies()) return false ; - // verifica continuit� orientazione + // verifica continuità orientazione if ( ! AdjustOrientations()) return false ; // verifica chiusura @@ -1889,7 +1805,7 @@ SurfTriMesh::PackVertices( void) vVId.push_back( SVT_DEL) ; } } - // se non c'� stata compattazione, esco + // se non c'è stata compattazione, esco if ( nFirstFree == SVT_NULL) return true ; // lunghezza vettore indici vertici @@ -1904,7 +1820,7 @@ SurfTriMesh::PackVertices( void) // salto i triangoli cancellati if ( vOId[0] == SVT_DEL) continue ; - // verifico la validit� degli indici + // verifico la validità degli indici if ( vOId[0] < 0 || vOId[0] >= nVIdSize || vOId[1] < 0 || vOId[1] >= nVIdSize || vOId[2] < 0 || vOId[2] >= nVIdSize) @@ -1944,7 +1860,7 @@ SurfTriMesh::PackTriangles( void) vTId.push_back( SVT_DEL) ; } } - // se non c'� stata compattazione, esco + // se non c'è stata compattazione, esco if ( nFirstFree == SVT_NULL) return true ; // Invalido HashGrid @@ -1958,7 +1874,7 @@ SurfTriMesh::PackTriangles( void) // salto vertice cancellato if ( nOId == SVT_DEL) continue ; - // verifico la validit� dell'indice + // verifico la validità dell'indice if ( nOId < 0 || nOId >= nTIdSize) return false ; // aggiorno @@ -1988,7 +1904,7 @@ SurfTriMesh::PackTriangles( void) // salto le facets non valide if ( m_vFacet[nId] == SVT_DEL) continue ; - // verifico validit� indice a triangolo + // verifico validità indice a triangolo if ( m_vFacet[nId] < 0 || m_vFacet[nId] >= nTIdSize) return false ; // aggiorno @@ -2090,7 +2006,7 @@ SurfTriMesh::CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) m_OGrMgr.Reset() ; ResetHashGrids3d() ; - // verifico se la polilinea � chiusa + // verifico se la polilinea è chiusa bool bClosed = PL.IsClosed() ; // costruisco la mesh @@ -2123,7 +2039,7 @@ SurfTriMesh::CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) } // se curva chiusa, aggiungo gli ultimi due triangoli if ( bClosed) { - // non devo aggiungere i vertici, perch� coincidono con quelli iniziali + // non devo aggiungere i vertici, perchè coincidono con quelli iniziali // aggiungo i due triangoli relativi nIdV[0] = nV ; nIdV[1] = nV - 1 ; @@ -2142,7 +2058,7 @@ SurfTriMesh::CreateByExtrusion( const PolyLine& PL, const Vector3d& vtExtr) bool SurfTriMesh::CreateByPointCurve( const Point3d& ptP, const PolyLine& PL) { - // verifico validit� punto/polilinea + // verifico validità punto/polilinea bool bClosed = PL.IsClosed() ; // se chiusa, la polilinea deve avere almeno 3 punti if ( bClosed) { @@ -2186,7 +2102,7 @@ SurfTriMesh::CreateByPointCurve( const Point3d& ptP, const PolyLine& PL) // aggiorno indice punto precedente su curva nIdV[1] = nIdV[2] ; } - // se chiusa aggiungo l'ultimo triangolo (non il vertice perch� � il primo della curva) + // se chiusa aggiungo l'ultimo triangolo (non il vertice perchè è il primo della curva) if ( bClosed) { nIdV[2] = 1 ; // inserisco il triangolo A2p -> A1p -> A1s @@ -2278,7 +2194,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR } // ciclo sui punti while ( bNext1 || bNext2) { - // se non c'� V2s oppure c'� nuovo V1s e la diagonale pi� corta � V2p -> V1s + // se non c'è V2s oppure c'è nuovo V1s e la diagonale più corta è V2p -> V1s if ( ! bNext2 || ( bNext1 && ( nP1s == vPnt2[nP2p].second || vPnt1[nP1s].second == nP2p))) { // inserisco il vertice V1s (se ultimo e curve chiuse, prendo il primo) if ( nP1s == nTotP1 - 1 && bClosed) @@ -2300,7 +2216,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR nV1p = nV1s ; nP1p = nP1s ; ++ nP1s ; bNext1 = ( nP1s < nTotP1) ; } - // altrimenti � V1p -> V2s + // altrimenti è V1p -> V2s else { // inserisco il vertice V2s (se ultimo e curve chiuse, prendo il primo) if ( nP2s == nTotP2 - 1 && bClosed) @@ -2327,7 +2243,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR // altrimenti rigata con parametrizzazione sincrona sulle due curve else { - // verifico validit� polilinee (devono avere almeno 2 punti e non coincidere se non agli estremi aperti) + // verifico validità polilinee (devono avere almeno 2 punti e non coincidere se non agli estremi aperti) if ( ! VerifyPolylinesForTwoCurves( PL1, PL2)) return false ; @@ -2452,7 +2368,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR if ( bNext2) dA2s = ( dU2s - dU2F) / dDeltaU2 ; } - // se non c'� dA2s oppure c'� nuovo dA1s e la diagonale pi� corta � dA2p -> dA1s + // se non c'è dA2s oppure c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s else if ( ! bNext2 || ( bNext1 && ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM)) { // inserisco il vertice A1s if ( ( nV1s = AddVertex( ptP1s)) == SVT_NULL) @@ -2476,7 +2392,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR if ( bNext1) dA1s = ( dU1s - dU1F) / dDeltaU1 ; } - // altrimenti � dA1p -> dA2s + // altrimenti è dA1p -> dA2s else { // inserisco il vertice A2s if ( ( nV2s = AddVertex( ptP2s)) == SVT_NULL) @@ -2505,7 +2421,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR if ( bClosed) { dA1s = 1 ; dA2s = 1 ; - // se la diagonale pi� corta � dA2p -> dA1s = 0 + // se la diagonale più corta è dA2p -> dA1s = 0 if ( ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM) { // inserisco il triangolo A2p -> A1p -> A1s = 0 nIdV[0] = nV2p ; @@ -2520,7 +2436,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR if ( AddTriangle( nIdV) == SVT_NULL) return false ; } - // altrimenti � dA1p -> dA2s = 1 + // altrimenti è dA1p -> dA2s = 1 else { // inserisco il triangolo A2p -> A1p -> A2s = 1 nIdV[0] = nV2p ; @@ -2595,7 +2511,7 @@ SurfTriMesh::VerifyPolylinesForTwoCurves( const PolyLine& PL1, const PolyLine& P return false ; // verifiche sui punti successivi (non sugli ultimi) while ( bNext1 || bNext2) { - // se c'� nuovo dA1s e la diagonale pi� corta � dA2p -> dA1s oppure non c'� dA2s + // se c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s oppure non c'è dA2s if ( ( bNext1 && ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM) || ! bNext2) { // verifico se coincidono if ( AreSamePointApprox( ptP2p, ptP1s)) @@ -2606,7 +2522,7 @@ SurfTriMesh::VerifyPolylinesForTwoCurves( const PolyLine& PL1, const PolyLine& P if ( bNext1) dA1s = ( dU1s - dU1F) / dDeltaU1 ; } - // altrimenti � dA1p -> dA2s = 1 + // altrimenti è dA1p -> dA2s = 1 else { // verifico se coincidono if ( AreSamePointApprox( ptP1p, ptP2s)) @@ -2710,7 +2626,7 @@ AdjustPolylineForRevolution( PolyLine& PL, const Point3d& ptAx, const Vector3d& plTrim.Translate( DIST_SIC * vtTrN) ; PL.Trim( plTrim, false) ; - // Se polilinea risultante � aperta con estremit� molto vicine all'asse le porto su questo + // Se polilinea risultante è aperta con estremità molto vicine all'asse le porto su questo if ( ! PL.IsClosed()) { // verifico l'inizio double dUStart ; @@ -2788,7 +2704,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve m_OGrMgr.Reset() ; ResetHashGrids3d() ; - // verifico se la polilinea � chiusa + // verifico se la polilinea è chiusa bool bClosed = MyPL.IsClosed() ; // costruisco la mesh @@ -2809,7 +2725,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve // verifico se il punto giace sull'asse e vi sta fisso bool bPrevOnAx = bOnlyRev && DistPointLine( ptP, ptAx, vtAx, 1, false).IsSmall() ; int nVPrevOnAx = nV ; - // se non � fisso sull'asse, inserisco le copie ruotate + // se non è fisso sull'asse, inserisco le copie ruotate if ( ! bPrevOnAx) { for ( int i = 1 ; i <= nStep ; ++i) { ptP.Rotate( ptAx, vtAx, dCosStepRot, dSinStepRot) ; @@ -2831,7 +2747,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve bool bOnAx = bOnlyRev && DistPointLine( ptP, ptAx, vtAx, 1, false).IsSmall() ; // ciclo sugli step for ( int i = 1 ; i <= nStep ; ++i) { - // se non � fisso sull'asse, inserisco le copie ruotate + // se non è fisso sull'asse, inserisco le copie ruotate if ( ! bOnAx) { ptP.Rotate( ptAx, vtAx, dCosStepRot, dSinStepRot) ; if ( ! bOnlyRev) @@ -2840,8 +2756,8 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve return false ; ++ nV ; } - // per i controlli gi� fatti non � possibile avere contemp. prec e corr su asse - // se il precedente � sull'asse, aggiungo un solo triangolo + // per i controlli già fatti non è possibile avere contemp. prec e corr su asse + // se il precedente è sull'asse, aggiungo un solo triangolo if ( bPrevOnAx) { nIdV[0] = nVPrevOnAx ; nIdV[1] = nV ; @@ -2849,7 +2765,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve if ( AddTriangle( nIdV) == SVT_NULL) return false ; } - // se il corrente � sull'asse, aggiungo un solo triangolo + // se il corrente è sull'asse, aggiungo un solo triangolo else if ( bOnAx) { nIdV[0] = nV - ( nStep + 2) + i ; nIdV[1] = nIdV[0] + 1 ; @@ -2869,8 +2785,8 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve } // se rivoluzione completa, aggiungo i due triangoli di chiusura if ( bFullRev) { - // per i controlli gi� fatti non � possibile avere contemp. prec e corr su asse - // se il precedente � sull'asse, aggiungo un solo triangolo + // per i controlli già fatti non è possibile avere contemp. prec e corr su asse + // se il precedente è sull'asse, aggiungo un solo triangolo if ( bPrevOnAx) { nIdV[0] = nVPrevOnAx ; nIdV[1] = nV - nStep ; @@ -2878,7 +2794,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve if ( AddTriangle( nIdV) == SVT_NULL) return false ; } - // se il corrente � sull'asse, aggiungo un solo triangolo + // se il corrente è sull'asse, aggiungo un solo triangolo else if ( bOnAx) { nIdV[0] = nV - 1 ; nIdV[1] = nV - ( nStep + 1) ; @@ -2901,7 +2817,7 @@ SurfTriMesh::CreateByScrewing( const PolyLine& PL, const Point3d& ptAx, const Ve // altrimenti ultimo punto di polilinea chiusa if ( bClosed) { for ( int i = 1 ; i <= nStep ; ++i) { - // non devo aggiungere i vertici, perch� coincidono con quelli iniziali + // non devo aggiungere i vertici, perchè coincidono con quelli iniziali // aggiungo triangolo in basso a sinistra nIdV[0] = nV - nStep + i - 1 ; nIdV[1] = nV - nStep + i ; nIdV[2] = i ; if ( AddTriangle( nIdV) == SVT_NULL) @@ -2937,7 +2853,7 @@ SurfTriMesh::AddBiTriangle( const int nIdVert[4]) // | | // 1 -> 2 int nIdV[3] ; - // se la diagonale 0->2 � uguale o pi� corta della 1->3 + // se la diagonale 0->2 è uguale o più corta della 1->3 if ( SqDist( m_vVert[nIdVert[0]].ptP, m_vVert[nIdVert[2]].ptP) <= SqDist( m_vVert[nIdVert[1]].ptP, m_vVert[nIdVert[3]].ptP) + EPS_SMALL) { // triangolo 0->1->2 @@ -2998,14 +2914,14 @@ SurfTriMesh::DoCompacting( double dTol) } // recupero la posizione geometrica del vertice Point3d ptP = m_vVert[nId].ptP ; - // se non c'� gi� un vertice con la stessa posizione lo inserisco nel grid + // se non c'è già un vertice con la stessa posizione lo inserisco nel grid int nAliasId ; if ( ! VertGrid.Find( ptP, dTol, nAliasId)) { VertGrid.InsertPoint( ptP, nId) ; // salvo l'Id nel vettore di reindirizzo vVId.push_back( nId) ; } - // c'� un vertice coincidente + // c'è un vertice coincidente else { // salvo l'Id alias nel vettore di reindirizzo vVId.push_back( nAliasId) ; @@ -3024,7 +2940,7 @@ SurfTriMesh::DoCompacting( double dTol) int vOId[3]{ m_vTria[nId].nIdVert[0], m_vTria[nId].nIdVert[1], m_vTria[nId].nIdVert[2]} ; - // verifico la validit� degli indici + // verifico la validità degli indici if ( vOId[0] < 0 || vOId[0] >= nVIdSize || vOId[1] < 0 || vOId[1] >= nVIdSize || vOId[2] < 0 || vOId[2] >= nVIdSize) @@ -3033,7 +2949,7 @@ SurfTriMesh::DoCompacting( double dTol) m_vTria[nId].nIdVert[0] = vVId[vOId[0]] ; m_vTria[nId].nIdVert[1] = vVId[vOId[1]] ; m_vTria[nId].nIdVert[2] = vVId[vOId[2]] ; - // se due vertici coincidono o la normale non � calcolabile, cancello il triangolo + // se due vertici coincidono o la normale non è calcolabile, cancello il triangolo if ( m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[1] || m_vTria[nId].nIdVert[0] == m_vTria[nId].nIdVert[2] || m_vTria[nId].nIdVert[1] == m_vTria[nId].nIdVert[2] || @@ -3096,7 +3012,7 @@ SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther, dou Point3d ptOP = pOther->m_vVert[nOId].ptP ; // la porto nel riferimento della prima superficie ptOP.ToGlob( frOther) ; - // se non c'� gi� un vertice con la stessa posizione lo inserisco + // se non c'è già un vertice con la stessa posizione lo inserisco int nNewId ; if ( ! VertGrid.Find( ptOP, dTol, nNewId)) { if ( ( nNewId = AddVertex( ptOP)) == SVT_NULL) @@ -3118,7 +3034,7 @@ SurfTriMesh::DoSewing( const ISurfTriMesh& stmOther, const Frame3d& frOther, dou // salto i triangoli cancellati if ( vOId[0] == SVT_DEL) continue ; - // verifico la validit� degli indici + // verifico la validità degli indici if ( vOId[0] < 0 || vOId[0] >= nVIdSize || vOId[1] < 0 || vOId[1] >= nVIdSize || vOId[2] < 0 || vOId[2] >= nVIdSize) @@ -3170,7 +3086,7 @@ SurfTriMesh::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const // verifico lo stato if ( m_nStatus != OK) return false ; - // verifico validit� del frame + // verifico validità del frame if ( frRef.GetType() == Frame3d::ERR) return false ; // assegno il box nel riferimento @@ -3215,7 +3131,7 @@ SurfTriMesh::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, if ( m_nStatus != OK) return false ; - // verifico validit� dell'asse di rotazione + // verifico validità dell'asse di rotazione if ( vtAx.IsSmall()) return false ; @@ -3281,7 +3197,7 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double bool bRecalc = ( abs( dCoeffX) < EPS_ZERO || abs( dCoeffY) < EPS_ZERO || abs( dCoeffZ) < EPS_ZERO) ; for ( int i = 0 ; i < GetTriangleSize() ; ++ i) { if ( m_vTria[i].nIdVert[0] != SVT_DEL) { - // se c'� mirror, devo invertire la faccia + // se c'è mirror, devo invertire la faccia if ( bMirror) InvertTriangle( i) ; // aggiorno la normale @@ -3303,7 +3219,7 @@ SurfTriMesh::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double bool SurfTriMesh::InvertTriangle( int nT) { - // controllo validit� triangolo + // controllo validità triangolo if ( ! ExistsTriangle( nT)) return true ; // scambio di due vertici @@ -3319,10 +3235,10 @@ SurfTriMesh::InvertTriangle( int nT) bool SurfTriMesh::CalcTriangleNormal( int nT) { - // controllo validit� triangolo + // controllo validità triangolo if ( m_vTria[nT].nIdVert[0] == SVT_DEL) return true ; - // controllo validit� vertici riferiti dal triangolo + // controllo validità vertici riferiti dal triangolo if ( m_vTria[nT].nIdVert[0] < 0 || m_vTria[nT].nIdVert[0] >= GetVertexSize() || m_vVert[m_vTria[nT].nIdVert[0]].nIdTria == SVT_DEL || @@ -3351,7 +3267,7 @@ SurfTriMesh::Mirror( const Point3d& ptOn, const Vector3d& vtNorm) // la superficie deve essere validata if ( m_nStatus != OK) return false ; - // verifico validit� del piano di specchiatura + // verifico validità del piano di specchiatura if ( vtNorm.IsSmall()) return false ; @@ -3383,7 +3299,7 @@ SurfTriMesh::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& // la superficie deve essere validata if ( m_nStatus != OK) return false ; - // verifico validit� dei parametri + // verifico validità dei parametri if ( vtNorm.IsSmall() || vtDir.IsSmall()) return false ; @@ -3414,11 +3330,11 @@ SurfTriMesh::ToGlob( const Frame3d& frRef) // la superficie deve essere validata if ( m_nStatus != OK) return false ; - // verifico validit� del frame + // verifico validità del frame if ( frRef.GetType() == Frame3d::ERR) return false ; - // se frame identit�, non devo fare alcunch� + // se frame identità, non devo fare alcunché if ( IsGlobFrame( frRef)) return true ; @@ -3448,11 +3364,11 @@ SurfTriMesh::ToLoc( const Frame3d& frRef) // la superficie deve essere validata if ( m_nStatus != OK) return false ; - // verifico validit� del frame + // verifico validità del frame if ( frRef.GetType() == Frame3d::ERR) return false ; - // se frame identit�, non devo fare alcunch� + // se frame identità, non devo fare alcunché if ( IsGlobFrame( frRef)) return true ; @@ -3482,11 +3398,11 @@ SurfTriMesh::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) // la superficie deve essere validata if ( m_nStatus != OK) return false ; - // verifico validit� dei frame + // verifico validità dei frame if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR) return false ; - // se i due riferimenti coincidono, non devo fare alcunch� + // se i due riferimenti coincidono, non devo fare alcunché if ( AreSameFrame( frOri, frDest)) return true ; @@ -3543,7 +3459,7 @@ SurfTriMesh::ResetHashGrids3d( void) const bool SurfTriMesh::VerifyHashGrids3d( void) const { - // se gi� calcolato, non devo fare altro + // se già calcolato, non devo fare altro if ( m_pHGrd3d != nullptr) return true ; // alloco diff --git a/SurfTriMesh.h b/SurfTriMesh.h index 116c966..fd35597 100644 --- a/SurfTriMesh.h +++ b/SurfTriMesh.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2023 //---------------------------------------------------------------------------- -// File : SurfTriMesh.h Data : 07.07.23 Versione : 2.5g1 +// File : SurfTriMesh.h Data : 09.12.23 Versione : 2.5l2 // Contenuto : Dichiarazione della classe Superficie TriMesh. // // @@ -27,19 +27,22 @@ class SurfFlatRegion ; // Classe Vertice class StmVert { -public : - StmVert( void) : ptP(), dU( -1), dV( -1), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {} - StmVert( const Point3d& ptQ) : ptP( ptQ), dU( -1), dV( -1), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {} - StmVert( const Point3d& ptQ, int nIdT, int nF) : ptP( ptQ), dU( -1), dV( -1), nIdTria( nIdT), nFlag( nF), nTemp( 0) {} -public : - Point3d ptP ; - double dU ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000) - // della sup di Bezier // -1 se non definito - double dV ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000) - // della sup di Bezier // -1 se non definito - int nIdTria ; - int nFlag ; - mutable int nTemp ; + public : + StmVert( void) + : ptP(), dU( SVT_NULL), dV( SVT_NULL), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {} + StmVert( const Point3d& ptQ) + : ptP( ptQ), dU( SVT_NULL), dV( SVT_NULL), nIdTria( SVT_NULL), nFlag( 0), nTemp( 0) {} + StmVert( const Point3d& ptQ, int nIdT, int nF) + : ptP( ptQ), dU( SVT_NULL), dV( SVT_NULL), nIdTria( nIdT), nFlag( nF), nTemp( 0) {} + public : + Point3d ptP ; + double dU ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000) + // della sup di Bezier // -1 se non definito + double dV ; // parametro riferito alle coordinate del punto nello spazio parametrico ( nSpanU x 1000) ( nSpanV x 1000) + // della sup di Bezier // -1 se non definito + int nIdTria ; + int nFlag ; + mutable int nTemp ; } ; //---------------------------------------------------------------------------- @@ -47,19 +50,18 @@ public : class StmTria { public : - StmTria( void) : vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0) - { nIdVert[0] = SVT_NULL ; nIdVert[1] = SVT_NULL ; nIdVert[2] = SVT_NULL ; - nIdAdjac[0] = SVT_NULL ; nIdAdjac[1] = SVT_NULL ; nIdAdjac[2] = SVT_NULL ; } - StmTria( const int nIdV[3]) : vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0) - { nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ; - nIdAdjac[0] = SVT_NULL ; nIdAdjac[1] = SVT_NULL ; nIdAdjac[2] = SVT_NULL ; } - StmTria( const int nIdV[3], int nTF) : vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nPart( SVT_NULL), nTemp( 0) - { nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ; - nIdAdjac[0] = SVT_NULL ; nIdAdjac[1] = SVT_NULL ; nIdAdjac[2] = SVT_NULL ; } + StmTria( void) + : nIdVert{ SVT_NULL, SVT_NULL, SVT_NULL}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0}, + vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {} + StmTria( const int nIdV[3]) + : nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0}, + vtN(), nIdFacet( SVT_NULL), nTFlag( 0), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {} + StmTria( const int nIdV[3], int nTF) + : nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ SVT_NULL, SVT_NULL, SVT_NULL}, nETempFlag{ 0, 0, 0}, + vtN(), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( 0), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {} StmTria( const int nIdV[3], const int nIdA[3], const Vector3d& vtV, int nTF, int nEF) - : vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nPart( SVT_NULL), nTemp( 0) - { nIdVert[0] = nIdV[0] ; nIdVert[1] = nIdV[1] ; nIdVert[2] = nIdV[2] ; - nIdAdjac[0] = nIdA[0] ; nIdAdjac[1] = nIdA[1] ; nIdAdjac[2] = nIdA[2] ; } + : nIdVert{ nIdV[0], nIdV[1], nIdV[2]}, nIdAdjac{ nIdA[0], nIdA[1], nIdA[2]}, nETempFlag{ 0, 0, 0}, + vtN( vtV), nIdFacet( SVT_NULL), nTFlag( nTF), nEFlag( nEF), nPart( SVT_NULL), nTemp( 0), nTempPart{ 0} {} public : int nIdVert[3] ; int nIdAdjac[3] ; @@ -73,11 +75,27 @@ class StmTria mutable int nTempPart ; } ; +//---------------------------------------------------------------------------- +// Classe Facet Edge +class StmFacEdge +{ + public : + StmFacEdge( void) + : nIdVert{ SVT_NULL, SVT_NULL}, nIdFacAdj{ SVT_NULL, SVT_NULL}, dIntAng{ 0} {} + StmFacEdge( int nV1, int nV2, int nFl, int nFr, double dA) + : nIdVert{ nV1, nV2}, nIdFacAdj{ nFl, nFr}, dIntAng{ dA} {} + public : + int nIdVert[2] ; + int nIdFacAdj[2] ; + double dIntAng ; +} ; + //---------------------------------------------------------------------------- // Classe di tre interi per code di elaborazione sui triangoli (senza iterazioni) struct Stm3Int { - Stm3Int( int nI, int nJ, int nK) : nI1( nI), nI2( nJ), nI3( nK) {} int nI1 ; int nI2 ; int nI3 ; + Stm3Int( int nI, int nJ, int nK) + : nI1( nI), nI2( nJ), nI3( nK) {} } ; //---------------------------------------------------------------------------- @@ -102,16 +120,10 @@ typedef std::unordered_map< int, TRIA3DVECTOR> TRIA3DVECTORMAP ; struct LineFacetClass { Point3d ptSt, ptEn ; int nTypeA, nTypeB ; - LineFacetClass( void) { - nTypeA = 0 ; - nTypeB = 0 ; - } - LineFacetClass( const Point3d& ptS, const Point3d& ptE, int nTpA, int nTpB) { - ptSt = ptS ; - ptEn = ptE ; - nTypeA = nTpA ; - nTypeB = nTpB ; - } + LineFacetClass( void) + : nTypeA{ 0}, nTypeB{ 0} {} + LineFacetClass( const Point3d& ptS, const Point3d& ptE, int nTpA, int nTpB) + : ptSt{ ptS}, ptEn{ ptE}, nTypeA{ nTpA}, nTypeB{ nTpB} {} } ; typedef std::vector LineFacetClassVector ; @@ -124,18 +136,11 @@ struct IntersInnSeg { Point3d ptSt ; Point3d ptEn ; Vector3d vtOuter ; - IntersInnSeg( void) { - ; - } - IntersInnSeg( const Point3d& ptS, const Point3d& ptE) { - ptSt = ptS ; - ptEn = ptE ; - } - IntersInnSeg( const Point3d& ptS, const Point3d& ptE, const Vector3d& vtO) { - ptSt = ptS ; - ptEn = ptE ; - vtOuter = vtO ; - } + IntersInnSeg( void) {} + IntersInnSeg( const Point3d& ptS, const Point3d& ptE) + : ptSt{ ptS}, ptEn{ ptE} {} + IntersInnSeg( const Point3d& ptS, const Point3d& ptE, const Vector3d& vtO) + : ptSt{ ptS}, ptEn{ ptE}, vtOuter{ vtO} {} } ; typedef std::vector IntersInnChain ; typedef std::vector INNCHAINVECTOR ; @@ -145,11 +150,8 @@ struct IntersEdge { Point3d ptSt ; Point3d ptEn ; INTVECTOR vOthFacetIndex ; - IntersEdge( const Point3d& ptS, const Point3d& ptE, const INTVECTOR& vOFI) { - ptSt = ptS; - ptEn = ptE; - vOthFacetIndex = vOFI ; - } + IntersEdge( const Point3d& ptS, const Point3d& ptE, const INTVECTOR& vOFI) + : ptSt{ ptS}, ptEn{ ptE}, vOthFacetIndex{ vOFI} {} } ; typedef std::vector IntersEdgeVec ; typedef std::unordered_map INTERSEDGEMAP ; @@ -255,9 +257,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW bool GetVertex( int nId, Point3d& ptP) const override ; bool GetVertexParam( int nId, double& dU, double& dV) const override ; int GetFirstVertex( Point3d& ptP) const override ; - int GetFirstVertexParam( int nId, double& dU, double& dV) const override ; int GetNextVertex( int nId, Point3d& ptP) const override ; - int GetNextVertexParam( int nId, double& dU, double& dV) const override ; bool GetTriangle( int nId, int nIdVert[3]) const override ; int GetFirstTriangle( int nIdVert[3]) const override ; int GetNextTriangle( int nId, int nIdVert[3]) const override ; @@ -293,6 +293,12 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW bool SwapFacets( int nF1, int nF2) override ; bool GetFacetLocalBBox( int nF, BBox3d& b3Loc, int nFlag = BBF_STANDARD) const override ; bool GetFacetBBox( int nF, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_STANDARD) const override ; + int GetEdgeCount( void) const override ; + int GetEdgeSize( void) const override + { return int( m_vFacEdge.size()) ; } + bool GetEdge( int nInd, int& nV1, int& nV2, int& nFl, int& nFr, double& dAng) const override ; + bool GetEdge( int nInd, Point3d& ptP1, Point3d& ptP2, double& dAng) const override ; + bool GetEdges( ICURVEPOVECTOR& vpCurve) const override ; bool Cut( const Plane3d& plPlane, bool bSaveOnEq) override ; bool GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq) override ; bool Add( const ISurfTriMesh& Other) override ; @@ -336,9 +342,10 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW bool SetTempInt( int nId, int nTempInt) const ; private : - typedef std::vector VERTVECTOR ; - typedef std::vector TRIAVECTOR ; - typedef std::deque TRINTDEQUE ; + typedef std::vector VERTVECTOR ; + typedef std::vector TRIAVECTOR ; + typedef std::vector FACEDGEVECTOR ; + typedef std::deque TRINTDEQUE ; private : enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ; @@ -377,6 +384,8 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW bool VerifyAdjacTriaFacet( INTVECTOR& vT) const ; bool MarchAlongFacetLoop( int nF, int nT, int nV, int nTimeStamp, PolyLine& PL) const ; bool MarchOneFacetTria( int nF, int& nT, int& nV, int nTimeStamp, PolyLine& PL, bool& bEnd) const ; + bool VerifyFacetEdging( void) const ; + bool UpdateFacetEdging( void) ; void ResetHashGrids3d( void) const ; bool VerifyHashGrids3d( void) const ; bool VerifyConnection( void) const ; @@ -407,9 +416,11 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW bool m_bOriented ; // la superficie è orientata consistentemente in tutte le sue parti bool m_bClosed ; // la superficie racchiude un volume bool m_bFaceted ; // flag di validità della sfaccettatura + bool m_bFacEdged ; // flag di validità dei bordi della sfaccettatura VERTVECTOR m_vVert ; // vettore dei vertici TRIAVECTOR m_vTria ; // vettore dei triangoli INTVECTOR m_vFacet ; // vettore delle sfaccettature + FACEDGEVECTOR m_vFacEdge ; // vettore degli edge delle sfaccettature mutable int m_nTimeStamp ; // orologio locale int m_nTempProp[2] ; // vettore proprietà temporanee double m_dTempParam[2] ; // vettore parametri temporanei diff --git a/SurfTriMeshFaceting.cpp b/SurfTriMeshFaceting.cpp index ce55f56..d79bfdd 100644 --- a/SurfTriMeshFaceting.cpp +++ b/SurfTriMeshFaceting.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2015 +// EgalTech 2015-2023 //---------------------------------------------------------------------------- -// File : SurfTriMeshFaceting.cpp Data : 25.02.15 Versione : 1.6b +// File : SurfTriMeshFaceting.cpp Data : 09.12.23 Versione : 2.5l2 // Contenuto : Implementazione della classe Superfici TriMesh. // // @@ -16,6 +16,7 @@ #include "SurfTriMesh.h" #include "GeoConst.h" #include "PolygonPlane.h" +#include "CurveLine.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include #include @@ -44,6 +45,7 @@ SurfTriMesh::UpdateFaceting( void) m_vFacet.clear() ; for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) m_vTria[i].nIdFacet = SVT_NULL ; + m_bFacEdged = false ; // indice faccia corrente int nFacet = -1 ; @@ -84,8 +86,8 @@ SurfTriMesh::UpdateFaceting( void) LOG_ERROR( GetEGkLogger(), "SurfTM : UpdateFaceting error") // calcolo facce piane effettuato - m_bFaceted = true ; - return true ; + m_bFaceted = bOk ; + return bOk ; } //---------------------------------------------------------------------------- @@ -858,3 +860,158 @@ SurfTriMesh::GetFacetBBox( int nF, const Frame3d& frRef, BBox3d& b3Ref, int nFla } return true ; } + +//---------------------------------------------------------------------------- +bool +SurfTriMesh::VerifyFacetEdging( void) const +{ + if ( m_bFacEdged) + return true ; + return (const_cast(this))->UpdateFacetEdging() ; +} + +//---------------------------------------------------------------------------- +bool +SurfTriMesh::UpdateFacetEdging( void) +{ + // reset degli Edge + m_bFacEdged = false ; + m_vFacEdge.clear() ; + + // verifico validità sfaccettatura + if ( ! VerifyFaceting()) + return false ; + + // reset flag temporaneo di edge dei triangoli + for ( int i = 0 ; i < int( m_vTria.size()) ; ++ i) { + m_vTria[i].nETempFlag[0] = 0 ; + m_vTria[i].nETempFlag[1] = 0 ; + m_vTria[i].nETempFlag[2] = 0 ; + } + + // ricostruisco gli edge delle facce + for ( int nT = 0 ; nT < int( m_vTria.size()) ; ++ nT) { + StmTria& Tria = m_vTria[nT] ; + // salto triangoli cancellati + if ( Tria.nIdVert[0] == SVT_DEL) + continue ; + // ciclo sui lati del triangolo + for ( int nE = 0 ; nE < 3 ; ++ nE) { + int nE2 = ( nE + 1) % 3 ; + int nTAdj = Tria.nIdAdjac[nE] ; + if ( Tria.nETempFlag[nE] == 0) { + if ( nTAdj == SVT_NULL) { + m_vFacEdge.emplace_back( Tria.nIdVert[nE], Tria.nIdVert[nE2], Tria.nIdFacet, SVT_NULL, 0.) ; + } + else if ( Tria.nIdFacet != m_vTria[nTAdj].nIdFacet) { + // calcolo l'angolo tra le facce ( 0 = allineate, > 0 convesse, < 0 concave) + Vector3d vtN1 = Tria.vtN ; + Vector3d vtN2 = m_vTria[nTAdj].vtN ; + Vector3d vtCm = m_vVert[Tria.nIdVert[nE2]].ptP - m_vVert[Tria.nIdVert[nE]].ptP ; + double dAng ; + bool bDet ; + if ( ! vtN1.GetRotation( vtN2, vtCm, dAng, bDet) || ! bDet) + dAng = 0 ; + // inserisco in lista + m_vFacEdge.emplace_back( Tria.nIdVert[nE], Tria.nIdVert[nE2], Tria.nIdFacet, m_vTria[nTAdj].nIdFacet, dAng) ; + // marco i due semi edge + int nEAdj = 0 ; + if ( m_vTria[nTAdj].nIdAdjac[1] == nT) + nEAdj = 1 ; + else if ( m_vTria[nTAdj].nIdAdjac[2] == nT) + nEAdj = 2 ; + Tria.nETempFlag[nE] = 1 ; + m_vTria[nTAdj].nETempFlag[nEAdj] = 1 ; + } + } + } + } + + // calcolo bordo delle facce piane effettuato + m_bFacEdged = true ; + + return true ; +} + +//---------------------------------------------------------------------------- +int +SurfTriMesh::GetEdgeCount( void) const +{ + // la superficie deve essere validata + if ( m_nStatus != OK) + return 0 ; + // verifico stato bordi sfaccettatura + if ( ! VerifyFacetEdging()) + return 0 ; + // restituisco il numero + return int( m_vFacEdge.size()) ; +} + +//---------------------------------------------------------------------------- +bool +SurfTriMesh::GetEdge( int nInd, int& nV1, int& nV2, int& nFl, int& nFr, double& dAng) const +{ + // la superficie deve essere validata + if ( m_nStatus != OK) + return false ; + // verifico stato bordi sfaccettatura + if ( ! VerifyFacetEdging()) + return false ; + // verifico la validità dell'indice + if ( nInd < 0 || nInd > int( m_vFacEdge.size())) + return SVT_NULL ; + // recupero i dati + nV1 = m_vFacEdge[nInd].nIdVert[0] ; + nV2 = m_vFacEdge[nInd].nIdVert[1] ; + nFl = m_vFacEdge[nInd].nIdFacAdj[0] ; + nFr = m_vFacEdge[nInd].nIdFacAdj[1] ; + dAng = m_vFacEdge[nInd].dIntAng ; + // ritorno indice edge corrente + return true ; +} + +//---------------------------------------------------------------------------- +bool +SurfTriMesh::GetEdge( int nInd, Point3d& ptP1, Point3d& ptP2, double& dAng) const +{ + // la superficie deve essere validata + if ( m_nStatus != OK) + return false ; + // verifico stato bordi sfaccettatura + if ( ! VerifyFacetEdging()) + return false ; + // verifico la validità dell'indice + if ( nInd < 0 || nInd > int( m_vFacEdge.size())) + return SVT_NULL ; + // recupero i dati + ptP1 = m_vVert[m_vFacEdge[nInd].nIdVert[0]].ptP ; + ptP2 = m_vVert[m_vFacEdge[nInd].nIdVert[0]].ptP ; + dAng = m_vFacEdge[nInd].dIntAng ; + // ritorno indice edge corrente + return true ; +} + +//---------------------------------------------------------------------------- +bool +SurfTriMesh::GetEdges( ICURVEPOVECTOR& vpCurve) const +{ + // la superficie deve essere validata + if ( m_nStatus != OK) + return false ; + // verifico stato bordi sfaccettatura + if ( ! VerifyFacetEdging()) + return false ; + // ciclo sugli edge, creo le curve e le assegno al parametro da restituire + for ( int nE = 0 ; nE < int( m_vFacEdge.size()) ; ++ nE) { + Point3d ptS, ptE ; + if ( ! GetVertex( m_vFacEdge[nE].nIdVert[0], ptS) || + ! GetVertex( m_vFacEdge[nE].nIdVert[1], ptE)) + return false ; + PtrOwner pLine( CreateBasicCurveLine()) ; + if ( IsNull( pLine) || ! pLine->Set( ptS, ptE)) + continue ; + pLine->SetTempParam( m_vFacEdge[nE].dIntAng) ; + vpCurve.emplace_back( Release( pLine)) ; + } + return true ; +} diff --git a/VolZmapGraphics.cpp b/VolZmapGraphics.cpp index 5dfc8ab..938d4ae 100644 --- a/VolZmapGraphics.cpp +++ b/VolZmapGraphics.cpp @@ -4670,7 +4670,7 @@ VolZmap::GetEdges( ICURVEPOVECTOR& vpCurve) const INTVECTOR vId ; while ( chainC.GetChainFromNear( ptNear, true, vId)) { // creo una curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; + PtrOwner pCrvCompo( CreateBasicCurveComposite()) ; if ( IsNull( pCrvCompo)) return false ; // recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita @@ -4678,7 +4678,7 @@ VolZmap::GetEdges( ICURVEPOVECTOR& vpCurve) const // creo un segmento di retta int nInd = abs( vId[i]) - 1 ; bool bInvert = ( vId[i] < 0) ; - PtrOwner pLine( CreateCurveLine()) ; + PtrOwner pLine( CreateBasicCurveLine()) ; if ( IsNull( pLine) || ! pLine->Set( vBpt[nInd].first, vBpt[nInd].second)) continue ; if ( bInvert) diff --git a/Voronoi.cpp b/Voronoi.cpp index b33130d..a43ce24 100644 --- a/Voronoi.cpp +++ b/Voronoi.cpp @@ -787,8 +787,8 @@ Voronoi::AdjustOpenOffsetCurve( ICurveComposite& pCompo, double dOffs) } else if ( vJunctions.size() == 2) { // recupero i due tratti di curva - PtrOwner pCompo1( ConvertCurveToComposite( pCompo.CopyParamRange( vJunctions[0] + 1, vJunctions[1]))) ; - PtrOwner pCompo2( ConvertCurveToComposite( pCompo.CopyParamRange( vJunctions[1] + 1, vJunctions[0]))) ; + PtrOwner pCompo1( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[0] + 1, vJunctions[1]))) ; + PtrOwner pCompo2( ConvertCurveToBasicComposite( pCompo.CopyParamRange( vJunctions[1] + 1, vJunctions[0]))) ; pCompo.Clear() ; if ( ! IsNull( pCompo1) && pCompo1->IsValid()) { int nSide = GetOffsetCurveSide( *pCompo1, 0) ;