EgtMachKernel :
- aggiunta gestione archi su piani diversi da XY - disposizione rimette sempre anche i sottopezzi al loro posto - aggiunti attacchi e uscite a fresature - aggiunta prima versione calcolo collegamenti tra lavorazioni evitando collisioni - modifiche a simulazione per tavole mobili con sottopezzi e pezzi.
This commit is contained in:
+41
-2
@@ -40,7 +40,10 @@ static std::string CAM_ACEN = "ACen" ;
|
||||
static std::string CAM_AXMC = "AxMC" ;
|
||||
static std::string CAM_AXMR = "AxMR" ;
|
||||
static std::string CAM_AXAC = "AxAC" ;
|
||||
static int CAM_TOTPARAM =CAM_PARAM_V2 ;
|
||||
static int CAM_PARAM_V3 = 18 ;
|
||||
static std::string CAM_NDIR = "NDir" ;
|
||||
static std::string CAM_AXND = "AxND" ;
|
||||
static int CAM_TOTPARAM =CAM_PARAM_V3 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkCamData", CamData) ;
|
||||
@@ -71,6 +74,7 @@ CamData::Clone( void) const
|
||||
pCam->m_ptEnd = m_ptEnd ;
|
||||
pCam->m_ptCen = m_ptCen ;
|
||||
pCam->m_dAngCen = m_dAngCen ;
|
||||
pCam->m_vtN = m_vtN ;
|
||||
pCam->m_dFeed = m_dFeed ;
|
||||
pCam->m_nFlag = m_nFlag ;
|
||||
pCam->m_nAxesStatus = m_nAxesStatus ;
|
||||
@@ -79,6 +83,7 @@ CamData::Clone( void) const
|
||||
pCam->m_ptMachCen = m_ptMachCen ;
|
||||
pCam->m_dMachRad = m_dMachRad ;
|
||||
pCam->m_dMachAngCen = m_dMachAngCen ;
|
||||
pCam->m_vtMachN = m_vtMachN ;
|
||||
}
|
||||
catch( ...) {
|
||||
delete pCam ;
|
||||
@@ -102,6 +107,7 @@ CamData::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
sOut += CAM_PBAS + "=" + ToString( m_ptEnd) + szNewLine ;
|
||||
sOut += CAM_PCEN + "=" + ToString( m_ptCen) + szNewLine ;
|
||||
sOut += CAM_ACEN + "=" + ToString( m_dAngCen) + szNewLine ;
|
||||
sOut += CAM_NDIR + "=" + ToString( m_vtN) + szNewLine ;
|
||||
sOut += CAM_FEED + "=" + ToString( m_dFeed) + szNewLine ;
|
||||
sOut += CAM_FLAG + "=" + ToString( m_nFlag) + szNewLine ;
|
||||
sOut += CAM_AXSTS + "=" + ToString( m_nAxesStatus) + szNewLine ;
|
||||
@@ -110,6 +116,7 @@ CamData::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
sOut += CAM_AXMC + "=" + ToString( m_ptMachCen) + szNewLine ;
|
||||
sOut += CAM_AXMR + "=" + ToString( m_dMachRad) + szNewLine ;
|
||||
sOut += CAM_AXAC + "=" + ToString( m_dMachAngCen) + szNewLine ;
|
||||
sOut += CAM_AXND + "=" + ToString( m_vtMachN) + szNewLine ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -161,6 +168,9 @@ CamData::Save( STRVECTOR& vString) const
|
||||
vString[++k] = CAM_AXMC + "=" + ToString( m_ptMachCen) ;
|
||||
vString[++k] = CAM_AXMR + "=" + ToString( m_dMachRad) ;
|
||||
vString[++k] = CAM_AXAC + "=" + ToString( m_dMachAngCen) ;
|
||||
// parametri aggiunti V3
|
||||
vString[++k] = CAM_NDIR + "=" + ToString( m_vtN) ;
|
||||
vString[++k] = CAM_AXND + "=" + ToString( m_vtMachN) ;
|
||||
}
|
||||
catch( ...) {
|
||||
return false ;
|
||||
@@ -203,7 +213,16 @@ CamData::Load( const STRVECTOR& vString, int nBaseGdbId)
|
||||
m_ptMachCen = ORIG ;
|
||||
m_dMachRad = 0 ;
|
||||
}
|
||||
|
||||
// parametri aggiunti V3
|
||||
if ( int( vString.size()) >= CAM_PARAM_V3) {
|
||||
if ( ! GetVal( vString[++k], CAM_NDIR, m_vtN) ||
|
||||
! GetVal( vString[++k], CAM_AXND, m_vtMachN))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
m_vtN = Z_AX ;
|
||||
m_vtMachN = Z_AX ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -527,6 +546,16 @@ CamData::SetAngCen( double dAngCen)
|
||||
ResetObjGraphics() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CamData::SetNormDir( const Vector3d& vtDir)
|
||||
{
|
||||
m_vtN = vtDir ;
|
||||
ResetObjGraphics() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CamData::SetFeed( double dFeed)
|
||||
@@ -593,6 +622,16 @@ CamData::SetAxesAngCen( double dAngCen)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CamData::SetAxesNormDir( const Vector3d& vtDir)
|
||||
{
|
||||
if ( ! IsArc())
|
||||
return false ;
|
||||
m_vtMachN = vtDir ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
CamData::ResetObjGraphics( void)
|
||||
|
||||
@@ -52,6 +52,7 @@ class CamData : public IUserObj
|
||||
bool SetEndPoint( const Point3d& ptEnd) ;
|
||||
bool SetCenter( const Point3d& ptCen) ;
|
||||
bool SetAngCen( double dAngCen) ;
|
||||
bool SetNormDir( const Vector3d& vtDir) ;
|
||||
bool SetFeed( double dFeed) ;
|
||||
bool SetFlag( int nFlag) ;
|
||||
bool SetAxes( int nStatus, const DBLVECTOR& vAxVal) ;
|
||||
@@ -61,6 +62,7 @@ class CamData : public IUserObj
|
||||
bool SetAxesCen( const Point3d ptAxCen) ;
|
||||
bool SetAxesRad( double dRad) ;
|
||||
bool SetAxesAngCen( double dAngCen) ;
|
||||
bool SetAxesNormDir( const Vector3d& vtDir) ;
|
||||
const int GetMoveType( void) const
|
||||
{ return m_nMove ; }
|
||||
const bool IsArc( void) const
|
||||
@@ -77,6 +79,8 @@ class CamData : public IUserObj
|
||||
{ return m_ptCen ; }
|
||||
double GetAngCen( void) const
|
||||
{ return m_dAngCen ; }
|
||||
const Vector3d& GetNormDir( void) const
|
||||
{ return m_vtN ; }
|
||||
double GetFeed( void) const
|
||||
{ return m_dFeed ; }
|
||||
int GetFlag( void) const
|
||||
@@ -93,6 +97,8 @@ class CamData : public IUserObj
|
||||
{ return m_dMachRad ; }
|
||||
const double GetAxesAngCen( void) const
|
||||
{ return m_dMachAngCen ; }
|
||||
const Vector3d& GetAxisNormDir( void) const
|
||||
{ return m_vtMachN ; }
|
||||
|
||||
public :
|
||||
enum { AS_NONE = 0,
|
||||
@@ -104,7 +110,9 @@ class CamData : public IUserObj
|
||||
MSK_L2 = 2,
|
||||
MSK_L3 = 4,
|
||||
MSK_R1 = 8,
|
||||
MSK_R2 = 16} ;
|
||||
MSK_R2 = 16,
|
||||
MSK_R3 = 32,
|
||||
MSK_R4 = 64} ;
|
||||
|
||||
private :
|
||||
void ResetObjGraphics( void) ;
|
||||
@@ -120,6 +128,7 @@ class CamData : public IUserObj
|
||||
Point3d m_ptEnd ; // punto finale
|
||||
Point3d m_ptCen ; // centro per archi
|
||||
double m_dAngCen ; // angolo al centro per archi
|
||||
Vector3d m_vtN ; // vettore normale al piano di giacitura per archi
|
||||
double m_dFeed ; // velocità di avanzamento in lavorazione
|
||||
int m_nFlag ; // flag per usi vari
|
||||
int m_nAxesStatus ; // stato dei valori degli assi
|
||||
@@ -128,6 +137,7 @@ class CamData : public IUserObj
|
||||
Point3d m_ptMachCen ; // centro arco espresso in assi macchina
|
||||
double m_dMachRad ; // raggio arco espresso in macchina
|
||||
double m_dMachAngCen ; // angolo al centro per archi espresso in macchina
|
||||
Vector3d m_vtMachN ; // vettore normale al piano di giacitura per archi espresso in macchina
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
+43
-3
@@ -343,6 +343,13 @@ Disposition::Apply(void)
|
||||
else
|
||||
FixData.nId = nId ;
|
||||
}
|
||||
// altrimenti sottopezzo da rimettere in posizione
|
||||
else {
|
||||
if ( ! PlaceFixture( FixData.nId, FixData.ptPos, FixData.dAng)) {
|
||||
string sOut = "Error placing fixture " + ToString( FixData.nId) ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// annullo movimento grezzi
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
@@ -441,9 +448,9 @@ Disposition::MoveFixture( int nId, const Vector3d& vtMove)
|
||||
// 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 ;
|
||||
for ( auto& FixData : m_vFixData) {
|
||||
if ( FixData.nId == nId) {
|
||||
FixData.ptPos += vtMove ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@@ -472,6 +479,39 @@ Disposition::RotateFixture( int nId, double dAngDeg)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::PlaceFixture( int nId, const Point3d& ptPos, double dAngDeg)
|
||||
{
|
||||
// verifica validità sottopezzo
|
||||
if ( ! VerifyFixture( nId))
|
||||
return false ;
|
||||
// verifico aggiornamento tavola
|
||||
if ( ! m_bTabOk && ! SetTable( m_sTabName))
|
||||
return false ;
|
||||
// verifico che la posizione sia nell'area della tavola
|
||||
if ( ! m_b3Area1.EnclosesXY( m_ptRef1 + ptPos))
|
||||
return false ;
|
||||
// resetto il riferimento del gruppo
|
||||
Frame3d* pfrFixt = m_pGeomDB->GetGroupFrame( nId) ;
|
||||
pfrFixt->Reset() ;
|
||||
// lo muovo nella posizione voluta
|
||||
Vector3d vtMove = ( m_ptRef1 + ptPos) - ORIG ;
|
||||
m_pGeomDB->TranslateGlob( nId, vtMove) ;
|
||||
// lo ruoto
|
||||
if ( fabs( dAngDeg) > EPS_ANG_SMALL)
|
||||
m_pGeomDB->RotateGroup( nId, ORIG, Z_AX, dAngDeg) ;
|
||||
// aggiorno la posizione dell'oggetto nel vettore dei comandi
|
||||
for ( auto& FixData : m_vFixData) {
|
||||
if ( FixData.nId == nId) {
|
||||
FixData.ptPos = ptPos ;
|
||||
FixData.dAng = dAngDeg ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Disposition::RemoveFixture( int nId)
|
||||
|
||||
@@ -82,6 +82,7 @@ class Disposition : public Operation
|
||||
int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngDeg = 0, bool bAddToList = true) ;
|
||||
bool MoveFixture( int nId, const Vector3d& vtMove) ;
|
||||
bool RotateFixture( int nId, double dAngDeg) ;
|
||||
bool PlaceFixture( int nId, const Point3d& ptPos, double dAngDeg) ;
|
||||
bool RemoveFixture( 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) ;
|
||||
|
||||
@@ -246,6 +246,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="Milling.cpp" />
|
||||
<ClCompile Include="MillingData.cpp" />
|
||||
<ClCompile Include="Operation.cpp" />
|
||||
<ClCompile Include="OperationCL.cpp" />
|
||||
<ClCompile Include="SawFinishing.cpp" />
|
||||
<ClCompile Include="SawFinishingData.cpp" />
|
||||
<ClCompile Include="Sawing.cpp" />
|
||||
|
||||
@@ -174,6 +174,9 @@
|
||||
<ClCompile Include="Operation.cpp">
|
||||
<Filter>Source Files\Operations</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OperationCL.cpp">
|
||||
<Filter>Source Files\Operations</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DllMain.h">
|
||||
|
||||
@@ -68,6 +68,8 @@ class Machine
|
||||
bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ;
|
||||
int GetCurrTool( void) const ;
|
||||
bool GetCurrTool( std::string& sTool) const ;
|
||||
int GetCurrHead( void) const ;
|
||||
bool GetCurrHead( std::string& sHead) const ;
|
||||
double GetCurrRot1W( void) const ;
|
||||
std::string GetKinematicAxis( int nInd) const ;
|
||||
bool BlockKinematicRotAxis( const std::string& sName, double dVal) ;
|
||||
|
||||
@@ -214,6 +214,28 @@ Machine::GetCurrTool( string& sTool) const
|
||||
return m_pGeomDB->GetName( m_nCalcToolId, sTool) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Machine::GetCurrHead( void) const
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero identificativo dell'utensile
|
||||
return m_nCalcHeadId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Machine::GetCurrHead( std::string& sHead) const
|
||||
{
|
||||
// controllo GeomDB
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero nome gruppo della testa
|
||||
return m_pGeomDB->GetName( m_nCalcHeadId, sHead) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
Machine::GetCurrRot1W( void) const
|
||||
|
||||
@@ -65,6 +65,7 @@ MachiningsMgr::MachiningsMgr( void)
|
||||
m_b5AxComp = MF_CURR_5AXCOMP ;
|
||||
m_dExtraLOnCutRegion = MF_CURR_EXTRALCR ;
|
||||
m_dExtraROnDrillRegion = MF_CURR_EXTRARDR ;
|
||||
m_dHoleDiamToler = MF_CURR_HOLEDTOL ;
|
||||
m_dExtSawArcMinRad = MF_CURR_EXTSAWARCMINRAD ;
|
||||
}
|
||||
|
||||
|
||||
+636
-4
@@ -18,7 +18,9 @@
|
||||
#include "Milling.h"
|
||||
#include "MachiningConst.h"
|
||||
#include "/EgtDev/Include/EGkCurveLine.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
@@ -187,6 +189,11 @@ Milling::Prepare( const string& sMillName)
|
||||
bool
|
||||
Milling::SetParam( int nType, bool bVal)
|
||||
{
|
||||
switch ( nType) {
|
||||
case MPA_INVERT :
|
||||
m_Params.m_bInvert = bVal ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -194,6 +201,28 @@ Milling::SetParam( int nType, bool bVal)
|
||||
bool
|
||||
Milling::SetParam( int nType, int nVal)
|
||||
{
|
||||
switch ( nType) {
|
||||
case MPA_WORKSIDE :
|
||||
if ( ! m_Params.VerifyWorkSide( nVal))
|
||||
return false ;
|
||||
m_Params.m_nWorkSide = nVal ;
|
||||
return true ;
|
||||
case MPA_STEPTYPE :
|
||||
if ( ! m_Params.VerifyStepType( nVal))
|
||||
return false ;
|
||||
m_Params.m_nStepType = nVal ;
|
||||
return true ;
|
||||
case MPA_LEADINTYPE :
|
||||
if ( ! m_Params.VerifyLeadInType( nVal))
|
||||
return false ;
|
||||
m_Params.m_nLeadInType = nVal ;
|
||||
return true ;
|
||||
case MPA_LEADOUTTYPE :
|
||||
if ( ! m_Params.VerifyLeadOutType( nVal))
|
||||
return false ;
|
||||
m_Params.m_nLeadOutType = nVal ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -246,6 +275,30 @@ Milling::SetParam( int nType, double dVal)
|
||||
else
|
||||
m_Params.m_dOffsL = dVal ;
|
||||
return true ;
|
||||
case MPA_DEPTH :
|
||||
m_Params.m_sDepth = ToString( dVal) ;
|
||||
return true ;
|
||||
case MPA_STARTPOS :
|
||||
m_Params.m_dStartPos = dVal ;
|
||||
return true ;
|
||||
case MPA_OVERLAP :
|
||||
m_Params.m_dOverlap = dVal ;
|
||||
return true ;
|
||||
case MPA_STEP :
|
||||
m_Params.m_dStep = dVal ;
|
||||
return true ;
|
||||
case MPA_LITANG :
|
||||
m_Params.m_dLiTang = dVal ;
|
||||
return true ;
|
||||
case MPA_LIPERP :
|
||||
m_Params.m_dLiPerp = dVal ;
|
||||
return true ;
|
||||
case MPA_LIELEV :
|
||||
m_Params.m_dLiElev = dVal ;
|
||||
return true ;
|
||||
case MPA_LICOMPLEN :
|
||||
m_Params.m_dLoCompLen = dVal ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
@@ -263,6 +316,9 @@ Milling::SetParam( int nType, const string& sVal)
|
||||
m_Params.m_ToolUuid = pTdata->m_Uuid ;
|
||||
m_TParams = *pTdata ;
|
||||
} break ;
|
||||
case MPA_DEPTH_STR :
|
||||
m_Params.m_sDepth = sVal ;
|
||||
return true ;
|
||||
case MPA_SYSNOTES :
|
||||
m_Params.m_sSysNotes = sVal ;
|
||||
break ;
|
||||
@@ -279,7 +335,29 @@ Milling::SetParam( int nType, const string& sVal)
|
||||
bool
|
||||
Milling::SetGeometry( const SELVECTOR& vIds)
|
||||
{
|
||||
return false ;
|
||||
// verifico validità gestore DB geometrico
|
||||
if ( m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// reset della geometria corrente
|
||||
m_vId.clear() ;
|
||||
// verifico che gli identificativi rappresentino delle entità ammissibili
|
||||
for ( const auto& Id : vIds) {
|
||||
// test sull'entità
|
||||
int nSubs ;
|
||||
if ( ! VerifyGeometry( Id, nSubs)) {
|
||||
string sOut = "Entity " + ToString( Id) + " skipped by Milling" ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
|
||||
continue ;
|
||||
}
|
||||
// posso aggiungere alla lista
|
||||
if ( nSubs == 0)
|
||||
m_vId.emplace_back( Id) ;
|
||||
else {
|
||||
for ( int i = 0 ; i < nSubs ; ++ i)
|
||||
m_vId.emplace_back( Id.nId, i) ;
|
||||
}
|
||||
}
|
||||
return ( ! m_vId.empty()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -299,7 +377,72 @@ Milling::Apply( bool bRecalc)
|
||||
// reset numero percorsi di lavoro generati
|
||||
m_nMills = 0 ;
|
||||
|
||||
return false ;
|
||||
// verifico validità gestore DB geometrico e Id del gruppo
|
||||
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
|
||||
return false ;
|
||||
|
||||
// recupero gruppo per geometria ausiliaria
|
||||
int nAuxId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUX) ;
|
||||
bool bChain = false ;
|
||||
// se non c'è, lo aggiungo
|
||||
if ( nAuxId == GDB_ID_NULL) {
|
||||
nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
|
||||
if ( nAuxId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nAuxId, MCH_AUX) ;
|
||||
m_pGeomDB->SetStatus( nAuxId, GDB_ST_OFF) ;
|
||||
bChain = true ;
|
||||
}
|
||||
// altrimenti, se chiesto ricalcolo, lo svuoto
|
||||
else if ( bRecalc) {
|
||||
m_pGeomDB->EmptyGroup( nAuxId) ;
|
||||
bChain = true ;
|
||||
}
|
||||
|
||||
// aggiorno dati geometrici dell'utensile
|
||||
if ( ! UpdateToolData()) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Sawing : UpdateToolData failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId))
|
||||
return false ;
|
||||
|
||||
// recupero gruppo per geometria di lavorazione (Cutter Location)
|
||||
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
|
||||
// se non c'è, lo aggiungo
|
||||
if ( nClId == GDB_ID_NULL) {
|
||||
nClId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
|
||||
if ( nClId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nClId, MCH_CL) ;
|
||||
}
|
||||
// altrimenti lo svuoto
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nClId) ;
|
||||
|
||||
// lavoro ogni singola catena
|
||||
int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ;
|
||||
while ( nPathId != GDB_ID_NULL) {
|
||||
if ( ! ProcessPath( nPathId, GDB_ID_NULL, nClId))
|
||||
return false ;
|
||||
nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
|
||||
}
|
||||
|
||||
// se lavorazione vuota, esco
|
||||
if ( m_nMills == 0)
|
||||
return true ;
|
||||
|
||||
// calcolo gli assi macchina
|
||||
if ( ! CalculateAxesValues())
|
||||
return false ;
|
||||
|
||||
// gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione
|
||||
if ( ! AdjustStartEndMovements())
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -317,6 +460,18 @@ Milling::GetParam( int nType, int& nVal) const
|
||||
case MPA_TYPE :
|
||||
nVal = MT_MILLING ;
|
||||
return true ;
|
||||
case MPA_WORKSIDE :
|
||||
nVal = m_Params.m_nWorkSide ;
|
||||
return true ;
|
||||
case MPA_STEPTYPE :
|
||||
nVal = m_Params.m_nStepType ;
|
||||
return true ;
|
||||
case MPA_LEADINTYPE :
|
||||
nVal = m_Params.m_nLeadInType ;
|
||||
return true ;
|
||||
case MPA_LEADOUTTYPE :
|
||||
nVal = m_Params.m_nLeadOutType ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
@@ -350,9 +505,25 @@ Milling::GetParam( int nType, double& dVal) const
|
||||
case MPA_STARTPOS :
|
||||
dVal = m_Params.m_dStartPos ;
|
||||
return true ;
|
||||
case MPA_SIDEANGLE :
|
||||
dVal = m_Params.m_dSideAngle ;
|
||||
case MPA_OVERLAP :
|
||||
dVal = m_Params.m_dOverlap ;
|
||||
return true ;
|
||||
case MPA_STEP :
|
||||
dVal = m_Params.m_dStep ;
|
||||
return true ;
|
||||
case MPA_LITANG :
|
||||
dVal = m_Params.m_dLiTang ;
|
||||
return true ;
|
||||
case MPA_LIPERP :
|
||||
dVal = m_Params.m_dLiPerp ;
|
||||
return true ;
|
||||
case MPA_LIELEV :
|
||||
dVal = m_Params.m_dLiElev ;
|
||||
return true ;
|
||||
case MPA_LICOMPLEN :
|
||||
dVal = m_Params.m_dLoCompLen ;
|
||||
return true ;
|
||||
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
@@ -607,3 +778,464 @@ Milling::AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP)
|
||||
// non devo fare alcunché
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
{
|
||||
// recupero gruppo per geometria temporanea
|
||||
const string GRP_TEMP = "Temp" ;
|
||||
int nTempId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, GRP_TEMP) ;
|
||||
// se non c'è, lo aggiungo
|
||||
if ( nTempId == GDB_ID_NULL) {
|
||||
nTempId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
|
||||
if ( nTempId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nTempId, GRP_TEMP) ;
|
||||
}
|
||||
// altrimenti lo svuoto
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nTempId) ;
|
||||
// in ogni caso lo dichiaro temporaneo e non visibile
|
||||
m_pGeomDB->SetLevel( nTempId, GDB_LV_TEMP) ;
|
||||
m_pGeomDB->SetStatus( nTempId, GDB_ST_OFF) ;
|
||||
|
||||
// copio la curva composita da elaborare
|
||||
int nCrvId = m_pGeomDB->GetFirstInGroup( nPathId) ;
|
||||
if ( m_pGeomDB->GetGeoType( nCrvId) != CRV_COMPO)
|
||||
return false ;
|
||||
int nCopyId = m_pGeomDB->CopyGlob( nCrvId, GDB_ID_NULL, nTempId) ;
|
||||
if ( nCopyId == GDB_ID_NULL)
|
||||
return false ;
|
||||
ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nCopyId)) ;
|
||||
|
||||
// unisco le parti allineate
|
||||
//if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL))
|
||||
// return false ;
|
||||
|
||||
// eventuale inversione percorso
|
||||
if ( m_Params.m_bInvert)
|
||||
pCompo->Invert() ;
|
||||
|
||||
// se utensile non centrato, eseguo correzione raggio utensile ed eventuale offset
|
||||
double dOffs = 0.5 * m_TParams.m_dTDiam + GetOffsR() ;
|
||||
if ( m_Params.m_nWorkSide != MILL_WS_CENTER && abs( dOffs) > EPS_SMALL) {
|
||||
double dSignOffs = ( m_Params.m_nWorkSide == MILL_WS_RIGHT) ? dOffs : - dOffs ;
|
||||
if ( ! pCompo->SimpleOffset( dSignOffs, ICurve::OFF_EXTEND)){
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : SimpleOffset not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// recupero estrusione e spessore
|
||||
Vector3d vtExtr ;
|
||||
pCompo->GetExtrusion( vtExtr) ;
|
||||
double dThick ;
|
||||
pCompo->GetThickness( dThick) ;
|
||||
|
||||
// recupero il box del grezzo in globale
|
||||
BBox3d b3Raw ;
|
||||
if ( ! GetRawGlobBox( m_nPhase, nPathId, b3Raw) || b3Raw.IsEmpty()) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in SawFinishing : Empty RawBox") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero distanza da fondo dei grezzi interessati dal percorso
|
||||
double dRbDist ;
|
||||
if ( ! GetDistanceFromRawBottom( m_nPhase, nCopyId, 2 * m_TParams.m_dThick, dRbDist))
|
||||
return false ;
|
||||
|
||||
// valuto l'espressione dell'affondamento
|
||||
ExeLuaSetGlobNumVar( "TH", (( dThick * vtExtr.z < 0) ? fabs( dThick) : 0)) ;
|
||||
ExeLuaSetGlobNumVar( "RB", dRbDist) ;
|
||||
double dDepth ;
|
||||
if ( ! ExeLuaEvalNumExpr( m_Params.m_sDepth, &dDepth)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : Depth not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// verifico di non superare il massimo materiale
|
||||
if ( dDepth > m_TParams.m_dMaxMat) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : Depth bigger than MaxMaterial") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero nome del path
|
||||
string sPathName ;
|
||||
m_pGeomDB->GetName( nPathId, sPathName) ;
|
||||
|
||||
// verifiche sull'ampiezza dell'angolo al centro degli eventuali archi
|
||||
const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
|
||||
int nMaxInd = pCompo->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// se arco con angolo al centro oltre il limite, lo divido a metà
|
||||
const ICurveArc* pArc = GetCurveArc( pCompo->GetCurve( i)) ;
|
||||
if ( pArc != nullptr && abs( pArc->GetAngCenter()) > MAX_ANG_CEN) {
|
||||
pCompo->AddJoint( i + 0.5) ;
|
||||
++ i ;
|
||||
++ nMaxInd ;
|
||||
}
|
||||
}
|
||||
|
||||
// creo gruppo per geometria di lavorazione del percorso
|
||||
int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ;
|
||||
if ( nPxId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nPxId, sPathName) ;
|
||||
m_pGeomDB->SetMaterial( nPxId, BLUE) ;
|
||||
|
||||
// calcolo il versore fresa
|
||||
Vector3d vtTool = Z_AX ;
|
||||
if ( ! vtExtr.IsSmall())
|
||||
vtTool = vtExtr ;
|
||||
|
||||
// Imposto dati comuni
|
||||
SetPathId( nPxId) ;
|
||||
SetToolDir( vtTool) ;
|
||||
// recupero distanza di sicurezza
|
||||
double dSafeZ = m_pMchMgr->GetCurrMachiningsMgr()->GetSafeZ() ;
|
||||
// lunghezza di approccio/retrazione
|
||||
double dAppr = m_Params.m_dStartPos ;
|
||||
|
||||
// ciclo sulle curve elementari
|
||||
bool bClosed = pCompo->IsClosed() ;
|
||||
nMaxInd = pCompo->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvC = pCompo->GetCurve( i) ;
|
||||
// copio la curva
|
||||
PtrOwner<ICurve> pCurve( ::GetCurve( pCrvC->Clone())) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pCurve->Translate( - vtTool * dDepth) ;
|
||||
// calcolo elevazione
|
||||
double dElev ;
|
||||
Point3d ptStart, ptMid, ptEnd ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
pCurve->GetMidPoint( ptMid) ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart, ptMid, ptEnd, vtTool, dElev)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
if ( dElev < EPS_SMALL) {
|
||||
BBox3d b3Crv ;
|
||||
pCurve->GetLocalBBox( b3Crv) ;
|
||||
dElev = max( 0., b3Raw.GetMax().z - b3Crv.GetMin().z) ;
|
||||
}
|
||||
// se prima entità, approccio e affondo
|
||||
if ( i == 0) {
|
||||
// dati inizio entità
|
||||
Point3d ptStart ;
|
||||
pCurve->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
pCurve->GetStartDir( vtStart) ;
|
||||
// determino inizio attacco
|
||||
Point3d ptP1 ;
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, ptP1))
|
||||
return false ;
|
||||
// aggiungo approccio
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dElev, dAppr))
|
||||
return false ;
|
||||
// affondo al punto iniziale
|
||||
SetFlag( 0) ;
|
||||
SetFeed( GetTipFeed()) ;
|
||||
if ( AddLinearMove( ptP1) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// elaborazioni sulla curva corrente
|
||||
if ( pCurve->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCurve) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddLinearMove( ptP3) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else if ( pCurve->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCurve) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
SetFeed( GetFeed()) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se ultima entità, uscita e retrazione
|
||||
if ( i == nMaxInd) {
|
||||
// dati fine entità
|
||||
Point3d ptEnd ;
|
||||
pCurve->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtEnd ;
|
||||
pCurve->GetEndDir( vtEnd) ;
|
||||
// aggiungo uscita
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, ptP1)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dElev, dAppr))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// incremento numero di fresate
|
||||
++ m_nMills ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
|
||||
{
|
||||
// se distanza di sicurezza minore di distanza di inizio
|
||||
if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) {
|
||||
// 1 -> punto sopra inizio
|
||||
SetFlag( 1) ;
|
||||
Point3d ptP1 = ptP + vtTool * ( dElev + dAppr) ;
|
||||
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
// 1a -> punto sopra inizio
|
||||
SetFlag( 1) ;
|
||||
Point3d ptP1b = ptP + vtTool * ( dElev + dAppr) ;
|
||||
Point3d ptP1a = ptP1b + vtTool * ( dSafeZ - m_Params.m_dStartPos) ;
|
||||
if ( AddRapidStart( ptP1a) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// 1b -> punto appena sopra inizio
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP1b) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
|
||||
{
|
||||
if ( dSafeZ < m_Params.m_dStartPos + 10 * EPS_SMALL) {
|
||||
// 4 -> movimento di risalita sopra il punto finale
|
||||
SetFeed( GetEndFeed()) ;
|
||||
Point3d ptP4 = ptP + vtTool * ( dElev + dAppr) ;
|
||||
if ( AddLinearMove( ptP4) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
// 4a -> movimento di risalita appena sopra il punto finale
|
||||
SetFeed( GetEndFeed()) ;
|
||||
Point3d ptP4a = ptP + vtTool * ( dElev + dAppr) ;
|
||||
if ( AddLinearMove( ptP4a) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// 4b -> movimento di risalita sopra il punto finale
|
||||
Point3d ptP4b = ptP4a + vtTool * ( dSafeZ - m_Params.m_dStartPos) ;
|
||||
if ( AddRapidMove( ptP4b) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, Point3d& ptP1)
|
||||
{
|
||||
switch ( m_Params.m_nLeadInType) {
|
||||
case MILL_LI_NONE :
|
||||
ptP1 = ptStart ;
|
||||
return true ;
|
||||
case MILL_LI_LINEAR :
|
||||
case MILL_LI_TANGENT : {
|
||||
if ( m_Params.m_dLiTang < 10 * EPS_SMALL && abs( m_Params.m_dLiPerp) < EPS_SMALL)
|
||||
return false ;
|
||||
Vector3d vtPerp = vtStart ;
|
||||
vtPerp.Rotate( vtN, ( ( m_Params.m_nWorkSide == MILL_WS_LEFT) ? 90 : - 90)) ;
|
||||
ptP1 = ptStart - vtStart * m_Params.m_dLiTang + vtPerp * m_Params.m_dLiPerp ;
|
||||
return true ;
|
||||
}
|
||||
case MILL_LI_GLIDE :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN)
|
||||
{
|
||||
switch ( m_Params.m_nLeadInType) {
|
||||
case MILL_LI_NONE :
|
||||
return true ;
|
||||
case MILL_LI_LINEAR :
|
||||
return ( AddLinearMove( ptStart, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
case MILL_LI_TANGENT :
|
||||
{
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptStart, ptP1, - vtStart, vtN)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
pCrv->Invert() ;
|
||||
if ( pCrv->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCrv) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
return ( AddLinearMove( ptP3, MCH_CL_LEADIN) != GDB_ID_NULL) ;
|
||||
}
|
||||
else if ( pCrv->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCrv) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
else if ( abs( dAngCen) < 2 * MAX_ANG_CEN){
|
||||
Point3d ptMid ;
|
||||
pArc->GetMidPoint( ptMid) ;
|
||||
// prima metà arco
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// oppure tre archi
|
||||
else {
|
||||
Point3d ptTmp ;
|
||||
// primo terzo
|
||||
pArc->GetPointD1D2( 1. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// secondo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
pArc->GetPointD1D2( 2. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// ultimo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 3, vtN, MCH_CL_LEADIN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
case MILL_LI_GLIDE :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, Point3d& ptP1)
|
||||
{
|
||||
// assegno i parametri
|
||||
int nType = m_Params.m_nLeadOutType ;
|
||||
double dTang = m_Params.m_dLoTang ;
|
||||
double dPerp = m_Params.m_dLoPerp ;
|
||||
if ( nType == MILL_LO_AS_LI) {
|
||||
nType = m_Params.m_nLeadInType ;
|
||||
dTang = m_Params.m_dLiTang ;
|
||||
dPerp = m_Params.m_dLiPerp ;
|
||||
}
|
||||
// eseguo a seconda del tipo
|
||||
switch ( nType) {
|
||||
case MILL_LO_NONE :
|
||||
ptP1 = ptEnd ;
|
||||
return true ;
|
||||
case MILL_LO_LINEAR :
|
||||
{
|
||||
if ( dTang < 10 * EPS_SMALL && abs( dPerp) < EPS_SMALL)
|
||||
return false ;
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
vtPerp.Rotate( vtN, ( ( m_Params.m_nWorkSide == MILL_WS_LEFT) ? 90 : - 90)) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
|
||||
return ( AddLinearMove( ptP1, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
case MILL_LO_TANGENT :
|
||||
{
|
||||
// calcolo punto finale dell'uscita
|
||||
if ( dTang < 10 * EPS_SMALL && abs( dPerp) < EPS_SMALL)
|
||||
return false ;
|
||||
Vector3d vtPerp = vtEnd ;
|
||||
vtPerp.Rotate( vtN, ( ( m_Params.m_nWorkSide == MILL_WS_LEFT) ? 90 : - 90)) ;
|
||||
ptP1 = ptEnd + vtEnd * dTang + vtPerp * dPerp ;
|
||||
// inserisco uscita
|
||||
PtrOwner<ICurve> pCrv( GetArc2PVN( ptEnd, ptP1, vtEnd, vtN)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
if ( pCrv->GetType() == CRV_LINE) {
|
||||
ICurveLine* pLine = GetCurveLine( pCrv) ;
|
||||
Point3d ptP3 = pLine->GetEnd() ;
|
||||
return ( AddLinearMove( ptP3, MCH_CL_LEADOUT) != GDB_ID_NULL) ;
|
||||
}
|
||||
else if ( pCrv->GetType() == CRV_ARC) {
|
||||
ICurveArc* pArc = GetCurveArc( pCrv) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
const double MAX_ANG_CEN = 150 + EPS_ANG_SMALL ;
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
else if ( abs( dAngCen) < 2 * MAX_ANG_CEN){
|
||||
Point3d ptMid ;
|
||||
pArc->GetMidPoint( ptMid) ;
|
||||
// prima metà arco
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
ptCen.z = ptMid.z ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// oppure tre archi
|
||||
else {
|
||||
Point3d ptTmp ;
|
||||
// primo terzo
|
||||
pArc->GetPointD1D2( 1. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// secondo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
pArc->GetPointD1D2( 2. / 3, ICurve::FROM_MINUS, ptTmp) ;
|
||||
if ( AddArcMove( ptTmp, ptCen, dAngCen / 3, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// ultimo terzo
|
||||
ptCen.z = ptTmp.z ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 3, vtN, MCH_CL_LEADOUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
case MILL_LO_GLIDE :
|
||||
// !!! DA FARE !!!
|
||||
return false ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,12 @@ class Milling : public Machining
|
||||
bool VerifyGeometry( SelData Id, int& nSubs) ;
|
||||
ICurve* GetCurve( SelData Id) ;
|
||||
bool Chain( int nGrpDestId) ;
|
||||
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
|
||||
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr) ;
|
||||
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN, Point3d& ptP1) ;
|
||||
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN) ;
|
||||
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN, Point3d& ptP1) ;
|
||||
|
||||
private :
|
||||
double GetSpeed() const
|
||||
|
||||
+96
-256
@@ -24,6 +24,7 @@
|
||||
#include "/EgtDev/Include/EgkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -608,9 +609,7 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
|
||||
vAxVal.emplace_back( dAng) ;
|
||||
// verifico i limiti di corsa degli assi
|
||||
int nStat ;
|
||||
double dAngA = ( vAng1.size() >= 1 ? vAng1[0] : 0) ;
|
||||
double dAngB = ( vAng1.size() >= 2 ? vAng1[1] : 0) ;
|
||||
bool bOsOk = m_pMchMgr->VerifyOutstroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
|
||||
bool bOsOk = m_pMchMgr->VerifyOutstroke( dX, dY, dZ, vAng1, nStat) ;
|
||||
if ( ! bOsOk || nStat != 0) {
|
||||
bOk = false ;
|
||||
pCamData->SetAxes( CamData::AS_OUTSTROKE, vAxVal) ;
|
||||
@@ -631,8 +630,9 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
|
||||
// ricavo punto medio
|
||||
Point3d ptCen = pCamData->GetCenter() ;
|
||||
double dAngCen = pCamData->GetAngCen() ;
|
||||
Vector3d vtN = pCamData->GetNormDir() ;
|
||||
Point3d ptMid = ptP ;
|
||||
ptMid.Rotate( ptCen, Z_AX, - dAngCen / 2) ;
|
||||
ptMid.Rotate( ptCen, vtN, - dAngCen / 2) ;
|
||||
// determino i valori degli assi al punto medio
|
||||
DBLVECTOR vAngMid( vAng1.size()) ;
|
||||
for ( size_t i = 0 ; i < vAng1.size() ; ++ i)
|
||||
@@ -655,6 +655,7 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
|
||||
pCamData->SetAxesCen( ptP2M) ;
|
||||
pCamData->SetAxesRad( 0) ;
|
||||
pCamData->SetAxesAngCen( 0) ;
|
||||
pCamData->SetAxesNormDir( V_NULL) ;
|
||||
// il movimento diventa lineare
|
||||
pCamData->SetMoveType( 1) ;
|
||||
// non è necessario verificare i limiti di corsa degli assi
|
||||
@@ -668,28 +669,30 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes,
|
||||
continue ;
|
||||
}
|
||||
// verifico il piano
|
||||
if ( pArc->GetNormVersor().z < 0)
|
||||
if ( pArc->GetNormVersor() * pCamData->GetToolDir() < 0)
|
||||
pArc->InvertN() ;
|
||||
// assegno il centro e il raggio di questo arco ai dati cam
|
||||
pCamData->SetAxesCen( pArc->GetCenter()) ;
|
||||
pCamData->SetAxesRad( pArc->GetRadius()) ;
|
||||
pCamData->SetAxesAngCen( pArc->GetAngCenter()) ;
|
||||
pCamData->SetAxesNormDir( pArc->GetNormVersor()) ;
|
||||
// aggiorno il tipo di arco
|
||||
pCamData->SetMoveType( pArc->GetAngCenter() > 0 ? 3 : 2) ;
|
||||
// verifico i limiti di corsa dei punti lungo l'arco
|
||||
const int NUM_VERIF_STEP = 16 ;
|
||||
Point3d ptCen = pCamData->GetAxesCen() ;
|
||||
double dAngCenStep = pCamData->GetAxesAngCen() / NUM_VERIF_STEP ;
|
||||
Vector3d vtN = pCamData->GetAxisNormDir() ;
|
||||
Vector3d vtCurr = Point3d( dXprec, dYprec, dZprec) - ptCen ;
|
||||
for ( int i = 1 ; i < NUM_VERIF_STEP ; ++ i) {
|
||||
vtCurr.Rotate( Z_AX, dAngCenStep) ;
|
||||
vtCurr.Rotate( vtN, dAngCenStep) ;
|
||||
Point3d ptCurr = ptCen + vtCurr ;
|
||||
double dCoeff = i / NUM_VERIF_STEP ;
|
||||
DBLVECTOR vAng( vAng1.size()) ;
|
||||
for ( size_t i = 0 ; i < vAng1.size() ; ++ i)
|
||||
vAng[i] = vAxRotPrec[i] * ( 1 - dCoeff) + vAng1[i] * dCoeff ;
|
||||
int nStat ;
|
||||
bool bOsOk = m_pMchMgr->VerifyOutstroke( ptCurr.x, ptCurr.y, ptCurr.z, vAng[0], vAng[1], nStat) ;
|
||||
bool bOsOk = m_pMchMgr->VerifyOutstroke( ptCurr.x, ptCurr.y, ptCurr.z, vAng, nStat) ;
|
||||
if ( ! bOsOk || nStat != 0) {
|
||||
bOk = false ;
|
||||
pCamData->SetAxes( CamData::AS_OUTSTROKE, vAxVal) ;
|
||||
@@ -761,6 +764,11 @@ Operation::AdjustStartEndMovements(void)
|
||||
DBLVECTOR vAxIni ;
|
||||
if ( ! pPrevOp->GetFinalAxesValues( vAxVal) || ! GetInitialAxesValues( vAxIni))
|
||||
return false ;
|
||||
// verifico se la testa interferisce con i pezzi o i bloccaggi sulla tavola
|
||||
if ( ! TestCollisionAvoid( vAxVal, vAxIni)) {
|
||||
if ( ! pPrevOp->AddRise( vAxVal))
|
||||
return false ;
|
||||
}
|
||||
// determino delta Z rispetto a posizione finale
|
||||
if ( vAxVal.size() >= 4 && vAxIni.size() >= 4) {
|
||||
double dDelta = 0 ;
|
||||
@@ -902,7 +910,7 @@ Operation::AddRise( DBLVECTOR& vAxVal, double dDelta)
|
||||
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nLastPxClId, Release( pGP)) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nId, MCH_RISE) ;
|
||||
m_pGeomDB->SetName( nId, MCH_CL_RISE) ;
|
||||
// creo oggetto dati Cam
|
||||
PtrOwner<CamData> pCam( pCamData->Clone()) ;
|
||||
if ( IsNull( pCam))
|
||||
@@ -958,16 +966,16 @@ Operation::RemoveRise( void)
|
||||
// recupero l'ultimo percorso CL
|
||||
int nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ;
|
||||
// elimino tutte le entità RISE alla fine del percorso
|
||||
int nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_RISE) ;
|
||||
int nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_RISE) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
m_pGeomDB->Erase( nId) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_RISE) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_RISE) ;
|
||||
}
|
||||
// elimino a maggior ragione le entità HOME
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_HOME) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_HOME) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
m_pGeomDB->Erase( nId) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_HOME) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_HOME) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -986,7 +994,7 @@ Operation::AddHome( void)
|
||||
// recupero l'ultimo percorso
|
||||
int nLastPxClId = m_pGeomDB->GetLastGroupInGroup( nClId) ;
|
||||
// recupero l'ultima entità del percorso di nome RISE
|
||||
int nEntId = m_pGeomDB->GetLastNameInGroup( nLastPxClId, MCH_RISE) ;
|
||||
int nEntId = m_pGeomDB->GetLastNameInGroup( nLastPxClId, MCH_CL_RISE) ;
|
||||
if ( nEntId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// ne recupero i dati Cam
|
||||
@@ -1003,7 +1011,7 @@ Operation::AddHome( void)
|
||||
int nId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nLastPxClId, Release( pGP)) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nId, MCH_HOME) ;
|
||||
m_pGeomDB->SetName( nId, MCH_CL_HOME) ;
|
||||
// creo oggetto dati Cam
|
||||
PtrOwner<CamData> pCam( pCamData->Clone()) ;
|
||||
if ( IsNull( pCam))
|
||||
@@ -1037,10 +1045,10 @@ Operation::RemoveHome( void)
|
||||
// recupero l'ultimo percorso CL
|
||||
int nClPathId = m_pGeomDB->GetLastGroupInGroup( nClId) ;
|
||||
// elimino tutte le entità HOME alla fine del percorso
|
||||
int nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_HOME) ;
|
||||
int nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_HOME) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
m_pGeomDB->Erase( nId) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_HOME) ;
|
||||
nId = m_pGeomDB->GetFirstNameInGroup( nClPathId, MCH_CL_HOME) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -1092,250 +1100,82 @@ Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Operation::SetPathId( int nPathId)
|
||||
Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd)
|
||||
{
|
||||
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::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::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 ;
|
||||
// Recupero macchina corrente
|
||||
Machine* pMch = ( m_pMchMgr != nullptr ? m_pMchMgr->GetCurrMachine() : nullptr) ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
// Recupero tavola corrente
|
||||
string sTable ;
|
||||
if ( ! pMch->GetCurrTable( sTable))
|
||||
return false ;
|
||||
// Recupero assi correnti
|
||||
STRVECTOR vAxName ;
|
||||
pMch->GetAllCurrAxesName( vAxName) ;
|
||||
// il numero di assi deve essere costante
|
||||
if ( vAxName.size() != vAxStart.size() || vAxName.size() != vAxEnd.size())
|
||||
return false ;
|
||||
// Porto la macchina in home
|
||||
pMch->ResetAllAxesPos() ;
|
||||
// Elenco grezzi attivi
|
||||
INTVECTOR vRawId ;
|
||||
int nRawId = m_pMchMgr->GetFirstRawPart() ;
|
||||
while ( nRawId != GDB_ID_NULL) {
|
||||
if ( m_pMchMgr->VerifyRawPartPhase( nRawId, m_nPhase))
|
||||
vRawId.emplace_back( nRawId) ;
|
||||
nRawId = m_pMchMgr->GetNextRawPart( nRawId) ;
|
||||
}
|
||||
// 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")
|
||||
// Aggancio pezzi attivi alla tavola corrente
|
||||
for ( const auto nRawId : vRawId)
|
||||
pMch->LinkRawPartToGroup( nRawId, sTable) ;
|
||||
// Elenco bloccaggi attivi
|
||||
INTVECTOR vFxtId ;
|
||||
int nFxtId = m_pMchMgr->GetFirstFixture() ;
|
||||
while ( nFxtId != GDB_ID_NULL) {
|
||||
vFxtId.emplace_back( nFxtId) ;
|
||||
nFxtId = m_pMchMgr->GetNextFixture( nFxtId) ;
|
||||
}
|
||||
// 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 ;
|
||||
}
|
||||
// Aggancio bloccaggi alla tavola corrente
|
||||
for ( const auto nFxtId : vFxtId)
|
||||
pMch->LinkFixtureToGroup( nFxtId, sTable) ;
|
||||
// Vado nelle posizioni da controllare
|
||||
bool bCollide = false ;
|
||||
for ( int i = 1 ; i <= 3 && ! bCollide ; ++ i) {
|
||||
double dCoeff = double( i) / 4 ;
|
||||
for ( size_t j = 0 ; j < vAxStart.size() ; ++ j) {
|
||||
double dPos = ( 1 - dCoeff) * vAxStart[j] + dCoeff * vAxEnd[j] ;
|
||||
pMch->SetAxisPos( vAxName[j], dPos) ;
|
||||
}
|
||||
// Eseguo controllo
|
||||
BBox3d b3Head ;
|
||||
m_pGeomDB->GetGlobalBBox( pMch->GetCurrHead(), b3Head) ;
|
||||
for ( const auto nRawId : vRawId) {
|
||||
BBox3d b3Raw ;
|
||||
int nRawSolidId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
|
||||
if ( m_pGeomDB->GetGlobalBBox( nRawSolidId, b3Raw) && b3Head.Overlaps( b3Raw)) {
|
||||
bCollide = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
for ( const auto nFxtId : vFxtId) {
|
||||
BBox3d b3Fxt ;
|
||||
if ( m_pGeomDB->GetGlobalBBox( nFxtId, b3Fxt) && b3Head.Overlaps( b3Fxt)) {
|
||||
bCollide = true ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
//int nRes = 1 ;
|
||||
//while ( nRes != 0)
|
||||
// nRes = ExeProcessEvents( 0, 5) ;
|
||||
}
|
||||
// Riporto la macchina in home
|
||||
pMch->ResetAllAxesPos() ;
|
||||
// Sgancio grezzi e sottopezzi dalla tavola corrente
|
||||
pMch->UnlinkAllRawPartsFromGroups() ;
|
||||
pMch->UnlinkAllFixturesFromGroups() ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
Operation::AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, double dDeltaZ)
|
||||
{
|
||||
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
|
||||
if ( ! pArc->SetCPA( ptCen, m_ptCurr, dAngCen, dDeltaZ))
|
||||
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->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
|
||||
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 ;
|
||||
return ( ! bCollide) ;
|
||||
}
|
||||
|
||||
+4
-1
@@ -76,6 +76,7 @@ class Operation : public IUserObj
|
||||
bool AddHome( void) ;
|
||||
bool RemoveHome( void) ;
|
||||
bool CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ) ;
|
||||
bool TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) ;
|
||||
|
||||
protected :
|
||||
int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore
|
||||
@@ -96,7 +97,9 @@ class Operation : public IUserObj
|
||||
int AddRapidStart( const Point3d& ptP) ;
|
||||
int AddRapidMove( const Point3d& ptP) ;
|
||||
int AddLinearMove( const Point3d& ptP) ;
|
||||
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, double dDeltaZ = 0) ;
|
||||
int AddLinearMove( const Point3d& ptP, const std::string& sName) ;
|
||||
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN) ;
|
||||
int AddArcMove( const Point3d& ptP, const Point3d& ptCen, double dAngCen, const Vector3d& vtN, const std::string& sName) ;
|
||||
bool ResetMoveData( void) ;
|
||||
|
||||
protected :
|
||||
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// 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::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::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 - ptCen) * 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->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 ;
|
||||
}
|
||||
+24
-18
@@ -1916,12 +1916,13 @@ Sawing::GenerateExtArcCl( const ICurveArc* pArc, const Vector3d& vtStaTool, cons
|
||||
SetFeed( GetFeed()) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
SetToolDir( vtEndTool) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
@@ -1930,11 +1931,11 @@ Sawing::GenerateExtArcCl( const ICurveArc* pArc, const Vector3d& vtStaTool, cons
|
||||
pArc->GetMidPoint( ptMid) ;
|
||||
// prima metà arco
|
||||
SetToolDir( vtMidTool) ;
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
SetToolDir( vtEndTool) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// 4 -> retrazione
|
||||
@@ -1985,11 +1986,12 @@ Sawing::GenerateExtArcCl( const ICurveArc* pArc, const Vector3d& vtStaTool, cons
|
||||
SetFeed( GetFeed()) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
double dCurrAngCen = dAngCen * ((( i % 2) == 0) ? -1 : 1) ;
|
||||
SetToolDir( ( ( i % 2) == 0) ? vtStaTool : vtEndTool) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
@@ -2000,11 +2002,11 @@ Sawing::GenerateExtArcCl( const ICurveArc* pArc, const Vector3d& vtStaTool, cons
|
||||
double dCurrAngCen = dAngCen / 2 * ((( i % 2) == 0) ? -1 : 1) ;
|
||||
// prima metà arco
|
||||
SetToolDir( vtMidTool) ;
|
||||
if ( AddArcMove( ptMid, ptCen, dCurrAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptMid, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
SetToolDir( ( ( i % 2) == 0) ? vtStaTool : vtEndTool) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -2046,13 +2048,14 @@ Sawing::GenerateExtArcCl( const ICurveArc* pArc, const Vector3d& vtStaTool, cons
|
||||
SetFeed( GetFeed()) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 += vtCorr * dDelta ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
SetToolDir( vtEndTool) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
@@ -2062,11 +2065,11 @@ Sawing::GenerateExtArcCl( const ICurveArc* pArc, const Vector3d& vtStaTool, cons
|
||||
ptMid += vtCorr * dDelta ;
|
||||
// prima metà arco
|
||||
SetToolDir( vtMidTool) ;
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
SetToolDir( vtEndTool) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se non è ultimo passo
|
||||
@@ -2544,13 +2547,14 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
SetFeed( GetFeed()) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
if ( abs( pArc->GetAngCenter()) < MAX_ANG_CEN) {
|
||||
SetToolDir( vtEndTool) ;
|
||||
SetCorrAuxDir( vtEndCorr) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
@@ -2560,12 +2564,12 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
// prima metà arco
|
||||
SetToolDir( vtMidTool) ;
|
||||
SetCorrAuxDir( vtMidCorr) ;
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
SetToolDir( vtEndTool) ;
|
||||
SetCorrAuxDir( vtEndCorr) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// 4 -> retrazione
|
||||
@@ -2618,12 +2622,13 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
SetFeed( GetFeed()) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
// se angolo al centro minore del limite, un solo arco
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
double dCurrAngCen = dAngCen * ((( i % 2) == 0) ? -1 : 1) ;
|
||||
SetToolDir( ( ( i % 2) == 0) ? vtStaTool : vtEndTool) ;
|
||||
SetCorrAuxDir( ( ( i % 2) == 0) ? vtStaCorr : vtEndCorr) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
@@ -2635,12 +2640,12 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
// prima metà arco
|
||||
SetToolDir( vtMidTool) ;
|
||||
SetCorrAuxDir( vtMidCorr) ;
|
||||
if ( AddArcMove( ptMid, ptCen, dCurrAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptMid, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
SetToolDir( ( ( i % 2) == 0) ? vtStaTool : vtEndTool) ;
|
||||
SetCorrAuxDir( ( ( i % 2) == 0) ? vtStaCorr : vtEndCorr) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dCurrAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -2685,6 +2690,7 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
SetFeed( GetFeed()) ;
|
||||
Point3d ptCen = pArc->GetCenter() ;
|
||||
double dAngCen = pArc->GetAngCenter() ;
|
||||
Vector3d vtN = pArc->GetNormVersor() ;
|
||||
Point3d ptP3 ;
|
||||
pArc->GetEndPoint( ptP3) ;
|
||||
ptP3 += Z_AX * dDelta ;
|
||||
@@ -2692,7 +2698,7 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
if ( abs( dAngCen) < MAX_ANG_CEN) {
|
||||
SetToolDir( vtEndTool) ;
|
||||
SetCorrAuxDir( vtEndCorr) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti due archi
|
||||
@@ -2703,12 +2709,12 @@ Sawing::GenerateIntArcCl( const ICurveArc* pArc,
|
||||
// prima metà arco
|
||||
SetToolDir( vtMidTool) ;
|
||||
SetCorrAuxDir( vtMidCorr) ;
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptMid, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// seconda metà arco
|
||||
SetToolDir( vtEndTool) ;
|
||||
SetCorrAuxDir( vtEndCorr) ;
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2) == GDB_ID_NULL)
|
||||
if ( AddArcMove( ptP3, ptCen, dAngCen / 2, vtN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// se non è ultimo passo
|
||||
|
||||
+4
-4
@@ -434,10 +434,10 @@ Simulator::GoHome( void)
|
||||
// controllo validità stato
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr)
|
||||
return false ;
|
||||
// reset stato macchina
|
||||
OnResetMachine() ;
|
||||
// porto la macchina in home
|
||||
m_pMchMgr->ResetAllAxesPos() ;
|
||||
// reset stato macchina
|
||||
OnResetMachine() ;
|
||||
// assegno valori home degli assi macchina attivi
|
||||
return m_pMchMgr->GetAllCalcAxesHomePos( m_AxesVal) ;
|
||||
}
|
||||
@@ -449,10 +449,10 @@ Simulator::Stop( void)
|
||||
// controllo validità stato
|
||||
if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr || m_pMachine == nullptr)
|
||||
return false ;
|
||||
// reset stato macchina
|
||||
OnResetMachine() ;
|
||||
// porto la macchina in home
|
||||
m_pMchMgr->ResetAllAxesPos() ;
|
||||
// reset stato macchina
|
||||
OnResetMachine() ;
|
||||
// rimuovo tavola variabili globali
|
||||
m_pMachine->LuaResetGlobVar( GLOB_VAR) ;
|
||||
// reset dello stato
|
||||
|
||||
Reference in New Issue
Block a user