diff --git a/Chiseling.cpp b/Chiseling.cpp index fd457fd..97967fa 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -895,11 +895,11 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) // ammessi : curve, testi, facce di trimesh o regioni const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ; if ( pGObj == nullptr) - return nullptr ; + return false ; // ne recupero il riferimento globale Frame3d frGlob ; if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob)) - return nullptr ; + return false ; // se curva if ( ( pGObj->GetType() & GEO_CURVE) != 0) { PtrOwner pCurve ; @@ -935,7 +935,7 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) } } if ( IsNull( pCurve)) - return nullptr ; + return false ; // la porto in globale pCurve->ToGlob( frGlob) ; // la restituisco @@ -962,23 +962,23 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) // recupero la trimesh const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ; if ( pSurf == nullptr) - return nullptr ; + return false ; // recupero l'indice della faccia int nFacet = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ; // recupero i contorni della faccia POLYLINEVECTOR vPL ; pSurf->GetFacetLoops( nFacet, vPL) ; if ( vPL.empty()) - return nullptr ; + return false ; // recupero la normale esterna della faccia Vector3d vtN ; if ( ! pSurf->GetFacetNormal( nFacet, vtN)) - return nullptr ; + return false ; // creo la curva a partire da quello esterno PtrOwner pCrvCompo( CreateCurveComposite()) ; pCrvCompo->FromPolyLine( vPL[0]) ; if ( ! pCrvCompo->IsValid()) - return nullptr ; + return false ; // assegno l'estrusione dalla normale alla faccia pCrvCompo->SetExtrusion( vtN) ; // unisco le eventuali parti allineate @@ -1031,7 +1031,7 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) } // altrimenti errore else - return nullptr ; + return false ; } //---------------------------------------------------------------------------- @@ -1313,8 +1313,8 @@ Chiseling::ProcessPath( int nPathId, int nPvId, int nClId) const double SIN_ANG_LIM = sin( ( ANG_RIGHT - 100 * EPS_ANG_SMALL) * DEGTORAD) ; if ( dPrevLen > 0.5 * m_TParams.m_dDiam - EPS_SMALL && dCurrLen > 0.5 * m_TParams.m_dDiam - EPS_SMALL && - ( dProVett > SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_LEFT) || - ( dProVett < - SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_RIGHT)) { + (( dProVett > SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_LEFT) || + ( dProVett < - SIN_ANG_LIM && m_Params.m_nWorkSide == CHISEL_WS_RIGHT))) { Vector3d vtMid = Media( - vtPrevDir, vtCurrDir, 0.5) ; Point3d ptIni ; pPrevCrv->GetEndPoint( ptIni) ; ptIni += vtMid * m_TParams.m_dDiam + vtTool * ( dElev - dDepth) ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 8f421ba..0f511b6 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/EgtMachKernel.vcxproj b/EgtMachKernel.vcxproj index 91caa32..a624e7f 100644 --- a/EgtMachKernel.vcxproj +++ b/EgtMachKernel.vcxproj @@ -33,7 +33,7 @@ DynamicLibrary true - v142 + ClangCL Unicode @@ -46,7 +46,7 @@ DynamicLibrary false - v142 + ClangCL true Unicode diff --git a/Generator.cpp b/Generator.cpp index bd631c0..19b9c56 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -51,7 +51,7 @@ Generator::Run( const string& sCncFile, const string& sInfo) int nOptExpDays ; int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, nOpt1, nOpt2, nOptExpDays) ; - if ( ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) { + if ( nRet == KEY_OK && ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) { // emetto info di log { string sOut = "Generator Run : " + sCncFile ; diff --git a/MachMgr.h b/MachMgr.h index 5776e73..90d2ce2 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -204,7 +204,7 @@ class MachMgr : public IMachMgr bool EraseCurrSetup( void) override ; // Machinings DataBase bool MdbGetMachiningNewName( std::string& sName) const override ; - bool MdbAddMachining( const std::string& sName, int nType) ; + bool MdbAddMachining( const std::string& sName, int nType) override ; bool MdbCopyMachining( const std::string& sSource, const std::string& sName) override ; bool MdbRemoveMachining( const std::string& sName) override ; bool MdbGetFirstMachining( int nType, std::string& sName) const override ; @@ -321,7 +321,7 @@ class MachMgr : public IMachMgr bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const override ; bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, - int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ; + int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const override ; bool GetCalcPositions( const Point3d& ptP, double dAngA, double dAngB, int& nStat, double& dX, double& dY, double& dZ) const override ; bool GetCalcPositions( const Point3d& ptP, const DBLVECTOR& vAng, diff --git a/MachMgrDBTools.cpp b/MachMgrDBTools.cpp index 23ff9c1..3aa5db3 100644 --- a/MachMgrDBTools.cpp +++ b/MachMgrDBTools.cpp @@ -445,7 +445,7 @@ MachMgr::TdbReload( void) // recupero il gestore di utensili della macchina corrente ToolsMgr* pTsMgr = GetCurrToolsMgr() ; if ( pTsMgr == nullptr) - return nullptr ; + return false ; // ricarico il db utensili return pTsMgr->Reload() ; } @@ -782,7 +782,7 @@ MachMgr::GetToolHolderPath( const string& sHeadName, int nExit, int nType) const // Verifico esista macchina corrente Machine* pMch = GetCurrMachine() ; if ( pMch == nullptr) - return false ; + return "" ; // Recupero il direttorio dei portautensili string sToolHolderDir ; if ( ! TdbGetToolHolderDir( sToolHolderDir)) diff --git a/MachMgrRawParts.cpp b/MachMgrRawParts.cpp index 98a5868..6a8cc7c 100644 --- a/MachMgrRawParts.cpp +++ b/MachMgrRawParts.cpp @@ -1031,8 +1031,9 @@ MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId) int nSide ; double dDist ; DistPointCurve distPC( ptTest, *pCurve) ; - if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL || - (distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) + if ( distPC.GetDist( dDist) && + ( dDist < 100 * EPS_SMALL || + ( distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT))) break ; } } diff --git a/MachMgrSetup.cpp b/MachMgrSetup.cpp index bc430cf..70a4110 100644 --- a/MachMgrSetup.cpp +++ b/MachMgrSetup.cpp @@ -107,7 +107,7 @@ MachMgr::VerifyCurrSetup( STRVECTOR& vsErrors) } // altrimenti, verifico se uscita coincide con quella indicata nel DB utensili else { - int nTdbExit ; + int nTdbExit = 0 ; if ( ! TdbSetCurrTool( sTool) || ! TdbGetCurrToolParam( TPA_EXIT, nTdbExit) || nExit != nTdbExit) { diff --git a/MachineLua.cpp b/MachineLua.cpp index 2c902ac..d9dee90 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -589,7 +589,7 @@ Machine::LuaEmtStdHead( lua_State* L) double dRot1W = 1 ; LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ; // lettura eventuale campo 'Rot2Stroke' dalla tabella - STROKE Rot2Stroke = { - INFINITO, INFINITO} ; + STROKE Rot2Stroke = { -INFINITO, INFINITO} ; LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ; // lettura eventuale campo 'SolCh' dalla tabella int nSolCh = MCH_SCC_NONE ; @@ -667,7 +667,7 @@ Machine::LuaEmtMultiHead( lua_State* L) double dRot1W = 1 ; LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ; // lettura eventuale campo 'Rot2Stroke' dalla tabella - STROKE Rot2Stroke = { - INFINITO, INFINITO} ; + STROKE Rot2Stroke = { -INFINITO, INFINITO} ; LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ; // lettura eventuale campo 'SolCh' dalla tabella int nSolCh = MCH_SCC_NONE ; @@ -734,7 +734,7 @@ Machine::LuaEmtSpecialHead( lua_State* L) double dRot1W = 1 ; LuaGetTabFieldParam( L, 1, FLD_ROT1W, dRot1W) ; // lettura eventuale campo 'Rot2Stroke' dalla tabella - STROKE Rot2Stroke = { - INFINITO, INFINITO} ; + STROKE Rot2Stroke = { -INFINITO, INFINITO} ; LuaGetTabFieldParam( L, 1, FLD_ROT2STROKE, Rot2Stroke.v) ; // lettura eventuale campo 'SolCh' dalla tabella int nSolCh = MCH_SCC_NONE ; diff --git a/MachiningCreate.h b/MachiningCreate.h index a43fceb..02c1cbf 100644 --- a/MachiningCreate.h +++ b/MachiningCreate.h @@ -24,11 +24,11 @@ CreateMachining( int nMchType) { // verifico sia richiesto un oggetto utente di tipo lavorazione if ( ! IsValidMachiningType( nMchType)) - return false ; + return nullptr ; // creo l'oggetto IUserObj* pUsrObj = USEROBJ_CREATE( GetOperationClass( nMchType)) ; if ( pUsrObj == nullptr) - return false ; + return nullptr ; // lo converto a lavorazione Machining* pMch = GetMachining( pUsrObj) ; if ( pMch == nullptr) diff --git a/Milling.cpp b/Milling.cpp index 9ab179d..8eca4a1 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -3399,14 +3399,16 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr, bool bOutStart, bool bAboveStart) { SetFlag( 1) ; - // se con aggregato da sotto + // se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi) + bool bBottomStart = false ; if ( m_bAggrBottom) { - // aggiuntivo in Z - double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ; - // distanza dal bordo del pezzo + // distanza dal bordo del pezzo (se negativa il punto è fuori dal grezzo) double dDistBottom ; if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom)) dDistBottom = 0 ; + bBottomStart = ( dDistBottom < - 10 * EPS_SMALL) ; + // aggiuntivo in Z + double dAggZ = ( bBottomStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ; // pre-approccio Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ; Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ; @@ -3439,7 +3441,7 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, // se non sono già sopra il pezzo e sopra attacco c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; double dElevZ = vtAppr.z * dElev ; - if ( ! bAboveStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { + if ( ! bAboveStart && ! bBottomStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { // se distanza di sicurezza minore di distanza di inizio if ( dSafeDist < dAppr + 10 * EPS_SMALL) { // 1 -> punto sopra inizio @@ -3538,10 +3540,19 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, vtAppr.z = 0 ; vtAppr.Normalize() ; } + // se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi) + bool bBottomOutStart = false ; + double dDistBottom ; + if ( m_bAggrBottom) { + // distanza dal bordo del pezzo (se negativa il punto è fuori dal grezzo) + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom)) + dDistBottom = 0 ; + bBottomOutStart = ( dDistBottom < - 10 * EPS_SMALL) ; + } // se non sono già sopra il pezzo e sopra uscita c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; double dElevZ = vtAppr.z * dElev ; - if ( ! bAboveEnd && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { + if ( ! bAboveEnd && ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { if ( dSafeDist < dAppr + 10 * EPS_SMALL) { // 4 -> movimento di risalita sopra il punto finale SetFeed( GetEndFeed()) ; @@ -3589,11 +3600,7 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, // se con aggregato da sotto if ( m_bAggrBottom) { // aggiuntivo in Z - double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ; - // distanza dal bordo del pezzo - double dDistBottom ; - if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom)) - dDistBottom = 0 ; + double dAggZ = ( bBottomOutStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ; // post-retract Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ; Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ; diff --git a/Operation.cpp b/Operation.cpp index 3a73995..6909b38 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -407,38 +407,49 @@ Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3 { if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; - // recupero il grezzo in cui è incluso il punto + // recupero il grezzo più vicino al punto (entro 100 mm) + const double EXPAND_LEN = 100 ; BBox3d b3Pnt( ptP) ; - b3Pnt.Expand( 10, 10, 0) ; - int nRawId = m_pMchMgr->GetFirstRawPart() ; - while ( nRawId != GDB_ID_NULL) { + b3Pnt.Expand( EXPAND_LEN, EXPAND_LEN, 0) ; + double dMinDist = INFINITO ; + int nRawId = GDB_ID_NULL ; + int nCurrRawId = m_pMchMgr->GetFirstRawPart() ; + while ( nCurrRawId != GDB_ID_NULL) { // verifico che il grezzo compaia nella fase - if ( m_pMchMgr->VerifyRawPartPhase( nRawId, nPhase)) { + if ( m_pMchMgr->VerifyRawPartPhase( nCurrRawId, nPhase)) { // pre-filtro con il box BBox3d b3Raw ; - int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ; + int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nCurrRawId, MACH_RAW_SOLID) ; if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Pnt.OverlapsXY( b3Raw)) { // porto il punto nel riferimento del grezzo (a Z=0 perchè ivi è il contorno) Frame3d frRaw ; - m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ; + m_pGeomDB->GetGroupGlobFrame( nCurrRawId, frRaw) ; Point3d ptPL = ptP ; ptPL.ToLoc( frRaw) ; ptPL.z = 0 ; // verifica con il contorno - int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ; + int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nCurrRawId, MACH_RAW_OUTLINE) ; const ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ; if ( pCurve != nullptr) { int nSide ; double dDist ; DistPointCurve distPC( ptPL, *pCurve) ; - if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL || - (distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) - break ; + if ( distPC.GetDist( dDist)) { + if ( dDist < 100 * EPS_SMALL || + (distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT)) { + nRawId = nCurrRawId ; + break ; + } + else if ( dDist < dMinDist) { + dMinDist = dDist ; + nRawId = nCurrRawId ; + } + } } } } // passo al grezzo successivo - nRawId = m_pMchMgr->GetNextRawPart( nRawId) ; + nCurrRawId = m_pMchMgr->GetNextRawPart( nCurrRawId) ; } // se il punto non è interno ad alcun grezzo, distanza nulla if ( nRawId == GDB_ID_NULL) { @@ -457,14 +468,16 @@ Operation::GetDistanceFromRawSide( int nPhase, const Point3d& ptP, const Vector3 return false ; // interseco il raggio di test (portato nel riferimento del contorno) con il contorno del grezzo const double RAY_LEN = 10000 ; + const double EXTRA_LEN = EXPAND_LEN ; PtrOwner pRay( CreateCurveLine()) ; - if ( IsNull( pRay) || ! pRay->SetPVL( ptP, vtDir, RAY_LEN)) + if ( IsNull( pRay) || ! pRay->SetPVL( ptP - vtDir * EXTRA_LEN, vtDir, RAY_LEN)) return false ; pRay->ToLoc( frStm) ; IntersCurveCurve intCC( *pRay, *pOut) ; + int nInters = intCC.GetIntersCount() ; IntCrvCrvInfo aInfo ; - if ( intCC.GetIntCrvCrvInfo( 0, aInfo)) - dDist = aInfo.IciA[0].dU * RAY_LEN ; + if ( nInters > 0 && intCC.GetIntCrvCrvInfo( nInters - 1, aInfo)) + dDist = aInfo.IciA[0].dU * RAY_LEN - EXTRA_LEN ; else dDist = 0 ; return true ; @@ -2036,11 +2049,11 @@ Operation::AdjustOneStartMovement( int nClPathId, int nPrevClPathId, Operation* if ( nPrevClPathId == GDB_ID_NULL) { if ( pPrevOp == nullptr || ! pPrevOp->RemoveRise() || - ! pPrevOp->AddRise( vAxNew1, dSafeZ - vAxPrev[2]), GDB_ID_NULL, bZHomeDown) + ! pPrevOp->AddRise( vAxNew1, dSafeZ - vAxPrev[2], GDB_ID_NULL, bZHomeDown)) return false ; } else { - if ( ! AddRise( vAxNew1, dSafeZ - vAxPrev[2], nPrevClPathId), bZHomeDown) + if ( ! AddRise( vAxNew1, dSafeZ - vAxPrev[2], nPrevClPathId, bZHomeDown)) return false ; } // aggiungo posizione elevata prima dell'inizio del percorso corrente @@ -2471,7 +2484,7 @@ Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR for ( int i = 0 ; i <= nStep ; ++ i) { vAng[0] = dR1Start + i * dR1Step ; vAng[1] = dR2Start + i * dR2Step ; - vAng[2] = dR3Start + i * dR2Step ; + vAng[2] = dR3Start + i * dR3Step ; Point3d ptTip ; if ( ! m_pMchMgr->GetCalcTipFromPositions( dL1, dL2, dL3, vAng, true, true, ptTip)) return false ; diff --git a/Pocketing.cpp b/Pocketing.cpp index 9f2812d..7bfa04f 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -3440,14 +3440,16 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe double dElev, double dAppr, bool bOutStart) { SetFlag( 1) ; - // se con aggregato da sotto + // se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi) + bool bBottomOutStart = false ; if ( m_bAggrBottom) { - // aggiuntivo in Z - double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ; - // distanza dal bordo del pezzo + // distanza dal bordo del pezzo (se negativa il punto è fuori dal grezzo) double dDistBottom ; if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom)) dDistBottom = 0 ; + bBottomOutStart = ( dDistBottom < - 10 * EPS_SMALL) ; + // aggiuntivo in Z + double dAggZ = ( bBottomOutStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ; // pre-approccio Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ; Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ; @@ -3473,7 +3475,7 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe } // se sopra attacco c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; - if ( dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { + if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { // se distanza di sicurezza minore di distanza di inizio if ( dSafeDist < dAppr + 10 * EPS_SMALL) { // 1 -> punto sopra inizio @@ -3562,9 +3564,18 @@ bool Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ, double dElev, double dAppr) { + // se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi) + bool bBottomOutStart = false ; + double dDistBottom ; + if ( m_bAggrBottom) { + // distanza dal bordo del pezzo + if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom)) + dDistBottom = 0 ; + bBottomOutStart = ( dDistBottom < - 10 * EPS_SMALL) ; + } // se sopra uscita c'è spazio per sicurezza o approccio double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ; - if ( dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { + if ( ! bBottomOutStart && dElev + max( dSafeDist, dAppr) > 10 * EPS_SMALL) { if ( dSafeDist < dAppr + 10 * EPS_SMALL) { // 4 -> movimento di risalita sopra il punto finale SetFeed( GetEndFeed()) ; @@ -3586,14 +3597,10 @@ Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ return false ; } } - // se con aggregato da sotto + // se con aggregato da sotto o equivalente (rinvio a 90 gradi su testa 5 assi) if ( m_bAggrBottom) { // aggiuntivo in Z - double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ; - // distanza dal bordo del pezzo - double dDistBottom ; - if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAggrBottom, dDistBottom)) - dDistBottom = 0 ; + double dAggZ = ( bBottomOutStart ? 0. : max( dElev + max( dSafeAggrBottZ, dAppr), 0.)) ; // post-retract Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAggrBottom * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ; Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 49bd0a9..87d84fd 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -847,7 +847,7 @@ SawFinishing::VerifyGeometry( SelData Id, int& nSubs) const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ; // se direttamente la curva if ( Id.nSub == SEL_SUB_ALL) { - pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ; + pCurve = ::GetCurve( pGObj) ; if ( pCurve != nullptr) { if ( pCurve->GetType() == CRV_COMPO) nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ; @@ -857,7 +857,7 @@ SawFinishing::VerifyGeometry( SelData Id, int& nSubs) } // altrimenti sottocurva di composita else { - const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ; + const ICurveComposite* pCompo = GetCurveComposite( pGObj) ; if ( pCompo != nullptr) pCurve = pCompo->GetCurve( Id.nSub) ; nSubs = 0 ; diff --git a/Sawing.cpp b/Sawing.cpp index cdf22c2..55a8f04 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -1081,7 +1081,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType) const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ; // se direttamente la curva if ( Id.nSub == SEL_SUB_ALL) { - pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ; + pCurve = ::GetCurve( pGObj) ; if ( pCurve != nullptr) { if ( pCurve->GetType() == CRV_COMPO) nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ; @@ -1091,7 +1091,7 @@ Sawing::VerifyGeometry( SelData Id, int& nSubs, int& nType) } // altrimenti sottocurva di composita else { - const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ; + const ICurveComposite* pCompo = GetCurveComposite( pGObj) ; if ( pCompo != nullptr) pCurve = pCompo->GetCurve( Id.nSub) ; nSubs = 0 ; @@ -1249,17 +1249,17 @@ Sawing::GetCurve( SelData Id) // recupero la regione const ISurfFlatRegion* pReg = ::GetSurfFlatRegion( pGObj) ; if ( pReg == nullptr) - return false ; + return nullptr ; // recupero l'indice del chunk int nChunk = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ; // recupero il contorno esterno del chunk PtrOwner pCrvCompo( CreateCurveComposite()) ; if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nChunk, 0))) - return false ; + return nullptr ; // recupero la normale della regione Vector3d vtN = pReg->GetNormVersor() ; if ( vtN.IsSmall()) - return false ; + return nullptr ; // assegno l'estrusione dalla normale alla faccia pCrvCompo->SetExtrusion( vtN) ; // unisco le eventuali parti allineate diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index f2dbbce..f328878 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -846,7 +846,7 @@ SurfFinishing::VerifyGeometry( SelData Id, int& nSubs) const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ; // se direttamente la curva if ( Id.nSub == SEL_SUB_ALL) { - pCurve = ::GetCurve( m_pGeomDB->GetGeoObj( Id.nId)) ; + pCurve = ::GetCurve( pGObj) ; if ( pCurve != nullptr) { if ( pCurve->GetType() == CRV_COMPO) nSubs = ::GetCurveComposite( pCurve)->GetCurveCount() ; @@ -856,7 +856,7 @@ SurfFinishing::VerifyGeometry( SelData Id, int& nSubs) } // altrimenti sottocurva di composita else { - const ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( Id.nId)) ; + const ICurveComposite* pCompo = GetCurveComposite( pGObj) ; if ( pCompo != nullptr) pCurve = pCompo->GetCurve( Id.nSub) ; nSubs = 0 ; diff --git a/WaterJetting.cpp b/WaterJetting.cpp index a6eeda8..c5dd2b4 100644 --- a/WaterJetting.cpp +++ b/WaterJetting.cpp @@ -1879,7 +1879,7 @@ WaterJetting::AddLeadOutPreview( const ICurveComposite* pCompo, ISurfFlatRegion* vtPerp.Rotate( vtN, 0, ( bCcwRot ? 1 : - 1)) ; Point3d ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ; if ( IsNull( pLine) || ! pLine->Set( ptEnd, ptP1)) - return nullptr ; + return false ; pCrv.Set( Release( pLine)) ; } break ; case WJET_LO_TANGENT :