From 9c33e2f4fce10eda2fa35f822c20f18b37a4aec6 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 15 Nov 2018 18:38:27 +0000 Subject: [PATCH] EgtMachKernel 1.9k1 : - nel generatore e estimatore aggiunta variabile EMT.SPLITARCS con info spezzatura archi - in svuotature migliorata gestione lati aperti con pulizia transizioni chiuso-aperto. --- EgtMachKernel.rc | Bin 11782 -> 11782 bytes MachMgr.h | 1 + MachMgrOperations.cpp | 22 ++++++++++++-- OutputConst.h | 1 + Pocketing.cpp | 69 +++++++++++++++++++++++++++++++++++++----- Processor.cpp | 3 ++ 6 files changed, 86 insertions(+), 10 deletions(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 071496cf0f7c2360df09a899b24f50ccac1a921c..0f0ab27c40eed26b228694dd2bd4fc42a80ef39a 100644 GIT binary patch delta 121 zcmZpRX^YwLgN@aYL5IO`^ItY=X69@L!^w`qx|_3v+!!~nNOI~D}d`2)2NkJbA OTnNOI~D}d`2)2NkJbA OTn pIter( CreateGdbIterator( m_pGeomDB)) ; + if ( IsNull( pIter) || ! pIter->GoTo( nId)) + return false ; + // verifico che faccia parte del gruppo delle operazioni + if ( pIter->GetParentId() != GetCurrOperId()) + return false ; + // verifico che il nome non sia gią usato da una operazione + if ( GetOperationId( sName) != GDB_ID_NULL) + return false ; + // assegno il nome + return pIter->SetName( sName) ; +} + +//---------------------------------------------------------------------------- +string MachMgr::GetOperationName( int nId) const { // recupero l'operazione PtrOwner pIter( CreateGdbIterator( m_pGeomDB)) ; if ( IsNull( pIter) || ! pIter->GoTo( nId)) return 0 ; - // verifico che il gruppo ricevuto sia corretto + // verifico che faccia parte del gruppo delle operazioni if ( pIter->GetParentId() != GetCurrOperId()) return 0 ; // recupero il nome dell'operazione riferita diff --git a/OutputConst.h b/OutputConst.h index cf8f24f..847b71f 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -25,6 +25,7 @@ static const std::string GVAR_ERR = ".ERR" ; // (int) codice di static const std::string GVAR_USETO1 = ".USETO1" ; // (bool) flag per utilizzo origine tavola static const std::string GVAR_MODAL = ".MODAL" ; // (bool) flag per emissione modale dei valori static const std::string GVAR_INCHES = ".INCHES" ; // (bool) flag unitą di misura (true=inches, false=mm) +static const std::string GVAR_SPLITARCS = ".SPLITARCS" ; // (int) flag spezzatura archi (0=mai, 1=piani generici, 2=piani diversi da XY, 3=sempre) static const std::string GVAR_NUM = ".NUM" ; // (bool) flag numerazione static const std::string GVAR_NUMTOK = ".Nt" ; // (string) token per numerazione static const std::string GVAR_LINENBR = ".LINENBR" ; // (int) numero progressivo di linea diff --git a/Pocketing.cpp b/Pocketing.cpp index 3143a13..7d53681 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -1274,10 +1274,13 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) if ( plPlane.GetVersN() * vtExtr * dArea < 0) pCompo->Invert() ; + // sposto l'inizio a metą del tratto pił lungo + AdjustContourStart( pCompo) ; + // sistemazioni per eventuali lati aperti if ( bSomeOpen) { - // raggio di riferimento - double dRad = 0.5 * m_TParams.m_dDiam + GetOffsR() ; + // raggio di riferimento per offset + double dRad = 0.25 * m_TParams.m_dDiam + GetOffsR() ; // estraggo tutte le curve in un vettore ICURVEPOVECTOR vpCrvs ; vpCrvs.reserve( pCompo->GetCurveCount()) ; @@ -1289,13 +1292,66 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) vpCrvs[i]->SimpleOffset( dRad) ; } // reinserisco le curve, chiudendo eventuali gap + bool bOpenCurr = false ; + double dDiam = m_TParams.m_dDiam + 2.0 + 2 * GetOffsR() ; for ( int i = 0 ; i < int( vpCrvs.size()) ; ++ i) { + // stato curve + bool bOpenPrev = bOpenCurr ; + bOpenCurr = ( vpCrvs[i]->GetTempProp() != 0) ; // 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) ; + if ( ! AreSamePointEpsilon( ptEnd, ptStart, 10 * EPS_SMALL)) { + if ( ! bOpenPrev && bOpenCurr) { + Vector3d vtTg ; pCompo->GetEndDir( vtTg) ; + Vector3d vtOrt = vtTg ; vtOrt.Rotate( vtExtr, 0, 1) ; + Point3d ptArc = ptEnd + dDiam * vtOrt ; + Point3d ptLine = ptArc - 5 * dDiam * vtTg ; + PtrOwner pJCrv( CreateCurveComposite()) ; + if ( IsNull( pJCrv)) + return false ; + pJCrv->SetExtrusion( vtExtr) ; + pJCrv->AddPoint( ptLine) ; + pJCrv->AddLine( ptArc, false) ; + pJCrv->AddArcTg( ptEnd, false) ; + IntersCurveCurve intCC( *pJCrv, *vpCrvs[i]) ; + IntCrvCrvInfo aInfo ; + if ( intCC.GetIntCrvCrvInfo( intCC.GetIntersCount() - 1, aInfo)) { + pJCrv->TrimEndAtParam( aInfo.IciA[0].dU) ; + vpCrvs[i]->TrimStartAtParam( aInfo.IciB[0].dU) ; + pCompo->AddCurve( ::Release( pJCrv), true, 10 * EPS_SMALL) ; + } + else + pCompo->AddLine( ptStart) ; + } + else if ( bOpenPrev && ! bOpenCurr) { + Vector3d vtTg ; vpCrvs[i]->GetStartDir( vtTg) ; + Vector3d vtOrt = vtTg ; vtOrt.Rotate( vtExtr, 0, 1) ; + Point3d ptArc = ptStart + dDiam * vtOrt ; + Point3d ptLine = ptArc + 5 * dDiam * vtTg ; + PtrOwner pJCrv( CreateCurveComposite()) ; + if ( IsNull( pJCrv)) + return false ; + pJCrv->SetExtrusion( vtExtr) ; + pJCrv->AddPoint( ptLine) ; + pJCrv->AddLine( ptArc) ; + pJCrv->AddArcTg( ptStart) ; + const ICurve* pLCrv = pCompo->GetLastCurve() ; + IntersCurveCurve intCC( *pJCrv, *pLCrv) ; + IntCrvCrvInfo aInfo ; + if ( intCC.GetIntCrvCrvInfo( 0, aInfo)) { + double dUs, dUe ; pCompo->GetDomain( dUs, dUe) ; + pCompo->TrimEndAtParam( dUe - 1 + aInfo.IciB[0].dU) ; + pJCrv->TrimStartAtParam( aInfo.IciA[0].dU) ; + pCompo->AddCurve( ::Release( pJCrv), true, 10 * EPS_SMALL) ; + } + else + pCompo->AddLine( ptStart) ; + } + else + pCompo->AddLine( ptStart) ; + } } // aggiungo la curva pCompo->AddCurve( ::Release( vpCrvs[i]), true, 10 * EPS_SMALL) ; @@ -1303,7 +1359,7 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) pCompo->Close() ; } - // unisco le parti allineate (tranne inizio-fine se chiusa) + // unisco le parti allineate (tranne inizio-fine) if ( ! pCompo->MergeCurves( 10 * EPS_SMALL, 10 * EPS_ANG_SMALL, false)) return false ; @@ -1461,9 +1517,6 @@ Pocketing::ProcessPath( int nPathId, int nPvId, int nClId) m_pGeomDB->SetName( nPxId, sPathName) ; m_pGeomDB->SetMaterial( nPxId, BLUE) ; - // sposto l'inizio a metą del tratto pił lungo - AdjustContourStart( pCompo) ; - // verifico se archi vanno approssimati con segmenti di retta int nSplitArcs = m_pMchMgr->GetCurrMachiningsMgr()->GetSplitArcs() ; bool bSplitArcs = ( nSplitArcs == SPLAR_ALWAYS || diff --git a/Processor.cpp b/Processor.cpp index 8317366..541c7eb 100644 --- a/Processor.cpp +++ b/Processor.cpp @@ -533,6 +533,9 @@ Processor::OnStart( void) bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_RRT, "R") ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FT, "F") ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ST, "S") ; + // variabili di sola lettura + int nSplitArcs = 0 ; m_pMchMgr->MdbGetGeneralParam( MGP_SPLITARCS, nSplitArcs) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SPLITARCS, nSplitArcs) ; // chiamo la funzione bOk = bOk && CallOnStart() ; return bOk ;