1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
23 // SMESH SMESH : implementaion of SMESH idl descriptions
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 <Geom2d_Curve.hxx>
33 #include <GeomAdaptor_Curve.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <TopoDS_Vertex.hxx>
36 #include <gp_Pnt2d.hxx>
38 #include "SMESH_StdMeshers.hxx"
42 #include <boost/shared_ptr.hpp>
46 class Adaptor2d_Curve2d;
47 class Adaptor3d_Curve;
48 class BRepAdaptor_CompCurve;
50 struct SMESH_ComputeError;
52 typedef struct uvPtStruct
57 double u; // original 2d parameter
59 double x; // 2d parameter, normalized [0,1]
61 const SMDS_MeshNode * node;
64 class StdMeshers_FaceSide;
65 typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
66 typedef boost::shared_ptr< uvPtStruct > UVPtStructPtr;
67 typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
68 typedef boost::shared_ptr< SMESH_ComputeError > TError;
70 //================================================================================
72 * \brief Represents a side of a quasi quadrilateral face.
73 * It can be composed of several edges. Gives access to geometry and 1D mesh of a side.
75 //================================================================================
77 class STDMESHERS_EXPORT StdMeshers_FaceSide
81 * \brief Wrap one edge
83 StdMeshers_FaceSide(const TopoDS_Face& theFace,
84 const TopoDS_Edge& theEdge,
86 const bool theIsForward,
87 const bool theIgnoreMediumNodes);
89 * \brief Wrap several edges. Edges must be properly ordered and oriented.
91 StdMeshers_FaceSide(const TopoDS_Face& theFace,
92 std::list<TopoDS_Edge>& theEdges,
94 const bool theIsForward,
95 const bool theIgnoreMediumNodes);
97 * \brief Wrap for vertex using data from other FaceSide
99 StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
100 const gp_Pnt2d thePnt2d,
101 const StdMeshers_FaceSide* theSide);
103 * \brief Return wires of a face as StdMeshers_FaceSide's
105 static TSideVector GetFaceWires(const TopoDS_Face& theFace,
106 SMESH_Mesh & theMesh,
107 const bool theIgnoreMediumNodes,
111 * \brief Change orientation of side geometry
115 * \brief Return nb nodes on edges and vertices (+1 to be == GetUVPtStruct().size() )
117 int NbPoints() const { return myNbPonits; }
119 * \brief Return nb edges
121 int NbSegments() const { return myNbSegments; }
125 SMESH_Mesh* GetMesh() const { return myMesh; }
127 * \brief Return true if there are vertices without nodes
129 bool MissVertexNode() const { return myMissingVertexNodes; }
131 * \brief Return detailed data on nodes
132 * \param isXConst - true if normalized parameter X is constant
133 * \param constValue - constant parameter value
135 * Missing nodes are allowed only on internal vertices
137 const std::vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
139 * \brief Simulates detailed data on nodes
140 * \param isXConst - true if normalized parameter X is constant
141 * \param constValue - constant parameter value
143 const std::vector<UVPtStruct>& SimulateUVPtStruct(int nbSeg,
145 double constValue = 0) const;
147 * \brief Return edge and parameter on edge by normalized parameter
149 inline double Parameter(double U, TopoDS_Edge & edge) const;
151 * \brief Return UV by normalized parameter
153 gp_Pnt2d Value2d(double U) const;
155 * \brief Creates a Adaptor2d_Curve2d to be used in SMESH_Block
157 Adaptor2d_Curve2d* GetCurve2d() const;
159 * \brief Creates a fully functional Adaptor_Curve
161 BRepAdaptor_CompCurve* GetCurve3d() const;
163 * \brief Return nb of wrapped edges
165 int NbEdges() const { return myEdge.size(); }
167 * \brief Return i-th wrapped edge (count starts from zero)
169 const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
171 * \brief Return 1st vertex of the i-the edge (count starts from zero)
173 TopoDS_Vertex FirstVertex(int i=0) const;
175 * \brief Return last vertex of the i-the edge (count starts from zero)
177 TopoDS_Vertex LastVertex(int i=-1) const;
179 * \brief Return first normalized parameter of the i-the edge (count starts from zero)
181 inline double FirstParameter(int i) const;
183 * \brief Return ast normalized parameter of the i-the edge (count starts from zero)
185 inline double LastParameter(int i) const;
187 * \brief Return side length
189 double Length() const { return myLength; }
191 * \brief Return edge index corresponding to normalized parameter
193 inline int EdgeIndex( double U ) const;
195 //virtual gp_Pnt Value(double U) const;
197 void dump(const char* msg=0) const;
202 // DON't FORGET tO update Reverse() when adding one more vector!
203 std::vector<uvPtStruct> myPoints, myFalsePoints;
204 std::vector<TopoDS_Edge> myEdge;
205 std::vector<Handle(Geom2d_Curve)> myC2d;
206 std::vector<GeomAdaptor_Curve> myC3dAdaptor;
207 std::vector<double> myFirst, myLast;
208 std::vector<double> myNormPar;
209 std::vector<double> myEdgeLength;
210 std::vector<double> myIsUniform;
212 int myNbPonits, myNbSegments;
214 bool myMissingVertexNodes, myIgnoreMediumNodes;
215 gp_Pnt2d myDefaultPnt2d;
219 //================================================================================
221 * \brief Return edge index corresponding to normalized parameter
222 * \param U - the parameter
223 * \retval int - index
225 //================================================================================
227 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
229 int i = myNormPar.size() - 1;
230 while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
234 //================================================================================
236 * \brief Return edge and parameter on edge by normalized parameter
237 * \param U - the parameter
238 * \retval double - pameter on a curve
240 //================================================================================
242 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
244 int i = EdgeIndex( U );
246 double prevU = i ? myNormPar[ i-1 ] : 0;
247 double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
248 return myFirst[i] * ( 1 - r ) + myLast[i] * r;
251 //================================================================================
253 * \brief Return first normalized parameter of the i-the edge
255 //================================================================================
257 inline double StdMeshers_FaceSide::FirstParameter(int i) const
259 return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
262 //================================================================================
264 * \brief Return ast normalized parameter of the i-the edge
266 //================================================================================
268 inline double StdMeshers_FaceSide::LastParameter(int i) const
270 return i<myNormPar.size() ? myNormPar[i] : 1;