diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index ddfe372..9c41859 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -225,6 +225,8 @@ MachMgr::GetOperationNewName( string& sName) const // verifico che il nome sia unico int nCount = 0 ; string sOrigName = sName ; + if ( sOrigName.rfind( "_1") == sOrigName.length() - 2) + sOrigName.erase( sOrigName.length() - 2) ; while ( GetOperationId( sName) != GDB_ID_NULL) { ++ nCount ; sName = sOrigName + "_" + ToString( nCount) ; diff --git a/Machine.cpp b/Machine.cpp index d1052c0..adf9aeb 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -192,7 +192,8 @@ Machine::AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay) //---------------------------------------------------------------------------- bool Machine::LoadMachineTable( const string& sName, const string& sParent, int nType, - const Point3d& ptRef1, const string& sGeo, const STRVECTOR& vsAux) + const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ, + const string& sGeo, const STRVECTOR& vsAux) { // recupero pezzo e layer della geometria originale della tavola string sPart, sLay ; @@ -215,6 +216,13 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType // aggiusto la posizione della tavola if ( ! AdjustTable( nLay, ptRef1)) return false ; + // eseguo eventuale scalatura + if ( abs( dCoeffX - 1.0) > EPS_ZERO || + abs( dCoeffY - 1.0) > EPS_ZERO || + abs( dCoeffZ - 1.0) > EPS_ZERO) { + if ( ! m_pGeomDB->ScaleGlob( nLay, Frame3d( ptRef1), dCoeffX, dCoeffY, dCoeffZ)) + return false ; + } // recupero l'area valida int nAreaId = m_pGeomDB->GetFirstNameInGroup( nLay, MCH_TAREA + "1") ; BBox3d b3Area1 ; diff --git a/Machine.h b/Machine.h index 3a80c62..41684aa 100644 --- a/Machine.h +++ b/Machine.h @@ -125,7 +125,8 @@ class Machine bool LoadMachineBase( const std::string& sName, const std::string& sGeo, const STRVECTOR& vsAux) ; bool AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay) ; bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType, - const Point3d& ptRef1, const std::string& sGeo, const STRVECTOR& vsAux) ; + const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ, + const std::string& sGeo, const STRVECTOR& vsAux) ; bool AdjustTable( int nLay, const Point3d& ptRef1) ; bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken, int nType, const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, diff --git a/MachineLua.cpp b/MachineLua.cpp index bada567..121cfd9 100644 --- a/MachineLua.cpp +++ b/MachineLua.cpp @@ -37,6 +37,7 @@ static const string FLD_AUX = "Aux" ; static const string FLD_TOKEN = "Token" ; static const string FLD_TYPE = "Type" ; static const string FLD_REF1 = "Ref1" ; +static const string FLD_SCALE = "Scale" ; static const string FLD_POS = "Pos" ; static const string FLD_DIR = "Dir" ; static const string FLD_STROKE = "Stroke" ; @@ -344,6 +345,9 @@ Machine::LuaEmtTable( lua_State* L) // lettura campo 'Ref1' dalla tabella Point3d Ref1 ; LuaCheckTabFieldParam( L, 1, FLD_REF1, Ref1) + // lettura eventuale campo 'Scale' dalla tabella + double vScale[3] = {1.0, 1.0, 1.0} ; + LuaGetTabFieldParam( L, 1, FLD_SCALE, vScale) ; // lettura campo 'Geo' dalla tabella string sGeo ; LuaCheckTabFieldParam( L, 1, FLD_GEO, sGeo) @@ -361,7 +365,7 @@ Machine::LuaEmtTable( lua_State* L) return luaL_error( L, " Unknown Machine") ; // carico i dati della tavola - if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, sGeo, vsAux)) + if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, vScale[0], vScale[1], vScale[2], sGeo, vsAux)) return luaL_error( L, " Load Machine Table failed") ; // restituisco l'indice della tavola diff --git a/MachiningsMgr.cpp b/MachiningsMgr.cpp index 5d84f83..ba40516 100644 --- a/MachiningsMgr.cpp +++ b/MachiningsMgr.cpp @@ -460,9 +460,11 @@ MachiningsMgr::GetMachiningNewName( string& sName) const // verifico che il nome sia unico int nCount = 0 ; string sOrigName = sName ; + if ( sOrigName.rfind( "_1") == sOrigName.length() - 2) + sOrigName.erase( sOrigName.length() - 2) ; while ( GetMachining( sName) != nullptr) { ++ nCount ; - sName = sOrigName + "-" + ToString( nCount) ; + sName = sOrigName + "_" + ToString( nCount) ; } return true ; } diff --git a/Milling.cpp b/Milling.cpp index b0c9131..b016b28 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -373,12 +373,12 @@ Milling::SetGeometry( const SELVECTOR& vIds) continue ; } // posso aggiungere alla lista - if ( nSubs == 0) + //if ( nSubs == 0) m_vId.emplace_back( Id) ; - else { - for ( int i = 0 ; i < nSubs ; ++ i) - m_vId.emplace_back( Id.nId, i) ; - } + //else { + // for ( int i = 0 ; i < nSubs ; ++ i) + // m_vId.emplace_back( Id.nId, i) ; + //} } return ( ! m_vId.empty()) ; } @@ -931,6 +931,8 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) LOG_INFO( GetEMkLogger(), "Error in Milling : Depth not computable") ; return false ; } + // sottraggo eventuale offset longitudinale + dDepth -= GetOffsL() ; // verifico di non superare il massimo materiale if ( dDepth > m_TParams.m_dMaxMat) { LOG_INFO( GetEMkLogger(), "Error in Milling : Depth bigger than MaxMaterial") ; @@ -1019,7 +1021,10 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) return false ; // aggiungo approccio per frese normali if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { - if ( ! AddApproach( ptP1, vtTool, dSafeZ, dElev, dAppr)) + double dStElev ; + if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, dStElev)) + dStElev = dElev ; + if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr)) return false ; // affondo al punto iniziale SetFlag( 0) ; @@ -1076,8 +1081,11 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId) } // aggiungo retrazione per frese normali if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) { + double dEndElev ; + if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, dEndElev)) + dEndElev = dElev ; // aggiungo retrazione - if ( ! AddRetract( ptP1, vtTool, dSafeZ, dElev, dAppr)) + if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr)) return false ; } // per lame non è necessario diff --git a/Simulator.cpp b/Simulator.cpp index c6d2697..171f920 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -113,7 +113,7 @@ Simulator::Start( void) return false ; // aggiornamenti legati al cambio di lavorazione (utensile e assi conseguenti) - if ( ! UpdateTool( true)) + if ( ! UpdateTool()) return false ; // richiamo gestione evento inizio lavorazione diff --git a/Table.cpp b/Table.cpp index 7c3df65..7d476bf 100644 --- a/Table.cpp +++ b/Table.cpp @@ -107,4 +107,3 @@ Table::Set( const string& sName, int nType, const Point3d& ptRef1, const BBox3d& m_b3Area1 = b3Area1 ; return true ; } - diff --git a/Table.h b/Table.h index 6081c86..910870b 100644 --- a/Table.h +++ b/Table.h @@ -21,12 +21,12 @@ class Table : public IUserObj { public : // IUserObj - virtual Table* Clone( void) const ; - virtual const std::string& GetClassName( void) const ; - virtual bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const ; - virtual bool SetOwner( int nId, IGeomDB* pGDB) ; - virtual int GetOwner( void) const ; - virtual IGeomDB* GetGeomDB( void) const ; + Table* Clone( void) const override ; + const std::string& GetClassName( void) const override ; + bool Dump( std::string& sOut, bool bMM = true, const char* szNewLine = "\n") const override ; + bool SetOwner( int nId, IGeomDB* pGDB) override ; + int GetOwner( void) const override ; + IGeomDB* GetGeomDB( void) const override ; public : Table( void) ; diff --git a/ToolsMgr.cpp b/ToolsMgr.cpp index 4fc778c..a65b8b6 100644 --- a/ToolsMgr.cpp +++ b/ToolsMgr.cpp @@ -312,6 +312,8 @@ ToolsMgr::GetToolNewName( string& sName) const // verifico che il nome sia unico int nCount = 0 ; string sOrigName = sName ; + if ( sOrigName.rfind( "_1") == sOrigName.length() - 2) + sOrigName.erase( sOrigName.length() - 2) ; while ( GetTool( sName) != nullptr) { ++ nCount ; sName = sOrigName + "-" + ToString( nCount) ;