From 6238ea10957f68afcba3c2478264fa27da49f9fa Mon Sep 17 00:00:00 2001 From: DarioS Date: Wed, 17 Aug 2022 19:17:44 +0200 Subject: [PATCH] EgtGeomKernel 2.4h1 : - in BBox3d aggiunti GetDimX, GetDimY e GetDimZ - corretta DistLineLine con parametri punti estremi - in creazione Stm da due curve (rigata) aggiunta gestione tipo RLT_ISOPAR_SMOOTH. --- BBox3d.cpp | 31 +++++++++++++++++-- DistLineLine.cpp | 32 +++++++++++--------- EgtGeomKernel.rc | Bin 11718 -> 11718 bytes GeoConst.h | 8 +++-- SurfTriMesh.cpp | 64 ++++++++++++++++++++++++++++++++++++---- SurfTriMeshFaceting.cpp | 2 +- 6 files changed, 113 insertions(+), 24 deletions(-) diff --git a/BBox3d.cpp b/BBox3d.cpp index 74271e0..12b14fe 100644 --- a/BBox3d.cpp +++ b/BBox3d.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2013-2013 +// EgalTech 2014-2022 //---------------------------------------------------------------------------- -// File : BBox3d.cpp Data : 14.01.14 Versione : 1.5a3 +// File : BBox3d.cpp Data : 17.08.22 Versione : 2.4h1 // Contenuto : Implementazione della classe axis aligned bounding box BBox3d. // // @@ -210,6 +210,33 @@ BBox3d::GetMinDim( Point3d& ptMin, double& dDimX, double& dDimY, double& dDimZ) return true ; } +//---------------------------------------------------------------------------- +double +BBox3d::GetDimX( void) const +{ + if ( ! IsValid()) + return 0 ; + return ( m_ptMax.x - m_ptMin.x) ; +} + +//---------------------------------------------------------------------------- +double +BBox3d::GetDimY( void) const +{ + if ( ! IsValid()) + return 0 ; + return ( m_ptMax.y - m_ptMin.y) ; +} + +//---------------------------------------------------------------------------- +double +BBox3d::GetDimZ( void) const +{ + if ( ! IsValid()) + return 0 ; + return ( m_ptMax.z - m_ptMin.z) ; +} + //---------------------------------------------------------------------------- bool BBox3d::GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const diff --git a/DistLineLine.cpp b/DistLineLine.cpp index eab126b..f915d9a 100644 --- a/DistLineLine.cpp +++ b/DistLineLine.cpp @@ -1,13 +1,13 @@ //---------------------------------------------------------------------------- -// EgalTech 2020-2020 +// EgalTech 2020-2022 //---------------------------------------------------------------------------- -// File : DistLineLine.h Data : 06.11.20 Versione : 2.2k1 +// File : DistLineLine.h Data : 12.08.22 Versione : 2.4h1 // Contenuto : Implementazione della classe distanza fra elementi lineari. // // // // Modifiche : 06.11.20 LM Creazione modulo. -// +// 12.08.22 DS Correzioni e migliorie varie. // //---------------------------------------------------------------------------- @@ -25,17 +25,19 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Point3d& ptEn1, const Point3d& ptSt2, const Point3d& ptEn2, bool bIsSegment1, bool bIsSegment2) { + // reset oggetto + m_dSqDist = - 1 ; + m_dDist = - 1 ; + // calcolo direzione segmenti Vector3d vtD1 = ptEn1 - ptSt1 ; double dLen1 = vtD1.Len() ; Vector3d vtD2 = ptEn2 - ptSt2 ; - double dLen2 = vtD1.Len() ; - if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) { - m_dSqDist = - 1 ; - m_dDist = - 1 ; + double dLen2 = vtD2.Len() ; + if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) return ; - } vtD1 /= dLen1 ; vtD2 /= dLen2 ; + // eseguo Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ; } @@ -45,11 +47,13 @@ DistLineLine::DistLineLine( const Point3d& ptSt1, const Vector3d& vtD1, double d const Point3d& ptSt2, const Vector3d& vtD2, double dLen2, bool bIsSegment1, bool bIsSegment2) { - if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) { - m_dSqDist = - 1 ; - m_dDist = - 1 ; + // reset oggetto + m_dSqDist = - 1 ; + m_dDist = - 1 ; + // verifico segmenti + if ( dLen1 < EPS_SMALL || dLen2 < EPS_SMALL) return ; - } + // eseguo Calculate( ptSt1, vtD1, dLen1, ptSt2, vtD2, dLen2, bIsSegment1, bIsSegment2) ; } @@ -193,8 +197,8 @@ DistLineLine::Calculate( const Point3d& ptSt1, const Vector3d& vtD1, double dLen double dDist01 = vtStSt * vtD1 ; double dDist02 = vtStSt * vtD2 ; double dDotD1D2 = vtD1 * vtD2 ; - double dT1 = dDist01 + ( ( dDist01 * dDotD1D2 - dDist02) * dDotD1D2) / ( 1 - dDotD1D2 * dDotD1D2) ; - double dT2 = ( dDist01 * dDotD1D2 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ; + double dT1 = ( dDist01 - dDotD1D2 * dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ; + double dT2 = ( dDotD1D2 * dDist01 - dDist02) / ( 1 - dDotD1D2 * dDotD1D2) ; // Posizioni minime e massime sui segmenti double dMin1 = ( bIsSegment1 ? 0 : -INFINITO) ; double dMax1 = ( bIsSegment1 ? dLen1 : INFINITO) ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index dc4787c649f1e22ef4f9d5bbf183012a8d512df5..63ee3acbc242765f731015edef77f947e3bbec29 100644 GIT binary patch delta 287 zcmX>WeJpyzI%aKGhCGIJh8%`WhGK>c1_cHUhESkLCPN8BDnkm89}HwAf_cT0FKS6| z{=m${%xb})!(h1iw%B>5$yHoBlN&fWCja7;Va{MMoP1DFce5K;4+~t4H8Vn7%7bxp zm#`1Q02E0iO*jlzQ?et~#Rn(f)0sEWeJpyzI%aiGhCGIJh8%`ehGHOAV9;O)W+-7u1ma8}FBB-731Uyas3kpFPd#gM z9Lo$QR&xd&2II~5#m+NLuH({~{EbtEIi10HvLd(cW-qQD7P!1MGeTU-gK=}8un#kK zNhD2J4AoMyBgLf$C*RYVH~EvAh+sb0N1k9G2=d2fJ@skKm{OZBYJFt_0G2LD APXGV_ diff --git a/GeoConst.h b/GeoConst.h index 30c8a3f..864a744 100644 --- a/GeoConst.h +++ b/GeoConst.h @@ -50,7 +50,11 @@ const double BEZARC_ANG_CEN_MAX = 90 ; //----------------- Costanti per superfici TriMesh --------------------------- // tolleranza lineare standard const double STM_STD_LIN_TOL = 0.1 ; -// angolo limite per definire un edge che è contorno di poligono +// angolo limite standard per definire un edge che è contorno di poligono const double STM_STD_BOUNDARY_ANG = 0.1 ; -// angolo limite per mediare le normali in un vertice +// angolo limite standard per mediare le normali in un vertice const double STM_STD_SMOOTH_ANG = 25.0 ; +// distanza limite tra diagonali per quadrilatero con twist +const double STM_TWIST_DIAG_DIST = 1.0 ; +// angolo limite con twist per mediare le normali in un vertice +const double STM_TWIST_SMOOTH_ANG = 35.0 ; diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index ed6a5be..7800461 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2014-2019 +// EgalTech 2014-2022 //---------------------------------------------------------------------------- -// File : SurfTriMesh.cpp Data : 02.01.19 Versione : 1.9l4 +// File : SurfTriMesh.cpp Data : 12.08.22 Versione : 2.4h1 // Contenuto : Implementazione della classe Superfici TriMesh. // // @@ -20,6 +20,7 @@ #include "NgeReader.h" #include "SurfFlatRegion.h" #include "DistPointLine.h" +#include "DistLineLine.h" #include "Triangulate.h" #include "GeoConst.h" #include "/EgtDev/Include/EGkIntersLinePlane.h" @@ -2207,7 +2208,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR } // ciclo sui punti while ( bNext1 || bNext2) { - // se c'è nuovo V1s e la diagonale più corta è V2p -> V1s oppure non c'è V2s + // se non c'è V2s oppure c'è nuovo V1s e la diagonale più corta è V2p -> V1s if ( ! bNext2 || ( bNext1 && ( nP1s == vPnt2[nP2p].second || vPnt1[nP1s].second == nP2p))) { // inserisco il vertice V1s (se ultimo e curve chiuse, prendo il primo) if ( nP1s == nTotP1 - 1 && bClosed) @@ -2275,6 +2276,7 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR return false ; // costruisco la mesh + bool bTwist = false ; int nVertNbr = PL1.GetPointNbr() + PL2.GetPointNbr() ; int nTriaNbr = max( PL1.GetPointNbr(), PL2.GetPointNbr()) + 1 ; if ( ! Init( nVertNbr, nTriaNbr)) @@ -2331,8 +2333,57 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR } // ciclo sui punti while ( bNext1 || bNext2) { - // se c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s oppure non c'è dA2s - if ( ( bNext1 && ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM) || ! bNext2) { + // se richiesto smoothing, ci sono entrambi i successivi, hanno circa lo stesso parametro e i segmenti sono sghembi oltre il limite + double dDiagDist = 0 ; + if ( nRuledType == RLT_ISOPAR_SMOOTH && + bNext1 && bNext2 && abs( dA1p + dA1s - dA2p - dA2s) < min( dA1s - dA1p, dA2s - dA2p) && + DistLineLine( ptP1p, ptP2s, ptP2p, ptP1s).GetDist( dDiagDist) && dDiagDist > STM_TWIST_DIAG_DIST) { + bTwist = true ; + // inserisco il vertice A1s + if ( ( nV1s = AddVertex( ptP1s)) == SVT_NULL) + return false ; + // inserisco il vertice A2s + if ( ( nV2s = AddVertex( ptP2s)) == SVT_NULL) + return false ; + // inserisco un nuovo vertice punto medio della linea tra i punti medi + Point3d ptCen = ( ptP1s + ptP1p + ptP2s + ptP2p) / 4 ; + int nVCen = AddVertex( ptCen) ; + if ( nVCen == SVT_NULL) + return false ; + // creo 4 triangoli dai lati del quadrilatero al vertice + nIdV[0] = nV2p ; + nIdV[1] = nV1p ; + nIdV[2] = nVCen ; + if ( AddTriangle( nIdV) == SVT_NULL) + return false ; + nIdV[0] = nV1p ; + nIdV[1] = nV1s ; + nIdV[2] = nVCen ; + if ( AddTriangle( nIdV) == SVT_NULL) + return false ; + nIdV[0] = nV1s ; + nIdV[1] = nV2s ; + nIdV[2] = nVCen ; + if ( AddTriangle( nIdV) == SVT_NULL) + return false ; + nIdV[0] = nV2s ; + nIdV[1] = nV2p ; + nIdV[2] = nVCen ; + if ( AddTriangle( nIdV) == SVT_NULL) + return false ; + // passo al punto successivo su 1 + nV1p = nV1s ; dA1p = dA1s ; dU1p = dU1s ; ptP1p = ptP1s ; + bNext1 = PL1.GetNextUPoint( &dU1s, &ptP1s, bClosed) ; + if ( bNext1) + dA1s = ( dU1s - dU1F) / dDeltaU1 ; + // passo al punto successivo su 2 + nV2p = nV2s ; dA2p = dA2s ; dU2p = dU2s ; ptP2p = ptP2s ; + bNext2 = PL2.GetNextUPoint( &dU2s, &ptP2s, bClosed) ; + if ( bNext2) + dA2s = ( dU2s - dU2F) / dDeltaU2 ; + } + // se non c'è dA2s oppure c'è nuovo dA1s e la diagonale più corta è dA2p -> dA1s + else if ( ! bNext2 || ( bNext1 && ( dA1s - dA2p) <= ( dA2s - dA1p) + EPS_PARAM)) { // inserisco il vertice A1s if ( ( nV1s = AddVertex( ptP1s)) == SVT_NULL) return false ; @@ -2415,6 +2466,9 @@ SurfTriMesh::CreateByTwoCurves( const PolyLine& PL1, const PolyLine& PL2, int nR return false ; } } + // in presenza di twist aumento il limite sulla deviazione angolare + if ( bTwist) + SetSmoothAngle( STM_TWIST_SMOOTH_ANG) ; } // sistemo la topologia diff --git a/SurfTriMeshFaceting.cpp b/SurfTriMeshFaceting.cpp index 678b62c..363325b 100644 --- a/SurfTriMeshFaceting.cpp +++ b/SurfTriMeshFaceting.cpp @@ -7,7 +7,7 @@ // // // Modifiche : 26.03.14 DS Creazione modulo. -// 15.05.14 DS Corr. errore CreateByTwoCurves che dava loop infinito. +// // //----------------------------------------------------------------------------