EgtGeomKernel :

- correzioni nella gestione dei trim delle superfici di Bezier.
- correzioni varie alle superfici di Bezier.
This commit is contained in:
Daniele Bariletti
2024-04-17 14:52:07 +02:00
parent a5a96c2bb5
commit 788a5bc4eb
4 changed files with 57 additions and 34 deletions
+43 -26
View File
@@ -26,6 +26,7 @@
#include "DistPointCrvComposite.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
#include <algorithm>
#include <numeric>
using namespace std ;
@@ -39,13 +40,13 @@ Tree::Tree( void)
m_mTree.insert( pair< int, Cell>( -1, cRoot)) ;
}
//----------------------------------------------------------------------------
Tree::Tree( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d& ptMin, const Point3d& ptMax)
: m_pSrfBz( nullptr), m_bTrimmed( false), m_bBilinear( false), m_bMulti( false), m_bClosedU( false), m_bClosedV( false), m_vbPole( { false, false, false, false}),
m_bSplitPatches( true), m_bTestMode( false)
{
SetSurf( pSrfBz, bSplitPatches, ptMin, ptMax) ;
}
////----------------------------------------------------------------------------
//Tree::Tree( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d& ptMin, const Point3d& ptMax)
// : m_pSrfBz( nullptr), m_bTrimmed( false), m_bBilinear( false), m_bMulti( false), m_bClosedU( false), m_bClosedV( false), m_vbPole( { false, false, false, false}),
// m_bSplitPatches( true), m_bTestMode( false)
//{
// SetSurf( pSrfBz, bSplitPatches, ptMin, ptMax) ;
//}
//----------------------------------------------------------------------------
Tree::~Tree( void)
@@ -73,8 +74,11 @@ Tree::LimitLoop( PolyLine& pl, POLYLINEVECTOR& vPl) const
bInverted = true ;
}
PtrOwner<ISurfFlatRegion> pParamTrim( GetSurfFlatRegionRectangle( SBZ_TREG_COEFF * m_nSpanU, SBZ_TREG_COEFF * m_nSpanV)) ;
if ( ! pParamTrim->Intersect( *pSfrTrim) || ! pParamTrim->IsValid())
return false ;
if ( ! pParamTrim->Intersect( *pSfrTrim) || ! pParamTrim->IsValid()) {
pParamTrim->Offset( 10 * EPS_SMALL, ICurve::OFF_EXTEND) ;
if ( ! pParamTrim->Intersect( *pSfrTrim) || ! pParamTrim->IsValid())
return false ;
}
// ricostruisco la curva tenendo solo le parti dentro lo spazio parametrico
// devo recuperare la polyline dei bordi dei vari chunk creati
@@ -90,14 +94,17 @@ Tree::LimitLoop( PolyLine& pl, POLYLINEVECTOR& vPl) const
vPl.push_back( plApprox) ;
}
return false ;
return true ;
}
//----------------------------------------------------------------------------
void
bool
Tree::SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches, const Point3d& ptMin, const Point3d& ptMax)
{
if ( pSrfBz == nullptr || ! pSrfBz->IsValid())
return false ;
// pulisco i vettori membri
m_mTree.clear() ;
m_vnLeaves.clear() ;
m_vnParents.clear() ;
m_mVert.clear() ;
@@ -159,7 +166,8 @@ Tree::SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches, const Point3d& ptMi
bCCW = false ;
// limito il loop allo spazio parametrico // potrei ottenere più loop a partire da quello originale
POLYLINEVECTOR vPlLimited ;
LimitLoop( plApprox, vPlLimited) ;
if ( ! LimitLoop( plApprox, vPlLimited))
return false ;
for ( int k = 0 ; k < int( vPlLimited.size()) ; ++k)
m_vPlApprox.push_back( tuple<PolyLine,bool>(vPlLimited[k], bCCW)) ;
}
@@ -172,7 +180,7 @@ Tree::SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches, const Point3d& ptMi
ptTop = ptMax ;
bLimited = true ;
}
m_mTree.clear() ;
//m_mTree.clear() ;
Cell cRoot( ptMin, ptTop) ;
m_mTree.insert( pair< int, Cell>( -1, cRoot)) ;
Point3d ptP00, ptP10, ptP11, ptP01 ;
@@ -350,6 +358,7 @@ Tree::SetSurf( const SurfBezier* pSrfBz, bool bSplitPatches, const Point3d& ptMi
m_vDim.push_back( ( dLen1 > EPS_ZERO ? dLen1 : 1)) ;
m_vDim.push_back( ( dLen2 > EPS_ZERO ? dLen2 : 1)) ;
m_vDim.push_back( ( dLen3 > EPS_ZERO ? dLen3 : 1)) ;
return true ;
}
//----------------------------------------------------------------------------
@@ -1388,15 +1397,15 @@ Tree::GetDepth( int nId, int nRef = -2) const
return i ;
}
//----------------------------------------------------------------------------
struct generator
{
int value ;
generator( void)
{ value = -1 ; }
int operator() ()
{ return ++value ; }
} ;
////----------------------------------------------------------------------------
//struct generator
//{
// int value ;
// generator( void)
// { value = -1 ; }
// int operator() ()
// { return ++value ; }
//} ;
//----------------------------------------------------------------------------
bool
@@ -1444,7 +1453,8 @@ Tree::GetPolygons( POLYLINEMATRIX& vPolygons)
INTVECTOR vnParentChunk ;
// vettore in cui salvo i loop che non appartengono al poligono che sto cotruendo nel ciclo attuale e da cui ripasserò dopo
INTVECTOR vToCheck( (int) m_mTree[nId].m_vInters.size()) ;
generate_n( vToCheck.begin(), (int) m_mTree[nId].m_vInters.size(), generator()) ;
//generate_n( vToCheck.begin(), (int) m_mTree[nId].m_vInters.size(), generator()) ;
iota (vToCheck.begin(), vToCheck.end(), 0) ;
// numero di poligoni aggiunti
int nPoly = 0 ;
// scorro sui vettori intersezione della cella nId e sui suoi vertici
@@ -3531,10 +3541,16 @@ Tree::CheckIfBetween( const Inters& inA, const Inters& inB) const
}
else if ( nEdge == 7)
nEdge = 0 ;
if ( AreSameEdge( inA.nIn, inA.nOut) && ! CheckIfBefore( inA.nIn, inA.vpt[0], inA.vpt.back()))
if ( AreSameEdge( inA.nIn, inA.nOut) && ! CheckIfBefore( inA.nIn, inA.vpt[0], inA.vpt.back(), nEdge))
vEdges.push_back( nEdge) ;
int nEdgeIn = inA.nIn ;
if ( nEdgeIn > 3 && nEdgeIn != 7) {
nEdgeIn = nEdgeIn - 4 ;
}
else if ( nEdgeIn == 7)
nEdgeIn = 0 ;
// creo la sequenza di Edges da scorrere per trovare i possibili validNextStart
while ( ! AreSameEdge( nEdge, inA.nIn) || (int) vEdges.size() == 0) {
while ( ! AreSameEdge( nEdge, nEdgeIn) || (int) vEdges.size() == 0) {
vEdges.push_back( nEdge) ;
if ( nEdge == 3)
nEdge = 0 ;
@@ -3883,7 +3899,8 @@ Tree::CreateCellContour( POLYLINEMATRIX& vPolygons)
// preparo tutto per poter chiamare la createCellPolygon
m_vnLeaves.push_back( nRoot) ;
INTVECTOR vToCheck( (int) m_mTree.at(nRoot).m_vInters.size()) ;
generate_n( vToCheck.begin(), (int) m_mTree.at(nRoot).m_vInters.size(), generator()) ;
//generate_n( vToCheck.begin(), (int) m_mTree.at(nRoot).m_vInters.size(), generator()) ;
iota( vToCheck.begin(), vToCheck.end(), 0) ;
int nPoly = 0 ;
INTVECTOR vnParentChunk ;
PolyLine pl ;