EgtGeomKernel 2.3i2 :

- modificata completamente SurfTriMesh::GetSilhouette ora richiede un parametro per la tolleranza nel calcolo (diminuita sensibilità a problemi topologici)
- aggiunta funzione GetSurfFlatRegionFromTriangle.
This commit is contained in:
DarioS
2021-09-26 16:27:31 +02:00
parent e7d0b00e0f
commit 4731df3702
4 changed files with 85 additions and 11 deletions
BIN
View File
Binary file not shown.
+28 -7
View File
@@ -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<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr))
return nullptr ;
// Creo curva composita.
// Creo curva composita.
PtrOwner<CurveComposite> 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<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr))
return nullptr ;
// Creo curva composita.
PtrOwner<CurveComposite> 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<SurfFlatRegion> 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<CurveComposite> 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)) ;
}
+54 -1
View File
@@ -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<ISurfFlatRegion> 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<ISurfFlatRegion> 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<SurfTriMesh> 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
}
//----------------------------------------------------------------------------
+3 -3
View File
@@ -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()) ; }