EgtGeomKernel :
- aggiunta gestione livello di debug tramite Set/GetEGkDebugLev - introduzione della costante SQ_INFINITO = INFINITO * INFINITO - corretta triangolazione per oggetti molto grandi (si usava INFINITO invece di SQ_INFINITO) - corretta scalatura di curve composite (quando si espande si aggiusta la continuità tra le curve componenti).
This commit is contained in:
@@ -153,7 +153,7 @@ CurveArc* GetArcCenTgCompoPnt( const Point3d& ptCen, const CurveComposite& crvCo
|
||||
const Point3d& ptNearEnd, const Vector3d& vtN, Point3d* pPtTg)
|
||||
{
|
||||
// ciclo sulla curva composita
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
PtrOwner<CurveArc> pCrvArc ;
|
||||
for ( const ICurve* pCrv = crvCompo.GetFirstCurve() ;
|
||||
pCrv != nullptr ;
|
||||
|
||||
@@ -323,7 +323,7 @@ GetArcPntDirTgCompo( const Point3d& ptP, const Vector3d& vtDir, const CurveCompo
|
||||
const Point3d& ptNear, const Vector3d& vtN, Point3d* pPtTg)
|
||||
{
|
||||
// ciclo sulla curva composita
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
PtrOwner<ICurve> pCrvNew ;
|
||||
for ( const ICurve* pCrv = crvCompo.GetFirstCurve() ;
|
||||
pCrv != nullptr ;
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ ChainCurves::ChooseStart( const Point3d& ptStart, const INTVECTOR& vStart, int&
|
||||
|
||||
// altrimenti, cerco la migliore
|
||||
int nI = - 1 ;
|
||||
double dSqDistMin = INFINITO * INFINITO ;
|
||||
double dSqDistMin = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < nSize ; ++ i) {
|
||||
// recupero indice e verso
|
||||
int nId = abs( vStart[i]) - 1 ;
|
||||
|
||||
@@ -158,7 +158,7 @@ GetCircleCenTgArc( const Point3d& ptCen, const Vector3d& vtN, const CurveArc& cr
|
||||
|
||||
// scelgo la soluzione più vicina al punto di riferimento
|
||||
int nIdOk = 0 ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < nSol ; ++ i) {
|
||||
double dSqDist = SqDist( vCenPtg[i].second, ptNear) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
@@ -225,7 +225,7 @@ GetCircleCenTgCompo( const Point3d& ptCen, const Vector3d& vtN, const CurveCompo
|
||||
const Point3d& ptNear, Point3d* pPtTg)
|
||||
{
|
||||
// ciclo sulla curva composita
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
PtrOwner<CurveArc> pCrvArc ;
|
||||
for ( const ICurve* pCrv = crvCompo.GetFirstCurve() ;
|
||||
pCrv != nullptr ;
|
||||
|
||||
+8
-5
@@ -863,7 +863,8 @@ CurveBezier::CalcSingularParam( void) const
|
||||
GetPointD1D2( vdRoot[i], ptPos, &vtDer1) ;
|
||||
if ( vtDer1.IsZero()) {
|
||||
m_dParSing = vdRoot[i] ;
|
||||
LOG_DBG_INFO( GetEGkLogger(), "INFO : Found Singularity in CurveBezier")
|
||||
if ( GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_INFO( GetEGkLogger(), "INFO : Found Singularity in CurveBezier")
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
@@ -1027,7 +1028,7 @@ CurveBezier::GetSegmentLength( int nLev, double dU0, double dU1, double dU2,
|
||||
const double LEN_RATIO = 1.2 ;
|
||||
|
||||
// verifica superamento del massimo livello di recursione per debug
|
||||
if ( nLev >= MAX_LEV)
|
||||
if ( nLev >= MAX_LEV && GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
|
||||
// calcolo delle distanze
|
||||
@@ -1319,7 +1320,8 @@ CurveBezier::FlatOrSplit( int nLev, const CurveBezier& crvBez, double dParStart,
|
||||
const int MAX_LEV = 10 ;
|
||||
if ( nLev >= MAX_LEV) {
|
||||
// segnalo situazione per debug
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
if ( GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
// considero la curva piatta (inserisco il punto se abbastanza lontano dal precedente) ed esco
|
||||
Point3d ptLast ;
|
||||
PL.GetLastPoint( ptLast) ;
|
||||
@@ -1484,7 +1486,8 @@ CurveBezier::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAngTo
|
||||
if ( nLev >= MAX_LEV) {
|
||||
dMaxDist = 0 ;
|
||||
// segnalo situazione per debug
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
if ( GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
}
|
||||
|
||||
// se lunghezza abbastanza picccola, forzo l'accettazione della curva
|
||||
@@ -1514,7 +1517,7 @@ CurveBezier::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAngTo
|
||||
// se raggiunto il massimo livello di recursione, errore
|
||||
if ( nLev >= MAX_LEV) {
|
||||
// segnalo situazione per debug
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
LOG_ERROR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -468,7 +468,8 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
||||
if ( nLev >= MAX_LEV) {
|
||||
dMaxDist = 0 ;
|
||||
// segnalo situazione per debug
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
if ( GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
}
|
||||
|
||||
// se lunghezza abbastanza picccola, forzo l'accettazione della curva
|
||||
@@ -498,7 +499,7 @@ CurveByApprox::BiArcOrSplit( int nLev, PolyLine& PL, double dLinTol, double dAng
|
||||
// se raggiunto il massimo livello di recursione, errore
|
||||
if ( nLev >= MAX_LEV) {
|
||||
// segnalo situazione per debug
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
LOG_ERROR( GetEGkLogger(), "ERROR : Exceeded recursions")
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
||||
@@ -2185,6 +2185,9 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
|
||||
if ( abs( dCoeffX) < EPS_ZERO && abs( dCoeffY) < EPS_ZERO && abs( dCoeffZ) < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// verifico se chiusa
|
||||
bool bClosed = IsClosed() ;
|
||||
|
||||
// calcolo bbox allineato con riferimento di scalatura e senza tener conto dello spessore
|
||||
// lo scalo per verificare se tutto si riduce a un punto
|
||||
BBox3d b3Ref ;
|
||||
@@ -2223,6 +2226,29 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
|
||||
}
|
||||
}
|
||||
|
||||
// se ingrandimento, aggiusto coincidenza estremi delle singole curve
|
||||
if ( abs( dCoeffX) > 1 || abs( dCoeffY) > 1 || abs( dCoeffZ) > 1) {
|
||||
int nCount = int( m_CrvSmplS.size()) ;
|
||||
for ( int i = 0 ; i < nCount ; ++ i) {
|
||||
int j = i - 1 ;
|
||||
if ( j < 0) {
|
||||
if ( bClosed)
|
||||
j = nCount - 1 ;
|
||||
else
|
||||
continue ;
|
||||
}
|
||||
ICurve* pCrvPrev = m_CrvSmplS[j] ;
|
||||
ICurve* pCrvCurr = m_CrvSmplS[i] ;
|
||||
Point3d ptEndPrev ; pCrvPrev->GetEndPoint( ptEndPrev) ;
|
||||
Point3d ptStaCurr ; pCrvCurr->GetStartPoint( ptStaCurr) ;
|
||||
if ( ! AreSamePointApprox( ptEndPrev, ptStaCurr)) {
|
||||
Point3d ptNew = Media( ptEndPrev, ptStaCurr) ;
|
||||
pCrvPrev->ModifyEnd( ptNew) ;
|
||||
pCrvCurr->ModifyStart( ptNew) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// scalo vettore estrusione, lo normalizzo e aggiusto spessore
|
||||
m_VtExtr.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
double dLen = m_VtExtr.Len() ;
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ PolishMinDistPointCurve( const Point3d& ptP, const ICurve& cCurve,
|
||||
} while ( nCount < MAX_COUNT && abs( dPar - dPrevPar) > EPS_PARAM &&
|
||||
abs( dSqCosA) > COS_ORTO_ANG_ZERO * COS_ORTO_ANG_ZERO) ;
|
||||
|
||||
if ( nCount == MAX_COUNT)
|
||||
if ( nCount == MAX_COUNT && GetEGkDebugLev() >= 5)
|
||||
LOG_DBG_ERR( GetEGkLogger(), "ERROR : Exceeded recursions") ;
|
||||
|
||||
return true ;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
// EgalTech 2013-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : DllMain.h Data : 18.12.13 Versione : 1.4l2
|
||||
// File : DllMain.h Data : 19.09.20 Versione : 2.2i2
|
||||
// Contenuto : Prototipi funzioni per uso locale della DLL.
|
||||
//
|
||||
//
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <string>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int GetEGkDebugLev( void) ;
|
||||
ILogger* GetEGkLogger( void) ;
|
||||
const std::string& GetEGkKey( void) ;
|
||||
int ProcessEvents( int nProg, int nPause) ;
|
||||
|
||||
@@ -78,6 +78,23 @@ GetEGkVersion( void)
|
||||
return s_szEGkNameVer ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static int s_nDebugLev = 0 ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
SetEGkDebugLev( int nDebugLev)
|
||||
{
|
||||
s_nDebugLev = nDebugLev ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
GetEGkDebugLev( void)
|
||||
{
|
||||
return s_nDebugLev ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static ILogger* s_pLogger = nullptr ;
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ IntersCurveCurve::GetIntersPointNearTo( int nCrv, const Point3d& ptNear, Point3d
|
||||
|
||||
// ricerca del punto più vicino tra le intersezioni singole
|
||||
bool bFound = false ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < m_nIntersCount ; ++ i) {
|
||||
// se è un'intersezione singola
|
||||
if ( ! m_Info[i].bOverlap) {
|
||||
|
||||
@@ -28,7 +28,7 @@ GetLinePointMinDistCurve( const Point3d& ptP, const ICurve& cCrv, const Point3d&
|
||||
DistPointCurve dstPtCurve( ptP, cCrv) ;
|
||||
// ciclo su questi punti per trovare il più vicino al desiderato
|
||||
bool bFound = false ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
Point3d ptFoot ;
|
||||
MinDistPCInfo mdInfo ;
|
||||
for ( int i = 0 ; dstPtCurve.GetMinDistInfo( i, mdInfo) ; ++ i) {
|
||||
|
||||
@@ -149,7 +149,7 @@ CurveLine*
|
||||
GetLinePointPerpCompo( const Point3d& ptP, const CurveComposite& crvCompo, const Point3d& ptNear)
|
||||
{
|
||||
// ciclo sulla curva composita
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
PtrOwner<CurveLine> pCrvLine ;
|
||||
for ( const ICurve* pCrv = crvCompo.GetFirstCurve() ;
|
||||
pCrv != nullptr ;
|
||||
|
||||
+2
-2
@@ -131,7 +131,7 @@ GetLinePointTgArc( const Point3d& ptP, const CurveArc& crvArc, const Point3d& pt
|
||||
|
||||
// scelgo la soluzione più vicina al punto di riferimento
|
||||
int nIdOk = 0 ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < nSol ; ++ i) {
|
||||
double dSqDist = SqDist( vBiPnt[i].second, ptNear) ;
|
||||
if ( dSqDist < dMinSqDist) {
|
||||
@@ -182,7 +182,7 @@ CurveLine*
|
||||
GetLinePointTgCompo( const Point3d& ptP, const CurveComposite& crvCompo, const Point3d& ptNear)
|
||||
{
|
||||
// ciclo sulla curva composita
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
PtrOwner<CurveLine> pCrvLine ;
|
||||
for ( const ICurve* pCrv = crvCompo.GetFirstCurve() ;
|
||||
pCrv != nullptr ;
|
||||
|
||||
+3
-3
@@ -862,7 +862,7 @@ PolyLine::MyApproxOnSide( const Vector3d& vtN, bool bLeftSide, double dToler)
|
||||
// --- si verifica se possibile eliminare il punto corrente rimanendo dal lato voluto e in tolleranza ---
|
||||
// distanza del punto corrente dal segmento che unisce gli adiacenti
|
||||
DistPointLine dPL( currP->first, precP->first, nextP->first) ;
|
||||
double dSqDist = INFINITO * INFINITO ;
|
||||
double dSqDist = SQ_INFINITO ;
|
||||
dPL.GetSqDist( dSqDist) ;
|
||||
// se punti allineati
|
||||
if ( dSqDist < SQ_EPS_SMALL) {
|
||||
@@ -916,7 +916,7 @@ PolyLine::MyApproxOnSide( const Vector3d& vtN, bool bLeftSide, double dToler)
|
||||
ptInt.ToGlob( frNorm) ;
|
||||
// verifico che distanza dell'intersezione dal segmento currP-nextP sia inferiore a tolleranza corrente
|
||||
DistPointLine dIL( ptInt, currP->first, nextP->first) ;
|
||||
double dSqDist2 = INFINITO * INFINITO ;
|
||||
double dSqDist2 = SQ_INFINITO ;
|
||||
dIL.GetSqDist( dSqDist2) ;
|
||||
// se eliminabile
|
||||
if ( dSqDist2 < dCurrToler * dCurrToler) {
|
||||
@@ -1139,7 +1139,7 @@ PolyLine::GetMinAreaRectangleXY( Point3d& ptCen, Vector3d& vtAx, double& dLen, d
|
||||
|
||||
// Starting edge nCount-1 -> 0
|
||||
int l = 0, m = 0, n = 0 ;
|
||||
double dMinArea = INFINITO * INFINITO ;
|
||||
double dMinArea = SQ_INFINITO ;
|
||||
{
|
||||
// Edge indexes
|
||||
int i = 0 ;
|
||||
|
||||
+1
-1
@@ -250,7 +250,7 @@ SelfIntersCurve::GetIntersPointNearTo( const Point3d& ptNear, Point3d& ptI)
|
||||
|
||||
// ricerca del punto più vicino tra le intersezioni singole
|
||||
bool bFound = false ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < m_nIntersCount ; ++ i) {
|
||||
// se è un'intersezione singola
|
||||
if ( ! m_Info[i].bOverlap) {
|
||||
|
||||
@@ -231,7 +231,7 @@ SurfTriMesh::GetFacetNearestEndPoint( int nF, const Point3d& ptNear, Point3d& pt
|
||||
return false ;
|
||||
// ciclo sui triangoli e sui loro lati di bordo
|
||||
bool bFound = false ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < int( vTria.size()) ; ++i) {
|
||||
int nT = vTria[i] ;
|
||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||
@@ -264,7 +264,7 @@ SurfTriMesh::GetFacetNearestMidPoint( int nF, const Point3d& ptNear, Point3d& pt
|
||||
return false ;
|
||||
// ciclo sui triangoli e sui loro lati di bordo
|
||||
bool bFound = false ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < int( vTria.size()) ; ++i) {
|
||||
int nT = vTria[i] ;
|
||||
for ( int j = 0 ; j < 3 ; ++ j) {
|
||||
|
||||
+3
-3
@@ -346,7 +346,7 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR&
|
||||
double dSqDist = SqDist(vPt[vPol[vPrev[i]]], vPt[vPol[vNext[i]]]) ;
|
||||
// Try with 3 next
|
||||
int j = i ;
|
||||
double dSqDist1 = INFINITO ;
|
||||
double dSqDist1 = SQ_INFINITO ;
|
||||
for ( int h = 0 ; h < 3 ; ++ h) {
|
||||
j = vNext[j] ;
|
||||
if ( vEar[j] == EAS_NULL)
|
||||
@@ -358,7 +358,7 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR&
|
||||
}
|
||||
// Try with 3 prev
|
||||
int k = i ;
|
||||
double dSqDist2 = INFINITO ;
|
||||
double dSqDist2 = SQ_INFINITO ;
|
||||
for ( int h = 0 ; h < 3 ; ++ h) {
|
||||
k = vPrev[k] ;
|
||||
if ( vEar[k] == EAS_NULL)
|
||||
@@ -916,7 +916,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n
|
||||
if ( bSwap)
|
||||
swap( ptPb, ptPc) ;
|
||||
double dMinTan = INFINITO ;
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
double dMinSqDist = SQ_INFINITO ;
|
||||
for ( int i = 0 ; i < nNumPt ; ++ i) {
|
||||
// salto il punto già trovato
|
||||
if ( i == nJ)
|
||||
|
||||
Reference in New Issue
Block a user