From ce139c6925fa505c6fc4e158139a7020ba4c633e Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 27 Feb 2024 18:18:13 +0100 Subject: [PATCH 1/2] EgtGeomKernel 2.6b4 : - aggiunta funzione GetSurfTriMeshTransSwept per creare superficie swept di traslazione. --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes StmFromCurves.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 74c82b1550dabe170620fe801c82970f70d013c0..77ada765245526139f2ba376a847c4665fcae96b 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&P#&A-_cnHfzcD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-WjGrO delta 94 zcmdlNy)SyhFE&Qw&A-_cnHh~ID{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-W11TR diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index 971eb26..0af869f 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -750,6 +750,91 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d return Release( pSTM) ; } +//------------------------------------------------------------------------------- +ISurfTriMesh* +GetSurfTriMeshTransSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol) +{ + // verifica parametri + if ( pSect == nullptr || pGuide == nullptr) + return nullptr ; + // determino se la sezione è chiusa + bool bSectClosed = pSect->IsClosed() ; + // punto iniziale della sezione e vettore a inizio guida + Point3d ptStart ; + if ( ! pSect->GetStartPoint( ptStart)) + return nullptr ; + Point3d ptGuide ; + if ( ! pGuide->GetStartPoint( ptGuide)) + return nullptr ; + Vector3d vtDelta = ptStart - ptGuide ; + // calcolo la polilinea che approssima la guida + PolyLine PLG ; + if ( ! pGuide->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLG)) + return nullptr ; + // determino se la guida è chiusa + bool bGuideClosed = PLG.IsClosed() ; + // calcolo la superficie + PtrOwner pSTM( CreateBasicSurfTriMesh()) ; + if ( IsNull( pSTM)) + return nullptr ; + // salvo tolleranza lineare usata + pSTM->SetLinearTolerance( dLinTol) ; + // superficie swept + PtrOwner pPrevCrv ; + Point3d ptP ; + bool bPoint = PLG.GetFirstPoint( ptP) ; + while ( bPoint) { + // nuova curva + PtrOwner pCurrCrv( pSect->Clone()) ; + if ( IsNull( pCurrCrv)) + return nullptr ; + pCurrCrv->Translate( ptP - ptStart + vtDelta) ; + // se esiste la curva precedente, costruisco la rigata (di tipo minima distanza) + if ( ! IsNull( pPrevCrv)) { + PtrOwner pSr( GetSurfTriMeshRuled( pPrevCrv, pCurrCrv, ISurfTriMesh::RLT_ISOPAR, dLinTol)) ; + if ( IsNull( pSr)) + return nullptr ; + pSTM->DoSewing( *pSr) ; + } + // salvo la curva come prossima precedente + pPrevCrv.Set( pCurrCrv) ; + // prossimo punto + bPoint = PLG.GetNextPoint( ptP) ; + } + // se richiesti caps e sezione chiusa e guida aperta + if ( bCapEnds && bSectClosed && ! bGuideClosed) { + // calcolo la polilinea che approssima la sezione + PolyLine PLS ; + if ( ! pSect->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLS)) + return nullptr ; + // verifico che la sezione sia chiusa e piatta + Plane3d plSect ; double dArea ; + if ( PLS.IsClosedAndFlat( plSect, dArea, 100 * EPS_SMALL)) { + // aggiungo il cap sull'inizio + PtrOwner pSci( CreateBasicSurfTriMesh()) ; + if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PLS)) + return nullptr ; + pSci->Invert() ; + Point3d ptGi ; PLG.GetFirstPoint( ptGi) ; + pSci->Translate( ptGi - ptStart + vtDelta) ; + pSTM->DoSewing( *pSci) ; + // aggiungo il cap sulla fine + PtrOwner pSce( CreateBasicSurfTriMesh()) ; + if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PLS)) + return nullptr ; + Point3d ptGe ; PLG.GetLastPoint( ptGe) ; + pSce->Translate( ptGe - ptStart + vtDelta) ; + pSTM->DoSewing( *pSce) ; + } + } + // se superficie risultante chiusa, verifico che la normale sia verso l'esterno + double dVol ; + if ( pSTM->GetVolume( dVol) && dVol < 0) + pSTM->Invert() ; + // restituisco la superficie + return Release( pSTM) ; +} + //------------------------------------------------------------------------------- ISurfTriMesh* GetSurfTriMeshRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol) From aea99a635f42161c34ea47475115516c66d07ff5 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 27 Feb 2024 18:25:01 +0100 Subject: [PATCH 2/2] EgtGeomKernel : - eliminati salvataggi di debug dalle booleanne delle trimesh. --- SurfTriMeshBooleans.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SurfTriMeshBooleans.cpp b/SurfTriMeshBooleans.cpp index 3d3d48b..742d316 100644 --- a/SurfTriMeshBooleans.cpp +++ b/SurfTriMeshBooleans.cpp @@ -35,7 +35,6 @@ #include "/EgtDev/Include/EGkPolygon3d.h" #include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/EGkGeoObjSave.h" #include using namespace std ; @@ -1486,9 +1485,6 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other) if ( bModif) bContinue = ( AdjustVertices() && DoCompacting() && SurfB.AdjustVertices() && SurfB.DoCompacting()) ; - SaveGeoObj( this, "C:\\Users\\riccardo.elitropi\\Desktop\\SurfA.nge") ; - SaveGeoObj( SurfB.Clone(), "C:\\Users\\riccardo.elitropi\\Desktop\\SurfB.nge") ; - // Triangoli sovrapposti if ( bContinue) { int nTriaNum2A = GetTriangleSize() ;