SALOME - SMESH
StdMeshers_FaceSide.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : StdMeshers_FaceSide.hxx
24 // Created : Wed Jan 31 18:41:25 2007
25 // Author : Edward AGAPOV (eap)
26 // Module : SMESH
27 //
28 #ifndef StdMeshers_FaceSide_HeaderFile
29 #define StdMeshers_FaceSide_HeaderFile
30 
31 #include <gp_Pnt2d.hxx>
32 #include <TopoDS_Edge.hxx>
33 #include <TopoDS_Vertex.hxx>
34 #include <Geom2d_Curve.hxx>
35 #include <TopExp.hxx>
36 
37 #include "SMESH_StdMeshers.hxx"
38 #include "SMESH_Algo.hxx"
39 
40 #include <vector>
41 #include <list>
42 #include <boost/shared_ptr.hpp>
43 
44 class SMDS_MeshNode;
45 class SMESH_Mesh;
46 class Adaptor2d_Curve2d;
47 class Adaptor3d_Curve;
48 class BRepAdaptor_CompCurve;
49 class TopoDS_Face;
50 struct SMESH_ComputeError;
51 
52 typedef struct uvPtStruct
53 {
54  double param;
55  //int curvIndex;
56  double normParam;
57  double u; // original 2d parameter
58  double v;
59  double x; // 2d parameter, normalized [0,1]
60  double y;
62 } UVPtStruct;
63 
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;
69 
70 //================================================================================
75 //================================================================================
76 
78 {
79 public:
83  StdMeshers_FaceSide(const TopoDS_Face& theFace,
84  const TopoDS_Edge& theEdge,
85  SMESH_Mesh* theMesh,
86  const bool theIsForward,
87  const bool theIgnoreMediumNodes);
91  StdMeshers_FaceSide(const TopoDS_Face& theFace,
92  std::list<TopoDS_Edge>& theEdges,
93  SMESH_Mesh* theMesh,
94  const bool theIsForward,
95  const bool theIgnoreMediumNodes);
99  StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
100  const gp_Pnt2d thePnt2d,
101  const StdMeshers_FaceSide* theSide);
105  static TSideVector GetFaceWires(const TopoDS_Face& theFace,
106  SMESH_Mesh & theMesh,
107  const bool theIgnoreMediumNodes,
108  TError & theError);
109 
113  void Reverse();
117  int NbPoints() const { return myNbPonits; }
121  int NbSegments() const { return myNbSegments; }
125  SMESH_Mesh* GetMesh() const { return myMesh; }
129  bool MissVertexNode() const { return myMissingVertexNodes; }
137  const std::vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
143  const std::vector<UVPtStruct>& SimulateUVPtStruct(int nbSeg,
144  bool isXConst = 0,
145  double constValue = 0) const;
149  inline double Parameter(double U, TopoDS_Edge & edge) const;
153  gp_Pnt2d Value2d(double U) const;
157  Adaptor2d_Curve2d* GetCurve2d() const;
161  BRepAdaptor_CompCurve* GetCurve3d() const;
165  int NbEdges() const { return myEdge.size(); }
169  const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
173  inline TopoDS_Vertex FirstVertex(int i=0) const;
177  inline TopoDS_Vertex LastVertex(int i=-1) const;
181  inline double FirstParameter(int i) const;
185  inline double LastParameter(int i) const;
189  double Length() const { return myLength; }
193  inline int EdgeIndex( double U ) const;
194 
195  //virtual gp_Pnt Value(double U) const;
196 
197  void dump(const char* msg=0) const;
198 
199 
200 protected:
201  std::vector<uvPtStruct> myPoints, myFalsePoints;
202  std::vector<TopoDS_Edge> myEdge;
203  std::vector<Handle(Geom2d_Curve)> myC2d;
204  std::vector<double> myFirst, myLast;
205  std::vector<double> myNormPar;
206  double myLength;
207  int myNbPonits, myNbSegments;
209  bool myMissingVertexNodes, myIgnoreMediumNodes;
210  gp_Pnt2d myDefaultPnt2d;
211 };
212 
213 
214 //================================================================================
220 //================================================================================
221 
222 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
223 {
224  int i = myNormPar.size() - 1;
225  while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
226  return i;
227 }
228 
229 //================================================================================
235 //================================================================================
236 
237 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
238 {
239  int i = EdgeIndex( U );
240  edge = myEdge[ i ];
241  double prevU = i ? myNormPar[ i-1 ] : 0;
242  double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
243  return myFirst[i] * ( 1 - r ) + myLast[i] * r;
244 }
245 
246 //================================================================================
250 //================================================================================
251 
252 inline TopoDS_Vertex StdMeshers_FaceSide::FirstVertex(int i) const
253 {
254  return i < myEdge.size() ? TopExp::FirstVertex( myEdge[i], 1 ) : TopoDS_Vertex();
255 }
256 
257 //================================================================================
261 //================================================================================
262 
263 inline TopoDS_Vertex StdMeshers_FaceSide::LastVertex(int i) const
264 {
265  return i<0 ? TopExp::LastVertex( myEdge.back(), 1) : i<myEdge.size() ? TopExp::LastVertex( myEdge[i], 1 ) : TopoDS_Vertex();
266 }
267 
268 //================================================================================
272 //================================================================================
273 
274 inline double StdMeshers_FaceSide::FirstParameter(int i) const
275 {
276  return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
277 }
278 
279 //================================================================================
283 //================================================================================
284 
285 inline double StdMeshers_FaceSide::LastParameter(int i) const
286 {
287  return i<myNormPar.size() ? myNormPar[i] : 1;
288 }
289 
290 #endif
uvPtStruct::v
double v
Definition: StdMeshers_FaceSide.hxx:58
SMESH_StdMeshers.hxx
SMESH_Algo.hxx
StdMeshers_FaceSide::Edge
const TopoDS_Edge & Edge(int i) const
Return i-th wrapped edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:169
StdMeshers_FaceSide::LastVertex
TopoDS_Vertex LastVertex(int i=-1) const
Return last vertex of the i-the edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:263
StdMeshers_FaceSide::Parameter
double Parameter(double U, TopoDS_Edge &edge) const
Return edge and parameter on edge by normalized parameter.
Definition: StdMeshers_FaceSide.hxx:237
StdMeshers_FaceSide::myDefaultPnt2d
gp_Pnt2d myDefaultPnt2d
Definition: StdMeshers_FaceSide.hxx:210
uvPtStruct::y
double y
Definition: StdMeshers_FaceSide.hxx:60
StdMeshers_FaceSide::myMissingVertexNodes
bool myMissingVertexNodes
Definition: StdMeshers_FaceSide.hxx:209
StdMeshers_FaceSide::Length
double Length() const
Return side length.
Definition: StdMeshers_FaceSide.hxx:189
StdMeshers_FaceSidePtr
boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr
Definition: StdMeshers_FaceSide.hxx:64
StdMeshers_FaceSide::myPoints
std::vector< uvPtStruct > myPoints
Definition: StdMeshers_FaceSide.hxx:201
uvPtStruct
Definition: StdMeshers_FaceSide.hxx:52
TSideVector
std::vector< StdMeshers_FaceSidePtr > TSideVector
Definition: StdMeshers_FaceSide.hxx:67
uvPtStruct::param
double param
Definition: StdMeshers_FaceSide.hxx:54
StdMeshers_FaceSide::FirstParameter
double FirstParameter(int i) const
Return first normalized parameter of the i-the edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:274
StdMeshers_FaceSide
Represents a side of a quasi quadrilateral face. It can be composed of several edges....
Definition: StdMeshers_FaceSide.hxx:77
uvPtStruct::node
const SMDS_MeshNode * node
Definition: StdMeshers_FaceSide.hxx:61
StdMeshers_FaceSide::myLength
double myLength
Definition: StdMeshers_FaceSide.hxx:206
StdMeshers_FaceSide::LastParameter
double LastParameter(int i) const
Return ast normalized parameter of the i-the edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:285
uvPtStruct::u
double u
Definition: StdMeshers_FaceSide.hxx:57
StdMeshers_FaceSide::MissVertexNode
bool MissVertexNode() const
Return true if there vertices without nodes.
Definition: StdMeshers_FaceSide.hxx:129
StdMeshers_FaceSide::EdgeIndex
int EdgeIndex(double U) const
Return edge index corresponding to normalized parameter.
Definition: StdMeshers_FaceSide.hxx:222
UVPtStruct
struct uvPtStruct UVPtStruct
UVPtStructPtr
boost::shared_ptr< uvPtStruct > UVPtStructPtr
Definition: StdMeshers_FaceSide.hxx:66
Adaptor3d_Curve
StdMeshers_FaceSide::myNbSegments
int myNbSegments
Definition: StdMeshers_FaceSide.hxx:207
SMESH_Mesh
Definition: SMESH_Mesh.hxx:54
TError
boost::shared_ptr< SMESH_ComputeError > TError
Definition: StdMeshers_FaceSide.hxx:68
SMESH_ComputeError
Contains algorithm and description of occured error.
Definition: SMESH_ComputeError.hxx:64
uvPtStruct::normParam
double normParam
Definition: StdMeshers_FaceSide.hxx:56
StdMeshers_FaceSide::NbPoints
int NbPoints() const
Return nb nodes on edges and vertices (+1 to be == GetUVPtStruct().size() )
Definition: StdMeshers_FaceSide.hxx:117
STDMESHERS_EXPORT
#define STDMESHERS_EXPORT
Definition: SMESH_StdMeshers.hxx:37
StdMeshers_FaceSide::myC2d
std::vector< Handle(Geom2d_Curve)> myC2d
Definition: StdMeshers_FaceSide.hxx:203
StdMeshers_FaceSide::FirstVertex
TopoDS_Vertex FirstVertex(int i=0) const
Return 1st vertex of the i-the edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:252
uvPtStruct::x
double x
Definition: StdMeshers_FaceSide.hxx:59
Adaptor2d_Curve2d
SMDS_MeshNode
Definition: SMDS_MeshNode.hxx:35
StdMeshers_FaceSide::GetMesh
SMESH_Mesh * GetMesh() const
Return mesh.
Definition: StdMeshers_FaceSide.hxx:125
StdMeshers_FaceSide::NbEdges
int NbEdges() const
Return nb of wrapped edges.
Definition: StdMeshers_FaceSide.hxx:165
StdMeshers_FaceSide::myMesh
SMESH_Mesh * myMesh
Definition: StdMeshers_FaceSide.hxx:208
StdMeshers_FaceSide::myFirst
std::vector< double > myFirst
Definition: StdMeshers_FaceSide.hxx:204
StdMeshers_FaceSide::NbSegments
int NbSegments() const
Return nb edges.
Definition: StdMeshers_FaceSide.hxx:121
StdMeshers_FaceSide::myEdge
std::vector< TopoDS_Edge > myEdge
Definition: StdMeshers_FaceSide.hxx:202
StdMeshers_FaceSide::myLast
std::vector< double > myLast
Definition: StdMeshers_FaceSide.hxx:204
StdMeshers_FaceSide::myNormPar
std::vector< double > myNormPar
Definition: StdMeshers_FaceSide.hxx:205