EgtGeomKernel :
- aggiunta funzione per l'approsimazione di curve con limitazione sulla lunghezza dei singoli tratti.
This commit is contained in:
+31
-2
@@ -41,7 +41,7 @@ GEOOBJ_REGISTER( CRV_ARC, NGE_C_ARC, CurveArc) ;
|
||||
class ArcApproxer
|
||||
{
|
||||
public :
|
||||
ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc) ;
|
||||
ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc, double dMaxLen = INFINITO) ;
|
||||
bool GetPoint( double& dU, Point3d& ptP) ;
|
||||
|
||||
private :
|
||||
@@ -1177,6 +1177,30 @@ CurveArc::ApproxWithLines( double dLinTol, double dAngTolDeg, int nType, PolyLin
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::ApproxWithLimitedLines( double dLinTol, double dAngTolDeg, int nType, double dMaxLen, PolyLine& PL) const
|
||||
{
|
||||
// pulisco la polilinea
|
||||
PL.Clear() ;
|
||||
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// eseguo approssimazione
|
||||
bool bInside = true ;
|
||||
ArcApproxer aAppr( dLinTol, dAngTolDeg, bInside, *this, dMaxLen) ;
|
||||
double dU ;
|
||||
Point3d ptPos ;
|
||||
while ( aAppr.GetPoint( dU, ptPos)) {
|
||||
if ( ! PL.AddUPoint( dU, ptPos))
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const
|
||||
@@ -2170,7 +2194,7 @@ CurveArc::Flip( void)
|
||||
// usando il versore medio dal centro e moltiplicandolo per il coefficiente ( 2 / ( 1 + cosA)).
|
||||
// Il versore dell'ultimo punto è già stato calcolato per il penultimo.
|
||||
//----------------------------------------------------------------------------
|
||||
ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc)
|
||||
ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const CurveArc& arArc, double dMaxLen)
|
||||
{
|
||||
// inizializzazioni
|
||||
m_nTotPnt = 0 ;
|
||||
@@ -2195,6 +2219,11 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const
|
||||
dAngStepDeg = sqrt( 8 * dLinTolRel) * RADTODEG ;
|
||||
else
|
||||
dAngStepDeg = sqrt( 8 * dLinTolRel / ( 1 + dLinTolRel)) * RADTODEG ;
|
||||
|
||||
if ( dMaxLen < INFINITO) {
|
||||
double dAngStepMaxLen = 2 * asin( dMaxLen / ( 2 * arArc.GetRadius())) * RADTODEG ;
|
||||
dAngStepDeg = min( dAngStepDeg, dAngStepMaxLen) ;
|
||||
}
|
||||
dAngStepDeg = min( dAngStepDeg, dAngTolDeg) ;
|
||||
|
||||
// dall'angolo al centro ricavo il numero di passi
|
||||
|
||||
Reference in New Issue
Block a user