From 0f3bd716a3be45d7071cb79b3a031e458c8ba38c Mon Sep 17 00:00:00 2001 From: DarioS Date: Wed, 28 Dec 2022 19:38:58 +0100 Subject: [PATCH] =?UTF-8?q?EgtGeomKernel=20:=20-=20modifiche=20per=20pi?= =?UTF-8?q?=C3=B9=20utensili=20in=20virtual=20milling=20(Zmap).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tool.cpp | 3 +- Tool.h | 4 +- VolZmap.cpp | 146 ++++++-- VolZmap.h | 74 ++-- VolZmapGraphics.cpp | 24 +- VolZmapVolume.cpp | 830 ++++++++++++++++++++++++++------------------ 6 files changed, 679 insertions(+), 402 deletions(-) diff --git a/Tool.cpp b/Tool.cpp index c4f306c..eac5034 100644 --- a/Tool.cpp +++ b/Tool.cpp @@ -41,8 +41,9 @@ Tool::~Tool( void) //---------------------------------------------------------------------------- bool -Tool::Clear( void) +Tool::Clear( bool bApproxWithLines) { + m_bApproxWithLines = bApproxWithLines ; m_dLinTol = LIN_TOL_STD ; m_dAngTolDeg = ANG_TOL_APPROX_DEG ; m_nType = UNDEF ; diff --git a/Tool.h b/Tool.h index acc340f..dcee784 100644 --- a/Tool.h +++ b/Tool.h @@ -23,7 +23,7 @@ class Tool ~Tool( void) ; public : - bool Clear( void) ; + bool Clear( bool bApproxWithLines = false) ; bool SetTolerances( double dLinTol, double dAngTolDeg = 45) ; bool SetStdTool( const std::string& sToolName, double dH, double dR, double dCornR, double dCutterH, int nToolNum) ; bool SetAdvTool( const std::string& sToolName, @@ -37,7 +37,7 @@ class Tool { m_nCurrentNum = nToolNum ; return true ; } int GetType() const { return m_nType ; } - int GetCurrentToolNum() const + int GetToolNum() const { return m_nCurrentNum ; } double GetHeigth() const { return m_dHeight ; } diff --git a/VolZmap.cpp b/VolZmap.cpp index 32cd3c5..7630931 100644 --- a/VolZmap.cpp +++ b/VolZmap.cpp @@ -35,7 +35,8 @@ GEOOBJ_REGISTER( VOL_ZMAP, NGE_V_ZMP, VolZmap) ; //---------------------------------------------------------------------------- VolZmap::VolZmap(void) : m_nStatus( TO_VERIFY), m_dStep( 10.0), m_nMapNum( 0), m_nShape( GENERIC), m_nVoxNumPerBlock( N_VOXBLOCK), - m_nDexVoxRatio( 1), m_nNumBlock( 0), m_nConnectedCompoCount( 0), m_Tool( true) + m_nDexVoxRatio( 1), m_nNumBlock( 0), m_nConnectedCompoCount( 0), m_nCurrTool( -1), + m_dToolLinTol( LIN_TOL_STD), m_dToolAngTolDeg( ANG_TOL_APPROX_DEG) { for ( int i = 0 ; i < N_MAPS ; ++ i) { m_nNx[i] = 0 ; @@ -47,7 +48,8 @@ VolZmap::VolZmap(void) } m_nTempProp[0] = 0 ; m_nTempProp[1] = 0 ; - m_Tool.SetTolerances( LIN_TOL_STD, ANG_TOL_APPROX_DEG) ; + m_vTool.resize( 1) ; + m_nCurrTool = 0 ; } //---------------------------------------------------------------------------- @@ -76,7 +78,10 @@ VolZmap::Clear( void) m_dStep = EPS_SMALL ; m_nTempProp[0] = 0 ; m_nTempProp[1] = 0 ; - m_Tool.Clear() ; + m_vTool.resize( 1) ; + m_nCurrTool = 0 ; + m_dToolLinTol = LIN_TOL_STD ; + m_dToolAngTolDeg = ANG_TOL_APPROX_DEG ; // imposto ricalcolo della grafica m_OGrMgr.Reset() ; @@ -1679,9 +1684,6 @@ VolZmap::Cut( const Plane3d& plPlane) // Porto il piano nel riferimento intrinseco Plane3d plMyPlane = plPlane ; plMyPlane.ToLoc( m_MapFrame) ; - // Imposto numero fittizio di utensile per avere il colore di sezione opportuno - int nToolNumOld = m_Tool.GetCurrentToolNum() ; - m_Tool.SetToolNum( 1) ; // Interseco lo Zmap col piano, ciclando sulle griglie bool bModified = false ; for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) { @@ -1717,26 +1719,23 @@ VolZmap::Cut( const Plane3d& plPlane) // se altrimenti entrambi gli estremi sono oltre il piano else if ( dStDist > -EPS_SMALL && dEnDist > -EPS_SMALL) { // Si elimina tutto - SubtractIntervals( nMap, nI, nJ, dMin, dMax, V_NULL, V_NULL) ; + SubtractIntervals( nMap, nI, nJ, dMin, dMax, V_NULL, V_NULL, 1) ; } // se altrimenti è da tenere il punto iniziale else if ( dStDist < 0) { // Si elimina la parte tra intersezione e punto finale double dInt = dMin + ( dMax - dMin) * abs( dStDist) / ( abs( dStDist) + abs( dEnDist)) ; - SubtractIntervals( nMap, nI, nJ, dInt, dMax, plMyPlane.GetVersN(), V_NULL) ; + SubtractIntervals( nMap, nI, nJ, dInt, dMax, plMyPlane.GetVersN(), V_NULL, 1) ; } // se altrimenti è da tenere il punto finale else if (dEnDist < 0) { // Si elimina la parte tra punto iniziale e intersezione double dInt = dMin + ( dMax - dMin) * abs( dStDist) / ( abs( dStDist) + abs( dEnDist)) ; - SubtractIntervals( nMap, nI, nJ, dMin, dInt, V_NULL, plMyPlane.GetVersN()) ; + SubtractIntervals( nMap, nI, nJ, dMin, dInt, V_NULL, plMyPlane.GetVersN(), 1) ; } } } - // Ripristino numero utensile - m_Tool.SetToolNum( nToolNumOld) ; - if ( bModified == true) { // Imposto forma generica m_nShape = GENERIC ; @@ -1970,56 +1969,149 @@ VolZmap::CalcBlockNum( void) bool VolZmap::SetToolTolerances( double dLinTol, double dAngTolDeg) { - return m_Tool.SetTolerances( dLinTol, dAngTolDeg) ; + m_dToolLinTol = max( dLinTol, LIN_TOL_MIN) ; + m_dToolAngTolDeg = max( dAngTolDeg, ANG_TOL_MIN_DEG) ; + return true ; } //---------------------------------------------------------------------------- bool -VolZmap::SetStdTool( const string& sToolName, double dH, double dR, double dCornR, double dCutterH, int nFlag) +VolZmap::SetStdTool( const string& sToolName, double dH, double dR, double dCornR, double dCutterH, int nFlag, bool bFirst) { - return m_Tool.SetStdTool( sToolName, dH, dR, dCornR, dCutterH, nFlag) ; + if ( bFirst) { + m_vTool.resize( 1) ; + m_vTool[0].Clear( true) ; + } + else + m_vTool.emplace_back( true) ; + m_nCurrTool = int( m_vTool.size()) - 1 ; + if ( m_nCurrTool < 0) + return false ; + m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ; + return m_vTool[m_nCurrTool].SetStdTool( sToolName, dH, dR, dCornR, dCutterH, nFlag) ; } //---------------------------------------------------------------------------- bool VolZmap::SetAdvTool( const string& sToolName, - double dH, double dR, double dTipH, double dTipR, double dCornR, double dCutterH, int nFlag) + double dH, double dR, double dTipH, double dTipR, double dCornR, double dCutterH, int nFlag, bool bFirst) { - return m_Tool.SetAdvTool( sToolName, dH, dR, dTipH, dTipR, dCornR, dCutterH, nFlag) ; + if ( bFirst) { + m_vTool.resize( 1) ; + m_vTool[0].Clear( true) ; + } + else + m_vTool.emplace_back( true) ; + m_nCurrTool = int( m_vTool.size()) - 1 ; + if ( m_nCurrTool < 0) + return false ; + m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ; + return m_vTool[m_nCurrTool].SetAdvTool( sToolName, dH, dR, dTipH, dTipR, dCornR, dCutterH, nFlag) ; } //---------------------------------------------------------------------------- bool VolZmap::SetSawTool( const string& sToolName, - double dH, double dR, double dThick, double dStemR, double dCornR, int nFlag) + double dH, double dR, double dThick, double dStemR, double dCornR, int nFlag, bool bFirst) { - return m_Tool.SetSawTool( sToolName, dH, dR, dThick, dStemR, dCornR, nFlag) ; + if ( bFirst) { + m_vTool.resize( 1) ; + m_vTool[0].Clear( true) ; + } + else + m_vTool.emplace_back( true) ; + m_nCurrTool = int( m_vTool.size()) - 1 ; + if ( m_nCurrTool < 0) + return false ; + m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ; + return m_vTool[m_nCurrTool].SetSawTool( sToolName, dH, dR, dThick, dStemR, dCornR, nFlag) ; } //---------------------------------------------------------------------------- bool -VolZmap::SetGenTool( const string& sToolName, const ICurveComposite* pToolOutline, int nFlag) +VolZmap::SetGenTool( const string& sToolName, const ICurveComposite* pToolOutline, int nFlag, bool bFirst) { - return m_Tool.SetGenTool( sToolName, pToolOutline, nFlag) ; + if ( bFirst) { + m_vTool.resize( 1) ; + m_vTool[0].Clear( true) ; + } + else + m_vTool.emplace_back( true) ; + m_nCurrTool = int( m_vTool.size()) - 1 ; + if ( m_nCurrTool < 0) + return false ; + m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ; + return m_vTool[m_nCurrTool].SetGenTool( sToolName, pToolOutline, nFlag) ; } //---------------------------------------------------------------------------- bool -VolZmap::SetMortiserTool( const string& sToolName, double dH, double dW, double dTh, double dRc, int nFlag) +VolZmap::SetMortiserTool( const string& sToolName, double dH, double dW, double dTh, double dRc, int nFlag, bool bFirst) { - return m_Tool.SetMortiserTool( sToolName, dH, dW, dTh, dRc, nFlag) ; + if ( bFirst) { + m_vTool.resize( 1) ; + m_vTool[0].Clear( true) ; + } + else + m_vTool.emplace_back( true) ; + m_nCurrTool = int( m_vTool.size()) - 1 ; + if ( m_nCurrTool < 0) + return false ; + m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ; + return m_vTool[m_nCurrTool].SetMortiserTool( sToolName, dH, dW, dTh, dRc, nFlag) ; } //---------------------------------------------------------------------------- bool -VolZmap::SetChiselTool( const string& sToolName, double dH, double dW, double dTh, int nFlag) +VolZmap::SetChiselTool( const string& sToolName, double dH, double dW, double dTh, int nFlag, bool bFirst) { - return m_Tool.SetChiselTool( sToolName, dH, dW, dTh, nFlag) ; + if ( bFirst) { + m_vTool.resize( 1) ; + m_vTool[0].Clear( true) ; + } + else + m_vTool.emplace_back( true) ; + m_nCurrTool = int( m_vTool.size()) - 1 ; + if ( m_nCurrTool < 0) + return false ; + m_vTool[m_nCurrTool].SetTolerances( m_dToolLinTol, m_dToolAngTolDeg) ; + return m_vTool[m_nCurrTool].SetChiselTool( sToolName, dH, dW, dTh, nFlag) ; +} + +//---------------------------------------------------------------------------- +int +VolZmap::GetToolCount( void) const +{ + return m_vTool.size() ; +} + +//---------------------------------------------------------------------------- +bool +VolZmap::SetCurrTool( int nCurrTool) +{ + if ( nCurrTool < 0 || nCurrTool >= int( m_vTool.size())) + return false ; + m_nCurrTool = nCurrTool ; + return true ; } //---------------------------------------------------------------------------- bool -VolZmap::ResetTool( void) +VolZmap::ResetTools( void) { - return m_Tool.Clear() ; + m_vTool.resize( 1) ; + m_nCurrTool = 0 ; + return m_vTool[0].Clear() ; +} + +//---------------------------------------------------------------------------- +const ICurveComposite& +VolZmap::GetToolOutline( bool bApprox) const +{ + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) { + static CurveComposite StatCrvCo ; + return StatCrvCo ; + } + const Tool& CurrTool = m_vTool[m_nCurrTool] ; + return ( bApprox ? CurrTool.GetApproxOutline() : CurrTool.GetOutline()) ; } diff --git a/VolZmap.h b/VolZmap.h index 500f494..6df1369 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -82,19 +82,27 @@ class VolZmap : public IVolZmap, public IGeoObjRW { return m_nDexVoxRatio ; } bool ChangeResolution( int nDexVoxRatio) override ; bool SetToolTolerances( double dLinTol, double dAngTolDeg = 90) override ; - bool SetStdTool( const std::string& sToolName, double dH, double dR, double dCornR, double dCutterH, int nFlag) override ; + bool SetStdTool( const std::string& sToolName, + double dH, double dR, double dCornR, double dCutterH, int nFlag, bool bFirst) override ; bool SetAdvTool( const std::string& sToolName, - double dH, double dR, double dTipH, double dTipR, double dCornR, double dCutterH, int nFlag) override ; + double dH, double dR, double dTipH, double dTipR, double dCornR, double dCutterH, int nFlag, bool bFirst) override ; bool SetSawTool( const std::string& sToolName, - double dH, double dR, double dThick, double dStemR, double dCornR, int nFlag) override ; - bool SetGenTool( const std::string& sToolName, const ICurveComposite* pToolOutline, int nFlag) override ; - bool SetMortiserTool( const std::string& sToolName, double dH, double dW, double dTh, double dRc, int nFlag) override ; - bool SetChiselTool( const std::string& sToolName, double dH, double dW, double dTh, int nFlag) override ; - bool ResetTool( void) override ; - const ICurveComposite& GetToolOutline( bool bApprox = false) const override - { return ( bApprox ? m_Tool.GetApproxOutline() : m_Tool.GetOutline()) ;} - bool MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Point3d& ptPe, const Vector3d& vtDe) override ; - bool MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, + double dH, double dR, double dThick, double dStemR, double dCornR, int nFlag, bool bFirst) override ; + bool SetGenTool( const std::string& sToolName, + const ICurveComposite* pToolOutline, int nFlag, bool bFirst) override ; + bool SetMortiserTool( const std::string& sToolName, + double dH, double dW, double dTh, double dRc, int nFlag, bool bFirst) override ; + bool SetChiselTool( const std::string& sToolName, + double dH, double dW, double dTh, int nFlag, bool bFirst) override ; + int GetToolCount( void) const override ; + bool SetCurrTool( int nCurrTool) override ; + bool ResetTools( void) override ; + const ICurveComposite& GetToolOutline( bool bApprox = false) const override ; + bool MillingStep( int nCurrTool, + const Point3d& ptPs, const Vector3d& vtDs, + const Point3d& ptPe, const Vector3d& vtDe) override ; + bool MillingStep( int nCurrTool, + const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) override ; bool GetDepth( const Point3d& ptP, const Vector3d& vtD, double& dInLength, double& dOutLength, bool bExact) const override ; bool GetLineIntersection( const Point3d& ptP, const Vector3d& vtD, ILZIVECTOR& vIntersInfo) const override ; @@ -218,9 +226,9 @@ class VolZmap : public IVolZmap, public IGeoObjRW INTVECTOR& vAdjBlockVoxComp, INTVECTOR& vAdjBordBlockVoxComp) const ; // OPERAZIONI SU INTERVALLI bool SubtractIntervals( int nGrid, int nI, int nJ, - double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) ; + double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum) ; bool AddIntervals( int nGrid, int nI, int nJ, - double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) ; + double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum) ; // Spostamenti utensile bool MillingTranslationStep( const Point3d& ptPs, const Point3d& ptPe, const Vector3d& vtD, const Vector3d& vtA) ; bool MillingGeneralMotionStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, @@ -264,36 +272,39 @@ class VolZmap : public IVolZmap, public IGeoObjRW // COMPONENTI // Asse di simmetria diretto come l'asse Z bool CompCyl_ZDrilling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, - double dHei, double dRad) ; - bool CompConus_ZDrilling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, - const Vector3d& vtArcNormMaxR = Vector3d( 0, 0, 0), const Vector3d& vtArcNormMinR = Vector3d( 0, 0, 0)) ; + double dHei, double dRad, int nToolNum) ; + bool CompConus_ZDrilling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtToolDir, + double dHei, double dMaxRad, double dMinRad, + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ; bool CompPar_ZDrilling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) ; - bool CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dRad) ; - bool CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, - const Vector3d& vtArcNormMaxR = Vector3d( 0, 0, 0), const Vector3d& vtArcNormMinR = Vector3d( 0, 0, 0)) ; + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; + bool CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, + double dHei, double dRad, int nToolNum) ; + bool CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, + double dHei, double dMaxRad, double dMinRad, + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ; bool CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realtà MillingPerp + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp // Asse di simmetria con orientazione generica bool CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, - double dHei, double dRad, bool bTapB, bool bTapT) ; + double dHei, double dRad, bool bTapB, bool bTapT, int nToolNum) ; bool CompConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT, - const Vector3d& vtArcNormMaxR = Vector3d( 0, 0, 0), const Vector3d& vtArcNormMinR = Vector3d( 0, 0, 0)) ; + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ; bool CompPar_Drilling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) ; + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; bool CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, - double dHei, double dRad, bool bTapB, bool bTapT) ; + double dHei, double dRad, bool bTapB, bool bTapT, int nToolNum) ; bool CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT, - const Vector3d& vtArcNormMaxR = Vector3d( 0, 0, 0), const Vector3d& vtArcNormMinR = Vector3d( 0, 0, 0)) ; + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) ; bool CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) ; // E' in realtà MillingPerp + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) ; // E' in realtà MillingPerp // Generica traslazione sfera - bool CompBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dRad) ; + bool CompBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dRad, int nToolNum) ; // BBox per utensili e solidi semplici con movimenti di traslazione inline bool TestToolBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV, int& nStI, int& nStJ, int& nEnI, int& nEnJ) ; @@ -444,12 +455,15 @@ class VolZmap : public IVolZmap, public IGeoObjRW mutable std::vector m_SliceXY ; mutable std::vector m_SliceXZ ; mutable std::vector m_SliceYZ ; - mutable std::mutex SliceMutex ; + mutable std::mutex m_SliceMutex ; mutable std::atomic m_bBreak ; std::atomic m_bIsBox ; - Tool m_Tool ; + int m_nCurrTool ; + std::vector m_vTool ; + double m_dToolLinTol ; + double m_dToolAngTolDeg ; } ; diff --git a/VolZmapGraphics.cpp b/VolZmapGraphics.cpp index 7a8aeac..077f084 100644 --- a/VolZmapGraphics.cpp +++ b/VolZmapGraphics.cpp @@ -1224,13 +1224,13 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const bDefTopology = true ; } if ( GetBlockNFromIJK( nSlBlockIJK, nSlBlockN)) { - SliceMutex.lock() ; + m_SliceMutex.lock() ; auto it = m_SliceYZ[nSlBlockN].find( nSliceN) ; if ( it != m_SliceYZ[nSlBlockN].end()) { bMatOnSlice = it->second ; bDefTopology = true ; } - SliceMutex.unlock() ; + m_SliceMutex.unlock() ; } } else if ( abs( nAdjVox3[nCount]) == 2) { @@ -1240,13 +1240,13 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const bDefTopology = true ; } if ( GetBlockNFromIJK( nSlBlockIJK, nSlBlockN)) { - SliceMutex.lock() ; + m_SliceMutex.lock() ; auto it = m_SliceXZ[nSlBlockN].find( nSliceN) ; if ( it != m_SliceXZ[nSlBlockN].end()) { bMatOnSlice = it->second ; bDefTopology = true ; } - SliceMutex.unlock() ; + m_SliceMutex.unlock() ; } } else if ( abs( nAdjVox3[nCount]) == 3) { @@ -1256,13 +1256,13 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const bDefTopology = true ; } if ( GetBlockNFromIJK( nSlBlockIJK, nSlBlockN)) { - SliceMutex.lock() ; + m_SliceMutex.lock() ; auto it = m_SliceXY[nSlBlockN].find( nSliceN) ; if ( it != m_SliceXY[nSlBlockN].end()) { bMatOnSlice = it->second ; bDefTopology = true ; } - SliceMutex.unlock() ; + m_SliceMutex.unlock() ; } } } @@ -1327,27 +1327,27 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const if ( nSlBlockN == nBlock) SliceYZ.emplace( nSliceN, bMatOnSlice) ; else { - SliceMutex.lock() ; + m_SliceMutex.lock() ; m_SliceYZ[nSlBlockN].emplace( nSliceN, bMatOnSlice) ; - SliceMutex.unlock() ; + m_SliceMutex.unlock() ; } } else if ( abs(nAdjVox3[nCount]) == 2) { if ( nSlBlockN == nBlock) SliceXZ.emplace( nSliceN, bMatOnSlice) ; else { - SliceMutex.lock() ; + m_SliceMutex.lock() ; m_SliceXZ[nSlBlockN].emplace( nSliceN, bMatOnSlice) ; - SliceMutex.unlock() ; + m_SliceMutex.unlock() ; } } else if ( abs(nAdjVox3[nCount]) == 3) { if ( nSlBlockN == nBlock) SliceXY.emplace(nSliceN, bMatOnSlice) ; else { - SliceMutex.lock(); + m_SliceMutex.lock() ; m_SliceXY[nSlBlockN].emplace( nSliceN, bMatOnSlice) ; - SliceMutex.unlock() ; + m_SliceMutex.unlock() ; } } } diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 4f0c008..5b665e7 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -30,7 +30,7 @@ using namespace std ; //---------------------------------------------------------------------------- bool VolZmap::SubtractIntervals( int nGrid, int nI, int nJ, - double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) + double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum) { // Controllo che dMin e dMax non siano quasi coincidenti if ( abs( dMax - dMin) < EPS_ZERO) @@ -81,25 +81,25 @@ VolZmap::SubtractIntervals( int nGrid, int nI, int nJ, if ( dMin <= vDexel[i].dMin + EPS_ZERO && dMax < vDexel[i].dMax - EPS_ZERO) { vDexel[i].dMin = dMax ; vDexel[i].vtMinN = vtNma ; - vDexel[i].nToolMin = m_Tool.GetCurrentToolNum() ; + vDexel[i].nToolMin = nToolNum ; } // se devo limitarlo superiormente else if ( dMin > vDexel[i].dMin + EPS_ZERO && dMax >= vDexel[i].dMax - EPS_ZERO) { vDexel[i].dMax = dMin ; vDexel[i].vtMaxN = vtNmi ; - vDexel[i].nToolMax = m_Tool.GetCurrentToolNum() ; + vDexel[i].nToolMax = nToolNum ; } // se devo dividerlo in due parti else if ( dMin > vDexel[i].dMin + EPS_ZERO && dMax < vDexel[i].dMax - EPS_ZERO) { // inserisco nuovo intervallo (parte superiore) vDexel.insert( vDexel.begin() + i + 1, - { dMax, vtNma, m_Tool.GetCurrentToolNum(), + { dMax, vtNma, nToolNum, vDexel[i].dMax, vDexel[i].vtMaxN, vDexel[i].nToolMax, vDexel[i].nCompo}) ; // aggiorno il vecchio (parte inferiore) vDexel[i].dMax = dMin ; vDexel[i].vtMaxN = vtNmi ; - vDexel[i].nToolMax = m_Tool.GetCurrentToolNum() ; + vDexel[i].nToolMax = nToolNum ; ++ i ; } // altrimenti devo eliminarlo @@ -250,7 +250,7 @@ VolZmap::SubtractIntervals( int nGrid, int nI, int nJ, //---------------------------------------------------------------------------- bool VolZmap::AddIntervals( int nGrid, int nI, int nJ, - double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax) + double dMin, double dMax, const Vector3d& vtNMin, const Vector3d& vtNMax, int nToolNum) { // // Controllo che dMin e dMax non siano quasi coincidenti // if ( abs( dMax - dMin) < EPS_SMALL) @@ -482,19 +482,27 @@ VolZmap::AddIntervals( int nGrid, int nI, int nJ, //---------------------------------------------------------------------------- bool -VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, +VolZmap::MillingStep( int nCurrTool, + const Point3d& ptPs, const Vector3d& vtDs, const Point3d& ptPe, const Vector3d& vtDe) { - return MillingStep( ptPs, vtDs, Vector3d(), ptPe, vtDe, Vector3d()) ; + return MillingStep( nCurrTool, ptPs, vtDs, Vector3d(), ptPe, vtDe, Vector3d()) ; } //---------------------------------------------------------------------------- bool -VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, +VolZmap::MillingStep( int nCurrTool, + const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) { + // Controllo utensile + if ( nCurrTool < 0 || nCurrTool >= int( m_vTool.size())) + return false ; + m_nCurrTool = nCurrTool ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Se non è definito l'utensile, non devo fare alcunchè - if ( m_Tool.GetType() == Tool::UNDEF) + if ( CurrTool.GetType() == Tool::UNDEF) return true ; // Controllo definizione vettori direzione if ( vtDs.IsSmall() || vtDe.IsSmall()) @@ -503,7 +511,7 @@ VolZmap::MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& if ( AreSamePointApprox( ptPs, ptPe) && AreSameVectorApprox( vtDs, vtDe)) return true ; // Se utensile chisel o mortise, controllo definizione vettori ausiliari - if ( m_Tool.GetType() == Tool::MORTISER || m_Tool.GetType() == Tool::CHISEL) { + if ( CurrTool.GetType() == Tool::MORTISER || CurrTool.GetType() == Tool::CHISEL) { if ( vtAs.IsSmall() || vtAe.IsSmall()) return false ; } @@ -647,6 +655,11 @@ VolZmap::InitializePointsAndVectors( const Point3d& ptPs, const Point3d& ptPe, c bool VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, const Vector3d& vtL, const Vector3d& vtAL) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Versore utensile parallelo all'asse Z (coincide con spillone) if ( vtL.SqLenXY() < EPS_ZERO * EPS_ZERO) { @@ -654,7 +667,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons // Foratura if ( vtMove.SqLenXY() < EPS_SMALL * EPS_SMALL) { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_ZDrilling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -676,7 +689,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons // Fresatura con vettore movimento perpendicolare all'utensile else if ( abs( vtMove.z) < EPS_SMALL) { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_ZMilling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -698,7 +711,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons // Fresatura con vettore movimento generico rispetto all'utensile else { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_ZMilling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -728,7 +741,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons // Foratura if ( dSqLOrt < EPS_SMALL * EPS_SMALL) { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_Drilling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -749,7 +762,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons } // Fresatura con vettore movimento perpendicolare all'utensile else if ( dSqLLong < EPS_SMALL * EPS_SMALL) { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_Milling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -772,7 +785,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons } // Fresatura con vettore movimento generico rispetto all'utensile else { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_Milling( nGrid, ptLs, ptLe, vtL); break ; @@ -801,7 +814,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons // Foratura if ( dSqLOrt < EPS_SMALL * EPS_SMALL) { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_Drilling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -822,7 +835,7 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons } // Fresatura con vettore movimento generico rispetto all'utensile else { - switch ( m_Tool.GetType()) { + switch ( CurrTool.GetType()) { case Tool::GEN : GenTool_Milling( nGrid, ptLs, ptLe, vtL) ; break ; @@ -856,6 +869,11 @@ VolZmap::SelectMotion( int nGrid, const Point3d& ptLs, const Point3d& ptLe, cons bool VolZmap::CylBall_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) @@ -865,8 +883,8 @@ VolZmap::CylBall_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, Point3d ptSxy( ptS.x, ptS.y, 0) ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dSqRad = CurrTool.GetRadius() * CurrTool.GetRadius() ; // Punte del gambo Point3d ptTStemS = ptS - vtToolDir * dStemHeigth ; @@ -884,22 +902,22 @@ VolZmap::CylBall_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, double dSqLen = vtC.SqLen() ; // Se il punto si trova dentro il cerchio taglio - if ( dSqLen < dSqRad - 2 * m_Tool.GetRadius() * EPS_SMALL) { + if ( dSqLen < dSqRad - 2 * CurrTool.GetRadius() * EPS_SMALL) { // utensile cilindrico - if ( m_Tool.GetType() == Tool::CYLMILL) - SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, - Z_AX) ; + if ( CurrTool.GetType() == Tool::CYLMILL) + SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, -Z_AX, CurrTool.GetToolNum()) ; // utensile sferico - else if ( m_Tool.GetType() == Tool::BALLMILL) { + else if ( CurrTool.GetType() == Tool::BALLMILL) { double dH = sqrt( dSqRad - dSqLen) ; if ( vtToolDir.z > 0) { Vector3d vtNorm = Point3d( ptSxy.x, ptSxy.y, dMinStemZ) - Point3d( dX, dY, dMinStemZ - dH) ; vtNorm.Normalize() ; - SubtractIntervals( nGrid, i, j, dMinStemZ - dH, dMaxStemZ, vtNorm, - vtToolDir) ; + SubtractIntervals( nGrid, i, j, dMinStemZ - dH, dMaxStemZ, vtNorm, -vtToolDir, CurrTool.GetToolNum()) ; } else { Vector3d vtNorm = Point3d( ptSxy.x, ptSxy.y, dMinStemZ) - Point3d( dX, dY, dMinStemZ + dH) ; vtNorm.Normalize() ; - SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ + dH, - vtToolDir, vtNorm) ; + SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ + dH, -vtToolDir, vtNorm, CurrTool.GetToolNum()) ; } } } @@ -912,14 +930,19 @@ VolZmap::CylBall_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, bool VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dSafeRad = m_Tool.GetRadius() - EPS_SMALL ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dSafeRad = CurrTool.GetRadius() - EPS_SMALL ; double dSafeSqRad = dSafeRad * dSafeRad ; // Punte del gambo @@ -951,17 +974,17 @@ VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const double dP1 = vtC * vtV1 ; double dP2 = vtC * vtV2 ; // Utensile cilindrico - if ( m_Tool.GetType() == Tool::CYLMILL) { + if ( CurrTool.GetType() == Tool::CYLMILL) { // Se il punto cade nella zona di interesse taglio if ( ( dP1 * dP1 + dP2 * dP2 < dSafeSqRad) || ( ( dP1 - dLen) * ( dP1 - dLen) + dP2 * dP2) < dSafeSqRad || ( dP1 > 0 && dP1 < dLen && abs( dP2) < dSafeRad)) - SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, -Z_AX, CurrTool.GetToolNum()) ; } // Utensile sferico - else if ( m_Tool.GetType() == Tool::BALLMILL) { + else if ( CurrTool.GetType() == Tool::BALLMILL) { if ( abs( dP2) < dSafeRad) { @@ -975,14 +998,14 @@ VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptInt( dX, dY, ptTStemS.z - dH) ; Vector3d vtN = ptTStemS - ptInt ; vtN.Normalize() ; - SubtractIntervals( nGrid, i, j, ptTStemS.z - dH, ptS.z, vtN, - Z_AX) ; + SubtractIntervals( nGrid, i, j, ptTStemS.z - dH, ptS.z, vtN, -Z_AX, CurrTool.GetToolNum()) ; } else { Point3d ptInt( dX, dY, ptTStemS.z + dH) ; Vector3d vtN = ptTStemS - ptInt ; vtN.Normalize() ; - SubtractIntervals( nGrid, i, j, ptS.z, ptTStemS.z + dH, Z_AX, vtN) ; + SubtractIntervals( nGrid, i, j, ptS.z, ptTStemS.z + dH, Z_AX, vtN, CurrTool.GetToolNum()) ; } } } @@ -995,14 +1018,14 @@ VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptInt( dX, dY, ptTStemS.z - dH) ; Vector3d vtN = - ( ptInt - ptTStemS) + ( ptInt - ptTStemS) * vtV1 * vtV1 ; vtN.Normalize() ; - SubtractIntervals( nGrid, i, j, ptTStemS.z - dH, ptS.z, vtN, - Z_AX) ; + SubtractIntervals( nGrid, i, j, ptTStemS.z - dH, ptS.z, vtN, -Z_AX, CurrTool.GetToolNum()) ; } else { Point3d ptInt( dX, dY, ptTStemS.z + dH) ; Vector3d vtN = - ( ptInt - ptTStemS) + ( ptInt - ptTStemS) * vtV1 * vtV1 ; vtN.Normalize() ; - SubtractIntervals( nGrid, i, j, ptS.z, ptTStemS.z + dH, Z_AX, vtN) ; + SubtractIntervals( nGrid, i, j, ptS.z, ptTStemS.z + dH, Z_AX, vtN, CurrTool.GetToolNum()) ; } } @@ -1015,14 +1038,14 @@ VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptInt( dX, dY, ptTStemE.z - dH) ; Vector3d vtN = ptTStemE - ptInt ; vtN.Normalize() ; - SubtractIntervals( nGrid, i, j, ptTStemE.z - dH, ptS.z, vtN, - Z_AX) ; + SubtractIntervals( nGrid, i, j, ptTStemE.z - dH, ptS.z, vtN, -Z_AX, CurrTool.GetToolNum()) ; } else { Point3d ptInt( dX, dY, ptTStemE.z + dH) ; Vector3d vtN = ptTStemE - ptInt ; vtN.Normalize() ; - SubtractIntervals( nGrid, i, j, ptS.z, ptTStemE.z + dH, Z_AX, vtN) ; + SubtractIntervals( nGrid, i, j, ptS.z, ptTStemE.z + dH, Z_AX, vtN, CurrTool.GetToolNum()) ; } } } @@ -1037,16 +1060,21 @@ VolZmap::CylBall_ZPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::CylBall_ZMilling( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dSafeRadius = m_Tool.GetRadius() - EPS_SMALL ; - double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ; - double dSafeSqRad = dSqRad - 2 * m_Tool.GetRadius() * EPS_SMALL ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dSafeRadius = CurrTool.GetRadius() - EPS_SMALL ; + double dSqRad = CurrTool.GetRadius() * CurrTool.GetRadius() ; + double dSafeSqRad = dSqRad - 2 * CurrTool.GetRadius() * EPS_SMALL ; // Studio delle simmetrie Point3d ptI = ( ptS.z < ptE.z ? ptS : ptE) ; @@ -1143,14 +1171,14 @@ VolZmap::CylBall_ZMilling( int nGrid, const Point3d & ptS, const Point3d & ptE, vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } - if ( m_Tool.GetType() == Tool::BALLMILL) + if ( CurrTool.GetType() == Tool::BALLMILL) - CompBall_Milling( nGrid, ptIT, ptFT, m_Tool.GetRadius()) ; + CompBall_Milling( nGrid, ptIT, ptFT, CurrTool.GetRadius(), CurrTool.GetToolNum()) ; return true ; } @@ -1161,15 +1189,20 @@ VolZmap::CylBall_ZMilling( int nGrid, const Point3d & ptS, const Point3d & ptE, bool VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dMinRad = min( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; - double dMaxRad = max( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dMinRad = min( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; + double dMaxRad = max( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; double dDeltaRad = dMaxRad - dMinRad ; double dSqMinRad = dMinRad * dMinRad ; double dSqMaxRad = dMaxRad * dMaxRad ; @@ -1178,17 +1211,17 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c Point3d ptO( ptS.x, ptS.y, 0) ; // Quote massime e minime dell'utensile durante il moto - double dZMax = max( max( ptS.z, ptS.z - vtToolDir.z * m_Tool.GetHeigth()), - max( ptE.z, ptE.z - vtToolDir.z * m_Tool.GetHeigth())) ; - double dZMin = min( min( ptS.z, ptS.z - vtToolDir.z * m_Tool.GetHeigth()), - min( ptE.z, ptE.z - vtToolDir.z * m_Tool.GetHeigth())) ; + double dZMax = max( max( ptS.z, ptS.z - vtToolDir.z * CurrTool.GetHeigth()), + max( ptE.z, ptE.z - vtToolDir.z * CurrTool.GetHeigth())) ; + double dZMin = min( min( ptS.z, ptS.z - vtToolDir.z * CurrTool.GetHeigth()), + min( ptE.z, ptE.z - vtToolDir.z * CurrTool.GetHeigth())) ; // Parametri geometrici per // determinare il vettore normale - double dL = m_Tool.GetTipHeigth() * dMaxRad / dDeltaRad ; + double dL = CurrTool.GetTipHeigth() * dMaxRad / dDeltaRad ; // Trapano - if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) { + if ( CurrTool.GetTipRadius() < CurrTool.GetRadius()) { // Ciclo sui punti for ( int i = nStartI ; i <= nEndI ; ++ i) { @@ -1204,7 +1237,7 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c if ( dSqDist < dSqMinRad) - SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, -Z_AX, CurrTool.GetToolNum()) ; else if ( dSqDist < dSqMaxRad) { @@ -1213,7 +1246,7 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c if ( vtToolDir.z > 0) { - double dMin = dZMin + m_Tool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; + double dMin = dZMin + CurrTool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; double dMax = dZMax ; Point3d ptInt( dX, dY, dMin) ; @@ -1222,12 +1255,12 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c Vector3d vtNmin = ptPn - ptInt ; vtNmin.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, -Z_AX, CurrTool.GetToolNum()) ; } else { double dMin = dZMin ; - double dMax = dZMax - m_Tool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; + double dMax = dZMax - CurrTool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; Point3d ptInt( dX, dY, dMax) ; Point3d ptPn( ptO.x, ptO.y, dMax - dl) ; @@ -1235,7 +1268,7 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c Vector3d vtNmax = ptPn - ptInt ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -1258,7 +1291,7 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c double dSqDist = vtC.SqLenXY() ; if ( dSqDist < dSqMinRad) { - SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, -Z_AX, CurrTool.GetToolNum()) ; } else if ( dSqDist < dSqMaxRad) { @@ -1268,7 +1301,7 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c if ( vtToolDir.z > 0) { double dMin = dZMin ; - double dMax = dZMax - dStemHeigth - m_Tool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; + double dMax = dZMax - dStemHeigth - CurrTool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; Point3d ptInt( dX, dY, dMax) ; Point3d ptPn( ptO.x, ptO.y, dMax - dl) ; @@ -1276,11 +1309,11 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c Vector3d vtNmax = ptPn - ptInt ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, vtNmax, CurrTool.GetToolNum()) ; } else { - double dMin = dZMin + dStemHeigth + m_Tool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; + double dMin = dZMin + dStemHeigth + CurrTool.GetTipHeigth() * ( dr - dMinRad) / dDeltaRad ; double dMax = dZMax ; Point3d ptInt( dX, dY, dMin) ; @@ -1289,7 +1322,7 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c Vector3d vtNmin = ptPn - ptInt ; vtNmin.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, -Z_AX, CurrTool.GetToolNum()) ; } } } @@ -1302,15 +1335,20 @@ VolZmap::Conus_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, c bool VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d & vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dMinRad = min( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; - double dMaxRad = max( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dMinRad = min( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; + double dMaxRad = max( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; double dDeltaRad = dMaxRad - dMinRad ; double dSqMinRad = dMinRad * dMinRad ; double dSqMaxRad = dMaxRad * dMaxRad ; @@ -1333,13 +1371,13 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const double dBaseZ = ptS.z ; double dStemZ = ptS.z - vtToolDir.z * dStemHeigth ; - double dTipZ = ptS.z - vtToolDir.z * m_Tool.GetHeigth() ; + double dTipZ = ptS.z - vtToolDir.z * CurrTool.GetHeigth() ; // Lunghezza cono - double dL = m_Tool.GetTipHeigth() * dMaxRad / dDeltaRad ; + double dL = CurrTool.GetTipHeigth() * dMaxRad / dDeltaRad ; // Punta a trapano - if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) { + if ( CurrTool.GetTipRadius() < CurrTool.GetRadius()) { Vector3d vtV = vtToolDir ; @@ -1372,7 +1410,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const double dMin = min( dBaseZ, dTipZ) ; double dMax = max( dBaseZ, dTipZ) ; - SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, -Z_AX, CurrTool.GetToolNum()) ; } else { @@ -1389,7 +1427,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Point3d ptInt( dX, dY, dMin) ; Vector3d vtU = ( ptInt - ptVS) - ( ptInt - ptVS) * vtV * vtV ; vtU.Normalize() ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; vtNmax = - Z_AX ; } @@ -1399,10 +1437,10 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVS) - ( ptInt - ptVS) * vtV * vtV ; vtU.Normalize() ; vtNmin = Z_AX ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } else if ( dP1 <= dLen) { @@ -1415,7 +1453,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Point3d ptInt( dX, dY, dMin) ; Vector3d vtU = ( ptInt - ptVtemp) - ( ptInt - ptVtemp) * vtV * vtV ; vtU.Normalize() ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; vtNmax = - Z_AX ; } @@ -1425,11 +1463,11 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVtemp) - ( ptInt - ptVtemp) * vtV * vtV ; vtU.Normalize() ; vtNmin = Z_AX ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } else { @@ -1443,7 +1481,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Point3d ptInt( dX, dY, dMin) ; Vector3d vtU = ( ptInt - ptVE) - ( ptInt - ptVE) * vtV * vtV ; vtU.Normalize() ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; vtNmax = -Z_AX ; } @@ -1453,11 +1491,11 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVE) - ( ptInt - ptVE) * vtV * vtV ; vtU.Normalize() ; vtNmin = Z_AX ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -1470,8 +1508,8 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtV = - vtToolDir ; - Point3d ptVS = ptS - vtToolDir * ( m_Tool.GetHeigth() - dL) ; - Point3d ptVE = ptE - vtToolDir * ( m_Tool.GetHeigth() - dL) ; + Point3d ptVS = ptS - vtToolDir * ( CurrTool.GetHeigth() - dL) ; + Point3d ptVE = ptE - vtToolDir * ( CurrTool.GetHeigth() - dL) ; for ( int i = nStartI ; i <= nEndI ; ++ i) { for( int j = nStartJ ; j <= nEndJ ; ++ j) { @@ -1497,7 +1535,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const ( abs( dP2) < dSafeMinRad && dP1 >= 0 && dP1 <= dLen)) { double dMin = min( dBaseZ, dTipZ) ; double dMax = max( dBaseZ, dTipZ) ; - SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, Z_AX, -Z_AX, CurrTool.GetToolNum()) ; } else { @@ -1513,7 +1551,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVS) - ( ptInt - ptVS) * vtV * vtV ; vtU.Normalize() ; vtNmin = Z_AX ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } @@ -1522,10 +1560,10 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVS) - ( ptInt - ptVS) * vtV * vtV ; vtU.Normalize() ; vtNmax = -Z_AX ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } else if ( dP1 <= dLen) { @@ -1539,7 +1577,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVtemp) - ( ptInt - ptVtemp) * vtV * vtV ; vtU.Normalize() ; vtNmin = Z_AX ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } @@ -1548,11 +1586,11 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVtemp) - ( ptInt - ptVtemp) * vtV * vtV ; vtU.Normalize() ; vtNmax = -Z_AX ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } else { @@ -1565,7 +1603,7 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVE) - ( ptInt - ptVE) * vtV * vtV ; vtU.Normalize() ; vtNmin = Z_AX ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } @@ -1574,11 +1612,11 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const Vector3d vtU = ( ptInt - ptVE) - ( ptInt - ptVE) * vtV * vtV ; vtU.Normalize() ; vtNmax = -Z_AX ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -1592,20 +1630,27 @@ VolZmap::Conus_ZPerp( int nGrid, const Point3d & ptS, const Point3d & ptE, const bool VolZmap::Conus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { - double dStemH = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; - CompCyl_ZMilling( nGrid, ptS, ptE, vtToolDir, dStemH, m_Tool.GetRadius()) ; + double dStemH = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; - if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) { + CompCyl_ZMilling( nGrid, ptS, ptE, vtToolDir, dStemH, CurrTool.GetRadius(), CurrTool.GetToolNum()) ; + + if ( CurrTool.GetTipRadius() < CurrTool.GetRadius()) { Point3d ptSC = ptS - vtToolDir * dStemH ; Point3d ptEC = ptE - vtToolDir * dStemH ; - CompConus_ZMilling( nGrid, ptSC, ptEC, vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; + CompConus_ZMilling( nGrid, ptSC, ptEC, vtToolDir, + CurrTool.GetTipHeigth(), CurrTool.GetRadius(), CurrTool.GetTipRadius(), V_NULL, V_NULL, CurrTool.GetToolNum()) ; } else { - Point3d ptSC = ptS - vtToolDir * m_Tool.GetHeigth() ; - Point3d ptEC = ptE - vtToolDir * m_Tool.GetHeigth() ; - CompConus_ZMilling( nGrid, ptSC, ptEC, - vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetTipRadius(), m_Tool.GetRadius()) ; + Point3d ptSC = ptS - vtToolDir * CurrTool.GetHeigth() ; + Point3d ptEC = ptE - vtToolDir * CurrTool.GetHeigth() ; + CompConus_ZMilling( nGrid, ptSC, ptEC, - vtToolDir, + CurrTool.GetTipHeigth(), CurrTool.GetTipRadius(), CurrTool.GetRadius(), V_NULL, V_NULL, CurrTool.GetToolNum()) ; } return true ; @@ -1617,6 +1662,11 @@ VolZmap::Conus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, cons bool VolZmap::Mrt_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Proiezione della traiettoria sul piano dei movimenti possibili Vector3d vtMoveOnP = ( ptE - ptS) * vtToolDir * vtToolDir ; Point3d ptEOnP = ptS + vtMoveOnP ; @@ -1624,23 +1674,23 @@ VolZmap::Mrt_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const // Scompongo la mortasatrice in solidi semplici // Parallelepipedo di base - double dLenX = m_Tool.GetMrtChsWidth() ; - double dLenY = m_Tool.GetMrtChsThickness() ; - double dLenZ = m_Tool.GetHeigth() - m_Tool.GetCornRadius() ; + double dLenX = CurrTool.GetMrtChsWidth() ; + double dLenY = CurrTool.GetMrtChsThickness() ; + double dLenZ = CurrTool.GetHeigth() - CurrTool.GetCornRadius() ; - CompPar_ZDrilling( nGrid, dLenX, dLenY, dLenZ, ptS, ptEOnP, vtToolDir, vtAux) ; + CompPar_ZDrilling( nGrid, dLenX, dLenY, dLenZ, ptS, ptEOnP, vtToolDir, vtAux, CurrTool.GetToolNum()) ; // Se la punta è di tipo bull-nose - if ( abs( m_Tool.GetMrtChsWidth() - 2 * m_Tool.GetCornRadius()) > EPS_SMALL) { + if ( abs( CurrTool.GetMrtChsWidth() - 2 * CurrTool.GetCornRadius()) > EPS_SMALL) { // Parallelepipedo di punta Point3d ptTipS = ptS - dLenZ * vtToolDir ; Point3d ptTipE = ptEOnP - dLenZ * vtToolDir ; - dLenX = abs( m_Tool.GetMrtChsWidth() - 2 * m_Tool.GetCornRadius()) ; - dLenZ = m_Tool.GetCornRadius() ; + dLenX = abs( CurrTool.GetMrtChsWidth() - 2 * CurrTool.GetCornRadius()) ; + dLenZ = CurrTool.GetCornRadius() ; - CompPar_ZDrilling( nGrid, dLenX, dLenY, dLenZ, ptTipS, ptTipE, vtToolDir, vtAux) ; + CompPar_ZDrilling( nGrid, dLenX, dLenY, dLenZ, ptTipS, ptTipE, vtToolDir, vtAux, CurrTool.GetToolNum()) ; Vector3d vtVOnP = vtToolDir ^ vtAux ; @@ -1650,8 +1700,8 @@ VolZmap::Mrt_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptSplus = ptTipS + ( 0.5 * dLenX) * vtVOnP + 0.5 * dLenY * vtAux ; Point3d ptEplus = ptTipE + ( 0.5 * dLenX) * vtVOnP + 0.5 * dLenY * vtAux ; - CompCyl_Milling( nGrid, ptSminus, ptEminus, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; - CompCyl_Milling( nGrid, ptSplus, ptEplus, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptSminus, ptEminus, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; + CompCyl_Milling( nGrid, ptSplus, ptEplus, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; } // se la punta è di tipo sfera @@ -1660,7 +1710,7 @@ VolZmap::Mrt_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptCylS = ptS - dLenZ * vtToolDir + 0.5 * dLenY * vtAux ; Point3d ptCylE = ptEOnP - dLenZ * vtToolDir + 0.5 * dLenY * vtAux ; - CompCyl_Milling( nGrid, ptCylS, ptCylE, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptCylS, ptCylE, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; } return true ; @@ -1673,8 +1723,13 @@ VolZmap::Mrt_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::Chs_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { - CompPar_ZDrilling( nGrid, m_Tool.GetMrtChsWidth(), m_Tool.GetMrtChsThickness(), m_Tool.GetHeigth(), - ptS, ptE, vtToolDir, vtAux) ; + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + + CompPar_ZDrilling( nGrid, CurrTool.GetMrtChsWidth(), CurrTool.GetMrtChsThickness(), CurrTool.GetHeigth(), + ptS, ptE, vtToolDir, vtAux, CurrTool.GetToolNum()) ; return true ; } @@ -1682,13 +1737,18 @@ VolZmap::Chs_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::Chs_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Proiezione della traiettoria sul piano dei moti possibili Point3d ptSp = ptS ; Vector3d vtMoveOnP = ( ptE - ptS) - ( ptE - ptS) * vtToolDir * vtToolDir ; Point3d ptEp = ptS + vtMoveOnP ; - CompPar_ZMilling( nGrid, m_Tool.GetMrtChsWidth(), m_Tool.GetMrtChsThickness(), m_Tool.GetHeigth(), - ptSp, ptEp, vtToolDir, vtAux) ; + CompPar_ZMilling( nGrid, CurrTool.GetMrtChsWidth(), CurrTool.GetMrtChsThickness(), CurrTool.GetHeigth(), + ptSp, ptEp, vtToolDir, vtAux, CurrTool.GetToolNum()) ; return true ; } @@ -1698,18 +1758,23 @@ VolZmap::Chs_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::GenTool_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Descrizione geometrica del moto Point3d ptI = ptS ; Point3d ptF = ptE ; Vector3d vtMove = ptE - ptS ; // Vettore delle normali agli archi - const VCT3DVECTOR& vArcNorm = m_Tool.GetArcNormalVec() ; + const VCT3DVECTOR& vArcNorm = CurrTool.GetArcNormalVec() ; // Poinché l'asse utensile è parallelo all'asse Z, definisco un sistema di // riferimento ad hoc in cui le normali agli archi giacciano nel piano XZ. Frame3d frNormFrame ; frNormFrame.Set( ORIG, X_AX, - Z_AX, Y_AX) ; // Ciclo sulle curve - const CurveComposite& ToolProfile = m_Tool.GetApproxOutline() ; + const CurveComposite& ToolProfile = CurrTool.GetApproxOutline() ; int i = - 1 ; const ICurve* pCurve = ToolProfile.GetCurve( ++ i) ; while ( pCurve != nullptr) { @@ -1737,13 +1802,13 @@ VolZmap::GenTool_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) { double dRadius = ptStart.x ; if ( dRadius > 10 * EPS_SMALL) - CompCyl_ZDrilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius) ; + CompCyl_ZDrilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, CurrTool.GetToolNum()) ; } // Se X crescente, è un cono con vettore equiverso a quello dell'utensile else if ( ptStart.x > ptEnd.x) { double dMaxRad = ptStart.x ; double dMinRad = ptEnd.x ; - CompConus_ZDrilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, vtNormSt, vtNormEn) ; + CompConus_ZDrilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, vtNormSt, vtNormEn, CurrTool.GetToolNum()) ; } // Se X decrescente, è un cono con vettore opposto a quello dell'utensile else if ( ptStart.x < ptEnd.x) { @@ -1753,7 +1818,7 @@ VolZmap::GenTool_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c Point3d ptFn = ptIn + vtMove ; vtNormEn.z *= -1 ; vtNormSt.z *= -1 ; - CompConus_ZDrilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, vtNormEn, vtNormSt) ; + CompConus_ZDrilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, vtNormEn, vtNormSt, CurrTool.GetToolNum()) ; } } } @@ -1770,7 +1835,7 @@ VolZmap::GenTool_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ; Point3d ptCenE = ptCenS + vtMove ; // Eseguo l'asportazione del materiale - CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ; + CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius, CurrTool.GetToolNum()) ; // aggiorno l'altezza dHeight = abs( ptStart.y - ptEnd.y) ; } @@ -1790,18 +1855,23 @@ VolZmap::GenTool_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c bool VolZmap::GenTool_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Descrizione geometrica del moto Point3d ptI = ptS ; Point3d ptF = ptE ; Vector3d vtMove = ptE - ptS ; // Vettore delle normali agli archi - const VCT3DVECTOR& vArcNorm = m_Tool.GetArcNormalVec() ; + const VCT3DVECTOR& vArcNorm = CurrTool.GetArcNormalVec() ; // Poinché l'asse utensile è parallelo all'asse Z, definisco un sistema di // riferimento ad hoc in cui le normali agli archi giacciano nel piano XZ. Frame3d frNormFrame; frNormFrame.Set( ORIG, X_AX, -Z_AX, Y_AX) ; // Ciclo sulle curve del profilo utensile - const CurveComposite& ToolProfile = m_Tool.GetApproxOutline() ; + const CurveComposite& ToolProfile = CurrTool.GetApproxOutline() ; int i = - 1 ; const ICurve* pCurve = ToolProfile.GetCurve( ++ i) ; while ( pCurve != nullptr) { @@ -1829,13 +1899,13 @@ VolZmap::GenTool_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) { double dRadius = ptStart.x ; if ( dRadius > 10 * EPS_SMALL) - CompCyl_ZMilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius) ; + CompCyl_ZMilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, CurrTool.GetToolNum()) ; } // Se X crescente, è un cono con vettore equiverso a quello dell'utensile else if ( ptStart.x > ptEnd.x) { double dMaxRad = ptStart.x ; double dMinRad = ptEnd.x ; - CompConus_ZMilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, vtNormSt, vtNormEn) ; + CompConus_ZMilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, vtNormSt, vtNormEn, CurrTool.GetToolNum()) ; } // Se X decrescente, è un cono con vettore opposto a quello dell'utensile else if ( ptStart.x < ptEnd.x) { @@ -1845,7 +1915,7 @@ VolZmap::GenTool_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Point3d ptFn = ptIn + vtMove ; vtNormEn.z *= -1 ; vtNormSt.z *= -1 ; - CompConus_ZMilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, vtNormEn, vtNormSt) ; + CompConus_ZMilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, vtNormEn, vtNormSt, CurrTool.GetToolNum()) ; } } } @@ -1862,7 +1932,7 @@ VolZmap::GenTool_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ; Point3d ptCenE = ptCenS + vtMove ; // Eseguo l'asportazione del materiale - CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ; + CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius, CurrTool.GetToolNum()) ; // aggiorno l'altezza dHeight = abs( ptStart.y - ptEnd.y) ; } @@ -1885,14 +1955,19 @@ VolZmap::GenTool_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co bool VolZmap::CylBall_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile e quota Z del movimento - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dSqRad = CurrTool.GetRadius() * CurrTool.GetRadius() ; double dZ = ptS.z ; // Vettore movimento e sua lunghezza @@ -1922,7 +1997,7 @@ VolZmap::CylBall_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, // Zona lavorata dalla parte cilindrica if ( dP1 > EPS_SMALL && dP1 < dStemHeigth + dLen - EPS_SMALL && - abs( dP2) < m_Tool.GetRadius()) { + abs( dP2) < CurrTool.GetRadius()) { double dH = sqrt( dSqRad - dP2 * dP2) ; double dMin = dZ - dH ; @@ -1939,11 +2014,11 @@ VolZmap::CylBall_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, vtMin.Normalize() ; vtMax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax, CurrTool.GetToolNum()) ; } // Se l'utensile è sferico sottraggo anche la punta - if ( m_Tool.GetType() == Tool::BALLMILL) + if ( CurrTool.GetType() == Tool::BALLMILL) if ( dSqLen < dSqRad) { // LA SOLUZIONE MOMENTANEA è CREARE UTENSILE GENERICO SE LO STELO è PIù CORTO DEL RAGGIO double dH = sqrt( dSqRad - dSqLen) ; @@ -1956,7 +2031,7 @@ VolZmap::CylBall_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, vtMin.Normalize() ; vtMax.Normalize() ; - SubtractIntervals( nGrid, i, j, dZ - dH, dZ + dH, vtMin, vtMax) ; + SubtractIntervals( nGrid, i, j, dZ - dH, dZ + dH, vtMin, vtMax, CurrTool.GetToolNum()) ; } } } @@ -1967,15 +2042,20 @@ VolZmap::CylBall_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, bool VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d & vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ; - double dSafeSqRad = dSqRad - 2 * m_Tool.GetRadius() * EPS_SMALL ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dSqRad = CurrTool.GetRadius() * CurrTool.GetRadius() ; + double dSafeSqRad = dSqRad - 2 * CurrTool.GetRadius() * EPS_SMALL ; // Studio simmetrie del problema Point3d ptI = ( ptS.z <= ptE.z ? ptS : ptE) ; @@ -2010,15 +2090,15 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons // Vettori e punti determinanti i piani Vector3d vtP = vtMove ; // Se dLen < EPS_SMALL non si usa vtP.Rotate( vtToolDir, 0, 1) ; - Point3d ptUp = ptI + m_Tool.GetRadius() * ( vtP.z > 0 ? vtP : - vtP) ; - Point3d ptDw = ptI + m_Tool.GetRadius() * ( vtP.z > 0 ? - vtP : vtP) ; + Point3d ptUp = ptI + CurrTool.GetRadius() * ( vtP.z > 0 ? vtP : - vtP) ; + Point3d ptDw = ptI + CurrTool.GetRadius() * ( vtP.z > 0 ? - vtP : vtP) ; Vector3d vtPXY( vtP.x, vtP.y, 0) ; Vector3d vtUp = ptUp - ORIG ; double dDotUp = vtUp * vtP ; Vector3d vtDw = ptDw - ORIG ; double dDotDw = vtDw * vtP ; - double dSmall = m_Tool.GetRadius() * vtPXY.LenXY() ; + double dSmall = CurrTool.GetRadius() * vtPXY.LenXY() ; // Parte sferica double dCos = vtMove.z ; // vtMove.z > 0 : ptF.z >= ptI.z @@ -2043,8 +2123,8 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons Vector3d vtNmin, vtNmax ; if ( dP1 > EPS_SMALL && dP1 < dStemHeigth - EPS_SMALL && - dP2 > - m_Tool.GetRadius() + EPS_SMALL && - dP2 < m_Tool.GetRadius() - EPS_SMALL) { + dP2 > - CurrTool.GetRadius() + EPS_SMALL && + dP2 < CurrTool.GetRadius() - EPS_SMALL) { dInfZ = ptI.z - sqrt( dSqRad - dP2 * dP2) ; dSupZ = ptF.z + sqrt( dSqRad - dP2 * dP2) ; @@ -2058,10 +2138,10 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons vtNmin.Normalize() ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dInfZ, dSupZ, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dInfZ, dSupZ, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } - if ( m_Tool.GetType() == Tool::BALLMILL) { + if ( CurrTool.GetType() == Tool::BALLMILL) { if ( dP1 > dStemHeigth - 2 * EPS_SMALL && ( dP1 - dStemHeigth) * ( dP1 - dStemHeigth) + dP2 * dP2 < dSafeSqRad) { @@ -2077,7 +2157,7 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons vtNmin.Normalize() ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dInfZ, dSupZ, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dInfZ, dSupZ, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -2100,7 +2180,7 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons // Parte cilindrica if ( dP1 > EPS_SMALL && dP1 < dStemHeigth - EPS_SMALL) { - if ( dP2 > - m_Tool.GetRadius() && dP2 < dLenXY + m_Tool.GetRadius()) { + if ( dP2 > - CurrTool.GetRadius() && dP2 < dLenXY + CurrTool.GetRadius()) { Vector3d vtNmin, vtNmax ; @@ -2154,16 +2234,16 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dInfZ, dSupZ, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dInfZ, dSupZ, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } // Se l'utensile è ball-end sottraggo la punta - if ( m_Tool.GetType() == Tool::BALLMILL) { + if ( CurrTool.GetType() == Tool::BALLMILL) { if ( ( ( dP1 - dStemHeigth) * ( dP1 - dStemHeigth) + dP2 * dP2 < dSqRad || ( dP1 - dStemHeigth) * ( dP1 - dStemHeigth) + ( dP2 - dLenXY) * ( dP2 - dLenXY) < dSqRad || - ( dP2 > 0 && dP2 < dLenXY && dP1 < m_Tool.GetHeigth())) && ( dP1 > dStemHeigth - 2 * EPS_SMALL)) { + ( dP2 > 0 && dP2 < dLenXY && dP1 < CurrTool.GetHeigth())) && ( dP1 > dStemHeigth - 2 * EPS_SMALL)) { double dSqRoot = sqrt( dSqRad - ( dP1 - dStemHeigth) * ( dP1 - dStemHeigth)) ; double dP2_0 = dCos * dSqRoot ; @@ -2217,7 +2297,7 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -2230,13 +2310,18 @@ VolZmap::CylBall_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, cons bool VolZmap::CylBall_XYMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { - if ( m_Tool.GetType() == Tool::CYLMILL) - return CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, m_Tool.GetHeigth(), m_Tool.GetRadius(), false, false) ; + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; - else if ( m_Tool.GetType() == Tool::BALLMILL) { - double dHei = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dHei, m_Tool.GetRadius(), false, false) ; - CompBall_Milling( nGrid, ptS - dHei * vtToolDir, ptE - dHei * vtToolDir, m_Tool.GetRadius()) ; + if ( CurrTool.GetType() == Tool::CYLMILL) + return CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, CurrTool.GetHeigth(), CurrTool.GetRadius(), false, false, CurrTool.GetToolNum()) ; + + else if ( CurrTool.GetType() == Tool::BALLMILL) { + double dHei = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dHei, CurrTool.GetRadius(), false, false, CurrTool.GetToolNum()) ; + CompBall_Milling( nGrid, ptS - dHei * vtToolDir, ptE - dHei * vtToolDir, CurrTool.GetRadius(), CurrTool.GetToolNum()) ; return true ; } @@ -2250,38 +2335,43 @@ VolZmap::CylBall_XYMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c bool VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dMinRad = min( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; - double dMaxRad = max( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dMinRad = min( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; + double dMaxRad = max( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; double dDeltaRad = dMaxRad - dMinRad ; // Geometria del moto double dLenXY = ( ptE - ptS).LenXY() ; Point3d ptI = ( vtToolDir * ( ptE - ptS) < 0 ? ptS : ptE) ; - double dMatStemLen = ( m_Tool.GetRadius() > m_Tool.GetTipRadius() ? dStemHeigth + dLenXY : dStemHeigth) ; - double dSqTipRad = m_Tool.GetTipRadius() * m_Tool.GetTipRadius() ; - double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ; + double dMatStemLen = ( CurrTool.GetRadius() > CurrTool.GetTipRadius() ? dStemHeigth + dLenXY : dStemHeigth) ; + double dSqTipRad = CurrTool.GetTipRadius() * CurrTool.GetTipRadius() ; + double dSqRad = CurrTool.GetRadius() * CurrTool.GetRadius() ; // Determinazione del vertice del cono - double dL = m_Tool.GetTipHeigth() * dMaxRad / dDeltaRad ; + double dL = CurrTool.GetTipHeigth() * dMaxRad / dDeltaRad ; Point3d ptV ; // Vertice Vector3d vtV ; // Vettore riferimento con origine nel vertice - if ( m_Tool.GetRadius() > m_Tool.GetTipRadius()) { + if ( CurrTool.GetRadius() > CurrTool.GetTipRadius()) { vtV = vtToolDir ; ptV = ( vtToolDir * ( ptE - ptS) < 0 ? ptE : ptS) - vtToolDir * ( dStemHeigth + dL) ; } else { vtV = - vtToolDir ; - ptV = ( vtToolDir * ( ptE - ptS) < 0 ? ptS : ptE) - vtToolDir * ( m_Tool.GetHeigth() - dL) ; + ptV = ( vtToolDir * ( ptE - ptS) < 0 ? ptS : ptE) - vtToolDir * ( CurrTool.GetHeigth() - dL) ; } // Sistema di riferimento sul piano @@ -2305,9 +2395,9 @@ VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co double dX1 = vtC * vtV1 ; double dX2 = vtC * vtV2 ; - double dr = m_Tool.GetRadius() + ( dX1 - dMatStemLen) * ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) / m_Tool.GetTipHeigth() ; + double dr = CurrTool.GetRadius() + ( dX1 - dMatStemLen) * ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) / CurrTool.GetTipHeigth() ; - if ( dX1 > EPS_SMALL && dX1 < dMatStemLen && abs( dX2) < m_Tool.GetRadius()) { + if ( dX1 > EPS_SMALL && dX1 < dMatStemLen && abs( dX2) < CurrTool.GetRadius()) { double dH = sqrt( dSqRad - dX2 * dX2) ; double dMin = ptI.z - dH ; @@ -2321,11 +2411,11 @@ VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Vector3d vtNmax = ( ptI - ptIntMax) - ( ptI - ptIntMax) * vtV1 * vtV1 ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, ptI.z - dH, ptI.z + dH, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, ptI.z - dH, ptI.z + dH, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } else if ( dX1 >= dMatStemLen && - dX1 < dMatStemLen + m_Tool.GetTipHeigth() - EPS_SMALL && + dX1 < dMatStemLen + CurrTool.GetTipHeigth() - EPS_SMALL && abs( dX2) < dr) { double dH = sqrt( dr * dr - dX2 * dX2) ; @@ -2335,22 +2425,22 @@ VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Point3d ptIntMin( dX, dY, dMin) ; Vector3d vtUmin = ( ptIntMin - ptV) - ( ptIntMin - ptV) * vtV * vtV ; vtUmin.Normalize() ; - Vector3d vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtUmin ; + Vector3d vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtUmin ; vtNmin.Normalize() ; Point3d ptIntMax( dX, dY, dMax) ; Vector3d vtUmax = ( ptIntMax - ptV) - ( ptIntMax - ptV) * vtV * vtV ; vtUmax.Normalize() ; - Vector3d vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtUmax ; + Vector3d vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtUmax ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } - if ( m_Tool.GetTipRadius() >= m_Tool.GetRadius()) { + if ( CurrTool.GetTipRadius() >= CurrTool.GetRadius()) { - if ( dX1 > dMatStemLen + m_Tool.GetTipHeigth() - 2 * EPS_SMALL && - dX1 < dMatStemLen + m_Tool.GetTipHeigth() + dLenXY - EPS_SMALL && + if ( dX1 > dMatStemLen + CurrTool.GetTipHeigth() - 2 * EPS_SMALL && + dX1 < dMatStemLen + CurrTool.GetTipHeigth() + dLenXY - EPS_SMALL && abs( dX2) < dSqTipRad) { double dH = sqrt( dSqTipRad - dX2 * dX2) ; @@ -2365,7 +2455,7 @@ VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Vector3d vtNmax = ( ptI - ptIntMax) - ( ptI - ptIntMax) * vtV1 * vtV1 ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, ptI.z - dH, ptI.z + dH, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, ptI.z - dH, ptI.z + dH, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -2377,16 +2467,21 @@ VolZmap::Conus_XYDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co bool VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestToolBBox( nGrid, ptS, ptE, vtToolDir, nStartI, nStartJ, nEndI, nEndJ)) return true ; // Parametri geometrici dell'utensile - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; - double dMinRad = min( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; - double dMaxRad = max( m_Tool.GetRadius(), m_Tool.GetTipRadius()) ; - double dSqRad = m_Tool.GetRadius() * m_Tool.GetRadius() ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + double dMinRad = min( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; + double dMaxRad = max( CurrTool.GetRadius(), CurrTool.GetTipRadius()) ; + double dSqRad = CurrTool.GetRadius() * CurrTool.GetRadius() ; double dDeltaRad = dMaxRad - dMinRad ; // Studio delle simmetrie del moto @@ -2408,10 +2503,10 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const vtMove.Normalize() ; // Riferimento coni - double dL = m_Tool.GetTipHeigth() * dMaxRad / dDeltaRad ; - Vector3d vtV = ( m_Tool.GetRadius() > m_Tool.GetTipRadius() ? vtToolDir : - vtToolDir) ; - Point3d ptVI = ptI - ( m_Tool.GetRadius() > m_Tool.GetTipRadius() ? dStemHeigth + dL : m_Tool.GetHeigth() - dL) * vtToolDir ; - Point3d ptVF = ptF - ( m_Tool.GetRadius() > m_Tool.GetTipRadius() ? dStemHeigth + dL : m_Tool.GetHeigth() - dL) * vtToolDir ; + double dL = CurrTool.GetTipHeigth() * dMaxRad / dDeltaRad ; + Vector3d vtV = ( CurrTool.GetRadius() > CurrTool.GetTipRadius() ? vtToolDir : - vtToolDir) ; + Point3d ptVI = ptI - ( CurrTool.GetRadius() > CurrTool.GetTipRadius() ? dStemHeigth + dL : CurrTool.GetHeigth() - dL) * vtToolDir ; + Point3d ptVF = ptF - ( CurrTool.GetRadius() > CurrTool.GetTipRadius() ? dStemHeigth + dL : CurrTool.GetHeigth() - dL) * vtToolDir ; // Movimento verticale if ( dLengthPathXY < EPS_SMALL) { @@ -2434,7 +2529,7 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const // Parte cilindrica if ( dP1 > EPS_SMALL && dP1 <= dStemHeigth && - dP2 > - m_Tool.GetRadius() + EPS_SMALL && dP2 < m_Tool.GetRadius() - EPS_SMALL) { + dP2 > - CurrTool.GetRadius() + EPS_SMALL && dP2 < CurrTool.GetRadius() - EPS_SMALL) { double dMin = dZI - sqrt( dSqRad - dP2 * dP2) ; double dMax = dZF + sqrt( dSqRad - dP2 * dP2) ; @@ -2447,15 +2542,15 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d vtNmax = - ( ptIntMax - ptF) + ( ptIntMax - ptF) * vtV1 * vtV1 ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } // Parte conica - else if ( dP1 > dStemHeigth && dP1 < m_Tool.GetHeigth() - EPS_SMALL && abs( dP2) < m_Tool.GetRadius() + - ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() - EPS_SMALL) { + else if ( dP1 > dStemHeigth && dP1 < CurrTool.GetHeigth() - EPS_SMALL && abs( dP2) < CurrTool.GetRadius() + + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() - EPS_SMALL) { double dr = dP2 ; - double dMr = m_Tool.GetRadius() + ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() ; + double dMr = CurrTool.GetRadius() + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() ; double dMin = dZI - sqrt( dMr * dMr - dr * dr) ; double dMax = dZF + sqrt( dMr * dMr - dr * dr) ; @@ -2463,16 +2558,16 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptIntMin( dX, dY, dMin) ; Vector3d vtUmin = ( ptIntMin - ptVI) - ( ptIntMin - ptVI) * vtV * vtV ; vtUmin.Normalize() ; - Vector3d vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtUmin ; + Vector3d vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtUmin ; vtNmin.Normalize() ; Point3d ptIntMax( dX, dY, dMax) ; Vector3d vtUmax = ( ptIntMax - ptVF) - ( ptIntMax - ptVF) * vtV * vtV ; vtUmax.Normalize() ; - Vector3d vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtUmax ; + Vector3d vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtUmax ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -2488,19 +2583,19 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d vtCross = vtToolDir ^ vtMove ; if ( vtCross.z < 0) vtCross = - vtCross ; // Punti di tangenza - Point3d ptUp = ptI - vtToolDir * dStemHeigth + m_Tool.GetRadius() * vtCross ; - Point3d ptDw = ptI - vtToolDir * dStemHeigth - m_Tool.GetRadius() * vtCross ; - double dSmallLength = m_Tool.GetRadius() * vtCross.LenXY() ; + Point3d ptUp = ptI - vtToolDir * dStemHeigth + CurrTool.GetRadius() * vtCross ; + Point3d ptDw = ptI - vtToolDir * dStemHeigth - CurrTool.GetRadius() * vtCross ; + double dSmallLength = CurrTool.GetRadius() * vtCross.LenXY() ; // Punti di tangenza in corrispondenza della punta - Point3d ptTipUp = ptI - vtToolDir * m_Tool.GetHeigth() + m_Tool.GetTipRadius() * vtCross ; - Point3d ptTipDw = ptI - vtToolDir * m_Tool.GetHeigth() - m_Tool.GetTipRadius() * vtCross ; + Point3d ptTipUp = ptI - vtToolDir * CurrTool.GetHeigth() + CurrTool.GetTipRadius() * vtCross ; + Point3d ptTipDw = ptI - vtToolDir * CurrTool.GetHeigth() - CurrTool.GetTipRadius() * vtCross ; Vector3d vtUpTan = ptTipUp - ptUp ; Vector3d vtDwTan = ptTipDw - ptDw ; Vector3d vtUpTanXY( vtUpTan.x, vtUpTan.y, 0) ; double dDeltaSmallAbs = abs( vtUpTanXY * vtV2) ; - double dDeltaSmall = ( m_Tool.GetRadius() > m_Tool.GetTipRadius() ? dDeltaSmallAbs : - dDeltaSmallAbs) ; + double dDeltaSmall = ( CurrTool.GetRadius() > CurrTool.GetTipRadius() ? dDeltaSmallAbs : - dDeltaSmallAbs) ; vtUpTan.Normalize() ; vtDwTan.Normalize() ; @@ -2540,7 +2635,7 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const // Parte cilindrica if ( dP1 > EPS_SMALL && dP1 <= dStemHeigth && // vedere se conviene dP1 < dStemHeigth + eps oppure dP1 <= dStemHeigth - dP2 > - m_Tool.GetRadius() && dP2 < dLengthPathXY + m_Tool.GetRadius()) { + dP2 > - CurrTool.GetRadius() && dP2 < dLengthPathXY + CurrTool.GetRadius()) { // Massimi if ( dP2 < - dSmallLength) { @@ -2582,20 +2677,20 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } // Parte conica - else if ( dP1 > dStemHeigth && dP1 < m_Tool.GetHeigth() - EPS_SMALL && - dP2 > - m_Tool.GetRadius() - ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() && - dP2 < m_Tool.GetRadius() + dLengthPathXY + - ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth()) { + else if ( dP1 > dStemHeigth && dP1 < CurrTool.GetHeigth() - EPS_SMALL && + dP2 > - CurrTool.GetRadius() - ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() && + dP2 < CurrTool.GetRadius() + dLengthPathXY + + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth()) { // Massimi - if ( dP2 < - dSmallLength + dDeltaSmall * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth()) { + if ( dP2 < - dSmallLength + dDeltaSmall * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth()) { double dr = dP2 ; - double dMr = m_Tool.GetRadius() + ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() ; + double dMr = CurrTool.GetRadius() + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() ; dMax = dZI + sqrt( dMr * dMr - dr * dr) ; @@ -2603,19 +2698,19 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d vtU = ( ptInt - ptVI) - ( ptInt - ptVI) * vtV * vtV ; vtU.Normalize() ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } else if ( dP2 < dLengthPathXY - dSmallLength + - dDeltaSmall * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth()) { + dDeltaSmall * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth()) { dMax = ( dDotUp - dX * vtUpCross.x - dY * vtUpCross.y) / vtUpCross.z ; vtNmax = vtUpCross ; } else { double dr = dP2 - dLengthPathXY ; - double dMr = m_Tool.GetRadius() + ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() ; + double dMr = CurrTool.GetRadius() + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() ; dMax = dZF + sqrt( dMr * dMr - dr * dr) ; @@ -2623,15 +2718,15 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d vtU = ( ptInt - ptVF) - ( ptInt - ptVF) * vtV * vtV ; vtU.Normalize() ; - vtNmax = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmax = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmax.Normalize() ; } // Minimi - if ( dP2 < dSmallLength - dDeltaSmall * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth()) { + if ( dP2 < dSmallLength - dDeltaSmall * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth()) { double dr = dP2 ; - double dMr = m_Tool.GetRadius() + ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() ; + double dMr = CurrTool.GetRadius() + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() ; dMin = dZI - sqrt( dMr * dMr - dr * dr) ; @@ -2639,11 +2734,11 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d vtU = ( ptInt - ptVI) - ( ptInt - ptVI) * vtV * vtV ; vtU.Normalize() ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; } - else if ( dP2 < dLengthPathXY + dSmallLength - dDeltaSmall * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth()) { + else if ( dP2 < dLengthPathXY + dSmallLength - dDeltaSmall * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth()) { dMin = ( dDotDw - dX * vtDwCross.x - dY * vtDwCross.y) / vtDwCross.z ; vtNmin = vtDwCross ; } @@ -2651,7 +2746,7 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const else { double dr = dP2 - dLengthPathXY ; - double dMr = m_Tool.GetRadius() + ( m_Tool.GetTipRadius() - m_Tool.GetRadius()) * ( dP1 - dStemHeigth) / m_Tool.GetTipHeigth() ; + double dMr = CurrTool.GetRadius() + ( CurrTool.GetTipRadius() - CurrTool.GetRadius()) * ( dP1 - dStemHeigth) / CurrTool.GetTipHeigth() ; dMin = dZF - sqrt( dMr * dMr - dr * dr) ; @@ -2659,11 +2754,11 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d vtU = ( ptInt - ptVF) - ( ptInt - ptVF) * vtV * vtV ; vtU.Normalize() ; - vtNmin = dDeltaRad * vtV - m_Tool.GetTipHeigth() * vtU ; + vtNmin = dDeltaRad * vtV - CurrTool.GetTipHeigth() * vtU ; vtNmin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, CurrTool.GetToolNum()) ; } } } @@ -2675,20 +2770,29 @@ VolZmap::Conus_XYPerp( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::Conus_XYMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; - CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, true) ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; - if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) { + CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, CurrTool.GetRadius(), false, true, CurrTool.GetToolNum()) ; + + if ( CurrTool.GetTipRadius() < CurrTool.GetRadius()) { Point3d ptSTip = ptS - dStemHeigth * vtToolDir ; Point3d ptETip = ptE - dStemHeigth * vtToolDir ; - CompConus_Milling( nGrid, ptSTip, ptETip, vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetRadius(), m_Tool.GetTipRadius(), true, false) ; + CompConus_Milling( nGrid, ptSTip, ptETip, vtToolDir, + CurrTool.GetTipHeigth(), CurrTool.GetRadius(), CurrTool.GetTipRadius(), + true, false, V_NULL, V_NULL, CurrTool.GetToolNum()) ; } else { - Point3d ptSTip = ptS - m_Tool.GetHeigth() * vtToolDir ; - Point3d ptETip = ptE - m_Tool.GetHeigth() * vtToolDir ; - CompConus_Milling( nGrid, ptSTip, ptETip, - vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetTipRadius(), m_Tool.GetRadius(), false, true) ; + Point3d ptSTip = ptS - CurrTool.GetHeigth() * vtToolDir ; + Point3d ptETip = ptE - CurrTool.GetHeigth() * vtToolDir ; + CompConus_Milling( nGrid, ptSTip, ptETip, - vtToolDir, + CurrTool.GetTipHeigth(), CurrTool.GetTipRadius(), CurrTool.GetRadius(), + false, true, V_NULL, V_NULL, CurrTool.GetToolNum()) ; } return true ; @@ -2701,15 +2805,20 @@ VolZmap::Conus_XYMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, con bool VolZmap::CylBall_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Altezza cilindro - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; // Sottraggo cilindro - CompCyl_Drilling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, false) ; + CompCyl_Drilling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, CurrTool.GetRadius(), false, false, CurrTool.GetToolNum()) ; // Se è sfera la sottraggo - if ( m_Tool.GetType() == Tool::BALLMILL) { + if ( CurrTool.GetType() == Tool::BALLMILL) { Point3d ptSBall = ptS - dStemHeigth * vtToolDir ; Point3d ptEBall = ptE - dStemHeigth * vtToolDir ; - CompBall_Milling( nGrid, ptSBall, ptEBall, m_Tool.GetRadius()) ; + CompBall_Milling( nGrid, ptSBall, ptEBall, CurrTool.GetRadius(), CurrTool.GetToolNum()) ; } return true ; } @@ -2718,15 +2827,20 @@ VolZmap::CylBall_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co bool VolZmap::CylBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Altezza cilindro - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; // Sottraggo cilindro - CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, false) ; + CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, CurrTool.GetRadius(), false, false, CurrTool.GetToolNum()) ; // Se è sfera la sottraggo - if ( m_Tool.GetType() == Tool::BALLMILL) { + if ( CurrTool.GetType() == Tool::BALLMILL) { Point3d ptSBall = ptS - dStemHeigth * vtToolDir ; Point3d ptEBall = ptE - dStemHeigth * vtToolDir ; - CompBall_Milling( nGrid, ptSBall, ptEBall, m_Tool.GetRadius()) ; + CompBall_Milling( nGrid, ptSBall, ptEBall, CurrTool.GetRadius(), CurrTool.GetToolNum()) ; } return true ; } @@ -2736,21 +2850,30 @@ VolZmap::CylBall_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con bool VolZmap::Conus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; - CompCyl_Drilling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, true) ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + + CompCyl_Drilling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, CurrTool.GetRadius(), false, true, CurrTool.GetToolNum()) ; // Trapano - if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) { + if ( CurrTool.GetTipRadius() < CurrTool.GetRadius()) { Point3d ptSCone = ptS - dStemHeigth * vtToolDir ; Point3d ptECone = ptE - dStemHeigth * vtToolDir ; - CompConus_Drilling( nGrid, ptSCone, ptECone, vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetRadius(), m_Tool.GetTipRadius(), true, false) ; + CompConus_Drilling( nGrid, ptSCone, ptECone, vtToolDir, + CurrTool.GetTipHeigth(), CurrTool.GetRadius(), CurrTool.GetTipRadius(), + true, false, V_NULL, V_NULL, CurrTool.GetToolNum()) ; } else { - Point3d ptSCone = ptS - m_Tool.GetHeigth() * vtToolDir ; - Point3d ptECone = ptE - m_Tool.GetHeigth() * vtToolDir ; - CompConus_Drilling( nGrid, ptSCone, ptECone, - vtToolDir, m_Tool.GetTipHeigth(), m_Tool.GetTipRadius(), m_Tool.GetRadius(), false, true) ; + Point3d ptSCone = ptS - CurrTool.GetHeigth() * vtToolDir ; + Point3d ptECone = ptE - CurrTool.GetHeigth() * vtToolDir ; + CompConus_Drilling( nGrid, ptSCone, ptECone, - vtToolDir, + CurrTool.GetTipHeigth(), CurrTool.GetTipRadius(), CurrTool.GetRadius(), + false, true, V_NULL, V_NULL, CurrTool.GetToolNum()) ; } return true ; @@ -2760,23 +2883,28 @@ VolZmap::Conus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, cons bool VolZmap::Conus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { - double dStemHeigth = m_Tool.GetHeigth() - m_Tool.GetTipHeigth() ; + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; - CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, m_Tool.GetRadius(), false, true) ; + double dStemHeigth = CurrTool.GetHeigth() - CurrTool.GetTipHeigth() ; + + CompCyl_Milling( nGrid, ptS, ptE, vtToolDir, dStemHeigth, CurrTool.GetRadius(), false, true, CurrTool.GetToolNum()) ; // Trapano - if ( m_Tool.GetTipRadius() < m_Tool.GetRadius()) { + if ( CurrTool.GetTipRadius() < CurrTool.GetRadius()) { Point3d ptSBall = ptS - dStemHeigth * vtToolDir ; Point3d ptEBall = ptE - dStemHeigth * vtToolDir ; - CompConus_Milling( nGrid, ptSBall, ptEBall, vtToolDir, m_Tool.GetTipHeigth(), - m_Tool.GetRadius(), m_Tool.GetTipRadius(), true, false) ; + CompConus_Milling( nGrid, ptSBall, ptEBall, vtToolDir, CurrTool.GetTipHeigth(), + CurrTool.GetRadius(), CurrTool.GetTipRadius(), true, false, V_NULL, V_NULL, CurrTool.GetToolNum()) ; } else { - Point3d ptSBall = ptS - m_Tool.GetHeigth() * vtToolDir ; - Point3d ptEBall = ptE - m_Tool.GetHeigth() * vtToolDir ; - CompConus_Milling( nGrid, ptSBall, ptEBall, - vtToolDir, m_Tool.GetTipHeigth(), - m_Tool.GetTipRadius(), m_Tool.GetRadius(), false, true) ; + Point3d ptSBall = ptS - CurrTool.GetHeigth() * vtToolDir ; + Point3d ptEBall = ptE - CurrTool.GetHeigth() * vtToolDir ; + CompConus_Milling( nGrid, ptSBall, ptEBall, - vtToolDir, CurrTool.GetTipHeigth(), + CurrTool.GetTipRadius(), CurrTool.GetRadius(), false, true, V_NULL, V_NULL, CurrTool.GetToolNum()) ; } return true ; @@ -2787,28 +2915,33 @@ VolZmap::Conus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::Mrt_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Proiezione della traiettoria sul piano dei movimenti possibili Point3d ptEOnP = ptS + ( ptE - ptS) * vtToolDir * vtToolDir ; // Scompongo la mortasatrice in solidi semplici // Parallelepipedo di base - double dLenX = m_Tool.GetMrtChsWidth() ; - double dLenY = m_Tool.GetMrtChsThickness() ; - double dLenZ = m_Tool.GetHeigth() - m_Tool.GetCornRadius() ; - CompPar_Drilling( nGrid, dLenX, dLenY, dLenZ, ptS, ptEOnP, vtToolDir, vtAux) ; + double dLenX = CurrTool.GetMrtChsWidth() ; + double dLenY = CurrTool.GetMrtChsThickness() ; + double dLenZ = CurrTool.GetHeigth() - CurrTool.GetCornRadius() ; + CompPar_Drilling( nGrid, dLenX, dLenY, dLenZ, ptS, ptEOnP, vtToolDir, vtAux, CurrTool.GetToolNum()) ; // Se la punta è di tipo bull-nose - if ( abs( m_Tool.GetMrtChsWidth() - 2 * m_Tool.GetCornRadius()) > EPS_SMALL) { + if ( abs( CurrTool.GetMrtChsWidth() - 2 * CurrTool.GetCornRadius()) > EPS_SMALL) { // Parallelepipedo di punta Point3d ptTipS = ptS - dLenZ * vtToolDir ; Point3d ptTipE = ptEOnP - dLenZ * vtToolDir ; - dLenX = abs( m_Tool.GetMrtChsWidth() - 2 * m_Tool.GetCornRadius()) ; - dLenZ = m_Tool.GetCornRadius() ; + dLenX = abs( CurrTool.GetMrtChsWidth() - 2 * CurrTool.GetCornRadius()) ; + dLenZ = CurrTool.GetCornRadius() ; - CompPar_Drilling( nGrid, dLenX, dLenY, dLenZ, ptTipS, ptTipE, vtToolDir, vtAux) ; + CompPar_Drilling( nGrid, dLenX, dLenY, dLenZ, ptTipS, ptTipE, vtToolDir, vtAux, CurrTool.GetToolNum()) ; Vector3d vtVOnP = vtToolDir ^ vtAux ; @@ -2818,8 +2951,8 @@ VolZmap::Mrt_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Point3d ptSplus = ptTipS + ( 0.5 * dLenX) * vtVOnP + 0.5 * dLenY * vtAux ; Point3d ptEplus = ptTipE + ( 0.5 * dLenX) * vtVOnP + 0.5 * dLenY * vtAux ; - CompCyl_Milling( nGrid, ptSminus, ptEminus, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; - CompCyl_Milling( nGrid, ptSplus, ptEplus, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptSminus, ptEminus, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; + CompCyl_Milling( nGrid, ptSplus, ptEplus, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; } // se la punta è di tipo sfera @@ -2827,7 +2960,7 @@ VolZmap::Mrt_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const // Cilindro Point3d ptCylS = ptS - dLenZ * vtToolDir + 0.5 * dLenY * vtAux ; Point3d ptCylE = ptEOnP - dLenZ * vtToolDir + 0.5 * dLenY * vtAux ; - CompCyl_Milling( nGrid, ptCylS, ptCylE, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptCylS, ptCylE, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; } return true ; @@ -2837,31 +2970,36 @@ VolZmap::Mrt_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Scompongo la mortasatrice in solidi semplici // Parallelepipedo di base - double dLenX = m_Tool.GetMrtChsWidth() ; - double dLenY = m_Tool.GetMrtChsThickness() ; - double dLenZ = m_Tool.GetHeigth() - m_Tool.GetCornRadius() ; + double dLenX = CurrTool.GetMrtChsWidth() ; + double dLenY = CurrTool.GetMrtChsThickness() ; + double dLenZ = CurrTool.GetHeigth() - CurrTool.GetCornRadius() ; Point3d ptBasePS = ptS - 0.5 * dLenZ * vtToolDir + 0.5 * dLenY * vtAux ; Point3d ptBasePE = ptE - 0.5 * dLenZ * vtToolDir + 0.5 * dLenY * vtAux ; - CompPar_Milling( nGrid, dLenX, dLenZ, dLenY, ptBasePS, ptBasePE, vtAux, vtToolDir) ; + CompPar_Milling( nGrid, dLenX, dLenZ, dLenY, ptBasePS, ptBasePE, vtAux, vtToolDir, CurrTool.GetToolNum()) ; // Se la punta è di tipo bull-nose - if ( abs( m_Tool.GetMrtChsWidth() - 2 * m_Tool.GetCornRadius()) > EPS_SMALL) { + if ( abs( CurrTool.GetMrtChsWidth() - 2 * CurrTool.GetCornRadius()) > EPS_SMALL) { // Parallelepipedo di punta Point3d ptTipPS = ptBasePS - 0.5 * dLenZ * vtToolDir ; Point3d ptTipPE = ptBasePE - 0.5 * dLenZ * vtToolDir ; - dLenX = abs( m_Tool.GetMrtChsWidth() - 2 * m_Tool.GetCornRadius()) ; - dLenZ = m_Tool.GetCornRadius() ; + dLenX = abs( CurrTool.GetMrtChsWidth() - 2 * CurrTool.GetCornRadius()) ; + dLenZ = CurrTool.GetCornRadius() ; ptTipPS -= 0.5 * dLenZ * vtToolDir ; ptTipPE -= 0.5 * dLenZ * vtToolDir ; - CompPar_Milling( nGrid, dLenX, dLenZ, dLenY, ptTipPS, ptTipPE, vtAux, vtToolDir) ; + CompPar_Milling( nGrid, dLenX, dLenZ, dLenY, ptTipPS, ptTipPE, vtAux, vtToolDir, CurrTool.GetToolNum()) ; // Cilindri // Vettore nel piano Vector3d vtVOnP = vtToolDir ^ vtAux ; @@ -2869,10 +3007,10 @@ VolZmap::Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const V vtVOnP *= -1 ; Point3d ptSminus = ptTipPS + 0.5 * dLenZ * vtToolDir - ( 0.5 * dLenX) * vtVOnP ; Point3d ptEminus = ptTipPE + 0.5 * dLenZ * vtToolDir - ( 0.5 * dLenX) * vtVOnP ; - CompCyl_Milling( nGrid, ptSminus, ptEminus, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptSminus, ptEminus, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; Point3d ptSplus = ptTipPS + 0.5 * dLenZ * vtToolDir + ( 0.5 * dLenX) * vtVOnP ; Point3d ptEplus = ptTipPE + 0.5 * dLenZ * vtToolDir + ( 0.5 * dLenX) * vtVOnP ; - CompCyl_Milling( nGrid, ptSplus, ptEplus, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptSplus, ptEplus, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; } // se la punta è di tipo sfera @@ -2880,7 +3018,7 @@ VolZmap::Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const V // Cilindro Point3d ptCylS = ptBasePS - 0.5 * dLenZ * vtToolDir ; Point3d ptCylE = ptBasePE - 0.5 * dLenZ * vtToolDir ; - CompCyl_Milling( nGrid, ptCylS, ptCylE, vtAux, dLenY, m_Tool.GetCornRadius(), false, false) ; + CompCyl_Milling( nGrid, ptCylS, ptCylE, vtAux, dLenY, CurrTool.GetCornRadius(), false, false, CurrTool.GetToolNum()) ; } return true ; @@ -2891,10 +3029,16 @@ VolZmap::Mrt_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const V bool VolZmap::Chs_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Proiezione della traiettoria sulla varietà del movimento Point3d ptProjE = ptS + ( ptE - ptS) * vtToolDir * vtToolDir ; - CompPar_Drilling( nGrid, m_Tool.GetMrtChsWidth(), m_Tool.GetMrtChsThickness(), m_Tool.GetHeigth(), ptS, ptProjE, vtToolDir, vtAux) ; + CompPar_Drilling( nGrid, CurrTool.GetMrtChsWidth(), CurrTool.GetMrtChsThickness(), CurrTool.GetHeigth(), + ptS, ptProjE, vtToolDir, vtAux, CurrTool.GetToolNum()) ; return true ; } @@ -2903,11 +3047,17 @@ VolZmap::Chs_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const bool VolZmap::Chs_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, const Vector3d& vtAux) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Proiezione della traiettoria sul piano dei movimenti possibili Vector3d vtMoveOnP = ( ptE - ptS) - ( ptE - ptS) * vtToolDir * vtToolDir ; Point3d ptProjE = ptS + vtMoveOnP ; - CompPar_Milling( nGrid, m_Tool.GetMrtChsWidth(), m_Tool.GetMrtChsThickness(), m_Tool.GetHeigth(), ptS, ptProjE, vtToolDir, vtAux) ; + CompPar_Milling( nGrid, CurrTool.GetMrtChsWidth(), CurrTool.GetMrtChsThickness(), CurrTool.GetHeigth(), + ptS, ptProjE, vtToolDir, vtAux, CurrTool.GetToolNum()) ; return true ; } @@ -2917,18 +3067,23 @@ VolZmap::Chs_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const V bool VolZmap::GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Descrizione geometrica del moto Point3d ptI = ptS ; Point3d ptF = ptE ; Vector3d vtMove = ptE - ptS ; // Vettore delle normali agli archi - const VCT3DVECTOR& vArcNorm = m_Tool.GetArcNormalVec() ; + const VCT3DVECTOR& vArcNorm = CurrTool.GetArcNormalVec() ; // Poinché l'asse utensile è parallelo all'asse Z, definisco un sistema di // riferimento ad hoc in cui le normali agli archi giacciano nel piano XZ. Frame3d frNormFrame ; frNormFrame.Set( ORIG, X_AX, -Z_AX, Y_AX) ; // Ciclo sulle curve del profilo - const CurveComposite& ToolProfile = m_Tool.GetApproxOutline() ; + const CurveComposite& ToolProfile = CurrTool.GetApproxOutline() ; int i = - 1 ; const ICurve* pPrevCurve = nullptr ; const ICurve* pCurve = ToolProfile.GetCurve( ++ i) ; @@ -2976,13 +3131,13 @@ VolZmap::GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) { double dRadius = ptStart.x ; if ( dRadius > 10 * EPS_SMALL) - CompCyl_Drilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT) ; + CompCyl_Drilling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT, CurrTool.GetToolNum()) ; } // Se X crescente, è un cono con vettore equiverso a quello dell'utensile else if ( ptStart.x > ptEnd.x) { double dMaxRad = ptStart.x ; double dMinRad = ptEnd.x ; - CompConus_Drilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, bTapB, bTapT, vtNormSt, vtNormEn) ; + CompConus_Drilling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, bTapB, bTapT, vtNormSt, vtNormEn, CurrTool.GetToolNum()) ; } // Se X decrescente, è un cono con vettore opposto a quello dell'utensile else if ( ptStart.x < ptEnd.x) { @@ -2992,7 +3147,7 @@ VolZmap::GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Point3d ptFn = ptIn + vtMove ; vtNormEn.z *= -1 ; vtNormSt.z *= -1 ; - CompConus_Drilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, bTapT, bTapB, vtNormEn, vtNormSt) ; + CompConus_Drilling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, bTapT, bTapB, vtNormEn, vtNormSt, CurrTool.GetToolNum()) ; } // Passo alla curva successiva pPrevCurve = pCurve ; @@ -3017,7 +3172,7 @@ VolZmap::GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ; Point3d ptCenE = ptCenS + vtMove ; // Eseguo l'asportazione del materiale - CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ; + CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius, CurrTool.GetToolNum()) ; // aggiorno l'altezza dHeight = abs( ptStart.y - ptEnd.y) ; // Passo alla curva successiva @@ -3037,18 +3192,23 @@ VolZmap::GenTool_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co bool VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir) { + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + // Descrizione geometrica del moto Point3d ptI = ptS ; Point3d ptF = ptE ; Vector3d vtMove = ptE - ptS ; // Vettore delle normali agli archi - const VCT3DVECTOR& vArcNorm = m_Tool.GetArcNormalVec() ; + const VCT3DVECTOR& vArcNorm = CurrTool.GetArcNormalVec() ; // Poinché l'asse utensile è parallelo all'asse Z, definisco un sistema di // riferimento ad hoc in cui le normali agli archi giacciano nel piano XZ. Frame3d frNormFrame ; frNormFrame.Set( ORIG, X_AX, -Z_AX, Y_AX) ; // Ciclo sulle curve del profilo - const CurveComposite& ToolProfile = m_Tool.GetApproxOutline() ; + const CurveComposite& ToolProfile = CurrTool.GetApproxOutline() ; int i = - 1 ; const ICurve* pPrevCurve = nullptr ; const ICurve* pCurve = ToolProfile.GetCurve( ++ i) ; @@ -3096,13 +3256,14 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con if ( abs( ptStart.x - ptEnd.x) < EPS_SMALL) { double dRadius = ptStart.x ; if ( dRadius > 10 * EPS_SMALL) - CompCyl_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT) ; + CompCyl_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dRadius, bTapB, bTapT, CurrTool.GetToolNum()) ; } // Se X crescente, è un cono con vettore equiverso a quello dell'utensile else if ( ptStart.x > ptEnd.x) { double dMaxRad = ptStart.x ; double dMinRad = ptEnd.x ; - CompConus_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, bTapB, bTapT, vtNormSt, vtNormEn) ; + CompConus_Milling( nGrid, ptI, ptF, vtToolDir, dHeight, dMaxRad, dMinRad, + bTapB, bTapT, vtNormSt, vtNormEn, CurrTool.GetToolNum()) ; } // Se X decrescente, è un cono con vettore opposto a quello dell'utensile else if ( ptStart.x < ptEnd.x) { @@ -3112,7 +3273,8 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con Point3d ptFn = ptIn + vtMove ; vtNormEn.z *= -1 ; vtNormSt.z *= -1 ; - CompConus_Milling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, bTapT, bTapB, vtNormEn, vtNormSt) ; + CompConus_Milling( nGrid, ptIn, ptFn, - vtToolDir, dHeight, dMaxRad, dMinRad, + bTapT, bTapB, vtNormEn, vtNormSt, CurrTool.GetToolNum()) ; } // Passo alla curva successiva pPrevCurve = pCurve ; @@ -3137,7 +3299,7 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con Point3d ptCenS = ptI - vtToolDir * ( ptStart.y - ptCen.y) ; Point3d ptCenE = ptCenS + vtMove ; // Eseguo l'asportazione del materiale - CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius) ; + CompBall_Milling( nGrid, ptCenS, ptCenE, dRadius, CurrTool.GetToolNum()) ; // aggiorno l'altezza dHeight = abs( ptStart.y - ptEnd.y) ; // Passo alla curva successiva @@ -3158,7 +3320,7 @@ VolZmap::GenTool_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, con //---------------------------------------------------------------------------- bool -VolZmap::CompCyl_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dRad) +VolZmap::CompCyl_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dRad, int nToolNum) { // Verifica sull'interferenza con lo Zmap int nStartI, nStartJ, nEndI, nEndJ ; @@ -3193,7 +3355,7 @@ VolZmap::CompCyl_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c // Se il punto si trova dentro il cerchio taglio if ( dSqLen < dSafeSqRad) - SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, -Z_AX) ; + SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, -Z_AX, nToolNum) ; } } return true ; @@ -3201,8 +3363,9 @@ VolZmap::CompCyl_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, c //---------------------------------------------------------------------------- bool -VolZmap::CompConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, - const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) +VolZmap::CompConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, + double dHei, double dMaxRad, double dMinRad, + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) { // Verifica sull'interferenza con lo Zmap int nStartI, nStartJ, nEndI, nEndJ ; @@ -3247,7 +3410,7 @@ VolZmap::CompConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, double dSqDist = vtC * vtC ; if ( dSqDist < dSqMinRad) { - SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, -Z_AX) ; + SubtractIntervals( nGrid, i, j, dZMin, dZMax, Z_AX, -Z_AX, nToolNum) ; } else if ( dSqDist < dSafeSqMaxRad) { // dSafeSqMaxRad è sperimentale @@ -3276,7 +3439,7 @@ VolZmap::CompConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, vtMin.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax, nToolNum) ; } else { @@ -3301,7 +3464,7 @@ VolZmap::CompConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, vtMax.Normalize() ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax, nToolNum) ; } } } @@ -3314,7 +3477,7 @@ VolZmap::CompConus_ZDrilling( int nGrid, const Point3d& ptS, const Point3d& ptE, bool VolZmap::CompPar_ZDrilling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) { Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; @@ -3350,7 +3513,7 @@ VolZmap::CompPar_ZDrilling( int nGrid, double dLenX, double dLenY, double dLenZ, double dR2 = vtR * vtV2 ; if ( abs( dR1) < 0.5 * dLenX && abs( dR2) < 0.5 * dLenY) - SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX, nToolNum) ; } } @@ -3361,7 +3524,8 @@ VolZmap::CompPar_ZDrilling( int nGrid, double dLenX, double dLenY, double dLenZ, //---------------------------------------------------------------------------- bool -VolZmap::CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dRad) +VolZmap::CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, + double dHei, double dRad, int nToolNum) { // Verifica sull'interferenza con lo Zmap int nStartI, nStartJ, nEndI, nEndJ ; @@ -3471,7 +3635,7 @@ VolZmap::CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co vtMin.Normalize() ; } } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax, nToolNum) ; } } } @@ -3480,8 +3644,9 @@ VolZmap::CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co //---------------------------------------------------------------------------- bool -VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, - const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) +VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, + double dHei, double dMaxRad, double dMinRad, + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) { int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestCompoBBox( nGrid, ptS, ptE, vtToolDir, dMaxRad, dMinRad, dHei, nStartI, nStartJ, nEndI, nEndJ)) @@ -3799,7 +3964,7 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, vtMax = vtM ; } - SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtMin, vtMax, nToolNum) ; } } } @@ -3810,7 +3975,7 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, bool // E' in realtà MillingPerp VolZmap::CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) { Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; @@ -3869,11 +4034,11 @@ VolZmap::CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ, // Asportazione materiale nella posizione iniziale if ( abs( dRS1) < 0.5 * dLenX && abs( dRS2) < 0.5 * dLenY) - SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX, nToolNum) ; // Asportazione materiale nella posizione finale if ( abs( dRE1) < 0.5 * dLenX && abs( dRE2) < 0.5 * dLenY) - SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX, nToolNum) ; // Asportazione materiale nel moto Vector3d vtR = ptC - ptOrigXY ; @@ -3882,7 +4047,7 @@ VolZmap::CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ, if ( dR2 > 0 && dR2 < dLenW2 && dR1 * dLenW2 > dDeltaW1 * dR2 && dR1 * dLenW2 < dLenW1 * dLenW2 + dDeltaW1 * dR2) - SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX) ; + SubtractIntervals( nGrid, i, j, dMinZ, dMaxZ, Z_AX, - Z_AX, nToolNum) ; } } return true ; @@ -3892,7 +4057,7 @@ VolZmap::CompPar_ZMilling( int nGrid, double dLenX, double dLenY, double dLenZ, //---------------------------------------------------------------------------- bool VolZmap::CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, - double dHei, double dRad, bool bTapB, bool bTapT) + double dHei, double dRad, bool bTapB, bool bTapT, int nToolNum) { // Verifico che il cilindro con il suo movimento intersechi la griglia int nStartI, nEndI, nStartJ, nEndJ ; @@ -3915,7 +4080,7 @@ VolZmap::CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co Point3d ptInt1, ptInt2 ; Vector3d vtN1, vtN2 ; if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dH, dRad, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -3926,7 +4091,7 @@ VolZmap::CompCyl_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co bool VolZmap::CompConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT, - const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) { int nStartI, nStartJ, nEndI, nEndJ ; if ( ! TestCompoBBox( nGrid, ptS, ptE, vtToolDir, dMaxRad, dMinRad, dHei, nStartI, nStartJ, nEndI, nEndJ)) @@ -3961,7 +4126,7 @@ VolZmap::CompConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, // Cilindro if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dH, dMaxRad, true, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Cono @@ -3987,7 +4152,7 @@ VolZmap::CompConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, vtN2 = - vtOriginalN2.z * vtToolDir - vtOriginalN2.x * vtL2 ; } } - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -3998,7 +4163,7 @@ VolZmap::CompConus_Drilling( int nGrid, const Point3d& ptS, const Point3d& ptE, bool VolZmap::CompPar_Drilling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) { Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; @@ -4034,7 +4199,7 @@ VolZmap::CompPar_Drilling( int nGrid, double dLenX, double dLenY, double dLenZ, Vector3d vtN1, vtN2 ; if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenX, dLenY, dLenZ + dLenMove, 0, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -4046,7 +4211,7 @@ VolZmap::CompPar_Drilling( int nGrid, double dLenX, double dLenY, double dLenZ, //---------------------------------------------------------------------------- bool VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, double dHei, double dRad, bool bTapB, bool bTapT) + const Vector3d& vtToolDir, double dHei, double dRad, bool bTapB, bool bTapT, int nToolNum) { // Verifica sull'interferenza utensile Zmap int nStartI, nStartJ, nEndI, nEndJ ; @@ -4083,7 +4248,7 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, // Cilindro iniziale CylFrame.ChangeOrig( ptITip) ; if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Cilindro finale:L'unica differenza rispetto a prima è l'origine @@ -4091,14 +4256,14 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, // il vettore che congiunge le due origini. CylFrame.ChangeOrig( ptITip + vtMove) ; if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dHei, dRad, bTapB, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Poliedro interno CylFrame.ChangeOrig( ptITip) ; if ( IntersLineMyPolyhedron( ptC, Z_AX, CylFrame, dOrtLen, 2 * dRad, dHei, dLongLen, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Se movimento non ortogonale all'asse cilindro ellittico di punta @@ -4106,7 +4271,7 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, CylFrame.ChangeOrig( ptITip) ; if ( IntersLineEllipticalCylinder( ptC, Z_AX, CylFrame, dRad, dLongLen, dOrtLen, bTapB, true, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Cilindro ellittico di base: L'unica differenza rispetto a prima è l'origine @@ -4115,7 +4280,7 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, CylFrame.ChangeOrig( ptITip + dHei * vtV1) ; if ( IntersLineEllipticalCylinder( ptC, Z_AX, CylFrame, dRad, dLongLen, dOrtLen, true, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -4127,7 +4292,7 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, bool VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, const Vector3d& vtToolDir, double dHei, double dMaxRad, double dMinRad, bool bTapB, bool bTapT, - const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR) + const Vector3d& vtArcNormMaxR, const Vector3d& vtArcNormMinR, int nToolNum) { // Verifico interferenza int nStartI, nStartJ, nEndI, nEndJ ; @@ -4238,7 +4403,7 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c vtN2.Normalize() ; } } - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Cono finale @@ -4266,7 +4431,7 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c vtN2.Normalize() ; } } - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Solido interno @@ -4429,7 +4594,7 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c ptInt2.ToGlob( PolyFrame) ; vtN2.ToGlob( PolyFrame) ; - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Se movimento non ortogonale all'asse sottraggo i cilindri ellittici @@ -4439,14 +4604,14 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c ConusFrame.ChangeOrig( ptV + vtV1 * dl) ; if ( IntersLineEllipticalCylinder( ptC, Z_AX, ConusFrame, dMinRad, dLongLen, dOrtLen, bTapB, true, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Traslazione ellisse di base ConusFrame.ChangeOrig( ptV + vtV1 * dL) ; if ( IntersLineEllipticalCylinder( ptC, Z_AX, ConusFrame, dMaxRad, dLongLen, dOrtLen, true, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -4488,14 +4653,14 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c vtN2.Normalize() ; } } - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Traslazione ellisse ConusFrame.ChangeOrig( ptV + vtV1 * dL) ; if ( IntersLineEllipticalCylinder( ptC, Z_AX, ConusFrame, dMaxRad, dLongLen, dOrtLen, true, bTapT, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -4507,7 +4672,7 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c bool VolZmap::CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ, const Point3d& ptS, const Point3d& ptE, - const Vector3d& vtToolDir, const Vector3d& vtAux) + const Vector3d& vtToolDir, const Vector3d& vtAux, int nToolNum) { Point3d ptMyS = ptS - EPS_SMALL * vtToolDir ; Point3d ptMyE = ptE - EPS_SMALL * vtToolDir ; @@ -4559,18 +4724,18 @@ VolZmap::CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ, // Solido nella posizione iniziale ParaFrame.ChangeOrig( ptV) ; if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenX, dLenY, dLenZ, 0, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Solido nella posizione finale ParaFrame.ChangeOrig( ptV + vtMove) ; if ( IntersLineMyPolyhedron( ptC, Z_AX, ParaFrame, dLenX, dLenY, dLenZ, 0, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } // Volume spazzato nel moto if ( IntersLineMyPolyhedron( ptC, Z_AX, MotionFrame, dLenW1, dLenZ, dLenW3, dDeltaW3, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -4582,7 +4747,7 @@ VolZmap::CompPar_Milling( int nGrid, double dLenX, double dLenY, double dLenZ, //---------------------------------------------------------------------------- bool -VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dRad) +VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dRad, int nToolNum) { // Verifico interferisca int nStartI, nStartJ, nEndI, nEndJ ; @@ -4615,7 +4780,7 @@ VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dMax = ptLs.z + sqrt( dSqRad - dStSqDXY) ; Vector3d vtNmax = ptLs - Point3d( dX, dY, dMax) ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, nToolNum) ; } // Sfera in posizione end @@ -4627,14 +4792,14 @@ VolZmap::CompBall_Milling( int nGrid, const Point3d& ptLs, const Point3d& ptLe, double dMax = ptLe.z + sqrt( dSqRad - dEnSqDXY) ; Vector3d vtNmax = ptLe - Point3d( dX, dY, dMax) ; vtNmax.Normalize() ; - SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax) ; + SubtractIntervals( nGrid, i, j, dMin, dMax, vtNmin, vtNmax, nToolNum) ; } // Cilindro inviluppo della sfera Point3d ptInt1, ptInt2 ; Vector3d vtN1, vtN2 ; if ( IntersLineCylinder( ptC, Z_AX, CylFrame, dLengthPath, dRad, false, false, ptInt1, vtN1, ptInt2, vtN2)) { - SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2) ; + SubtractIntervals( nGrid, i, j, ptInt1.z, ptInt2.z, vtN1, vtN2, nToolNum) ; } } } @@ -4693,7 +4858,12 @@ inline bool VolZmap::TestToolBBox( int nGrid, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV, int& nStI, int& nStJ, int& nEnI, int& nEnJ) { - return TestCompoBBox( nGrid, ptP1, ptP2, vtV, m_Tool.GetRadius(), m_Tool.GetTipRadius(), m_Tool.GetHeigth(), + // Controllo utensile + if ( m_nCurrTool < 0 || m_nCurrTool >= int( m_vTool.size())) + return false ; + Tool& CurrTool = m_vTool[m_nCurrTool] ; + + return TestCompoBBox( nGrid, ptP1, ptP2, vtV, CurrTool.GetRadius(), CurrTool.GetTipRadius(), CurrTool.GetHeigth(), nStI, nStJ, nEnI, nEnJ) ; }