From 1097f2a19f77801d64fe615ec214a3cba214c818 Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 21 Jul 2023 15:12:35 +0200 Subject: [PATCH] EgtMachKernel : - semplificazioni con utilizzo di ConvertCurveToComposite. --- Chiseling.cpp | 4 ++-- Milling.cpp | 20 ++++++++++---------- Pocketing.cpp | 28 ++++++++++++++-------------- SawFinishing.cpp | 12 ++++++------ SawRoughing.cpp | 8 ++++---- Sawing.cpp | 4 ++-- SurfFinishing.cpp | 4 ++-- WaterJetting.cpp | 8 ++++---- 8 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Chiseling.cpp b/Chiseling.cpp index cfa1a6a..4651bbd 100644 --- a/Chiseling.cpp +++ b/Chiseling.cpp @@ -1036,8 +1036,8 @@ Chiseling::GetCurves( SelData Id, ICURVEPLIST& lstPC) for ( int nC = nCstart ; nC < nCend ; ++ nC) { // recupero i contorni del chunk for ( int nL = 0 ; nL < pReg->GetLoopCount( nC) ; ++ nL) { - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nC, nL))) + PtrOwner pCrvCompo ; + if ( ! pCrvCompo.Set( ConvertCurveToComposite( pReg->GetLoop( nC, nL)))) return false ; // assegno l'estrusione dalla normale alla regione pCrvCompo->SetExtrusion( vtN) ; diff --git a/Milling.cpp b/Milling.cpp index becae00..ec3e6fd 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -1385,8 +1385,8 @@ Milling::GetCurves( SelData Id, ICURVEPLIST& lstPC) for ( int nC = nCstart ; nC < nCend ; ++ nC) { // recupero i contorni del chunk for ( int nL = 0 ; nL < pReg->GetLoopCount( nC) ; ++ nL) { - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nC, nL))) + PtrOwner pCrvCompo ; + if ( ! pCrvCompo.Set( ConvertCurveToComposite( pReg->GetLoop( nC, nL)))) return false ; // assegno l'estrusione dalla normale alla regione pCrvCompo->SetExtrusion( vtN) ; @@ -4441,7 +4441,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - m_dAddedOverlap - dTang, dU)) { double dParS, dParE ; pCompo->GetDomain( dParS, dParE) ; - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( dU, dParE)))) return false ; } else { @@ -4457,7 +4457,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& else { double dU ; if ( pCompo->GetParamAtLength( m_dAddedOverlap + dTang, dU)) { - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( 0, dU))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( 0, dU)))) return false ; } else { @@ -4492,7 +4492,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& if ( pCompo->GetParamAtLength( dTang, dU)) { double dParS, dParE ; pCompo->GetDomain( dParS, dParE) ; - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dParS, dU))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( dParS, dU)))) return false ; } else { @@ -4505,7 +4505,7 @@ Milling::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - dTang, dU)) { double dParS, dParE ; pCompo->GetDomain( dParS, dParE) ; - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( dU, dParE)))) return false ; } else { @@ -4666,7 +4666,7 @@ Milling::CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vect if ( ! bInvert) { double dU ; if ( pCompo->GetParamAtLength( m_dAddedOverlap + dTang, dU)) { - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( 0, dU))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( 0, dU)))) return false ; } else { @@ -4681,7 +4681,7 @@ Milling::CalcLeadOutEnd( const Point3d& ptEnd, const Vector3d& vtEnd, const Vect if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - m_dAddedOverlap - dTang, dU)) { double dParS, dParE ; pCompo->GetDomain( dParS, dParE) ; - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( dU, dParE)))) return false ; } else { @@ -4797,7 +4797,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d if ( ! bInvert) { double dU ; if ( pCompo->GetParamAtLength( m_dAddedOverlap + dTang, dU)) { - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( 0, dU))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( 0, dU)))) return false ; } else { @@ -4812,7 +4812,7 @@ Milling::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d if ( pCompo->GetLength( dLen) && pCompo->GetParamAtLength( dLen - m_dAddedOverlap - dTang, dU)) { double dParS, dParE ; pCompo->GetDomain( dParS, dParE) ; - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pCompo->CopyParamRange( dU, dParE))) + if ( ! pCrv.Set( ConvertCurveToComposite( pCompo->CopyParamRange( dU, dParE)))) return false ; } else { diff --git a/Pocketing.cpp b/Pocketing.cpp index 929ae0a..3c3ad71 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -1226,8 +1226,8 @@ Pocketing::GetCurves( SelData Id, ICURVEPLIST& lstPC) for ( int nC = nCstart ; nC < nCend ; ++ nC) { // recupero i contorni del chunk for ( int nL = 0 ; nL < pReg->GetLoopCount( nC) ; ++ nL) { - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nC, nL))) + PtrOwner pCrvCompo ; + if ( ! pCrvCompo.Set( ConvertCurveToComposite( pReg->GetLoop( nC, nL)))) return false ; // reset proprietà temporanee ResetCurveAllTempProp( pCrvCompo) ; @@ -2044,8 +2044,8 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con nOffsCrvNbr = 0 ; // setto a zero per non rientrare nel while else { // recupero la prima curva di offset - PtrOwner pOffs( CreateCurveComposite()) ; - if ( IsNull( pOffs) || ! pOffs->AddCurve( OffsCrv.GetLongerCurve())) { + PtrOwner pOffs ; + if ( ! pOffs.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) { m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ; return false ; } @@ -2227,8 +2227,8 @@ Pocketing::AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, con while ( OffsCrv2.GetCurveCount() > 0) { // recupero la prima curva di offset - PtrOwner pOffs2( CreateCurveComposite()) ; - if ( IsNull( pOffs2) || ! pOffs2->AddCurve( OffsCrv2.GetLongerCurve())) { + PtrOwner pOffs2 ; + if ( ! pOffs2.Set( ConvertCurveToComposite( OffsCrv2.GetLongerCurve()))) { m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ; return false ; } @@ -3061,8 +3061,8 @@ Pocketing::AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, con while ( OffsCrv.GetCurveCount() > 0) { // recupero la prima curva di offset - PtrOwner pOffs( CreateCurveComposite()) ; - if ( IsNull( pOffs) || ! pOffs->AddCurve( OffsCrv.GetLongerCurve())) { + PtrOwner pOffs ; + if ( ! pOffs.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) { m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ; return false ; } @@ -3206,8 +3206,8 @@ Pocketing::AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, con // ciclo sulle curve risultanti while ( OffsCrv2.GetCurveCount() > 0) { - PtrOwner pOffs2( CreateCurveComposite()) ; - if ( IsNull( pOffs2) || ! pOffs2->AddCurve( OffsCrv2.GetLongerCurve())) { + PtrOwner pOffs2 ; + if ( ! pOffs2.Set( ConvertCurveToComposite( OffsCrv2.GetLongerCurve()))) { m_pMchMgr->SetLastError( 2413, "Error in Pocketing : Toolpath not computable") ; return false ; } @@ -5262,8 +5262,8 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3 return false ; // eventuale spezzatura if ( bSplitArcs) { - PtrOwner pCompo( CreateCurveComposite()) ; - if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pArc)) || ! ApproxWithLines( pCompo)) + PtrOwner pCompo ; + if ( ! pCompo.Set( ConvertCurveToComposite( Release( pArc))) || ! ApproxWithLines( pCompo)) return false ; return ( AddCurveMove( pCompo, MCH_CL_LEADIN) != GDB_ID_NULL) ; } @@ -5310,7 +5310,7 @@ Pocketing::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3 if ( pRCrv->GetLength( dLen) && pRCrv->GetParamAtLength( dLen - m_Params.m_dLiTang, dU)) { double dParS, dParE ; pRCrv->GetDomain( dParS, dParE) ; - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pRCrv->CopyParamRange( dU, dParE))) + if ( ! pCrv.Set( ConvertCurveToComposite( pRCrv->CopyParamRange( dU, dParE)))) return false ; } else { @@ -5398,7 +5398,7 @@ Pocketing::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector PtrOwner pCrv ; double dU ; if ( pRCrv->GetParamAtLength( m_Params.m_dLoTang, dU)) { - if ( ! pCrv.Set( CreateCurveComposite()) || ! pCrv->AddCurve( pRCrv->CopyParamRange( 0, dU))) + if ( ! pCrv.Set( ConvertCurveToComposite( pRCrv->CopyParamRange( 0, dU)))) return false ; } else { diff --git a/SawFinishing.cpp b/SawFinishing.cpp index 926f96e..849b4ea 100644 --- a/SawFinishing.cpp +++ b/SawFinishing.cpp @@ -982,8 +982,8 @@ SawFinishing::AdjustGeometry( int nAuxId) if ( ! pGuide->IsFlat( plPlane, false, 10 * EPS_SMALL) || ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), Z_AX)) return false ; // verifiche sulla curva (che trasformo in composita) - PtrOwner pCompo( CreateCurveComposite()) ; - if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pGuide))) + PtrOwner pCompo ; + if ( ! pCompo.Set( ConvertCurveToComposite( Release( pGuide)))) return false ; // converto in archi e rette pCompo->ArcsBezierCurvesToArcsPerpExtr( LIN_TOL_MID, ANG_TOL_STD_DEG) ; @@ -2403,8 +2403,8 @@ SawFinishing::CalcCurvedAlongVerticalCuts( ICurve* pSect, int nUmin, int nUmax, Vector3d vtMove = ( dY - m_TParams.m_dThick / 2) * Z_AX ; OffsetCurve OffsCrv ; OffsCrv.Make( pGuide, dOffs, ICurve::OFF_FILLET) ; - PtrOwner pCut( CreateCurveComposite()) ; - if ( IsNull( pCut) || ! pCut->AddCurve( OffsCrv.GetLongerCurve())) + PtrOwner pCut ; + if ( ! pCut.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) return false ; VerifyArcs( pCut) ; pCut->SimpleOffset( SAWRF_OFFS, ICurve::OFF_FORCE_OPEN) ; @@ -2478,8 +2478,8 @@ SawFinishing::CalcCurvedAlongStdCuts( ICurve* pSect, double dUmin, double dUmax, Vector3d vtMove = ( ptP.y - m_TParams.m_dThick / 2) * Z_AX ; OffsetCurve OffsCrv ; OffsCrv.Make( pGuide, dOffs, ICurve::OFF_FILLET) ; - PtrOwner pCut( CreateCurveComposite()) ; - if ( IsNull( pCut) || ! pCut->AddCurve( OffsCrv.GetLongerCurve())) + PtrOwner pCut ; + if ( ! pCut.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) return false ; VerifyArcs( pCut) ; pCut->SimpleOffset( SAWRF_OFFS, ICurve::OFF_FORCE_OPEN) ; diff --git a/SawRoughing.cpp b/SawRoughing.cpp index 6acc7ab..2c32078 100644 --- a/SawRoughing.cpp +++ b/SawRoughing.cpp @@ -940,8 +940,8 @@ SawRoughing::AdjustGeometry( int nAuxId) if ( ! pGuide->IsFlat( plPlane, false, 10 * EPS_SMALL) || ! AreSameOrOppositeVectorApprox( plPlane.GetVersN(), Z_AX)) return false ; // verifiche sulla curva (che trasformo in composita) - PtrOwner pCompo( CreateCurveComposite()) ; - if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pGuide))) + PtrOwner pCompo ; + if ( ! pCompo.Set( ConvertCurveToComposite( Release( pGuide)))) return false ; // converto in archi e rette pCompo->ArcsBezierCurvesToArcsPerpExtr( LIN_TOL_MID, ANG_TOL_STD_DEG) ; @@ -1330,8 +1330,8 @@ SawRoughing::CalculateCurvedToolPath( int nAuxId, int nClId) // creo la curva di taglio OffsetCurve OffsCrv ; OffsCrv.Make( pGuide, dX, ICurve::OFF_FILLET) ; - PtrOwner pCut( CreateCurveComposite()) ; - if ( IsNull( pCut) || ! pCut->AddCurve( OffsCrv.GetLongerCurve())) + PtrOwner pCut ; + if ( ! pCut.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) return false ; VerifyArcs( pCut) ; Vector3d vtMove = ( dY - m_TParams.m_dThick / 2) * Z_AX ; diff --git a/Sawing.cpp b/Sawing.cpp index 976a1e3..5f43449 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -1279,8 +1279,8 @@ Sawing::GetCurve( SelData Id) // recupero l'indice del chunk int nChunk = ( ( Id.nSub == SEL_SUB_ALL) ? 0 : Id.nSub) ; // recupero il contorno esterno del chunk - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo) || ! pCrvCompo->AddCurve( pReg->GetLoop( nChunk, 0))) + PtrOwner pCrvCompo ; + if ( ! pCrvCompo.Set( ConvertCurveToComposite( pReg->GetLoop( nChunk, 0)))) return nullptr ; // recupero la normale della regione Vector3d vtN = pReg->GetNormVersor() ; diff --git a/SurfFinishing.cpp b/SurfFinishing.cpp index 21ee6f3..d3f5649 100644 --- a/SurfFinishing.cpp +++ b/SurfFinishing.cpp @@ -1331,8 +1331,8 @@ SurfFinishing::AddZigZag( ICAvToolSurfTm* pCAvTlStm, const Frame3d& frSurf, bool bStart = true ; while ( OffsCrv.GetCurveCount() > 0) { // recupero la prima curva di offset - PtrOwner pOffs( CreateCurveComposite()) ; - if ( IsNull( pOffs) || ! pOffs->AddCurve( OffsCrv.GetLongerCurve())) { + PtrOwner pOffs ; + if ( ! pOffs.Set( ConvertCurveToComposite( OffsCrv.GetLongerCurve()))) { m_pMchMgr->SetLastError( 3110, "Error in SurfFinishing : Toolpath not computable") ; return false ; } diff --git a/WaterJetting.cpp b/WaterJetting.cpp index cde1c3b..1722d2a 100644 --- a/WaterJetting.cpp +++ b/WaterJetting.cpp @@ -2610,8 +2610,8 @@ WaterJetting::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vect pCrv->Invert() ; // eventuale spezzatura if ( bSplitArcs) { - PtrOwner pCompo( CreateCurveComposite()) ; - if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pCrv)) || ! ApproxWithLines( pCompo)) + PtrOwner pCompo ; + if ( ! pCompo.Set( ConvertCurveToComposite( Release( pCrv))) || ! ApproxWithLines( pCompo)) return false ; return ( AddCurveMove( pCompo, MCH_CL_LEADIN) != GDB_ID_NULL) ; } @@ -2681,8 +2681,8 @@ WaterJetting::AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vec return false ; // eventuale spezzatura if ( bSplitArcs) { - PtrOwner pCompo( CreateCurveComposite()) ; - if ( IsNull( pCompo) || ! pCompo->AddCurve( Release( pCrv)) || ! ApproxWithLines( pCompo)) + PtrOwner pCompo ; + if ( ! pCompo.Set( ConvertCurveToComposite( Release( pCrv))) || ! ApproxWithLines( pCompo)) return false ; return ( AddCurveMove( pCompo, MCH_CL_LEADOUT) != GDB_ID_NULL) ; }