EgtGeomKernel 2.5g3 :

- migliorata gestione approssimazione con archi.
This commit is contained in:
DarioS
2023-07-28 11:22:50 +02:00
parent 2ba32eb93c
commit fb62c6d68e
4 changed files with 78 additions and 25 deletions
+23 -11
View File
@@ -20,6 +20,7 @@
#include "/EgtDev/Include/EGkCurveComposite.h"
#include "/EgtDev/Include/EGkArcSpecial.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EgtNumUtils.h"
#include "/EgtDev/Include/EgtPointerOwner.h"
using namespace std ;
@@ -97,7 +98,7 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
CurveArc* pArc = GetBasicCurveArc( pJCrv) ;
if ( pArc == nullptr)
return nullptr ;
double dU = - 1 ;
double dU = -1 ;
double dRad = pArc->GetRadius() ;
double dSqRad = dRad * dRad ;
Point3d ptCen = pArc->GetCenter() ;
@@ -121,9 +122,11 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
}
}
}
// elimino casi vicino agli estremi, danno solo problemi
if ( dU < 0.1 || dU > 0.9)
// non c'è intersezione, assegno valore medio
if ( dU < -0.5)
dU = 0.5 ;
// elimino casi vicino agli estremi, danno solo problemi
dU = Clamp( dU, 0.1, 0.9) ;
pBiArc.Set( GetBiArc( ptP0, dDir0Deg, ptP1, dDir1Deg, dU)) ;
}
@@ -132,15 +135,24 @@ GetBiArc( const Point3d& ptP0, double dDir0Deg, const Point3d& ptP1, double dDir
return nullptr ;
// determino la massima distanza tra la curva e il biarco
Point3d ptP ;
double dSqDist = 0 ;
for ( bool bPnt = PL.GetFirstPoint( ptP) ;
bPnt ;
bPnt = PL.GetNextPoint( ptP)) {
DistPointCurve dstPC( ptP, *pBiArc) ;
double dSqDistPC ;
if ( dstPC.GetSqDist( dSqDistPC) && dSqDistPC > dSqDist)
dSqDist = dSqDistPC ;
const double STEP = 10 ;
Point3d ptCurr ;
bool bPnt = PL.GetFirstPoint( ptCurr) ;
Point3d ptPrev = ptCurr ;
while ( bPnt) {
double dLen = Dist( ptCurr, ptPrev) ;
int nStep = ( dLen < STEP ? 2 : 1) * int( dLen / STEP) + 1 ;
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCoeff = double( i) / nStep ;
Point3d ptP = Media( ptPrev, ptCurr, dCoeff) ;
DistPointCurve dstPC( ptP, *pBiArc) ;
double dSqDistPC ;
if ( dstPC.GetSqDist( dSqDistPC) && dSqDistPC > dSqDist)
dSqDist = dSqDistPC ;
}
ptPrev = ptCurr ;
bPnt = PL.GetNextPoint( ptCurr) ;
}
dDist = sqrt( dSqDist) ;