EgtMachKernel :
- aggiunta gestione prima disposizione in lista operazioni - migliorato controllo dati macchina al caricamento - ora macchina deve essere disegnata e definita cinematicamente con tutti gli assi a 0, si definisce la posizione home e dopo il carico viene posta in questa posizione.
This commit is contained in:
@@ -40,6 +40,7 @@ Axis::Clone( void) const
|
||||
// eseguo copia dei dati
|
||||
if ( pAx != nullptr) {
|
||||
try { pAx->m_nOwnerId = GDB_ID_NULL ;
|
||||
pAx->m_pGeomDB = nullptr ;
|
||||
pAx->m_sName = m_sName ;
|
||||
pAx->m_nType = m_nType ;
|
||||
pAx->m_ptPos = m_ptPos ;
|
||||
@@ -75,10 +76,11 @@ Axis::Dump( string& sOut, const char* szNewLine) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Axis::SetOwner( int nId)
|
||||
Axis::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
return true ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -88,25 +90,33 @@ Axis::GetOwner( void) const
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Axis::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Axis::Axis( void)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_nType( MCH_AT_NONE), m_Stroke( {{0,0}}), m_dHomeVal( 0), m_dCurrVal( 0)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr),
|
||||
m_nType( MCH_AT_NONE), m_Stroke( {{0,0}}), m_dHomeVal( 0), m_dCurrVal( 0)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Axis::Set( const string& sName, int nType,
|
||||
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dVal)
|
||||
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome)
|
||||
{
|
||||
m_sName = sName ;
|
||||
m_nType = nType ;
|
||||
m_ptPos = ptPos ;
|
||||
m_vtDir = vtDir ;
|
||||
m_Stroke = Stroke ;
|
||||
m_dHomeVal = dVal ;
|
||||
m_dCurrVal = dVal ;
|
||||
m_dHomeVal = dHome ;
|
||||
m_dCurrVal = 0.0 ;
|
||||
return m_vtDir.Normalize() ;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,14 @@ class Axis : public IObjUser
|
||||
virtual Axis* Clone( void) const ;
|
||||
virtual const std::string& GetClassName( void) const ;
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool SetOwner( int nId) ;
|
||||
virtual bool SetOwner( int nId, IGeomDB* pGDB) ;
|
||||
virtual int GetOwner( void) const ;
|
||||
virtual IGeomDB* GetGeomDB( void) const ;
|
||||
|
||||
public :
|
||||
Axis( void) ;
|
||||
bool Set( const std::string& sName, int nType,
|
||||
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dVal) ;
|
||||
const Point3d& ptPos, const Vector3d& vtDir, const STROKE& Stroke, double dHome) ;
|
||||
bool SetCurrVal( double dVal) { m_dCurrVal = dVal ; return true ; }
|
||||
const std::string& GetName( void) { return m_sName ; }
|
||||
int GetType( void) { return m_nType ; }
|
||||
@@ -42,6 +43,7 @@ class Axis : public IObjUser
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
std::string m_sName ;
|
||||
int m_nType ;
|
||||
Point3d m_ptPos ;
|
||||
|
||||
+587
@@ -0,0 +1,587 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Drilling.cpp Data : 21.05.15 Versione : 1.6e7
|
||||
// Contenuto : Implementazione gestione forature.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 21.05.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "MachMgr.h"
|
||||
#include "DllMain.h"
|
||||
#include "Disposition.h"
|
||||
#include "Table.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkObjUserFactory.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
OBJUSER_REGISTER( "EMkDisposition", Disposition) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string&
|
||||
Disposition::GetClassName( void) const
|
||||
{
|
||||
return OBJUSER_GETNAME( Disposition) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Disposition*
|
||||
Disposition::Clone( void) const
|
||||
{
|
||||
// alloco oggetto
|
||||
Disposition* pDisp = new(nothrow) Disposition ;
|
||||
// eseguo copia dei dati
|
||||
if ( pDisp != nullptr) {
|
||||
try { pDisp->m_nOwnerId = GDB_ID_NULL ;
|
||||
pDisp->m_pGeomDB = nullptr ;
|
||||
pDisp->m_sTabName = m_sTabName ;
|
||||
pDisp->m_bTabOk = m_bTabOk ;
|
||||
pDisp->m_vFixData = m_vFixData ;
|
||||
pDisp->m_vMvrData = m_vMvrData ;
|
||||
}
|
||||
catch( ...) {
|
||||
delete pDisp ;
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
// ritorno l'oggetto
|
||||
return pDisp ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::Dump( string& sOut, const char* szNewLine) const
|
||||
{
|
||||
sOut += GetClassName() + szNewLine ;
|
||||
sOut += "Tab=" + m_sTabName + ( m_bTabOk ? " (ok)" : " (to verify)") + szNewLine ;
|
||||
for ( int i = 0 ; i < int( m_vFixData.size()) ; ++ i) {
|
||||
sOut += "FxD=" + m_vFixData[i].sName + "," +
|
||||
ToString( m_vFixData[i].nId) + ",(" +
|
||||
ToString( m_vFixData[i].ptPos) + ")" + szNewLine ;
|
||||
}
|
||||
for ( int i = 0 ; i < int( m_vMvrData.size()) ; ++ i) {
|
||||
sOut += "MvD=" + ToString( m_vMvrData[i].nRawId) + "," ;
|
||||
switch (m_vMvrData[i].nType) {
|
||||
case MoveRawData::NONE :
|
||||
sOut += string( " NONE") + szNewLine ;
|
||||
break ;
|
||||
case MoveRawData::COR :
|
||||
sOut += " COR,(" + ToString( m_vMvrData[i].ptP) + ")," + ToString( m_vMvrData[i].nFlag) + szNewLine ;
|
||||
break ;
|
||||
case MoveRawData::CEN :
|
||||
sOut += " CEN,(" + ToString( m_vMvrData[i].ptP) + ")," + ToString( m_vMvrData[i].nFlag) + szNewLine ;
|
||||
break ;
|
||||
case MoveRawData::ROT :
|
||||
sOut += " ROT,(" + ToString( m_vMvrData[i].ptP) + ")" + szNewLine ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::Save( STRVECTOR& vString) const
|
||||
{
|
||||
try {
|
||||
int k = - 1 ;
|
||||
int nFxdTot = int( m_vFixData.size()) ;
|
||||
int nFxdLines = 1 + 2 * nFxdTot ;
|
||||
int nMvdTot = int( m_vMvrData.size()) ;
|
||||
int nMvdLines = 1 + 4 * nMvdTot ;
|
||||
vString.insert( vString.begin(), 1 + nFxdLines + nMvdLines, "") ;
|
||||
// nome
|
||||
if ( ! SetVal( DIS_TABLE, m_sTabName, vString[++k]))
|
||||
return false ;
|
||||
// dati sottopezzi
|
||||
if ( ! SetVal( DIS_FXD_TOT, nFxdTot, vString[++k]))
|
||||
return false ;
|
||||
for ( int i = 0 ; i < nFxdTot ; ++ i) {
|
||||
if ( ! SetVal( DIS_FXD_NAME, m_vFixData[i].sName, vString[++k]) ||
|
||||
! SetVal( DIS_FXD_POS, m_vFixData[i].ptPos, vString[++k]))
|
||||
return false ;
|
||||
}
|
||||
// dati posizionamento grezzi
|
||||
if ( ! SetVal( DIS_MVD_TOT, nMvdTot, vString[++k]))
|
||||
return false ;
|
||||
for ( int i = 0 ; i < nMvdTot ; ++ i) {
|
||||
if ( ! SetVal( DIS_MVD_ID, m_vMvrData[i].nRawId, vString[++k]) ||
|
||||
! SetVal( DIS_MVD_TYPE, m_vMvrData[i].nType, vString[++k]) ||
|
||||
! SetVal( DIS_MVD_PNT, m_vMvrData[i].ptP, vString[++k]) ||
|
||||
! SetVal( DIS_MVD_FLAG, m_vMvrData[i].nFlag, vString[++k]))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
catch( ...) { return false ; }
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::Load( const STRVECTOR& vString)
|
||||
{
|
||||
if ( vString.size() < 3)
|
||||
return false ;
|
||||
int k = - 1 ;
|
||||
// nome
|
||||
if ( ! GetVal( vString[++k], DIS_TABLE, m_sTabName))
|
||||
return false ;
|
||||
// dati sottopezzi
|
||||
int nFxdTot ;
|
||||
if ( ! GetVal( vString[++k], DIS_FXD_TOT, nFxdTot))
|
||||
return false ;
|
||||
int nFxdLines = 1 + 2 * nFxdTot ;
|
||||
if ( int( vString.size()) < 1 + nFxdLines + 1)
|
||||
return false ;
|
||||
m_vFixData.insert( m_vFixData.begin(), nFxdTot, FixtureData()) ;
|
||||
for ( int i = 0 ; i < nFxdTot ; ++ i) {
|
||||
if ( ! GetVal( vString[++k], DIS_FXD_NAME, m_vFixData[i].sName) ||
|
||||
! GetVal( vString[++k], DIS_FXD_POS, m_vFixData[i].ptPos))
|
||||
return false ;
|
||||
}
|
||||
// dati posizionamento grezzi
|
||||
int nMvdTot ;
|
||||
if ( ! GetVal( vString[++k], DIS_MVD_TOT, nMvdTot))
|
||||
return false ;
|
||||
int nMvdLines = 1 + 4 * nMvdTot ;
|
||||
if ( int( vString.size()) < 1 + nFxdLines + nMvdLines)
|
||||
return false ;
|
||||
m_vMvrData.insert( m_vMvrData.begin(), nMvdTot, MoveRawData()) ;
|
||||
for ( int i = 0 ; i < nMvdTot ; ++ i) {
|
||||
if ( ! GetVal( vString[++k], DIS_MVD_ID, m_vMvrData[i].nRawId) ||
|
||||
! GetVal( vString[++k], DIS_MVD_TYPE, m_vMvrData[i].nType) ||
|
||||
! GetVal( vString[++k], DIS_MVD_PNT, m_vMvrData[i].ptP) ||
|
||||
! GetVal( vString[++k], DIS_MVD_FLAG, m_vMvrData[i].nFlag))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Disposition::GetOwner( void) const
|
||||
{
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Disposition::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Disposition::Disposition( void)
|
||||
{
|
||||
m_nOwnerId = GDB_ID_NULL ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_pMchMgr = nullptr ;
|
||||
m_bTabOk = false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::Init( MachMgr* pMchMgr)
|
||||
{
|
||||
m_pMchMgr = pMchMgr ;
|
||||
if ( m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
if ( m_pMchMgr->GetGeomDB() != m_pGeomDB)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::SetTable( const string& sTable)
|
||||
{
|
||||
// dichiaro tavola non verificata
|
||||
m_bTabOk = false ;
|
||||
// verifico il gestore lavorazioni
|
||||
if ( m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
// recupero la macchina corrente
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
// imposta questa tavola come corrente
|
||||
if ( ! pMch->SetCurrTable( sTable))
|
||||
return false ;
|
||||
// recupero il primo riferimento della tavola
|
||||
Table* pTab = pMch->GetTable( sTable) ;
|
||||
if ( pTab == nullptr)
|
||||
return false ;
|
||||
m_ptRef1 = pTab->GetRef1() ;
|
||||
// salvo il nome e dichiaro tavola verificata
|
||||
m_sTabName = sTable ;
|
||||
m_bTabOk = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::Apply(void)
|
||||
{
|
||||
// aggiornamento sottopezzi
|
||||
for ( auto iIter = m_vFixData.begin() ; iIter != m_vFixData.end() ; ++ iIter) {
|
||||
// se sottopezzo da caricare
|
||||
if ( iIter->nId == GDB_ID_NULL) {
|
||||
int nId = AddSubPiece( iIter->sName, iIter->ptPos, false) ;
|
||||
if ( nId == GDB_ID_NULL) {
|
||||
string sOut = "Error adding subpiece " + iIter->sName ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
}
|
||||
else
|
||||
iIter->nId = nId ;
|
||||
}
|
||||
}
|
||||
// aggiornamento movimento pezzi
|
||||
for ( auto iIter = m_vMvrData.begin() ; iIter != m_vMvrData.end() ; ++ iIter) {
|
||||
switch ( iIter->nType) {
|
||||
case MoveRawData::COR :
|
||||
if ( ! MoveToCornerRawPart( iIter->nRawId, iIter->ptP, iIter->nFlag, false)) {
|
||||
string sOut = "Error in MovoToCornerRawPart " + ToString( iIter->nRawId) ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
}
|
||||
break ;
|
||||
case MoveRawData::CEN :
|
||||
if ( ! MoveToCenterRawPart( iIter->nRawId, iIter->ptP, iIter->nFlag, false)) {
|
||||
string sOut = "Error in MovoToCenterRawPart " + ToString( iIter->nRawId) ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
}
|
||||
break ;
|
||||
case MoveRawData::ROT :
|
||||
if ( ! ApplyRotationToRawPart( iIter->nRawId, iIter->ptP.x, iIter->ptP.y, iIter->ptP.z)) {
|
||||
string sOut = "Error in ApplyRotationToRawPart " + ToString( iIter->nRawId) ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
}
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Disposition::AddSubPiece( const string& sName, const Point3d& ptPos, bool bAddToList)
|
||||
{
|
||||
// verifico MachMgr e GeomDB
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// verifico tavola
|
||||
if ( ! m_bTabOk && ! SetTable( m_sTabName))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il gruppo delle fixtures nella macchinata corrente
|
||||
int nFixtGrpId = m_pMchMgr->GetCurrFixtGroupId() ;
|
||||
if ( nFixtGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// verifico esistenza file sottopezzo
|
||||
string sFixtFile = m_pMchMgr->GetCurrFixtDir() + "\\" + sName + ".Nge" ;
|
||||
if ( ! ExistsFile( sFixtFile))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il sottopezzo nel gruppo
|
||||
if ( ! m_pGeomDB->Load( sFixtFile, nFixtGrpId))
|
||||
return GDB_ID_NULL ;
|
||||
int nFixtId = m_pGeomDB->GetLastGroupInGroup( nFixtGrpId) ;
|
||||
if ( nFixtId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// imposto il livello a temporaneo
|
||||
m_pGeomDB->SetLevel( nFixtId, GDB_LV_TEMP) ;
|
||||
// la muovo nella posizione voluta
|
||||
Vector3d vtMove = ( m_ptRef1 + ptPos) - ORIG ;
|
||||
m_pGeomDB->TranslateGlob( nFixtId, vtMove) ;
|
||||
// se da aggiungere alla lista
|
||||
if ( bAddToList)
|
||||
m_vFixData.emplace_back( sName, nFixtId, ptPos) ;
|
||||
return nFixtId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::MoveSubPiece( int nId, const Vector3d& vtMove)
|
||||
{
|
||||
// verifica validità sottopezzo
|
||||
if ( ! VerifyFixture( nId))
|
||||
return false ;
|
||||
// verifico aggiornamento tavola
|
||||
if ( ! m_bTabOk && ! SetTable( m_sTabName))
|
||||
return false ;
|
||||
// muovo l'oggetto
|
||||
m_pGeomDB->TranslateGlob( nId, vtMove) ;
|
||||
// aggiorno la posizione dell'oggetto nel vettore dei comandi
|
||||
for ( auto iIter = m_vFixData.begin() ; iIter != m_vFixData.end() ; ++ iIter) {
|
||||
if ( iIter->nId == nId) {
|
||||
iIter->ptPos += vtMove ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::RemoveSubPiece( int nId)
|
||||
{
|
||||
// verifica validità sottopezzo
|
||||
if ( ! VerifyFixture( nId))
|
||||
return false ;
|
||||
// verifico aggiornamento tavola
|
||||
if ( ! m_bTabOk && ! SetTable( m_sTabName))
|
||||
return false ;
|
||||
// rimuovo l'oggetto dal DB
|
||||
m_pGeomDB->Erase( nId) ;
|
||||
// rimuovo l'oggetto dal vettore dei comandi
|
||||
while ( true) {
|
||||
auto iIter = find_if( m_vFixData.begin(), m_vFixData.end(),
|
||||
[ nId]( const FixtureData& Fxt)
|
||||
{ return ( Fxt.nId == nId) ; }) ;
|
||||
if ( iIter == m_vFixData.end())
|
||||
break ;
|
||||
else
|
||||
m_vFixData.erase( iIter) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// recupero il solido
|
||||
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
// determino il box del grezzo (solo il solido ovviamente)
|
||||
BBox3d b3Raw ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
|
||||
return false ;
|
||||
// calcolo il movimento necessario
|
||||
Vector3d vtMove ;
|
||||
switch ( nFlag) {
|
||||
case MCH_CR_TL :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMin().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
case MCH_CR_TR :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMax().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
default : // RPCP_BL
|
||||
vtMove = ( m_ptRef1 + ptP) - b3Raw.GetMin() ;
|
||||
break ;
|
||||
case MCH_CR_BR :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMax().x, b3Raw.GetMin().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
// eseguo traslazione in globale
|
||||
if ( ! vtMove.IsSmall())
|
||||
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
// se da aggiungere alla lista
|
||||
if ( bAddToList) {
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::COR, ptP, nFlag) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::COR, ptP, nFlag) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// recupero il solido
|
||||
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
// determino il box del grezzo (solo il solido ovviamente)
|
||||
BBox3d b3Raw ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
|
||||
return false ;
|
||||
// ricavo il centro dal box (in generale non è il centro geometrico)
|
||||
Point3d ptCen ;
|
||||
b3Raw.GetCenter( ptCen) ;
|
||||
// calcolo il movimento necessario
|
||||
Vector3d vtMove ;
|
||||
switch ( nFlag) {
|
||||
case MCH_CE_TC :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( ptCen.x, b3Raw.GetMax().y, ptCen.z) ;
|
||||
break ;
|
||||
default : // RPCE_ML
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMin().x, ptCen.y, ptCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_MR :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( b3Raw.GetMax().x, ptCen.y, ptCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_BC :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( ptCen.x, b3Raw.GetMin().y, ptCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_MC :
|
||||
vtMove = ( m_ptRef1 + ptP) - Point3d( ptCen.x, ptCen.y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
// eseguo traslazione in globale
|
||||
if ( ! vtMove.IsSmall())
|
||||
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
// se da aggiungere alla lista
|
||||
if ( bAddToList) {
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::CEN, ptP, nFlag) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::CEN, ptP, nFlag) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// se movimento nullo, non devo fare alcunché
|
||||
if ( vtMove.IsSmall())
|
||||
return true ;
|
||||
// verifico ci sia già un movimento assoluto di questo grezzo
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId &&
|
||||
( Mrv.nType == MoveRawData::COR || Mrv.nType == MoveRawData::CEN)) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
return false ;
|
||||
// eseguo traslazione in globale
|
||||
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
// aggiorno comando di movimento
|
||||
iIter->ptP += vtMove ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// recupero centro del grezzo
|
||||
Point3d ptAx ;
|
||||
if ( ! m_pMchMgr->GetRawPartCenter( nRawId, ptAx))
|
||||
return false ;
|
||||
// eseguo rotazione in globale attorno al centro del grezzo
|
||||
if ( ! m_pGeomDB->RotateGlob( nRawId, ptAx, vtAx, dAngRotDeg))
|
||||
return false ;
|
||||
// recupero riferimento globale del grezzo
|
||||
Frame3d frRaw ;
|
||||
m_pGeomDB->GetGroupGlobFrame( nRawId, frRaw) ;
|
||||
// ne calcolo gli angoli di Eulero
|
||||
double dAngCDeg, dAngADeg, dAngC1Deg ;
|
||||
frRaw.GetRotationsCAC1( dAngCDeg, dAngADeg, dAngC1Deg) ;
|
||||
// aggiungo o modifico nella lista
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId && Mrv.nType == MoveRawData::ROT) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
m_vMvrData.emplace_back( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
else
|
||||
*iIter = MoveRawData( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// recupero riferimento del grezzo (coincide con quello globale)
|
||||
Frame3d* pfrRaw = m_pGeomDB->GetGroupFrame( nRawId) ;
|
||||
// lo trasformo nel nuovo riferimento
|
||||
pfrRaw->Set( pfrRaw->Orig(), dAngCDeg, dAngADeg, dAngC1Deg) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::RemoveRawPart( int nRawId)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// elimino i movimenti registrati per questo grezzo
|
||||
while ( true) {
|
||||
auto iIter = find_if( m_vMvrData.begin(), m_vMvrData.end(),
|
||||
[ nRawId]( const MoveRawData& Mrv)
|
||||
{ return ( Mrv.nRawId == nRawId) ; }) ;
|
||||
if ( iIter == m_vMvrData.end())
|
||||
break ;
|
||||
else
|
||||
m_vMvrData.erase( iIter) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::VerifyFixture( int nFixtId) const
|
||||
{
|
||||
// verifico MachMgr e GeomDB
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gruppo delle fixtures nella macchinata corrente
|
||||
int nFixtGrpId = m_pMchMgr->GetCurrFixtGroupId() ;
|
||||
if ( nFixtGrpId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// verifico che l'oggetto appartenga al gruppo delle fixtures
|
||||
if ( m_pGeomDB->GetParentId( nFixtId) != nFixtGrpId)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::VerifyRawPart( int nRawId) const
|
||||
{
|
||||
// verifico MachMgr e GeomDB
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gruppo dei grezzi nella macchinata corrente
|
||||
int nRawGroupId = m_pMchMgr->GetCurrRawGroupId() ;
|
||||
if ( nRawGroupId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// verifico che questo grezzo ne faccia parte
|
||||
if ( m_pGeomDB->GetParentId( nRawId) != nRawGroupId)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Disposition.h Data : 27.05.15 Versione : 1.6e7
|
||||
// Contenuto : Dichiarazione della classe Disposition.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.05.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkObjUser.h"
|
||||
#include "/EgtDev/Include/EgtNumCollection.h"
|
||||
#include <string>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct FixtureData
|
||||
{
|
||||
std::string sName ; // nome del dispositivo di bloccaggio
|
||||
int nId ; // identificativo
|
||||
Point3d ptPos ; // posizione nel riferimento tavola
|
||||
FixtureData( void)
|
||||
: sName(), nId( GDB_ID_NULL), ptPos() {}
|
||||
FixtureData( const std::string& sN, int nI, const Point3d& ptP)
|
||||
: sName( sN), nId( nI), ptPos( ptP) {}
|
||||
} ;
|
||||
typedef std::vector<FixtureData> FIXDATAVECTOR ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct MoveRawData
|
||||
{
|
||||
int nRawId ; // identificativo del grezzo
|
||||
int nType ; // tipo di movimento ( 1=MoveToCorner, 2=MoveToCenter, 3=Rotate)
|
||||
Point3d ptP ; // punto di riferimento / angoli di Eulero CAC'
|
||||
int nFlag ; // flag tipo movimento/rotazione
|
||||
enum { NONE = 0, COR = 1, CEN = 2, ROT = 3} ;
|
||||
MoveRawData( void)
|
||||
: nRawId( 0), nType( NONE), ptP(), nFlag( 0) {}
|
||||
MoveRawData( int nId, int nT, const Point3d& ptR, int nF)
|
||||
: nRawId( nId), nType( nT), ptP( ptR), nFlag( nF) {}
|
||||
} ;
|
||||
typedef std::vector<MoveRawData> MVRDATAVECTOR ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static std::string DIS_TABLE = "Tab" ;
|
||||
static std::string DIS_FXD_TOT = "FxT" ;
|
||||
static std::string DIS_FXD_NAME = "FxN" ;
|
||||
static std::string DIS_FXD_POS = "FxP" ;
|
||||
static std::string DIS_MVD_TOT = "MvT" ;
|
||||
static std::string DIS_MVD_ID = "MvI" ;
|
||||
static std::string DIS_MVD_TYPE = "MvT" ;
|
||||
static std::string DIS_MVD_PNT = "MvP" ;
|
||||
static std::string DIS_MVD_ANG = "MvA" ;
|
||||
static std::string DIS_MVD_FLAG = "MvF" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class Disposition : public IObjUser
|
||||
{
|
||||
public :
|
||||
virtual Disposition* Clone( void) const ;
|
||||
virtual const std::string& GetClassName( void) const ;
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool ToSave( void) const { return true ; }
|
||||
virtual bool Save( STRVECTOR& vString) const ;
|
||||
virtual bool Load( const STRVECTOR& vString) ;
|
||||
virtual bool SetOwner( int nId, IGeomDB* pGDB) ;
|
||||
virtual int GetOwner( void) const ;
|
||||
virtual IGeomDB* GetGeomDB( void) const ;
|
||||
|
||||
public :
|
||||
Disposition( void) ;
|
||||
bool Init( MachMgr* pMchMgr) ;
|
||||
bool SetTable( const std::string& sTable) ;
|
||||
bool Apply( void) ;
|
||||
int AddSubPiece( const std::string& sName, const Point3d& ptPos, bool bAddToList = true) ;
|
||||
bool MoveSubPiece( int nId, const Vector3d& vtMove) ;
|
||||
bool RemoveSubPiece( int nId) ;
|
||||
bool MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList = true) ;
|
||||
bool MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, bool bAddToList = true) ;
|
||||
bool MoveRawPart( int nRawId, const Vector3d& vtMove) ;
|
||||
bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ;
|
||||
bool ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADeg, double dAngC1Deg) ;
|
||||
bool RemoveRawPart( int nRawId) ;
|
||||
|
||||
private :
|
||||
bool VerifyFixture( int nFixtId) const ;
|
||||
bool VerifyRawPart( int nRawId) const ;
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
|
||||
std::string m_sTabName ; // nome della tavola di appartenenza
|
||||
Point3d m_ptRef1 ; // origine 1 della tavola
|
||||
bool m_bTabOk ; // flag di tavola verificata
|
||||
FIXDATAVECTOR m_vFixData ; // elenco posizionamento bloccaggi
|
||||
MVRDATAVECTOR m_vMvrData ; // elenco movimenti grezzi
|
||||
} ;
|
||||
+28
-15
@@ -39,9 +39,11 @@ Drilling::Clone( void) const
|
||||
Drilling* pDri = new(nothrow) Drilling ;
|
||||
// eseguo copia dei dati
|
||||
if ( pDri != nullptr) {
|
||||
try { pDri->m_nOwnerId = GDB_ID_NULL ;
|
||||
pDri->m_Params = m_Params ;
|
||||
pDri->m_TParams = m_TParams ;
|
||||
try {
|
||||
pDri->m_nOwnerId = GDB_ID_NULL ;
|
||||
pDri->m_pGeomDB = nullptr ;
|
||||
pDri->m_Params = m_Params ;
|
||||
pDri->m_TParams = m_TParams ;
|
||||
}
|
||||
catch( ...) {
|
||||
delete pDri ;
|
||||
@@ -74,18 +76,20 @@ bool
|
||||
Drilling::Save( STRVECTOR& vString) const
|
||||
{
|
||||
try {
|
||||
vString.insert( vString.begin(), 8, "") ;
|
||||
if ( ! SetVal( DRI_IDS, m_Params.m_vId, vString[0]) ||
|
||||
! SetVal( DRI_INV, m_Params.m_bInvert, vString[1]) ||
|
||||
! SetVal( DRI_SPS, m_Params.m_dStartPos, vString[2]) ||
|
||||
! SetVal( DRI_SSL, m_Params.m_dStartSlowLen, vString[3]) ||
|
||||
! SetVal( DRI_ESL, m_Params.m_dEndSlowLen, vString[4]) ||
|
||||
! SetVal( DRI_TAL, m_Params.m_dThroughAddLen, vString[5]) ||
|
||||
! SetVal( DRI_STP, m_Params.m_dStep, vString[6]) ||
|
||||
! SetVal( DRI_RPS, m_Params.m_dReturnPos, vString[7]))
|
||||
vString.insert( vString.begin(), 8, "") ;
|
||||
if ( ! SetVal( DRI_IDS, m_Params.m_vId, vString[0]) ||
|
||||
! SetVal( DRI_INV, m_Params.m_bInvert, vString[1]) ||
|
||||
! SetVal( DRI_SPS, m_Params.m_dStartPos, vString[2]) ||
|
||||
! SetVal( DRI_SSL, m_Params.m_dStartSlowLen, vString[3]) ||
|
||||
! SetVal( DRI_ESL, m_Params.m_dEndSlowLen, vString[4]) ||
|
||||
! SetVal( DRI_TAL, m_Params.m_dThroughAddLen, vString[5]) ||
|
||||
! SetVal( DRI_STP, m_Params.m_dStep, vString[6]) ||
|
||||
! SetVal( DRI_RPS, m_Params.m_dReturnPos, vString[7]))
|
||||
return false ;
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
}
|
||||
catch( ...) { return false ;}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -109,10 +113,11 @@ Drilling::Load( const STRVECTOR& vString)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Drilling::SetOwner( int nId)
|
||||
Drilling::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
return true ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -122,11 +127,19 @@ Drilling::GetOwner( void) const
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Drilling::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Drilling::Drilling( void)
|
||||
{
|
||||
m_nOwnerId = GDB_ID_NULL ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_Params.m_bInvert = false ;
|
||||
m_Params.m_dStartPos = 5 ;
|
||||
m_Params.m_dStartSlowLen = 0 ;
|
||||
|
||||
+3
-1
@@ -68,8 +68,9 @@ class Drilling : public IObjUser
|
||||
virtual bool ToSave( void) const { return true ; }
|
||||
virtual bool Save( STRVECTOR& vString) const ;
|
||||
virtual bool Load( const STRVECTOR& vString) ;
|
||||
virtual bool SetOwner( int nId) ;
|
||||
virtual bool SetOwner( int nId, IGeomDB* pGDB) ;
|
||||
virtual int GetOwner( void) const ;
|
||||
virtual IGeomDB* GetGeomDB( void) const ;
|
||||
|
||||
public :
|
||||
Drilling( void) ;
|
||||
@@ -77,6 +78,7 @@ class Drilling : public IObjUser
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
DrillingParams m_Params ;
|
||||
DrillBitParams m_TParams ;
|
||||
} ;
|
||||
@@ -205,6 +205,12 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Axis.cpp" />
|
||||
<ClCompile Include="Disposition.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Drilling.cpp" />
|
||||
<ClCompile Include="EMkDllMain.cpp" />
|
||||
<ClCompile Include="Exit.cpp" />
|
||||
@@ -234,6 +240,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EMkDllMain.h" />
|
||||
<ClInclude Include="..\Include\EMkMachMgr.h" />
|
||||
<ClInclude Include="Axis.h" />
|
||||
<ClInclude Include="Disposition.h" />
|
||||
<ClInclude Include="DllMain.h" />
|
||||
<ClInclude Include="Drilling.h" />
|
||||
<ClInclude Include="Exit.h" />
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<Filter Include="Source Files\Machine">
|
||||
<UniqueIdentifier>{d6353594-7db7-4dc2-8d9e-3e7524b9327f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\Machinings">
|
||||
<Filter Include="Source Files\Operations">
|
||||
<UniqueIdentifier>{3e3114d1-29a3-4acb-8f29-916ef8d05592}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
@@ -76,7 +76,7 @@
|
||||
<Filter>Source Files\Machine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Drilling.cpp">
|
||||
<Filter>Source Files\Machinings</Filter>
|
||||
<Filter>Source Files\Operations</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GeoCalc.cpp">
|
||||
<Filter>Source Files\Machine</Filter>
|
||||
@@ -87,6 +87,9 @@
|
||||
<ClCompile Include="Exit.cpp">
|
||||
<Filter>Source Files\Machine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Disposition.cpp">
|
||||
<Filter>Source Files\Operations</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DllMain.h">
|
||||
@@ -134,6 +137,9 @@
|
||||
<ClInclude Include="MachineStruConst.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Disposition.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtMachKernel.rc">
|
||||
|
||||
@@ -40,6 +40,7 @@ Exit::Clone( void) const
|
||||
// eseguo copia dei dati
|
||||
if ( pExit != nullptr) {
|
||||
try { pExit->m_nOwnerId = GDB_ID_NULL ;
|
||||
pExit->m_pGeomDB = nullptr ;
|
||||
pExit->m_sName = m_sName ;
|
||||
pExit->m_ptPos = m_ptPos ;
|
||||
pExit->m_vtTDir = m_vtTDir ;
|
||||
@@ -69,10 +70,11 @@ Exit::Dump( string& sOut, const char* szNewLine) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Exit::SetOwner( int nId)
|
||||
Exit::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
return true ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -82,10 +84,17 @@ Exit::GetOwner( void) const
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Exit::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Exit::Exit( void)
|
||||
: m_nOwnerId( GDB_ID_NULL)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ class Exit : public IObjUser
|
||||
virtual Exit* Clone( void) const ;
|
||||
virtual const std::string& GetClassName( void) const ;
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool SetOwner( int nId) ;
|
||||
virtual bool SetOwner( int nId, IGeomDB* pGDB) ;
|
||||
virtual int GetOwner( void) const ;
|
||||
virtual IGeomDB* GetGeomDB( void) const ;
|
||||
|
||||
public :
|
||||
Exit( void) ;
|
||||
@@ -38,6 +39,7 @@ class Exit : public IObjUser
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
std::string m_sName ;
|
||||
Point3d m_ptPos ;
|
||||
Vector3d m_vtTDir ;
|
||||
|
||||
@@ -40,6 +40,7 @@ Head::Clone( void) const
|
||||
// eseguo copia dei dati
|
||||
if ( pHead != nullptr) {
|
||||
try { pHead->m_nOwnerId = GDB_ID_NULL ;
|
||||
pHead->m_pGeomDB = nullptr ;
|
||||
pHead->m_sName = m_sName ;
|
||||
pHead->m_nType = m_nType ;
|
||||
pHead->m_vsHSet = m_vsHSet ;
|
||||
@@ -69,10 +70,11 @@ Head::Dump( string& sOut, const char* szNewLine) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Head::SetOwner( int nId)
|
||||
Head::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
return true ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -82,10 +84,17 @@ Head::GetOwner( void) const
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Head::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Head::Head( void)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_nType( MCH_HT_NONE)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_nType( MCH_HT_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ class Head : public IObjUser
|
||||
virtual Head* Clone( void) const ;
|
||||
virtual const std::string& GetClassName( void) const ;
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool SetOwner( int nId) ;
|
||||
virtual bool SetOwner( int nId, IGeomDB* pGDB) ;
|
||||
virtual int GetOwner( void) const ;
|
||||
virtual IGeomDB* GetGeomDB( void) const ;
|
||||
|
||||
public :
|
||||
Head( void) ;
|
||||
@@ -38,6 +39,7 @@ class Head : public IObjUser
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
std::string m_sName ;
|
||||
int m_nType ;
|
||||
STRVECTOR m_vsHSet ;
|
||||
|
||||
@@ -37,8 +37,6 @@ struct MachGrp {
|
||||
//----------------------------------------------------------------------------
|
||||
class MachMgr : public IMachMgr
|
||||
{
|
||||
friend class Machine ;
|
||||
|
||||
public :
|
||||
// Basic
|
||||
virtual ~MachMgr( void) ;
|
||||
@@ -66,10 +64,10 @@ class MachMgr : public IMachMgr
|
||||
virtual int AddRawPartWithPart( int nPartId, int nCrvSrfId, double dOverMat, Color cCol) ;
|
||||
virtual bool ModifyRawPartHeight( int nRawId, double dHeight) ;
|
||||
virtual bool RemoveRawPart( int nRawId) ;
|
||||
virtual bool TranslateRawPart( int nRawId, const Vector3d& vtMove) ;
|
||||
virtual bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) ;
|
||||
virtual bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) ;
|
||||
virtual bool MoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) ;
|
||||
virtual bool MoveRawPart( int nRawId, const Vector3d& vtMove) ;
|
||||
// Parts
|
||||
virtual int GetPartInRawPartNbr( int nRawId) const ;
|
||||
virtual int GetFirstPartInRawPart( int nRawId) const ;
|
||||
@@ -78,7 +76,8 @@ class MachMgr : public IMachMgr
|
||||
virtual bool RemovePartFromRawPart( int nPartId) ;
|
||||
virtual bool TranslatePartInRawPart( int nPartId, const Vector3d& vtMove) ;
|
||||
virtual bool RotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg) ;
|
||||
// Fixtures
|
||||
// Tables and Fixtures
|
||||
virtual bool SetTable( const std::string& sTable) ;
|
||||
virtual int AddSubPiece( const std::string& sName, const Point3d& ptPos) ;
|
||||
// Machine
|
||||
virtual bool SetAxisPos( const std::string& sAxis, double dVal) ;
|
||||
@@ -101,11 +100,42 @@ class MachMgr : public IMachMgr
|
||||
virtual bool GetOperationNewName( std::string& sName) const ;
|
||||
virtual std::string GetOperationName( int nId) const ;
|
||||
virtual int GetOperationId( const std::string& sName) const ;
|
||||
|
||||
// Da verificare bene
|
||||
virtual int AddDisposition( const std::string& sName) ;
|
||||
virtual int AddDrilling( const std::string& sName) ;
|
||||
|
||||
public :
|
||||
MachMgr( void) ;
|
||||
// Basic
|
||||
int GetContextId( void)
|
||||
{ return m_nContextId ; }
|
||||
IGeomDB* GetGeomDB( void)
|
||||
{ return m_pGeomDB ; }
|
||||
int GetMachBaseId( void)
|
||||
{ return m_nMachBaseId ; }
|
||||
int GetMachAuxId( void)
|
||||
{ return m_nMachAuxId ; }
|
||||
std::string GetLuaLibsDir( void) const
|
||||
{ return m_sLuaLibsDir ; }
|
||||
std::string GetLuaLastRequire( void) const
|
||||
{ return m_sLuaLastRequire ; }
|
||||
// MachGroups
|
||||
std::string GetCurrMGeoName( void) const
|
||||
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.MGeoName : "") ; }
|
||||
std::string GetCurrFixtDir( void) const
|
||||
{ return ( ExistsCurrMachGroup() ? m_sMachinesDir+"\\"+m_cCurrMGrp.MGeoName+"\\"+FIXTURES_DIR : "") ; }
|
||||
int GetCurrSetupGroupId( void) const
|
||||
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.SetupGroupId : GDB_ID_NULL) ; }
|
||||
int GetCurrFixtGroupId( void) const
|
||||
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.FixtGroupId : GDB_ID_NULL) ; }
|
||||
int GetCurrRawGroupId( void) const
|
||||
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.RawGroupId : GDB_ID_NULL) ; }
|
||||
int GetCurrOperId( void) const
|
||||
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.OperGroupId : GDB_ID_NULL) ; }
|
||||
// RawParts
|
||||
bool GetRawPartCenter( int nRawId, Point3d& ptCen) ;
|
||||
// Machines
|
||||
Machine* GetCurrMachine( void) const ;
|
||||
|
||||
private :
|
||||
// Basic
|
||||
@@ -119,21 +149,8 @@ class MachMgr : public IMachMgr
|
||||
bool CreateMachAux( void) ;
|
||||
// MachGroups
|
||||
bool VerifyMachGroup( int nId, MachGrp& mgData) const ;
|
||||
std::string GetCurrMGeoName( void) const
|
||||
{ return ( m_pGeomDB == nullptr) ? "" :
|
||||
(( m_nCurrMGrpId == GDB_ID_NULL) ? "" : m_cCurrMGrp.MGeoName) ; }
|
||||
int GetCurrSetupGroupId( void) const
|
||||
{ return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
|
||||
(( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.SetupGroupId) ; }
|
||||
int GetCurrFixtGroupId( void) const
|
||||
{ return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
|
||||
(( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.FixtGroupId) ; }
|
||||
int GetCurrRawGroupId( void) const
|
||||
{ return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
|
||||
(( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.RawGroupId) ; }
|
||||
int GetCurrOperId( void) const
|
||||
{ return ( m_pGeomDB == nullptr) ? GDB_ID_NULL :
|
||||
(( m_nCurrMGrpId == GDB_ID_NULL) ? GDB_ID_NULL : m_cCurrMGrp.OperGroupId) ; }
|
||||
bool ExistsCurrMachGroup( void) const
|
||||
{ return ( m_pGeomDB != nullptr && m_nCurrMGrpId != GDB_ID_NULL) ; }
|
||||
// Machines
|
||||
bool LoadMachine( const std::string& sMachineName) ;
|
||||
int GetMachine( const std::string& sMachineName) const ;
|
||||
@@ -144,7 +161,6 @@ class MachMgr : public IMachMgr
|
||||
bool VerifyRawPart( int nRawId) const ;
|
||||
bool SetRawPartCenter( int nRawId) ;
|
||||
bool ResetRawPartCenter( int nRawId) ;
|
||||
bool GetRawPartCenter( int nRawId, Point3d& ptCen) ;
|
||||
// Parts
|
||||
bool AddPartToRawPart( int nPartId, int nRawId) ;
|
||||
bool SwapParts( bool bToRawPart) ;
|
||||
@@ -155,15 +171,15 @@ class MachMgr : public IMachMgr
|
||||
typedef std::vector<Machine*> MCHPVECTOR ;
|
||||
|
||||
private :
|
||||
int m_nContextId ; // 1-based
|
||||
IGeomDB* m_pGeomDB ;
|
||||
std::string m_sMachinesDir ;
|
||||
std::string m_sLuaLibsDir ;
|
||||
std::string m_sLuaLastRequire ;
|
||||
int m_nMachBaseId ;
|
||||
int m_nMachAuxId ;
|
||||
int m_nCurrMGrpId ;
|
||||
MachGrp m_cCurrMGrp ;
|
||||
int m_nCurrMch ; // 0-based
|
||||
MCHPVECTOR m_vMachines ;
|
||||
int m_nContextId ; // indice contesto corrente (1-based)
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico del contesto corrente
|
||||
std::string m_sMachinesDir ; // direttorio delle macchine
|
||||
std::string m_sLuaLibsDir ; // direttorio delle librerie lua
|
||||
std::string m_sLuaLastRequire ; // nome ultima libreria caricata
|
||||
int m_nMachBaseId ; // identificativo gruppo base per le macchinate
|
||||
int m_nMachAuxId ; // identificativo gruppo base per le macchine
|
||||
int m_nCurrMGrpId ; // identificativo macchinata corrente
|
||||
MachGrp m_cCurrMGrp ; // dati principali macchinata corrente
|
||||
int m_nCurrMch ; // indice macchina corrente (0-based)
|
||||
MCHPVECTOR m_vMachines ; // elenco macchine caricate
|
||||
} ;
|
||||
|
||||
+19
-18
@@ -16,32 +16,33 @@
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
#include "MachConst.h"
|
||||
#include "Disposition.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SetTable( const string& sTable)
|
||||
{
|
||||
// imposto la tavola per la disposizione ( e il calcolo)
|
||||
int nDispId = GetFirstOperation() ;
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
return ( pDisp != nullptr && pDisp->SetTable( sTable)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::AddSubPiece( const string& sName, const Point3d& ptPos)
|
||||
{
|
||||
// recupero il gruppo delle fixtures nella macchinata corrente
|
||||
int nFixtGrpId = GetCurrFixtGroupId() ;
|
||||
if ( nFixtGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// verifico esistenza file sottopezzo
|
||||
string sFixtFile = m_sMachinesDir + "\\" + GetCurrMGeoName() + "\\" + FIXTURES_DIR + "\\" + sName + ".Nge" ;
|
||||
if ( ! ExistsFile( sFixtFile))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il sottopezzo nel gruppo
|
||||
if ( ! m_pGeomDB->Load( sFixtFile, nFixtGrpId))
|
||||
return GDB_ID_NULL ;
|
||||
int nFixtId = m_pGeomDB->GetLastGroupInGroup( nFixtGrpId) ;
|
||||
if ( nFixtId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// la muovo nella posizione voluta
|
||||
Vector3d vtMove = ptPos - ORIG ;
|
||||
m_pGeomDB->TranslateGlob( nFixtId, vtMove) ;
|
||||
return nFixtId ;
|
||||
// recupero la prima operazione, deve essere la disposizione
|
||||
int nDispId = GetFirstOperation() ;
|
||||
// recupero l'oggetto disposizione
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
if ( pDisp == nullptr)
|
||||
return false ;
|
||||
// eseguo l'operazione
|
||||
return pDisp->AddSubPiece( sName, ptPos) ;
|
||||
}
|
||||
|
||||
+15
-1
@@ -16,6 +16,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
#include "MachConst.h"
|
||||
#include "Disposition.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
@@ -124,6 +125,11 @@ MachMgr::AddMachGroup( const string& sName, const string& sMachineName)
|
||||
m_pGeomDB->Erase( nNewId) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
// inserisco la prima operazione, sempre disposizione iniziale
|
||||
if ( ! AddDisposition( "Disp")) {
|
||||
m_pGeomDB->Erase( nNewId) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
// restituisco l'identificativo del gruppo
|
||||
return nNewId ;
|
||||
}
|
||||
@@ -286,7 +292,15 @@ MachMgr::SetCurrMachGroup( int nId)
|
||||
// rendo visibile il nuovo gruppo corrente e la relativa macchina
|
||||
m_pGeomDB->SetStatus( m_nCurrMGrpId, GDB_ST_ON) ;
|
||||
m_pGeomDB->SetStatus( GetCurrMGeoId(), GDB_ST_ON) ;
|
||||
return true ;
|
||||
// eseguo la prima operazione di disposizione
|
||||
int nDispId = GetFirstOperation() ;
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
if ( pDisp != nullptr) {
|
||||
pDisp->Init( this) ;
|
||||
return pDisp->Apply() ;
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+10
-1
@@ -40,7 +40,7 @@ MachMgr::LoadMachine( const string& sMachineName)
|
||||
if ( IsNull( pMch))
|
||||
return false ;
|
||||
// tento di caricarla
|
||||
if ( pMch->Init( sMachineName, this)) {
|
||||
if ( pMch->Init( m_sMachinesDir, sMachineName, this)) {
|
||||
m_vMachines.push_back( Release( pMch)) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -70,6 +70,15 @@ MachMgr::GetCurrMGeoId( void) const
|
||||
return m_vMachines[m_nCurrMch]->GetMGeoId() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Machine*
|
||||
MachMgr::GetCurrMachine( void) const
|
||||
{
|
||||
if ( m_nCurrMch < 0 || m_nCurrMch >= int( m_vMachines.size()))
|
||||
return nullptr ;
|
||||
return m_vMachines[m_nCurrMch] ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::SetAxisPos( const string& sAxis, double dVal)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
#include "MachConst.h"
|
||||
#include "Disposition.h"
|
||||
#include "Drilling.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
@@ -132,6 +133,33 @@ MachMgr::GetOperationId( const string& sName) const
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::AddDisposition( const string& sName)
|
||||
{
|
||||
// recupero il gruppo delle operazioni nella macchinata corrente
|
||||
int nOperGrpId = GetCurrOperId() ;
|
||||
if ( nOperGrpId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero nome originale, partendo da quello proposto
|
||||
string sNewName = sName ;
|
||||
if ( ! GetOperationNewName( sNewName))
|
||||
return GDB_ID_NULL ;
|
||||
// inserisco il gruppo
|
||||
int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// assegno il nome
|
||||
m_pGeomDB->SetName( nId, sNewName) ;
|
||||
// installo il gestore della lavorazione
|
||||
Disposition* pDisp = new(nothrow) Disposition ;
|
||||
if ( pDisp == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
pDisp->Init( this) ;
|
||||
m_pGeomDB->SetObjUser( nId, pDisp) ;
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
MachMgr::AddDrilling( const string& sName)
|
||||
|
||||
+35
-76
@@ -16,6 +16,7 @@
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
#include "MachConst.h"
|
||||
#include "Disposition.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
@@ -332,102 +333,60 @@ MachMgr::VerifyRawPart( int nRawId) const
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::TranslateRawPart( int nRawId, const Vector3d& vtMove)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
return false ;
|
||||
// eseguo traslazione in globale
|
||||
return m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
// recupero la prima operazione, deve essere la disposizione
|
||||
int nDispId = GetFirstOperation() ;
|
||||
// recupero l'oggetto disposizione
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
if ( pDisp == nullptr)
|
||||
return false ;
|
||||
// recupero centro del grezzo
|
||||
Point3d ptAx ;
|
||||
if ( ! GetRawPartCenter( nRawId, ptAx))
|
||||
return false ;
|
||||
// eseguo rotazione in globale attorno al centro del grezzo
|
||||
return m_pGeomDB->RotateGlob( nRawId, ptAx, vtAx, dAngRotDeg) ;
|
||||
// eseguo l'operazione
|
||||
return pDisp->RotateRawPart( nRawId, vtAx, dAngRotDeg) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
// recupero la prima operazione, deve essere la disposizione
|
||||
int nDispId = GetFirstOperation() ;
|
||||
// recupero l'oggetto disposizione
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
if ( pDisp == nullptr)
|
||||
return false ;
|
||||
// recupero il solido
|
||||
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
// determino il box del grezzo (solo il solido ovviamente)
|
||||
BBox3d b3Raw ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
|
||||
return false ;
|
||||
// calcolo il movimento necessario
|
||||
Vector3d vtMove ;
|
||||
switch ( nFlag) {
|
||||
case MCH_CR_TL :
|
||||
vtMove = ptP - Point3d( b3Raw.GetMin().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
case MCH_CR_TR :
|
||||
vtMove = ptP - Point3d( b3Raw.GetMax().x, b3Raw.GetMax().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
default : // RPCP_BL
|
||||
vtMove = ptP - b3Raw.GetMin() ;
|
||||
break ;
|
||||
case MCH_CR_BR :
|
||||
vtMove = ptP - Point3d( b3Raw.GetMax().x, b3Raw.GetMin().y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
// eseguo traslazione in globale
|
||||
return m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
// eseguo l'operazione
|
||||
return pDisp->MoveToCornerRawPart( nRawId, ptP, nFlag) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag)
|
||||
{
|
||||
// verifica validità grezzo
|
||||
if ( ! VerifyRawPart( nRawId))
|
||||
// recupero la prima operazione, deve essere la disposizione
|
||||
int nDispId = GetFirstOperation() ;
|
||||
// recupero l'oggetto disposizione
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
if ( pDisp == nullptr)
|
||||
return false ;
|
||||
// recupero il solido
|
||||
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
// determino il box del grezzo (solo il solido ovviamente)
|
||||
BBox3d b3Raw ;
|
||||
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
|
||||
// eseguo l'operazione
|
||||
return pDisp->MoveToCenterRawPart( nRawId, ptP, nFlag) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::MoveRawPart( int nRawId, const Vector3d& vtMove)
|
||||
{
|
||||
// recupero la prima operazione, deve essere la disposizione
|
||||
int nDispId = GetFirstOperation() ;
|
||||
// recupero l'oggetto disposizione
|
||||
Disposition* pDisp = dynamic_cast<Disposition*>( m_pGeomDB->GetObjUser( nDispId)) ;
|
||||
if ( pDisp == nullptr)
|
||||
return false ;
|
||||
// ricavo il centro dal box (in generale non è il centro geometrico)
|
||||
Point3d ptCen ;
|
||||
b3Raw.GetCenter( ptCen) ;
|
||||
// calcolo il movimento necessario
|
||||
Vector3d vtMove ;
|
||||
switch ( nFlag) {
|
||||
case MCH_CE_TC :
|
||||
vtMove = ptP - Point3d( ptCen.x, b3Raw.GetMax().y, ptCen.z) ;
|
||||
break ;
|
||||
default : // RPCE_ML
|
||||
vtMove = ptP - Point3d( b3Raw.GetMin().x, ptCen.y, ptCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_MR :
|
||||
vtMove = ptP - Point3d( b3Raw.GetMax().x, ptCen.y, ptCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_BC :
|
||||
vtMove = ptP - Point3d( ptCen.x, b3Raw.GetMin().y, ptCen.z) ;
|
||||
break ;
|
||||
case MCH_CE_MC :
|
||||
vtMove = ptP - Point3d( ptCen.x, ptCen.y, b3Raw.GetMin().z) ;
|
||||
break ;
|
||||
}
|
||||
// eseguo traslazione in globale
|
||||
return m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
|
||||
// eseguo l'operazione
|
||||
return pDisp->MoveRawPart( nRawId,vtMove) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+221
-98
@@ -21,7 +21,7 @@
|
||||
#include "Exit.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
@@ -31,7 +31,9 @@ using namespace std ;
|
||||
Machine::Machine( void)
|
||||
{
|
||||
m_pMchMgr = nullptr ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_nGroupId = GDB_ID_NULL ;
|
||||
m_nTempGroupId = GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -45,16 +47,17 @@ void
|
||||
Machine::Clear( void)
|
||||
{
|
||||
// cancellazione eventuali gruppi geometrici associati
|
||||
if ( m_pMchMgr != nullptr && m_pMchMgr->m_pGeomDB != nullptr) {
|
||||
if ( m_pGeomDB != nullptr) {
|
||||
if ( m_nGroupId != GDB_ID_NULL)
|
||||
m_pMchMgr->m_pGeomDB->Erase( m_nGroupId) ;
|
||||
m_pGeomDB->Erase( m_nGroupId) ;
|
||||
if ( m_nTempGroupId != GDB_ID_NULL)
|
||||
m_pMchMgr->m_pGeomDB->Erase( m_nTempGroupId) ;
|
||||
m_pGeomDB->Erase( m_nTempGroupId) ;
|
||||
}
|
||||
// pulizia interprete lua di macchina
|
||||
LuaExit() ;
|
||||
// reset membri
|
||||
m_pMchMgr = nullptr ;
|
||||
m_pGeomDB = nullptr ;
|
||||
m_sName.clear() ;
|
||||
m_sMachineDir.clear() ;
|
||||
m_nGroupId = GDB_ID_NULL ;
|
||||
@@ -65,27 +68,28 @@ Machine::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::Init( const std::string& sMachineName, MachMgr* pMchMgr)
|
||||
Machine::Init( const string& sMachinesDir, const string& sMachineName, MachMgr* pMchMgr)
|
||||
{
|
||||
// pulisco
|
||||
Clear() ;
|
||||
// verifico ambiente
|
||||
if ( pMchMgr == nullptr || pMchMgr->m_nContextId == 0 || pMchMgr->m_pGeomDB == nullptr)
|
||||
if ( pMchMgr == nullptr || pMchMgr->GetContextId() == 0 || pMchMgr->GetGeomDB() == nullptr)
|
||||
return false ;
|
||||
m_pMchMgr = pMchMgr ;
|
||||
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
|
||||
// verifico direttorio dati macchina
|
||||
m_sMachineDir = pMchMgr->m_sMachinesDir + "\\" + sMachineName ;
|
||||
m_sMachineDir = sMachinesDir + "\\" + sMachineName ;
|
||||
if ( ! ExistsDirectory( m_sMachineDir))
|
||||
return false ;
|
||||
// creo il gruppo per la macchina
|
||||
int nId = pMchMgr->m_pGeomDB->InsertGroup( GDB_ID_NULL, pMchMgr->m_nMachAuxId, GDB_LAST_SON, GLOB_FRM) ;
|
||||
int nId = m_pGeomDB->InsertGroup( GDB_ID_NULL, pMchMgr->GetMachAuxId(), GDB_LAST_SON, GLOB_FRM) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// imposto nome del gruppo
|
||||
pMchMgr->m_pGeomDB->SetName( nId, sMachineName) ;
|
||||
m_pGeomDB->SetName( nId, sMachineName) ;
|
||||
// carico l'interprete lua dedicato alla macchina
|
||||
if ( ! LuaInit( sMachineName)) {
|
||||
pMchMgr->m_pGeomDB->Erase( nId) ;
|
||||
m_pGeomDB->Erase( nId) ;
|
||||
return false ;
|
||||
}
|
||||
// salvo i dati
|
||||
@@ -95,17 +99,19 @@ Machine::Init( const std::string& sMachineName, MachMgr* pMchMgr)
|
||||
string sMachineMde = m_sMachineDir + "\\" + sMachineName + ".Mde" ;
|
||||
bool bOk = LuaExecFile( sMachineMde) ;
|
||||
// cancello il gruppo temporaneo
|
||||
pMchMgr->m_pGeomDB->Erase( m_nTempGroupId) ;
|
||||
m_pGeomDB->Erase( m_nTempGroupId) ;
|
||||
m_nTempGroupId = GDB_ID_NULL ;
|
||||
// in caso di errore, cancello tutta la geometria
|
||||
if ( ! bOk) {
|
||||
pMchMgr->m_pGeomDB->Erase( m_nGroupId) ;
|
||||
pMchMgr->m_pGeomDB->Erase( m_nTempGroupId) ;
|
||||
m_pGeomDB->Erase( m_nGroupId) ;
|
||||
m_pGeomDB->Erase( m_nTempGroupId) ;
|
||||
m_nGroupId = GDB_ID_NULL ;
|
||||
m_nTempGroupId = GDB_ID_NULL ;
|
||||
m_sName.clear() ;
|
||||
m_sMachineDir.clear() ;
|
||||
}
|
||||
// metto tutti gli assi in posizione home
|
||||
bOk = bOk && ResetAllAxesPos() ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -114,15 +120,15 @@ bool
|
||||
Machine::LoadMachineGeometry( const string& sMGeoName, const Vector3d& vtOffset)
|
||||
{
|
||||
// creo un sotto gruppo temporaneo in cui caricare la macchina
|
||||
m_nTempGroupId = m_pMchMgr->m_pGeomDB->AddGroup( GDB_ID_NULL, m_pMchMgr->m_nMachAuxId, GLOB_FRM) ;
|
||||
m_nTempGroupId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_pMchMgr->GetMachAuxId(), GLOB_FRM) ;
|
||||
if ( m_nTempGroupId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// carico la macchina
|
||||
string sMachineNge = m_sMachineDir + "\\" + sMGeoName ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->Load( sMachineNge, m_nTempGroupId))
|
||||
if ( ! m_pGeomDB->Load( sMachineNge, m_nTempGroupId))
|
||||
return false ;
|
||||
// applico offset
|
||||
return m_pMchMgr->m_pGeomDB->TranslateGlob( m_nTempGroupId, vtOffset) ;
|
||||
return m_pGeomDB->TranslateGlob( m_nTempGroupId, vtOffset) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -133,80 +139,127 @@ Machine::LoadMachineBase( const string& sName, const string& sGeo)
|
||||
string sPart, sLay ;
|
||||
Split( sGeo, "/", true, sPart, sLay) ;
|
||||
// cerco il gruppo nella geometria originale
|
||||
int nPart = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
int nPart = m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
if ( nLay == GDB_ID_NULL)
|
||||
return false ;
|
||||
// lo sposto nella radice della macchina
|
||||
if ( ! m_pMchMgr->m_pGeomDB->RelocateGlob( nLay, m_nGroupId, GDB_FIRST_SON))
|
||||
if ( ! m_pGeomDB->RelocateGlob( nLay, m_nGroupId, GDB_FIRST_SON))
|
||||
return false ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
m_pGeomDB->SetName( nLay, sName) ;
|
||||
// lo inserisco nel dizionario dei gruppi della macchina
|
||||
return m_mapGroups.emplace( sName, nLay).second ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::LoadMachineTable( const string& sName, const string& sParent, int nType, const string& sGeo)
|
||||
Machine::LoadMachineTable( const string& sName, const string& sParent, int nType,
|
||||
const Point3d& ptRef1, const string& sGeo)
|
||||
{
|
||||
// recupero pezzo e layer della geometria originale della tavola
|
||||
string sPart, sLay ;
|
||||
Split( sGeo, "/", true, sPart, sLay) ;
|
||||
// cerco il gruppo nella geometria originale
|
||||
int nPart = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
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_pMchMgr->m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
return false ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
m_pGeomDB->SetName( nLay, sName) ;
|
||||
// installo e inizializzo il gestore della tavola
|
||||
Table* pTab = new(nothrow) Table ;
|
||||
if ( pTab == nullptr)
|
||||
return false ;
|
||||
pTab->Set( sName, nType) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pTab) ;
|
||||
pTab->Set( sName, nType, ptRef1) ;
|
||||
m_pGeomDB->SetObjUser( nLay, pTab) ;
|
||||
// aggiusto la posizione della tavola
|
||||
if ( ! AdjustTablePos( nLay, ptRef1))
|
||||
return false ;
|
||||
// lo inserisco nel dizionario dei gruppi della macchina
|
||||
return m_mapGroups.emplace( sName, nLay).second ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::AdjustTablePos( int nLay, const Point3d& ptRef1)
|
||||
{
|
||||
// riferimento globale del gruppo tavola
|
||||
Frame3d frTable ;
|
||||
m_pGeomDB->GetGroupGlobFrame( nLay, frTable) ;
|
||||
// recupero il primo riferimento della tavola
|
||||
int nRef1 = m_pGeomDB->GetFirstNameInGroup( nLay, MCH_TREF + "1") ;
|
||||
if ( nRef1 == GDB_ID_NULL || m_pGeomDB->GetGeoType( nRef1) != GEO_FRAME3D) {
|
||||
string sOut = " Missing " + MCH_TREF + "1" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
// recupero frame
|
||||
const Frame3d& frFrame = GetGeoFrame3d( m_pGeomDB->GetGeoObj( nRef1))->GetFrame() ;
|
||||
// ne calcolo l'origine in globale
|
||||
Point3d ptPos = frFrame.Orig() ;
|
||||
ptPos.ToGlob( frTable) ;
|
||||
// verifico eventuale aggiustamento di posizione
|
||||
Vector3d vtMove = ptRef1 - ptPos ;
|
||||
if ( ! vtMove.IsSmall()) {
|
||||
string sOut = " Move = (" + ToString( vtMove) + ")" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return m_pGeomDB->TranslateGlob( nLay, vtMove) ;
|
||||
}
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
|
||||
const Point3d& ptPos, const Vector3d& vtDir,
|
||||
const STROKE& Stroke, const string& sGeo, double dVal)
|
||||
const STROKE& Stroke, const string& sGeo, double dHome)
|
||||
{
|
||||
// verifico sia di tipo ammesso
|
||||
if ( nType != MCH_AT_LINEAR && nType != MCH_AT_ROTARY) {
|
||||
LOG_ERROR( GetEMkLogger(), " Wrong Axis Type") ;
|
||||
return false ;
|
||||
}
|
||||
// recupero pezzo e layer della geometria originale dell'asse
|
||||
string sPart, sLay ;
|
||||
Split( sGeo, "/", true, sPart, sLay) ;
|
||||
// cerco il gruppo nella geometria originale
|
||||
int nPart = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
if ( nLay == GDB_ID_NULL)
|
||||
int nPart = m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
if ( nLay == GDB_ID_NULL) {
|
||||
string sOut = " Missing Axis Part " + sPart ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
// cerco il gruppo padre per spostarvelo
|
||||
int nParentId = GetGroup( sParent) ;
|
||||
if ( nParentId == GDB_ID_NULL ||
|
||||
! m_pMchMgr->m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON)) {
|
||||
string sOut = " Missing Parent Group " + sParent ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
// verifico che il valore sia nei limiti di corsa
|
||||
if ( dVal < Stroke.Min || dVal > Stroke.Max)
|
||||
}
|
||||
// verifico che il valore di home sia nei limiti di corsa
|
||||
if ( dHome < Stroke.Min || dHome > Stroke.Max) {
|
||||
LOG_ERROR( GetEMkLogger(), " Home Position Out of stroke") ;
|
||||
return false ;
|
||||
}
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
m_pGeomDB->SetName( nLay, sName) ;
|
||||
// installo e inizializzo il gestore dell'asse
|
||||
Axis* pAxis = new(nothrow) Axis ;
|
||||
if ( pAxis == nullptr)
|
||||
return false ;
|
||||
pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dVal) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pAxis) ;
|
||||
// inserisco il vettore rappresentativo dell'asse
|
||||
if ( ! AddAxisVector( nLay, ptPos, vtDir, sName))
|
||||
pAxis->Set( sName, nType, ptPos, vtDir, Stroke, dHome) ;
|
||||
m_pGeomDB->SetObjUser( nLay, pAxis) ;
|
||||
// verifico il vettore rappresentativo dell'asse
|
||||
if ( ! AdjustAxisVector( nLay, sPart, sName, nType, ptPos, vtDir))
|
||||
return false ;
|
||||
// lo inserisco nel dizionario dei gruppi della macchina
|
||||
return m_mapGroups.emplace( sName, nLay).second ;
|
||||
@@ -214,37 +267,68 @@ Machine::LoadMachineAxis( const string& sName, const string& sParent, int nType,
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::AddAxisVector( int nLay, const Point3d& ptPos, const Vector3d& vtDir, const string& sName)
|
||||
Machine::AdjustAxisVector( int nLay, const string& sPart, const string& sName,
|
||||
int nType, const Point3d& ptPos, const Vector3d& vtDir)
|
||||
{
|
||||
// riferimento globale del gruppo asse
|
||||
Frame3d frFrame ;
|
||||
m_pMchMgr->m_pGeomDB->GetGroupGlobFrame( nLay, frFrame) ;
|
||||
// punto base e vettore in locale
|
||||
Point3d ptBase = ptPos ;
|
||||
ptBase.ToLoc( frFrame) ;
|
||||
Vector3d vtAxis = vtDir ;
|
||||
if ( ! vtAxis.Normalize())
|
||||
// verifico presenza vettore asse
|
||||
int nId = m_pGeomDB->GetFirstNameInGroup( nLay, sPart) ;
|
||||
if ( nId == GDB_ID_NULL || m_pGeomDB->GetGeoType( nId) != GEO_VECT3D) {
|
||||
string sOut = " Missing Axis Vector " + sPart ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
vtAxis *= AXIS_LEN ;
|
||||
vtAxis.ToLoc( frFrame) ;
|
||||
// vettore geometrico
|
||||
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
|
||||
if ( IsNull( pGeoVct) || ! pGeoVct->Set( vtAxis, ptBase))
|
||||
}
|
||||
// lo sposto all'inizio del suo gruppo
|
||||
if ( ! m_pGeomDB->Relocate( nId, nLay, GDB_FIRST_SON))
|
||||
return false ;
|
||||
// lo inserisco al primo posto nel gruppo
|
||||
int nId = m_pMchMgr->m_pGeomDB->InsertGeoObj( GDB_ID_NULL, nLay, GDB_FIRST_SON, Release( pGeoVct)) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// gli assegno il nome di axis
|
||||
if ( ! m_pMchMgr->m_pGeomDB->SetName( nId, sName))
|
||||
return false ;
|
||||
// gli assegno il colore blu
|
||||
if ( ! m_pMchMgr->m_pGeomDB->SetMaterial( nId, BLUE))
|
||||
// lo rinomino come l'asse
|
||||
if ( ! m_pGeomDB->SetName( nId, sName))
|
||||
return false ;
|
||||
// lo nascondo
|
||||
if ( ! m_pMchMgr->m_pGeomDB->SetStatus( nId, GDB_ST_OFF))
|
||||
if ( ! m_pGeomDB->SetStatus( nId, GDB_ST_OFF))
|
||||
return false ;
|
||||
return true ;
|
||||
|
||||
// riferimento globale del gruppo asse
|
||||
Frame3d frFrame ;
|
||||
m_pGeomDB->GetGroupGlobFrame( nLay, frFrame) ;
|
||||
// recupero punto base e vettore direzione
|
||||
IGeoVector3d* pGeoVct = GetGeoVector3d( m_pGeomDB->GetGeoObj( nId)) ;
|
||||
Point3d ptBase = pGeoVct->GetBase() ;
|
||||
Vector3d vtAxis = pGeoVct->GetVector() ;
|
||||
vtAxis.Normalize() ;
|
||||
// riassegno il vettore normalizzato
|
||||
pGeoVct->ChangeVector( vtAxis) ;
|
||||
// li porto in globale
|
||||
ptBase.ToGlob( frFrame) ;
|
||||
vtAxis.ToGlob( frFrame) ;
|
||||
|
||||
// se asse lineare devo verificarne solo la direzione
|
||||
if ( nType == MCH_AT_LINEAR) {
|
||||
Vector3d vtDirN = vtDir ;
|
||||
if ( ! vtDirN.Normalize() || ! AreSameVectorApprox( vtAxis, vtDirN)) {
|
||||
string sOut = " Wrong Axis Vector or Dir " + sPart ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// altrimenti asse rotante, devo verificarne direzione e coassialità
|
||||
else {
|
||||
Vector3d vtDirN = vtDir ;
|
||||
if ( ! vtDirN.Normalize() || ! AreSameVectorApprox( vtAxis, vtDirN)) {
|
||||
string sOut = " Wrong Axis Vector or Dir " + sPart ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
Vector3d vtDelta = ptPos - ptBase ;
|
||||
vtDelta -= ( vtDelta * vtDirN) * vtDirN ;
|
||||
if ( ! vtDelta.IsSmall()) {
|
||||
string sOut = " Wrong Axis Base move = (" + ToString( vtDelta) + ")" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -257,26 +341,26 @@ Machine::LoadMachineStdHead( const string& sName, const string& sParent, const s
|
||||
string sPart, sLay ;
|
||||
Split( sGeo, "/", true, sPart, sLay) ;
|
||||
// cerco il gruppo nella geometria originale
|
||||
int nPart = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
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_pMchMgr->m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
return false ;
|
||||
// sistemo lo stato di visualizzazione
|
||||
bool bShow = ( sHSet == sName) ;
|
||||
m_pMchMgr->m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
m_pGeomDB->SetName( nLay, sName) ;
|
||||
// installo e inizializzo il gestore della testa
|
||||
Head* pHead = new(nothrow) Head ;
|
||||
if ( pHead == nullptr)
|
||||
return false ;
|
||||
pHead->Set( sName, MCH_HT_STD, sHSet, vtADir) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pHead) ;
|
||||
m_pGeomDB->SetObjUser( nLay, pHead) ;
|
||||
// aggiorno la testa capostipite
|
||||
if ( ! AddHeadToSet( sHSet, sName))
|
||||
return false ;
|
||||
@@ -299,26 +383,26 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
|
||||
string sPart, sLay ;
|
||||
Split( sGeo, "/", true, sPart, sLay) ;
|
||||
// cerco il gruppo nella geometria originale
|
||||
int nPart = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( m_nTempGroupId, sPart) ;
|
||||
int nLay = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nPart, sLay) ;
|
||||
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_pMchMgr->m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
! m_pGeomDB->RelocateGlob( nLay, nParentId, GDB_FIRST_SON))
|
||||
return false ;
|
||||
// sistemo lo stato di visualizzazione
|
||||
bool bShow = ( sHSet == sName) ;
|
||||
m_pMchMgr->m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
m_pGeomDB->SetStatus( nLay, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
// gli assegno il nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nLay, sName) ;
|
||||
m_pGeomDB->SetName( nLay, sName) ;
|
||||
// installo e inizializzo il gestore della testa
|
||||
Head* pHead = new(nothrow) Head ;
|
||||
if ( pHead == nullptr)
|
||||
return false ;
|
||||
pHead->Set( sName, MCH_HT_MULTI, sHSet, vtADir) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nLay, pHead) ;
|
||||
m_pGeomDB->SetObjUser( nLay, pHead) ;
|
||||
// aggiorno la testa capostipite
|
||||
if ( ! AddHeadToSet( sHSet, sName))
|
||||
return false ;
|
||||
@@ -331,7 +415,7 @@ Machine::LoadMachineMultiHead( const string& sName, const string& sParent, const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machine::GetGroup( const string& sGroup)
|
||||
Machine::GetGroup( const string& sGroup) const
|
||||
{
|
||||
STRINT_UMAP::const_iterator Iter = m_mapGroups.find( sGroup) ;
|
||||
return (( Iter != m_mapGroups.end()) ? Iter->second : GDB_ID_NULL) ;
|
||||
@@ -339,30 +423,30 @@ Machine::GetGroup( const string& sGroup)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Axis*
|
||||
Machine::GetAxis( int nGroup)
|
||||
Machine::GetAxis( int nGroup) const
|
||||
{
|
||||
return ( dynamic_cast<Axis*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
return ( dynamic_cast<Axis*>( m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Table*
|
||||
Machine::GetTable( int nGroup)
|
||||
Machine::GetTable( int nGroup) const
|
||||
{
|
||||
return ( dynamic_cast<Table*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
return ( dynamic_cast<Table*>( m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Head*
|
||||
Machine::GetHead( int nGroup)
|
||||
Machine::GetHead( int nGroup) const
|
||||
{
|
||||
return ( dynamic_cast<Head*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
return ( dynamic_cast<Head*>( m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
Exit*
|
||||
Machine::GetExit( int nGroup)
|
||||
Machine::GetExit( int nGroup) const
|
||||
{
|
||||
return ( dynamic_cast<Exit*>( m_pMchMgr->m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
return ( dynamic_cast<Exit*>( m_pGeomDB->GetObjUser( nGroup))) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -382,7 +466,7 @@ Machine::AddHeadToSet( const string& sHSet, const string& sName)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const STRVECTOR&
|
||||
Machine::GetHSet( const string& sHead)
|
||||
Machine::GetHSet( const string& sHead) const
|
||||
{
|
||||
// vettore di stringhe vuoto, da restituire in caso di errore
|
||||
static const STRVECTOR vsNull ;
|
||||
@@ -413,7 +497,7 @@ Machine::EnableHeadInSet( const string& sHead)
|
||||
for ( size_t i = 0 ; i < vsHSet.size() ; ++ i) {
|
||||
int nH = GetGroup( vsHSet[i]) ;
|
||||
bool bShow = ( vsHSet[i] == sHead) ;
|
||||
m_pMchMgr->m_pGeomDB->SetStatus( nH, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
m_pGeomDB->SetStatus( nH, ( bShow ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -422,34 +506,73 @@ Machine::EnableHeadInSet( const string& sHead)
|
||||
bool
|
||||
Machine::CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit)
|
||||
{
|
||||
// riferimento globale del gruppo testa
|
||||
Frame3d frHead ;
|
||||
m_pGeomDB->GetGroupGlobFrame( nLay, 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 sostituisco con gruppo equivalente
|
||||
int nT = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nLay, sName) ;
|
||||
if ( nT != GDB_ID_NULL && m_pMchMgr->m_pGeomDB->GetGeoType( nT) == GEO_FRAME3D) {
|
||||
const Frame3d& frFrame = GetGeoFrame3d( m_pMchMgr->m_pGeomDB->GetGeoObj( nT))->GetFrame() ;
|
||||
int nGT = m_pMchMgr->m_pGeomDB->InsertGroup( GDB_ID_NULL, nT, GDB_AFTER, frFrame) ;
|
||||
if ( nGT == GDB_ID_NULL) {
|
||||
string sOut = "Error inserting group " + sName ;
|
||||
int nT = m_pGeomDB->GetFirstNameInGroup( nLay, sName) ;
|
||||
if ( nT != GDB_ID_NULL && m_pGeomDB->GetGeoType( nT) == GEO_FRAME3D) {
|
||||
// recupero frame
|
||||
const Frame3d& frFrame = GetGeoFrame3d( m_pGeomDB->GetGeoObj( nT))->GetFrame() ;
|
||||
// verifico dati frame rispetto ad uscita (in globale)
|
||||
Point3d ptPos = frFrame.Orig() ;
|
||||
ptPos.ToGlob( frHead) ;
|
||||
Vector3d vtTDir = frFrame.VersZ() ;
|
||||
vtTDir.ToGlob(frHead) ;
|
||||
vtTDir.Normalize() ;
|
||||
Vector3d vtDelta = vMuExit[i].ptPos - ptPos ;
|
||||
if ( ! vtDelta.IsSmall()) {
|
||||
string sOut = " Wrong Exit Position " + sName + " move = (" + ToString( vtDelta) +")" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
m_pMchMgr->m_pGeomDB->Erase( nT) ;
|
||||
// assegno nome
|
||||
m_pMchMgr->m_pGeomDB->SetName( nGT, sName) ;
|
||||
Vector3d vtDirN = vMuExit[i].vtTDir ;
|
||||
if ( ! vtDirN.Normalize() || ! AreSameVectorApprox( vtTDir, vtDirN)) {
|
||||
string sOut = " Wrong Exit Vector " + sName ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
// inserisco gruppo con riferimento del frame
|
||||
int nGT = m_pGeomDB->InsertGroup( GDB_ID_NULL, nT, GDB_BEFORE, frFrame) ;
|
||||
if ( nGT == GDB_ID_NULL) {
|
||||
string sOut = " Error inserting group " + sName ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
// cambio nome al riferimento e lo nascondo
|
||||
m_pGeomDB->SetName( nT, "_" + sName) ;
|
||||
m_pGeomDB->SetStatus( nT, GDB_ST_OFF) ;
|
||||
// assegno nome al gruppo
|
||||
m_pGeomDB->SetName( nGT, sName) ;
|
||||
// installo e inizializzo il gestore dell'uscita
|
||||
Exit* pExit = new(nothrow) Exit ;
|
||||
if ( pExit == nullptr)
|
||||
return false ;
|
||||
pExit->Set( sName, vMuExit[i].ptPos, vMuExit[i].vtTDir) ;
|
||||
m_pMchMgr->m_pGeomDB->SetObjUser( nGT, pExit) ;
|
||||
m_pGeomDB->SetObjUser( nGT, pExit) ;
|
||||
}
|
||||
else {
|
||||
string sOut = "Error finding frame " + sName ;
|
||||
string sOut = " Error finding frame " + sName ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::ResetAllAxesPos( void)
|
||||
{
|
||||
// ciclo sugi gruppi della macchina
|
||||
for ( auto Iter = m_mapGroups.cbegin() ; Iter != m_mapGroups.cend() ; ++ Iter) {
|
||||
if ( IsAxisGroup( Iter->second)) {
|
||||
if ( ! ResetAxisPos( Iter->first))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -30,11 +30,13 @@ class Machine
|
||||
public :
|
||||
Machine( void) ;
|
||||
~Machine( void) ;
|
||||
bool Init( const std::string& sMachineName, MachMgr* pMchMgr) ;
|
||||
int GetMGeoId( void)
|
||||
bool Init( const std::string& sMachinesDir, const std::string& sMachineName, MachMgr* pMchMgr) ;
|
||||
int GetMGeoId( void) const
|
||||
{ return m_nGroupId ; }
|
||||
const std::string& GetMachineName( void)
|
||||
const std::string& GetMachineName( void) const
|
||||
{ return m_sName ; }
|
||||
Table* GetTable( const std::string& sTable) const
|
||||
{ return GetTable( GetGroup( sTable)) ; }
|
||||
bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ;
|
||||
bool ResetHeadSet( const std::string& sHead) ;
|
||||
bool SetAxisPos( const std::string& sAxis, double dVal) ;
|
||||
@@ -53,30 +55,34 @@ class Machine
|
||||
void Clear( void) ;
|
||||
bool LoadMachineGeometry( const std::string& sMGeoName, const Vector3d& vtOffset) ;
|
||||
bool LoadMachineBase( const std::string& sName, const std::string& sGeo) ;
|
||||
bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType, const std::string& sGeo) ;
|
||||
bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType,
|
||||
const Point3d& ptRef1, const std::string& sGeo) ;
|
||||
bool AdjustTablePos( int nLay, const Point3d& ptRef1) ;
|
||||
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, int nType,
|
||||
const Point3d& ptPos, const Vector3d& vtDir,
|
||||
const STROKE& Stroke, const std::string& sGeo, double dVal) ;
|
||||
bool AddAxisVector( int nLay, const Point3d& ptPos, const Vector3d& vtDir, const std::string& sName) ;
|
||||
const STROKE& Stroke, const std::string& sGeo, double dHome) ;
|
||||
bool AdjustAxisVector( int nLay, const std::string& sPart, const std::string& sName,
|
||||
int nType, const Point3d& ptPos, const Vector3d& vtDir) ;
|
||||
bool LoadMachineStdHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
|
||||
const Point3d& ptPos, const Vector3d& vtTDir,
|
||||
const Vector3d& vtADir, const std::string& sGeo) ;
|
||||
bool LoadMachineMultiHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
|
||||
const MUEXITVECTOR& vMuExit,
|
||||
const Vector3d& vtADir, const std::string& sGeo) ;
|
||||
int GetGroup( const std::string& sGroup) ;
|
||||
Axis* GetAxis( int nGroup) ;
|
||||
bool IsAxisGroup( int nGroup) { return ( GetAxis( nGroup) != nullptr) ; }
|
||||
Table* GetTable( int nGroup) ;
|
||||
bool IsTableGroup( int nGroup) { return ( GetTable( nGroup) != nullptr) ; }
|
||||
Head* GetHead( int nGroup) ;
|
||||
bool IsHeadGroup( int nGroup) { return ( GetHead( nGroup) != nullptr) ; }
|
||||
Exit* GetExit( int nGroup) ;
|
||||
bool IsExitGroup( int nGroup) { return ( GetExit( nGroup) != nullptr) ; }
|
||||
int GetGroup( const std::string& sGroup) const ;
|
||||
Axis* GetAxis( int nGroup) const ;
|
||||
bool IsAxisGroup( int nGroup) const { return ( GetAxis( nGroup) != nullptr) ; }
|
||||
Table* GetTable( int nGroup) const ;
|
||||
bool IsTableGroup( int nGroup) const { return ( GetTable( nGroup) != nullptr) ; }
|
||||
Head* GetHead( int nGroup) const ;
|
||||
bool IsHeadGroup( int nGroup) const { return ( GetHead( nGroup) != nullptr) ; }
|
||||
Exit* GetExit( int nGroup) const ;
|
||||
bool IsExitGroup( int nGroup) const { return ( GetExit( nGroup) != nullptr) ; }
|
||||
bool AddHeadToSet( const std::string& sHSet, const std::string& sName) ;
|
||||
const STRVECTOR& GetHSet( const std::string& sHead) ;
|
||||
const STRVECTOR& GetHSet( const std::string& sHead) const ;
|
||||
bool EnableHeadInSet( const std::string& sHead) ;
|
||||
bool CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) ;
|
||||
bool ResetAllAxesPos( void) ;
|
||||
bool CalculateKinematicChain( void) ;
|
||||
bool AddKinematicAxis( bool bOnHead, int nId) ;
|
||||
bool AdjustAngleInStroke( int nId, double& dAng) ;
|
||||
@@ -90,6 +96,7 @@ class Machine
|
||||
|
||||
private :
|
||||
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
LuaMgr m_LuaMgr ; // interprete lua della macchina
|
||||
std::string m_sName ; // nome della macchina
|
||||
std::string m_sMachineDir ; // direttorio della macchina
|
||||
|
||||
+18
-5
@@ -26,6 +26,9 @@ using namespace std ;
|
||||
bool
|
||||
Machine::SetAxisPos( const string& sAxis, double dVal)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gruppo dell'asse
|
||||
int nAxGrp = GetGroup( sAxis) ;
|
||||
// recupero il relativo gestore
|
||||
@@ -39,12 +42,13 @@ Machine::SetAxisPos( const string& sAxis, double dVal)
|
||||
// limiti della corsa
|
||||
STROKE Stroke = pAx->GetStroke() ;
|
||||
// recupero il vettore dell'asse
|
||||
int nV = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nAxGrp, sAxis) ;
|
||||
const IGeoVector3d* pGV = GetGeoVector3d( m_pMchMgr->m_pGeomDB->GetGeoObj( nV)) ;
|
||||
int nV = m_pGeomDB->GetFirstNameInGroup( nAxGrp, sAxis) ;
|
||||
const IGeoVector3d* pGV = GetGeoVector3d( m_pGeomDB->GetGeoObj( nV)) ;
|
||||
if ( pGV == nullptr)
|
||||
return false ;
|
||||
Point3d ptPos = pGV->GetBase() ;
|
||||
Vector3d vtDir = pGV->GetVector() / AXIS_LEN ;
|
||||
Vector3d vtDir = pGV->GetVector() ;
|
||||
vtDir.Normalize() ;
|
||||
// limito il movimento alla corsa dell'asse
|
||||
if ( dVal > Stroke.Max)
|
||||
dVal = Stroke.Max ;
|
||||
@@ -52,9 +56,9 @@ Machine::SetAxisPos( const string& sAxis, double dVal)
|
||||
dVal = Stroke.Min ;
|
||||
// eseguo il movimento
|
||||
if ( bLinear)
|
||||
m_pMchMgr->m_pGeomDB->TranslateGroup( nAxGrp, vtDir * ( dVal - dCurrVal)) ;
|
||||
m_pGeomDB->TranslateGroup( nAxGrp, vtDir * ( dVal - dCurrVal)) ;
|
||||
else
|
||||
m_pMchMgr->m_pGeomDB->RotateGroup( nAxGrp, ptPos, vtDir, ( dVal - dCurrVal)) ;
|
||||
m_pGeomDB->RotateGroup( nAxGrp, ptPos, vtDir, ( dVal - dCurrVal)) ;
|
||||
// salvo la nuova posizione
|
||||
return pAx->SetCurrVal( dVal) ;
|
||||
}
|
||||
@@ -63,6 +67,9 @@ Machine::SetAxisPos( const string& sAxis, double dVal)
|
||||
bool
|
||||
Machine::GetAxisPos( const string& sAxis, double& dVal)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il relativo gestore
|
||||
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
||||
if ( pAx == nullptr)
|
||||
@@ -76,6 +83,9 @@ Machine::GetAxisPos( const string& sAxis, double& dVal)
|
||||
bool
|
||||
Machine::GetAxisHomePos( const string& sAxis, double& dHomeVal)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gestore dell'asse
|
||||
Axis* pAx = GetAxis( GetGroup( sAxis)) ;
|
||||
if ( pAx == nullptr)
|
||||
@@ -89,6 +99,9 @@ Machine::GetAxisHomePos( const string& sAxis, double& dHomeVal)
|
||||
bool
|
||||
Machine::ResetAxisPos( const string& sAxis)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero la posizione home
|
||||
double dHomeVal ;
|
||||
if ( ! GetAxisHomePos( sAxis, dHomeVal))
|
||||
|
||||
+20
-8
@@ -29,6 +29,9 @@ using namespace std ;
|
||||
bool
|
||||
Machine::SetCurrTable( const string& sTable)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gruppo della tavola
|
||||
m_nCalcTabId = GetGroup( sTable) ;
|
||||
if ( m_nCalcTabId == GDB_ID_NULL || ! IsTableGroup( m_nCalcTabId)) {
|
||||
@@ -42,6 +45,9 @@ Machine::SetCurrTable( const string& sTable)
|
||||
bool
|
||||
Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// azzero tutto
|
||||
m_nCalcHeadId = GDB_ID_NULL ;
|
||||
m_nCalcExitId = GDB_ID_NULL ;
|
||||
@@ -55,7 +61,7 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
|
||||
return false ;
|
||||
// recupero il gruppo dell'uscita
|
||||
string sExit = MCH_EXIT + ToString( nExit) ;
|
||||
int nExitId = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHeadId, sExit) ;
|
||||
int nExitId = m_pGeomDB->GetFirstNameInGroup( nHeadId, sExit) ;
|
||||
// recupero i dati dell'uscita
|
||||
Exit* pExit = GetExit( nExitId) ;
|
||||
if ( pExit == nullptr)
|
||||
@@ -63,11 +69,11 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
|
||||
// recupero i dati dell'utensile
|
||||
if ( ! LoadTool( sHead, nExit, sTool))
|
||||
return false ;
|
||||
int nToolId = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ;
|
||||
if ( nToolId == GDB_ID_NULL || m_pMchMgr->m_pGeomDB->GetGdbType( nToolId) != GDB_TY_GROUP)
|
||||
int nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ;
|
||||
if ( nToolId == GDB_ID_NULL || m_pGeomDB->GetGdbType( nToolId) != GDB_TY_GROUP)
|
||||
return false ;
|
||||
double dTLen ;
|
||||
if ( ! m_pMchMgr->m_pGeomDB->GetInfo( nToolId, "L", dTLen))
|
||||
if ( ! m_pGeomDB->GetInfo( nToolId, "L", dTLen))
|
||||
return false ;
|
||||
// assegno tutti i dati
|
||||
m_nCalcHeadId = nHeadId ;
|
||||
@@ -85,30 +91,33 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit)
|
||||
bool
|
||||
Machine::CalculateKinematicChain( void)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// azzero tutti gli assi della catena cinematica
|
||||
m_vCalcLinAx.clear() ;
|
||||
m_vCalcRotAx.clear() ;
|
||||
// recupero gli assi di tavola
|
||||
if ( m_nCalcTabId == GDB_ID_NULL)
|
||||
return false ;
|
||||
int nTParId = m_pMchMgr->m_pGeomDB->GetParentId( m_nCalcTabId) ;
|
||||
int nTParId = m_pGeomDB->GetParentId( m_nCalcTabId) ;
|
||||
if ( nTParId == GDB_ID_NULL)
|
||||
return false ;
|
||||
while ( IsAxisGroup( nTParId)) {
|
||||
if ( ! AddKinematicAxis( false, nTParId))
|
||||
return false ;
|
||||
nTParId = m_pMchMgr->m_pGeomDB->GetParentId( nTParId) ;
|
||||
nTParId = m_pGeomDB->GetParentId( nTParId) ;
|
||||
}
|
||||
// recupero gli assi di testa
|
||||
if ( m_nCalcHeadId == GDB_ID_NULL)
|
||||
return false ;
|
||||
int nHParId = m_pMchMgr->m_pGeomDB->GetParentId( m_nCalcHeadId) ;
|
||||
int nHParId = m_pGeomDB->GetParentId( m_nCalcHeadId) ;
|
||||
if ( nHParId == GDB_ID_NULL)
|
||||
return false ;
|
||||
while ( IsAxisGroup( nHParId)) {
|
||||
if ( ! AddKinematicAxis( true, nHParId))
|
||||
return false ;
|
||||
nHParId = m_pMchMgr->m_pGeomDB->GetParentId( nHParId) ;
|
||||
nHParId = m_pGeomDB->GetParentId( nHParId) ;
|
||||
}
|
||||
// verifiche sugli assi lineari :
|
||||
// devono essere 3
|
||||
@@ -148,6 +157,9 @@ Machine::CalculateKinematicChain( void)
|
||||
bool
|
||||
Machine::AddKinematicAxis( bool bOnHead, int nId)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gestore dell'asse
|
||||
Axis* pAx = GetAxis( nId) ;
|
||||
if ( pAx == nullptr)
|
||||
|
||||
+19
-13
@@ -25,13 +25,16 @@ using namespace std ;
|
||||
bool
|
||||
Machine::LoadTool( const string& sHead, int nExit, const string& sTool)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il gruppo della testa
|
||||
int nHdGrp = GetGroup( sHead) ;
|
||||
if ( ! IsHeadGroup( nHdGrp))
|
||||
return false ;
|
||||
// cerco il gruppo dell'uscita in quello della testa
|
||||
string sExit = MCH_EXIT + ToString( nExit) ;
|
||||
int nExGrp = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
||||
int nExGrp = m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
||||
Exit* pExit = GetExit( nExGrp) ;
|
||||
if ( pExit == nullptr)
|
||||
return false ;
|
||||
@@ -43,22 +46,22 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool)
|
||||
if ( ! ExistsFile( sToolFile))
|
||||
return false ;
|
||||
// pulisco il gruppo dell'uscita
|
||||
m_pMchMgr->m_pGeomDB->EmptyGroup( nExGrp) ;
|
||||
m_pGeomDB->EmptyGroup( nExGrp) ;
|
||||
// inserisco l'utensile nel gruppo
|
||||
if ( ! m_pMchMgr->m_pGeomDB->Load( sToolFile, nExGrp))
|
||||
if ( ! m_pGeomDB->Load( sToolFile, nExGrp))
|
||||
return false ;
|
||||
int nTGrpId = m_pMchMgr->m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
||||
int nSolidId = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nTGrpId, "SOLID") ;
|
||||
int nTGrpId = m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
||||
int nSolidId = m_pGeomDB->GetFirstNameInGroup( nTGrpId, "SOLID") ;
|
||||
if ( nSolidId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pMchMgr->m_pGeomDB->RelocateGlob( nSolidId, nExGrp, GDB_FIRST_SON) ;
|
||||
m_pMchMgr->m_pGeomDB->Erase( nTGrpId) ;
|
||||
m_pMchMgr->m_pGeomDB->SetName( nSolidId, sTool) ;
|
||||
m_pGeomDB->RelocateGlob( nSolidId, nExGrp, GDB_FIRST_SON) ;
|
||||
m_pGeomDB->Erase( nTGrpId) ;
|
||||
m_pGeomDB->SetName( nSolidId, sTool) ;
|
||||
// lo ruoto 90 deg attorno alla X locale
|
||||
int nT = m_pMchMgr->m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
||||
int nT = m_pGeomDB->GetFirstGroupInGroup( nExGrp) ;
|
||||
if ( nT == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pMchMgr->m_pGeomDB->Rotate( nT, ORIG, X_AX, 90) ;
|
||||
m_pGeomDB->Rotate( nT, ORIG, X_AX, 90) ;
|
||||
pExit->SetTool( sTool) ;
|
||||
return EnableHeadInSet( sHead) ;
|
||||
}
|
||||
@@ -67,6 +70,9 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool)
|
||||
bool
|
||||
Machine::ResetHeadSet( const string& sHead)
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero il set della testa
|
||||
const STRVECTOR& vsHSet = GetHSet( sHead) ;
|
||||
if ( vsHSet.empty())
|
||||
@@ -81,17 +87,17 @@ Machine::ResetHeadSet( const string& sHead)
|
||||
for ( int j = 1 ; true ; ++ j) {
|
||||
// recupero il gruppo dell'uscita
|
||||
string sExit = MCH_EXIT + ToString( j) ;
|
||||
int nExGrp = m_pMchMgr->m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
||||
int nExGrp = m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ;
|
||||
// recupero l'oggetto uscita
|
||||
Exit* pExit = GetExit( nExGrp) ;
|
||||
if ( pExit == nullptr)
|
||||
break ;
|
||||
// pulisco il gruppo dell'uscita
|
||||
m_pMchMgr->m_pGeomDB->EmptyGroup( nExGrp) ;
|
||||
m_pGeomDB->EmptyGroup( nExGrp) ;
|
||||
pExit->SetTool( "") ;
|
||||
}
|
||||
// visualizzo solo la prima testa
|
||||
m_pMchMgr->m_pGeomDB->SetStatus( nHdGrp, ( i == 0 ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
m_pGeomDB->SetStatus( nHdGrp, ( i == 0 ? GDB_ST_ON : GDB_ST_OFF)) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
+40
-17
@@ -45,9 +45,9 @@ Machine::LuaInit( const string& sMachineName)
|
||||
sLua += " (" + sMachineName + ")" ;
|
||||
LOG_INFO( GetEMkLogger(), sLua.c_str())
|
||||
// imposto il direttorio delle librerie
|
||||
m_LuaMgr.SetLuaLibsDir( m_pMchMgr->m_sLuaLibsDir) ;
|
||||
m_LuaMgr.SetLuaLibsDir( m_pMchMgr->GetLuaLibsDir()) ;
|
||||
// carico la libreria standard
|
||||
m_LuaMgr.Require( m_pMchMgr->m_sLuaLastRequire) ;
|
||||
m_LuaMgr.Require( m_pMchMgr->GetLuaLastRequire()) ;
|
||||
// registro le funzioni per lua
|
||||
m_LuaMgr.RegisterFunction( "EmtGeneral", Machine::LuaEmtGeneral) ;
|
||||
m_LuaMgr.RegisterFunction( "EmtBase", Machine::LuaEmtBase) ;
|
||||
@@ -74,16 +74,19 @@ Machine::LuaExit( void)
|
||||
bool
|
||||
Machine::LuaExecFile( const string& sFile)
|
||||
{
|
||||
// info
|
||||
string sOut = "LuaExecFile : " + sFile ;
|
||||
ExeOutLog( sOut) ;
|
||||
// imposto contesto corretto
|
||||
int nOldCtx = ExeGetCurrentContext() ;
|
||||
if ( nOldCtx != m_pMchMgr->m_nContextId)
|
||||
ExeSetCurrentContext( m_pMchMgr->m_nContextId) ;
|
||||
if ( nOldCtx != m_pMchMgr->GetContextId())
|
||||
ExeSetCurrentContext( m_pMchMgr->GetContextId()) ;
|
||||
// imposto l'oggetto corrente per Lua
|
||||
m_pMchLua = this ;
|
||||
// carico la macchina
|
||||
bool bOk = m_LuaMgr.ExecFile( sFile) ;
|
||||
// ripristino contesto originale
|
||||
if ( nOldCtx != m_pMchMgr->m_nContextId)
|
||||
if ( nOldCtx != m_pMchMgr->GetContextId())
|
||||
ExeSetCurrentContext( nOldCtx) ;
|
||||
return bOk ;
|
||||
}
|
||||
@@ -92,7 +95,6 @@ Machine::LuaExecFile( const string& sFile)
|
||||
int
|
||||
Machine::LuaEmtGeneral( lua_State* L)
|
||||
{
|
||||
ExeOutLog( "LuaEmtGeneral") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -104,6 +106,10 @@ Machine::LuaEmtGeneral( lua_State* L)
|
||||
LuaGetTabFieldParam( L, 1, "Offset", vtOffset) ;
|
||||
LuaClearStack( L) ;
|
||||
|
||||
// info
|
||||
string sOut = "LuaEmtGeneral : " + sFile ;
|
||||
ExeOutLog( sOut) ;
|
||||
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
@@ -119,7 +125,6 @@ Machine::LuaEmtGeneral( lua_State* L)
|
||||
int
|
||||
Machine::LuaEmtBase( lua_State* L)
|
||||
{
|
||||
ExeOutLog( "LuaEmtBase") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -131,6 +136,10 @@ Machine::LuaEmtBase( lua_State* L)
|
||||
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
|
||||
LuaClearStack( L) ;
|
||||
|
||||
// info
|
||||
string sOut = "LuaEmtBase : " + sName ;
|
||||
ExeOutLog( sOut) ;
|
||||
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
@@ -146,7 +155,6 @@ Machine::LuaEmtBase( lua_State* L)
|
||||
int
|
||||
Machine::LuaEmtTable( lua_State* L)
|
||||
{
|
||||
ExeOutLog( "LuaEmtTable") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -159,17 +167,24 @@ Machine::LuaEmtTable( lua_State* L)
|
||||
// lettura campo 'Type' dalla tabella
|
||||
int nType ;
|
||||
LuaCheckTabFieldParam( L, 1, "Type", nType)
|
||||
// lettura campo 'Ref1' dalla tabella
|
||||
Point3d Ref1 ;
|
||||
LuaCheckTabFieldParam( L, 1, "Ref1", Ref1)
|
||||
// lettura campo 'Geo' dalla tabella
|
||||
string sGeo ;
|
||||
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
|
||||
LuaClearStack( L) ;
|
||||
|
||||
// info
|
||||
string sOut = "LuaEmtTable : " + sName ;
|
||||
ExeOutLog( sOut) ;
|
||||
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
|
||||
// carico i dati della tavola
|
||||
if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, sGeo))
|
||||
if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, sGeo))
|
||||
return luaL_error( L, " Load Machine Table failed") ;
|
||||
|
||||
return 0 ;
|
||||
@@ -179,7 +194,6 @@ Machine::LuaEmtTable( lua_State* L)
|
||||
int
|
||||
Machine::LuaEmtAxis( lua_State* L)
|
||||
{
|
||||
ExeOutLog( "LuaEmtAxis") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -204,17 +218,21 @@ Machine::LuaEmtAxis( lua_State* L)
|
||||
// lettura campo 'Geo' dalla tabella
|
||||
string sGeo ;
|
||||
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
|
||||
// lettura eventuale campo 'Val' dalla tabella (default 0)
|
||||
double dVal = 0 ;
|
||||
LuaGetTabFieldParam( L, 1, "Val", dVal) ;
|
||||
// lettura eventuale campo 'Home' dalla tabella (default 0)
|
||||
double dHome = 0 ;
|
||||
LuaGetTabFieldParam( L, 1, "Home", dHome) ;
|
||||
LuaClearStack( L) ;
|
||||
|
||||
// info
|
||||
string sOut = "LuaEmtAxis : " + sName ;
|
||||
ExeOutLog( sOut) ;
|
||||
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
|
||||
// carico i dati dell'asse
|
||||
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, nType, ptPos, vtDir, Stroke, sGeo, dVal))
|
||||
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, nType, ptPos, vtDir, Stroke, sGeo, dHome))
|
||||
return luaL_error( L, " Load Machine Axis failed") ;
|
||||
|
||||
return 0 ;
|
||||
@@ -224,7 +242,6 @@ Machine::LuaEmtAxis( lua_State* L)
|
||||
int
|
||||
Machine::LuaEmtHead( lua_State* L)
|
||||
{
|
||||
ExeOutLog( "LuaEmtHead") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -245,7 +262,6 @@ Machine::LuaEmtHead( lua_State* L)
|
||||
int
|
||||
Machine::LuaEmtStdHead( lua_State* L)
|
||||
{
|
||||
ExeOutLog( " Standard Head") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -272,6 +288,10 @@ Machine::LuaEmtStdHead( lua_State* L)
|
||||
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
|
||||
LuaClearStack( L) ;
|
||||
|
||||
// info
|
||||
string sOut = "LuaEmtStdHead : " + sName ;
|
||||
ExeOutLog( sOut) ;
|
||||
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
@@ -287,7 +307,6 @@ Machine::LuaEmtStdHead( lua_State* L)
|
||||
int
|
||||
Machine::LuaEmtMultiHead( lua_State* L)
|
||||
{
|
||||
ExeOutLog( " Multiple Head") ;
|
||||
// Il parametro 1 deve essere una tabella
|
||||
if ( ! lua_istable( L, 1))
|
||||
return luaL_error( L, " Invalid Parameter, required a table") ;
|
||||
@@ -325,6 +344,10 @@ Machine::LuaEmtMultiHead( lua_State* L)
|
||||
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
|
||||
LuaClearStack( L) ;
|
||||
|
||||
// info
|
||||
string sOut = "LuaEmtMultiHead : " + sName ;
|
||||
ExeOutLog( sOut) ;
|
||||
|
||||
// verifico ci sia una macchina attiva
|
||||
if ( m_pMchLua == nullptr)
|
||||
return luaL_error( L, " Unknown Machine") ;
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ enum MchHeadType { MCH_HT_NONE = 0,
|
||||
MCH_HT_MULTI = 2} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Lunghezza vettore di movimento degli assi macchina
|
||||
const double AXIS_LEN = 100 ;
|
||||
// Identificativo iniziale riferimenti di tavola
|
||||
const std::string MCH_TREF = "R" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Identificativo iniziale gruppo uscita di teste
|
||||
|
||||
@@ -40,8 +40,10 @@ Table::Clone( void) const
|
||||
// eseguo copia dei dati
|
||||
if ( pAx != nullptr) {
|
||||
try { pAx->m_nOwnerId = GDB_ID_NULL ;
|
||||
pAx->m_pGeomDB = nullptr ;
|
||||
pAx->m_sName = m_sName ;
|
||||
pAx->m_nType = m_nType ;
|
||||
pAx->m_ptRef1 = m_ptRef1 ;
|
||||
}
|
||||
catch( ...) {
|
||||
delete pAx ;
|
||||
@@ -60,15 +62,17 @@ Table::Dump( string& sOut, const char* szNewLine) const
|
||||
sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ;
|
||||
sOut += "Name=" + m_sName + szNewLine ;
|
||||
sOut += "Type=" + ToString( m_nType) + szNewLine ;
|
||||
sOut += "Ref1=(" + ToString( m_ptRef1) + ")" + szNewLine ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Table::SetOwner( int nId)
|
||||
Table::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
return true ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -78,19 +82,27 @@ Table::GetOwner( void) const
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Table::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Table::Table( void)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_nType( MCH_TT_NONE)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_nType( MCH_TT_NONE), m_ptRef1()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Table::Set( const string& sName, int nType)
|
||||
Table::Set( const string& sName, int nType, const Point3d& ptRef1)
|
||||
{
|
||||
m_sName = sName ;
|
||||
m_nType = nType ;
|
||||
m_ptRef1 = ptRef1 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,21 @@ class Table : public IObjUser
|
||||
virtual Table* Clone( void) const ;
|
||||
virtual const std::string& GetClassName( void) const ;
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool SetOwner( int nId) ;
|
||||
virtual bool SetOwner( int nId, IGeomDB* pGDB) ;
|
||||
virtual int GetOwner( void) const ;
|
||||
virtual IGeomDB* GetGeomDB( void) const ;
|
||||
|
||||
public :
|
||||
Table( void) ;
|
||||
bool Set( const std::string& sName, int nType) ;
|
||||
bool Set( const std::string& sName, int nType, const Point3d& ptRef1) ;
|
||||
const std::string& GetName( void) { return m_sName ; }
|
||||
int GetType( void) { return m_nType ; }
|
||||
const Point3d& GetRef1( void) { return m_ptRef1 ; }
|
||||
|
||||
private :
|
||||
int m_nOwnerId ;
|
||||
IGeomDB* m_pGeomDB ;
|
||||
std::string m_sName ;
|
||||
int m_nType ;
|
||||
Point3d m_ptRef1 ;
|
||||
} ;
|
||||
Reference in New Issue
Block a user