EgtMachKernel :
- gestione rinvio da sotto con gestione normale e con rotazione alla MDC.
This commit is contained in:
+66
-62
@@ -888,9 +888,8 @@ Drilling::GenerateHoleCl( int nInd, const SelData& nCircId, const string& sPName
|
||||
}
|
||||
// verifiche per foro verso il basso
|
||||
m_bAggrBottom = false ;
|
||||
if ( ! VerifyHoleFromBottom( hole, nCircId)) {
|
||||
if ( ! VerifyHoleFromBottom( hole, nCircId))
|
||||
return false ;
|
||||
}
|
||||
// assegno il vettore estrazione al gruppo del percorso
|
||||
m_pGeomDB->SetInfo( nPathId, KEY_EXTR, hole.vtDir) ;
|
||||
// assegno il punto di inizio al gruppo del percorso
|
||||
@@ -1243,21 +1242,16 @@ Drilling::VerifyHoleFromBottom( const Hole& hole, SelData Id)
|
||||
bool bTabTilting = false ;
|
||||
if ( m_pMchMgr->GetCurrMachine()->GetCurrTableIsTilting( bTabTilting) && bTabTilting)
|
||||
return true ;
|
||||
// verifico se c'è rinvio da sotto
|
||||
int nHeadId = m_pMchMgr->GetHeadId( m_TParams.m_sHead) ;
|
||||
int nAgbType ;
|
||||
if ( ! m_pGeomDB->GetInfo( nHeadId, "AGB_TYPE", nAgbType) || nAgbType == 0) {
|
||||
// recupero dati di eventuale rinvio da sotto
|
||||
if ( ! GetAggrBottomData( m_TParams.m_sHead, m_AggrBottom) || m_AggrBottom.nType == 0) {
|
||||
string sOut = "Error in Drilling : Entity " + ToString( Id) + " skipped because missing aggregate from bottom" ;
|
||||
m_pMchMgr->SetLastError( 2106, sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
// recupero la massima distanza consentita dal rinvio
|
||||
double dAgbDmax = 0 ;
|
||||
m_pGeomDB->GetInfo( nHeadId, "AGB_DMAX", dAgbDmax) ;
|
||||
// calcolo la distanza minima del punto dal contorno del grezzo
|
||||
double dDist ;
|
||||
Vector3d vtDir ;
|
||||
if ( ! GetMinDistanceFromRawSide( m_nPhase, hole.ptIni, dDist, vtDir) || dDist > dAgbDmax) {
|
||||
if ( ! GetMinDistanceFromRawSide( m_nPhase, hole.ptIni, dDist, vtDir) || dDist > m_AggrBottom.dDMax) {
|
||||
string sOut = "Error in Drilling : Entity " + ToString( Id) + " skipped because too far from part sides" ;
|
||||
m_pMchMgr->SetLastError( 2107, sOut.c_str()) ;
|
||||
return false ;
|
||||
@@ -1290,13 +1284,6 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
|
||||
bool bEndSlow = ( dEndSlowLen > EPS_SMALL) ;
|
||||
// determino alcune caratteristiche dell'utensile
|
||||
double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ;
|
||||
// se con aggregato da sotto, ne recupero alcuni dati
|
||||
double dAgbEncH = 0 ;
|
||||
double dAgbEncV = 0 ;
|
||||
if ( m_bAggrBottom) {
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCH", dAgbEncH) ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCV", dAgbEncV) ;
|
||||
}
|
||||
// imposto dati comuni
|
||||
SetPathId( nPathId) ;
|
||||
SetToolDir( hole.vtDir) ;
|
||||
@@ -1307,18 +1294,27 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
|
||||
double dAppr = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
|
||||
Point3d ptP1 = hole.ptIni + hole.vtDir * ( dAppr + dTExtrLen) ;
|
||||
if ( m_bAggrBottom) {
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
vtAux.Rotate( Z_AX, - 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetAuxDir( m_vtAux) ;
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti rinvio normale
|
||||
else {
|
||||
SetAuxDir( m_vtAux) ;
|
||||
if ( AddRapidStart( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetFlag( 0) ;
|
||||
}
|
||||
if ( AddRapidMove( ptP1) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
@@ -1371,15 +1367,18 @@ Drilling::DoStandardDrilling( const Hole& hole, SelData Id, int nPathId)
|
||||
// 7 -> punto fuori (se uso aggregato da sotto)
|
||||
if ( m_bAggrBottom) {
|
||||
SetFlag( 0) ;
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_OUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// reset dati di movimento
|
||||
@@ -1411,13 +1410,6 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
|
||||
bool bEndSlow = ( dEndSlowLen > EPS_SMALL) ;
|
||||
// determino alcune caratteristiche dell'utensile
|
||||
double dTExtrLen = max( 0.0, m_TParams.m_dTLen - m_TParams.m_dLen) ;
|
||||
// se con aggregato da sotto, ne recupero alcuni dati
|
||||
double dAgbEncH = 0 ;
|
||||
double dAgbEncV = 0 ;
|
||||
if ( m_bAggrBottom) {
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCH", dAgbEncH) ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCV", dAgbEncV) ;
|
||||
}
|
||||
// imposto dati comuni
|
||||
SetPathId( nPathId) ;
|
||||
SetToolDir( hole.vtDir) ;
|
||||
@@ -1428,18 +1420,27 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
|
||||
double dAppr = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
|
||||
Point3d ptP1 = hole.ptIni + hole.vtDir * ( dAppr + dTExtrLen) ;
|
||||
if ( m_bAggrBottom) {
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
vtAux.Rotate( Z_AX, - 90) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetFlag( 0) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetFlag( 0) ;
|
||||
SetAuxDir( m_vtAux) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti rinvio normale
|
||||
else {
|
||||
SetAuxDir( m_vtAux) ;
|
||||
if ( AddRapidStart( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetFlag( 0) ;
|
||||
}
|
||||
if ( AddRapidMove( ptP1) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
@@ -1565,15 +1566,18 @@ Drilling::DoPeckDrilling( const Hole& hole, SelData Id, int nPathId)
|
||||
// 7 -> punto fuori (se uso aggregato da sotto)
|
||||
if ( m_bAggrBottom) {
|
||||
SetFlag( 0) ;
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
Point3d ptP0 = ptP1 + m_vtAux * ( m_dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAppr + dTExtrLen) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_OUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// reset dati di movimento
|
||||
|
||||
@@ -96,4 +96,5 @@ class Drilling : public Machining
|
||||
int m_nDrillings ; // numero di fori generati
|
||||
bool m_bAggrBottom ; // flag di utilizzo dell'aggregato da sotto
|
||||
double m_dDistBottom ; // distanza del foro dal bordo del grezzo
|
||||
AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto
|
||||
} ;
|
||||
|
||||
+74
-774
@@ -21,7 +21,6 @@
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EgkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkUserObjFactory.h"
|
||||
@@ -39,6 +38,28 @@ using namespace std ;
|
||||
// 2805 = "Error in GenMachining : link movements not calculable"
|
||||
// 2806 = "Error in GenMachining : post apply not calculable"
|
||||
|
||||
//------------------------------ Constants -----------------------------------
|
||||
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
|
||||
static const string EVAR_MACHID = ".MACHID" ; // IN (int) identificativo della lavorazione
|
||||
static const string EVAR_GEOM = ".GEOM" ; // IN (table) tabella delle entità da lavorare
|
||||
static const string EVAR_DEPTH = ".DEPTH" ; // IN (string) affondamento (espressione numerica)
|
||||
static const string EVAR_TINVERT = ".TOOLINVERT" ; // IN (bool) flag di inversione direzione utensile
|
||||
static const string EVAR_INVERT = ".INVERT" ; // IN (bool) flag di inversione direzione lavorazione
|
||||
static const string EVAR_STARTPOS = ".STARTPOS" ; // IN (num) quota di inizio lavorazione (sempre >= 0)
|
||||
static const string EVAR_OFFSR = ".OFFSR" ; // IN (num) offset radiale
|
||||
static const string EVAR_OFFSL = ".OFFSL" ; // IN (num) offset longitudinale
|
||||
static const string EVAR_TOOL = ".TOOL" ; // IN (string) nome dell'utensile
|
||||
static const string EVAR_FEED = ".FEED" ; // IN (num) feed dell'utensile
|
||||
static const string EVAR_STARTFEED = ".STARTFEED" ;// IN (num) feed di inizio dell'utensile
|
||||
static const string EVAR_ENDFEED = ".ENDFEED" ; // IN (num) feed di fine dell'utensile
|
||||
static const string EVAR_TIPFEED = ".TIPFEED" ; // IN (num) feed di punta dell'utensile
|
||||
static const string EVAR_SYSNOTES = ".SYSNOTES" ; // IN (string) note interne
|
||||
static const string EVAR_USERNOTES = ".USERNOTES" ;// IN (string) note dell'utente
|
||||
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
|
||||
static const string EVAR_MILLS = ".MILLS" ; // OUT (int) numero di percorsi di lavoro
|
||||
static const string ON_PREVIEW = "OnPreview_" ;
|
||||
static const string ON_APPLY = "OnApply_" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkGenMachining", GenMachining) ;
|
||||
|
||||
@@ -357,34 +378,12 @@ GenMachining::Preview( bool bRecalc)
|
||||
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 GenMachining : UpdateToolData failed") ;
|
||||
m_pMchMgr->SetLastError( 2801, "Error in GenMachining : 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 Preview
|
||||
int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ;
|
||||
// se non c'è, lo aggiungo
|
||||
@@ -398,12 +397,57 @@ GenMachining::Preview( bool bRecalc)
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nPvId) ;
|
||||
|
||||
// lavoro ogni singola catena
|
||||
int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ;
|
||||
while ( nPathId != GDB_ID_NULL) {
|
||||
if ( ! ProcessPath( nPathId, nPvId, GDB_ID_NULL))
|
||||
return false ;
|
||||
nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
|
||||
// recupero la macchina corrente
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
|
||||
// nome della funzione lua da Ini della macchina
|
||||
string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ;
|
||||
string sKey = GENMACHINING_SCRIPT_KEY + ToString( m_Params.m_nSubType) ;
|
||||
string sName = GetPrivateProfileStringUtf8( GENMACHINING_SEC.c_str(), sKey.c_str(), "", sMachIni.c_str()) ;
|
||||
string sPreview = ON_PREVIEW + sName ;
|
||||
|
||||
// verifico esistenza funzione
|
||||
if ( ! pMch->LuaExistsFunction( sPreview)) {
|
||||
string sErr = "Error in GenMachining : missing Script " + sPreview ;
|
||||
m_pMchMgr->SetLastError( 2802, sErr) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// imposto stato
|
||||
bool bOk = true ;
|
||||
int nErr = 99 ;
|
||||
// imposto valori parametri
|
||||
bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_MACHID, m_nOwnerId) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_GEOM, m_vId) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_DEPTH, m_Params.m_sDepth) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TINVERT, m_Params.m_bToolInvert) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_INVERT, m_Params.m_bInvert) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_STARTPOS, m_Params.m_dStartPos) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_OFFSR, GetOffsR()) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_OFFSL, GetOffsL()) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TOOL, m_TParams.m_sName) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_FEED, GetFeed()) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_STARTFEED, GetStartFeed()) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_ENDFEED, GetEndFeed()) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TIPFEED, GetTipFeed()) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_SYSNOTES, m_Params.m_sSysNotes) ;
|
||||
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_USERNOTES, m_Params.m_sUserNotes) ;
|
||||
// eseguo
|
||||
bOk = bOk && pMch->LuaCallFunction( sPreview, false) ;
|
||||
// recupero valori parametri obbligatori
|
||||
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ;
|
||||
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_MILLS, m_nMills) ;
|
||||
// reset
|
||||
bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ;
|
||||
// segnalo errori
|
||||
if ( ! bOk || nErr != 0) {
|
||||
m_nMills = 0 ;
|
||||
string sErr = "Error in GenMachining : Error in " + sPreview + " (" + ToString( nErr) + ")" ;
|
||||
m_pMchMgr->SetLastError( 2803, sErr) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
@@ -439,27 +483,6 @@ GenMachining::Apply( bool bRecalc)
|
||||
else
|
||||
m_pGeomDB->EmptyGroup( nClId) ;
|
||||
|
||||
// costanti
|
||||
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
|
||||
static const string EVAR_MACHID = ".MACHID" ; // IN (int) identificativo della lavorazione
|
||||
static const string EVAR_GEOM = ".GEOM" ; // IN (table) tabella delle entità da lavorare
|
||||
static const string EVAR_DEPTH = ".DEPTH" ; // IN (string) affondamento (espressione numerica)
|
||||
static const string EVAR_TINVERT = ".TOOLINVERT" ; // IN (bool) flag di inversione direzione utensile
|
||||
static const string EVAR_INVERT = ".INVERT" ; // IN (bool) flag di inversione direzione lavorazione
|
||||
static const string EVAR_STARTPOS = ".STARTPOS" ; // IN (num) quota di inizio lavorazione (sempre >= 0)
|
||||
static const string EVAR_OFFSR = ".OFFSR" ; // IN (num) offset radiale
|
||||
static const string EVAR_OFFSL = ".OFFSL" ; // IN (num) offset longitudinale
|
||||
static const string EVAR_TOOL = ".TOOL" ; // IN (string) nome dell'utensile
|
||||
static const string EVAR_FEED = ".FEED" ; // IN (num) feed dell'utensile
|
||||
static const string EVAR_STARTFEED = ".STARTFEED" ;// IN (num) feed di inizio dell'utensile
|
||||
static const string EVAR_ENDFEED = ".ENDFEED" ; // IN (num) feed di fine dell'utensile
|
||||
static const string EVAR_TIPFEED = ".TIPFEED" ; // IN (num) feed di punta dell'utensile
|
||||
static const string EVAR_SYSNOTES = ".SYSNOTES" ; // IN (string) note interne
|
||||
static const string EVAR_USERNOTES = ".USERNOTES" ;// IN (string) note dell'utente
|
||||
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
|
||||
static const string EVAR_MILLS = ".MILLS" ; // OUT (int) numero di percorsi di lavoro
|
||||
static const string ON_APPLY = "OnApply_" ;
|
||||
|
||||
// recupero la macchina corrente
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
if ( pMch == nullptr)
|
||||
@@ -750,261 +773,6 @@ GenMachining::VerifyGeometry( SelData Id, int& nSubs, int& nType)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ICurve*
|
||||
GenMachining::GetCurve( SelData Id)
|
||||
{
|
||||
// ammessi : curve o facce di polymesh
|
||||
const IGeoObj* pGObj = m_pGeomDB->GetGeoObj( Id.nId) ;
|
||||
if ( pGObj == nullptr)
|
||||
return nullptr ;
|
||||
// ne recupero il riferimento globale
|
||||
Frame3d frGlob ;
|
||||
if ( ! m_pGeomDB->GetGlobFrame( Id.nId, frGlob))
|
||||
return nullptr ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
PtrOwner<ICurve> pCurve ;
|
||||
// se direttamente curva
|
||||
if ( Id.nSub == SEL_SUB_ALL) {
|
||||
// recupero e duplico la curva
|
||||
const ICurve* pOriCurve = ::GetCurve( pGObj) ;
|
||||
if ( pOriCurve != nullptr)
|
||||
pCurve.Set( pOriCurve->Clone()) ;
|
||||
// se estrusione mancante, imposto default
|
||||
Vector3d vtExtr ;
|
||||
if ( ! pCurve->GetExtrusion( vtExtr) || vtExtr.IsSmall())
|
||||
pCurve->SetExtrusion( Z_AX) ;
|
||||
}
|
||||
// altrimenti sottocurva di composita
|
||||
else {
|
||||
// recupero la composita
|
||||
const ICurveComposite* pCompo = GetCurveComposite( pGObj) ;
|
||||
if ( pCompo != nullptr) {
|
||||
// duplico la curva semplice
|
||||
const ICurve* pOriCurve = ::GetCurve( pCompo->GetCurve( Id.nSub)) ;
|
||||
if ( pOriCurve != nullptr) {
|
||||
pCurve.Set( pOriCurve->Clone()) ;
|
||||
// recupero estrusione e spessore
|
||||
Vector3d vtExtr ;
|
||||
if ( ! pCompo->GetExtrusion( vtExtr) || vtExtr.IsSmall())
|
||||
vtExtr = Z_AX ;
|
||||
pCurve->SetExtrusion( vtExtr) ;
|
||||
double dThick ;
|
||||
if ( pCompo->GetThickness( dThick))
|
||||
pCurve->SetThickness( dThick) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( IsNull( pCurve))
|
||||
return nullptr ;
|
||||
// la porto in globale
|
||||
pCurve->ToGlob( frGlob) ;
|
||||
// la restituisco
|
||||
return Release( pCurve) ;
|
||||
}
|
||||
// se altrimenti superficie
|
||||
else if ( ( pGObj->GetType() & GEO_SURF) != 0) {
|
||||
// recupero la trimesh
|
||||
const ISurfTriMesh* pSurf = ::GetSurfTriMesh( pGObj) ;
|
||||
if ( pSurf == nullptr)
|
||||
return nullptr ;
|
||||
// recupero l'indice della faccia
|
||||
int nFacet = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ;
|
||||
// recupero i contorni della faccia
|
||||
POLYLINEVECTOR vPL ;
|
||||
pSurf->GetFacetLoops( nFacet, vPL) ;
|
||||
if ( vPL.empty())
|
||||
return nullptr ;
|
||||
// recupero la normale esterna della faccia
|
||||
Vector3d vtN ;
|
||||
if ( ! pSurf->GetFacetNormal( nFacet, vtN))
|
||||
return nullptr ;
|
||||
// creo la curva a partire da quello esterno
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
pCrvCompo->FromPolyLine( vPL[0]) ;
|
||||
if ( ! pCrvCompo->IsValid())
|
||||
return nullptr ;
|
||||
// assegno l'estrusione dalla normale alla faccia
|
||||
pCrvCompo->SetExtrusion( vtN) ;
|
||||
// la porto in globale
|
||||
pCrvCompo->ToGlob( frGlob) ;
|
||||
// sistemazioni varie
|
||||
AdjustCurveFromSurf( pCrvCompo) ;
|
||||
// la restituisco
|
||||
return Release( pCrvCompo) ;
|
||||
}
|
||||
// altrimenti errore
|
||||
else
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::AdjustCurveFromSurf( ICurveComposite* pCrvCompo)
|
||||
{
|
||||
// con utensile fresa fa il contorno
|
||||
if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
|
||||
// cerco l'estremo più alto e lo imposto come inizio
|
||||
double dU = 0 ;
|
||||
double dUmax = 0 ;
|
||||
double dZmax = - INFINITO ;
|
||||
Point3d ptP ;
|
||||
while ( pCrvCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptP)) {
|
||||
if ( ptP.z > dZmax + EPS_SMALL) {
|
||||
dZmax = ptP.z ;
|
||||
dUmax = dU ;
|
||||
}
|
||||
dU += 1 ;
|
||||
}
|
||||
if ( dU != 0)
|
||||
pCrvCompo->ChangeStartPoint( dUmax) ;
|
||||
}
|
||||
// con utensile lama tiene solo la parte sotto
|
||||
else {
|
||||
// ingombro
|
||||
BBox3d b3Box ;
|
||||
pCrvCompo->GetLocalBBox( b3Box) ;
|
||||
double dZmin = b3Box.GetMin().z ;
|
||||
double dZtol = min( ( b3Box.GetMax().z - b3Box.GetMin().z) / 2., 20.) ;
|
||||
// elimino le linee troppo sopra il minimo dall'inizio e poi dalla fine
|
||||
const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
Point3d ptMid ; pCrv->GetMidPoint( ptMid) ;
|
||||
Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
|
||||
if ( ptMid.z > dZmin + dZtol) {
|
||||
ICurve* pErase = pCrvCompo->RemoveFirstOrLastCurve( false) ;
|
||||
delete( pErase) ;
|
||||
pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
pCrv = pCrvCompo->GetLastCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
Point3d ptMid ; pCrv->GetMidPoint( ptMid) ;
|
||||
Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
|
||||
if ( ptMid.z > dZmin + dZtol) {
|
||||
ICurve* pErase = pCrvCompo->RemoveFirstOrLastCurve( true) ;
|
||||
delete( pErase) ;
|
||||
pCrv = pCrvCompo->GetLastCurve() ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
// verifico il versore estrusione
|
||||
Vector3d vtN ;
|
||||
pCrvCompo->GetExtrusion( vtN) ;
|
||||
if ( vtN.z < - sin( 2 * DEGTORAD)) {
|
||||
pCrvCompo->Invert() ;
|
||||
pCrvCompo->Translate( vtN * m_TParams.m_dThick) ;
|
||||
pCrvCompo->SetExtrusion( - vtN) ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::Chain( int nGrpDestId)
|
||||
{
|
||||
// vettore puntatori alle curve
|
||||
POCRVVECTOR vpCrvs ;
|
||||
vpCrvs.reserve( m_vId.size()) ;
|
||||
// recupero tutte le curve e le porto in globale
|
||||
for ( const auto& Id : m_vId) {
|
||||
// prendo curva
|
||||
vpCrvs.emplace_back( GetCurve( Id)) ;
|
||||
// ne verifico la validità
|
||||
if ( IsNull( vpCrvs.back())) {
|
||||
string sOut = "Entity " + ToString( Id) + " skipped by GenMachining" ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str()) ;
|
||||
vpCrvs.back().Reset() ;
|
||||
}
|
||||
}
|
||||
// preparo i dati per il concatenamento
|
||||
bool bFirst = true ;
|
||||
Point3d ptNear = ORIG ;
|
||||
double dToler = 10 * EPS_SMALL ;
|
||||
ChainCurves chainC ;
|
||||
chainC.Init( true, dToler, int( vpCrvs.size())) ;
|
||||
for ( size_t i = 0 ; i < vpCrvs.size() ; ++ i) {
|
||||
// recupero la curva e il suo riferimento
|
||||
ICurve* pCrv = vpCrvs[i] ;
|
||||
if ( pCrv == nullptr)
|
||||
continue ;
|
||||
// recupero i dati della curva necessari al concatenamento e li assegno
|
||||
Point3d ptStart, ptEnd ;
|
||||
Vector3d vtStart, vtEnd ;
|
||||
if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) ||
|
||||
! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd))
|
||||
return false ;
|
||||
if ( ! chainC.AddCurve( int( i + 1), ptStart, vtStart, ptEnd, vtEnd))
|
||||
return false ;
|
||||
// se prima curva, assegno inizio della ricerca
|
||||
if ( bFirst) {
|
||||
ptNear = ptStart + 10 * EPS_SMALL * vtStart ;
|
||||
bFirst = false ;
|
||||
}
|
||||
}
|
||||
// recupero i percorsi concatenati
|
||||
int nCount = 0 ;
|
||||
INTVECTOR vnId2 ;
|
||||
while ( chainC.GetChainFromNear( ptNear, false, vnId2)) {
|
||||
// creo una curva composita
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo))
|
||||
return false ;
|
||||
// estrusione e spessore
|
||||
Vector3d vtExtr = Z_AX ;
|
||||
double dThick = 0 ;
|
||||
// vettore Id originali
|
||||
SELVECTOR vId2 ;
|
||||
vId2.reserve( vnId2.size()) ;
|
||||
// recupero le curve semplici e le inserisco nella curva composita
|
||||
for ( size_t i = 0 ; i < vnId2.size() ; ++ i) {
|
||||
int nId = abs( vnId2[i]) - 1 ;
|
||||
bool bInvert = ( vnId2[i] < 0) ;
|
||||
vId2.emplace_back( m_vId[nId]) ;
|
||||
// recupero la curva
|
||||
ICurve* pCrv = vpCrvs[nId] ;
|
||||
// se necessario, la inverto
|
||||
if ( bInvert)
|
||||
pCrv->Invert() ;
|
||||
// recupero eventuali estrusione e spessore
|
||||
Vector3d vtTemp ;
|
||||
if ( pCrv->GetExtrusion( vtTemp)) {
|
||||
vtExtr = vtTemp ;
|
||||
double dTemp ;
|
||||
if ( pCrv->GetThickness( dTemp) && fabs( dTemp) > fabs( dThick))
|
||||
dThick = dTemp ;
|
||||
}
|
||||
// la aggiungo alla curva composta
|
||||
if ( ! pCrvCompo->AddCurve( ::Release( vpCrvs[nId]), true, dToler))
|
||||
return false ;
|
||||
}
|
||||
// se non sono state inserite curve, vado oltre
|
||||
if ( pCrvCompo->GetCurveCount() == 0)
|
||||
continue ;
|
||||
// imposto estrusione e spessore
|
||||
pCrvCompo->SetExtrusion( vtExtr) ;
|
||||
pCrvCompo->SetThickness( dThick) ;
|
||||
// aggiorno il nuovo punto vicino
|
||||
pCrvCompo->GetEndPoint( ptNear) ;
|
||||
// creo nuovo gruppo
|
||||
int nPathId = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrpDestId, Frame3d()) ;
|
||||
if ( nPathId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nPathId, MCH_PATH + ToString( ++ nCount)) ;
|
||||
m_pGeomDB->SetInfo( nPathId, KEY_IDS, ToString( vId2)) ;
|
||||
// inserisco la curva composita nel gruppo destinazione
|
||||
int nNewId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, ::Release( pCrvCompo)) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP) const
|
||||
@@ -1012,471 +780,3 @@ GenMachining::AdjustEndPointForAxesCalc( const CamData* pCamData, Point3d& ptP)
|
||||
// non devo fare alcunché
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::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)) ;
|
||||
|
||||
// eventuale inversione percorso
|
||||
if ( m_Params.m_bInvert)
|
||||
pCompo->Invert() ;
|
||||
|
||||
// recupero estrusione e spessore
|
||||
Vector3d vtExtr ;
|
||||
pCompo->GetExtrusion( vtExtr) ;
|
||||
double dThick ;
|
||||
pCompo->GetThickness( dThick) ;
|
||||
|
||||
// unisco le parti allineate (tranne inizio-fine se chiusa)
|
||||
if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false))
|
||||
return false ;
|
||||
|
||||
// recupero il punto di inizio (per poi salvarlo nelle info di CL path)
|
||||
Point3d ptStart ;
|
||||
pCompo->GetStartPoint( ptStart) ;
|
||||
|
||||
// recupero il box del grezzo in globale
|
||||
BBox3d b3Raw ;
|
||||
if ( ! GetRawGlobBox( m_nPhase, nPathId, 0.5 * m_TParams.m_dDiam, b3Raw) || b3Raw.IsEmpty()) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in GenMachining : Empty RawBox") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero distanza da fondo dei grezzi interessati dal percorso
|
||||
double dRbDist = 0 ;
|
||||
if ( AreSameVectorApprox( vtExtr, Z_AX)) {
|
||||
if ( ! GetDistanceFromRawBottom( m_nPhase, nCopyId, m_TParams.m_dDiam, dRbDist))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// valuto l'espressione dell'affondamento
|
||||
ExeLuaSetGlobNumVar( "TH", abs( dThick)) ;
|
||||
ExeLuaSetGlobNumVar( "RB", dRbDist) ;
|
||||
double dDepth ;
|
||||
string sMyDepth = m_Params.m_sDepth ;
|
||||
if ( ! ExeLuaEvalNumExpr( ToUpper( sMyDepth), &dDepth)) {
|
||||
LOG_INFO( GetEMkLogger(), "Error in GenMachining : Depth not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// se spessore positivo, lo sottraggo dal risultato
|
||||
if ( dThick > 0)
|
||||
dDepth -= dThick ;
|
||||
// sottraggo eventuale offset longitudinale
|
||||
dDepth -= GetOffsL() ;
|
||||
|
||||
// recupero nome del path
|
||||
string sPathName ;
|
||||
m_pGeomDB->GetName( nPathId, sPathName) ;
|
||||
|
||||
// eventuale approssimazione con segmenti di retta
|
||||
int nSplitArcs = m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() ;
|
||||
bool bSplitArcs = ( nSplitArcs == SPLAR_ALWAYS ||
|
||||
( nSplitArcs == SPLAR_NO_XY_PLANE && ! vtExtr.IsZplus()) ||
|
||||
( nSplitArcs == SPLAR_GEN_PLANE && vtExtr.IsGeneric())) ;
|
||||
if ( bSplitArcs) {
|
||||
const double ANG_TOL_MAX_DEG = 90 ;
|
||||
PolyLine PL ;
|
||||
if ( pCompo->ApproxWithLines( 50 * EPS_SMALL, ANG_TOL_MAX_DEG, ICurve::APL_SPECIAL, PL)) {
|
||||
// sostituisco le linee alle curve originali
|
||||
pCompo->Clear() ;
|
||||
pCompo->FromPolyLine( PL) ;
|
||||
// riassegno estrusione e spessore
|
||||
pCompo->SetExtrusion( vtExtr) ;
|
||||
pCompo->SetThickness( dThick) ;
|
||||
}
|
||||
}
|
||||
|
||||
// verifiche sull'ampiezza dell'angolo al centro degli eventuali archi
|
||||
VerifyArcs( pCompo) ;
|
||||
|
||||
// calcolo il versore fresa
|
||||
Vector3d vtTool = Z_AX ;
|
||||
if ( ! vtExtr.IsSmall())
|
||||
vtTool = vtExtr ;
|
||||
|
||||
// calcolo l'elevazione massima
|
||||
double dElev ;
|
||||
if ( CalcPathElevation( pCompo, vtTool, dDepth, 0.5 * m_TParams.m_dDiam, dElev)) {
|
||||
if ( dElev < EPS_SMALL && AreSameVectorApprox( vtExtr, Z_AX)) {
|
||||
BBox3d b3Crv ;
|
||||
pCompo->GetLocalBBox( b3Crv) ;
|
||||
dElev = max( 0., b3Raw.GetMax().z - b3Crv.GetMin().z + min( 0., dThick) + dDepth) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
|
||||
// se richiesta anteprima
|
||||
if ( nPvId != GDB_ID_NULL) {
|
||||
// creo gruppo per geometria di lavorazione del percorso
|
||||
int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nPvId, Frame3d()) ;
|
||||
if ( nPxId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nPxId, sPathName) ;
|
||||
m_pGeomDB->SetMaterial( nPxId, GREEN) ;
|
||||
// creo l'anteprima del percorso
|
||||
if ( ! GenerateMillingPv( nPxId, pCompo))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se richiesta lavorazione
|
||||
if ( nClId != GDB_ID_NULL) {
|
||||
// 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) ;
|
||||
|
||||
// assegno il vettore estrazione al gruppo del percorso
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_EXTR, vtTool) ;
|
||||
// assegno il punto di inizio al gruppo del percorso
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_START, ptStart) ;
|
||||
// assegno l'elevazione massima
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_ELEV, dElev) ;
|
||||
|
||||
// Imposto dati comuni
|
||||
SetPathId( nPxId) ;
|
||||
SetToolDir( vtTool) ;
|
||||
|
||||
// Calcolo la lavorazione
|
||||
if ( ! AddStandardMilling( pCompo, vtTool, vtExtr, dDepth, dElev, bSplitArcs))
|
||||
return false ;
|
||||
|
||||
// assegno al gruppo l'ingombro del percorso di lavoro
|
||||
BBox3d b3Grp ;
|
||||
m_pGeomDB->GetGlobalBBox( nPxId, b3Grp) ;
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_PMIN, b3Grp.GetMin()) ;
|
||||
m_pGeomDB->SetInfo( nPxId, KEY_PMAX, b3Grp.GetMax()) ;
|
||||
}
|
||||
|
||||
// incremento numero di fresate
|
||||
++ m_nMills ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad,
|
||||
double& dElev)
|
||||
{
|
||||
dElev = 0 ;
|
||||
int nMaxInd = pCompo->GetCurveCount() - 1 ;
|
||||
for ( int i = 0 ; i <= nMaxInd ; ++ i) {
|
||||
// curva corrente
|
||||
const ICurve* pCrvC = pCompo->GetCurve( i) ;
|
||||
// calcolo elevazione
|
||||
double dCurrElev ;
|
||||
Point3d ptStart, ptMid, ptEnd ;
|
||||
pCrvC->GetStartPoint( ptStart) ;
|
||||
pCrvC->GetMidPoint( ptMid) ;
|
||||
pCrvC->GetEndPoint( ptEnd) ;
|
||||
Vector3d vtStartPerp, vtMidPerp, vtEndPerp, vtTg ;
|
||||
pCrvC->GetStartDir( vtTg) ;
|
||||
vtStartPerp = vtTg ^ vtTool ;
|
||||
vtStartPerp.Normalize() ;
|
||||
vtStartPerp *= dRad ;
|
||||
pCrvC->GetMidDir( vtTg) ;
|
||||
vtMidPerp = vtTg ^ vtTool ;
|
||||
vtMidPerp.Normalize() ;
|
||||
vtMidPerp *= dRad ;
|
||||
pCrvC->GetEndDir( vtTg) ;
|
||||
vtEndPerp = vtTg ^ vtTool ;
|
||||
vtEndPerp.Normalize() ;
|
||||
vtEndPerp *= dRad ;
|
||||
Vector3d vtDepth = vtTool * dDepth ;
|
||||
// linea centro utensile
|
||||
if ( GetElevation( m_nPhase, ptStart - vtDepth, ptMid - vtDepth, ptEnd - vtDepth, vtTool, dCurrElev)) {
|
||||
if ( dCurrElev > dElev)
|
||||
dElev = dCurrElev ;
|
||||
}
|
||||
else {
|
||||
LOG_INFO( GetEMkLogger(), "Error in GenMachining : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
// da una parte
|
||||
if ( GetElevation( m_nPhase, ptStart + vtStartPerp - vtDepth, ptMid + vtMidPerp - vtDepth,
|
||||
ptEnd + vtEndPerp - vtDepth, vtTool, dCurrElev)) {
|
||||
if ( dCurrElev > dElev)
|
||||
dElev = dCurrElev ;
|
||||
}
|
||||
else {
|
||||
LOG_INFO( GetEMkLogger(), "Error in GenMachining : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
// dall'altra parte
|
||||
if ( GetElevation( m_nPhase, ptStart - vtStartPerp - vtDepth, ptMid - vtMidPerp - vtDepth,
|
||||
ptEnd - vtEndPerp - vtDepth, vtTool, dCurrElev)) {
|
||||
if ( dCurrElev > dElev)
|
||||
dElev = dCurrElev ;
|
||||
}
|
||||
else {
|
||||
LOG_INFO( GetEMkLogger(), "Error in GenMachining : Entity GetElevation") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::GenerateMillingPv( int nPathId, const ICurveComposite* pCompo)
|
||||
{
|
||||
// creo copia della curva composita
|
||||
PtrOwner< ICurve> pCrv( pCompo->Clone()) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
// calcolo la regione
|
||||
PtrOwner<ISurfFlatRegion> pSfr ;
|
||||
pSfr.Set( GetSurfFlatRegionFromFatCurve( Release( pCrv), 0.5 * m_TParams.m_dDiam, false, false)) ;
|
||||
if ( IsNull( pSfr))
|
||||
return false ;
|
||||
// ne recupero il contorno
|
||||
PtrOwner< ICurve> pCrv2 ;
|
||||
pCrv2.Set( pSfr->GetLoop( 0, 0)) ;
|
||||
if ( IsNull( pCrv2))
|
||||
return false ;
|
||||
// inserisco la curva nel DB
|
||||
int nC2Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv2)) ;
|
||||
if ( nC2Id == GDB_ID_NULL)
|
||||
return false ;
|
||||
// assegno nome e colore
|
||||
m_pGeomDB->SetName( nC2Id, MCH_PV_CUT) ;
|
||||
m_pGeomDB->SetMaterial( nC2Id, LIME) ;
|
||||
// eventuali altri contorni ( interni di contornatura chiusa)
|
||||
const int MAX_INT_LOOP = 1000 ;
|
||||
for ( int i = 1 ; i <= MAX_INT_LOOP ; ++i) {
|
||||
PtrOwner< ICurve> pCrv3 ;
|
||||
pCrv3.Set( pSfr->GetLoop( 0, i)) ;
|
||||
if ( IsNull( pCrv3))
|
||||
break ;
|
||||
// inserisco la curva nel DB
|
||||
int nC3Id = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pCrv3)) ;
|
||||
if ( nC3Id == GDB_ID_NULL)
|
||||
return false ;
|
||||
// assegno nome e colore
|
||||
m_pGeomDB->SetName( nC3Id, MCH_PV_CUT) ;
|
||||
m_pGeomDB->SetMaterial( nC3Id, LIME) ;
|
||||
}
|
||||
// inserisco la regione nel DB
|
||||
int nRId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, Release( pSfr)) ;
|
||||
if ( nRId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nRId, MCH_PV_RCUT) ;
|
||||
m_pGeomDB->SetMaterial( nRId, INVISIBLE) ;
|
||||
// la copio anche come regione ridotta
|
||||
int nRrId = m_pGeomDB->Copy( nRId, GDB_ID_NULL, nPathId) ;
|
||||
if ( nRrId == GDB_ID_NULL)
|
||||
return false ;
|
||||
m_pGeomDB->SetName( nRrId, MCH_PV_RRCUT) ;
|
||||
m_pGeomDB->SetMaterial( nRrId, INVISIBLE) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||
double dDepth, double dElev, bool bSplitArcs)
|
||||
{
|
||||
// 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() ;
|
||||
int 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( pCrvC->Clone()) ;
|
||||
if ( IsNull( pCurve))
|
||||
return false ;
|
||||
// aggiungo affondamento
|
||||
pCurve->Translate( - vtTool * dDepth) ;
|
||||
// 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 = ptStart ;
|
||||
// aggiungo approccio per frese normali con spazio sopra attacco
|
||||
if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
|
||||
// determino elevazione su inizio attacco
|
||||
double dStElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptStart - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dStElev))
|
||||
dStElev = dElev ;
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dStElev, dAppr))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti, approccio per lame o diretto
|
||||
else {
|
||||
// affondo al punto iniziale
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidStart( ptP1) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
// ...
|
||||
}
|
||||
// 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()) ;
|
||||
// ...
|
||||
// aggiungo retrazione per frese normali
|
||||
if ( ( m_TParams.m_nType & TF_SAWBLADE) == 0) {
|
||||
double dEndElev ;
|
||||
if ( ! GetElevation( m_nPhase, ptEnd - 10 * EPS_SMALL * vtTool, vtTool, GetRadiusForStartEndElevation(), dEndElev))
|
||||
dEndElev = dElev ;
|
||||
dEndElev -= ( ptP1 - ptEnd) * vtExtr ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dEndElev, dAppr))
|
||||
return false ;
|
||||
}
|
||||
// per lame non è necessario
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
|
||||
{
|
||||
// se sopra attacco c'è spazio per sicurezza o approccio
|
||||
if ( dElev + max( dSafeZ, dAppr) > 10 * EPS_SMALL) {
|
||||
// se distanza di sicurezza minore di distanza di inizio
|
||||
if ( dSafeZ < dAppr + 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 - dAppr) ;
|
||||
if ( AddRapidStart( ptP1a) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// 1b -> punto appena sopra inizio
|
||||
if ( ( dElev + dAppr) > EPS_SMALL) {
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP1b) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// affondo al punto iniziale
|
||||
SetFlag( 0) ;
|
||||
SetFeed( GetTipFeed()) ;
|
||||
if ( AddLinearMove( ptP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
// affondo diretto al punto iniziale
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidStart( ptP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GenMachining::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dElev, double dAppr)
|
||||
{
|
||||
// se sopra uscita c'è spazio per sicurezza o approccio
|
||||
if ( dElev + max( dSafeZ, dAppr) > 10 * EPS_SMALL) {
|
||||
if ( dSafeZ < dAppr + 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
|
||||
Point3d ptP4a = ptP + vtTool * ( dElev + dAppr) ;
|
||||
if ( dElev + dAppr > EPS_SMALL) {
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( AddLinearMove( ptP4a) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// 4b -> movimento di risalita sopra il punto finale
|
||||
Point3d ptP4b = ptP4a + vtTool * ( dSafeZ - dAppr) ;
|
||||
if ( AddRapidMove( ptP4b) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
GenMachining::GetRadiusForStartEndElevation( void)
|
||||
{
|
||||
const double DELTA_ELEV_RAD = 20.0 ;
|
||||
return ( 0.5 * m_TParams.m_dTDiam + DELTA_ELEV_RAD) ;
|
||||
}
|
||||
|
||||
@@ -63,17 +63,6 @@ class GenMachining : public Machining
|
||||
private :
|
||||
bool UpdateToolData( void) ;
|
||||
bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ;
|
||||
ICurve* GetCurve( SelData Id) ;
|
||||
bool AdjustCurveFromSurf( ICurveComposite* pCrvCompo) ;
|
||||
bool Chain( int nGrpDestId) ;
|
||||
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
|
||||
bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) ;
|
||||
bool GenerateMillingPv( int nPathId, const ICurveComposite* pCompo) ;
|
||||
bool AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||
double dDepth, double dElev, bool bSplitArcs) ;
|
||||
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) ;
|
||||
double GetRadiusForStartEndElevation( void) ;
|
||||
|
||||
private :
|
||||
double GetSpeed() const
|
||||
|
||||
@@ -83,3 +83,29 @@ const std::string MCH_TAREA ="A" ;
|
||||
//----------------------------------------------------------------------------
|
||||
// Identificativo iniziale gruppo uscita di teste
|
||||
const std::string MCH_EXIT = "T" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Info in rinvio rotante per forzare risalita alla rotazione
|
||||
const std::string MCH_ZMAXONROT = "ZMAXONROT" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Dati aggregato rotante da sotto
|
||||
struct AggrBottom {
|
||||
int nType ;
|
||||
double dDMax ;
|
||||
double dEncH ;
|
||||
double dEncV ;
|
||||
AggrBottom( void) : nType( 0), dDMax( 0), dEncH( 0), dEncV( 0) {}
|
||||
void Clear( void)
|
||||
{ nType = 0 ; dDMax= 0 ; dEncH = 0 ; dEncV = 0 ; }
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Info in rinvio rotante da sotto con dichiarazione dello stesso
|
||||
const std::string MCH_AGB_TYPE = "AGB_TYPE" ;
|
||||
// Info in rinvio rotante da sotto con massima distanza di lavorazione dal bordo
|
||||
const std::string MCH_AGB_DMAX = "AGB_DMAX" ;
|
||||
// Info in rinvio rotante da sotto con ingombro orizzontale
|
||||
const std::string MCH_AGB_ENCH = "AGB_ENCH" ;
|
||||
// Info in rinvio rotante da sotto con ingombro verticale
|
||||
const std::string MCH_AGB_ENCV = "AGB_ENCV" ;
|
||||
|
||||
+100
-84
@@ -41,15 +41,17 @@ using namespace std ;
|
||||
// 2306 = "Error in Milling : Entity GetElevation"
|
||||
// 2307 = "Error in Milling : missing aggregate from bottom"
|
||||
// 2308 = "Error in Milling : path too far from part sides"
|
||||
// 2309 = "Error in Milling : LeadIn not computable"
|
||||
// 2310 = "Error in Milling : LeadOut not computable"
|
||||
// 2311 = "Error in Milling : Linear Approx not computable"
|
||||
// 2312 = "Error in Milling : LeadIn must be out of rawpart"
|
||||
// 2313 = "Error in Milling : Chaining failed"
|
||||
// 2314 = "Error in Milling : Tool MaxMaterial too small (xx)"
|
||||
// 2315 = "Error in Milling : axes values not calculable"
|
||||
// 2316 = "Error in Milling : link movements not calculable"
|
||||
// 2317 = "Error in Milling : post apply not calculable"
|
||||
// 2309 = "Error in Milling : Approach not computable"
|
||||
// 2310 = "Error in Milling : LeadIn not computable"
|
||||
// 2311 = "Error in Milling : LeadOut not computable"
|
||||
// 2312 = "Error in Milling : Retract not computable"
|
||||
// 2313 = "Error in Milling : Linear Approx not computable"
|
||||
// 2314 = "Error in Milling : LeadIn must be out of rawpart"
|
||||
// 2315 = "Error in Milling : Chaining failed"
|
||||
// 2316 = "Error in Milling : Tool MaxMaterial too small (xx)"
|
||||
// 2317 = "Error in Milling : axes values not calculable"
|
||||
// 2318 = "Error in Milling : link movements not calculable"
|
||||
// 2319 = "Error in Milling : post apply not calculable"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkMilling", Milling) ;
|
||||
@@ -456,7 +458,7 @@ Milling::Preview( bool bRecalc)
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId)) {
|
||||
m_pMchMgr->SetLastError( 2313, "Error in Milling : Chaining failed") ;
|
||||
m_pMchMgr->SetLastError( 2315, "Error in Milling : Chaining failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -521,7 +523,7 @@ Milling::Apply( bool bRecalc)
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId)) {
|
||||
m_pMchMgr->SetLastError( 2313, "Error in Milling : Chaining failed") ;
|
||||
m_pMchMgr->SetLastError( 2315, "Error in Milling : Chaining failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -567,19 +569,19 @@ Milling::Apply( bool bRecalc)
|
||||
if ( ! m_Params.m_sInitAngs.empty())
|
||||
sHint = m_Params.m_sInitAngs ;
|
||||
if ( ! CalculateAxesValues( sHint)) {
|
||||
m_pMchMgr->SetLastError( 2315, "Error in Milling : axes values not calculable") ;
|
||||
m_pMchMgr->SetLastError( 2317, "Error in Milling : axes values not calculable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione
|
||||
if ( ! AdjustStartEndMovements()) {
|
||||
m_pMchMgr->SetLastError( 2316, "Error in Milling : link movements not calculable") ;
|
||||
m_pMchMgr->SetLastError( 2318, "Error in Milling : link movements not calculable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// esecuzione eventuali personalizzazioni
|
||||
if ( ! PostApply()) {
|
||||
m_pMchMgr->SetLastError( 2317, "Error in Milling : post apply not calculable") ;
|
||||
m_pMchMgr->SetLastError( 2319, "Error in Milling : post apply not calculable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1377,7 +1379,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
( nSplitArcs == SPLAR_NO_XY_PLANE && ! vtExtr.IsZplus()) ||
|
||||
( nSplitArcs == SPLAR_GEN_PLANE && vtExtr.IsGeneric())) ;
|
||||
if ( bSplitArcs && ! ApproxWithLines( pCompo)) {
|
||||
m_pMchMgr->SetLastError( 2311, "Error in Milling : Linear Approx not computable") ;
|
||||
m_pMchMgr->SetLastError( 2313, "Error in Milling : Linear Approx not computable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1418,7 +1420,7 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
if ( m_TParams.m_dMaxMat < dElev && m_TParams.m_dMaxMat < MIN_MAXMAT) {
|
||||
string sInfo = "Error in Milling : Tool MaxMaterial too small (" +
|
||||
ToString( m_TParams.m_dMaxMat, 2) + ")" ;
|
||||
m_pMchMgr->SetLastError( 2314, sInfo) ;
|
||||
m_pMchMgr->SetLastError( 2316, sInfo) ;
|
||||
return false ;
|
||||
}
|
||||
// se lo step supera la capacità dell'utensile
|
||||
@@ -1448,10 +1450,9 @@ Milling::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
}
|
||||
|
||||
// verifiche per fresatura dal basso
|
||||
m_bAggrBottom = false ;
|
||||
if ( ! VerifyPathFromBottom( pCompo, vtTool)) {
|
||||
m_bAggrBottom = false ;
|
||||
if ( ! VerifyPathFromBottom( pCompo, vtTool))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// se richiesta anteprima
|
||||
if ( nPvId != GDB_ID_NULL) {
|
||||
@@ -1595,17 +1596,11 @@ Milling::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vt
|
||||
bool bTabTilting = false ;
|
||||
if ( m_pMchMgr->GetCurrMachine()->GetCurrTableIsTilting( bTabTilting) && bTabTilting)
|
||||
return true ;
|
||||
// verifico se c'è rinvio da sotto
|
||||
int nHeadId = m_pMchMgr->GetHeadId( m_TParams.m_sHead) ;
|
||||
int nAgbType ;
|
||||
if ( ! m_pGeomDB->GetInfo( nHeadId, "AGB_TYPE", nAgbType) || nAgbType == 0) {
|
||||
string sOut = "Error in Milling : missing aggregate from bottom" ;
|
||||
m_pMchMgr->SetLastError( 2307, sOut.c_str()) ;
|
||||
// recupero dati di eventuale rinvio da sotto
|
||||
if ( ! GetAggrBottomData( m_TParams.m_sHead, m_AggrBottom) || m_AggrBottom.nType == 0) {
|
||||
m_pMchMgr->SetLastError( 2307, "Error in Milling : missing aggregate from bottom") ;
|
||||
return false ;
|
||||
}
|
||||
// recupero la massima distanza consentita dal rinvio
|
||||
double dAgbDmax = 0 ;
|
||||
m_pGeomDB->GetInfo( nHeadId, "AGB_DMAX", dAgbDmax) ;
|
||||
// calcolo la massima distanza minima del percorso dal contorno del grezzo
|
||||
double dDist = 0 ;
|
||||
Vector3d vtDir ;
|
||||
@@ -1639,9 +1634,8 @@ Milling::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vt
|
||||
}
|
||||
}
|
||||
// se supera il limite, errore
|
||||
if ( dDist > dAgbDmax) {
|
||||
string sOut = "Error in Milling : path too far from part sides" ;
|
||||
m_pMchMgr->SetLastError( 2308, sOut.c_str()) ;
|
||||
if ( dDist > m_AggrBottom.dDMax) {
|
||||
m_pMchMgr->SetLastError( 2308, "Error in Milling : path too far from part sides") ;
|
||||
return false ;
|
||||
}
|
||||
// assegno direzione di accesso e segnalo utilizzo aggregato da sotto
|
||||
@@ -1757,14 +1751,16 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
dStElev = - LIO_ELEV_TOL ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti, approccio per lame o diretto
|
||||
else {
|
||||
// verifico di entrare in aria
|
||||
if ( ! bOutStart) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
return false ;
|
||||
}
|
||||
// affondo al punto iniziale
|
||||
@@ -1775,7 +1771,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, pCompo, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1813,7 +1809,7 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, pCompo, bSplitArcs, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione per frese normali
|
||||
@@ -1823,8 +1819,10 @@ Milling::AddStandardMilling( const ICurveComposite* pCompo, const Vector3d& vtTo
|
||||
// determino se la fine dell'uscita è sopra il grezzo
|
||||
bool bAboveEnd = GetPointAboveRaw( ptP1) ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd))
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd)) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// per lame non è necessario
|
||||
}
|
||||
@@ -1894,8 +1892,10 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// correggo elevazione iniziale con punto inizio attacco
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti, affondo al punto iniziale
|
||||
else {
|
||||
@@ -1905,7 +1905,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
if ( j == 1) {
|
||||
// verifico di entrare in aria
|
||||
if ( ! bOutStart) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
return false ;
|
||||
}
|
||||
// eseguo affondo
|
||||
@@ -1927,7 +1927,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bInvert, pCompo, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1969,7 +1969,7 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, bInvert, pCompo, bSplitArcs, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// se ultimo step aggiungo retrazione per frese normali
|
||||
@@ -1979,8 +1979,10 @@ Milling::AddZigZagMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// determino se la fine dell'uscita è sopra il grezzo
|
||||
bool bAboveEnd = GetPointAboveRaw( ptP1) ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd))
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd)) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// per lame non è necessario
|
||||
}
|
||||
@@ -2056,14 +2058,16 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
dStElev = ( j - 1) * dStep ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti, approccio per lame
|
||||
else {
|
||||
// verifico di entrare in aria
|
||||
if ( ! bOutStart) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
return false ;
|
||||
}
|
||||
// affondo al punto iniziale
|
||||
@@ -2075,7 +2079,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, pCompo, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -2116,7 +2120,7 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, pCompo, bSplitArcs, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione per frese normali
|
||||
@@ -2126,8 +2130,10 @@ Milling::AddOneWayMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// determino se la fine dell'uscita è sopra il grezzo
|
||||
bool bAboveEnd = GetPointAboveRaw( ptP1) ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd))
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd)) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// per lame non è necessario
|
||||
}
|
||||
@@ -2200,14 +2206,16 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// correggo elevazione iniziale con punto inizio attacco
|
||||
dStElev -= ( ptP1 - ptStart) * vtExtr ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti, affondo al punto iniziale per lame
|
||||
else {
|
||||
// verifico di entrare in aria
|
||||
if ( ! bOutStart) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
m_pMchMgr->SetLastError( 2314, "Error in Milling : LeadIn must be out of rawpart") ;
|
||||
return false ;
|
||||
}
|
||||
// eseguo affondamento
|
||||
@@ -2218,7 +2226,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, false, pCompo, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -2260,7 +2268,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, false, pCompo, bSplitArcs, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione per frese normali
|
||||
@@ -2270,8 +2278,10 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// determino se la fine dell'uscita è sopra il grezzo
|
||||
bool bAboveEnd = GetPointAboveRaw( ptP1) ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd))
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd)) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// per lame non è necessario
|
||||
}
|
||||
@@ -2326,8 +2336,10 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// determino se l'inizio dell'attacco è sopra il grezzo
|
||||
bool bAboveStart = GetPointAboveRaw( ptP1) ;
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr, bOutStart, bAboveStart)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// altrimenti, affondo per lame
|
||||
else {
|
||||
@@ -2338,7 +2350,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, bInvert, pCompo, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2309, "Error in Milling : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -2380,7 +2392,7 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
Point3d ptP1 ;
|
||||
SetFeed( GetEndFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, dEndElev, bInvert, pCompo, bSplitArcs, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2310, "Error in Milling : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2311, "Error in Milling : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione per frese normali
|
||||
@@ -2390,8 +2402,10 @@ Milling::AddSpiralMilling( const ICurveComposite* pCompo, const Vector3d& vtTool
|
||||
// determino se la fine dell'uscita è sopra il grezzo
|
||||
bool bAboveEnd = GetPointAboveRaw( ptP1) ;
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd))
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr, bAboveEnd)) {
|
||||
m_pMchMgr->SetLastError( 2312, "Error in Milling : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// per lame non è necessario
|
||||
}
|
||||
@@ -2409,11 +2423,6 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
|
||||
SetFlag( 1) ;
|
||||
// se con aggregato da sotto
|
||||
if ( m_bAggrBottom) {
|
||||
// ne recupero alcuni dati
|
||||
double dAgbEncH = 0 ;
|
||||
double dAgbEncV = 0 ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCH", dAgbEncH) ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCV", dAgbEncV) ;
|
||||
// aggiuntivo in Z
|
||||
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
|
||||
// distanza dal bordo del pezzo
|
||||
@@ -2421,18 +2430,27 @@ Milling::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
|
||||
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAux, dDistBottom))
|
||||
dDistBottom = 0 ;
|
||||
// pre-approccio
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
vtAux.Rotate( Z_AX, - 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetAuxDir( m_vtAux) ;
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti rinvio normale
|
||||
else {
|
||||
SetAuxDir( m_vtAux) ;
|
||||
if ( AddRapidStart( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetFlag( 0) ;
|
||||
}
|
||||
}
|
||||
// se non sono già sopra il pezzo e sopra attacco c'è spazio per sicurezza o approccio
|
||||
double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
|
||||
@@ -2506,11 +2524,6 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
|
||||
}
|
||||
// se con aggregato da sotto
|
||||
if ( m_bAggrBottom) {
|
||||
// ne recupero alcuni dati
|
||||
double dAgbEncH = 0 ;
|
||||
double dAgbEncV = 0 ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCH", dAgbEncH) ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCV", dAgbEncV) ;
|
||||
// aggiuntivo in Z
|
||||
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
|
||||
// distanza dal bordo del pezzo
|
||||
@@ -2518,15 +2531,18 @@ Milling::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ,
|
||||
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAux, dDistBottom))
|
||||
dDistBottom = 0 ;
|
||||
// post-retract
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_OUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -118,5 +118,6 @@ class Milling : public Machining
|
||||
MillingData m_Params ; // parametri lavorazione
|
||||
ToolData m_TParams ; // parametri utensile
|
||||
int m_nMills ; // numero di percorsi di lavoro generati
|
||||
bool m_bAggrBottom ; // flag di utilizzo dell'aggregato da sotto
|
||||
bool m_bAggrBottom ; // flag utilizzo di aggregato da sotto
|
||||
AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto
|
||||
} ;
|
||||
+26
-2
@@ -1569,6 +1569,8 @@ Operation::RemoveHome( void)
|
||||
bool
|
||||
Operation::CalcDeltaZForHeadRotation( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd, double& dDeltaZ)
|
||||
{
|
||||
if ( m_pMchMgr == nullptr)
|
||||
return false ;
|
||||
// il numero di assi deve essere costante
|
||||
if ( vAxStart.size() != vAxEnd.size())
|
||||
return false ;
|
||||
@@ -1638,7 +1640,7 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
|
||||
// Se testa con Info ZMAXONROT != 0 e movimento assi rotanti -> collisione
|
||||
int nHeadId = pMch->GetCurrHead() ;
|
||||
int nVal = 0 ;
|
||||
if ( m_pGeomDB->GetInfo( nHeadId, "ZMAXONROT", nVal) && nVal != 0) {
|
||||
if ( m_pGeomDB->GetInfo( nHeadId, MCH_ZMAXONROT, nVal) && nVal != 0) {
|
||||
int nLinAxes = m_pMchMgr->GetCurrLinAxes() ;
|
||||
int nRotAxes = m_pMchMgr->GetCurrRotAxes() ;
|
||||
for ( int i = nLinAxes ; i < nLinAxes + nRotAxes ; ++ i) {
|
||||
@@ -1763,7 +1765,7 @@ bool
|
||||
Operation::SpecialMoveZup( Vector3d& vtTool, DBLVECTOR& vAx, bool& bModif)
|
||||
{
|
||||
// recupero la macchina corrente
|
||||
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
|
||||
Machine* pMch = ( m_pMchMgr != nullptr ? m_pMchMgr->GetCurrMachine() : nullptr) ;
|
||||
if ( pMch == nullptr)
|
||||
return false ;
|
||||
// costanti
|
||||
@@ -1815,3 +1817,25 @@ Operation::SpecialMoveZup( Vector3d& vtTool, DBLVECTOR& vAx, bool& bModif)
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Operation::GetAggrBottomData( const string& sHead, AggrBottom& agbData)
|
||||
{
|
||||
// inizializzo la struttura
|
||||
agbData.Clear() ;
|
||||
// verifiche
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
|
||||
return false ;
|
||||
// recupero identificativo della testa
|
||||
int nHeadId = m_pMchMgr->GetHeadId( sHead) ;
|
||||
if ( nHeadId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// leggo i dati
|
||||
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_TYPE, agbData.nType) ;
|
||||
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_DMAX, agbData.dDMax) ;
|
||||
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_ENCH, agbData.dEncH) ;
|
||||
m_pGeomDB->GetInfo( nHeadId, MCH_AGB_ENCV, agbData.dEncV) ;
|
||||
return true ;
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "MachConst.h"
|
||||
#include "MachineStruConst.h"
|
||||
#include "/EgtDev/Include/EGkPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkUserObj.h"
|
||||
#include "/EgtDev/Include/EGkSelection.h"
|
||||
@@ -93,6 +94,8 @@ class Operation : public IUserObj
|
||||
bool TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEnd) ;
|
||||
bool SpecialMoveZup( Vector3d& vtTool, DBLVECTOR& vAx, bool& bModif) ;
|
||||
|
||||
bool GetAggrBottomData( const std::string& sHead, AggrBottom& agbData) ;
|
||||
|
||||
protected :
|
||||
int m_nOwnerId ; // identificativo dell'oggetto geometrico possessore
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
|
||||
+74
-67
@@ -47,16 +47,18 @@ using namespace std ;
|
||||
// 2411 = "Error in Pocketing : toolpath allocation failed"
|
||||
// 2412 = "Error in Pocketing : Offset not computable"
|
||||
// 2413 = "Error in Pocketing : Toolpath not computable"
|
||||
// 2414 = "Error in Pocketing : LeadIn not computable"
|
||||
// 2415 = "Error in Pocketing : LeadOut not computable"
|
||||
// 2416 = "Error in Pocketing : Link not computable"
|
||||
// 2417 = "Error in Pocketing : Linear Approx not computable"
|
||||
// 2418 = "Error in Pocketing : Return toolpath not computable"
|
||||
// 2419 = "Error in Pocketing : Chaining failed"
|
||||
// 2420 = "Error in Pocketing : Tool MaxMaterial too small (xxx)"
|
||||
// 2421 = "Error in Pocketing : axes values not calculable"
|
||||
// 2422 = "Error in Pocketing : link movements not calculable"
|
||||
// 2423 = "Error in Pocketing : post apply not calculable"
|
||||
// 2414 = "Error in Pocketing : Approach not computable"
|
||||
// 2415 = "Error in Pocketing : LeadIn not computable"
|
||||
// 2416 = "Error in Pocketing : LeadOut not computable"
|
||||
// 2417 = "Error in Pocketing : Retract not computable"
|
||||
// 2418 = "Error in Pocketing : Link not computable"
|
||||
// 2419 = "Error in Pocketing : Linear Approx not computable"
|
||||
// 2420 = "Error in Pocketing : Return toolpath not computable"
|
||||
// 2421 = "Error in Pocketing : Chaining failed"
|
||||
// 2422 = "Error in Pocketing : Tool MaxMaterial too small (xxx)"
|
||||
// 2423 = "Error in Pocketing : axes values not calculable"
|
||||
// 2424 = "Error in Pocketing : link movements not calculable"
|
||||
// 2425 = "Error in Pocketing : post apply not calculable"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
USEROBJ_REGISTER( "EMkPocketing", Pocketing) ;
|
||||
@@ -429,7 +431,7 @@ Pocketing::Preview( bool bRecalc)
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId)) {
|
||||
m_pMchMgr->SetLastError( 2419, "Error in Pocketing : Chaining failed") ;
|
||||
m_pMchMgr->SetLastError( 2421, "Error in Pocketing : Chaining failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -494,7 +496,7 @@ Pocketing::Apply( bool bRecalc)
|
||||
|
||||
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
|
||||
if ( bChain && ! Chain( nAuxId)) {
|
||||
m_pMchMgr->SetLastError( 2419, "Error in Pocketing : Chaining failed") ;
|
||||
m_pMchMgr->SetLastError( 2421, "Error in Pocketing : Chaining failed") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -543,19 +545,19 @@ Pocketing::Apply( bool bRecalc)
|
||||
if ( ! m_Params.m_sInitAngs.empty())
|
||||
sHint = m_Params.m_sInitAngs ;
|
||||
if ( ! CalculateAxesValues( sHint)) {
|
||||
m_pMchMgr->SetLastError( 2421, "Error in Pocketing : axes values not calculable") ;
|
||||
m_pMchMgr->SetLastError( 2423, "Error in Pocketing : axes values not calculable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine della lavorazione
|
||||
if ( ! AdjustStartEndMovements()) {
|
||||
m_pMchMgr->SetLastError( 2422, "Error in Pocketing : link movements not calculable") ;
|
||||
m_pMchMgr->SetLastError( 2424, "Error in Pocketing : link movements not calculable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// esecuzione eventuali personalizzazioni
|
||||
if ( ! PostApply()) {
|
||||
m_pMchMgr->SetLastError( 2423, "Error in Pocketing : post apply not calculable") ;
|
||||
m_pMchMgr->SetLastError( 2425, "Error in Pocketing : post apply not calculable") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1132,7 +1134,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
|
||||
if ( m_TParams.m_dMaxMat < dElev && m_TParams.m_dMaxMat < MIN_MAXMAT) {
|
||||
string sInfo = "Error in Pocketing : Tool MaxMaterial too small (" +
|
||||
ToString( m_TParams.m_dMaxMat, 2) + ")" ;
|
||||
m_pMchMgr->SetLastError( 2420, sInfo) ;
|
||||
m_pMchMgr->SetLastError( 2422, sInfo) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
@@ -1319,16 +1321,11 @@ Pocketing::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d&
|
||||
bool bTabTilting = false ;
|
||||
if ( m_pMchMgr->GetCurrMachine()->GetCurrTableIsTilting( bTabTilting) && bTabTilting)
|
||||
return true ;
|
||||
// verifico se c'è rinvio da sotto
|
||||
int nHeadId = m_pMchMgr->GetHeadId( m_TParams.m_sHead) ;
|
||||
int nAgbType ;
|
||||
if ( ! m_pGeomDB->GetInfo( nHeadId, "AGB_TYPE", nAgbType) || nAgbType == 0) {
|
||||
// recupero dati di eventuale rinvio da sotto
|
||||
if ( ! GetAggrBottomData( m_TParams.m_sHead, m_AggrBottom) || m_AggrBottom.nType == 0) {
|
||||
m_pMchMgr->SetLastError( 2409, "Error in Pocketing : missing aggregate from bottom") ;
|
||||
return false ;
|
||||
}
|
||||
// recupero la massima distanza consentita dal rinvio
|
||||
double dAgbDmax = 0 ;
|
||||
m_pGeomDB->GetInfo( nHeadId, "AGB_DMAX", dAgbDmax) ;
|
||||
// calcolo la massima distanza minima del percorso dal contorno del grezzo
|
||||
double dDist = 0 ;
|
||||
Vector3d vtDir ;
|
||||
@@ -1362,7 +1359,7 @@ Pocketing::VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d&
|
||||
}
|
||||
}
|
||||
// se supera il limite, errore
|
||||
if ( dDist > dAgbDmax) {
|
||||
if ( dDist > m_AggrBottom.dDMax) {
|
||||
m_pMchMgr->SetLastError( 2410, "Error in Pocketing : path too far from part sides") ;
|
||||
return false ;
|
||||
}
|
||||
@@ -1509,12 +1506,14 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
dStElev = 0 ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pRCrv, ! m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1523,7 +1522,7 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
SetFeed( GetStartFeed()) ;
|
||||
ptP1 -= vtExtr * dStep ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pRCrv, ! m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : Link not computable") ;
|
||||
m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1585,12 +1584,14 @@ Pocketing::AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, c
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, pRCrv, bSplitArcs, ptP1, dEndElev)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr))
|
||||
if ( ! AddRetract( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1653,7 +1654,7 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
if ( j == 1) {
|
||||
// determino inizio attacco
|
||||
if ( ! CalcLeadInStart( ptStart, vtStart, vtExtr, pRCrv, ptP1)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// determino elevazione su inizio attacco
|
||||
@@ -1669,12 +1670,14 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
dStElev = 0 ;
|
||||
}
|
||||
// approccio al punto iniziale
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr))
|
||||
if ( ! AddApproach( ptP1, vtTool, dSafeZ, dSafeAggrBottZ, dStElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : Approach not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo attacco
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pRCrv, m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2414, "Error in Pocketing : LeadIn not computable") ;
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadIn not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1683,7 +1686,7 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
SetFeed( GetStartFeed()) ;
|
||||
ptP1 -= vtExtr * dStep ;
|
||||
if ( ! AddLeadIn( ptP1, ptStart, vtStart, vtExtr, pRCrv, m_Params.m_bInvert, bSplitArcs)) {
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : Link not computable") ;
|
||||
m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Link not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -1745,12 +1748,14 @@ Pocketing::AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool,
|
||||
double dEndElev = dElev ;
|
||||
SetFeed( GetStartFeed()) ;
|
||||
if ( ! AddLeadOut( ptEnd, vtEnd, vtExtr, pRCrv, bSplitArcs, ptQ, dEndElev)) {
|
||||
m_pMchMgr->SetLastError( 2415, "Error in Pocketing : LeadOut not computable") ;
|
||||
m_pMchMgr->SetLastError( 2416, "Error in Pocketing : LeadOut not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// aggiungo retrazione
|
||||
if ( ! AddRetract( ptQ, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr))
|
||||
if ( ! AddRetract( ptQ, vtTool, dSafeZ, dSafeAggrBottZ, dEndElev, dAppr)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Retract not computable") ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1826,7 +1831,7 @@ Pocketing::CalcSpiral( const ICurveComposite* pCompo, bool bSplitArcs,
|
||||
}
|
||||
// se necessario, approssimo archi con rette
|
||||
if ( bSplitArcs && ! ApproxWithLines( pMCrv)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Linear Approx not computable") ;
|
||||
m_pMchMgr->SetLastError( 2421, "Error in Pocketing : Linear Approx not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// eventuale sistemazione archi
|
||||
@@ -1892,7 +1897,7 @@ Pocketing::CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double d
|
||||
}
|
||||
// se necessario, approssimo con rette
|
||||
if ( bSplitArcs && ! ApproxWithLines( pMCrv)) {
|
||||
m_pMchMgr->SetLastError( 2417, "Error in Pocketing : Linear Approx not computable") ;
|
||||
m_pMchMgr->SetLastError( 2421, "Error in Pocketing : Linear Approx not computable") ;
|
||||
return false ;
|
||||
}
|
||||
// eventuale sistemazione archi
|
||||
@@ -1905,7 +1910,7 @@ Pocketing::CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double d
|
||||
if ( ! AreSamePointApprox( ptStart, ptEnd)) {
|
||||
PtrOwner<ICurveArc> pArc2( CreateCurveArc()) ;
|
||||
if ( IsNull( pArc2) || ! pArc2->Set2PVN( ptStart, ptEnd, - vtStart, vtN)) {
|
||||
m_pMchMgr->SetLastError( 2418, "Error in Pocketing : Return toolpath not computable") ;
|
||||
m_pMchMgr->SetLastError( 2420, "Error in Pocketing : Return toolpath not computable") ;
|
||||
return false ;
|
||||
}
|
||||
pRCrv->AddCurve( Release( pArc2)) ;
|
||||
@@ -1925,11 +1930,6 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe
|
||||
SetFlag( 1) ;
|
||||
// se con aggregato da sotto
|
||||
if ( m_bAggrBottom) {
|
||||
// ne recupero alcuni dati
|
||||
double dAgbEncH = 0 ;
|
||||
double dAgbEncV = 0 ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCH", dAgbEncH) ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCV", dAgbEncV) ;
|
||||
// aggiuntivo in Z
|
||||
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
|
||||
// distanza dal bordo del pezzo
|
||||
@@ -1937,18 +1937,27 @@ Pocketing::AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafe
|
||||
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAux, dDistBottom))
|
||||
dDistBottom = 0 ;
|
||||
// pre-approccio
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
vtAux.Rotate( Z_AX, - 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidStart( ptP00, MCH_CL_AGB_DWN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetAuxDir( m_vtAux) ;
|
||||
SetFlag( 0) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
// altrimenti rinvio normale
|
||||
else {
|
||||
SetAuxDir( m_vtAux) ;
|
||||
if ( AddRapidStart( ptP0, MCH_CL_AGB_IN) == GDB_ID_NULL)
|
||||
return false ;
|
||||
SetFlag( 0) ;
|
||||
}
|
||||
}
|
||||
// se sopra attacco c'è spazio per sicurezza o approccio
|
||||
double dSafeDist = ( m_bAggrBottom ? dSafeAggrBottZ : dSafeZ) ;
|
||||
@@ -2022,11 +2031,6 @@ Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ
|
||||
}
|
||||
// se con aggregato da sotto
|
||||
if ( m_bAggrBottom) {
|
||||
// ne recupero alcuni dati
|
||||
double dAgbEncH = 0 ;
|
||||
double dAgbEncV = 0 ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCH", dAgbEncH) ;
|
||||
m_pGeomDB->GetInfo( m_pMchMgr->GetHeadId( m_TParams.m_sHead), "AGB_ENCV", dAgbEncV) ;
|
||||
// aggiuntivo in Z
|
||||
double dAggZ = max( dElev + max( dSafeAggrBottZ, dAppr), 0.) ;
|
||||
// distanza dal bordo del pezzo
|
||||
@@ -2034,15 +2038,18 @@ Pocketing::AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ
|
||||
if ( ! GetDistanceFromRawSide( m_nPhase, ptP, m_vtAux, dDistBottom))
|
||||
dDistBottom = 0 ;
|
||||
// post-retract
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + dAgbEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( dAgbEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
Point3d ptP0 = ptP - Z_AX * dAggZ + m_vtAux * ( dDistBottom + m_AggrBottom.dEncH + dSafeZ) ;
|
||||
Point3d ptP00 = ptP0 + Z_AX * ( m_AggrBottom.dEncV + m_TParams.m_dLen + dAggZ - dElev) ;
|
||||
if ( AddRapidMove( ptP0, MCH_CL_AGB_OUT) == GDB_ID_NULL)
|
||||
return false ;
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
// se rinvio da sotto che richiede speciale rotazione
|
||||
if ( m_AggrBottom.nType == 1) {
|
||||
Vector3d vtAux = m_vtAux ;
|
||||
vtAux.Rotate( Z_AX, 90) ;
|
||||
SetAuxDir( vtAux) ;
|
||||
if ( AddRapidMove( ptP00, MCH_CL_AGB_UP) == GDB_ID_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -126,4 +126,5 @@ class Pocketing : public Machining
|
||||
ToolData m_TParams ; // parametri utensile
|
||||
int m_nPockets ; // numero di percorsi di svuotatura generati
|
||||
bool m_bAggrBottom ; // flag di utilizzo dell'aggregato da sotto
|
||||
AggrBottom m_AggrBottom ; // dati eventuale aggregato da sotto
|
||||
} ;
|
||||
Reference in New Issue
Block a user