From: eap Date: Wed, 26 Jan 2005 08:32:21 +0000 (+0000) Subject: PAL7358. Add VertexParameters() and EdgeParameters() X-Git-Tag: V2_2_0b2~26 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=a4f98fe737bc2fa31c83806448d5c8118b8d64ea;hp=efdf984e40ba00513859a612721ebe25e711b851 PAL7358. Add VertexParameters() and EdgeParameters() --- diff --git a/src/SMESH/SMESH_Block.cxx b/src/SMESH/SMESH_Block.cxx index 016805fd3..4c55ca8e4 100644 --- a/src/SMESH/SMESH_Block.cxx +++ b/src/SMESH/SMESH_Block.cxx @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -381,9 +384,24 @@ bool SMESH_Block::ComputeParameters(const gp_Pnt& thePoint, gp_XYZ& theParams, const int theShapeID) { + if ( VertexParameters( theShapeID, theParams )) + return true; + + if ( IsEdgeID( theShapeID )) { + TEdge& e = myEdge[ theShapeID - ID_Ex00 ]; + GeomAdaptor_Curve curve( e.myC3d ); + double f = Min( e.myFirst, e.myLast ), l = Max( e.myFirst, e.myLast ); + Extrema_ExtPC anExtPC( thePoint, curve, f, l ); + int i, nb = anExtPC.IsDone() ? anExtPC.NbExt() : 0; + for ( i = 1; i <= nb; i++ ) { + if ( anExtPC.IsMin( i )) + return EdgeParameters( theShapeID, anExtPC.Point( i ).Parameter(), theParams ); + } + return false; + } + // MESSAGE( endl<<"SMESH_Block::ComputeParameters( " // < vertexVec; + GetEdgeVertexIDs( theEdgeID, vertexVec ); + VertexParameters( vertexVec[0], theParams ); + TEdge& e = myEdge[ theEdgeID - ID_Ex00 ]; + double param = ( theU - e.myFirst ) / ( e.myLast - e.myFirst ); + theParams.SetCoord( e.myCoordInd, param ); + return true; + } + return false; +} + //======================================================================= //function : GetStateNumber //purpose : diff --git a/src/SMESH/SMESH_Block.hxx b/src/SMESH/SMESH_Block.hxx index 7ab38891a..7258fdeff 100644 --- a/src/SMESH/SMESH_Block.hxx +++ b/src/SMESH/SMESH_Block.hxx @@ -122,7 +122,14 @@ class SMESH_Block: public math_FunctionSetWithDerivatives bool ComputeParameters (const gp_Pnt& thePoint, gp_XYZ& theParams, const int theShapeID = ID_Shell); - // compute point parameters in the block + // compute point parameters in the block. + // Note: for edges, it is better to use EdgeParameters() + + bool VertexParameters(const int theVertexID, gp_XYZ& theParams); + // return parameters of a vertex given by TShapeID + + bool EdgeParameters(const int theEdgeID, const double theU, gp_XYZ& theParams); + // return parameters of a point given by theU on edge static void GetFaceEdgesIDs (const int faceID, vector< int >& edgeVec ); // return edges IDs of a face in the order u0, u1, 0v, 1v