EgtMachKernel 1.6f2 :
- aggiunto UserObj CamData per rappresentare dati tipo CL in entità geometriche - possibilità di ruotare i sottopezzi - aggiunto calcolo percorsi di lavorazione di fori - aggiunte prime versioni parziali di taglio con lama e fresatura.
This commit is contained in:
+210
@@ -0,0 +1,210 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Machining.cpp Data : 10.06.15 Versione : 1.6f2
|
||||
// Contenuto : Implementazione gestione base lavorazioni.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 10.06.15 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "MachMgr.h"
|
||||
#include "Machining.h"
|
||||
#include "CamData.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetOwner( int nId, IGeomDB* pGDB)
|
||||
{
|
||||
m_nOwnerId = nId ;
|
||||
m_pGeomDB = pGDB ;
|
||||
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machining::GetOwner( void) const
|
||||
{
|
||||
return m_nOwnerId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IGeomDB*
|
||||
Machining::GetGeomDB( void) const
|
||||
{
|
||||
return m_pGeomDB ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::Init( MachMgr* pMchMgr)
|
||||
{
|
||||
m_pMchMgr = pMchMgr ;
|
||||
if ( m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
if ( m_pMchMgr->GetGeomDB() != m_pGeomDB)
|
||||
return false ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
Machining::Machining( void)
|
||||
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_pMchMgr( nullptr),
|
||||
m_nPathId( GDB_ID_NULL), m_OrigId(), m_bCurr( false), m_ptCurr(),
|
||||
m_vtTool(), m_vtCorr(), m_vtAux(), m_dFeed( 0), m_nFlag( 0)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetPathId( int nPathId)
|
||||
{
|
||||
m_nPathId = nPathId ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetOrigId( SelData OrigId)
|
||||
{
|
||||
m_OrigId = OrigId ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetToolDir( const Vector3d& vtDir)
|
||||
{
|
||||
m_vtTool = vtDir ;
|
||||
return ( m_vtTool.Normalize()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetCorrDir( const Vector3d& vtDir)
|
||||
{
|
||||
m_vtCorr = vtDir ;
|
||||
return ( ! m_vtCorr.IsSmall()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetAuxDir( const Vector3d& vtDir)
|
||||
{
|
||||
m_vtAux = vtDir ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetFeed( double dFeed)
|
||||
{
|
||||
m_dFeed = dFeed ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::SetFlag( int nFlag)
|
||||
{
|
||||
m_nFlag = nFlag ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machining::AddStart( const Point3d& ptP)
|
||||
{
|
||||
// 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->SetOrigId( m_OrigId) ;
|
||||
pCam->SetToolDir( m_vtTool) ;
|
||||
pCam->SetCorrDir( m_vtCorr) ;
|
||||
pCam->SetAuxDir( m_vtAux) ;
|
||||
pCam->SetBasePoint( ptP) ;
|
||||
// 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
|
||||
Machining::AddLinearMove( const Point3d& ptP)
|
||||
{
|
||||
// verifico di essere in uno stato valido per un movimento lineare
|
||||
if ( ! m_bCurr || m_vtTool.IsSmall() || m_dFeed < EPS_SMALL)
|
||||
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->SetOrigId( m_OrigId) ;
|
||||
pCam->SetToolDir( m_vtTool) ;
|
||||
pCam->SetCorrDir( m_vtCorr) ;
|
||||
pCam->SetAuxDir( m_vtAux) ;
|
||||
pCam->SetBasePoint( 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 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machining::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 ;
|
||||
}
|
||||
Reference in New Issue
Block a user