EgtGeomKernel :
- correzioni e migliorie alla triangolazione delle bezier.
This commit is contained in:
+79
-18
@@ -40,6 +40,7 @@
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Extern/Eigen/Dense"
|
||||
#include "EgtDev/Include/EGkGeoObjSave.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -1590,7 +1591,8 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const
|
||||
for( int i = 0 ; i < int( vPL3d.size()) ; ++i) {
|
||||
PolyLine& pl3d = vPL3d[i] ;
|
||||
Point3d pt3d ; pl3d.GetFirstPoint( pt3d) ;
|
||||
//vPnt3d.push_back( pt3d) ;
|
||||
if( vPL3d.size() > 1)
|
||||
vPnt3d.push_back( pt3d) ;
|
||||
while ( pl3d.GetNextPoint( pt3d)) {
|
||||
vPnt3d.push_back( pt3d) ;
|
||||
}
|
||||
@@ -1603,14 +1605,16 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const
|
||||
|
||||
// se ho ottenuto meno triangoli di quelli che avrei dovuto avere allora potrei aver avuto un problema in prossimità di un polo
|
||||
// se comunque ho corrispondenza tra vPnt e vPnt3d allora eseguo la trinagolazione in 3d
|
||||
bool bTriangulationFailedIn2D = ( vPnt.size() - 2) != ( vTria.size()) / 3 ;
|
||||
bool bMismatch2D3D = vPnt.size() != vPnt3d.size() ;
|
||||
int nTriaNumber = ( vPnt.size() - 2) + (2 * (vPL.size() - 1)) - (vPL.size() > 2 ? vPL.size() - 2 : 0) - (vPL.size() != 1 ? vPL.size() : 0) ;
|
||||
bool bTriangulationFailedIn2D = nTriaNumber != ( vTria.size()) / 3 ;
|
||||
//bool bMismatch2D3D = vPnt.size() != vPnt3d.size() ;
|
||||
bool bTriangulatedIn3D = false ;
|
||||
PNTVECTOR vPnt2d ;
|
||||
if ( bTriangulationFailedIn2D) {
|
||||
PNTVECTOR vPntBackup = vPnt ;
|
||||
INTVECTOR vTriaBackup = vTria ;
|
||||
if ( ! Tri.Make( vPL3d, vPnt, vTria))
|
||||
return nullptr ;
|
||||
bool bTriangulationSucceded = ( vPnt.size() - 2 ) == ( vTria.size() ) / 3 ;
|
||||
bool bTriangulationSucceded = ( vPnt.size() - 2) + (2 * (vPL.size() - 1)) - (vPL.size() > 2 ? vPL.size() - 2 : 0) - (vPL.size() != 1 ? vPL.size() : 0) == ( vTria.size() ) / 3 ;
|
||||
if( bTriangulationFailedIn2D) {
|
||||
if ( bTriangulationSucceded)
|
||||
LOG_INFO( GetEGkLogger(), "Info : Last problem in MakeByEC23(1) RESOLVED")
|
||||
@@ -1628,19 +1632,15 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const
|
||||
tria.Set( vPnt[vTria[0]], vPnt[vTria[1]], vPnt[vTria[2]]) ;
|
||||
if( tria.GetN() * vtN < 0)
|
||||
reverse( vTria.begin(), vTria.end()) ;
|
||||
for( int i = 0 ; i < int( vPL.size()) ; ++i) {
|
||||
PolyLine& pl = vPL[i] ;
|
||||
Point3d pt ; pl.GetFirstPoint( pt) ;
|
||||
//vPnt2D.push_back( pt) ;
|
||||
while ( pl.GetNextPoint( pt)) {
|
||||
vPnt2d.push_back( pt) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
vPnt = vPntBackup ;
|
||||
vTria = vTriaBackup ;
|
||||
}
|
||||
}
|
||||
|
||||
// riordino il vettore dei punti su cui non ho fatto la triangolazione
|
||||
if( int(vPL.size()) > 1 || bTriangulatedIn3D) {
|
||||
if( int(vPL.size()) == 2) {
|
||||
//if( vPnt.size() != vPnt3d.size())
|
||||
// return nullptr ;
|
||||
PNTVECTOR vPntOrd ;
|
||||
@@ -1654,6 +1654,27 @@ SurfBezier::GetApproxSurf( double dTol, double dSideMin) const
|
||||
vPnt3d = vPntOrd ;
|
||||
}
|
||||
}
|
||||
else if ( bTriangulatedIn3D) {
|
||||
if( vPL.size() == 1) {
|
||||
vPnt3d = vPnt ;
|
||||
PNTVECTOR vPnt2d ;
|
||||
for( int i = 0 ; i < int( vPL.size()) ; ++i) {
|
||||
PolyLine& pl = vPL[i] ;
|
||||
Point3d pt ; pl.GetFirstPoint( pt) ;
|
||||
//vPnt2D.push_back( pt) ;
|
||||
while ( pl.GetNextPoint( pt)) {
|
||||
vPnt2d.push_back( pt) ;
|
||||
}
|
||||
}
|
||||
vPnt = vPnt2d ;
|
||||
}
|
||||
else {
|
||||
PNTVECTOR vPntOrd ;
|
||||
ReorderPntEnhancedVector( vPL3d, true, vPnt, vPL, vPntOrd) ;
|
||||
vPnt3d = vPnt ;
|
||||
vPnt = vPntOrd ;
|
||||
}
|
||||
}
|
||||
|
||||
//controllo che i due vettori vPnt e vPnt3d abbiano la stessa lunghezza, sennò vuol dire che nel vettore vPnt3d ho avuto dei Rejected e devo ricalcolarli
|
||||
// i punti in eccesso verranno poi scartati dalla trimesh
|
||||
@@ -1705,23 +1726,23 @@ SurfBezier::ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D,
|
||||
nInd = 0 ;
|
||||
Point3d ptPoly ; pl.GetFirstPoint( ptPoly) ;
|
||||
bool bFound = false ;
|
||||
if( AreSamePointStepApprox( pt, ptPoly)){
|
||||
if( AreSamePointStepExact( pt, ptPoly)){
|
||||
nPoints = pl.GetPointNbr() ;
|
||||
nPoly = poly ;
|
||||
bFound = true ;
|
||||
pl.GetNextPoint( ptPoly) ;
|
||||
if( ! AreSamePointStepApprox( vPnt[p+1], ptPoly))
|
||||
if( ! AreSamePointStepExact( vPnt[p+1], ptPoly))
|
||||
bInverted = true ;
|
||||
break ;
|
||||
}
|
||||
while ( pl.GetNextPoint( ptPoly) && ! bFound) {
|
||||
++ nInd ;
|
||||
if( AreSamePointStepApprox( pt, ptPoly)) {
|
||||
if( AreSamePointStepExact( pt, ptPoly)) {
|
||||
nPoints = pl.GetPointNbr() ;
|
||||
nPoly = poly ;
|
||||
bFound = true ;
|
||||
pl.GetNextPoint( ptPoly) ;
|
||||
if( ! AreSamePointStepApprox( vPnt[p+1], ptPoly))
|
||||
if( ! AreSamePointStepExact( vPnt[p+1], ptPoly))
|
||||
bInverted = true ;
|
||||
break ;
|
||||
}
|
||||
@@ -1769,6 +1790,46 @@ SurfBezier::ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D,
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::ReorderPntEnhancedVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const
|
||||
{
|
||||
vPntOrd.clear() ;
|
||||
// costruisco il vettore dei punti da ordinare
|
||||
PNTVECTOR vPntPolyToOrd ;
|
||||
for ( int i = 0 ; i < int( vPLToOrd.size()) ; ++i) {
|
||||
Point3d pt ; vPLToOrd[i].GetFirstPoint( pt) ;
|
||||
vPntPolyToOrd.push_back( pt) ;
|
||||
while( vPLToOrd[i].GetNextPoint( pt))
|
||||
vPntPolyToOrd.push_back( pt) ;
|
||||
}
|
||||
// costruisco il vettore con i punti delle polyline in ordine
|
||||
PNTVECTOR vPntPoly ;
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++i) {
|
||||
Point3d pt ; vPL[i].GetFirstPoint( pt) ;
|
||||
vPntPoly.push_back( pt) ;
|
||||
while( vPL[i].GetNextPoint( pt))
|
||||
vPntPoly.push_back( pt) ;
|
||||
}
|
||||
BOOLVECTOR vbPntChecked( vPnt.size()) ;
|
||||
fill( vbPntChecked.begin(), vbPntChecked.end(), false) ;
|
||||
// confronto questo vettore con il vettore dei punti in ordine sparso
|
||||
for ( int p = 0 ; p < int( vPntPoly.size()) ; ++p) {
|
||||
Point3d pt = vPntPoly[p] ;
|
||||
for ( int t = 0 ; t < int( vPnt.size()) ; ++t) {
|
||||
if( vbPntChecked[t])
|
||||
continue ;
|
||||
Point3d ptToCheck = vPnt[t] ;
|
||||
if ( AreSamePointStepExact( pt, ptToCheck)) {
|
||||
vbPntChecked[t] = true ;
|
||||
vPntOrd.push_back( vPntPolyToOrd[p]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// applico la stessa trasformazione al vettore dei punti delle polyline vPLToOrd
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::GetLeaves( vector<tuple<int, Point3d, Point3d>>& vLeaves) const
|
||||
|
||||
@@ -204,6 +204,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool CalcPoles( void) const ;
|
||||
bool FindMatchByParam( const PolyLine& pl0, const PolyLine& pl1, INTVECTOR& vMatch, int& nLong) const ;
|
||||
bool ReorderPntVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ;
|
||||
bool ReorderPntEnhancedVector( const POLYLINEVECTOR& vPL, bool bTriangulatedIn3D, const PNTVECTOR& vPnt, const POLYLINEVECTOR& vPLToOrd, PNTVECTOR& vPntOrd) const ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
|
||||
Reference in New Issue
Block a user