Modifiche varie
This commit is contained in:
+52
-5
@@ -12,17 +12,34 @@
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
//#include "stdafx.h"
|
||||
//#include "DllMain.h"
|
||||
//#include "Triangulate.h"
|
||||
//#include "ProjPlane.h"
|
||||
//#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
//#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
//#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
//#include <algorithm>
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "Triangulate.h"
|
||||
#include "ProjPlane.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "CurveLine.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include "/EgtDev/Include/EGkPlane3d.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "tpp_interface.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
using namespace tpp ;
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
enum EarStatus{ EAS_NULL = -1, EAS_NO = 0, EAS_OK = 1} ;
|
||||
|
||||
@@ -35,13 +52,17 @@ static bool ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi) ;
|
||||
// INTVECTOR (int Vector) : 3*T indices of above points for T triangles
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType)
|
||||
{
|
||||
// verifico che la polilinea sia chiusa e piana e calcolo il piano medio del poligono
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
if ( ! PL.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL))
|
||||
return false ;
|
||||
|
||||
if ( trgType != TRG_STANDARD)
|
||||
return Make( POLYLINEVECTOR{ PL}, vPt, vTr, trgType) ;
|
||||
|
||||
// determino il piano ottimale di proiezione e il relativo senso di rotazione
|
||||
bool bCCW ;
|
||||
if ( ! CalcProjPlane( plPlane.GetVersN(), m_nPlane, bCCW))
|
||||
@@ -82,12 +103,13 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// In : POLYLINEVECTOR : vector of polylines, the first outer, the others inner
|
||||
// trgType : triangulation type
|
||||
// Out : PNTVECTOR (Point3d Vector) : points of the polyline
|
||||
// INTVECTOR (int Vector) : 3*T indices of above points for T triangles
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
{
|
||||
Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType)
|
||||
{
|
||||
// pulisco i vettori di ritorno
|
||||
vPt.clear() ;
|
||||
vTr.clear() ;
|
||||
@@ -95,7 +117,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
if ( &vPL == nullptr || vPL.empty())
|
||||
return false ;
|
||||
// se una sola polilinea mi riconduco al caso precedente
|
||||
if ( vPL.size() == 1)
|
||||
if ( vPL.size() == 1 && trgType == TRG_STANDARD)
|
||||
return Make( vPL[0], vPt, vTr) ;
|
||||
// verifico che la polilinea esterna sia chiusa e piana e calcolo il piano medio del poligono
|
||||
double dArea ;
|
||||
@@ -115,6 +137,31 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
! AreOppositeVectorApprox( plExtPlane.GetVersN(), plPlane.GetVersN()))
|
||||
return false ;
|
||||
}
|
||||
|
||||
// triangolazione Delaunay
|
||||
if ( trgType == TRG_DEL_CONFORMING) {
|
||||
if ( ! MakeByDelaunay( vPL, vPt, vTr, true, true)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( conforming)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else if ( trgType == TRG_DEL_QUALITY) {
|
||||
if ( ! MakeByDelaunay( vPL, vPt, vTr, false, true)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( quality)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
else if ( trgType == TRG_DEL_NOQUALITY) {
|
||||
if ( ! MakeByDelaunay( vPL, vPt, vTr, false, false)) {
|
||||
LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( no quality)") ;
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
// ear clipping
|
||||
// se non CCW inverto tutte le polilinee
|
||||
if ( ! bCCW) {
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++i)
|
||||
@@ -172,7 +219,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr)
|
||||
INTVECTOR vPol ;
|
||||
int n = int( vPt.size()) ;
|
||||
vPol.reserve( n) ;
|
||||
// non devo gestire separatamente CCW perch� ho gi� invertito i punti
|
||||
// non devo gestire separatamente CCW perch� ho gi� invertito i punti
|
||||
for ( int i = 0 ; i < n ; ++ i)
|
||||
vPol.push_back( i) ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user