diff --git a/RotationMinimizingFrame.cpp b/RotationMinimizingFrame.cpp index cbb878c..c81d7dc 100644 --- a/RotationMinimizingFrame.cpp +++ b/RotationMinimizingFrame.cpp @@ -92,11 +92,18 @@ RotationMinimizingFrame::GetFrameAtParam( const Frame3d& frAct, const double dPa Vector3d vtCurrR = frAct.VersX() ; Vector3d vtCurrT = frAct.VersZ() ; - // punto i-esimo sulla curva e suo vettore tangente + // punto i-esimo sulla curva e suo vettore tangente medio + Point3d ptNextM, ptNextP ; + Vector3d vtNextM, vtNextP ; + if ( ! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_MINUS, ptNextM, &vtNextM) || + ! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_PLUS, ptNextP, &vtNextP) || + ! vtNextM.Normalize() || ! vtNextP.Normalize()) + return false ; Point3d ptNext ; Vector3d vtNextT ; - if ( ! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_MINUS, ptNext, &vtNextT) || - ! vtNextT.Normalize()) + ptNext = Media( ptNextM, ptNextP) ; + vtNextT = Media( vtNextM, vtNextP) ; + if ( ! vtNextT.Normalize()) return false ; // controllo per casi degeneri diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index 8ccb23d..3ffa6ee 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -1095,7 +1095,7 @@ GetSurfTriMeshSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d // determino se la guida è chiusa bool bGuideClosed = pGuide->IsClosed() ; // determino algoritmo da usare per calcolare i riferimenti lungo la curva - bool bRMF = vtAx.IsSmall() ; + bool bRMF = ( ! vtAx.IsValid() || vtAx.IsSmall()) ; // riferimento all'inizio della linea guida Point3d ptStart ; @@ -1242,9 +1242,9 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, const Vector3d& if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd)) bIsLine = true ; } - // se la guida è piana + // se la guida è piana e il vettore di riferimento è non definito oppure non nullo Plane3d plGuide ; - if ( pGuide->IsFlat( plGuide, bIsLine, 10 * EPS_SMALL)) + if ( pGuide->IsFlat( plGuide, bIsLine, 10 * EPS_SMALL) && ( ! vtAx.IsValid() || ! vtAx.IsSmall())) return GetSurfTriMeshSweptInPlane( pSect, pGuide, plGuide.GetVersN(), bCapEnds, dLinTol) ; // altrimenti swept 3d