EgtMachKernel 1.6n4 :

- migliorie a gestione fasi
- migliorie a gestione spezzatura grezzi.
This commit is contained in:
Dario Sassi
2016-02-15 07:45:43 +00:00
parent a8c34397be
commit bbb25a4fec
10 changed files with 409 additions and 83 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -285,7 +285,7 @@ Generator::ProcessMachining( int nOpId, int nOpInd)
return false ;
// Verifico non sia vuota
if ( m_pMchMgr->IsEmpty())
if ( m_pMchMgr->IsMachiningEmpty())
return true ;
// Recupero l'utensile della lavorazione corrente
+10 -4
View File
@@ -88,11 +88,13 @@ class MachMgr : public IMachMgr
bool ModifyRawPartSize( int nRawId, double dLength, double dWidth, double dHeight) override ;
bool ModifyRawPartHeight( int nRawId, double dHeight) override ;
bool KeepRawPart( int nRawId) override ;
bool VerifyRawPartPhase( int nRawId, int nPhase) const override ;
bool RemoveRawPart( int nRawId) override ;
bool RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg) override ;
bool MoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag) override ;
bool MoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag) override ;
bool MoveRawPart( int nRawId, const Vector3d& vtMove) ;
int SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId) override ;
// Parts
int GetPartInRawPartCount( int nRawId) const override ;
int GetFirstPartInRawPart( int nRawId) const override ;
@@ -163,18 +165,21 @@ class MachMgr : public IMachMgr
int GetLastActiveOperation( void) const override ;
int GetPrevActiveOperation( int nId) const override ;
int GetOperationType( int nId) const override ;
int GetOperationPhase( int nId) const override ;
std::string GetOperationName( int nId) const override ;
int GetOperationId( const std::string& sName) const override ;
bool RemoveOperation( int nId) override ;
bool RemoveAllOperations( bool bExceptFirstDisp) override ;
bool RemoveAllPhaseOperations( int nPhase) override ;
bool RemoveAllOperations( void) override ;
bool SetOperationMode( int nId, bool bActive) override ;
bool GetOperationMode( int nId, bool& bActive) const override ;
bool SetAllOperationsMode( bool bExceptFirstDisp, bool bActive) override ;
bool SetOperationStatus( int nId, bool bShow) override ;
bool GetOperationStatus( int nId, bool& bShow) const override ;
bool SetAllOperationsStatus(bool bExceptFirstDisp, bool bShow) override ;
bool ChangeOperationPhase( int nMchId, int nNewPhase) override ;
// Operations : dispositions
int AddDisposition( const std::string& sName) override ;
int GetPhaseDisposition( int nPhase) const override ;
// Operations : machinings
int AddMachining( const std::string& sName, const std::string& sMachining) override ;
bool SetCurrMachining( int nId) override ;
@@ -192,7 +197,7 @@ class MachMgr : public IMachMgr
bool GetMachiningParam( int nType, double& dVal) const override ;
bool GetMachiningParam( int nType, std::string& sVal) const override ;
bool GetMachiningGeometry( SELVECTOR& vIds) const override ;
bool IsEmpty( void) const override ;
bool IsMachiningEmpty( void) const override ;
// Simulation
bool SimStart( void) override ;
bool SimMove( int& nStatus) override ;
@@ -302,9 +307,10 @@ class MachMgr : public IMachMgr
// Parts
bool SwapParts( bool bToRawPart) ;
bool SwapRawPartParts( int nRawId, bool bToRawPart) ;
int SwapRawPartPart( int nId, bool bToRawPart) ;
bool ShowRootParts( bool bShow) ;
// Operations : dispositions
int AddDisposition( const std::string& sName, int nOperGrpId, int nPhase) ;
int AddDisposition( const std::string& sName) ;
private :
typedef std::vector<MachineData> MCHDATAVECTOR ;
+4 -4
View File
@@ -28,7 +28,7 @@ bool
MachMgr::SetTable( const string& sTable)
{
// imposto la tavola per la prima disposizione ( e il calcolo)
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
return ( pDisp != nullptr && pDisp->SetTable( sTable)) ;
}
@@ -40,7 +40,7 @@ MachMgr::GetTableRef( int nInd, Point3d& ptPos)
if ( nInd != 1)
return false ;
// recupero la prima operazione, deve essere la prima disposizione
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
if ( pDisp == nullptr)
return false ;
// recupero il punto
@@ -55,7 +55,7 @@ MachMgr::GetTableArea( int nInd, BBox3d& b3Area1)
if ( nInd != 1)
return false ;
// recupero la prima operazione, deve essere la prima disposizione
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( GetFirstOperation())) ;
if ( pDisp == nullptr)
return false ;
// recupero il bounding box
@@ -67,7 +67,7 @@ int
MachMgr::AddFixture( const string& sName, const Point3d& ptPos, double dAngRotDeg)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
+159 -40
View File
@@ -151,19 +151,19 @@ MachMgr::GetPrevActiveOperation( int nId) const
int
MachMgr::GetOperationType( int nId) const
{
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
if ( nOperGrpId == GDB_ID_NULL)
// recupero l'operazione
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter) || ! pIter->GoTo( nId))
return OPER_NULL ;
// verifico che il gruppo ricevuto sia corretto
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
if ( pIter->GetParentId() != GetCurrOperId())
return OPER_NULL ;
// recupero user object
IUserObj* pUserObj = m_pGeomDB->GetUserObj( nId) ;
IUserObj* pUserObj = pIter->GetUserObj() ;
if ( pUserObj == nullptr)
return OPER_NULL ;
// recupero il tipo di UserObj
string sUserObj = pUserObj->GetClassName() ;
const string& sUserObj = pUserObj->GetClassName() ;
if ( sUserObj == USEROBJ_GETNAME( Disposition))
return OPER_DISP ;
else if ( sUserObj == USEROBJ_GETNAME( Drilling))
@@ -176,6 +176,37 @@ MachMgr::GetOperationType( int nId) const
return OPER_NULL ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetOperationPhase( int nId) const
{
// recupero l'operazione
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter) || ! pIter->GoTo( nId))
return 0 ;
// verifico che il gruppo ricevuto sia corretto
if ( pIter->GetParentId() != GetCurrOperId())
return 0 ;
// recupero user object
IUserObj* pUserObj = pIter->GetUserObj() ;
if ( pUserObj == nullptr)
return 0 ;
// se disposizione
if ( pUserObj->GetClassName() == USEROBJ_GETNAME( Disposition)) {
const Disposition* pDisp = ::GetDisposition( pUserObj) ;
if ( pDisp != nullptr)
return pDisp->GetPhase() ;
}
// altrimenti lavorazione
else {
const Machining* pMch = GetMachining( pUserObj) ;
if ( pMch != nullptr)
return pMch->GetPhase() ;
}
// errore
return 0 ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetOperationNewName( string& sName) const
@@ -203,16 +234,16 @@ MachMgr::GetOperationNewName( string& sName) const
std::string
MachMgr::GetOperationName( int nId) const
{
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
if ( nOperGrpId == GDB_ID_NULL)
return "" ;
// recupero l'operazione
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter) || ! pIter->GoTo( nId))
return 0 ;
// verifico che il gruppo ricevuto sia corretto
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
return "" ;
// recupero il nome del gruppo riferito
if ( pIter->GetParentId() != GetCurrOperId())
return 0 ;
// recupero il nome dell'operazione riferita
string sName ;
m_pGeomDB->GetName( nId, sName) ;
pIter->GetName( sName) ;
return sName ;
}
@@ -223,22 +254,18 @@ MachMgr::GetOperationId( const string& sName) const
// verifica dei parametri
if ( &sName == nullptr || sName.empty())
return false ;
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
if ( nOperGrpId == GDB_ID_NULL)
return GDB_ID_NULL ;
// recupero l'identificativo del gruppo con il nome indicato
// recupero l'identificativo dell'operazione con il nome indicato
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return false ;
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ;
while( bIter) {
bool bIter = pIter->GoToFirstInGroup( GetCurrOperId()) ;
while ( bIter) {
// verifico il nome
string sOperGrpName ;
if ( pIter->GetName( sOperGrpName) && EqualNoCase( sOperGrpName, sName))
string sOperName ;
if ( pIter->GetName( sOperName) && EqualNoCase( sOperName, sName))
return pIter->GetId() ;
// passo al successivo
bIter = pIter->GoToNextGroup() ;
bIter = pIter->GoToNext() ;
}
return GDB_ID_NULL ;
}
@@ -247,8 +274,9 @@ MachMgr::GetOperationId( const string& sName) const
bool
MachMgr::RemoveOperation( int nId)
{
// verifico sia una Operazione
if ( GetOperationType( nId) == OPER_NULL)
// verifico sia una Operazione diversa da Disposizione
int nType = GetOperationType( nId) ;
if ( nType == OPER_NULL || nType == OPER_DISP)
return false ;
// se lavorazione corrente, resetto
if ( m_nCurrMachiningId == nId)
@@ -260,15 +288,53 @@ MachMgr::RemoveOperation( int nId)
//----------------------------------------------------------------------------
bool
MachMgr::RemoveAllOperations( bool bExceptFirstDisp)
MachMgr::RemoveAllPhaseOperations( int nPhase)
{
// recupero la disposizione di inizio fase
int nDispId = GetPhaseDisposition( nPhase) ;
if ( nDispId == GDB_ID_NULL)
return true ;
// elimino tutte le operazioni successive della stessa fase
int nOperId = m_pGeomDB->GetNext( nDispId) ;
while ( nOperId != GDB_ID_NULL) {
int nNextOperId = m_pGeomDB->GetNext( nOperId) ;
if ( GetOperationPhase( nOperId) == nPhase) {
if ( m_nCurrMachiningId == nOperId)
m_nCurrMachiningId = GDB_ID_NULL ;
m_pGeomDB->Erase( nOperId) ;
}
else
break ;
nOperId = nNextOperId ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::RemoveAllOperations( void)
{
// indice terminazione ciclo
int nStopId = ( bExceptFirstDisp ? GetFirstOperation() : GDB_ID_NULL) ;
int nStopId = GetFirstOperation() ;
// rimuovo tutte le operazioni a partire dalla fine
int nId = GetLastOperation() ;
while ( nId != GDB_ID_NULL && nId != nStopId) {
RemoveOperation( nId) ;
nId = GetLastOperation() ;
// se disposizione, elimino la fase
if ( GetOperationType( nId) == OPER_DISP)
RemoveLastPhase() ;
// altrimenti...
else {
// se lavorazione corrente, resetto
if ( m_nCurrMachiningId == nId)
m_nCurrMachiningId = GDB_ID_NULL ;
// eseguo la rimozione
m_pGeomDB->Erase( nId) ;
}
// recupero la nuova ultima (deve essere diversa dalla precedente)
int nPrevId = GetLastOperation() ;
if ( nPrevId == nId)
return false ;
nId = nPrevId ;
}
return true ;
}
@@ -357,6 +423,44 @@ MachMgr::SetAllOperationsStatus( bool bExceptFirstDisp, bool bShow)
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ChangeOperationPhase( int nId, int nNewPhase)
{
// l'operazione deve esistere e non essere una disposizione
int nType = GetOperationType( nId) ;
if ( nType == OPER_NULL || nType == OPER_DISP)
return false ;
// verifico che la nuova fase esista
if ( nNewPhase > m_nPhasesCount)
return false ;
// se la fase dell'operazione è già giusta, esco subito con successo
if ( GetOperationPhase( nId) == nNewPhase)
return true ;
// cerco l'ultima operazione della nuova fase
int nRefId = GDB_ID_NULL ;
int nCurrId = GetFirstOperation() ;
while ( nCurrId != GDB_ID_NULL) {
int nPhase = GetOperationPhase( nCurrId) ;
if ( nPhase == nNewPhase)
nRefId = nCurrId ;
else if ( nPhase > nNewPhase)
break ;
nCurrId = GetNextOperation( nCurrId) ;
}
if ( nRefId == GDB_ID_NULL)
return false ;
// recupero la lavorazione
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nId)) ;
if ( pMch == nullptr)
return false ;
// sposto la lavorazione
if ( ! m_pGeomDB->Relocate( nId, nRefId, GDB_AFTER))
return false ;
// assegno nuova fase
return pMch->SetPhase( nNewPhase) ;
}
//----------------------------------------------------------------------------
// Dispositions
//----------------------------------------------------------------------------
@@ -371,14 +475,6 @@ MachMgr::AddDisposition( const string& sName)
string sNewName = sName ;
if ( ! GetOperationNewName( sNewName))
return GDB_ID_NULL ;
// eseguo
return AddDisposition( sNewName, nOperGrpId, m_nCurrPhase) ;
}
//----------------------------------------------------------------------------
int
MachMgr::AddDisposition( const string& sName, int nOperGrpId, int nPhase)
{
// inserisco il gruppo
int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ;
if ( nId == GDB_ID_NULL)
@@ -391,10 +487,32 @@ MachMgr::AddDisposition( const string& sName, int nOperGrpId, int nPhase)
return GDB_ID_NULL ;
m_pGeomDB->SetUserObj( nId, pDisp) ;
pDisp->Init( this) ;
pDisp->SetPhase( nPhase) ;
pDisp->SetPhase( m_nCurrPhase) ;
return nId ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetPhaseDisposition( int nPhase) const
{
// verifico esista la fase
if ( nPhase > m_nPhasesCount)
return GDB_ID_NULL ;
// cerco la disposizione nel gruppo delle operazioni
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return GDB_ID_NULL ;
bool bIter = pIter->GoToFirstInGroup( GetCurrOperId()) ;
while ( bIter) {
const Disposition* pDisp = ::GetDisposition( pIter->GetUserObj()) ;
if ( pDisp != nullptr && pDisp->GetPhase() == nPhase)
return pIter->GetId() ;
bIter = pIter->GoToNext() ;
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
// Machinings
//----------------------------------------------------------------------------
@@ -418,6 +536,7 @@ MachMgr::SetCurrMachining( int nId)
m_nCurrMachiningId = nId ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ResetCurrMachining( void)
@@ -703,7 +822,7 @@ MachMgr::GetMachiningGeometry( SELVECTOR& vIds) const
//----------------------------------------------------------------------------
bool
MachMgr::IsEmpty( void) const
MachMgr::IsMachiningEmpty( void) const
{
// recupero la lavorazione corrente
int nCurrMchId = GetCurrMachining() ;
+32 -21
View File
@@ -202,33 +202,44 @@ MachMgr::SwapRawPartParts( int nRawId, bool bToRawPart)
while ( nId != GDB_ID_NULL) {
// recupero il successivo
int nNextId = m_pGeomDB->GetNextGroup( nId) ;
// se devo portare i pezzi dalla radice al grezzo
if ( bToRawPart) {
// se è un riferimento al pezzo
int nSou ;
if ( m_pGeomDB->GetInfo( nId, GDB_SI_SOURCE, nSou)) {
m_pGeomDB->GroupSwap( nSou, nId, true, true) ;
// mi assicuro sia visibile
m_pGeomDB->SetStatus( nSou, GDB_ST_ON) ;
}
}
// altrimenti dal grezzo alla radice
else {
// se è un pezzo spostato
int nBase ;
if ( m_pGeomDB->GetInfo( nId, GDB_SI_BASE, nBase)) {
m_pGeomDB->GroupSwap( nId, nBase, true, true) ;
// mi assicuro sia nascosto e di livello utente
m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ;
m_pGeomDB->SetLevel( nId, GDB_LV_USER) ;
}
}
// eseguo lo swap del pezzo
SwapRawPartPart( nId, bToRawPart) ;
// passo al successivo
nId = nNextId ;
}
return true ;
}
//----------------------------------------------------------------------------
int
MachMgr::SwapRawPartPart( int nId, bool bToRawPart)
{
// se devo portare i pezzi dalla radice al grezzo
if ( bToRawPart) {
// se è un riferimento al pezzo
int nSou ;
if ( m_pGeomDB->GetInfo( nId, GDB_SI_SOURCE, nSou)) {
m_pGeomDB->GroupSwap( nSou, nId, true, true) ;
// mi assicuro sia visibile
m_pGeomDB->SetStatus( nSou, GDB_ST_ON) ;
return nSou ;
}
}
// altrimenti dal grezzo alla radice
else {
// se è un pezzo spostato
int nBase ;
if ( m_pGeomDB->GetInfo( nId, GDB_SI_BASE, nBase)) {
m_pGeomDB->GroupSwap( nId, nBase, true, true) ;
// mi assicuro sia nascosto e di livello utente
m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ;
m_pGeomDB->SetLevel( nId, GDB_LV_USER) ;
return nBase ;
}
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ShowRootParts( bool bShow)
+46 -6
View File
@@ -31,7 +31,7 @@ MachMgr::AddPhase( void)
string sTable ;
int nDispId = GetFirstOperation() ;
while ( nDispId != GDB_ID_NULL) {
const Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( nDispId)) ;
const Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nDispId)) ;
if ( pDisp != nullptr)
pDisp->GetTable( sTable) ;
nDispId = GetNextOperation( nDispId) ;
@@ -47,7 +47,7 @@ MachMgr::AddPhase( void)
return 0 ;
// assegno la tavola della disposizione precedente
if ( ! sTable.empty()) {
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
pDisp->SetTable( sTable) ;
}
@@ -120,7 +120,7 @@ MachMgr::PrepareCurrPhase( int nPhase, bool bDoDisp)
Disposition* pDisp = nullptr ;
nDispId = GetFirstOperation() ;
while ( nDispId != GDB_ID_NULL) {
pDisp = GetDisposition( m_pGeomDB->GetUserObj( nDispId)) ;
pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nDispId)) ;
if ( pDisp != nullptr && pDisp->GetPhase() == nPhase)
break ;
else
@@ -161,11 +161,51 @@ MachMgr::GetCurrPhase( void) const
bool
MachMgr::RemoveLastPhase( void)
{
if ( m_pGeomDB == nullptr)
return false ;
// non è possibile rimuovere la prima e unica fase
if ( m_nPhasesCount <= 1)
return false ;
// imposto le relative lavorazioni come disattivate e senza fase
// elimino i grezzi appartenenti a questa sola fase e la relativa disposizione
// cancello le eventuali lavorazioni della fase
int nOperId = GetLastOperation() ;
while ( nOperId != GDB_ID_NULL) {
if ( GetOperationType( nOperId) != OPER_DISP && GetOperationPhase( nOperId) == m_nPhasesCount) {
if ( m_nCurrMachiningId == nOperId)
m_nCurrMachiningId = GDB_ID_NULL ;
m_pGeomDB->Erase( nOperId) ;
}
else
break ;
nOperId = GetLastOperation() ;
}
// aggiorno i grezzi ed elimino quelli appartenenti a questa sola fase
int nRawId = GetFirstRawPart() ;
while ( nRawId != GDB_ID_NULL) {
// prossimo grezzo
int nNextRawId = GetNextRawPart( nRawId) ;
// recupero le fasi in cui è presente il grezzo
INTVECTOR vPhase ;
if ( ! m_pGeomDB->GetInfo( nRawId, MACH_RAW_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
// se appartiene alla fase
auto iIter = find( vPhase.begin(), vPhase.end(), m_nPhasesCount) ;
if ( iIter != vPhase.end()) {
// se appartiene solo a questa fase, lo elimino
if ( vPhase.size() == 1)
RemoveRawPart( nRawId) ;
// altrimenti aggiorno l'elenco delle fasi di appartenenza
else {
vPhase.erase( iIter) ;
m_pGeomDB->SetInfo( nRawId, MACH_RAW_PHASE, vPhase) ;
}
}
// passo al prossimo
nRawId = nNextRawId ;
}
// elimino la disposizione di fase
int nDispId = GetLastOperation() ;
if ( GetOperationType( nDispId) == OPER_DISP && GetOperationPhase( nDispId) == m_nPhasesCount)
m_pGeomDB->Erase( nDispId) ;
// se era corrente, rendo corrente la precedente
if ( m_nCurrPhase == m_nPhasesCount)
SetCurrPhase( m_nCurrPhase - 1) ;
@@ -188,7 +228,7 @@ MachMgr::CalcPhaseCount( void) const
int nPhases = 0 ;
int nDispId = GetFirstOperation() ;
while ( nDispId != GDB_ID_NULL) {
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( nDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( nDispId)) ;
if ( pDisp != nullptr)
nPhases = max( nPhases, pDisp->GetPhase()) ;
nDispId = GetNextOperation( nDispId) ;
+152 -6
View File
@@ -20,10 +20,12 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkGdbIterator.h"
#include "/EgtDev/Include/EGkGeoPoint3d.h"
#include "/EgtDev/Include/EgkCurveAux.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EGkCurveAux.h"
#include "/EgtDev/Include/EGkOffsetCurve.h"
#include "/EgtDev/Include/EgkDistPointCurve.h"
#include "/EgtDev/Include/EGkStmStandard.h"
#include "/EgtDev/Include/EGkStmFromCurves.h"
#include "/EgtDev/Include/EmkMachiningGeoConst.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
@@ -501,6 +503,20 @@ MachMgr::KeepRawPart( int nRawId)
return SwapRawPartParts( nRawId, true) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyRawPartPhase( int nRawId, int nPhase) const
{
// verifico validità grezzo
if ( ! VerifyRawPart( nRawId))
return false ;
// verifico sia attivo nella fase indicata
INTVECTOR vPhase ;
if ( ! m_pGeomDB->GetInfo( nRawId, MACH_RAW_PHASE, vPhase) || vPhase.empty())
vPhase.emplace_back( 1) ;
return ( find( vPhase.begin(), vPhase.end(), nPhase) != vPhase.end()) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::RemoveRawPart( int nRawId)
@@ -534,7 +550,7 @@ bool
MachMgr::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
@@ -546,7 +562,7 @@ bool
MachMgr::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
@@ -558,7 +574,7 @@ bool
MachMgr::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
@@ -570,7 +586,7 @@ bool
MachMgr::MoveRawPart( int nRawId, const Vector3d& vtMove)
{
// recupero l'oggetto disposizione corrente
Disposition* pDisp = GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
Disposition* pDisp = ::GetDisposition( m_pGeomDB->GetUserObj( m_nCurrDispId)) ;
if ( pDisp == nullptr)
return false ;
// eseguo l'operazione
@@ -648,3 +664,133 @@ MachMgr::GetRawPartCenter( int nRawId, Point3d& ptCen)
ptCen.ToGlob( frGPnt) ;
return true ;
}
//----------------------------------------------------------------------------
int
MachMgr::SplitFlatRawPartWithMachinings( int nRawId, const INTVECTOR& vMchId)
{
if ( m_pGeomDB == nullptr)
return GDB_ID_NULL ;
// verifico sia un grezzo e non appartenga alla fase corrente
if ( ! VerifyRawPart( nRawId) || VerifyRawPartPhase( nRawId, m_nCurrPhase))
return GDB_ID_NULL ;
// recupero alcuni dati del grezzo
// il solido del grezzo
int nRawSolId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_SOLID) ;
if ( nRawSolId == GDB_ID_NULL)
return GDB_ID_NULL ;
// il box del grezzo
BBox3d b3Raw ;
if ( ! m_pGeomDB->GetGlobalBBox( nRawSolId, b3Raw))
return GDB_ID_NULL ;
double dZmin = b3Raw.GetMin().z ;
double dHeight = b3Raw.GetMax().z - b3Raw.GetMin().z ;
// il colore del grezzo
Color cCol = AQUA ;
m_pGeomDB->GetCalcMaterial( nRawSolId, cCol) ;
// creo la regione del grezzo a partire dal suo contorno
// recupero il contorno
int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nRawId, MACH_RAW_OUTLINE) ;
if ( nOutCrvId == GDB_ID_NULL)
return GDB_ID_NULL ;
// creo la regione
INTVECTOR vCrvIds ;
vCrvIds.emplace_back( nOutCrvId) ;
int nSfrId = ExeCreateSurfFlatRegion( nRawId, vCrvIds, nullptr) ;
if ( nSfrId == GDB_ID_NULL)
return GDB_ID_NULL ;
m_pGeomDB->SetLevel( nSfrId, GDB_LV_TEMP) ;
// recupero le regioni delle lavorazioni
INTVECTOR vMchRReg ;
for ( auto nMchId : vMchId) {
// recupero gruppo preview lavorazioni nella lavorazione
int nPVGrp = m_pGeomDB->GetFirstNameInGroup( nMchId, MCH_PV) ;
if ( nPVGrp == GDB_ID_NULL)
return false ;
// se vuoto, cerco il rimando al preview nel pezzo
if ( m_pGeomDB->GetGroupObjs( nPVGrp) == 0 &&
! m_pGeomDB->GetInfo( nPVGrp, MCH_PV_KEY_RELOCATE, nPVGrp))
return false ;
// ciclo sui percorsi utensile (CL)
int nClId = m_pGeomDB->GetFirstGroupInGroup( nPVGrp) ;
while ( nClId != GDB_ID_NULL) {
// tagli ridotti
int nCrId = m_pGeomDB->GetFirstNameInGroup( nClId, MCH_PV_RRCUT) ;
while ( nCrId != GDB_ID_NULL) {
vMchRReg.emplace_back( nCrId) ;
nCrId = m_pGeomDB->GetNextName( nCrId, MCH_PV_RRCUT) ;
}
// passo al successivo percorso utensile
nClId = m_pGeomDB->GetNextGroup( nClId) ;
}
}
// sottraggo queste regioni a quella del grezzo
for ( auto nMchRReg : vMchRReg) {
ExeSurfFrSubtract( nSfrId, nMchRReg) ;
}
// creo i grezzi risultanti
// creo i nuovi grezzi
INTVECTOR vNewIds ;
int nChunk = 0 ;
int nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, nullptr) ;
while ( nFirstLoopId != GDB_ID_NULL) {
// dichiaro temporanea la curva
m_pGeomDB->SetLevel( nFirstLoopId, GDB_LV_TEMP) ;
// creo il grezzo
int nId = AddRawPart( nFirstLoopId, 0, dZmin, dHeight, cCol) ;
if ( nId == GDB_ID_NULL)
return GDB_ID_NULL ;
vNewIds.emplace_back( nId) ;
// assegno la fase al gruppo
m_pGeomDB->SetInfo( nId, MACH_RAW_PHASE, m_nCurrPhase) ;
++ nChunk ;
// cancello la curva
m_pGeomDB->Erase( nFirstLoopId) ;
// passo alla prossima curva
nFirstLoopId = ExeExtractSurfFrChunkLoops( nSfrId, nChunk, nRawId, nullptr) ;
}
// cancello la regione
m_pGeomDB->Erase( nSfrId) ;
// verifico esista almeno un nuovo grezzo
if ( vNewIds.empty())
return GDB_ID_NULL ;
// inserisco i pezzi del grezzo originale nei nuovi grezzi
int nGroupId = m_pGeomDB->GetFirstGroupInGroup( nRawId) ;
while ( nGroupId != GDB_ID_NULL) {
for ( auto nNewId : vNewIds) {
// copio il gruppo
int nNewGroupId = m_pGeomDB->CopyGlob( nGroupId, GDB_ID_NULL, nNewId) ;
// scambio con pezzo
int nPartId = SwapRawPartPart( nNewGroupId, true) ;
// verifico se il pezzo sta nel grezzo
int nLayerId = m_pGeomDB->GetFirstGroupInGroup( nPartId) ;
int nEntId = m_pGeomDB->GetFirstInGroup( nLayerId) ;
Point3d ptTest ;
if ( ExeCenterPoint( nEntId, nNewId, ptTest)) {
int nOutCrvId = m_pGeomDB->GetFirstNameInGroup( nNewId, MACH_RAW_OUTLINE) ;
ICurve* pCurve = GetCurve( m_pGeomDB->GetGeoObj( nOutCrvId)) ;
if ( pCurve != nullptr) {
int nSide ;
double dDist ;
DistPointCurve distPC( ptTest, *pCurve) ;
if ( distPC.GetDist( dDist) && dDist < 100 * EPS_SMALL ||
(distPC.GetSideAtMinDistPoint( 0, Z_AX, nSide) && nSide != MDS_RIGHT))
break ;
}
}
// altrimenti scambio pezzo ed elimino gruppo
nNewGroupId = SwapRawPartPart( nPartId, false) ;
m_pGeomDB->Erase( nNewGroupId) ;
}
nGroupId = m_pGeomDB->GetNextGroup( nGroupId) ;
}
return vNewIds[0] ;
}
+3 -1
View File
@@ -1162,7 +1162,9 @@ Sawing::GenerateEntityPv( const ICurveLine* pLine, const Vector3d& vtTool, const
m_pGeomDB->SetName( nRId, MCH_PV_RCUT) ;
m_pGeomDB->SetMaterial( nRId, INVISIBLE) ;
// regione di taglio ridotto per nesting (sono escluse le parti iniziale e finale)
int nRrId = ExeCreateSurfFrRectangle3P( nPxId, ptIni, ptCross, ptEnd, RTY_LOC) ;
const double EXTRALEN_R = 10 * EPS_SMALL ;
int nRrId = ExeCreateSurfFrRectangle3P( nPxId, ptIni - vtDir * EXTRALEN_R,
ptCross + vtDir * EXTRALEN_R, ptEnd, RTY_LOC) ;
m_pGeomDB->SetName( nRrId, MCH_PV_RRCUT) ;
m_pGeomDB->SetMaterial( nRrId, INVISIBLE) ;
// regione di ingresso al taglio (parte iniziale)
+2
View File
@@ -65,6 +65,8 @@ Simulator::Start( void)
int nMachGrp = m_pMchMgr->GetCurrMachGroup() ;
if ( nMachGrp == GDB_ID_NULL)
return false ;
// imposto fase iniziale
m_pMchMgr->SetCurrPhase( 1) ;
// verifico la disposizione iniziale della macchinata
int nOpId = m_pMchMgr->GetFirstActiveOperation() ;
if ( m_pMchMgr->GetOperationType( nOpId) != OPER_DISP)