From 641708a5fa9d4f8d2ab998cec3b4ce21607bb290 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 13 Sep 2021 15:48:36 +0200 Subject: [PATCH 1/4] =?UTF-8?q?EgtGeomKernel=202.3i1=20:=20-=20in=20Region?= =?UTF-8?q?i=20se=20richiesto=20offset=20praticamente=20nullo=20non=20si?= =?UTF-8?q?=20fa=20alcunch=C3=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes SurfFlatRegionOffset.cpp | 3 +++ 2 files changed, 3 insertions(+) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index c9fb3319f2f2ff385e93f64d571482d9299f0f93..50dcb017871d34b0c3871da232f91b6e5f1cf84e 100644 GIT binary patch delta 118 zcmdlNy)SyhH#SyF1|0^&&A-{?nVB;g3@0mc>u&bq>S2M3-{!MM7I$OZ+#~G9j8n2h Q8ZL=uq6g#VEaea`0ANlYDgXcg delta 118 zcmdlNy)SyhH#Sxa1|0_D&A-{?nVB;fj3+B{>u&bq>S2M3-{!MM7I$OZ+#~G9j8n2h Q8ZL=uq6g#VEaea`0AeH_G5`Po diff --git a/SurfFlatRegionOffset.cpp b/SurfFlatRegionOffset.cpp index be335b2..18fb77c 100644 --- a/SurfFlatRegionOffset.cpp +++ b/SurfFlatRegionOffset.cpp @@ -27,6 +27,9 @@ SurfFlatRegion::Offset( double dDist, int nType) int nChunk = GetChunkCount() ; if ( nChunk == 0) return false ; + // se offset nullo, non devo fare alcunché + if ( abs( dDist) < 10 * EPS_SMALL) + return true ; // creo una nuova regione PtrOwner pSfr( new( nothrow) SurfFlatRegion) ; if ( IsNull( pSfr)) From e7d0b00e0f96db5c8bed9558880abfc7d8b0e84f Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 13 Sep 2021 16:47:15 +0200 Subject: [PATCH 2/4] EgtGeomKernel : - correzione a Zmap per calcolo grafica a triangoli. --- VolZmapGraphics.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/VolZmapGraphics.cpp b/VolZmapGraphics.cpp index 90c85fb..b07419c 100644 --- a/VolZmapGraphics.cpp +++ b/VolZmapGraphics.cpp @@ -1,13 +1,13 @@ //---------------------------------------------------------------------------- -// EgalTech 2015-2019 +// EgalTech 2015-2021 //---------------------------------------------------------------------------- -// File : VolZmap.cpp Data : 07.03.19 Versione : 2.1c2 +// File : VolZmap.cpp Data : 13.09.21 Versione : 2.3i1 // Contenuto : Implementazione della classe Volume Zmap (tre griglie) // // // // Modifiche : 22.01.15 DS Creazione modulo. -// +// 13.09.21 LM Correzione funzione che determina se voxel su frontiera di un blocco. // //---------------------------------------------------------------------------- @@ -3984,13 +3984,13 @@ VolZmap::IsAVoxelOnBoundary( const int nLimits[], const int nIJK[], int nDeltaIn -- nDeltaIndex[0] ; else if ( nIJK[0] == nLimits[1] - 1) ++ nDeltaIndex[0] ; - if ( nIJK[0] == nLimits[0]) + if ( nIJK[1] == nLimits[2]) -- nDeltaIndex[1]; - else if ( nIJK[0] == nLimits[1] - 1) + else if ( nIJK[1] == nLimits[3] - 1) ++ nDeltaIndex[1]; - if ( nIJK[0] == nLimits[0]) + if ( nIJK[2] == nLimits[4]) -- nDeltaIndex[2]; - else if ( nIJK[0] == nLimits[1] - 1) + else if ( nIJK[2] == nLimits[5] - 1) ++ nDeltaIndex[2]; return ( nDeltaIndex[0] != 0 || nDeltaIndex[1] != 0 || nDeltaIndex[2] != 0) ; } From 4731df3702de38441fd3bf38edb332ca4c1ed9e9 Mon Sep 17 00:00:00 2001 From: DarioS Date: Sun, 26 Sep 2021 16:27:31 +0200 Subject: [PATCH 3/4] =?UTF-8?q?EgtGeomKernel=202.3i2=20:=20-=20modificata?= =?UTF-8?q?=20completamente=20SurfTriMesh::GetSilhouette=20ora=20richiede?= =?UTF-8?q?=20un=20parametro=20per=20la=20tolleranza=20nel=20calcolo=20(di?= =?UTF-8?q?minuita=20sensibilit=C3=A0=20a=20problemi=20topologici)=20-=20a?= =?UTF-8?q?ggiunta=20funzione=20GetSurfFlatRegionFromTriangle.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes SfrCreate.cpp | 35 ++++++++++++++++++++++++------ SurfTriMesh.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++- SurfTriMesh.h | 6 +++--- 4 files changed, 85 insertions(+), 11 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 50dcb017871d34b0c3871da232f91b6e5f1cf84e..ba184468120877e984f9770c2bfecac322ddaeff 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&P_&A-_cnHh~HD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-Vf-5U delta 94 zcmdlNy)SyhFE&QQ&A-_cnHdcyD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-U|t&X diff --git a/SfrCreate.cpp b/SfrCreate.cpp index 957dc03..d21c5ac 100644 --- a/SfrCreate.cpp +++ b/SfrCreate.cpp @@ -279,13 +279,34 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b //---------------------------------------------------------------------------- ISurfFlatRegion* -GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine) +GetSurfFlatRegionFromTriangle( const Triangle3d& Tria) { // Creo la regione. PtrOwner pSfr( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSfr)) return nullptr ; - // Creo curva composita. + // Creo curva composita. + PtrOwner pLoop( CreateBasicCurveComposite()) ; + if ( IsNull( pLoop)) + return nullptr ; + if ( ! pLoop->AddPoint( Tria.GetP( 0)) || + ! pLoop->AddLine( Tria.GetP( 1)) || + ! pLoop->AddLine( Tria.GetP( 2)) || + ! pLoop->Close()) + return nullptr ; + pSfr->AddExtLoop( Release( pLoop)) ; + return Release( pSfr) ; +} + +//---------------------------------------------------------------------------- +ISurfFlatRegion* +GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine) +{ + // Creo la regione. + PtrOwner pSfr( CreateBasicSurfFlatRegion()) ; + if ( IsNull( pSfr)) + return nullptr ; + // Creo curva composita. PtrOwner pLoop( CreateBasicCurveComposite()) ; if ( IsNull( pLoop)) return nullptr ; @@ -307,13 +328,13 @@ GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine) ISurfFlatRegion* GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec) { - // Creo la regione. + // Creo la regione. PtrOwner pSfr( CreateBasicSurfFlatRegion()) ; if ( IsNull( pSfr)) return nullptr ; - // Ciclo sulle PolyLine. + // Ciclo sulle PolyLine. for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) { - // Creo curva composita. + // Creo curva composita. PtrOwner pLoop( CreateBasicCurveComposite()) ; if ( IsNull( pLoop)) return nullptr ; @@ -327,11 +348,11 @@ GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec) ptSt = ptEn ; bContinue = vContoursPolyLineVec[nL].GetNextPoint( ptEn) ; } - // Loop esterno + // Loop esterno if ( nL == 0) { pSfr->AddExtLoop( Release( pLoop)) ; } - // Loop interno + // Loop interno else { pSfr->AddIntLoop( Release( pLoop)) ; } diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index 0a8b3ff..a96df26 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -991,7 +991,7 @@ SurfTriMesh::MarchOneTria( int& nT, int& nV, int nTimeStamp, //---------------------------------------------------------------------------- bool -SurfTriMesh::GetSilhouette( const Vector3d& vtDir, POLYLINEVECTOR& vPL) const +SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL) const { // Verifico lo stato if ( m_nStatus != OK) @@ -1002,6 +1002,57 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, POLYLINEVECTOR& vPL) const if ( ! vtVers.Normalize()) return false ; + // Controlli su tolleranza + dTol = max( dTol, 100 * EPS_SMALL) ; + + // Determino il riferimento di proiezione + Frame3d frOCS ; frOCS.Set( ORIG, vtVers) ; + Frame3d frBox = frOCS ; frBox.Invert() ; + BBox3d b3Box ; + GetBBox( frBox, b3Box) ; + frOCS.Translate( b3Box.GetMin().z * frOCS.VersZ()) ; + + // calcolo la regione dei triangoli proiettati + PtrOwner pSfr ; + Triangle3d Tria ; + int nT = GetFirstTriangle( Tria) ; + while ( nT != SVT_NULL) { + // verifico la normale e il triangolo proiettato + if ( Tria.GetN() * vtVers > EPS_ZERO && + Tria.Scale( frOCS, 1, 1, 0) && Tria.GetSqMinHeight() > SQ_EPS_SMALL) { + PtrOwner pSfrTria( GetSurfFlatRegionFromTriangle( Tria)) ; + if ( ! IsNull( pSfrTria)) { + pSfrTria->Offset( dTol, ICurve::OFF_FILLET) ; + if ( IsNull( pSfr)) + pSfr.Set( Release( pSfrTria)) ; + else + pSfr->Add( *pSfrTria) ; + } + } + // passo al successivo + nT = GetNextTriangle( nT, Tria) ; + } + + // Se non esiste la regione + if ( IsNull( pSfr)) + return false ; + + // Effettuo contro-offset + pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ; + + // Recupero i contorni della regione + for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) { + for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) { + PolyLine PL ; + if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) + vPL.emplace_back( PL) ; + } + } + + return true ; + +#if 0 + // Copio la superficie PtrOwner pStm( Clone()) ; if ( IsNull( pStm)) @@ -1021,6 +1072,8 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, POLYLINEVECTOR& vPL) const // Recupero i loop della nuova superficie return pStm->GetLoops( vPL) ; + +#endif } //---------------------------------------------------------------------------- diff --git a/SurfTriMesh.h b/SurfTriMesh.h index bd32138..303e6c7 100644 --- a/SurfTriMesh.h +++ b/SurfTriMesh.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- -// EgalTech 2014-2019 +// EgalTech 2014-2021 //---------------------------------------------------------------------------- -// File : SurfTriMesh.h Data : 12.02.19 Versione : 2.1b2 +// File : SurfTriMesh.h Data : 26.09.21 Versione : 2.3i2 // Contenuto : Dichiarazione della classe Superficie TriMesh. // // @@ -278,7 +278,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW bool GetTriangleBoundaryEdges( int nId, TriFlags3d& TFlags) const override ; bool GetTriangleSmoothNormals( int nId, TriNormals3d& TNrms) const override ; bool GetLoops( POLYLINEVECTOR& vPL) const override ; - bool GetSilhouette( const Vector3d& vtDir, POLYLINEVECTOR& vPL) const override ; + bool GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& vPL) const override ; int GetFacetCount( void) const override ; int GetFacetSize( void) const override { return int( m_vFacet.size()) ; } From add949b6a69fddab9cc8994c6115f3f30a4946e1 Mon Sep 17 00:00:00 2001 From: DarioS Date: Mon, 4 Oct 2021 09:01:36 +0200 Subject: [PATCH 4/4] EgtGeomKernel : - tentativo abortito di velocizzare Silhouette di superfici. --- SurfTriMesh.cpp | 94 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 24 deletions(-) diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index a96df26..db53337 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -1012,6 +1012,76 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& GetBBox( frBox, b3Box) ; frOCS.Translate( b3Box.GetMin().z * frOCS.VersZ()) ; +#if 0 + // *** 1° Sfruttando le adiacenze *** + // Non funziona perchè genera loop con anelli + // Copio la superficie + PtrOwner pStm( Clone()) ; + if ( IsNull( pStm)) + return false ; + + // Elimino i triangoli con normale non equiversa alla direzione scelta + for ( int i = 0 ; i < int( pStm->m_vTria.size()) ; ++ i) { + // se già cancellato, passo oltre + if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL) + continue ; + // verifico la normale + if ( pStm->m_vTria[i].vtN * vtVers < EPS_ZERO) + pStm->RemoveTriangle( i) ; + } + // dichiaro facce non calcolate + pStm->m_bFaceted = false ; + + // Proietto la superficie + pStm->Scale( frOCS, 1, 1, 0) ; + + // Recupero i loop della nuova superficie + POLYLINEVECTOR vMyPL ; + if ( pStm->GetLoops( vMyPL)) { + // calcolo la regione della superficie proiettata + bool bOk = true ; + PtrOwner pSfr ; + for ( int i = 0 ; i < int( vMyPL.size()) && bOk ; ++ i) { + // Regione di un loop + PtrOwner pSfrPart( GetSurfFlatRegionFromPolyLine( vMyPL[i])) ; + if ( ! IsNull( pSfrPart)) { + pSfrPart->Offset( dTol, ICurve::OFF_FILLET) ; + if ( IsNull( pSfr)) + if ( pSfrPart->GetNormVersor() * vtVers > 0) + bOk = pSfr.Set( Release( pSfrPart)) ; + else + bOk = false ; + else { + if ( pSfrPart->GetNormVersor() * vtVers > 0) + bOk = pSfr->Add( *pSfrPart) ; + else { + pSfrPart->Invert() ; + bOk = pSfr->Subtract( *pSfrPart) ; + } + } + } + else + bOk = false ; + } + // Verifico esistenza della regione + if ( bOk && ! IsNull( pSfr)) { + // Effettuo contro-offset + pSfr->Offset( -dTol, ICurve::OFF_EXTEND) ; + // Recupero i contorni della regione + for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) { + for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) { + PolyLine PL ; + if ( pSfr->ApproxLoopWithLines( i, j, LIN_TOL_STD, ANG_TOL_STD_DEG, ICurve::APL_STD, PL)) + vPL.emplace_back( PL) ; + } + } + return true ; + } + } + vPL.clear() ; +#endif + + // *** 2° Mediante unione delle regioni dei triangoli proiettati *** // calcolo la regione dei triangoli proiettati PtrOwner pSfr ; Triangle3d Tria ; @@ -1050,30 +1120,6 @@ SurfTriMesh::GetSilhouette( const Vector3d& vtDir, double dTol, POLYLINEVECTOR& } return true ; - -#if 0 - - // Copio la superficie - PtrOwner pStm( Clone()) ; - if ( IsNull( pStm)) - return false ; - - // Elimino i triangoli con normale non equiversa alla direzione scelta - for ( int i = 0 ; i < int( pStm->m_vTria.size()) ; ++ i) { - // se già cancellato, passo oltre - if ( pStm->m_vTria[i].nIdVert[0] == SVT_DEL) - continue ; - // verifico la normale - if ( pStm->m_vTria[i].vtN * vtVers < - EPS_ZERO) - pStm->RemoveTriangle( i) ; - } - // dichiaro facce non calcolate - pStm->m_bFaceted = false ; - - // Recupero i loop della nuova superficie - return pStm->GetLoops( vPL) ; - -#endif } //----------------------------------------------------------------------------