diff --git a/Pocketing.cpp b/Pocketing.cpp index b2dacd1..859a78b 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -1826,11 +1826,11 @@ Pocketing::ProcessPath( int nAuxId, int nPvId, int nClId) // Eseguo la lavorazione della superificie finale switch ( m_Params.m_nSubType) { case POCKET_SUB_ZIGZAG: - if ( ! AddZigZag( pSrfPock, vtTool, vtExtr, dDepth, dMaxElev, dElev, dOkStep, bSplitArcs)) + if ( ! AddZigZag( pSrfPock, vtTool, vtExtr, dDepth, dElev, dMaxElev, dOkStep, bSplitArcs)) return false ; break ; case POCKET_SUB_ONEWAY: - if ( ! AddOneWay( pSrfPock, vtTool, vtExtr, dDepth, dElev, dOkStep, bSplitArcs)) + if ( ! AddOneWay( pSrfPock, vtTool, vtExtr, dDepth, dElev, dMaxElev, dOkStep, bSplitArcs)) return false ; break ; case POCKET_SUB_SPIRALIN: @@ -2250,7 +2250,7 @@ GetCurveRadius( const ICurve* pCrv) //---------------------------------------------------------------------------- bool Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dMaxElev, double dElev, double dOkStep, bool bSplitArcs) + double dDepth, double dElev, double dMaxElev, double dOkStep, bool bSplitArcs) { // recupero distanze di sicurezza @@ -2514,6 +2514,8 @@ Pocketing::AddZigZag( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c PtrOwner pCrvLoop( ConvertCurveToComposite( pSrfForCrv->GetLoop( cfc, l))) ; if ( IsNull( pCrvLoop)) return false ; + if ( l > 0) + pCrvLoop->Invert() ; bool bOutTmp = false ; @@ -4129,7 +4131,7 @@ Pocketing::CutCurveWithLine( ICurveComposite* pCrvA, const ICurveLine* pCrvB) //---------------------------------------------------------------------------- bool Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, const Vector3d& vtExtr, - double dDepth, double dElev, double dOkStep, bool bSplitArcs) + double dDepth, double dElev, double dMaxElev, double dOkStep, bool bSplitArcs) { // recupero distanze di sicurezza @@ -4142,13 +4144,13 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c if ( m_TParams.m_nType == TT_MILL_NOTIP) { if ( ! LeadInRawIsOk()) { m_pMchMgr->SetLastError( 2431, "Error in Pocketing : LeadIn with Mill NoTip in material") ; - return false; + return false ; } } // determino numero e affondamento degli step int nStep = 1 ; - nStep = max( 1, static_cast( ceil(dElev / dOkStep))) ; + nStep = max( 1, static_cast( ceil( dElev / dOkStep))) ; double dStep = dElev / nStep ; double dTRad = 0.5 * m_TParams.m_dDiam ; @@ -4161,7 +4163,6 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c return false ; // creo le regioni ideali -------------------------------------------- - // creo un frame di riferimento della svuotatura Frame3d frLoc ; Point3d ptC ; pSrfToPock->GetCentroid( ptC) ; @@ -4169,34 +4170,16 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c frLoc.Set( ptC, vtN) ; pSrfToPock->ToLoc( frLoc) ; - ISURFFRPOVECTOR vSrfFlat ; - INTVECTOR vIndChunk ; - PNTVECTOR vPtCheck ; - struct PtSPtC { // struttura per punti inziali - int nInd ; // indice per vettori vPtStart, vbMidOpen, vPtMidOpen, vVtMidOut - Point3d ptC ; // punto check sulla curva - } ; - - if ( ! OptimizeChunkOneWay( pSrfToPock, vSrfFlat, vIndChunk, vPtCheck)) + ISURFFRPOVECTOR vSrfFlat ; // vettore delle regioni ideali + if ( ! OptimizeChunkOneWay( pSrfToPock, vSrfFlat)) return false ; - typedef vector vPtSCheck ; - vPtSCheck vNewPtStart(( int)vIndChunk.size()) ; - for ( int i = 0 ; i < ( int)vIndChunk.size() ; ++ i){ - vNewPtStart[i].nInd = vIndChunk[i] ; - vNewPtStart[i].ptC = vPtCheck[i] ; - } - - // riporto le superifici ideali nel sistema di riferimento globale + // riporto le superifici ideali nel sistema di riferimento globale ( Ogni chunk verrà poi messo nel suo frame) for ( int i = 0 ; i < (int )vSrfFlat.size() ; ++ i) vSrfFlat[i]->ToGlob( frLoc) ; - // ------------------------------------------------------------------ - // === per ogni superificie ideale creo 2 Offsets === - // - dOffs con le curve da percorrere all'inizio ( bordo da percorrere, senza mai superarlo) - // - dOffs - dExtra per definire le curve interne della svuotatura ( bordo immaginario per il OneWay ) - + // scorro le regioni ideali for ( int nIs = 0 ; nIs < int( vSrfFlat.size()) ; ++ nIs) { // copio la superificie ideale @@ -4204,6 +4187,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c if ( IsNull( pSrfIdeal)) return false ; + // adatto la superficie alla sua geometria e al grezzo ISURFFRPOVECTOR vSrfSliced( nStep) ; vector vCrvOEWithFlags( nStep) ; BOOLVECTOR vbChangedPrec( nStep, false) ; @@ -4213,8 +4197,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c return false ; Point3d ptP1 ; // per LeadIn - - for ( int j = 1 ; j <= nStep ; ++ j) { + for ( int j = 1 ; j <= nStep ; ++ j) { // ... per ogni step // se superificie non valida, salto allo step successivo if ( IsNull( vSrfSliced[ j-1]) || vSrfSliced[j-1]->GetChunkCount() == 0) { @@ -4227,10 +4210,9 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c if ( IsNull( pSrfLeanInOut) || pSrfLeanInOut->GetChunkCount() == 0) return false ; - // === PRIMO OFFSET === // NB. Effettuando il primo Offset, il numero di chunk qui potrebbe cambiare... PtrOwner pSrfFirstOffs( CloneSurfFlatRegion( vSrfSliced[j-1])) ; - if ( IsNull( pSrfFirstOffs) || pSrfFirstOffs->GetChunkCount() == 0) + if ( IsNull( pSrfFirstOffs) || ! pSrfFirstOffs->IsValid()) return false ; if ( ! pSrfFirstOffs->Offset( - dOffs, ICurve::OFF_FILLET)) { m_pMchMgr->SetLastError( 2412, "Error in Pocketing : Offset not computable") ; @@ -4254,7 +4236,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c // regioni non svuotate ( come soluzione interseco ogni segmento di OneWay con questa superificie Offsettata di // -dOffs e tagliando ogni segmento, lo accorcio sia all'inizio che alla fine della quantità dExtra - // organizzo i Chunck della superificie elaborata con il grezzo ... + // organizzo i Chunck ( MIGLIORABILE AVENDO UNA TEMP_PROP3 CHE MI DICE L'OFFSET DA QUALE CHUNK DISCENDE) for ( int c = 0 ; c < vSrfSliced[j-1]->GetChunkCount() ; ++ c) { PtrOwner pSrfChuck_c( vSrfSliced[j-1]->CloneChunk( c)) ; if ( IsNull( pSrfChuck_c)) @@ -4267,14 +4249,20 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c for ( int cc = 0 ; cc < pSrfChuck_c->GetChunkCount() ; ++ cc) { for ( int l = 0 ; l < pSrfChuck_c->GetLoopCount( cc) ; ++ l) { - vAllCrv.emplace_back( GetCurveComposite( pSrfChuck_c->GetLoop( cc, l))) ; + PtrOwner pCrvCompoLoop( ConvertCurveToComposite( pSrfChuck_c->GetLoop( cc, l))) ; + if ( IsNull( pCrvCompoLoop) || ! pCrvCompoLoop->IsValid()) + return false ; + if ( l > 0) + pCrvCompoLoop->Invert() ; + vAllCrv.emplace_back( Release( pCrvCompoLoop)) ; vInd.emplace_back( c) ; } } } + // se non ho curve di bordo, salto allo step succevo, non avrà nemmeno i segmenti OneWay if (( int)vAllCrv.size() == 0) - return false ; + continue ; // passo allo step successivo // Sistemo i punti iniziali per i nuovi Chunks ------------------------------------------ VCT3DVECTOR vVtMidOut(( int)vAllCrv.size(), V_NULL) ; @@ -4287,10 +4275,11 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c // per ogni curva di bordo... bool bOutTmp = false ; - + // ricavo il chunk da vui deriva -> vInd PtrOwner pSrfCurrChunk( vSrfSliced[j-1]->CloneChunk( vInd[u])) ; if ( IsNull( pSrfCurrChunk)) return false ; + // imposto un punto valido per l'entrata if ( ! SetBetterPtStartForSubChunks( vAllCrv[u], pSrfCurrChunk, vPtStart[u], vVtMidOut[u], bOutTmp)) return false ; @@ -4318,12 +4307,13 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c if ( vbMidOut[u]) { // calcolo il punto fuori Point3d ptOut = vPtStart[u] + vVtMidOut[u] * ( 0.5 * m_TParams.m_dDiam + dSafeZ) ; - ptOut.Translate( - vtTool * ( dDepth - dElev + j * dStep)) ; + ptOut.Translate( vVtTrasl[j-1]) ; // lo traslo allo step corrente double dStElev ; - bool bOutStart = ( ! GetElevation( m_nPhase, ptOut, vtTool, 0.5 * m_TParams.m_dDiam, vtTool, dStElev) || dStElev < EPS_SMALL); + bool bOutStart = ( ! GetElevation( m_nPhase, ptOut, vtTool, 0.5 * m_TParams.m_dDiam, vtTool, dStElev) || + dStElev < EPS_SMALL) ; if ( bOutStart || m_bOpenOutRaw) { // aggiungo alla curva il tratto lineare - ptOut.Translate( vtTool * ( dDepth - dElev + j * dStep)) ; + ptOut.Translate( - vVtTrasl[j-1]) ; vAllCrv[u]->AddLine( ptOut, false) ; AssignFeedForLineInOut( vAllCrv[u], true) ; } @@ -4342,11 +4332,14 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c } // riordino le curve ( e i relativi vettori ) in base alla vicinanza - // ( piccola ottimizzazione per l'ordine dei percorsi sui bordi ) + // ( piccola ottimizzazione per l'ordine dei percorsi sui bordi) Point3d ptStart ; vAllCrv[0]->GetStartPoint( ptStart) ; if ( ! OrderCurvesByLastPntOfPath( vAllCrv, ptStart, vPtStart, vVtMidOut, vbMidOut)) return false ; + // determino l'affondamento attuale + double dSink = dElev - dDepth + dMaxElev - vVtTrasl[j-1].Len() ; + // ---------------------------- Disegno le curve di contorno ---------------------- for ( int u = 0 ; u < int( vAllCrv.size()) ; ++ u) { // percorro tutte le curve ( ordinate ) @@ -4370,7 +4363,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c if ( IsNull( pCurve)) return false ; // aggiungo affondamento - pCurve->Translate( -vtTool * ( dDepth - dElev + j * dStep)) ; + pCurve->Translate( vVtTrasl[j-1]) ; // SE PRIMA ENTITA' if ( i == 0) { // dati inizio entità @@ -4389,7 +4382,8 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c return false ; // determino elevazione su inizio attacco //double dStElev ; - if ( ! GetElevation( m_nPhase, ptForElev - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) + dStElev = dSink ; + /*if ( ! GetElevation( m_nPhase, ptForElev - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) dStElev = j * dStep ; bool bAhUnderRaw = m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab && GetAhPointUnderRaw( ptP1, vtTool, 0, GetRadiusForStartEndElevation(), @@ -4399,7 +4393,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ; if ( bAhUnderRaw || bUhAboveRaw || m_bTiltingTab) dStElev = max( dStElev, j * dStep) ; - dStElev -= ( ptP1 - ptStart) * vtExtr ; + dStElev -= ( ptP1 - ptStart) * vtExtr ;*/ // se attacco a zigzag o a spirale o a scivolo, l'elevazione va nell'attacco if ( GetLeadInType() == POCKET_LI_ZIGZAG || GetLeadInType() == POCKET_LI_HELIX || @@ -4418,16 +4412,6 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ; return false ; } - //} - // altrimenti solo collegamento - // else { - // SetFeed( GetStartFeed()) ; - // GetCurrPos( ptP1) ; - // if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pSrfLeanInOut, nullptr, !m_Params.m_bInvert, bSplitArcs)) { - // m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Link not computable") ; - // return false ; - // } - // } } // elaborazioni sulla curva corrente // elaborazioni sulla curva corrente @@ -4439,7 +4423,6 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c if ( pCurve->GetType() == CRV_LINE) { ICurveLine* pLine = GetCurveLine( pCurve) ; Point3d ptP3 = pLine->GetEnd() ; - //SetFeed( dFeedRid * GetFeed()) ; if ( AddLinearMove( ptP3) == GDB_ID_NULL) return false ; } @@ -4450,27 +4433,22 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c Vector3d vtN = pArc->GetNormVersor() ; Point3d ptP3 ; pArc->GetEndPoint( ptP3) ; - //SetFeed( dFeedRid * GetFeed()) ; if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL) return false ; } // SE ULTIMA ENTITA' if ( i == nMaxInd) { // se ultimo step, uscita e retrazione di collegamento - //if ( j == nStep ) { // dati fine entità Point3d ptEnd ; pCurve->GetEndPoint( ptEnd) ; Vector3d vtEnd ; pCurve->GetEndDir( vtEnd) ; // aggiungo uscita - //Point3d ptP1 ; <----------- ????????????? - //double dEndElev = dElev ; - //double dEndElev = dStElev ; - double dEndElev ; - if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + double dEndElev = dSink ; + /*if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) dEndElev = j * dStep ; - dEndElev = max( dEndElev, j * dStep) ; + dEndElev = max( dEndElev, j * dStep) ;*/ SetFeed( GetEndFeed()) ; if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, nullptr, bSplitArcs, false, ptP1, dEndElev, false)) { m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ; @@ -4511,10 +4489,9 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c // calcolo le linee di svuotatura const double EXP_LEN = 1.0 ; - //for ( int j = 1 ; j <= nStep ; ++j) { for ( int i = 1 ; i <= nYStep ; ++ i) { - // definisco la linea + // definisco la linea PtrOwner pLine( CreateCurveLine()) ; Point3d ptStart( ptMin.x - EXP_LEN, ptMin.y + ( - dExtra + i * dYStep), ptMin.z + dDimZ) ; if ( IsNull( pLine) || ! pLine->SetPVL( ptStart, X_AX, dDimX + 2 * EXP_LEN)) { @@ -4548,32 +4525,24 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c Point3d ptS, ptE ; pCrvSeg->GetStartPoint( ptS) ; - //pCrvSeg->GetEndPoint( ptE) ; // imposto la Feed - //vAddedLines.emplace_back( pCrvSeg->Clone()) ; pCrvCompo->Clear() ; pCrvCompo->AddCurve( pCrvSeg->Clone()) ; vAddedLines.emplace_back( pCrvCompo->Clone()) ; if ( ! AssignFeedZigZagOneWay( pCrvCompo, false, vLineAbove, vLineUnder, vCrvLink)) return false ; - //PtrOwner pCrvCompo( CreateCurveComposite()) ; - //if ( IsNull( pCrvCompo)) - // return false ; - //pCrvCompo->AddCurve( pCrvSeg->Clone()) ; - //if ( ! AssignFeedOneWay( pCrvSeg, pSrfRemoved) || - // ! GetDynamicClearedRegion( pSrfRemoved, pCrvCompo)) - // return false ; // INIZIO ptS.ToGlob( frPocket) ; - ptS.Translate( -vtTool * ( dDepth - dElev + j * dStep)) ; + ptS.Translate( vVtTrasl[j-1]) ; // determino inizio attacco Point3d ptP ; if ( ! CalcLeadInStart( ptS, frPocket.VersX(), vtExtr, nullptr, ptP)) return false ; // determino elevazione su inizio attacco - double dStElev ; + double dStElev = dSink ; + /*double dStElev ; if ( ! GetElevation( m_nPhase, ptS - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dStElev)) dStElev = j * dStep ; bool bAhUnderRaw = m_bAboveHead && ! m_bAggrBottom && ! m_bTiltingTab && @@ -4584,7 +4553,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c m_TParams.m_dLen, false, dSafeZ, vtTool, dStElev) ; if( bAhUnderRaw || bUhAboveRaw || ( i == 1 && w == 1)) dStElev = max( dStElev, j * dStep) ; - dStElev -= ( ptP - ptS) * vtExtr ; + dStElev -= ( ptP - ptS) * vtExtr ;*/ // sempre approccio di collegamento if ( ! AddLinkApproach( ptP, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr)) { m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Link not computable") ; @@ -4599,12 +4568,10 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) { - //ptE.ToGlob( frPocket) ; - //ptE.Translate( -vtTool * (dDepth - dElev + j * dStep)) ; const ICurve* pCurve( pCrvCompo->GetCurve( u)) ; pCurve->GetEndPoint( ptE) ; ptE.ToGlob( frPocket) ; - ptE.Translate( -vtTool * ( dDepth - dElev + j * dStep)) ; + ptE.Translate( vVtTrasl[j-1]) ; // movimento al punto finale // elaborazioni sulla curva corrente @@ -4612,18 +4579,6 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c double dFeed = pCurve->GetTempProp( 0) / FEED_DIVISOR < dMinFeed - 50 * EPS_SMALL ? GetFeed() : pCurve->GetTempProp( 0) / FEED_DIVISOR ; SetFeed( dFeed) ; - //PtrOwner pCrv_TestFeed( pCurve->Clone()) ; - //pCrv_TestFeed->ToGlob( frPocket) ; - //if ( abs( dFeed - GetMinFeed()) < EPS_SMALL) { - // int rosso = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCrv_TestFeed->Clone()) ; - // m_pGeomDB->SetMaterial( rosso, RED) ; - //} - //if ( abs( dFeed - GetMaxFeed()) < EPS_SMALL) { - // int verde = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCrv_TestFeed->Clone()) ; - // m_pGeomDB->SetMaterial( verde, GREEN) ; - //} - //SetFeed( dFeed) ; - //SetFeed( GetFeed()) ; if ( AddLinearMove( ptE) == GDB_ID_NULL) return false ; @@ -4632,10 +4587,10 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c // FINE Point3d ptQ ; //double dEndElev = dElev ; - double dEndElev ; - if ( ! GetElevation( m_nPhase, ptE - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) + double dEndElev = dSink ; + /*if ( ! GetElevation( m_nPhase, ptE - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), vtTool, dEndElev)) dEndElev = j * dStep ; - dEndElev = max( dEndElev, j * dStep) ; + dEndElev = max( dEndElev, j * dStep) ;*/ SetFeed( GetEndFeed()) ; if ( ! AddLeadOut( ptE, frPocket.VersX(), vtExtr, nullptr, bSplitArcs, true, ptQ, dEndElev)) { m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ; @@ -12059,18 +12014,12 @@ Pocketing::GetStmRawPart( int nId, ISurfTriMesh* pSrfTMRaw, Frame3d frPocket) //---------------------------------------------------------------------------- bool -Pocketing::OptimizeChunkOneWay( ISurfFlatRegion* pSrfOrig, ISURFFRPOVECTOR& vSrfIdeal, INTVECTOR& vIndChunk, PNTVECTOR& vPtCheck) +Pocketing::OptimizeChunkOneWay( ISurfFlatRegion* pSrfOrig, ISURFFRPOVECTOR& vSrfIdeal) { // controllo parametri if ( pSrfOrig == nullptr || pSrfOrig->GetChunkCount() == 0) return false ; vSrfIdeal.clear() ; - vIndChunk.clear() ; - vPtCheck.clear() ; - - // Temp prop della superificie - int nProp0 ; - int nProp1 ; // clono la superificie passata alla funzione PtrOwner pSrfToPock( CloneSurfFlatRegion( pSrfOrig)) ; @@ -12082,82 +12031,59 @@ Pocketing::OptimizeChunkOneWay( ISurfFlatRegion* pSrfOrig, ISURFFRPOVECTOR& vSrf INTVECTOR vChunksAvailable( pSrfToPock->GetChunkCount(), 1) ; - struct PtSPtC { // struttura per punti inziali - int nInd ; // indice per vettori vPtStart, vbMidOpen, vPtMidOpen, vVtMidOut - Point3d ptC ; // punto check sulla curva - } ; - typedef vector vPtSCheck ; - vPtSCheck vNewPtStart ; - for ( int c = 0 ; c < pSrfToPock->GetChunkCount() ; ++ c) { PtrOwner pSrfIdeal( CreateSurfFlatRegion()) ; if ( IsNull( pSrfIdeal)) return false ; if ( vChunksAvailable[c] == 1) { // se Chunk valido... - PtrOwner pCrvExt( GetCurveComposite( pSrfToPock->GetLoop( c, 0))) ; + // prendo la curva esterna + PtrOwner pCrvExt( ConvertCurveToComposite( pSrfToPock->GetLoop( c, 0))) ; if ( IsNull( pCrvExt)) return false ; - nProp0 = pCrvExt->GetTempProp( 0) ; - nProp1 = pCrvExt->GetTempProp( 1) ; - pSrfIdeal.Set( pSrfToPock->CloneChunk( c)) ; // inserisco curva esterna + // inserisco il chunk c-esimo ( curva per curva, così non perdo le temp prop) + pSrfIdeal->AddExtLoop( *pCrvExt) ; // ... inizio a creare la regione ideale da esso + for ( int l = 1 ; l < pSrfToPock->GetLoopCount( c) ; ++ l) + pSrfIdeal->AddIntLoop( *ConvertCurveToComposite( pSrfToPock->GetLoop( c, l))) ; + // il chunk c-esimo non è più disponibile... vChunksAvailable[c] = -1 ; - PtSPtC newPtSPtC ; newPtSPtC.nInd = c ; pCrvExt->GetStartPoint( newPtSPtC.ptC) ; + // scorro tutti gli altri chunk i-esimi ancora disponibili for ( int i = 0 ; i < int( vChunksAvailable.size()) ; ++ i) { - if ( vChunksAvailable[i] == 1) { // se chunk valido... - PtrOwner pCrvExtC( GetCurveComposite( pSrfToPock->GetLoop( i, 0))) ; + if ( vChunksAvailable[i] == 1) { + // prendo la curva esterna del chunk i-esimo disponibile + PtrOwner pCrvExtC( ConvertCurveToComposite( pSrfToPock->GetLoop( i, 0))) ; if ( IsNull( pCrvExtC)) return false ; + // classifico i bordi esterni ( se il bordo del chunk c-esimo contiene o è contenuto nel loop + // esterno del chunk i-esimo -> sono chunks appartenenti alla stessa superficie ideale) IntersCurveCurve intCC( *pCrvExtC, *pCrvExt) ; CRVCVECTOR ccClass, ccClass1 ; intCC.GetCurveClassification( 0, EPS_SMALL, ccClass) ; intCC.GetCurveClassification( 1, EPS_SMALL, ccClass1) ; if (( ccClass.size() == 1 && ccClass[0].nClass == CRVC_IN) || ( ccClass1.size() == 1 && ccClass1[0].nClass == CRVC_IN)) { - pSrfIdeal->Add( *pSrfToPock->CloneChunk( i)) ; // ... inserisco loop interno - vChunksAvailable[i] = -1 ; + // inserisco il chunk i-esimo ( curva per curva, così non perdo le temp prop) + pSrfIdeal->AddExtLoop( *ConvertCurveToComposite( pSrfToPock->GetLoop( i, 0))) ; + for ( int l = 1 ; l < pSrfToPock->GetLoopCount( i) ; ++ l) + pSrfIdeal->AddIntLoop( *ConvertCurveToComposite( pSrfToPock->GetLoop( i, l))) ; + vChunksAvailable[i] = -1 ; // chunk j-esimo non più disponibile + // NB: Se il chunk i-esimo contiene la pSrfIdeal ( quindi chunk i-esimo unito ad eventuali altri chunk + // j-esimi precedenti -> prendo come bordo esterno di riferimento il suo e ricontrollo dall'inizio i + // chunk disponibili if (( int)ccClass1.size() == 1 && ccClass1[0].nClass == CRVC_IN) { pCrvExt.Set( pCrvExtC->Clone()) ; - newPtSPtC.nInd = i ; pCrvExtC->GetStartPoint( newPtSPtC.ptC) ; i = 0 ; } } } } - vNewPtStart.push_back( newPtSPtC) ; } - if ( pSrfIdeal->GetChunkCount() > 0) { + + if ( pSrfIdeal->GetChunkCount() > 0) vSrfIdeal.emplace_back( Release( pSrfIdeal)) ; - } + } - // imposto vettore dei punti iniziali e vettore degli indici dei chunks - for ( int i = 0 ; i < ( int)vNewPtStart.size() ; ++ i){ - vIndChunk.emplace_back( vNewPtStart[i].nInd) ; - vPtCheck.emplace_back( vNewPtStart[i].ptC) ; - } - - // reimposto tutte le temp prop alle curve delle nuove superifici - for ( int i = 0 ; i < ( int)vSrfIdeal.size() ; ++ i) { - PtrOwner pSrfIdeal_TmpProp( CreateSurfFlatRegion()) ; - if ( IsNull( pSrfIdeal_TmpProp)) - return false ; - for ( int c = 0 ; c < vSrfIdeal[i]->GetChunkCount() ; ++ c) { - for ( int l = 0 ; l < vSrfIdeal[i]->GetLoopCount( c) ; ++ l) { - PtrOwner pCrvCurr( vSrfIdeal[i]->GetLoop( c, l)) ; - if ( IsNull( pCrvCurr) || ! pCrvCurr->IsValid()) - return false ; - pCrvCurr->SetTempProp( nProp0, 0) ; - pCrvCurr->SetTempProp( nProp1, 1) ; - if ( l == 0) - pSrfIdeal_TmpProp->AddExtLoop( Release( pCrvCurr)) ; - else - pSrfIdeal_TmpProp->AddIntLoop( Release( pCrvCurr)) ; - } - } - vSrfIdeal[i].Set( Release( pSrfIdeal_TmpProp)) ; - } - - return ( vSrfIdeal.size() != 0) ; + return ( int( vSrfIdeal.size() != 0)) ; } @@ -13384,7 +13310,7 @@ Pocketing::SetBetterPtStartForSubChunks( ICurveComposite* pCrvOffsAct, const ISu } // creo un vettore con tutti i Loops della pSwfToWork per i quali, mediante l'Offset, non hanno - // generato alcuna curva presente nella pCrv ( quella da cui devo entrare ) + // generato alcuna curva presente nella pCrv ( quella da cui devo entrare) ICRVCOMPOPOVECTOR vOtherCrv ; for ( int i = 0 ; i < ( int)vCrvLoops.size() ; ++ i) { bool bOk = true ; diff --git a/Pocketing.h b/Pocketing.h index 08f21fc..2d0cfa5 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -206,9 +206,8 @@ class Pocketing : public Machining // ============================ OneWay =============================== bool AddOneWay( const ISurfFlatRegion* pSrfPock , const Vector3d& vtTool, const Vector3d& vtExtr, double dDepth, - double dElev, double dOkStep, bool bSplitArcs) ; - bool OptimizeChunkOneWay( ISurfFlatRegion* pSrfOrig, ISURFFRPOVECTOR& vSrfIdeal, INTVECTOR& vIndChunk, - PNTVECTOR& vPtCheck) ; + double dElev, double dMaxElev, double dOkStep, bool bSplitArcs) ; + bool OptimizeChunkOneWay( ISurfFlatRegion* pSrfOrig, ISURFFRPOVECTOR& vSrfIdeal) ; // =================================================================== // ============================ SpiralIn/Out ========================= @@ -370,8 +369,8 @@ class Pocketing : public Machining AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto bool m_bOpenOutRaw ; // flag forzatura lati aperti sempre fuori dal grezzo double m_dOpenMinSafe ; // minima distanza di sicurezza di attacco su lato aperto - bool m_bIntersRaw = false ; // flag per intersezione con grezzo - bool m_bProjectRaw = false ; // flag di proiezione del grezzo + bool m_bIntersRaw = true ; // flag per intersezione con grezzo + bool m_bProjectRaw = true ; // flag di proiezione del grezzo bool m_bHasShape = true ; // flag per presenza di geometria voluta PtrOwner m_pStmShape ; // puntatore alla superficie TriMesh da seguire double m_dMaxLenRawProj = 100 ; // lunghezza massima per contatto di proiezione