From ed16ca5f3a14264d942e08ef45bbe3ae3e102e74 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 5 Apr 2017 06:48:11 +0000 Subject: [PATCH] EgtGeomKernel : - aggiunta AdjustCurveSlope. --- CurveAux.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/CurveAux.cpp b/CurveAux.cpp index bf755c1..e8dcb13 100644 --- a/CurveAux.cpp +++ b/CurveAux.cpp @@ -734,4 +734,39 @@ ProjectCurveOnPlane( const ICurve& crCrv, const Plane3d& plPlane) return nullptr ; // restituisco la nuova curva return Release( pCrv) ; -} \ No newline at end of file +} + +//---------------------------------------------------------------------------- +bool +AdjustCurveSlope( ICurveComposite* pCrv, double dNini, double dNfin) +{ + // verifico curva + if ( pCrv == nullptr) + return false ; + // determino versore estrusione + Vector3d vtN ; + if ( ! pCrv->GetExtrusion( vtN) || vtN.IsSmall()) + vtN = Z_AX ; + // assegno la corretta pendenza + int i = 0 ; + double dCurrLen = 0 ; + double dLen ; pCrv->GetLength( dLen) ; + const ICurve* pSCrv = pCrv->GetFirstCurve() ; + while ( pSCrv != nullptr) { + double dCrvLen ; + pSCrv->GetLength( dCrvLen) ; + double dCoeff = dCurrLen / dLen ; + double dCurrN = dNini * ( 1.0 - dCoeff) + dNfin * dCoeff ; + Point3d ptJoin ; + pSCrv->GetStartPoint( ptJoin) ; + pCrv->ModifyJoint( i, ptJoin + vtN * ( dCurrN - ( ptJoin - ORIG) * vtN)) ; + // passo al successivo + dCurrLen += dCrvLen ; + pSCrv = pCrv->GetNextCurve() ; + ++ i ; + } + Point3d ptFin ; pCrv->GetEndPoint( ptFin) ; + ptFin += vtN * ( dNfin - ( ptFin - ORIG) * vtN) ; + pCrv->ModifyEnd( ptFin) ; + return true ; +}