EgtMachKernel 1.6l3 :

- aggiunta prima gestione preview tagli con lama.
This commit is contained in:
Dario Sassi
2015-12-15 14:48:11 +00:00
parent 629fda20d1
commit cc2a72d5af
11 changed files with 195 additions and 31 deletions
+141 -17
View File
@@ -19,6 +19,7 @@
#include "MachiningConst.h"
#include "CamData.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EXeConst.h"
#include "/EgtDev/Include/EGkCurveLine.h"
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EgkChainCurves.h"
@@ -314,7 +315,7 @@ Sawing::SetGeometry( const SELVECTOR& vIds)
//----------------------------------------------------------------------------
bool
Sawing::Apply( void)
Sawing::Preview( bool bRecalc)
{
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
@@ -322,23 +323,84 @@ Sawing::Apply( void)
// 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) ;
bChain = true ;
}
// altrimenti lo svuoto
else
// altrimenti, se chiesto ricalcolo, lo svuoto
else if ( bRecalc) {
m_pGeomDB->EmptyGroup( nAuxId) ;
bChain = true ;
}
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
if ( bChain && ! Chain( nAuxId))
return false ;
// verifiche per angolo di sbandamento
if ( ! VerifySideAngle())
return false ;
// eseguo concatenamento, inserisco i percorsi sotto la geometria ausiliaria
if ( ! Chain( nAuxId))
// recupero gruppo per anteprima di lavorazione (PreView)
int nPvId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_PV) ;
// se non c'è, lo aggiungo
if ( nPvId == GDB_ID_NULL) {
nPvId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nPvId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nPvId, MCH_PV) ;
}
// altrimenti lo svuoto
else
m_pGeomDB->EmptyGroup( nPvId) ;
// calcolo anteprima di 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) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::Apply( bool bRecalc)
{
// 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) ;
bChain = true ;
}
// altrimenti, se chiesto ricalcolo, lo svuoto
else if ( bRecalc) {
m_pGeomDB->EmptyGroup( nAuxId) ;
bChain = true ;
}
// se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria
if ( bChain && ! Chain( nAuxId))
return false ;
// verifiche per angolo di sbandamento
if ( ! VerifySideAngle())
return false ;
// recupero gruppo per geometria di lavorazione (Cutter Location)
@@ -357,7 +419,7 @@ Sawing::Apply( void)
// lavoro ogni singola catena
int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ;
while ( nPathId != GDB_ID_NULL) {
if ( ! PathApply( nPathId, nClId))
if ( ! ProcessPath( nPathId, GDB_ID_NULL, nClId))
return false ;
nPathId = m_pGeomDB->GetNextGroup( nPathId) ;
}
@@ -722,7 +784,7 @@ Sawing::Chain( int nGrpDestId)
//----------------------------------------------------------------------------
bool
Sawing::PathApply( int nPathId, int nClId)
Sawing::ProcessPath( int nPathId, int nPvId, int nClId)
{
// recupero gruppo per geometria temporanea
const string GRP_TEMP = "Temp" ;
@@ -846,7 +908,7 @@ Sawing::PathApply( int nPathId, int nClId)
const ICurve* pCrvN = pCompo->GetCurve( k) ;
// elaborazioni sulla curva corrente
string sName = sPathName + "_" + ToString( i) ;
if ( ! EntityApply( pCrvP, pCrvC, pCrvN, dDepth, dExtraCut, i == 0, i == nMaxInd, sName, nClId))
if ( ! ProcessEntity( pCrvP, pCrvC, pCrvN, dDepth, dExtraCut, i == 0, i == nMaxInd, sName, nPvId, nClId))
return false ;
}
@@ -855,19 +917,13 @@ Sawing::PathApply( int nPathId, int nClId)
//----------------------------------------------------------------------------
bool
Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN,
double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast,
const string& sName, int nClId)
Sawing::ProcessEntity( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCrvN,
double dDepth, double dExtraCut, bool bIsFirst, bool bIsLast,
const string& sName, int nPvId, int nClId)
{
// se non è una linea, la salto
if ( pCrvC->GetType() != CRV_LINE)
return true ;
// creo gruppo per geometria di lavorazione della linea
int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ;
if ( nPxId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nPxId, sName) ;
m_pGeomDB->SetMaterial( nPxId, BLUE) ;
// copio la curva
PtrOwner<ICurveLine> pLine( GetCurveLine( pCrvC->Clone())) ;
// calcolo i versori fresa e correzione
@@ -928,6 +984,74 @@ Sawing::EntityApply( const ICurve* pCrvP, const ICurve* pCrvC, const ICurve* pCr
return true ;
}
// Se richiesto Preview
if ( nPvId != GDB_ID_NULL) {
if ( ! GenerateEntityPv( Get( pLine), vtTool, vtCorr, dElev, dExtraCut, sName, nPvId))
return false ;
}
// Se richiesta geometria di lavorazione
if ( nClId != GDB_ID_NULL) {
if ( ! GenerateEntityCl( Get( pLine), vtTool, vtCorr, dElev, dExtraCut, sName, nClId))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::GenerateEntityPv( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr,
double dElev, double dExtraCut, const string& sName, int nPvId)
{
// creo gruppo per anteprima di lavorazione della linea
int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nPvId, Frame3d()) ;
if ( nPxId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nPxId, sName) ;
m_pGeomDB->SetMaterial( nPxId, BLUE) ;
// rettangolo per parte di taglio completo
Point3d ptIni = pLine->GetStart() + dElev * vtCorr ;
Point3d ptEnd = pLine->GetEnd() + dElev * vtCorr ;
Vector3d vtToolH( vtTool.x, vtTool.y, 0) ;
vtToolH *= m_TParams.m_dThick / vtToolH.SqLen() ;
Point3d ptCross = ptEnd + vtToolH ;
Vector3d vtDZ( 0, 0, 0.1) ;
int nId = ExeCreateRectangle3P( nPxId, ptIni + vtDZ, ptCross + vtDZ, ptEnd + vtDZ, RTY_LOC) ;
// assegno colore
m_pGeomDB->SetMaterial( nId, LIME) ;
// distanza XY tra centro e bordo taglio
double dDeltaT = (( dElev < 0.5 * m_TParams.m_dDiam) ? sqrt( dElev * m_TParams.m_dDiam - dElev * dElev) : 0) ;
// direzione del taglio
Vector3d vtDir ;
pLine->GetStartDir( vtDir) ;
// rettangolo per parte parziale iniziale
int nId2 = ExeCreateRectangle3P( nPxId, ptIni - vtDir * dDeltaT, ptIni + vtToolH, ptIni, RTY_LOC) ;
// assegno colore
m_pGeomDB->SetMaterial( nId2, FUCHSIA) ;
// rettangolo per parte parziale finale
int nId3 = ExeCreateRectangle3P( nPxId, ptEnd, ptCross + vtDir * dDeltaT, ptEnd + vtDir * dDeltaT, RTY_LOC) ;
// assegno colore
m_pGeomDB->SetMaterial( nId3, FUCHSIA) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Sawing::GenerateEntityCl( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr,
double dElev, double dExtraCut, const string& sName, int nClId)
{
// creo gruppo per geometria di lavorazione della linea
int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ;
if ( nPxId == GDB_ID_NULL)
return false ;
m_pGeomDB->SetName( nPxId, sName) ;
m_pGeomDB->SetMaterial( nPxId, BLUE) ;
// Imposto dati comuni
SetPathId( nPxId) ;
SetToolDir( vtTool) ;