EgtGeomKernel 2.4a2 :

- in TriMesh eliminata ResetFaceting e UpdateFaceting ora cerca di ricostruire facce con indice come le eventuali precedenti
- in Trimesh SimplifyFacets cerca di conservare l'identificativo di faccia nei nuovi triangoli
- in Trimesh aggiunta funzione Repair e migliorata SimplifyFacets
- in Trimesh al termine di CutWithOtherSurf si cerca di regolarizzare il risultato.
This commit is contained in:
DarioS
2022-01-07 10:00:19 +01:00
parent 41d76f0c3f
commit 9b11212d07
8 changed files with 138 additions and 55 deletions
+56 -6
View File
@@ -1763,6 +1763,10 @@ SurfTriMesh::FlipTriangles( int nTA, int nTB)
bool
SurfTriMesh::Add( const ISurfTriMesh& Other)
{
// Le superfici devono essere valide
if ( ! IsValid() || ! Other.IsValid())
return false ;
m_OGrMgr.Clear() ;
SurfTriMesh SurfB ;
@@ -1806,8 +1810,7 @@ SurfTriMesh::Add( const ISurfTriMesh& Other)
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
// cerco di semplificare le facce
if ( ! SimplifyFacets( 5000.0, true))
if ( ! SimplifyFacets())
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Add")
return bOk ;
@@ -1817,6 +1820,10 @@ SurfTriMesh::Add( const ISurfTriMesh& Other)
bool
SurfTriMesh::Intersect( const ISurfTriMesh& Other)
{
// Le superfici devono essere valide
if ( ! IsValid() || ! Other.IsValid())
return false ;
m_OGrMgr.Clear() ;
SurfTriMesh SurfB ;
@@ -1860,7 +1867,7 @@ SurfTriMesh::Intersect( const ISurfTriMesh& Other)
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
if ( ! SimplifyFacets( 5000.0, true))
if ( ! SimplifyFacets())
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Intersect")
return bOk ;
@@ -1870,6 +1877,10 @@ SurfTriMesh::Intersect( const ISurfTriMesh& Other)
bool
SurfTriMesh::Subtract( const ISurfTriMesh& Other)
{
// Le superfici devono essere valide
if ( ! IsValid() || ! Other.IsValid())
return false ;
m_OGrMgr.Clear() ;
SurfTriMesh SurfB ;
@@ -1914,7 +1925,7 @@ SurfTriMesh::Subtract( const ISurfTriMesh& Other)
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
if ( ! SimplifyFacets( 5000.0, true))
if ( ! SimplifyFacets())
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Intersect")
return bOk ;
@@ -1925,7 +1936,7 @@ bool
SurfTriMesh::GetSurfClassification( const ISurfTriMesh& ClassifierSurf,
INTVECTOR& vTriaIn, INTVECTOR& vTriaOut, INTVECTOR& vTriaOnP, INTVECTOR& vTriaOnM, INTVECTOR& vTriaIndef)
{
// Le superfici devono essere valide
// Le superfici devono essere valide
if ( ! IsValid() || ! ClassifierSurf.IsValid())
return false ;
if ( ClassifierSurf.GetVertexCount() == 0 || ClassifierSurf.GetTriangleCount() == 0)
@@ -1975,18 +1986,23 @@ SurfTriMesh::GetSurfClassification( const ISurfTriMesh& ClassifierSurf,
bool
SurfTriMesh::CutWithOtherSurf( const ISurfTriMesh& CutterSurf, bool bInVsOut, bool bSaveOnEq)
{
// Le superfici devono essere valide
// Le superfici devono essere valide
if ( ! IsValid() || ! CutterSurf.IsValid())
return false ;
m_OGrMgr.Clear() ;
SurfTriMesh SurfC ;
SurfC.CopyFrom( &CutterSurf) ;
Frame3d frScalingRef ;
frScalingRef.Set( m_vVert[0].ptP, X_AX, Y_AX, Z_AX) ;
Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
SurfC.Scale( frScalingRef, BOOLEAN_SCALE, BOOLEAN_SCALE, BOOLEAN_SCALE) ;
IntersectTriMeshTriangle( SurfC) ;
IdentifyParts() ;
int nPartToRemove = ( bInVsOut ? -1 : 1) ;
int nCoplanarPartToRemove = ( bSaveOnEq ? ( nPartToRemove ? -2 : 2) : 5) ;
int nTriaNum = GetTriangleSize() ;
@@ -1994,11 +2010,45 @@ SurfTriMesh::CutWithOtherSurf( const ISurfTriMesh& CutterSurf, bool bInVsOut, bo
if ( m_vTria[nT].nTempPart == nPartToRemove || m_vTria[nT].nTempPart == nCoplanarPartToRemove)
RemoveTriangle( nT) ;
}
bool bOk = ( AdjustVertices() && DoCompacting()) ;
bOk = bOk && RemoveTJunctions() ;
bOk = bOk && ( AdjustVertices() && DoCompacting()) ;
Scale( frScalingRef, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE, 1. / BOOLEAN_SCALE) ;
if ( ! SimplifyFacets())
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::CutWithOtherSurf")
return bOk ;
}
//----------------------------------------------------------------------------
bool
SurfTriMesh::Repair( double dMaxEdgeLen)
{
// La superficie deve essere valida
if ( ! IsValid())
return false ;
// Forzo aggiornamento grafica
m_OGrMgr.Clear() ;
// Inserisco triangoli per rimuovere giunzioni a T
RemoveTJunctions() ;
// Sistemo
if ( ! AdjustVertices() || ! DoCompacting())
return false ;
// Ritriangolo le facce
if ( ! SimplifyFacets( dMaxEdgeLen, true))
LOG_ERROR( GetEGkLogger(), "Error in SimplifyFacets of Stm::Intersect")
return true ;
}
//----------------------------------------------------------------------------
int
SurfTriMesh::VerifyLoopPlane( const PolyLine& ExtLoop, const Plane3d& plCutPlane)