diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 071496c..0f0ab27 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachMgr.h b/MachMgr.h index f76eb5b..4f30aea 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -216,6 +216,7 @@ class MachMgr : public IMachMgr int GetPrevActiveOperation( int nId) const override ; int GetOperationType( int nId) const override ; int GetOperationPhase( int nId) const override ; + bool SetOperationName( int nId, const std::string& sName) override ; std::string GetOperationName( int nId) const override ; int GetOperationId( const std::string& sName) const override ; bool IsOperationEmpty( int nId) const override ; diff --git a/MachMgrOperations.cpp b/MachMgrOperations.cpp index a02d357..6f13b86 100644 --- a/MachMgrOperations.cpp +++ b/MachMgrOperations.cpp @@ -204,14 +204,32 @@ MachMgr::GetOperationNewName( string& sName) const } //---------------------------------------------------------------------------- -std::string +bool +MachMgr::SetOperationName( int nId, const string& sName) +{ + // recupero l'operazione + PtrOwner 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 ;