EgtMachKernel 1.6p4 :

- ampliata Disposizione con gestione movimenti di pezzi con la testa tramite SpecialApply (che richiama script)
- modifiche a Simulatore per gestire queste disposizioni e aggiunti richiami script su diversi eventi
- modifiche a Generatore per gestire queste disposizioni
- varie altre modifiche e migliorie.
This commit is contained in:
Dario Sassi
2016-05-05 07:31:35 +00:00
parent 06a8b15d99
commit b8965da858
37 changed files with 3234 additions and 1898 deletions
+230 -23
View File
@@ -24,6 +24,7 @@
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGnFileUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
#include <algorithm>
using namespace std ;
@@ -143,7 +144,7 @@ Machine::LoadMachineGeometry( const string& sMGeoName, const Vector3d& vtOffset)
//----------------------------------------------------------------------------
bool
Machine::LoadMachineBase( const string& sName, const string& sGeo)
Machine::LoadMachineBase( const string& sName, const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della base
string sPart, sLay ;
@@ -154,18 +155,42 @@ Machine::LoadMachineBase( const string& sName, const string& sGeo)
if ( nLay == GDB_ID_NULL)
return false ;
// lo sposto nella radice della macchina
if ( ! m_pGeomDB->RelocateGlob( nLay, m_nGroupId, GDB_FIRST_SON))
if ( ! m_pGeomDB->RelocateGlob( nLay, m_nGroupId, GDB_LAST_SON))
return false ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// lo inserisco nel dizionario dei gruppi della macchina
return m_mapGroups.emplace( sName, nLay).second ;
}
//----------------------------------------------------------------------------
bool
Machine::AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay)
{
// sistemo la geometria ausiliaria
for ( const auto& sAux : vsAux) {
// recupero pezzo e layer della geometria ausiliaria della base
string sAuxPart, sAuxLay ;
Split( sAux, "/", true, sAuxPart, sAuxLay) ;
// cerco il gruppo nella geometria originale
int nAuxPart = m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sAuxPart) ;
int nAuxLay = m_pGeomDB->GetFirstNameInGroup( nAuxPart, sAuxLay) ;
if ( nAuxLay == GDB_ID_NULL)
return false ;
// lo sposto nel gruppo della base
if ( ! m_pGeomDB->RelocateGlob( nAuxLay, nLay, GDB_LAST_SON))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::LoadMachineTable( const string& sName, const string& sParent, int nType,
const Point3d& ptRef1, const string& sGeo)
const Point3d& ptRef1, const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della tavola
string sPart, sLay ;
@@ -178,10 +203,13 @@ Machine::LoadMachineTable( const string& sName, const string& sParent, int nType
// cerco il gruppo padre per spostarvelo
int nParentId = GetGroup( sParent) ;
if ( nParentId == GDB_ID_NULL ||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_LAST_SON))
return false ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// aggiusto la posizione della tavola
if ( ! AdjustTablePos( nLay, ptRef1))
return false ;
@@ -234,7 +262,7 @@ 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, const string& sGeo, double dHome)
const STROKE& Stroke, double dHome, const string& sGeo, const STRVECTOR& vsAux)
{
// verifico sia di tipo ammesso
if ( nType != MCH_AT_LINEAR && nType != MCH_AT_ROTARY) {
@@ -255,7 +283,7 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
// cerco il gruppo padre per spostarvelo
int nParentId = GetGroup( sParent) ;
if ( nParentId == GDB_ID_NULL ||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON)) {
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_LAST_SON)) {
string sOut = " Missing Parent Group " + sParent ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
@@ -267,6 +295,9 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
}
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// installo e inizializzo il gestore dell'asse
Axis* pAxis = new(nothrow) Axis ;
if ( pAxis == nullptr)
@@ -391,7 +422,8 @@ Machine::ModifyMachineAxisHome( const string& sName, double dHome)
bool
Machine::LoadMachineStdHead( const string& sName, const string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const string& sGeo)
double dRot1W, const STROKE& Rot2Stroke, int nSolCh,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale dell'asse
string sPart, sLay ;
@@ -404,13 +436,16 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
// cerco il gruppo padre per spostarvelo
int nParentId = GetGroup( sParent) ;
if ( nParentId == GDB_ID_NULL ||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_LAST_SON))
return false ;
// sistemo lo stato di visualizzazione
bool bShow = ( sHSet == sName) ;
m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// installo e inizializzo il gestore della testa
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
@@ -420,9 +455,12 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
return false ;
// trasformazione del riferimento di uscita in gruppo di uscita
// sistemo il riferimento dell'uscita rispetto alla direzione ausiliaria
MUEXITVECTOR vMuExit ;
vMuExit.emplace_back( ptPos, vtTDir) ;
if ( ! AdjustExitFrames( nLay, vMuExit, vtADir))
return false ;
// trasformazione del riferimento di uscita in gruppo di uscita
if ( ! CreateExitGroups( nLay, vMuExit))
return false ;
// lo inserisco nel dizionario dei gruppi della macchina
@@ -433,7 +471,8 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
bool
Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const std::string& sHSet,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh, const string& sGeo)
double dRot1W, const STROKE& Rot2Stroke, int nSolCh,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale dell'asse
string sPart, sLay ;
@@ -446,13 +485,16 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
// cerco il gruppo padre per spostarvelo
int nParentId = GetGroup( sParent) ;
if ( nParentId == GDB_ID_NULL ||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_LAST_SON))
return false ;
// sistemo lo stato di visualizzazione
bool bShow = ( sHSet == sName) ;
m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// installo e inizializzo il gestore della testa
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
@@ -462,6 +504,9 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
return false ;
// sistemo i riferimenti delle uscite rispetto alla direzione ausiliaria
if ( ! AdjustExitFrames( nLay, vMuExit, vtADir))
return false ;
// trasformazione dei riferimenti di uscita in gruppi di uscita
if ( ! CreateExitGroups( nLay, vMuExit))
return false ;
@@ -469,6 +514,55 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
return m_mapGroups.emplace( sName, nLay).second ;
}
//----------------------------------------------------------------------------
bool
Machine::LoadMachineSpecialHead( const string& sName, const string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, const STROKE& Rot2Stroke, int nSolCh,
const string& sGeo, const STRVECTOR& vsAux)
{
// recupero pezzo e layer della geometria originale della testa
string sPart, sLay ;
Split( sGeo, "/", true, sPart, sLay) ;
// cerco il gruppo nella geometria originale
int nPart = m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
int nLay = m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
if ( nLay == GDB_ID_NULL)
return false ;
// cerco il gruppo padre per spostarvelo
int nParentId = GetGroup( sParent) ;
if ( nParentId == GDB_ID_NULL ||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_LAST_SON))
return false ;
// sistemo lo stato di visualizzazione
bool bShow = ( sHSet == sName) ;
m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
// gli assegno il nome
m_pGeomDB->SetName( nLay, sName) ;
// sistemo la geometria ausiliaria
if ( ! AdjustAuxGeometry( vsAux, nLay))
return false ;
// installo e inizializzo il gestore della testa
Head* pHead = new(nothrow) Head ;
if ( pHead == nullptr)
return false ;
pHead->Set( sName, MCH_HT_SPECIAL, sHSet, vtADir, dRot1W, Rot2Stroke, nSolCh) ;
m_pGeomDB->SetUserObj( nLay, pHead) ;
// aggiorno la testa capostipite
if ( ! AddHeadToSet( sHSet, sName))
return false ;
// sistemo il riferimento dell'uscita rispetto alla direzione ausiliaria
MUEXITVECTOR vMuExit ;
vMuExit.emplace_back( ptPos, vtTDir) ;
if ( ! AdjustExitFrames( nLay, vMuExit, vtADir))
return false ;
// trasformazione del riferimento di uscita in gruppo di uscita
if ( ! CreateExitGroups( nLay, vMuExit))
return false ;
// lo inserisco nel dizionario dei gruppi della macchina
return m_mapGroups.emplace( sName, nLay).second ;
}
//----------------------------------------------------------------------------
int
Machine::GetGroup( const string& sGroup) const
@@ -477,6 +571,23 @@ Machine::GetGroup( const string& sGroup) const
return (( Iter != m_mapGroups.end()) ? Iter->second : GDB_ID_NULL) ;
}
//----------------------------------------------------------------------------
bool
Machine::IsBaseGroup( int nGroup) const
{
if ( m_pGeomDB == nullptr)
return false ;
// deve essere nel primo gruppo della macchina
return ( m_pGeomDB->GetParentId( nGroup) == m_nGroupId) ;
}
//----------------------------------------------------------------------------
Table*
Machine::GetTable( int nGroup) const
{
return ( dynamic_cast<Table*>( m_pGeomDB->GetUserObj( nGroup))) ;
}
//----------------------------------------------------------------------------
Axis*
Machine::GetAxis( int nGroup) const
@@ -500,13 +611,6 @@ Machine::IsRotaryAxisGroup( int nGroup) const
return ( pAx != nullptr && pAx->GetType() == MCH_AT_ROTARY) ;
}
//----------------------------------------------------------------------------
Table*
Machine::GetTable( int nGroup) const
{
return ( dynamic_cast<Table*>( m_pGeomDB->GetUserObj( nGroup))) ;
}
//----------------------------------------------------------------------------
Head*
Machine::GetHead( int nGroup) const
@@ -574,6 +678,46 @@ Machine::EnableHeadInSet( const string& sHead)
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::AdjustExitFrames( int nLay, const MUEXITVECTOR& vMuExit, const Vector3d& vtADir)
{
// se il versore ausiliario non è definito, non sono necessari controlli
if ( vtADir.IsSmall())
return true ;
// riferimento globale del gruppo testa
Frame3d frHead ;
m_pGeomDB->GetGroupGlobFrame( nLay, frHead) ;
// porto il vettore ausiliario nel riferimento testa
Vector3d vtAuxL = vtADir ;
vtAuxL.ToLoc( frHead) ;
// ciclo sulle uscite
for ( int i = 0 ; i < int( vMuExit.size()) ; ++ i) {
string sName = MCH_EXIT + ToString( i + 1) ;
// se trovo riferimento per uscita, lo verifico
int nT = m_pGeomDB->GetFirstNameInGroup( nLay, sName) ;
if ( nT != GDB_ID_NULL && m_pGeomDB->GetGeoType( nT) == GEO_FRAME3D) {
// recupero frame
IGeoFrame3d* pGF = GetGeoFrame3d( m_pGeomDB->GetGeoObj( nT)) ;
Frame3d frFrame = pGF->GetFrame() ;
// determino rotazione attorno a RifAxZ per massimo allineamento RifAxX con direzione ausiliaria
bool bDet ;
double dAngRotDeg ;
if ( frFrame.VersX().GetRotation( vtAuxL, frFrame.VersZ(), dAngRotDeg, bDet) && bDet) {
if ( abs( dAngRotDeg) > EPS_ANG_SMALL) {
frFrame.Rotate( frFrame.Orig(), frFrame.VersZ(), dAngRotDeg) ;
pGF->Set( frFrame) ;
}
}
else {
string sOut = " Exit " + sName + " with frame not adjustable for AuxDir" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
}
}
}
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit)
@@ -583,7 +727,7 @@ Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit)
m_pGeomDB->GetGroupGlobFrame( nLay, frHead) ;
// ciclo sulle uscite
for ( int i = 0 ; i < int( vMuExit.size()) ; ++ i) {
string sName = MCH_EXIT + ToString( i+1) ;
string sName = MCH_EXIT + ToString( i + 1) ;
// se trovo riferimento per uscita, lo sostituisco con gruppo equivalente
int nT = m_pGeomDB->GetFirstNameInGroup( nLay, sName) ;
if ( nT != GDB_ID_NULL && m_pGeomDB->GetGeoType( nT) == GEO_FRAME3D) {
@@ -653,7 +797,7 @@ Machine::SetLook( int nFlag)
return false ;
// recupero l'identificativo del gruppo di base della macchina
int nMBaseId = m_pGeomDB->GetFirstInGroup( GetMGeoId()) ;
int nMBaseId = m_pGeomDB->GetFirstInGroup( GetMachineId()) ;
// recupero la tavola corrente
int nTabId = GetCurrTable() ;
@@ -674,15 +818,17 @@ Machine::SetLook( int nFlag)
nParentId = m_pGeomDB->GetParentId( nParentId) ;
}
// recupero l'utensile corrente
// recupero l'utensile e l'uscita correnti (per gestire casi senza utensile)
int nToolId = GetCurrTool() ;
int nExitId = m_nCalcExitId ;
// nascondo o visualizzo i fratelli e tutti i fratelli degli ascendenti
bool bToolOnly = ( nFlag > MCH_LOOK_TAB && nFlag < MCH_LOOK_ALL) ;
int nToolCurrId = nToolId ;
int nToolCurrId = ( nToolId != GDB_ID_NULL ? nToolId : nExitId) ;
nParentId = m_pGeomDB->GetParentId( nToolCurrId) ;
while ( nParentId != GDB_ID_NULL && nParentId != nMBaseId) {
bool bHide = bToolOnly ;
if ( nFlag == MCH_LOOK_TAB_HEAD) {
if ( nFlag == MCH_LOOK_TAB_HEAD ||
( nFlag == MCH_LOOK_TAB_TOOL && nToolId == GDB_ID_NULL)) {
if ( IsHeadGroup( nParentId) || IsRotaryAxisGroup( nParentId))
bHide = false ;
}
@@ -712,3 +858,64 @@ Machine::SetLook( int nFlag)
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::LinkRawPartToGroup( int nRawPartId, const std::string& sGroupName)
{
// verifico DB geometrico e gestore lavorazioni
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
return false ;
// recupero l'identificativo del gruppo di base dei grezzi
int nRawGrpId = m_pMchMgr->GetCurrRawGroupId() ;
if ( nRawGrpId == GDB_ID_NULL)
return false ;
// verifico che il grezzo appartenga a questo gruppo
if ( m_pGeomDB->GetParentId( nRawPartId) != nRawGrpId)
return false ;
// recupero il gruppo di macchina indicato
int nGrpId = m_pMchLua->GetGroup( sGroupName) ;
if ( nGrpId == GDB_ID_NULL)
return false ;
// aggancio il grezzo al gruppo
if ( ! m_pGeomDB->RelocateGlob( nRawPartId, nGrpId))
return false ;
// inserisco il grezzo nell'elenco dei linkati
m_vLinkedRawParts.push_back( nRawPartId) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::UnlinkRawPartFromGroup( int nRawPartId)
{
// verifico DB geometrico e gestore lavorazioni
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr)
return false ;
// recupero il gruppo dei grezzi dalla macchina
int nRawGrpId = m_pMchLua->m_pMchMgr->GetCurrRawGroupId() ;
if ( nRawGrpId == GDB_ID_NULL)
return false ;
// verifico che il grezzo indicato sia nell'elenco dei linkati
auto iIter = find( m_vLinkedRawParts.begin(), m_vLinkedRawParts.end(), nRawPartId) ;
if ( iIter == m_vLinkedRawParts.end())
return false ;
// riporto il grezzo nel gruppo dei grezzi
if ( ! m_pMchLua->m_pGeomDB->RelocateGlob( nRawPartId, nRawGrpId))
return false ;
// tolgo il grezzo dall'elenco dei linkati
m_vLinkedRawParts.erase( iIter) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Machine::UnlinkAllRawPartsFromGroups( void)
{
while ( m_vLinkedRawParts.size() > 0) {
int nRawId = m_vLinkedRawParts.back() ;
if ( ! UnlinkRawPartFromGroup( nRawId))
return false ;
}
return true ;
}