From ea786599a4fc1c83550d8fedce7226ee324c5574 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 28 Nov 2020 18:53:38 +0000 Subject: [PATCH] EgtMachKernel : - aggiunte AuxView in Milling e Mortising (per indicare il lato di riferimento della eventuale faccia lavorata). --- Milling.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- Milling.h | 1 + Mortising.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- Mortising.h | 1 + 4 files changed, 94 insertions(+), 6 deletions(-) diff --git a/Milling.cpp b/Milling.cpp index 7815d28..badb74e 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -730,6 +730,22 @@ Milling::Apply( bool bRecalc, bool bPostApply) bChain = true ; } + // recupero gruppo per vista ausiliaria + int nAuxViewId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUXVIEW) ; + // se non c'è, lo aggiungo + if ( nAuxViewId == GDB_ID_NULL) { + nAuxViewId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; + if ( nAuxViewId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nAuxViewId, MCH_AUXVIEW) ; + m_pGeomDB->SetMaterial( nAuxViewId, Color( 64, 0, 0)) ; + m_pGeomDB->SetStatus( nAuxViewId, GDB_ST_OFF) ; + } + // altrimenti, se necessario chain, lo svuoto + else if ( bChain) { + m_pGeomDB->EmptyGroup( nAuxViewId) ; + } + // rendo corrente l'utensile usato nella lavorazione if ( ! m_pMchMgr->SetCalcTool( m_TParams.m_sName, m_TParams.m_sHead, m_TParams.m_nExit)) { m_pMchMgr->SetLastError( 2322, "Error in Milling : Tool loading failed") ; @@ -756,9 +772,12 @@ Milling::Apply( bool bRecalc, bool bPostApply) m_pGeomDB->EmptyGroup( nClId) ; // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria - if ( bChain && ! Chain( nAuxId)) { - m_pMchMgr->SetLastError( 2315, "Error in Milling : Chaining failed") ; - return false ; + if ( bChain) { + if ( ! Chain( nAuxId)) { + m_pMchMgr->SetLastError( 2315, "Error in Milling : Chaining failed") ; + return false ; + } + CalcSurfAuxView( nAuxId, nAuxViewId) ; } // lavoro ogni singola catena @@ -1485,6 +1504,30 @@ Milling::AdjustArcCenterForAxesCalc( const CamData* pCamData, Point3d& ptCen) co return true ; } +//---------------------------------------------------------------------------- +bool +Milling::CalcSurfAuxView( int nAuxId, int nAuxViewId) +{ + const double FAT_RAD = 0.5 ; + if ( m_Params.m_nFaceUse != MILL_FU_NONE) { + int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ; + while ( nPathId != GDB_ID_NULL) { + int nCrvId = m_pGeomDB->GetFirstInGroup( nPathId) ; + const ICurve* pCrv = ::GetCurve( m_pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCrv == nullptr) + continue ; + ISurfFlatRegion* pSfr = GetSurfFlatRegionFromFatCurve( pCrv->Clone(), FAT_RAD, false, false) ; + if ( pSfr == nullptr) + continue ; + int nSfrId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nAuxViewId, pSfr) ; + if ( nSfrId == GDB_ID_NULL) + continue ; + nPathId = m_pGeomDB->GetNextGroup( nPathId) ; + } + } + return true ; +} + //---------------------------------------------------------------------------- bool Milling::ProcessPath( int nPathId, int nPvId, int nClId) diff --git a/Milling.h b/Milling.h index e750bbd..4ba7837 100644 --- a/Milling.h +++ b/Milling.h @@ -80,6 +80,7 @@ class Milling : public Machining bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ; bool GetCurves( SelData Id, ICURVEPLIST& lstPC) ; bool Chain( int nGrpDestId) ; + bool CalcSurfAuxView( int nAuxId, int nAuxViewId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; bool AdjustPathDrawForSaw( int nClPathId) ; bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ; diff --git a/Mortising.cpp b/Mortising.cpp index 58dcaa8..de341a6 100644 --- a/Mortising.cpp +++ b/Mortising.cpp @@ -548,6 +548,22 @@ Mortising::Apply( bool bRecalc, bool bPostApply) bChain = true ; } + // recupero gruppo per vista ausiliaria + int nAuxViewId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUXVIEW) ; + // se non c'è, lo aggiungo + if ( nAuxViewId == GDB_ID_NULL) { + nAuxViewId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ; + if ( nAuxViewId == GDB_ID_NULL) + return false ; + m_pGeomDB->SetName( nAuxViewId, MCH_AUXVIEW) ; + m_pGeomDB->SetMaterial( nAuxViewId, Color( 64, 0, 0)) ; + m_pGeomDB->SetStatus( nAuxViewId, GDB_ST_OFF) ; + } + // altrimenti, se necessario chain, lo svuoto + else if ( bChain) { + m_pGeomDB->EmptyGroup( nAuxViewId) ; + } + // recupero gruppo per geometria di lavorazione (Cutter Location) int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ; // se non c'è, lo aggiungo @@ -562,9 +578,12 @@ Mortising::Apply( bool bRecalc, bool bPostApply) m_pGeomDB->EmptyGroup( nClId) ; // se necessario, eseguo concatenamento ed inserisco i percorsi sotto la geometria ausiliaria - if ( bChain && ! Chain( nAuxId)) { - m_pMchMgr->SetLastError( 2506, "Error in Mortising : Chaining failed") ; - return false ; + if ( bChain) { + if ( ! Chain( nAuxId)) { + m_pMchMgr->SetLastError( 2506, "Error in Mortising : Chaining failed") ; + return false ; + } + CalcSurfAuxView( nAuxId, nAuxViewId) ; } // lavoro ogni singola catena @@ -1080,6 +1099,30 @@ Mortising::Chain( int nGrpDestId) return true ; } +//---------------------------------------------------------------------------- +bool +Mortising::CalcSurfAuxView( int nAuxId, int nAuxViewId) +{ + const double FAT_RAD = 0.5 ; + if ( m_Params.m_nFaceUse != MILL_FU_NONE) { + int nPathId = m_pGeomDB->GetFirstGroupInGroup( nAuxId) ; + while ( nPathId != GDB_ID_NULL) { + int nCrvId = m_pGeomDB->GetFirstInGroup( nPathId) ; + const ICurve* pCrv = ::GetCurve( m_pGeomDB->GetGeoObj( nCrvId)) ; + if ( pCrv == nullptr) + continue ; + ISurfFlatRegion* pSfr = GetSurfFlatRegionFromFatCurve( pCrv->Clone(), FAT_RAD, false, false) ; + if ( pSfr == nullptr) + continue ; + int nSfrId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nAuxViewId, pSfr) ; + if ( nSfrId == GDB_ID_NULL) + continue ; + nPathId = m_pGeomDB->GetNextGroup( nPathId) ; + } + } + return true ; +} + //---------------------------------------------------------------------------- bool Mortising::ProcessPath( int nPathId, int nPvId, int nClId) diff --git a/Mortising.h b/Mortising.h index dd30615..73a69ae 100644 --- a/Mortising.h +++ b/Mortising.h @@ -70,6 +70,7 @@ class Mortising : public Machining bool VerifyGeometry( SelData Id, int& nSubs, int& nType) ; ICurve* GetCurve( SelData Id) ; bool Chain( int nGrpDestId) ; + bool CalcSurfAuxView( int nAuxId, int nAuxViewId) ; bool ProcessPath( int nPathId, int nPvId, int nClId) ; bool CalcPathElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double dThick, double& dElev) const ; bool GenerateMortisingPv( int nPathId, const ICurveComposite* pCompo) ;