1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : StdMeshers_FaceSide.hxx
25 // Created : Wed Jan 31 18:41:25 2007
26 // Author : Edward AGAPOV (eap)
29 #ifndef StdMeshers_FaceSide_HeaderFile
30 #define StdMeshers_FaceSide_HeaderFile
32 #include <gp_Pnt2d.hxx>
33 #include <TopoDS_Edge.hxx>
34 #include <TopoDS_Vertex.hxx>
35 #include <Geom2d_Curve.hxx>
40 #include <boost/shared_ptr.hpp>
44 class Adaptor2d_Curve2d;
45 class Adaptor3d_Curve;
46 class BRepAdaptor_CompCurve;
48 class SMESH_ComputeError;
50 typedef struct uvPtStruct
55 double u; // original 2d parameter
57 double x; // 2d parameter, normalized [0,1]
59 const SMDS_MeshNode * node;
62 class StdMeshers_FaceSide;
63 typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
64 typedef boost::shared_ptr< uvPtStruct > UVPtStructPtr;
65 typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
66 typedef boost::shared_ptr< SMESH_ComputeError > TError;
68 //================================================================================
70 * \brief Represents a side of a quasi quadrilateral face.
71 * It can be composed of several edges. Gives access to geometry and 1D mesh of a side.
73 //================================================================================
75 class StdMeshers_FaceSide
79 * \brief Wrap one edge
81 StdMeshers_FaceSide(const TopoDS_Face& theFace,
82 const TopoDS_Edge& theEdge,
84 const bool theIsForward,
85 const bool theIgnoreMediumNodes);
87 * \brief Wrap several edges. Edges must be properly ordered and oriented.
89 StdMeshers_FaceSide(const TopoDS_Face& theFace,
90 list<TopoDS_Edge>& theEdges,
92 const bool theIsForward,
93 const bool theIgnoreMediumNodes);
96 * \brief Return wires of a face as StdMeshers_FaceSide's
98 static TSideVector GetFaceWires(const TopoDS_Face& theFace,
100 const bool theIgnoreMediumNodes,
104 * \brief Change orientation of side geometry
108 * \brief Return nb nodes on edges and vertices (+1 to be == GetUVPtStruct().size() )
110 int NbPoints() const { return myNbPonits; }
112 * \brief Return nb edges
114 int NbSegments() const { return myNbSegments; }
118 SMESH_Mesh* GetMesh() const { return myMesh; }
120 * \brief Return true if there vertices without nodes
122 bool MissVertexNode() const { return myMissingVertexNodes; }
124 * \brief Return detailed data on nodes
125 * \param isXConst - true if normalized parameter X is constant
126 * \param constValue - constant parameter value
128 * Missing nodes are allowed only on internal vertices
130 const vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
132 * \brief Simulates detailed data on nodes
133 * \param isXConst - true if normalized parameter X is constant
134 * \param constValue - constant parameter value
136 const vector<UVPtStruct>& SimulateUVPtStruct(int nbSeg,
138 double constValue = 0) const;
140 * \brief Return edge and parameter on edge by normalized parameter
142 inline double Parameter(double U, TopoDS_Edge & edge) const;
144 * \brief Return UV by normalized parameter
146 gp_Pnt2d Value2d(double U) const;
148 * \brief Creates a Adaptor2d_Curve2d to be used in SMESH_Block
150 Adaptor2d_Curve2d* GetCurve2d() const;
152 * \brief Creates a fully functional Adaptor_Curve
154 BRepAdaptor_CompCurve* GetCurve3d() const;
156 * \brief Return nb of wrapped edges
158 int NbEdges() const { return myEdge.size(); }
160 * \brief Return i-th wrapped edge (count starts from zero)
162 const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
164 * \brief Return 1st vertex of the i-the edge (count starts from zero)
166 inline TopoDS_Vertex FirstVertex(int i=0) const;
168 * \brief Return last vertex of the i-the edge (count starts from zero)
170 inline TopoDS_Vertex LastVertex(int i=-1) const;
172 * \brief Return first normalized parameter of the i-the edge (count starts from zero)
174 inline double FirstParameter(int i) const;
176 * \brief Return ast normalized parameter of the i-the edge (count starts from zero)
178 inline double LastParameter(int i) const;
180 * \brief Return side length
182 double Length() const { return myLength; }
184 * \brief Return edge index corresponding to normalized parameter
186 inline int EdgeIndex( double U ) const;
188 //virtual gp_Pnt Value(double U) const;
190 void dump(const char* msg=0) const;
194 vector<uvPtStruct> myPoints, myFalsePoints;
195 vector<TopoDS_Edge> myEdge;
196 vector<Handle(Geom2d_Curve)> myC2d;
197 vector<double> myFirst, myLast;
198 vector<double> myNormPar;
200 int myNbPonits, myNbSegments;
202 bool myMissingVertexNodes, myIgnoreMediumNodes;
206 //================================================================================
208 * \brief Return edge index corresponding to normalized parameter
209 * \param U - the parameter
210 * \retval int - index
212 //================================================================================
214 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
216 int i = myNormPar.size() - 1;
217 while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
221 //================================================================================
223 * \brief Return edge and parameter on edge by normalized parameter
224 * \param U - the parameter
225 * \retval double - pameter on a curve
227 //================================================================================
229 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
231 int i = EdgeIndex( U );
233 double prevU = i ? myNormPar[ i-1 ] : 0;
234 double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
235 return myFirst[i] * ( 1 - r ) + myLast[i] * r;
238 //================================================================================
240 * \brief Return 1st vertex of the i-the edge
242 //================================================================================
244 inline TopoDS_Vertex StdMeshers_FaceSide::FirstVertex(int i) const
246 return i < myEdge.size() ? TopExp::FirstVertex( myEdge[i], 1 ) : TopoDS_Vertex();
249 //================================================================================
251 * \brief Return last vertex of the i-the edge
253 //================================================================================
255 inline TopoDS_Vertex StdMeshers_FaceSide::LastVertex(int i) const
257 return i<0 ? TopExp::LastVertex( myEdge.back(), 1) : i<myEdge.size() ? TopExp::LastVertex( myEdge[i], 1 ) : TopoDS_Vertex();
260 //================================================================================
262 * \brief Return first normalized parameter of the i-the edge
264 //================================================================================
266 inline double StdMeshers_FaceSide::FirstParameter(int i) const
268 return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
271 //================================================================================
273 * \brief Return ast normalized parameter of the i-the edge
275 //================================================================================
277 inline double StdMeshers_FaceSide::LastParameter(int i) const
279 return i<myNormPar.size() ? myNormPar[i] : 1;