From 068a1c9fb7f86165b4be5be60d863a5c33540c30 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 15 Jul 2024 07:10:26 +0200 Subject: [PATCH 1/2] =?UTF-8?q?EgtMachkernel=20:=20-=20in=20finitura=20sup?= =?UTF-8?q?erfici=20silhouette=20approssimate=20con=20archi=20e=20reset=20?= =?UTF-8?q?propriet=C3=A0=20curve=20dei=20contorni=20risultanti=20-=20in?= =?UTF-8?q?=20sgrossatura=20superfici=20silhouette=20approssimate=20con=20?= =?UTF-8?q?archi=20e=20migliorie=20stilistiche.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SurfFinishing.cpp | 45 +++++++++++++++++------ SurfRoughing.cpp | 91 +++++++++++++++++++++++++---------------------- 2 files changed, 82 insertions(+), 54 deletions(-) diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index 5a54667..ac98571 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -1263,6 +1263,19 @@ SurfFinishing::ProcessPath( int nPathId, int nPvId, int nClId) if ( IsNull( pSilCrv)) return false ; pSilCrv->FromPolyLine( PL) ; + // approssimo con archi + const double SILH_ARC_TOL = 0.1 * SILH_TOL ; + const double SILH_ARC_FEA_MAX = 100. ; + PolyArc PA ; + if ( pSilCrv->ApproxWithArcsEx( SILH_ARC_TOL, ANG_TOL_STD_DEG, SILH_ARC_FEA_MAX, PA)) { + PtrOwner pTempCrv( CreateCurveComposite()) ; + if ( ! IsNull( pTempCrv) && + pTempCrv->FromPolyArc( PA) && + pTempCrv->RemoveSmallDefects( SILH_ARC_TOL / 2, ANG_TOL_STD_DEG) && + pTempCrv->MergeCurves( SILH_ARC_TOL / 2, ANG_TOL_STD_DEG)) + pSilCrv.Set( pTempCrv) ; + } + // aggiungo per regione if ( ! SfrMaker.AddCurve( Release( pSilCrv))) { m_pMchMgr->SetLastError( 3124, "Error in SurfFinishing : region not computable") ; return false ; @@ -1272,20 +1285,30 @@ SurfFinishing::ProcessPath( int nPathId, int nPvId, int nClId) if ( ! IsNull( pSfrSil)) { pSfrSil->ToGlob( frSurf) ; double dPockRadOffs = m_TParams.m_dDiam - m_Params.m_dSideStep - m_Params.m_dOverlap ; - pSfrSil->Offset( dPockRadOffs, ICurve::OFF_CHAMFER) ; // offset radiale sulla Silhouette + pSfrSil->Offset( dPockRadOffs, ICurve::OFF_CHAMFER) ; + // intersezione tra contorno e regione + if ( ! pSfrCnt->Intersect( *pSfrSil)) { + // ricreo la regione originale + pSfrCnt->Clear() ; + pSfrCnt->AddExtLoop( *pCompo) ; + } + // azzero le proprietà delle curve semplici dei contorni delle regioni ( se 1 lato aperto) + for ( int nC = 0 ; nC < pSfrCnt->GetChunkCount() ; ++ nC) { + for ( int nL = 0 ; nL < pSfrCnt->GetLoopCount( nC) ; ++ nL) { + for ( int nCrv = 0 ; ; ++ nCrv) { + if ( ! pSfrCnt->SetCurveTempProp( nC, nL, nCrv, 0, 0) || + ! pSfrCnt->SetCurveTempProp( nC, nL, nCrv, 0, 1)) + break ; + } + } + } } - // intersezione tra contorno e regione - pSfrCnt->Intersect( *pSfrSil) ; - //if ( pSfrCnt->IsValid() && pSfrCnt->GetChunkCount() > 0) { - // PtrOwner pCont( ConvertCurveToComposite( pSfrCnt->GetLoop( 0, 0))) ; - // if ( ! IsNull( pCont)) { - // int nNewId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nTempId, Release( pCont)) ; - // if ( nNewId != GDB_ID_NULL) - // pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nNewId)) ; - // } - //} } + // se regione risultante vuota, non devo fare altro + if ( ! pSfrCnt->IsValid()) + return true ; + // assegno il vettore estrazione al gruppo del percorso m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ; diff --git a/SurfRoughing.cpp b/SurfRoughing.cpp index 9e586ca..a39ddc5 100644 --- a/SurfRoughing.cpp +++ b/SurfRoughing.cpp @@ -1432,6 +1432,19 @@ SurfRoughing::ProcessPath( int nPathId, int nTempId, int nPvId, int nClId) if ( IsNull( pSilCrv)) return false ; pSilCrv->FromPolyLine( PL) ; + // approssimo con archi + const double SILH_ARC_TOL = 0.1 * SILH_TOL ; + const double SILH_ARC_FEA_MAX = 100. ; + PolyArc PA ; + if ( pSilCrv->ApproxWithArcsEx( SILH_ARC_TOL, ANG_TOL_STD_DEG, SILH_ARC_FEA_MAX, PA)) { + PtrOwner pTempCrv( CreateCurveComposite()) ; + if ( ! IsNull( pTempCrv) && + pTempCrv->FromPolyArc( PA) && + pTempCrv->RemoveSmallDefects( SILH_ARC_TOL / 2, ANG_TOL_STD_DEG) && + pTempCrv->MergeCurves( SILH_ARC_TOL / 2, ANG_TOL_STD_DEG)) + pSilCrv.Set( pTempCrv) ; + } + // aggiungo per regione if ( ! SfrMaker.AddCurve( Release( pSilCrv))) { m_pMchMgr->SetLastError( 3024, "Error in SurfRoughing : region not computable") ; return false ; @@ -2360,30 +2373,27 @@ SurfRoughing::SimplifyCurve( ICurveComposite* pCompo) const Point3d ptStart ; pCompo->GetStartPoint( ptStart) ; Point3d ptEnd ; pCompo->GetEndPoint( ptEnd) ; - // tengo una copia della curva originaria + // eseguo le modifiche su una copia della curva originale PtrOwner pCompoCL( CloneCurveComposite( pCompo)) ; if ( IsNull( pCompoCL)) return false ; - PolyArc PA ; - Point3d ptNewStart, ptNewEnd ; - // merge per uniformità - if ( pCompoCL->MergeCurves( 200 * EPS_SMALL, 200 * EPS_ANG_SMALL) && - // rimozione Spikes o Curve Z - pCompoCL->RemoveSmallDefects( 150 * EPS_SMALL, 2 * ANG_TOL_STD_DEG, true) && - // interpolazione mediante linee ed archi - pCompoCL->ApproxWithArcsEx( 150 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) && - pCompoCL->Clear() && - pCompoCL->FromPolyArc( PA) && - // controllo aggiuntivo sui punti iniziali e finali che siano gli stessi - pCompoCL->GetStartPoint( ptNewStart) && - pCompoCL->GetEndPoint( ptNewEnd) && - AreSamePointApprox( ptNewStart, ptStart) && - AreSamePointApprox( ptNewEnd, ptEnd)) { - // sostiuisco la curva corrente con l'originaria + bool bOk = pCompoCL->MergeCurves( 200 * EPS_SMALL, 200 * EPS_ANG_SMALL, false) ; + // rimozione Spikes o Curve Z + bOk = bOk && pCompoCL->RemoveSmallDefects( 150 * EPS_SMALL, 2 * ANG_TOL_STD_DEG, true) ; + // interpolazione mediante linee ed archi + PolyArc PA ; + bOk = bOk && pCompoCL->ApproxWithArcsEx( 50 * EPS_SMALL, ANG_TOL_STD_DEG, LIN_FEA_STD, PA) && + pCompoCL->Clear() && pCompoCL->FromPolyArc( PA) ; + // controllo aggiuntivo sui punti iniziali e finali che siano gli stessi + Point3d ptNewStart, ptNewEnd ; + bOk = bOk && pCompoCL->GetStartPoint( ptNewStart) && pCompoCL->GetEndPoint( ptNewEnd) && + AreSamePointApprox( ptNewStart, ptStart) && AreSamePointApprox( ptNewEnd, ptEnd) ; + + // se tutto bene, sostiuisco la curva originale con la modificata + if ( bOk) pCompo->CopyFrom( pCompoCL) ; - } return true ; } @@ -2401,15 +2411,15 @@ SurfRoughing::SimplyfySfr( ISurfFlatRegion* pSfr) const if ( IsNull( pSfrSimple)) return false ; - // scorro tutti i loops - for ( int c = 0 ; c < pSfr->GetChunkCount() ; ++ c) { - for ( int l = 0 ; l < pSfr->GetLoopCount( c) ; ++ l) { + // scorro tutti i loops di tutte le parti + for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) { + for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; ++ nL) { // recupero la curva di Loop e la semplifico - PtrOwner pCompoLoop( ConvertCurveToComposite( pSfr->GetLoop( c, l))) ; + PtrOwner pCompoLoop( ConvertCurveToComposite( pSfr->GetLoop( nC, nL))) ; if ( IsNull( pCompoLoop) || ! SimplifyCurve( pCompoLoop)) return false ; - // la inserisco nella nuova regione - if ( l == 0) { + // inserisco le curve nella nuova regione (il primo loop di ogni parte è esterno) + if ( nL == 0) { if ( ! pSfrSimple->AddExtLoop( Release( pCompoLoop))) return false ; } @@ -2457,24 +2467,17 @@ SurfRoughing::RemoveChunksUnderTolerance( ISurfFlatRegion* pSfr) const // scorro tutti i chunk della superficie bool bSameSurf = true ; - for ( int c = 0 ; c < pSfr->GetChunkCount() ; ++ c) { + for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) { // verifico se l'Offset massimo del chunk è sopra alla tolleranza double dMaxOffs = EPS_SMALL ; - pSfr->GetChunkMaxOffset( c, dMaxOffs) ; - /* - // rimuovo il Chunk c-esimo se l'Offset massimo è minore della tolleranza - if ( dMaxOffs < m_dSubStepToler) { - pSfr->RemoveChunk( c) ; - -- c ; - } - */ + pSfr->GetChunkMaxOffset( nC, dMaxOffs) ; if ( dMaxOffs > m_dSubStepToler) { // recupero il loop esterno - if ( ! pSfrBeauty->AddExtLoop( pSfr->GetLoop( c, 0))) + if ( ! pSfrBeauty->AddExtLoop( pSfr->GetLoop( nC, 0))) return false ; // inserisco le isole del Chunk corrente - for ( int l = 1 ; l < pSfr->GetLoopCount( c) ; ++ l) - if ( ! pSfrBeauty->AddIntLoop( pSfr->GetLoop( c, l))) + for ( int nL = 1 ; nL < pSfr->GetLoopCount( nC) ; ++ nL) + if ( ! pSfrBeauty->AddIntLoop( pSfr->GetLoop( nC, nL))) return false ; } else @@ -2510,11 +2513,11 @@ SurfRoughing::CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler return false ; // scorro tutti i chunk della superficie - for ( int c = 0 ; c < pSfr->GetChunkCount() ; ++ c) { + for ( int nC = 0 ; nC < pSfr->GetChunkCount() ; ++ nC) { // scorro tutti i loop - for ( int l = 0 ; l < pSfr->GetLoopCount( c) ; ++ l) { + for ( int nL = 0 ; nL < pSfr->GetLoopCount( nC) ; ++ nL) { // recupero il loop come curva composita - PtrOwner pCrvLoop( ConvertCurveToComposite( pSfr->GetLoop( c, l))) ; + PtrOwner pCrvLoop( ConvertCurveToComposite( pSfr->GetLoop( nC, nL))) ; if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid()) return false ; // ------------- ricavo tratti di proprietà uniformi ------------- @@ -2561,17 +2564,19 @@ SurfRoughing::CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler if ( IsNull( pCrvNewLoop)) return false ; for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) { - if ( vpCrvs[i]->GetTempProp( 0) == 1 && int( vpCrvs.size()) != 1) { // se tratto aperto e non coincidente a tutta la curva + // se tratto aperto e non coincidente con tutta la curva + if ( vpCrvs[i]->GetTempProp( 0) == 1 && int( vpCrvs.size()) != 1) { // semplifico il loop per avere curve più uniformi SimplifyCurve( vpCrvs[i]) ; // riporto le proprietà vpCrvs[i]->SetTempProp( 1) ; for ( int j = 0 ; j < vpCrvs[i]->GetCurveCount() ; ++ j) - vpCrvs[i]->SetCurveTempProp( j, 1, 0) ; + vpCrvs[i]->SetCurveTempProp( j, 1, 0) ; // controllo la lunghezza delle curve double dLen = EPS_SMALL ; vpCrvs[i]->GetLength( dLen) ; - if ( dLen < dToler) { // e più corto della tolleranza + // se più corto della tolleranza + if ( dLen < dToler) { vpCrvs[i]->SetTempProp( 0, 0) ; for ( int j = 0 ; j < vpCrvs[i]->GetCurveCount() ; ++ j) vpCrvs[i]->SetCurveTempProp( j, 0, 0) ; @@ -2581,7 +2586,7 @@ SurfRoughing::CloseOpenEdgesUnderTolerance( ISurfFlatRegion* pSfr, double dToler } // inserisco i nuovi loop nella superficie regolare - if ( l == 0) { + if ( nL == 0) { if ( ! pSfrRegular->AddExtLoop( Release( pCrvNewLoop))) return false ; } From 3745da80c1f00ce0f8c63bda532177190c2a4fa2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 15 Jul 2024 10:18:14 +0200 Subject: [PATCH 2/2] EgtMachKernel : - in sgrossatura superfici corretto calcolo P1 sopra elica di attacco per area successiva alla prima. --- SurfRoughing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SurfRoughing.cpp b/SurfRoughing.cpp index a39ddc5..2c89a1a 100644 --- a/SurfRoughing.cpp +++ b/SurfRoughing.cpp @@ -1911,7 +1911,7 @@ SurfRoughing::AddPocket( const INTINTVECTOR& vPocket, const Vector3d& vtTool, co // se attacco elica od equivalente di step pieno, devo fare elica o similari solo sulla parte con materiale if ( nSubType != SURFROU_SUB_ONEWAY && nSubType != SURFROU_SUB_ZIGZAG && - ! bIsSubStep && + nBasicStep > 0 && ! bIsSubStep && ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX || GetLeadInType() == POCKET_LI_GLIDE)) {