5ffbaab0e4
- modifiche per gestione aggregato da sotto in foratura e fresatura - modifiche per nuovi tipi di uscite lame allungate.
316 lines
9.7 KiB
C++
316 lines
9.7 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2016-2016
|
|
//----------------------------------------------------------------------------
|
|
// File : Operation.cpp Data : 29.05.16 Versione : 1.6r7
|
|
// Contenuto : Implementazione gestione operazioni per CL.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 29.05.16 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "Operation.h"
|
|
#include "MachMgr.h"
|
|
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
|
#include "/EgtDev/Include/EGkCurveLine.h"
|
|
#include "/EgtDev/Include/EGkCurveArc.h"
|
|
#include "/EgtDev/Include/EGkGeomDB.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetPathId( int nPathId)
|
|
{
|
|
m_nPathId = nPathId ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetToolDir( const Vector3d& vtDir)
|
|
{
|
|
m_vtTool = vtDir ;
|
|
return ( m_vtTool.Normalize()) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetCorrDir( const Vector3d& vtDir)
|
|
{
|
|
m_vtCorr = vtDir ;
|
|
return ( ! m_vtCorr.IsSmall()) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetAuxDir( const Vector3d& vtDir)
|
|
{
|
|
m_vtAux = vtDir ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetCorrAuxDir( const Vector3d& vtDir)
|
|
{
|
|
m_vtCorr = vtDir ;
|
|
m_vtAux = vtDir ;
|
|
return ( ! m_vtCorr.IsSmall()) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetFeed( double dFeed)
|
|
{
|
|
m_dFeed = dFeed ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::SetFlag( int nFlag)
|
|
{
|
|
m_nFlag = nFlag ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddRapidStart( const Point3d& ptP)
|
|
{
|
|
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
|
return GDB_ID_NULL ;
|
|
// verifico di essere in uno stato valido per inizio
|
|
if ( m_vtTool.IsSmall())
|
|
return GDB_ID_NULL ;
|
|
// creo oggetto punto per DB geometrico
|
|
PtrOwner<IGeoPoint3d> pGP( CreateGeoPoint3d()) ;
|
|
if ( IsNull( pGP))
|
|
return GDB_ID_NULL ;
|
|
// assegno le coordinate del punto
|
|
pGP->Set( ptP) ;
|
|
// inserisco l'oggetto nel DB geometrico
|
|
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pGP)) ;
|
|
if ( nId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// creo oggetto dati Cam
|
|
PtrOwner<CamData> pCam( new( nothrow) CamData) ;
|
|
if ( IsNull( pCam))
|
|
return GDB_ID_NULL ;
|
|
// assegno valori
|
|
pCam->SetMoveType( 0) ;
|
|
pCam->SetToolDir( m_vtTool) ;
|
|
pCam->SetCorrDir( m_vtCorr) ;
|
|
pCam->SetAuxDir( m_vtAux) ;
|
|
pCam->SetEndPoint( ptP) ;
|
|
pCam->SetFeed( 0) ;
|
|
pCam->SetFlag( m_nFlag) ;
|
|
// associo questo oggetto a quello geometrico
|
|
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
|
|
// salvo la posizione corrente
|
|
m_bCurr = true ;
|
|
m_ptCurr = ptP ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddRapidStart( const Point3d& ptP, const string& sName)
|
|
{
|
|
int nId = AddRapidStart( ptP) ;
|
|
if ( nId != GDB_ID_NULL)
|
|
m_pGeomDB->SetName( nId, sName) ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddRapidMove( const Point3d& ptP)
|
|
{
|
|
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
|
return GDB_ID_NULL ;
|
|
// verifico di essere in uno stato valido per un movimento in rapido
|
|
if ( ! m_bCurr || m_vtTool.IsSmall())
|
|
return GDB_ID_NULL ;
|
|
// creo oggetto linea per DB geometrico
|
|
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
|
if ( IsNull( pLine))
|
|
return GDB_ID_NULL ;
|
|
// assegno le coordinate degli estremi
|
|
if ( ! pLine->Set( m_ptCurr, ptP))
|
|
return GDB_ID_NULL ;
|
|
// inserisco l'oggetto nel DB geometrico
|
|
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pLine)) ;
|
|
if ( nId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// creo oggetto dati Cam
|
|
PtrOwner<CamData> pCam( new( nothrow) CamData) ;
|
|
if ( IsNull( pCam))
|
|
return GDB_ID_NULL ;
|
|
// assegno valori
|
|
pCam->SetMoveType( 0) ;
|
|
pCam->SetToolDir( m_vtTool) ;
|
|
pCam->SetCorrDir( m_vtCorr) ;
|
|
pCam->SetAuxDir( m_vtAux) ;
|
|
pCam->SetEndPoint( ptP) ;
|
|
pCam->SetFeed( 0) ;
|
|
pCam->SetFlag( m_nFlag) ;
|
|
// associo questo oggetto a quello geometrico
|
|
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
|
|
// salvo la posizione corrente
|
|
m_ptCurr = ptP ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddRapidMove( const Point3d& ptP, const string& sName)
|
|
{
|
|
int nId = AddRapidMove( ptP) ;
|
|
if ( nId != GDB_ID_NULL)
|
|
m_pGeomDB->SetName( nId, sName) ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddLinearMove( const Point3d& ptP)
|
|
{
|
|
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
|
return GDB_ID_NULL ;
|
|
// verifico di essere in uno stato valido per un movimento lineare
|
|
if ( ! m_bCurr || m_vtTool.IsSmall()) {
|
|
LOG_INFO( GetEMkLogger(), "Error on LinearMove : Curr or ToolDir")
|
|
return GDB_ID_NULL ;
|
|
}
|
|
// se feed nulla, assegno il minimo e lo segnalo
|
|
if ( m_dFeed < FEED_MIN) {
|
|
m_dFeed = FEED_MIN ;
|
|
LOG_INFO( GetEMkLogger(), "Error on LinearMove : Min Feed")
|
|
}
|
|
// creo oggetto linea per DB geometrico
|
|
PtrOwner<ICurveLine> pLine( CreateCurveLine()) ;
|
|
if ( IsNull( pLine))
|
|
return GDB_ID_NULL ;
|
|
// assegno le coordinate degli estremi
|
|
if ( ! pLine->Set( m_ptCurr, ptP))
|
|
return GDB_ID_NULL ;
|
|
// inserisco l'oggetto nel DB geometrico
|
|
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pLine)) ;
|
|
if ( nId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// creo oggetto dati Cam
|
|
PtrOwner<CamData> pCam( new( nothrow) CamData) ;
|
|
if ( IsNull( pCam))
|
|
return GDB_ID_NULL ;
|
|
// assegno valori
|
|
pCam->SetMoveType( 1) ;
|
|
pCam->SetToolDir( m_vtTool) ;
|
|
pCam->SetCorrDir( m_vtCorr) ;
|
|
pCam->SetAuxDir( m_vtAux) ;
|
|
pCam->SetEndPoint( ptP) ;
|
|
pCam->SetFeed( m_dFeed) ;
|
|
pCam->SetFlag( m_nFlag) ;
|
|
// associo questo oggetto a quello geometrico
|
|
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
|
|
// salvo la posizione corrente
|
|
m_ptCurr = ptP ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddLinearMove( const Point3d& ptP, const string& sName)
|
|
{
|
|
int nId = AddLinearMove( ptP) ;
|
|
if ( nId != GDB_ID_NULL)
|
|
m_pGeomDB->SetName( nId, sName) ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN)
|
|
{
|
|
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
|
return GDB_ID_NULL ;
|
|
// verifico di essere in uno stato valido per un movimento arco
|
|
if ( ! m_bCurr || m_vtTool.IsSmall()) {
|
|
LOG_INFO( GetEMkLogger(), "Error on ArcMove : Curr or ToolDir")
|
|
return GDB_ID_NULL ;
|
|
}
|
|
// se feed nulla, assegno il minimo e lo segnalo
|
|
if ( m_dFeed < FEED_MIN) {
|
|
m_dFeed = FEED_MIN ;
|
|
LOG_INFO( GetEMkLogger(), "Error on ArcMove : Min Feed")
|
|
}
|
|
// creo oggetto arco per DB geometrico
|
|
PtrOwner<ICurveArc> pArc( CreateCurveArc()) ;
|
|
if ( IsNull( pArc))
|
|
return GDB_ID_NULL ;
|
|
// assegno i dati dell'arco
|
|
double dDeltaZ = ( ptP - m_ptCurr) * vtN ;
|
|
if ( ! pArc->SetCPAN( ptCen, m_ptCurr, dAngCen, dDeltaZ, vtN))
|
|
return GDB_ID_NULL ;
|
|
Point3d ptFin ;
|
|
if ( ! pArc->GetEndPoint( ptFin) || ! AreSamePointApprox( ptFin, ptP))
|
|
return GDB_ID_NULL ;
|
|
int nMove = ( dAngCen > 0 ? 3 : 2) ;
|
|
// inserisco l'oggetto nel DB geometrico
|
|
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, m_nPathId, Release( pArc)) ;
|
|
if ( nId == GDB_ID_NULL)
|
|
return GDB_ID_NULL ;
|
|
// creo oggetto dati Cam
|
|
PtrOwner<CamData> pCam( new( nothrow) CamData) ;
|
|
if ( IsNull( pCam))
|
|
return GDB_ID_NULL ;
|
|
// assegno valori
|
|
pCam->SetMoveType( nMove) ;
|
|
pCam->SetToolDir( m_vtTool) ;
|
|
pCam->SetCorrDir( m_vtCorr) ;
|
|
pCam->SetAuxDir( m_vtAux) ;
|
|
pCam->SetEndPoint( ptP) ;
|
|
pCam->SetCenter( ptCen) ;
|
|
pCam->SetAngCen( dAngCen) ;
|
|
pCam->SetDeltaN( dDeltaZ) ;
|
|
pCam->SetNormDir( vtN) ;
|
|
pCam->SetFeed( m_dFeed) ;
|
|
pCam->SetFlag( m_nFlag) ;
|
|
// associo questo oggetto a quello geometrico
|
|
m_pGeomDB->SetUserObj( nId, Release( pCam)) ;
|
|
// salvo la posizione corrente
|
|
m_ptCurr = ptP ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
int
|
|
Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, const string& sName)
|
|
{
|
|
int nId = AddArcMove( ptP, ptCen, dAngCen, vtN) ;
|
|
if ( nId != GDB_ID_NULL)
|
|
m_pGeomDB->SetName( nId, sName) ;
|
|
return nId ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Operation::ResetMoveData( void)
|
|
{
|
|
m_bCurr = false ;
|
|
m_ptCurr = ORIG ;
|
|
m_vtTool = V_NULL ;
|
|
m_vtCorr = V_NULL ;
|
|
m_vtAux = V_NULL ;
|
|
m_dFeed = 0 ;
|
|
m_nFlag = 0 ;
|
|
return true ;
|
|
}
|