diff --git a/Pocketing.cpp b/Pocketing.cpp index 01414d7..a3d6495 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -3830,7 +3830,7 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c for ( int nIs = 0 ; nIs < int( vSrfFlat.size()) ; ++ nIs) { - // copio la superificie ideale + // copio la superificie ideale PtrOwner pSrfIdeal( CloneSurfFlatRegion( vSrfFlat[nIs])) ; if ( IsNull( pSrfIdeal)) return false ; @@ -3838,39 +3838,13 @@ Pocketing::AddOneWay( const ISurfFlatRegion* pSrfPock, const Vector3d& vtTool, c ISURFFRPOVECTOR vSrfSliced( nStep) ; vector vCrvOEWithFlags( nStep) ; BOOLVECTOR vbChangedPrec( nStep, false) ; - for ( int j = 1 ; j <= nStep ; ++ j) { - // controllo l'intersezione/proiezione tra la superificie e il grezzo - PtrOwner pCrvOPF( CreateCurveComposite()) ; - Vector3d vtTrasl = -vtTool * ( dDepth - dElev + j * dStep) ; - ICRVCOMPOPOVECTOR vCrvOEF ; - bool bChanged = false ; - PtrOwner pSrfToAdapt( CloneSurfFlatRegion( pSrfIdeal)) ; - if ( AdaptSfrWithRaw( pSrfToAdapt, vtTrasl, nullptr, 100.0, vCrvOEF, bChanged, j, dStep)) { - vSrfSliced[j-1].Set( pSrfToAdapt->Clone()) ; - if ( ! IsNull( vSrfSliced[j-1])) { - for ( int h = 0 ; h < ( int)vCrvOEF.size() ; ++h) - vCrvOEWithFlags[j-1].emplace_back( Release( vCrvOEF[h])) ; - - // controllo se la superificie attuale e precedente sono diverse tra loro - if ( j > 1) { - double dAreaPrec = 0 ; double dAreaAct = 0 ; - if ( ! IsNull( vSrfSliced[j-2])) { - vSrfSliced[j-2]->GetArea( dAreaPrec) ; - vSrfSliced[j-1]->GetArea( dAreaAct) ; - if ( abs( dAreaAct - dAreaPrec) > 500 * EPS_SMALL) - vbChangedPrec[j-1] = true ; - } - else - vbChangedPrec[j-1] = true ; - } - } - } - else { - return false ; - } - } + VCT3DVECTOR vVtTrasl( nStep, V_NULL) ; + if ( ! GetParamsAtEachStep( vSrfSliced, vCrvOEWithFlags, vbChangedPrec, vVtTrasl, pSrfIdeal, + nStep, vtTool, dElev, dDepth, dStep)) + return false ; + + Point3d ptP1 ; // per LeadIn - Point3d ptP1 ; for ( int j = 1 ; j <= nStep ; ++ j) { // se superificie non valida, salto allo step successivo @@ -9530,7 +9504,7 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vectorClone()) ; // la superificie potrebbe non essere valida ( ad esempio se già svuotata tutta con un Tool in precedenza...) if ( ! IsNull( vSrfSliced[j-1])) { @@ -9576,6 +9549,7 @@ Pocketing::GetParamsAtEachStep( ISURFFRPOVECTOR& vSrfSliced, vectorClone()) ; // 3) scalo la superficie rispetto al sistema di riferimento ( mettendo a 0 la componente vtN) - if ( ! pStmRef->Scale( frPlane, 1., 1., 0.)) + pStmRef->ToLoc( frPlane) ; + //int G = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRef->Clone()) ; + //m_pGeomDB->SetMaterial( G, GREEN) ; + if ( ! pStmRef->Scale( GLOB_FRM, 1., 1., 0.)) return false ; - int G = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRef->Clone()) ; - m_pGeomDB->SetMaterial( G, GREEN) ; - + pStmRef->ToGlob( frPlane) ; //int p = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pStmRef->Clone()) ; //m_pGeomDB->SetMaterial( p, PURPLE) ; - // 4) controllo la validità della superficie ottenuta if ( IsNull( pStmRef) || ! pStmRef->IsValid() || pStmRef->GetTriangleCount() == 0) return true ; // la proeizione sparisce @@ -10189,7 +10163,7 @@ Pocketing::CloseCurvesOnProjectionSurface( ICurveComposite* pCrvCompo, const ISu //---------------------------------------------------------------------------- bool -Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMesh* pStmRaw, const double& dRawSecLen, +Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMesh* pStmRaw, ICRVCOMPOPOVECTOR& vCrvOEFlags, bool& bChanged, int nStep, double dStep, double dAreaToll, ISurfTriMesh* pStmShape) { @@ -10210,9 +10184,10 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMes PtrOwner pSrfOrig( CloneSurfFlatRegion( pSrf)) ; if ( IsNull( pSrfOrig) || ! pSrfOrig->IsValid()) return false ; + // 1) INTERSEZIONE CON GREZZO - if ( m_bIntersRaw) { // proporzionale all'area ? 95 %? - if ( ! IntersSurfWithRaw( pSrf, pStmRaw, vtTrasl, bChanged, 500 * EPS_SMALL, true, m_dDiam_Prec < EPS_SMALL)) + if ( m_bIntersRaw) { + if ( ! IntersSurfWithRaw( pSrf, pStmRaw, vtTrasl, bChanged, dAreaToll, true, m_dDiam_Prec < EPS_SMALL)) return false ; if ( pSrf == nullptr || pSrf->GetChunkCount() == 0 || ! pSrf->IsValid()) return true ; @@ -10221,7 +10196,7 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMes // 2) PROIEZIONE CON GREZZO if ( m_bProjectRaw) { // recupero la Trimesh di partenza - if ( ! ProjectRaw( pSrf, vtTrasl, pStmRaw, nProp0, dRawSecLen, pSrfOrig, nStep, dStep, 500 * EPS_SMALL)) + if ( ! ProjectRaw( pSrf, vtTrasl, pStmRaw, nProp0, pSrfOrig, nStep, dStep)) return false ; if ( pSrf->GetChunkCount() == 0 || ! pSrf->IsValid()) return true ; @@ -10236,23 +10211,6 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMes } } - /*PtrOwner pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ; - pSrf_toDraw->Translate( vtTrasl) ; - int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ; - m_pGeomDB->SetMaterial( a, Color( 0.23, 0.47, 0.98, 0.5)) ; - for ( int c = 0 ; c < pSrf_toDraw->GetChunkCount() ; ++ c) { - for ( int l = 0 ; l < pSrf_toDraw->GetLoopCount( c) ; ++ l) { - const ICurveComposite* pCrvCompo( GetCurveComposite( pSrf_toDraw->GetLoop( c, l))) ; - for ( int u = 0 ; u < pCrvCompo->GetCurveCount() ; ++ u) { - int nProp0 ; pCrvCompo->GetCurveTempProp( u, nProp0, 0) ; - int nProp1 ; pCrvCompo->GetCurveTempProp( u, nProp1, 1) ; - int aaa = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pCrvCompo->GetCurve( u)->Clone()) ; - m_pGeomDB->SetMaterial( aaa, nProp0 == 0 ? BLUE : RED) ;; - } - } - }*/ - - // salvo una copia della superficie attuale PtrOwner pSrf_noOpenEdge( CloneSurfFlatRegion( pSrf)) ; if ( IsNull( pSrf_noOpenEdge)) @@ -10262,11 +10220,6 @@ Pocketing::AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMes if ( ! ModifySurfByOpenEdge( pSrf, vCrvOEFlags, vtTrasl, pStmRaw)) return false ; - /*PtrOwner pSrf_toDraw( CloneSurfFlatRegion( pSrf)) ; - pSrf_toDraw->Translate( vtTrasl) ; - int a = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSrf_toDraw->Clone()) ; - m_pGeomDB->SetMaterial( a, Color( 0.23, 0.47, 0.98, 0.5)) ;*/ - // 4) SE SUPERIFICIE PRECEDENTEMENTE GIA' LAVORATA... if ( m_dDiam_Prec > 0) return GetNewSrfByAnotherPocketing( pSrf, pSrf_noOpenEdge, vtTrasl) ; @@ -10340,15 +10293,15 @@ Pocketing::SubtractFinalShape( ISurfFlatRegion* pSfrCurr, const Vector3d& vtTras if ( IsNull( pSfrCurr_c) || ! pSfrCurr_c->IsValid()) return false ; - //int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrCurr_c->Clone()) ; - //m_pGeomDB->SetMaterial( W, WHITE) ; - //int F = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrShape_c->Clone()) ; - //m_pGeomDB->SetMaterial( F, BLACK) ; + int W = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrCurr_c->Clone()) ; + m_pGeomDB->SetMaterial( W, WHITE) ; + int F = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrShape_c->Clone()) ; + m_pGeomDB->SetMaterial( F, BLACK) ; if ( ! pSfrCurr_c->Subtract( *pSfrShape_c)) return false ; - //int G = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrShape_c->Clone()) ; - //m_pGeomDB->SetMaterial( G, GREEN) ; + int G = m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrCurr_c->Clone()) ; + m_pGeomDB->SetMaterial( G, GRAY) ; // ricalcolo le TmpProp SurfFlatRegionByContours sfrBC ; @@ -10386,7 +10339,6 @@ Pocketing::SubtractFinalShape( ISurfFlatRegion* pSfrCurr, const Vector3d& vtTras if ( IsNull( pSfrFINAL) || ! pSfrFINAL->IsValid()) return false ; pSfrCurr->CopyFrom( pSfrFINAL) ; - //pSfrCurr->Translate( -vtTrasl) ; return true ; } @@ -12130,7 +12082,7 @@ Pocketing::CutProjectionToFitShape( ISurfFlatRegion* pSrfProjected, const ISurfF //---------------------------------------------------------------------------- bool Pocketing::ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrasl, - const ISurfTriMesh* pStmRaw, int nId, const double& dRawSecLen, const ISurfFlatRegion* pSrfOrig, + const ISurfTriMesh* pStmRaw, int nId, const ISurfFlatRegion* pSrfOrig, int nStep, double dStep, double dAreaToll) { // controllo se funzione necessaria diff --git a/Pocketing.h b/Pocketing.h index ee5ac3f..3fe3381 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -108,7 +108,7 @@ class Pocketing : public Machining bool CalcExtraSteps( const ISurfFlatRegion* pSfrAct, const ISurfTriMesh* pStmORIG, const Vector3d vtTool, const double& dElev, const double& dDepth, const int& nStep, const double& dStep, VCT3DVECTOR& vtVtTrasl) ; - bool AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMesh* pStmRaw, const double& dRawSecLen, + bool AdaptSfrWithRaw( ISurfFlatRegion* pSrf, Vector3d vtTrasl, ISurfTriMesh* pStmRaw, ICRVCOMPOPOVECTOR& vCrvOEFlags, bool& bChanged, int nStep, double dStep, double dAreaToll = 500 * EPS_SMALL, ISurfTriMesh* pStmShape = nullptr) ; bool AdjustFakeOpenEdges( ICurveComposite* pCrvCompo, const ISurfFlatRegion* pSrfOrig, const ISurfTriMesh* pStmRaw, @@ -125,7 +125,7 @@ class Pocketing : public Machining bool& bIsChanged, double dAreaToll = 500 * EPS_SMALL, bool bInVsOut = true, bool bRemoveSmallRawParts = false, bool bComputeOpenEdge = true) ; bool ProjectRaw( ISurfFlatRegion* pSrf, const Vector3d& vtTrals, const ISurfTriMesh* pSrfProjRaw, int nId, - const double& dRawSecLen, const ISurfFlatRegion* pSrfOrig, int nStep, double dStep, + const ISurfFlatRegion* pSrfOrig, int nStep, double dStep, double dAreaToll = 500 * EPS_SMALL) ; bool SubtractFinalShape( ISurfFlatRegion* pSfrCurr, const Vector3d& vtTrasl, const ISurfTriMesh* pStmShape) ; bool AdjustAngleForProjectedFace( const ISurfFlatRegion* pSrfFaceT, ICurveComposite* pCrvEdgeBorder, double dAngle) ;