From 4f0a1460fdc4a29d162feee24344450d3c647539 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 13 Jun 2022 20:13:50 +0200 Subject: [PATCH] EgtGeomKernel 2.4f2 : - nell'intersezione tra un piano e una superficie trimesh forzo il risultato a stare esattamente nel piano. --- EgtGeomKernel.rc | Bin 11718 -> 11718 bytes IntersPlaneSurfTm.cpp | 31 ++++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 80e1d54522e157d6de6459e597b5757d7d333c1e..bfe11262f44aa9bc70984e943f2caa36083fd034 100644 GIT binary patch delta 100 zcmX>WeJpyzFE&P_&G*I5Gfl4J(wY2?Q;pGRvLd(cW-qP@EMOU1W|)YS2jk{G;Q$~X Qr~yeBsu05nEu}f!0J&5j?f?J) delta 100 zcmX>WeJpyzFE&QQ&G*I5Gfl4J(wY2?Q;pGZvLd(cW-qP@EMOU1W|)YS2jk{G;Q$~X Qr~yeBsu05nEu}f!0Jpp!<^TWy diff --git a/IntersPlaneSurfTm.cpp b/IntersPlaneSurfTm.cpp index dfdfc5c..fc29405 100644 --- a/IntersPlaneSurfTm.cpp +++ b/IntersPlaneSurfTm.cpp @@ -27,7 +27,7 @@ using namespace std ; //---------------------------------------------------------------------------- -void +static void UpdateIntersPlaneSurfTm( const Plane3d& plPlane, const Triangle3d& Tria, PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria, PointGrid3d& PtGrid, HashGrids3d& LnGrid, HashGrids3d& TrGrid) { @@ -109,8 +109,9 @@ UpdateIntersPlaneSurfTm( const Plane3d& plPlane, const Triangle3d& Tria, PNTVECT } //---------------------------------------------------------------------------- -void -AdjustIntersPlaneSurfTm( PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, const TRIA3DVECTOR& vTria, const HashGrids3d& LnGrid, const HashGrids3d& TrGrid) +static void +AdjustIntersPlaneSurfTm( PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria, + const Plane3d& plPlane, const HashGrids3d& LnGrid, const HashGrids3d& TrGrid) { // rimuovo i punti che stanno sui segmenti for ( int i = int( vPnt.size()) - 1 ; i >= 0 ; -- i) { @@ -173,6 +174,26 @@ AdjustIntersPlaneSurfTm( PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, const TRIA3DVECTOR& vBpt.erase( vBpt.begin() + i) ; } + // porto i punti esattamente nel piano + for ( int i = 0 ; i < int( vPnt.size()) ; ++ i) { + vPnt[i] = ProjectPointOnPlane( vPnt[i], plPlane) ; + } + + // porto i segmenti esattamente nel piano + for ( int i = 0 ; i < int( vBpt.size()) ; ++ i) { + vBpt[i].first = ProjectPointOnPlane( vBpt[i].first, plPlane) ; + vBpt[i].second = ProjectPointOnPlane( vBpt[i].second, plPlane) ; + } + + // porto i triangoli esattamente nel piano + for ( int i = 0 ; i < int( vTria.size()) ; ++ i) { + Triangle3d& trTria = vTria[i] ; + trTria.SetP( 0, ProjectPointOnPlane( trTria.GetP( 0), plPlane)) ; + trTria.SetP( 1, ProjectPointOnPlane( trTria.GetP( 1), plPlane)) ; + trTria.SetP( 2, ProjectPointOnPlane( trTria.GetP( 2), plPlane)) ; + trTria.Validate( true) ; + } + return ; } @@ -216,7 +237,7 @@ IntersPlaneSurfTm( const Plane3d& plPlane, const ISurfTriMesh& Stm, nT = Stm.GetNextTriangle( nT, Tria) ; } - AdjustIntersPlaneSurfTm( vPnt, vBpt, vTria, LnGrid, TrGrid) ; + AdjustIntersPlaneSurfTm( vPnt, vBpt, vTria, plPlane, LnGrid, TrGrid) ; return true ; } @@ -303,7 +324,7 @@ IntersParPlanesSurfTm::GetInters( double dDist, PNTVECTOR& vPnt, BIPNTVECTOR& vB } } - AdjustIntersPlaneSurfTm( vPnt, vBpt, vTria, LnGrid, TrGrid) ; + AdjustIntersPlaneSurfTm( vPnt, vBpt, vTria, plPlane, LnGrid, TrGrid) ; return true ; } \ No newline at end of file