EgtMachKernel 1.6r2 :

- modifiche per gestire fino a 4 assi rotanti contemporaneamente attivi (almeno 2 bloccati)
- correzioni e migliorie varie.
This commit is contained in:
Dario Sassi
2016-05-17 07:00:08 +00:00
parent 31b4099d0f
commit 05a69a650b
20 changed files with 551 additions and 165 deletions
+26 -17
View File
@@ -211,7 +211,7 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// aggiusto la posizione della tavola
if ( ! AdjustTablePos( nLay, ptRef1))
if ( ! AdjustTable( nLay, ptRef1))
return false ;
// recupero l'area valida
int nAreaId = m_pGeomDB->GetFirstNameInGroup( nLay, MCH_TAREA + "1") ;
@@ -230,7 +230,7 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType
//----------------------------------------------------------------------------
bool
Machine::AdjustTablePos( int nLay, const Point3d& ptRef1)
Machine::AdjustTable( int nLay, const Point3d& ptRef1)
{
// riferimento globale del gruppo tavola
Frame3d frTable ;
@@ -261,8 +261,8 @@ Machine::AdjustTablePos( int nLay, const Point3d& ptRef1)
//----------------------------------------------------------------------------
bool
Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
const Point3d& ptPos, const Vector3d& vtDir,
const STROKE& Stroke, double dHome, const string& sGeo, const STRVECTOR& vsAux)
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome,
bool bAdjustAux, const string& sGeo, const STRVECTOR& vsAux)
{
// verifico sia di tipo ammesso
if ( nType != MCH_AT_LINEAR && nType != MCH_AT_ROTARY) {
@@ -305,7 +305,7 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dHome) ;
m_pGeomDB->SetUserObj( nLay, pAxis) ;
// verifico il vettore rappresentativo dell'asse
if ( ! AdjustAxisVector( nLay, sPart, sName, nType, ptPos, vtDir))
if ( ! AdjustAxis( nLay, sPart, sName, nType, ptPos, vtDir, bAdjustAux))
return false ;
// lo inserisco nel dizionario dei gruppi della macchina
return m_mapGroups.emplace( sName, nLay).second ;
@@ -313,8 +313,8 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
//----------------------------------------------------------------------------
bool
Machine::AdjustAxisVector( int nLay, const string& sPart, const string& sName,
int nType, const Point3d& ptPos, const Vector3d& vtDir)
Machine::AdjustAxis( int nLay, const string& sPart, const string& sName,
int nType, const Point3d& ptPos, const Vector3d& vtDir, bool bAdjustAux)
{
// verifico presenza vettore asse
int nId = m_pGeomDB->GetFirstNameInGroup( nLay, sPart) ;
@@ -355,10 +355,9 @@ Machine::AdjustAxisVector( int nLay, const string& sPart, const string& sName,
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
return true ;
}
// altrimenti asse rotante, devo verificarne direzione e coassialità
// altrimenti asse rotante, devo verificarne direzione e coassialità (questa solo se non abilitato movimento)
else {
Vector3d vtDirN = vtDir ;
if ( ! vtDirN.Normalize() || ! AreSameVectorApprox( vtAxis, vtDirN)) {
@@ -367,10 +366,10 @@ Machine::AdjustAxisVector( int nLay, const string& sPart, const string& sName,
return false ;
}
Vector3d vtDelta = ptPos - ptBase ;
vtDelta -= ( vtDelta * vtDirN) * vtDirN ;
if ( ! vtDelta.IsSmall()) {
if ( vtDelta.Len() > m_dAxisMaxAdjust) {
string sOut = " Wrong Axis Base move = (" + ToString( vtDelta) + ")" ;
Vector3d vtDeltaPerp = vtDelta - ( vtDelta * vtDirN) * vtDirN ;
if ( ! vtDeltaPerp.IsSmall()) {
if ( vtDeltaPerp.Len() > m_dAxisMaxAdjust && ! bAdjustAux) {
string sOut = " Wrong Axis Base move = (" + ToString( vtDeltaPerp) + ")" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
@@ -380,8 +379,18 @@ Machine::AdjustAxisVector( int nLay, const string& sPart, const string& sName,
m_pGeomDB->TranslateGlob( nId, vtDelta) ;
}
}
return true ;
}
// se richiesto, muovo la geometria ausiliaria
if ( bAdjustAux) {
Vector3d vtDelta = ptPos - ptBase ;
int nIdAux = m_pGeomDB->GetFirstInGroup( nLay) ;
while ( nIdAux != GDB_ID_NULL) {
if ( nIdAux != nId)
m_pGeomDB->TranslateGlob( nIdAux, vtDelta) ;
nIdAux = m_pGeomDB->GetNext( nIdAux) ;
}
}
return true ;
}
//----------------------------------------------------------------------------
@@ -874,7 +883,7 @@ Machine::LinkRawPartToGroup( int nRawPartId, const std::string& sGroupName)
if ( m_pGeomDB->GetParentId( nRawPartId) != nRawGrpId)
return false ;
// recupero il gruppo di macchina indicato
int nGrpId = m_pMchLua->GetGroup( sGroupName) ;
int nGrpId = GetGroup( sGroupName) ;
if ( nGrpId == GDB_ID_NULL)
return false ;
// aggancio il grezzo al gruppo
@@ -893,7 +902,7 @@ Machine::UnlinkRawPartFromGroup( int nRawPartId)
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
return false ;
// recupero il gruppo dei grezzi dalla macchina
int nRawGrpId = m_pMchLua->m_pMchMgr->GetCurrRawGroupId() ;
int nRawGrpId = m_pMchMgr->GetCurrRawGroupId() ;
if ( nRawGrpId == GDB_ID_NULL)
return false ;
// verifico che il grezzo indicato sia nell'elenco dei linkati
@@ -901,7 +910,7 @@ Machine::UnlinkRawPartFromGroup( int nRawPartId)
if ( iIter == m_vLinkedRawParts.end())
return false ;
// riporto il grezzo nel gruppo dei grezzi
if ( ! m_pMchLua->m_pGeomDB->RelocateGlob( nRawPartId, nRawGrpId))
if ( ! m_pGeomDB->RelocateGlob( nRawPartId, nRawGrpId))
return false ;
// tolgo il grezzo dall'elenco dei linkati
m_vLinkedRawParts.erase( iIter) ;