diff --git a/IntersLineSurfBez.cpp b/IntersLineSurfBez.cpp index b9780e1..2a6d42d 100644 --- a/IntersLineSurfBez.cpp +++ b/IntersLineSurfBez.cpp @@ -282,22 +282,23 @@ IntersLineSurfBzBilinear( const Point3d& ptL, const Vector3d& vtL, double dLen, int nRoots = PolynomialRoots( 2, vdCoeff, vdRoots) ; bool bFound = false ; for( int w = 0 ; w < nRoots ; ++w) { - if ( vdRoots[w] > 0 - EPS_ZERO && vdRoots[w] < 1 + EPS_ZERO ) { - double dU = 0, dV = vdRoots[w] ; - // verifico che non sia una soluzione con molteplicità > 1 - bool bAlreadyFound = false ; - for ( int k = w - 1 ; k >= 0 && ! bAlreadyFound ; --k) - bAlreadyFound = abs( dV - vdRoots[k]) < EPS_PARAM ; - if( ! bAlreadyFound) { - dU = (dV * (C1 - C2) + ( D1 - D2)) / ( dV * ( A2 - A1) + ( B2 - B1)) ; - if ( dU > - EPS_ZERO && dU < 1 + EPS_ZERO) { - Point3d ptIBez, ptIBez2 ; - Vector3d vtN ; - pSurfBz->GetPointNrmD1D2(dU, dV, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptIBez, vtN) ; - Point3d ptSP( dU, dV, 0), ptSP2 ; - double dCos = vtN * vtL, dCos2 = 0 ; - UpdateInfoIntersLineSurfBz( ptL, vtL, ILTT_NO_TRIA, -1, ptSP, ptIBez, dCos, ptSP2, ptIBez2, dCos2, vInfo) ; - bFound = true ; + if ( vdRoots[w] > 0 - EPS_ZERO && vdRoots[w] < 1 + EPS_ZERO ) { + double dU = 0, dV = vdRoots[w] ; + // verifico che non sia una soluzione con molteplicità > 1 + bool bAlreadyFound = false ; + for ( int k = w - 1 ; k >= 0 && ! bAlreadyFound ; --k) + bAlreadyFound = abs( dV - vdRoots[k]) < EPS_PARAM ; + if( ! bAlreadyFound) { + dU = (dV * (C1 - C2) + ( D1 - D2)) / ( dV * ( A2 - A1) + ( B2 - B1)) ; + if ( dU > - EPS_ZERO && dU < 1 + EPS_ZERO) { + Point3d ptIBez, ptIBez2 ; + Vector3d vtN ; + pSurfBz->GetPointNrmD1D2(dU, dV, ISurfBezier::Side::FROM_MINUS, ISurfBezier::Side::FROM_MINUS, ptIBez, vtN) ; + Point3d ptSP( dU, dV, 0), ptSP2 ; + double dCos = vtN * vtL, dCos2 = 0 ; + UpdateInfoIntersLineSurfBz( ptL, vtL, ILTT_NO_TRIA, -1, ptSP, ptIBez, dCos, ptSP2, ptIBez2, dCos2, vInfo) ; + bFound = true ; + } } } } @@ -334,11 +335,11 @@ IntersLineSurfBzBilinear( const Point3d& ptL, const Vector3d& vtL, double dLen, } Point3d ptInt1, ptInt2 ; - if ( c < nTot - 1 && c > 0) { + if ( nClosestLine < nTot - 1 && nClosestLine > 0) { // tra i due tratti dell'approssimazione che arrivano al punto selezionato come più vicino, devo trovare quale si avvicina di più Point3d ptStart ; plApprox.GetFirstPoint( ptStart) ; Point3d ptEnd ; - for( int z = 1 ; z < c - 1 ; ++z) + for( int z = 1 ; z < nClosestLine - 1 ; ++z) plApprox.GetNextPoint( ptStart) ; plApprox.GetNextPoint( ptEnd) ; // linea precedente al punto @@ -361,7 +362,7 @@ IntersLineSurfBzBilinear( const Point3d& ptL, const Vector3d& vtL, double dLen, else dllCurr.GetMinDistPoints( ptInt1, ptInt2) ; } - else if ( c == 0){ + else if ( nClosestLine == 0){ // il punto più vicino è sulla prima linea Point3d ptStart ; plApprox.GetFirstPoint( ptStart) ; Point3d ptEnd ; plApprox.GetNextPoint( ptEnd) ; @@ -370,11 +371,11 @@ IntersLineSurfBzBilinear( const Point3d& ptL, const Vector3d& vtL, double dLen, DistLineLine dllCurr( ptStart, vtLineCurr, dLenCurr, ptL, vtL,dLen) ; dllCurr.GetMinDistPoints( ptInt1, ptInt2) ; } - else if ( c == nTot- 1) { + else if ( nClosestLine == nTot- 1) { // il punto più vicino è sull'ultima linea Point3d ptStart ; plApprox.GetFirstPoint( ptStart) ; Point3d ptEnd ; - for( int z = 1 ; z < c - 1 ; ++z) + for( int z = 1 ; z < nClosestLine - 1 ; ++z) plApprox.GetNextPoint( ptStart) ; plApprox.GetNextPoint( ptEnd) ; Vector3d vtLinePre = ptEnd - ptStart ;