diff --git a/Chiseling.cpp b/Chiseling.cpp index 16d3ad8..265699a 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -79,10 +79,12 @@ Chiseling::Clone( void) const // eseguo copia dei dati if ( pChisel != nullptr) { try { + pChisel->m_vId = m_vId ; pChisel->m_pMchMgr = m_pMchMgr ; pChisel->m_nPhase = m_nPhase ; pChisel->m_Params = m_Params ; pChisel->m_TParams = m_TParams ; + pChisel->m_nChisels = m_nChisels ; } catch( ...) { delete pChisel ; diff --git a/Drilling.cpp b/Drilling.cpp index 3f4c215..ac44fd8 100644 --- a/Drilling.cpp +++ b/Drilling.cpp @@ -79,10 +79,12 @@ Drilling::Clone( void) const // eseguo copia dei dati if ( pDri != nullptr) { try { + pDri->m_vId = m_vId ; pDri->m_pMchMgr = m_pMchMgr ; pDri->m_nPhase = m_nPhase ; pDri->m_Params = m_Params ; pDri->m_TParams = m_TParams ; + pDri->m_nDrillings = m_nDrillings ; } catch( ...) { delete pDri ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 0512184..071496c 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Machining.cpp b/Machining.cpp index 107ac39..0e064fc 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -224,14 +224,20 @@ Machining::ToolPreview( int nEntId, int nFlag) const // verifico validità gestori DB geometrico e CAM if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) return GDB_ID_NULL ; + // recupero la testa nel gruppo per anteprima utensile + int nId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST)) ; + if ( nId == GDB_ID_NULL) + return GDB_ID_NULL ; + m_pGeomDB->SetStatus( nId, GDB_ST_OFF) ; // recupero gruppo per geometria di lavorazione (Cutter Location) int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; if ( nClId == GDB_ID_NULL) return GDB_ID_NULL ; + int nParentId ; // se entità nulla if ( nEntId == GDB_ID_NULL || ! m_pGeomDB->ExistsObj( nEntId)) { // recupero il gruppo di appartenenza - int nParentId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; + nParentId = m_pGeomDB->GetFirstGroupInGroup( nClId) ; // se richiesta successiva if ( nFlag == MCH_TPM_AFTER) nEntId = GetToolPreviewNext( m_pGeomDB, nEntId, nParentId) ; @@ -245,7 +251,7 @@ Machining::ToolPreview( int nEntId, int nFlag) const // altrimenti else { // verifico che l'entità stia in un sottogruppo di CL - int nParentId = m_pGeomDB->GetParentId( nEntId) ; + nParentId = m_pGeomDB->GetParentId( nEntId) ; if ( m_pGeomDB->GetParentId( nParentId) == nClId) { // se richiesta successiva if ( nFlag == MCH_TPM_AFTER) @@ -257,6 +263,9 @@ Machining::ToolPreview( int nEntId, int nFlag) const else nEntId = GDB_ID_NULL ; } + // se esiste il gruppo genitore, visualizzo testa preview + if ( nParentId != GDB_ID_NULL) + m_pGeomDB->SetStatus( nId, GDB_ST_ON) ; // recupero i dati di questa entità const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ; if ( pCamData == nullptr) @@ -265,11 +274,6 @@ Machining::ToolPreview( int nEntId, int nFlag) const AdjustEndPointForAxesCalc( pCamData, ptEnd) ; Vector3d vtTool = pCamData->GetToolDir() ; Vector3d vtBAux = pCamData->GetBackAuxDir() ; - // recupero la testa nel gruppo per anteprima utensile - int nId = m_pGeomDB->GetFirstGroupInGroup( m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST)) ; - if ( nId == GDB_ID_NULL) - return GDB_ID_NULL ; - m_pGeomDB->SetStatus( nId, GDB_ST_ON) ; // dati correnti testa/uscita int nExitId = m_pGeomDB->GetFirstNameInGroup( nId, MCH_EXIT + ToString( GetExitNbr())) ; Frame3d frExit ; diff --git a/Milling.cpp b/Milling.cpp index 11bd988..ba03166 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -77,10 +77,12 @@ Milling::Clone( void) const // eseguo copia dei dati if ( pMill != nullptr) { try { + pMill->m_vId = m_vId ; pMill->m_pMchMgr = m_pMchMgr ; pMill->m_nPhase = m_nPhase ; pMill->m_Params = m_Params ; pMill->m_TParams = m_TParams ; + pMill->m_nMills = m_nMills ; } catch( ...) { delete pMill ; diff --git a/Mortising.cpp b/Mortising.cpp index 7c4a877..0deb1d9 100644 --- a/Mortising.cpp +++ b/Mortising.cpp @@ -66,10 +66,12 @@ Mortising::Clone( void) const // eseguo copia dei dati if ( pMort != nullptr) { try { + pMort->m_vId = m_vId ; pMort->m_pMchMgr = m_pMchMgr ; pMort->m_nPhase = m_nPhase ; pMort->m_Params = m_Params ; pMort->m_TParams = m_TParams ; + pMort->m_nMortises = m_nMortises ; } catch( ...) { delete pMort ; diff --git a/Operation.cpp b/Operation.cpp index 3a5875c..81b8d19 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -679,7 +679,7 @@ Operation::ApproxWithArcsIfUseful( ICurveComposite* pCompo) double dLen = 0 ; pCompo->GetLength( dLen) ; int nCrvs = pCompo->GetCurveCount() ; - if ( nCrvs < 5 || dLen > nCrvs * LIN_FEA_STD) + if ( nCrvs < 10 || dLen > nCrvs * LIN_FEA_STD) return true ; // limito l'approssimazione alle curve piane Frame3d frRef ; diff --git a/Pocketing.cpp b/Pocketing.cpp index 1a10371..5033e79 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -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 ; diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 1ef9bc4..3d74275 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -80,10 +80,12 @@ SawFinishing::Clone( void) const // eseguo copia dei dati if ( pSaw != nullptr) { try { + pSaw->m_vId = m_vId ; pSaw->m_pMchMgr = m_pMchMgr ; pSaw->m_nPhase = m_nPhase ; pSaw->m_Params = m_Params ; pSaw->m_TParams = m_TParams ; + pSaw->m_nCuts = m_nCuts ; } catch( ...) { delete pSaw ; diff --git a/SawRoughing.cpp b/SawRoughing.cpp index d3c4104..445b0f0 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -73,10 +73,12 @@ SawRoughing::Clone( void) const // eseguo copia dei dati if ( pSaw != nullptr) { try { + pSaw->m_vId = m_vId ; pSaw->m_pMchMgr = m_pMchMgr ; pSaw->m_nPhase = m_nPhase ; pSaw->m_Params = m_Params ; pSaw->m_TParams = m_TParams ; + pSaw->m_nCuts = m_nCuts ; } catch( ...) { delete pSaw ; diff --git a/Sawing.cpp b/Sawing.cpp index 6673cc3..15442c2 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -84,10 +84,12 @@ Sawing::Clone( void) const // eseguo copia dei dati if ( pSaw != nullptr) { try { + pSaw->m_vId = m_vId ; pSaw->m_pMchMgr = m_pMchMgr ; pSaw->m_nPhase = m_nPhase ; pSaw->m_Params = m_Params ; pSaw->m_TParams = m_TParams ; + pSaw->m_nCuts = m_nCuts ; } catch( ...) { delete pSaw ;