EgtMachKernel 1.9j6 :

- prima versione gestione lati aperti di svuotature
- corrette Clone di lavorazioni per Copia
- migliorata gestione visualizzazione Anteprima utensile in lavorazione.
This commit is contained in:
Dario Sassi
2018-10-29 07:37:47 +00:00
parent 712ead789f
commit 10fface7d0
11 changed files with 105 additions and 8 deletions
+79
View File
@@ -68,6 +68,9 @@ using namespace std ;
// 2428 = "Error in Pocketing : Tool loading failed"
// 2429 = "Error in Pocketing : machining depth (xxx) bigger than MaxDepth (yyy)"
//----------------------------------------------------------------------------
static std::string KEY_OPEN = "OPEN" ;
//----------------------------------------------------------------------------
USEROBJ_REGISTER( GetOperationClass( OPER_POCKETING), Pocketing) ;
@@ -87,10 +90,12 @@ Pocketing::Clone( void) const
// eseguo copia dei dati
if ( pPock != nullptr) {
try {
pPock->m_vId = m_vId ;
pPock->m_pMchMgr = m_pMchMgr ;
pPock->m_nPhase = m_nPhase ;
pPock->m_Params = m_Params ;
pPock->m_TParams = m_TParams ;
pPock->m_nPockets = m_nPockets ;
}
catch( ...) {
delete pPock ;
@@ -993,6 +998,30 @@ Pocketing::GetCurves( SelData Id, ICURVEPLIST& lstPC)
pCrvCompo->FromPolyLine( vPL[0]) ;
if ( ! pCrvCompo->IsValid())
return false ;
// determino eventuali lati aperti e aggiorno proprietà del contorno
int nInd = 0 ;
double dPar ;
bool bFound = vPL[0].GetFirstU( dPar, true) ;
while ( bFound) {
// recupero il flag
int nFlag = int( dPar) ;
// se non c'è nulla di adiacente, lato aperto
if ( nFlag == SVT_NULL)
pCrvCompo->SetCurveTempProp( nInd, 1) ;
// altrimenti verifico se la faccia adiacente forma diedro convesso o concavo
else {
bool bAdjac ;
Point3d ptP1, ptP2 ;
double dAng ;
if ( ! pSurf->GetFacetsContact( nFacet, nFlag, bAdjac, ptP1, ptP2, dAng))
dAng = - ANG_RIGHT ;
if ( dAng > - EPS_ANG_SMALL)
pCrvCompo->SetCurveTempProp( nInd, 1) ;
}
// passo al successivo
++ nInd ;
bFound = vPL[0].GetNextU( dPar, true) ;
}
// recupero la normale esterna della faccia
Vector3d vtN ;
if ( ! pSurf->GetFacetNormal( nFacet, vtN))
@@ -1146,6 +1175,13 @@ Pocketing::Chain( int nGrpDestId)
// se utile, approssimo con archi
if ( ! ApproxWithArcsIfUseful( pCrvCompo))
return false ;
// recupero eventuali lati aperti
INTVECTOR vOpen ;
for ( int i = 0 ; i < int( pCrvCompo->GetCurveCount()) ; ++ i) {
int nProp = 0 ;
if ( pCrvCompo->GetCurveTempProp( i, nProp) && nProp == 1)
vOpen.emplace_back( i) ;
}
// creo nuovo gruppo
int nPathId = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrpDestId, Frame3d()) ;
if ( nPathId == GDB_ID_NULL)
@@ -1156,6 +1192,9 @@ Pocketing::Chain( int nGrpDestId)
int nNewId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nPathId, ::Release( pCrvCompo)) ;
if ( nNewId == GDB_ID_NULL)
return false ;
// salvo info con eventuali lati aperti
if ( ! vOpen.empty())
m_pGeomDB->SetInfo( nNewId, KEY_OPEN, vOpen) ;
}
return true ;
}
@@ -1197,6 +1236,17 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
return false ;
ICurveComposite* pCompo = GetCurveComposite( m_pGeomDB->GetGeoObj( nCopyId)) ;
// aggiorno flag per lati aperti
bool bSomeOpen = m_pGeomDB->ExistsInfo( nCrvId, KEY_OPEN) ;
if ( bSomeOpen) {
for ( int i = 0 ; i < int( pCompo->GetCurveCount()) ; ++ i)
pCompo->SetCurveTempProp( i, 0) ;
INTVECTOR vOpen ;
m_pGeomDB->GetInfo( nCrvId, KEY_OPEN, vOpen) ;
for ( int j : vOpen)
pCompo->SetCurveTempProp( j, 1) ;
}
// recupero estrusione e spessore
Vector3d vtExtr = Z_AX ;
pCompo->GetExtrusion( vtExtr) ;
@@ -1224,6 +1274,35 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId)
if ( plPlane.GetVersN() * vtExtr * dArea < 0)
pCompo->Invert() ;
// sistemazioni per eventuali lati aperti
if ( bSomeOpen) {
// raggio di riferimento
double dRad = 0.5 * m_TParams.m_dDiam + GetOffsR() ;
// estraggo tutte le curve in un vettore
ICURVEPOVECTOR vpCrvs ;
vpCrvs.reserve( pCompo->GetCurveCount()) ;
while ( pCompo->GetCurveCount() > 0)
vpCrvs.emplace_back( pCompo->RemoveFirstOrLastCurve( false)) ;
// offsetto del raggio le curve aperte
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
if ( vpCrvs[i]->GetTempProp() == 1)
vpCrvs[i]->SimpleOffset( dRad) ;
}
// reinserisco le curve, chiudendo eventuali gap
for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) {
// chiudo eventuale gap
if ( i > 0) {
Point3d ptEnd ; pCompo->GetEndPoint( ptEnd) ;
Point3d ptStart ; vpCrvs[i]->GetStartPoint( ptStart) ;
if ( ! AreSamePointEpsilon( ptEnd, ptStart, 10 * EPS_SMALL))
pCompo->AddLine( ptStart) ;
}
// aggiungo la curva
pCompo->AddCurve( ::Release( vpCrvs[i]), true, 10 * EPS_SMALL) ;
}
pCompo->Close() ;
}
// unisco le parti allineate (tranne inizio-fine se chiusa)
if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false))
return false ;