diff --git a/Pocketing.cpp b/Pocketing.cpp index 4ef191b..de502ff 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -1608,13 +1608,6 @@ Pocketing::ProcessPath( int nAuxId, int nPvId, int nClId) if ( ! pCompoOriCrv->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false, true)) return false ; - for ( int u = 0 ; u < pCompoOriCrv->GetCurveCount() ; ++ u) - { - int nProp ; pCompoOriCrv->GetCurveTempProp( u, nProp, 0) ; - int OOOO = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompoOriCrv->GetCurve( u)->Clone()) ; - m_pGeomDB->SetMaterial( OOOO, nProp == 0 ? BLUE : RED) ; - } - // recupero estrusione e spessore Vector3d vtExtr_p = Z_AX ; pCompoOriCrv->GetExtrusion( vtExtr_p) ; @@ -8670,8 +8663,8 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP PtrOwner pCrvRange( CreateCurveComposite()) ; pCrvRange->AddCurve( vpCrvs[i]->Clone()) ; - //int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvRange->Clone()) ; - //m_pGeomDB->SetMaterial( W, WHITE) ; + int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvRange->Clone()) ; + m_pGeomDB->SetMaterial( W, WHITE) ; for ( int j = 0 ; j < pCrvRange->GetCurveCount() ; ++ j) pCrvRange->SetCurveTempProp( j, 1, 0) ; @@ -8680,8 +8673,8 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP } } - //int green = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ; - //m_pGeomDB->SetMaterial( green, GREEN) ; + int green = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ; + m_pGeomDB->SetMaterial( green, GREEN) ; // clono la pCompo PtrOwner pCompo_clone( CloneCurveComposite( pCompo)) ; @@ -8711,6 +8704,9 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP PtrOwner pCrvNew( CreateCurveComposite()) ; AdjustPathOutsideRawForOpenEdges( pCompo_clone, vCrvIsl, pHHHH, ptS, ptE, dRad, dDiam, pCrvNew) ; vpCrvs[i].Set( Release( pCrvNew)) ; + vpCrvs[i]->GetStartPoint( ptStart) ; + int BRO = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, vpCrvs[i]->Clone()) ; + m_pGeomDB->SetMaterial( BRO, BROWN) ; // ----------------------------------------------------------------------------------- // determino la curva ad amo @@ -8727,8 +8723,8 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP if ( IsNull( pJCrv)) return false ; pJCrv->AddCurve( Release( pCrvArc)) ; - //int y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ; - //m_pGeomDB->SetMaterial( y, YELLOW) ; + int y = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ; + m_pGeomDB->SetMaterial( y, YELLOW) ; // assegno alle sue sottocurve la proprietà di curva aperta //for ( int u = 0 ; u < pJCrv->GetCurveCount() ; ++ u) @@ -8777,8 +8773,8 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP pJCrv->AddLine( ptArc) ;; pJCrv->AddArcTg( ptStart) ; - //int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ; - //m_pGeomDB->SetMaterial( a, ORANGE) ; + int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pJCrv->Clone()) ; + m_pGeomDB->SetMaterial( a, ORANGE) ; // assegno alle sue sottocurve la proprietà di curva aperta for ( int u = 0 ; u < pJCrv->GetCurveCount() ; ++ u) @@ -8791,6 +8787,9 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP if ( pCompo->GetCurveCount() >= 2) pLCrv->AddCurve( pCompo->GetPrevCurve()->Clone(), false) ; double dUL = pLCrv->GetCurveCount() ; + int A = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pLCrv->Clone()) ; + m_pGeomDB->SetMaterial( A, AQUA) ; + pJCrv->ToLoc( frPocket) ; pLCrv->ToLoc( frPocket) ; IntersCurveCurve intCC( *pJCrv, *pLCrv) ; @@ -8818,14 +8817,14 @@ Pocketing::AdjustContourWithOpenEdges( ICurveComposite* pCompo, const ICRVCOMPOP // aggiungo la curva pCompo->AddCurve( ::Release( vpCrvs[i]), true, 10 * EPS_SMALL) ; - //int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ; - //m_pGeomDB->SetMaterial( p, PURPLE) ; + int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ; + m_pGeomDB->SetMaterial( p, PURPLE) ; } // non dovrebbe esserci un gap, ma meglio prevenire problemi pCompo->Close() ; - //int LI = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ; - //m_pGeomDB->SetMaterial( LI, LIME) ; + int LI = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo->Clone()) ; + m_pGeomDB->SetMaterial( LI, LIME) ; return true ; @@ -8850,13 +8849,13 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons PtrOwner pCompo_Prec( CloneCurveComposite( pCompo)) ; pCompo_Prec->GetParamAtPoint( ptCrvOpenS, dUTrimS) ; pCompo_Prec->TrimEndAtParam( dUTrimS) ; - //int B = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCompo_Prec->Clone()) ; // - //m_pGeomDB->SetMaterial( B, BLACK) ; // + int B = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCompo_Prec->Clone()) ; // + m_pGeomDB->SetMaterial( B, BLACK) ; // PtrOwner pCompo_Succ( CloneCurveComposite( pCompo)) ; pCompo_Succ->GetParamAtPoint( ptCrvOpenE, dUTrimE) ; pCompo_Succ->TrimStartAtParam( dUTrimE) ; - //int Bl = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo_Succ->Clone()) ; // - //m_pGeomDB->SetMaterial( Bl, BLUE) ; // + int Bl = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCompo_Succ->Clone()) ; // + m_pGeomDB->SetMaterial( Bl, BLUE) ; // PtrOwner pCrvOpen( CloneCurveComposite( pCompo)) ; pCrvOpen->TrimStartEndAtParam( dUTrimS, dUTrimE) ; PtrOwner pCompo_noOpenCrv( CloneCurveComposite( pCompo_Succ)) ; @@ -8886,8 +8885,8 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons PtrOwner pSfrInc( GetSurfFlatRegionFromFatCurve( Release( pCrvOpen_clone), dRad, true, false)) ; if ( IsNull( pSfrInc) || ! pSfrInc->IsValid()) return false ; - //int arancione = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; // - //m_pGeomDB->SetMaterial( arancione, ORANGE) ; // + int arancione = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; // + m_pGeomDB->SetMaterial( arancione, ORANGE) ; // // -------------- AGGIORNAMENTO DELLA REGIONE DI INFLUENZA -------------- // creo un vettore con la pCompo senza lato aperto e le isole contenute al suo interno @@ -8950,14 +8949,18 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons pCrvExtBorder->AddCurve( Release( pLineE)) ; // secondo tratto lineare pCrvCurrPartIn->Invert() ; // inversione del tratto interno pCrvExtBorder->AddCurve( Release( pCrvCurrPartIn)) ; // aggiunta del tratto interno + + int rrr = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExtBorder->Clone()) ; + m_pGeomDB->SetMaterial( rrr, RED) ; + if ( pCrvExtBorder->IsClosed()) { // 9) Creo la nuova regione da aggiungere a quella di influenza PtrOwner pSfrExpan( CreateSurfFlatRegion()) ; if ( IsNull( pSfrExpan)) return false ; pSfrExpan->AddExtLoop( Release( pCrvExtBorder)) ; - //int green = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExpan->Clone()) ; // - //m_pGeomDB->SetMaterial( green, GREEN) ; // + int green = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrExpan->Clone()) ; // + m_pGeomDB->SetMaterial( green, GREEN) ; // if ( pSfrExpan->IsValid()) { if ( AreOppositeVectorApprox( pSfrExpan->GetNormVersor(), vtExtr)) pSfrExpan->Invert() ; @@ -8974,20 +8977,20 @@ Pocketing::AdjustPathOutsideRawForOpenEdges( const ICurveComposite* pCompo, cons return false ; } - //int brown = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; // - //m_pGeomDB->SetMaterial( brown, BROWN) ; // + int brown = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrInc->Clone()) ; // + m_pGeomDB->SetMaterial( brown, BROWN) ; // // RECUPERO DELLA CURVA DI BORDO ESTERNA DA AGGIUNGERE ALLA SVUOTATURA PtrOwner pCrvNewBorder( GetCurveComposite( pSfrInc->GetLoop( 0, 0))) ; if ( IsNull( pCrvNewBorder)) return false ; - double dUSTART ; pCrvNewBorder->GetParamAtPoint( ptSTART, dUSTART) ; + double dUSTART ; pCrvNewBorder->GetParamAtPoint( ptSTART, dUSTART, 1500 * EPS_SMALL) ; pCrvNewBorder->ChangeStartPoint( dUSTART) ; - double dUEND ; pCrvNewBorder->GetParamAtPoint( ptEND, dUEND) ; + double dUEND ; pCrvNewBorder->GetParamAtPoint( ptEND, dUEND, 1500 * EPS_SMALL) ; pCrvNewBorder->TrimEndAtParam( dUEND) ; - //int bb = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvNewBorder->Clone()) ; // - //m_pGeomDB->SetMaterial( bb, BLUE) ; // + int bb = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvNewBorder->Clone()) ; // + m_pGeomDB->SetMaterial( bb, BLUE) ; // pNewCrv->Clear() ; pNewCrv->AddCurve( Release( pCrvNewBorder)) ; for ( int u = 0 ; u < pNewCrv->GetCurveCount() ; ++ u) @@ -9274,6 +9277,10 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO if ( IsNull( pSrfFinal) || IsNull( pSrf_noOpenEdge)) return false ; + + int l = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf->Clone()) ; + m_pGeomDB->SetMaterial( l, LIME) ; + // per ogni Chunck della superificie ottenuta... for ( int c = 0 ; c < pSrf->GetChunkCount() ; ++ c) { @@ -9385,6 +9392,19 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ICRVCOMPOPO pSrf->Clear() ; pSrf->CopyFrom( pSrfFinal) ; + + for ( int c = 0 ; c < pSrf->GetChunkCount() ; ++ c) { + for ( int l = 0 ; l < pSrf->GetLoopCount( c) ; ++ l) { + PtrOwner pCrvCompo( GetCurveComposite( pSrf->GetLoop( c, l))) ; + for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) + { + int nProp ; pCrvCompo->GetCurveTempProp( u, nProp, 0) ; + int OOOO = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvCompo->GetCurve( u)->Clone()) ; + m_pGeomDB->SetMaterial( OOOO, nProp == 0 ? BLUE : RED) ; + } + } + } + return pSrf->IsValid() && pSrf->GetChunkCount() != 0 ; } @@ -9694,10 +9714,10 @@ Pocketing::CheckBoundingPointForIslands( ICurveComposite* pCrvCurr, int nInd, co //---------------------------------------------------------------------------- bool -Pocketing::GetStmRawPart( int nId, ISurfTriMesh* pSrfTMRaw, Frame3d frPocket) +Pocketing::GetStmRawPart( int nId, ISurfTriMesh* pSrfTMRaw, Frame3d frPocket) { // controllo se ho i flag abilitati - if ( !m_bIntersRaw && !m_bProjectRaw) + if ( ! m_bIntersRaw && ! m_bProjectRaw) return true ; // controllo MachManager e database geometrico @@ -10115,7 +10135,7 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, return false ; frLoc.Set( ptOri, vtZ) ; - // porto le superifici e isole con lati aperte nel nuovo frame + // porto le superifici nel nuovo frame pSrf->ToLoc( frLoc) ; pSrfOnPlPlus->ToLoc( frLoc) ; @@ -10143,6 +10163,14 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, if ( IsNull( pCrvExtProj) || ! pCrvExtProj->IsValid() || pCrvExtProj->GetCurveCount() == 0) return false ; + // derivando da una trimesh, semplifico le curve ( specialmente per circonferenze) + pCrvExtProj->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ; + pCrvExtSfr->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, true, true) ; + //int b = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExtProj->Clone()) ; + //m_pGeomDB->SetMaterial( b, BLACK) ; + //int l = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExtSfr->Clone()) ; + //m_pGeomDB->SetMaterial( l, LIME) ; + // parametri Vector3d vtS ; Vector3d vtE ; Point3d ptS ; Point3d ptE ; @@ -10195,6 +10223,10 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, //int R = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvExtSfr->Clone()) ; //m_pGeomDB->SetMaterial( R, RED) ; + // paramtri dU iniziali e finali del tratto di curva compreso tra le due rette + double dUS = EPS_SMALL ; + double dUE = EPS_SMALL ; + // scorro tutte le curve del contorno, cercando di raccordare linearmente i tratti aperti // con il bordo della proiezione ( in modo da estendere la superficie da svuotare bool bIsLastOpen = false ; @@ -10205,7 +10237,7 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, return false ; // controllo se fa overlap con il bordo della proiezione e/o con il bordo di un isola aperta int nStat1 = 0 ; - if ( ! CheckSimpleOverlap( pCrv, pCrvExtProj, nStat1)) + if ( ! CheckSimpleOverlap( pCrv, pCrvExtProj, nStat1, 5 * EPS_SMALL)) return false ; // se lato aperto e non sulla curva esterna di proiezione... if ( pCrv->GetTempProp() == 1 && nStat1 == 0) { @@ -10218,6 +10250,9 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, //int CC = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvLS->Clone()) ; //m_pGeomDB->SetMaterial( CC, AQUA) ; + // imposto il parametro inziale sulla curva + pCrvExtSfr->GetParamAtPoint( ptS, dUS) ; + // la spezzo alla prima intersezione con il grezzo CRVCVECTOR ccClass ; if ( pSrfOnPlPlus->GetCurveClassification( *pCrvLS, EPS_SMALL, ccClass) && @@ -10254,11 +10289,33 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, pCrv->GetStartDir( vtE) ; vtE = -vtE ; pCrv->GetStartPoint( ptE) ; - // setto la retta finale di raccordo + // setto la retta finale di raccordo pCrvLE->Set( ptE, ptE + vtE * 10000) ; //int BB = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvLE->Clone()) ; //m_pGeomDB->SetMaterial( BB, BLUE) ; + // imposto il parametro finale sulla curva + pCrvExtSfr->GetParamAtPoint( ptE, dUE) ; + + // controllo se il tratto di curva esterno alla superificie da svuotare + PtrOwner pCrvToCheck( GetCurveComposite( pCrvExtSfr->CopyParamRange( dUS, dUE))) ; + if ( ! IsNull( pCrvToCheck) && pCrvToCheck->IsValid()) { + CRVCVECTOR ccClass_c ; + if ( pSrf->GetCurveClassification( *pCrvToCheck, EPS_SMALL, ccClass_c)) { + bool bIsPartOut = false ; + for ( int _c = 0 ; _c < ( int)ccClass_c.size() && ! bIsPartOut ; ++ _c) { + if ( ccClass_c[_c].nClass == CRVC_OUT) + bIsPartOut = true ; + } + // se la curva trovata non è esterna alla superificie ( caso in cui il grezzo sia interno alla + // curva di svuotatura, allora non allargo la sua proiezione al suo box) + if ( ! bIsPartOut) { + nCont = 0 ; + continue ; + } + } + } + // la spezzo alla prima intersezione con il grezzo CRVCVECTOR ccClass ; if ( pSrfOnPlPlus->GetCurveClassification( *pCrvLE, EPS_SMALL, ccClass) && @@ -10318,6 +10375,8 @@ Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, pSrf->Translate( -vtTrasl) ; + //int r = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf->Clone()) ; + //m_pGeomDB->SetMaterial( r, RED) ; return true ; } @@ -11682,7 +11741,7 @@ Pocketing::AssignDefaultFeed( ICurveComposite* pCrv) { bool Pocketing::DrawColoredCrvForFeedTest( ICurve* pCurve, double dFeed) { - //return true ; + return true ; if ( abs( dFeed - GetMinFeed()) < EPS_SMALL) { int rosso = m_pGeomDB->AddGeoObj(GDB_ID_NULL, GDB_ID_ROOT, pCurve->Clone()) ; m_pGeomDB->SetMaterial( rosso, RED) ;