diff --git a/CurveArc.cpp b/CurveArc.cpp
index 8ccca6d..acf483a 100644
--- a/CurveArc.cpp
+++ b/CurveArc.cpp
@@ -23,10 +23,6 @@ using namespace std ;
//----------------------------------------------------------------------------
GEOOBJ_REGISTER( CRV_ARC, "C_ARC", CurveArc) ;
-//----------------------------------------------------------------------------
-const double CurveArc::PAR_START = 0 ;
-const double CurveArc::PAR_END = 1 ;
-
//----------------------------------------------------------------------------
CurveArc::CurveArc( void)
{
@@ -226,22 +222,7 @@ CurveArc::GetEndPoint( Point3d& ptEnd) const
//----------------------------------------------------------------------------
bool
-CurveArc::GetDomain( double& dStart, double& dEnd) const
-{
- // verifico lo stato
- if ( m_nStatus != OK)
- return false ;
-
- // assegno gli estremi del dominio
- dStart = PAR_START ;
- dEnd = PAR_END ;
-
- return true ;
-}
-
-//----------------------------------------------------------------------------
-bool
-CurveArc::GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
+CurveArc::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
{
double dAng ;
Vector3d vtDir ;
@@ -384,7 +365,7 @@ CurveArc::TrimStartAtParam( double dUTrim)
// riporto i parametri nel loro range
- dUTrim = ( ( dUTrim < PAR_START) ? PAR_START : (( dUTrim > PAR_END) ? PAR_END : dUTrim)) ;
+ dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
// recupero lunghezza
if ( ! GetLength( dLen))
@@ -402,7 +383,7 @@ CurveArc::TrimEndAtParam( double dUTrim)
// riporto i parametri nel loro range
- dUTrim = ( ( dUTrim < PAR_START) ? PAR_START : (( dUTrim > PAR_END) ? PAR_END : dUTrim)) ;
+ dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
// recupero lunghezza
if ( ! GetLength( dLen))
diff --git a/CurveArc.h b/CurveArc.h
index 10f7555..44a082c 100644
--- a/CurveArc.h
+++ b/CurveArc.h
@@ -42,15 +42,17 @@ class CurveArc : public ICurveArc
{ return ::IsClosed( *this) ; }
virtual bool GetStartPoint( Point3d& ptStart) const ;
virtual bool GetEndPoint( Point3d& ptEnd) const ;
- virtual bool GetDomain( double& dStart, double& dEnd) const ;
+ virtual bool GetDomain( double& dStart, double& dEnd) const
+ { dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; }
virtual bool GetLength( double& dLen) const ;
- virtual bool GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
- virtual bool GetPoint( double dU, Point3d& ptPos) const
- { return ::GetPoint( *this, dU, ptPos) ; }
- virtual bool GetPointTang( double dU, Point3d& ptPos, Vector3d& vtTang) const
- { return ::GetPointTang( *this, dU, ptPos, vtTang) ; }
- virtual bool GetPointTangNormCurv( double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv) const
- { return ::GetPointTangNormCurv( *this, dU, ptPos, vtT, vtN, dCurv) ; }
+ virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
+ virtual bool GetPoint( double dU, Side nS, Point3d& ptPos) const
+ { return ::GetPoint( *this, dU, nS, ptPos) ; }
+ virtual bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const
+ { return ::GetPointTang( *this, dU, nS, ptPos, vtTang) ; }
+ virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const
+ { oDiffG.nFlag = CrvPointDiffGeom::STD ;
+ return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
virtual bool Reverse( void) ;
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
virtual bool TrimStartAtParam( double dUTrim) ;
@@ -91,8 +93,6 @@ class CurveArc : public ICurveArc
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
- static const double PAR_START ;
- static const double PAR_END ;
private :
Status m_nStatus ; // stato
diff --git a/CurveAux.cpp b/CurveAux.cpp
index 62e5d66..41e2343 100644
--- a/CurveAux.cpp
+++ b/CurveAux.cpp
@@ -29,54 +29,71 @@ IsClosed( const ICurve& crvC)
//----------------------------------------------------------------------------
bool
-GetPoint( const ICurve& crvC, double dU, Point3d& ptPos)
+GetPoint( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos)
{
Vector3d vtDer1 ;
Vector3d vtDer2 ;
- return crvC.GetPointD1D2( dU, ptPos, vtDer1, vtDer2) ;
+ return crvC.GetPointD1D2( dU, ICurve::FROM_MINUS, ptPos, vtDer1, vtDer2) ;
}
//----------------------------------------------------------------------------
bool
-GetPointTang( const ICurve& crvC, double dU, Point3d& ptPos, Vector3d& vtTang)
+GetPointTang( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos, Vector3d& vtTang)
{
Vector3d vtDer2 ;
- if ( ! crvC.GetPointD1D2( dU, ptPos, vtTang, vtDer2))
+ if ( ! crvC.GetPointD1D2( dU, nS, ptPos, vtTang, vtDer2))
return false ;
return ( vtTang.Normalize()) ;
}
//----------------------------------------------------------------------------
bool
-GetPointTangNormCurv( const ICurve& crvC, double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv)
+GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGeom& oDiffG)
{
double dSqLenD1 ;
+ Point3d ptPos ;
+ Vector3d vtDer1 ;
Vector3d vtDer2 ;
- if ( ! crvC.GetPointD1D2( dU, ptPos, vtT, vtDer2))
+ if ( ! crvC.GetPointD1D2( dU, nS, ptPos, vtDer1, vtDer2))
return false ;
+ // assegno parametro e posizione
+ oDiffG.dU = dU ;
+ oDiffG.ptP = ptPos ;
// se esiste la derivata prima non nulla
- dSqLenD1 = vtT.SqLen() ;
- if ( vtT.Normalize()) {
+ dSqLenD1 = vtDer1.SqLen() ;
+ if ( vtDer1.Normalize()) {
+ oDiffG.vtT = vtDer1 ;
// del vettore deriv2^ tengo la sola componente perpendicolare al vettore tangente
- vtN = vtDer2 - ( vtDer2 * vtT) * vtT ;
- if ( vtN.Normalize())
- dCurv = ( vtT ^ vtDer2).Len() / dSqLenD1 ;
- else
- dCurv = 0 ;
+ oDiffG.vtN = vtDer2 - ( vtDer2 * vtDer1) * vtDer1 ;
+ if ( oDiffG.vtN.Normalize()) {
+ oDiffG.dCurv = ( vtDer1 ^ vtDer2).Len() / dSqLenD1 ;
+ oDiffG.nStatus = CrvPointDiffGeom::NCRV ;
+ }
+ else {
+ oDiffG.dCurv = 0 ;
+ oDiffG.nStatus = CrvPointDiffGeom::TANG ;
+ }
}
+ // se esiste almeno derivata seconda non nulla, definisce la tangente
+ else if ( vtDer2.Normalize()) {
+ oDiffG.vtT = vtDer2 ;
+ oDiffG.vtN.Set( 0, 0, 0) ;
+ oDiffG.dCurv = 0 ;
+ oDiffG.nStatus = CrvPointDiffGeom::TANG ;
+ }
+ // altrimenti non sono definite la tangente e la normale
else {
- // se esiste derivata seconda non nulla, definisce la tangente
- if ( vtDer2.Normalize())
- vtT = vtDer2 ;
- vtN.Set( 0, 0, 0) ;
- dCurv = 0 ;
- }
+ oDiffG.vtT.Set( 0, 0, 0) ;
+ oDiffG.vtN.Set( 0, 0, 0) ;
+ oDiffG.dCurv = 0 ;
+ oDiffG.nStatus = CrvPointDiffGeom::POS ;
+ }
return true ;
}
diff --git a/CurveAux.h b/CurveAux.h
index 51fbf8a..244b6cc 100644
--- a/CurveAux.h
+++ b/CurveAux.h
@@ -17,6 +17,6 @@
//----------------------------------------------------------------------------
bool IsClosed( const ICurve& crvC) ;
-bool GetPoint( const ICurve& crvC, double dU, Point3d& ptPos) ;
-bool GetPointTang( const ICurve& crvC, double dU, Point3d& ptPos, Vector3d& vtTang) ;
-bool GetPointTangNormCurv( const ICurve& crvC, double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv) ;
+bool GetPoint( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos) ;
+bool GetPointTang( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos, Vector3d& vtTang) ;
+bool GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGeom& oDiffG) ;
diff --git a/CurveBezier.cpp b/CurveBezier.cpp
index a43f63c..d247315 100644
--- a/CurveBezier.cpp
+++ b/CurveBezier.cpp
@@ -26,10 +26,6 @@ using namespace std ;
//----------------------------------------------------------------------------
GEOOBJ_REGISTER( CRV_BEZ, "C_BEZ", CurveBezier) ;
-//----------------------------------------------------------------------------
-const double CurveBezier::PAR_START = 0 ;
-const double CurveBezier::PAR_END = 1 ;
-
//----------------------------------------------------------------------------
CurveBezier::CurveBezier( void)
{
@@ -352,26 +348,11 @@ CurveBezier::GetEndPoint( Point3d& ptEnd) const
return true ;
}
-//----------------------------------------------------------------------------
-bool
-CurveBezier::GetDomain( double& dStart, double& dEnd) const
-{
- // verifico lo stato
- if ( m_nStatus != OK)
- return false ;
-
- // assegno gli estremi del dominio
- dStart = PAR_START ;
- dEnd = PAR_END ;
-
- return true ;
-}
-
//----------------------------------------------------------------------------
// Calcolo i polinomi di Bernstein e da questi il punto ( vedi Piegl-Tiller)
//----------------------------------------------------------------------------
bool
-CurveBezier::GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
+CurveBezier::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
{
int i ;
double dBern[MAXDEG] ;
@@ -382,10 +363,10 @@ CurveBezier::GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d
return false ;
// il parametro U deve essere compreso tra 0 e 1
- if ( dU < PAR_START)
- dU = PAR_START ;
- else if ( dU > PAR_END)
- dU = PAR_END ;
+ if ( dU < 0)
+ dU = 0 ;
+ else if ( dU > 1)
+ dU = 1 ;
// se forma polinomiale (o integrale)
if ( ! m_bRat) {
@@ -568,12 +549,12 @@ CurveBezier::GetSegmentLength( int nLev, double dU0, double dU1, double dU2,
// prima metā
dUMid = 0.5 * ( dU0 + dU1) ;
- GetPoint( dUMid, ptMid) ;
+ GetPoint( dUMid, ICurve::FROM_MINUS, ptMid) ;
double dD3 = GetSegmentLength( nLev +1, dU0, dUMid, dU1,
ptP0, ptMid, ptP1) ;
// seconda metā
dUMid = 0.5 * ( dU1 + dU2) ;
- GetPoint( dUMid, ptMid) ;
+ GetPoint( dUMid, ICurve::FROM_MINUS, ptMid) ;
double dD4 = GetSegmentLength( nLev + 1, dU1, dUMid, dU2,
ptP1, ptMid, ptP2) ;
@@ -604,25 +585,25 @@ CurveBezier::GetLengthAtParam( double dU, double& dLen) const
return false ;
// fuori dominio del parametro -> errore
- if ( dU < PAR_START - EPS_ZERO)
+ if ( dU < 0 - EPS_ZERO)
return false ;
- if ( dU > ( PAR_END + EPS_ZERO))
+ if ( dU > ( 1 + EPS_ZERO))
return false ;
// inizio
- if ( dU < PAR_START + EPS_ZERO) {
+ if ( dU < 0 + EPS_ZERO) {
dLen = 0 ;
return true ;
}
// parto con un numero fisso di punti e poi affino dove serve
dLen = 0 ;
- dUIni = PAR_START ;
- GetPoint( PAR_START, ptIni) ;
+ dUIni = 0 ;
+ GetPoint( 0, ICurve::FROM_MINUS, ptIni) ;
for ( i = 1 ; i <= NUM_SEG ; ++ i) {
// ricavo il punto
dUFin = i / (double) NUM_SEG * dU ;
- GetPoint( dUFin, ptFin) ;
+ GetPoint( dUFin, ICurve::FROM_MINUS, ptFin) ;
// se punto dispari
if ( ( i % 2) == 1) {
// assegno nuovo medio
@@ -658,11 +639,11 @@ CurveBezier::GetSegmentParam( double dLen, double& dCurrLen, double& dSegLen,
dUStart = dUIni ;
dUEnd = dUFin ;
- GetPoint( dUIni, ptIni) ;
+ GetPoint( dUIni, ICurve::FROM_MINUS, ptIni) ;
for ( i = 1 ; i <= NUM_SEG ; ++ i) {
// ricavo il punto
dUFin = dUStart + i / (double) NUM_SEG * ( dUEnd - dUStart) ;
- GetPoint( dUFin, ptFin) ;
+ GetPoint( dUFin, ICurve::FROM_MINUS, ptFin) ;
// se punto dispari
if ( ( i % 2) == 1) {
// assegno nuovo medio
@@ -705,14 +686,14 @@ CurveBezier::GetParamAtLength( double dLen, double& dU) const
// inizio
if ( dLen < EPS_SMALL) {
- dU = PAR_START ;
+ dU = 0 ;
return true ;
}
// approfondisco nell'intervallo diinteresse
dCurrLen = 0 ;
- dUIni = PAR_START ;
- dUFin = PAR_END ;
+ dUIni = 0 ;
+ dUFin = 1 ;
while ( ( bOk = GetSegmentParam( dLen, dCurrLen, dSegLen, dUIni, dUFin)) && dSegLen > MAX_SEG_LEN)
;
// aggiustamento finale parametro
@@ -821,7 +802,7 @@ CurveBezier::ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) c
PL.AddUPoint( 0, m_aPtCtrl[0]) ;
// verifico se va divisa
- FlatOrSplit( 0, *this, PAR_START, PAR_END, dLinTol, dAngTolDeg, PL) ;
+ FlatOrSplit( 0, *this, 0, 1, dLinTol, dAngTolDeg, PL) ;
// se č stato inserito un solo punto, aggiungo il finale
if ( PL.GetPointNbr() == 1)
@@ -863,10 +844,10 @@ CurveBezier::TrimStartAtParam( double dUTrim)
// se devo togliere dall'inizio o prima non tolgo niente
- if ( dUTrim <= PAR_START)
+ if ( dUTrim <= 0)
return true ;
// se devo togliere a partire dalla fine o dopo non rimane niente
- if ( dUTrim >= PAR_END)
+ if ( dUTrim >= 1)
return false ;
// eseguo il trim (algoritmo di de Casteljau)
for ( k = 1 ; k <= m_nDeg ; k ++) {
@@ -894,10 +875,10 @@ CurveBezier::TrimEndAtParam( double dUTrim)
// se devo togliere a partire dall'inizio o prima non rimane niente
- if ( dUTrim <= PAR_START)
+ if ( dUTrim <= 0)
return false ;
// se devo togliere dalla fine o dopo non tolgo niente
- if ( dUTrim >= PAR_END)
+ if ( dUTrim >= 1)
return true ;
// eseguo il trim (algoritmo di de Casteljau)
for ( k = 1 ; k <= m_nDeg ; k ++) {
diff --git a/CurveBezier.h b/CurveBezier.h
index fe9ee30..9c2638f 100644
--- a/CurveBezier.h
+++ b/CurveBezier.h
@@ -42,17 +42,19 @@ class CurveBezier : public ICurveBezier
{ return ::IsClosed( *this) ; }
virtual bool GetStartPoint( Point3d& ptStart) const ;
virtual bool GetEndPoint( Point3d& ptEnd) const ;
- virtual bool GetDomain( double& dStart, double& dEnd) const ;
+ virtual bool GetDomain( double& dStart, double& dEnd) const
+ { dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; }
virtual bool GetLength( double& dLen) const ;
virtual bool GetLengthAtParam( double dU, double& dLen) const ;
virtual bool GetParamAtLength( double dLen, double& dU) const ;
- virtual bool GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
- virtual bool GetPoint( double dU, Point3d& ptPos) const
- { return ::GetPoint( *this, dU, ptPos) ; }
- virtual bool GetPointTang( double dU, Point3d& ptPos, Vector3d& vtTang) const
- { return ::GetPointTang( *this, dU, ptPos, vtTang) ; }
- virtual bool GetPointTangNormCurv( double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv) const
- { return ::GetPointTangNormCurv( *this, dU, ptPos, vtT, vtN, dCurv) ; }
+ virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
+ virtual bool GetPoint( double dU, Side nS, Point3d& ptPos) const
+ { return ::GetPoint( *this, dU, nS, ptPos) ; }
+ virtual bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const
+ { return ::GetPointTang( *this, dU, nS, ptPos, vtTang) ; }
+ virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const
+ { oDiffG.nFlag = CrvPointDiffGeom::STD ;
+ return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
virtual bool Reverse( void) ;
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
virtual bool TrimStartAtParam( double dUTrim) ;
@@ -99,8 +101,6 @@ class CurveBezier : public ICurveBezier
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
static const int MAXDEG = 11 ;
static const int ST_PTC = 4 ;
- static const double PAR_START ;
- static const double PAR_END ;
private :
Status m_nStatus ; // stato
diff --git a/CurveComposite.cpp b/CurveComposite.cpp
index 00760a7..4a0199a 100644
--- a/CurveComposite.cpp
+++ b/CurveComposite.cpp
@@ -23,9 +23,6 @@ using namespace std ;
//----------------------------------------------------------------------------
GEOOBJ_REGISTER( CRV_COMPO, "C_CMP", CurveComposite) ;
-//----------------------------------------------------------------------------
-const double CurveComposite::PAR_START = 0 ;
-
//----------------------------------------------------------------------------
CurveComposite::CurveComposite( void)
{
@@ -330,7 +327,7 @@ CurveComposite::GetDomain( double& dStart, double& dEnd) const
return false ;
// assegno gli estremi del dominio
- dStart = PAR_START ;
+ dStart = 0 ;
dEnd = m_nCounter ;
return true ;
@@ -338,26 +335,30 @@ CurveComposite::GetDomain( double& dStart, double& dEnd) const
//----------------------------------------------------------------------------
bool
-CurveComposite::GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
+CurveComposite::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
{
- double dParStart ;
- double dParEnd ;
PCRVSMPL_LIST::const_iterator Iter ;
// il parametro U deve essere compreso tra 0 e m_nCounter
- if ( dU < PAR_START)
- dU = PAR_START ;
- else if ( dU > m_nCounter)
+ if ( dU < ( 0 + EPS_ZERO)) {
+ dU = 0 ;
+ nS = ICurve::FROM_PLUS ;
+ }
+ else if ( dU > ( m_nCounter - EPS_ZERO)) {
dU = m_nCounter ;
+ nS = ICurve::FROM_MINUS ;
+ }
// determino la curva di appartenenza e faccio eseguire il calcolo
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
- (*Iter)->GetDomain( dParStart, dParEnd) ;
- if ( dU <= ( dParEnd - dParStart))
- return (*Iter)->GetPointD1D2( dParStart + dU, ptPos, vtDer1, vtDer2) ;
+ // ogni curva semplice ha parametro compreso tra 0 e 1
+ // se nella parametrizzazione della curva semplice, oppure all'estremo superiore e dal basso
+ if ( dU < ( 1 - EPS_ZERO) ||
+ ( fabs( dU - 1) < EPS_ZERO && nS == ICurve::FROM_MINUS))
+ return (*Iter)->GetPointD1D2( dU, ICurve::FROM_MINUS, ptPos, vtDer1, vtDer2) ;
else
- dU -= ( dParEnd - dParStart) ;
+ dU -= 1 ;
}
return false ;
diff --git a/CurveComposite.h b/CurveComposite.h
index 0a8a67a..dde6342 100644
--- a/CurveComposite.h
+++ b/CurveComposite.h
@@ -48,13 +48,14 @@ class CurveComposite : public ICurveComposite
virtual bool GetEndPoint( Point3d& ptEnd) const ;
virtual bool GetDomain( double& dStart, double& dEnd) const ;
virtual bool GetLength( double& dLen) const ;
- virtual bool GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
- virtual bool GetPoint( double dU, Point3d& ptPos) const
- { return ::GetPoint( *this, dU, ptPos) ; }
- virtual bool GetPointTang( double dU, Point3d& ptPos, Vector3d& vtTang) const
- { return ::GetPointTang( *this, dU, ptPos, vtTang) ; }
- virtual bool GetPointTangNormCurv( double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv) const
- { return ::GetPointTangNormCurv( *this, dU, ptPos, vtT, vtN, dCurv) ; }
+ virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
+ virtual bool GetPoint( double dU, Side nS, Point3d& ptPos) const
+ { return ::GetPoint( *this, dU, nS, ptPos) ; }
+ virtual bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const
+ { return ::GetPointTang( *this, dU, nS, ptPos, vtTang) ; }
+ virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const
+ { oDiffG.nFlag = ( IsParamAtJoint( dU) ? CrvPointDiffGeom::TO_VERIFY : CrvPointDiffGeom::STD) ;
+ return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
virtual bool Reverse( void) ;
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
virtual bool TrimStartAtParam( double dUTrim) ;
@@ -87,7 +88,6 @@ class CurveComposite : public ICurveComposite
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
- static const double PAR_START ;
private :
Status m_nStatus ; // stato
diff --git a/CurveLine.cpp b/CurveLine.cpp
index 1a456d1..79711d2 100644
--- a/CurveLine.cpp
+++ b/CurveLine.cpp
@@ -23,10 +23,6 @@ using namespace std ;
//----------------------------------------------------------------------------
GEOOBJ_REGISTER( CRV_LINE, "C_LIN", CurveLine) ;
-//----------------------------------------------------------------------------
-const double CurveLine::PAR_START = 0 ;
-const double CurveLine::PAR_END = 1 ;
-
//----------------------------------------------------------------------------
CurveLine::CurveLine( void)
{
@@ -149,22 +145,7 @@ CurveLine::GetEndPoint( Point3d& ptEnd) const
//----------------------------------------------------------------------------
bool
-CurveLine::GetDomain( double& dStart, double& dEnd) const
-{
- // verifico lo stato
- if ( m_nStatus != OK)
- return false ;
-
- // assegno gli estremi del dominio
- dStart = 0 ;
- dEnd = 1 ;
-
- return true ;
-}
-
-//----------------------------------------------------------------------------
-bool
-CurveLine::GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
+CurveLine::GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const
{
// verifico lo stato
if ( m_nStatus != OK)
@@ -239,7 +220,7 @@ CurveLine::TrimStartAtParam( double dUTrim)
// riporto i parametri nel loro range
- dUTrim = ( ( dUTrim < PAR_START) ? PAR_START : (( dUTrim > PAR_END) ? PAR_END : dUTrim)) ;
+ dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
// recupero lunghezza
if ( ! GetLength( dLen))
@@ -257,7 +238,7 @@ CurveLine::TrimEndAtParam( double dUTrim)
// riporto i parametri nel loro range
- dUTrim = ( ( dUTrim < PAR_START) ? PAR_START : (( dUTrim > PAR_END) ? PAR_END : dUTrim)) ;
+ dUTrim = ( ( dUTrim < 0) ? 0 : (( dUTrim > 1) ? 1 : dUTrim)) ;
// recupero lunghezza
if ( ! GetLength( dLen))
diff --git a/CurveLine.h b/CurveLine.h
index ddb347c..ac4d091 100644
--- a/CurveLine.h
+++ b/CurveLine.h
@@ -42,15 +42,17 @@ class CurveLine : public ICurveLine
{ return ::IsClosed( *this) ; }
virtual bool GetStartPoint( Point3d& ptStart) const ;
virtual bool GetEndPoint( Point3d& ptEnd) const ;
- virtual bool GetDomain( double& dStart, double& dEnd) const ;
+ virtual bool GetDomain( double& dStart, double& dEnd) const
+ { dStart = 0 ; dEnd = 1 ; return ( m_nStatus == OK) ; }
virtual bool GetLength( double& dLen) const ;
- virtual bool GetPointD1D2( double dU, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
- virtual bool GetPoint( double dU, Point3d& ptPos) const
- { return ::GetPoint( *this, dU, ptPos) ; }
- virtual bool GetPointTang( double dU, Point3d& ptPos, Vector3d& vtTang) const
- { return ::GetPointTang( *this, dU, ptPos, vtTang) ; }
- virtual bool GetPointTangNormCurv( double dU, Point3d& ptPos, Vector3d& vtT, Vector3d& vtN, double& dCurv) const
- { return ::GetPointTangNormCurv( *this, dU, ptPos, vtT, vtN, dCurv) ; }
+ virtual bool GetPointD1D2( double dU, Side nS, Point3d& ptPos, Vector3d& vtDer1, Vector3d& vtDer2) const ;
+ virtual bool GetPoint( double dU, Side nS, Point3d& ptPos) const
+ { return ::GetPoint( *this, dU, nS, ptPos) ; }
+ virtual bool GetPointTang( double dU, Side nS, Point3d& ptPos, Vector3d& vtTang) const
+ { return ::GetPointTang( *this, dU, nS, ptPos, vtTang) ; }
+ virtual bool GetPointDiffGeom( double dU, Side nS, CrvPointDiffGeom& oDiffG) const
+ { oDiffG.nFlag = CrvPointDiffGeom::STD ;
+ return ::GetPointDiffGeom( *this, dU, nS, oDiffG) ; }
virtual bool Reverse( void) ;
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ;
virtual bool TrimStartAtParam( double dUTrim) ;
@@ -77,8 +79,6 @@ class CurveLine : public ICurveLine
private :
enum Status { ERR = 0, OK = 1, TO_VERIFY = 2} ;
- static const double PAR_START ;
- static const double PAR_END ;
private :
Status m_nStatus ; // stato
diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc
index 6ffa6a2..d398724 100644
Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ
diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj
index 80726d7..ad22e1a 100644
--- a/EgtGeomKernel.vcxproj
+++ b/EgtGeomKernel.vcxproj
@@ -151,6 +151,7 @@ copy $(TargetPath) \EgtProg\Dll
+
@@ -162,7 +163,7 @@ copy $(TargetPath) \EgtProg\Dll
-
+
diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters
index 85827a5..a3a3b09 100644
--- a/EgtGeomKernel.vcxproj.filters
+++ b/EgtGeomKernel.vcxproj.filters
@@ -227,15 +227,18 @@
File di intestazione
-
- File di intestazione
-
File di intestazione
File di intestazione
+
+ File di intestazione
+
+
+ File di intestazione
+
diff --git a/OutScl.cpp b/OutScl.cpp
index 146dd41..1139e49 100644
--- a/OutScl.cpp
+++ b/OutScl.cpp
@@ -278,7 +278,7 @@ OutScl::CircleCR( const Point3d& ptCen, double dRad)
//----------------------------------------------------------------------------
bool
-OutScl::ArcCurvOrTgOrNone( const Point3d& ptFin, const Vector3d& vtT, const Vector3d& vtN, double dCurv)
+OutScl::ArcCurvOrTgOrNone( const CrvPointDiffGeom& oDiffG)
{
bool bCCW ;
double dAngCenDeg ;
@@ -286,21 +286,21 @@ OutScl::ArcCurvOrTgOrNone( const Point3d& ptFin, const Vector3d& vtT, const Vect
// curvatura
- if ( fabs( dCurv) > EPS_ZERO) {
+ if ( oDiffG.nStatus == CrvPointDiffGeom::NCRV && fabs( oDiffG.dCurv) > EPS_ZERO) {
// tratto di arco
- ptCen = ptFin + vtN / dCurv ;
- bCCW = ( vtT ^ vtN).z > 0 ;
- dAngCenDeg = ( bCCW ? 1 : -1) * 4 * dCurv * RADTODEG ;
- ArcCPA( ptCen, ptFin, dAngCenDeg) ;
+ ptCen = oDiffG.ptP + oDiffG.vtN / oDiffG.dCurv ;
+ bCCW = ( oDiffG.vtT ^ oDiffG.vtN).z > 0 ;
+ dAngCenDeg = ( bCCW ? 1 : -1) * 4 * oDiffG.dCurv * RADTODEG ;
+ ArcCPA( ptCen, oDiffG.ptP, dAngCenDeg) ;
// raggio
- Line2P( ptFin, ptCen) ;
+ Line2P( oDiffG.ptP, ptCen) ;
}
// altrimenti, tangente
- else if ( ! vtT.IsSmall())
- Line2P( ptFin - vtT, ptFin + vtT) ;
+ else if ( oDiffG.nStatus == CrvPointDiffGeom::TANG && ! oDiffG.vtT.IsSmall())
+ Line2P( oDiffG.ptP - oDiffG.vtT, oDiffG.ptP + oDiffG.vtT) ;
// altrimenti cerchietto
else
- CircleCR( ptFin, 1) ;
+ CircleCR( oDiffG.ptP, 1) ;
return true ;
}
@@ -343,12 +343,10 @@ OutScl::PutCurveArc( const ICurveArc& CrvArc, int nFlag)
{
bool bFound ;
double dU ;
- double dCurv ;
Point3d ptIni ;
Point3d ptFin ;
- Vector3d vtT ;
- Vector3d vtN ;
PolyLine PL ;
+ CrvPointDiffGeom oDiffG ;
// ciclo sui segmenti
@@ -363,9 +361,9 @@ OutScl::PutCurveArc( const ICurveArc& CrvArc, int nFlag)
Remark( "ArcTangents+Der2") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
- CrvArc.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ;
+ CrvArc.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
- ArcCurvOrTgOrNone( ptFin, vtT, vtN, dCurv) ;
+ ArcCurvOrTgOrNone( oDiffG) ;
}
}
@@ -378,12 +376,10 @@ OutScl::PutCurveBez( const ICurveBezier& CrvBez, int nFlag)
{
bool bFound ;
double dU ;
- double dCurv ;
Point3d ptIni ;
Point3d ptFin ;
- Vector3d vtT ;
- Vector3d vtN ;
PolyLine PL ;
+ CrvPointDiffGeom oDiffG ;
// se richiesto anche il poligono di controllo
@@ -402,9 +398,9 @@ OutScl::PutCurveBez( const ICurveBezier& CrvBez, int nFlag)
Remark( "BezierTangents+Der2") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
- CrvBez.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ;
+ CrvBez.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
// curvatura o tangente o niente
- ArcCurvOrTgOrNone( ptFin, vtT, vtN, dCurv) ;
+ ArcCurvOrTgOrNone( oDiffG) ;
}
}
@@ -440,12 +436,11 @@ OutScl::PutCurveCompo( const ICurveComposite& CrvCompo, int nFlag)
{
bool bFound ;
double dU ;
- double dCurv ;
Point3d ptIni ;
Point3d ptFin ;
- Vector3d vtT ;
- Vector3d vtN ;
PolyLine PL ;
+ CrvPointDiffGeom oDiffG ;
+ CrvPointDiffGeom oDiffGs ;
// ciclo per disegnare i segmenti
@@ -460,15 +455,17 @@ OutScl::PutCurveCompo( const ICurveComposite& CrvCompo, int nFlag)
Remark( "CompositeTangents+Der2") ;
for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) {
// ricavo il punto, la tangente, la normale e la curvatura
- CrvCompo.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ;
- // curvatura o tangente o niente
- ArcCurvOrTgOrNone( ptFin, vtT, vtN, dCurv) ;
- // se alla giunzione tra due curve semplici, calcolo anche appena dopo
- if ( CrvCompo.IsParamAtJoint( dU)) {
- // ricavo il punto, la tangente, la normale e la curvatura
- CrvCompo.GetPointTangNormCurv( dU + EPS_ZERO, ptFin, vtT, vtN, dCurv) ;
- // curvatura o tangente o niente
- ArcCurvOrTgOrNone( ptFin, vtT, vtN, dCurv) ;
+ CrvCompo.GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ;
+ // emetto curvatura o tangente o niente
+ ArcCurvOrTgOrNone( oDiffG) ;
+ // se punto con possibili discontinuitā
+ if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) {
+ // ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore
+ CrvCompo.GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ;
+ // se ci sono delle discontinuitā
+ if ( ThereIsDiscontinuity( oDiffG, oDiffGs))
+ // emetto curvatura o tangente o niente
+ ArcCurvOrTgOrNone( oDiffGs) ;
}
}
}
diff --git a/OutScl.h b/OutScl.h
index f3c82de..5f2b85e 100644
--- a/OutScl.h
+++ b/OutScl.h
@@ -50,7 +50,7 @@ class OutScl
bool Arc3P( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3) ;
bool ArcCPA( const Point3d& ptCen, const Point3d& ptMed, double dAngCenDeg) ;
bool CircleCR( const Point3d& ptCen, double dRad) ;
- bool ArcCurvOrTgOrNone( const Point3d& ptFin, const Vector3d& vtT, const Vector3d& vtN, double dCurv) ;
+ bool ArcCurvOrTgOrNone( const CrvPointDiffGeom& oDiffG) ;
private :
std::ofstream m_ofFile ;
diff --git a/PolyLine.cpp b/PolyLine.cpp
index 0669d2b..9e78f32 100644
--- a/PolyLine.cpp
+++ b/PolyLine.cpp
@@ -81,7 +81,7 @@ PolyLine::Splice( PolyLine& PL)
//----------------------------------------------------------------------------
bool
-PolyLine::GetFirstUPoint( double* pdPar, Point3d* pptP)
+PolyLine::GetFirstUPoint( double* pdPar, Point3d* pptP) const
{
m_iter = m_lUPoints.begin() ;
if ( m_iter == m_lUPoints.end())
@@ -97,7 +97,7 @@ PolyLine::GetFirstUPoint( double* pdPar, Point3d* pptP)
//----------------------------------------------------------------------------
bool
-PolyLine::GetNextUPoint( double* pdPar, Point3d* pptP)
+PolyLine::GetNextUPoint( double* pdPar, Point3d* pptP) const
{
++ m_iter ;
if ( m_iter == m_lUPoints.end())
@@ -113,7 +113,7 @@ PolyLine::GetNextUPoint( double* pdPar, Point3d* pptP)
//----------------------------------------------------------------------------
bool
-PolyLine::GetLastUPoint( double* pdPar, Point3d* pptP)
+PolyLine::GetLastUPoint( double* pdPar, Point3d* pptP) const
{
if ( m_lUPoints.begin() == m_lUPoints.end())
return false ;
@@ -128,7 +128,7 @@ PolyLine::GetLastUPoint( double* pdPar, Point3d* pptP)
//----------------------------------------------------------------------------
bool
-PolyLine::GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin)
+PolyLine::GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const
{
// parametro e punto iniziali
m_iter = m_lUPoints.begin() ;
@@ -153,7 +153,7 @@ PolyLine::GetFirstULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d*
//----------------------------------------------------------------------------
bool
-PolyLine::GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin)
+PolyLine::GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d* pptFin) const
{
// parametro e punto iniziali (č il precedente finale)
if ( m_iter == m_lUPoints.end())