diff --git a/Pocketing.cpp b/Pocketing.cpp index 63e9024..98f3672 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -2926,7 +2926,7 @@ Pocketing::CutVolumeByPlane( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pS //---------------------------------------------------------------------------- bool Pocketing::CheckSideAngleForVolume( const ISurfTriMesh* pStmVol_Above, const ISurfTriMesh* pStm_Part, - ISurfFlatRegion* pSfr_Projection, double& dExtraLenInOut) + ISurfFlatRegion* pSfr_Projection, double& dExtraLenInOut, bool& bPerpFaces) { // NB. Questa funzione è chimata solo in caso ci sia uno Step e il tool non sia cilindrico @@ -3035,6 +3035,7 @@ Pocketing::CheckSideAngleForVolume( const ISurfTriMesh* pStmVol_Above, const ISu } else dExtraLenInOut = max( dExtraLenInOut, BBox.GetDimZ() * tan( m_TParams.m_dSideAng * DEGTORAD)) ; + bProj = true ; } // se la faccia è da proiettare @@ -3085,6 +3086,14 @@ Pocketing::CheckSideAngleForVolume( const ISurfTriMesh* pStmVol_Above, const ISu if ( AreOppositeVectorApprox( Z_AX, pSfr_Projection->GetNormVersor())) pSfr_Projection->Invert() ; + // in questo caso + if ( m_TParams.m_dSideAng > 0 && dExtraLenInOut > 0) { + if ( ! pSfr_Projection->IsValid()) // ho tutte le facce perpendicolari... + bPerpFaces = true ; + else if ( ! pSfr_Projection->Offset( dExtraLenInOut, ICurve::OFF_FILLET)) + return false ; + } + return true ; } @@ -3217,8 +3226,17 @@ Pocketing::ProjectVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_ return false ; if ( m_TParams.m_dSideAng != 0 && bOneStep) { - if ( ! CheckSideAngleForVolume( pStmAbove_Near, pStm_Part, pSfrProjection, dExtraLenInOut)) + bool bPerpFaces = false ; + if ( ! CheckSideAngleForVolume( pStmAbove_Near, pStm_Part, pSfrProjection, dExtraLenInOut, bPerpFaces)) return false ; + if ( bPerpFaces && dExtraLenInOut > 0) { + pSfrProjection->CopyFrom( pSfr) ; + PtrOwner pSfrNegOffs( pSfrProjection->CreateOffsetSurf( - dExtraLenInOut, ICurve::OFF_CHAMFER)) ; + if ( IsNull( pSfrNegOffs) || + ! pSfrNegOffs->IsValid() || + ! pSfrProjection->Subtract( *pSfrNegOffs)) + return false ; + } } else { INTVECTOR vAllTria_A ; @@ -3270,9 +3288,13 @@ Pocketing::ProjectVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_ return false ; // 2) ricavo la superficie da svuotare come sottrazione tra la ( *pSfr) e la ( *pSfrProjection) - if ( pSfr->IsValid() && pSfrProjection->IsValid()) - if ( ! pSfr->Subtract( *pSfrProjection)) + if ( pSfr->IsValid() && pSfrProjection->IsValid()) { + m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfr->Clone()) ; + m_pGeomDB->AddGeoObj( GDB_ID_NULL, GDB_ID_ROOT, pSfrProjection->Clone()) ; + if ( ! pSfr->Subtract( *pSfrProjection)) { return false ; + } + } return true ; } @@ -5934,7 +5956,7 @@ Pocketing::AddOneWay( ISURFFRPOVECTOR& vSfr, const std::vectorGetTempProp( 0) ; double dExtension = 0. ; @@ -5958,10 +5980,26 @@ Pocketing::AdjustTrapezoidSpiralLeadInLeadOutForSideAngle( ICurveComposite* pMCr else if ( nTmpProp & 1 || nTmpProp & 4 || nTmpProp == 10) { // almeno 1 base aperta o entrambi i lati obliqui aperti if ( nOutsideRaw == 2) return true ; - if ( nOutsideRaw == 0) - pMCrv->ExtendStartByLen( dExtension) ; - - pMCrv->ExtendEndByLen( dExtension) ; + if ( nOutsideRaw == 0) { + if ( pMCrv->GetCurve( 0)->GetTempProp( 0) != 1 && nTmpProp < 8) { + Vector3d vtS ; pMCrv->GetStartDir( vtS) ; + Point3d ptS ; pMCrv->GetStartPoint( ptS) ; + vtS.Rotate( vtN, ( nTmpProp & 1) && m_Params.m_bInvert ? - ANG_RIGHT : ANG_RIGHT) ; + vtS *= dExtension ; + pMCrv->AddLine( ptS + vtS, false) ; + } + else + pMCrv->ExtendStartByLen( dExtension) ; + } + if ( pMCrv->GetLastCurve()->GetTempProp( 0) != 1 && ( nTmpProp & 2) == 0) { + Vector3d vtE ; pMCrv->GetEndDir( vtE) ; + Point3d ptE ; pMCrv->GetEndPoint( ptE) ; + vtE.Rotate( vtN, ( nTmpProp & 1) && m_Params.m_bInvert ? - ANG_RIGHT : ANG_RIGHT) ; + vtE *= dExtension ; + pMCrv->AddLine( ptE + vtE, true) ; + } + else + pMCrv->ExtendEndByLen( dExtension) ; return true ; } else if ( nTmpProp == 2 || nTmpProp == 8) { // 1 lato obliquo aperto e tutti gli altri chiusi @@ -5977,9 +6015,7 @@ Pocketing::AdjustTrapezoidSpiralLeadInLeadOutForSideAngle( ICurveComposite* pMCr return true ; } } - else { - - } + return true ; } @@ -6157,7 +6193,7 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector& } } // se non ho un'entrata da fuori e il tool non è cilindrico... - if ( ! bOutStart && ! bOptimizedTrap && m_TParams.m_dSideAng != 0 && dExtraLenInOut > EPS_SMALL) { + if ( ! ( bOutStart || m_bOpenOutRaw) && ! bOptimizedTrap && m_TParams.m_dSideAng < 0 && dExtraLenInOut > EPS_SMALL) { Vector3d vtDir ; Point3d ptS ; Vector3d vtIn ; @@ -6166,7 +6202,7 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector& if ( pMCrv->GetCurveCount() > 0) { pMCrv->GetStartDir( vtDir) ; pMCrv->GetStartPoint( ptS) ; - vtIn = vtDir ; vtIn.Rotate( vtTool, ANG_RIGHT) ; + vtIn = vtDir ; vtIn.Rotate( vtTool, m_Params.m_bInvert ? -ANG_RIGHT : ANG_RIGHT) ; if ( GetLeadInType() == POCKET_LI_HELIX) dLenCheck = min( 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam), m_dMaxHelixRad) ; @@ -6202,7 +6238,7 @@ Pocketing::AddSpiralIn( ISURFFRPOVECTOR& vSfr, const vector& bOutStart = ( nOutsideRaw > 0) ; // controllo geometria del tool if ( m_TParams.m_dSideAng != 0) { - if ( ! AdjustTrapezoidSpiralLeadInLeadOutForSideAngle( pMCrv, dExtraLenInOut, nOutsideRaw)) + if ( ! AdjustTrapezoidSpiralLeadInLeadOutForSideAngle( pMCrv, dExtraLenInOut, nOutsideRaw, vtTool)) return false ; } // aggiorno la curva per eventuali inversioni @@ -12302,7 +12338,6 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTr pMCrv->Invert() ; } - } } } @@ -12312,8 +12347,6 @@ Pocketing::CalcTrapezoidSpiral( ICurveComposite* pCrvPocket, const Frame3d& frTr pMCrv->ToGlob( frTrap) ; - - if ( ! m_Params.m_bInvert) { pMCrv->Invert() ; // inverto le proprietà in modo che nProp3 sia sempre legata al punto iniziale e nProp1 a quello finale diff --git a/Pocketing.h b/Pocketing.h index 24ea268..2aff5c2 100644 --- a/Pocketing.h +++ b/Pocketing.h @@ -98,7 +98,7 @@ class Pocketing : public Machining double& dElev) ; bool AdjustTrapezoidSpiralLeadInLeadOutForSideAngle( ICurveComposite* pMCrv, const double dExtraLenInOut, - const int nOutsideRaw) ; + const int nOutsideRaw, const Vector3d& vtN) ; bool GetRaw( ISurfTriMesh* pStmRaw) ; bool SliceVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_Part, const ISurfTriMesh* pSt_Raw, ISURFFRPOVECTOR& vSrfSliced, ISURFFRPOVECTOR& vSfrLimit, std::vector& vCrvOEWithFlags, @@ -110,7 +110,7 @@ class Pocketing : public Machining bool CutVolumeByPlane( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_Part, const Vector3d& vtTrasl, const bool bIsExtraStep, ISurfFlatRegion* pSfrResult) ; bool CheckSideAngleForVolume( const ISurfTriMesh* pStmVol_Sliced, const ISurfTriMesh* pStm_Part, - ISurfFlatRegion* pSfr_Projection, double& dExtraLenInOut) ; + ISurfFlatRegion* pSfr_Projection, double& dExtraLenInOut, bool& bPerpFaces) ; bool ProjectVolume( const ISurfTriMesh* pStmVol, const ISurfTriMesh* pStm_Part, const Vector3d& vtTrasl, const Vector3d& vtTraslPrec, const ISurfFlatRegion* pSfrOpenProjPrec, ISurfFlatRegion* pSfr, const bool bOneStep, double& dExtraLenInOut) ;