diff --git a/Pocketing.cpp b/Pocketing.cpp index fd428fc..cd65dff 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -101,6 +101,7 @@ using namespace std ; // 2440 = "Error in Pocketing : Computing second pocket failed" // 2441 = "Error in Pocketing : Return path not computable" // 2442 = "Error in Pocketing : Defining volume's faces failed" +// 2443 = "Error in Pocketing : Failed region simplification" // 2451 = "Warning in Pocketing : Skipped entity (xx)" // 2452 = "Warning in Pocketing : No machinable pocket" // 2453 = "Warning in Pocketing : Tool name changed (xx)" @@ -2539,8 +2540,10 @@ Pocketing::SliceVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_Pa return false ; } // dato che la FlatRegion è ricavata a partire da una Trimesh, semplifico i suoi loops - if ( ! SimplifySfrLoops( pSfrCurr)) + if ( ! SimplifySfrLoops( pSfrCurr)) { + m_pMchMgr->SetLastError( 2443, "Error in Pocketing : Failed region simplification") ; return false ; + } // salvo le curve originali per casi ottimizzati if ( ! GetCurvesForOptimizedPocketing( pSfrCurr, vCrvOEWithFlags[j-1])) return false ; @@ -2589,9 +2592,6 @@ Pocketing::SimplifySfrLoops( ISurfFlatRegion* pSfr) if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid()) return false ; - int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvLoop->Clone()) ; - m_pGeomDB->SetMaterial( r, RED) ; - // ricavo i tratti con proprità omogenee, quindi aperti e chiusi ICRVCOMPOPOVECTOR vCrvSameProps ; if ( ! GetHomogeneousParts( pCrvLoop, vCrvSameProps)) @@ -2636,9 +2636,6 @@ Pocketing::SimplifySfrLoops( ISurfFlatRegion* pSfr) return false ; } - int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvSimpleLoop->Clone()) ; - m_pGeomDB->SetMaterial( b, BLUE) ; - // ora che ho il loop semplificato lo inserisco nella flatRegion semplificata if ( l == 0) { if ( ! pSfrSimple->AddExtLoop( Release( pCrvSimpleLoop))) @@ -6931,18 +6928,12 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl vCrvBisectors.empty()) return false ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrSafe->Clone()) ; - ICURVEPOVECTOR VRONI ; - pSfrSafe->CalcVoronoiDiagram( VRONI) ; - // porto i bisettori nel riferimento e rimuovo quelli con un parametro a zero ICURVEPOVECTOR vCrvBisectors_tmp ; for ( int i = 0 ; i < ( int)vCrvBisectors.size() ; ++ i) { // tolgo tutti i Bisettori che presentano un parametro nullo if ( vCrvBisectors[i]->GetTempParam( 0) > EPS_SMALL && vCrvBisectors[i]->GetTempParam( 1) > EPS_SMALL) { - int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, 158, vCrvBisectors[i]->Clone()) ; - m_pGeomDB->SetMaterial( r, RED) ; vCrvBisectors[i]->ToLoc( frCurr) ; vCrvBisectors_tmp.emplace_back( Release( vCrvBisectors[i])) ; } @@ -6950,12 +6941,6 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl swap( vCrvBisectors, vCrvBisectors_tmp) ; vCrvBisectors_tmp.clear() ; - // porto i bisettori nel riferimento - for ( int i = 0 ; i < ( int)VRONI.size() ; ++ i) { - int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, 159, VRONI[i]->Clone()) ; - m_pGeomDB->SetMaterial( r, BLUE) ; - } - // trasformo in composite concatenando le curve ( bloccandomi alle biforcazioni) ICRVCOMPOPOVECTOR vCompoBisChain ; if ( ! ChainBisectors( vCrvBisectors, vCompoBisChain)) @@ -6976,8 +6961,6 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl Point3d ptS_path, ptE_path ; if ( ! pCrvPath->GetStartPoint( ptS_path) || ! pCrvPath->GetEndPoint( ptE_path)) return false ; - int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrDanger->Clone()) ; - m_pGeomDB->SetMaterial( r, ORANGE) ; if ( ! AreSamePointEpsilon( ptS_path, ORIG, 5 * EPS_SMALL)) { PtrOwner pSegStart( CreateCurveLine()) ; @@ -6985,7 +6968,6 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl ! pSegStart->ToGlob( frCurr) || ! GetSpecialElevation( pSfrDanger, pSegStart, true, dMAxElev)) return false ; bSkip = ( dMAxElev > EPS_SMALL) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSegStart->Clone()) ; } if ( ! bSkip) { if ( ! AreSamePointEpsilon( ptE_path, ptEProj, 5 * EPS_SMALL)) { @@ -7017,10 +6999,8 @@ Pocketing::CalcLinkOnStep( const Point3d& ptS, const Point3d& ptE, const ISurfFl // approssimo il percorso PtrOwner pCrvRes( CreateCurveComposite()) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvPath->Clone()) ; if ( ! IsNull( pCrvRes) && GetApproxCurveDP( pCrvPath, dMinPar, pCrvRes)) pCrvPath.Set( Release( pCrvRes)) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvPath->Clone()) ; // smusso mediante parametro di VRONI ModifyCurveToSmoothed( pCrvPath, dMinPar, dMinPar, false) ; @@ -7125,11 +7105,6 @@ Pocketing::ChooseBestBisectorPath( ICRVCOMPOPOVECTOR& vCrvCompo, const Point3d& return false ; pCrvPath->Clear() ; - for ( int u = 0 ; u < int( vCrvCompo.size()) ; ++ u) { - int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vCrvCompo[u]->Clone()) ; - m_pGeomDB->SetMaterial( b, BLUE) ; - } - // cerco gli indici delle curve più vicine a ptS e ptE double dMinDistORIG = INFINITO, dMinDistEnd = INFINITO ; int nIndS, nIndE ; @@ -7158,15 +7133,6 @@ Pocketing::ChooseBestBisectorPath( ICRVCOMPOPOVECTOR& vCrvCompo, const Point3d& ! vCrvCompo[nIndE]->GetParamAtPoint( ptBisE, dUE, 10 * EPS_SMALL)) return false ; - IGeoPoint3d* ptSS = CreateGeoPoint3d() ; ptSS->Set( ptS) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ptSS->Clone()) ; - ptSS->Set( ptBisS) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ptSS->Clone()) ; - ptSS->Set( ptE) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ptSS->Clone()) ; - ptSS->Set( ptBisE) ; - m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, ptSS->Clone()) ; - // splitto le curve più vicine sui rispettivi punti ( se non coincidenti a degli estremi) if ( nIndS != nIndE) { // se le curve sono distinte @@ -11943,6 +11909,7 @@ Pocketing::SetBetterPtStartForSubChunks( ICurveComposite* pCrvOffsAct, const ISu // creo un vettore di indici. Questi indici si riferiscono alle posizioni di vCrvLoops i quali offset // hanno generato delle curve sulla pCrv ( curva da cui devo entrare ) INTVECTOR vIndex ; + int nInd = -1 ; // indice della prima curva che non è "raccordo" di Offset // scorro tutte le curve presenti in pCrv ( curva da cui devo entrare) for ( int i = 0 ; i < pCrv->GetCurveCount() ; ++ i) { @@ -11965,12 +11932,29 @@ Pocketing::SetBetterPtStartForSubChunks( ICurveComposite* pCrvOffsAct, const ISu // se la curva è aperta, aggiorno il Flag if ( nTempProp == 1 && ! bSomeOpen) bSomeOpen = true ; + // salvo l'indice della prima curva trovata che non è un "raccordo" di Offset + if ( nInd == -1) + nInd = i ; } else pCrv->SetCurveTempProp( i, 0, 0) ; } - else - pCrv->SetCurveTempProp( i, 1, 0) ; + else { + pCrv->SetCurveTempProp( i, -2, 0) ; + pCrv->SetCurveTempProp( i, -2, 1) ; + } + } + + // scorro tutte le curve incerte ( che derivano da raccordi ) + if ( nInd != -1) + pCrv->ChangeStartPoint( nInd) ; // la prima curva non è un "raccordo" di Offset + + for ( int i = 1 ; i < pCrv->GetCurveCount() ; ++ i) { + int nTmpProp0, nTmpProp1 ; + if (( pCrv->GetCurveTempProp( i, nTmpProp0, 0) && nTmpProp0 == -2) && + ( pCrv->GetCurveTempProp( i, nTmpProp1, 1) && nTmpProp1 == -2)) + // copio la temp prop della curva precedente + pCrv->SetCurveTempProp( i, pCrv->GetCurve( i-1)->GetTempProp(), 0) ; } // se ho dei lati aperti... @@ -12005,6 +11989,7 @@ Pocketing::SetBetterPtStartForSubChunks( ICurveComposite* pCrvOffsAct, const ISu } } } + // il punto iniziale della curva sarà il punto iniziale della sottocurva trovata pCrv->ChangeStartPoint( nIndClosesOpenCrv) ; }