+ case POS_LEFT: // point is most close to an edge
+ {
+ gp_Vec edge( xyz[ pos._index ], xyz[ pos._index+1 ]);
+ gp_Vec n1p ( xyz[ pos._index ], point );
+ double u = ( edge * n1p ) / edge.SquareMagnitude(); // param [0,1] on the edge
+ // projection of the point on the edge
+ gp_XYZ proj = xyz[ pos._index ] + u * edge.XYZ();
+ double dist2 = point.SquareDistance( proj );
+ if ( dist2 < minDist2 )
+ {
+ if ( closestPnt ) *closestPnt = proj;
+ minDist2 = dist2;