Version: 8.3.0
StdMeshers_FaceSide.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 
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 "SMESH_StdMeshers.hxx"
32 
33 #include "SMESH_ProxyMesh.hxx"
34 
35 #include <Geom2d_Curve.hxx>
36 #include <GeomAdaptor_Curve.hxx>
37 #include <TopoDS_Edge.hxx>
38 #include <TopoDS_Face.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <gp_Pnt2d.hxx>
41 
42 #include <vector>
43 #include <list>
44 #include <boost/shared_ptr.hpp>
45 
46 class Adaptor2d_Curve2d;
47 class Adaptor3d_Curve;
48 class BRepAdaptor_CompCurve;
49 class SMDS_MeshNode;
50 class SMESH_Mesh;
51 class SMESH_MesherHelper;
54 
55 typedef boost::shared_ptr< SMESH_ComputeError > TError;
56 typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
57 typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
58 
59 //================================================================================
64 //================================================================================
65 
67 {
68 public:
69 
70  enum { ALL_EDGES = -1, LAST_EDGE = -1 };
71 
75  StdMeshers_FaceSide(const TopoDS_Face& theFace,
76  const TopoDS_Edge& theEdge,
77  SMESH_Mesh* theMesh,
78  const bool theIsForward,
79  const bool theIgnoreMediumNodes,
80  SMESH_MesherHelper* theFaceHelper = NULL,
85  StdMeshers_FaceSide(const TopoDS_Face& theFace,
86  std::list<TopoDS_Edge>& theEdges,
87  SMESH_Mesh* theMesh,
88  const bool theIsForward,
89  const bool theIgnoreMediumNodes,
90  SMESH_MesherHelper* theFaceHelper = NULL,
96  const SMDS_MeshNode* theNode,
97  const gp_Pnt2d* thePnt2d1,
98  const gp_Pnt2d* thePnt2d2 = NULL,
99  const Handle(Geom2d_Curve)& theC2d = NULL,
100  const double theUFirst = 0.,
101  const double theULast = 1.);
105  StdMeshers_FaceSide(UVPtStructVec& theSideNodes,
106  const TopoDS_Face& theFace = TopoDS_Face(),
107  const TopoDS_Edge& theEdge = TopoDS_Edge(),
108  SMESH_Mesh* theMesh = 0);
109 
111 
112  // static "consrtuctors"
113  static StdMeshers_FaceSidePtr New(const TopoDS_Face& Face,
114  const TopoDS_Edge& Edge,
115  SMESH_Mesh* Mesh,
116  const bool IsForward,
117  const bool IgnoreMediumNodes,
118  SMESH_MesherHelper* FaceHelper = NULL,
120  { return StdMeshers_FaceSidePtr
121  ( new StdMeshers_FaceSide( Face,Edge,Mesh,IsForward,IgnoreMediumNodes,FaceHelper,ProxyMesh ));
122  }
123  static StdMeshers_FaceSidePtr New (const TopoDS_Face& Face,
124  std::list<TopoDS_Edge>& Edges,
125  SMESH_Mesh* Mesh,
126  const bool IsForward,
127  const bool IgnoreMediumNodes,
128  SMESH_MesherHelper* FaceHelper = NULL,
130  { return StdMeshers_FaceSidePtr
131  ( new StdMeshers_FaceSide( Face,Edges,Mesh,IsForward,IgnoreMediumNodes,FaceHelper,ProxyMesh ));
132  }
134  const SMDS_MeshNode* Node,
135  const gp_Pnt2d* Pnt2d1,
136  const gp_Pnt2d* Pnt2d2 = NULL,
137  const Handle(Geom2d_Curve)& C2d = NULL,
138  const double UFirst = 0.,
139  const double ULast = 1.)
140  { return StdMeshers_FaceSidePtr
141  ( new StdMeshers_FaceSide( Side,Node,Pnt2d1,Pnt2d2,C2d,UFirst,ULast ));
142  }
143  static StdMeshers_FaceSidePtr New (UVPtStructVec& theSideNodes,
144  const TopoDS_Face& theFace = TopoDS_Face())
145  {
146  return StdMeshers_FaceSidePtr( new StdMeshers_FaceSide( theSideNodes, theFace ));
147  }
148 
152  static TSideVector GetFaceWires(const TopoDS_Face& theFace,
153  SMESH_Mesh & theMesh,
154  const bool theIgnoreMediumNodes,
155  TError & theError,
156  SMESH_MesherHelper* theFaceHelper = NULL,
158  const bool theCheckVertexNodes = true);
162  void Reverse();
166  void SetIgnoreMediumNodes(bool toIgnore);
167 
173  int NbPoints(const bool update = false) const;
179  int NbSegments(const bool update = false) const;
183  SMESH_Mesh* GetMesh() const { return myProxyMesh->GetMesh(); }
187  bool MissVertexNode() const { return myMissingVertexNodes; }
188 
197  const UVPtStructVec& GetUVPtStruct( bool isXConst = 0, double constValue = 0 ) const;
203  const UVPtStructVec& SimulateUVPtStruct(int nbSeg,
204  bool isXConst = 0,
205  double constValue = 0) const;
211  std::vector<const SMDS_MeshNode*> GetOrderedNodes( int iE = ALL_EDGES ) const;
212 
218  bool GetEdgeNodes(const size_t i,
219  std::vector<const SMDS_MeshNode*>& nodes,
220  bool inlude1stVertex=true,
221  bool inludeLastVertex=true) const;
222 
227  const SMDS_MeshNode* VertexNode(std::size_t i, bool* isMoved = 0) const;
228 
229  /*
230  * \brief Return edge and parameter on edge by normalized parameter
231  */
232  inline double Parameter(double U, TopoDS_Edge & edge) const;
233  /*
234  * \brief Return edge ID and parameter on edge by normalized parameter
235  */
236  inline double Parameter(double U, int & edgeID) const;
240  gp_Pnt2d Value2d(double U) const;
244  gp_Pnt Value3d(double U) const;
248  Adaptor2d_Curve2d* GetCurve2d() const;
252  BRepAdaptor_CompCurve* GetCurve3d() const;
256  int NbEdges() const { return myEdge.size(); }
260  const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
264  const std::vector<TopoDS_Edge>& Edges() const { return myEdge; }
268  const TopoDS_Face& Face() const { return myFace; }
272  TopoDS_Vertex FirstVertex(int i=0) const;
276  TopoDS_Vertex LastVertex(int i = LAST_EDGE) const;
280  bool IsClosed() const;
284  double Length() const { return myLength; }
288  inline int EdgeIndex( double U ) const;
289 
290  void dump(const char* msg=0) const;
291 
295  inline int EdgeID(int i) const;
299  inline Handle(Geom2d_Curve) Curve2d(int i) const;
303  inline double FirstParameter(int i) const;
307  inline double LastParameter(int i) const;
312  inline double FirstU(int i) const;
317  inline double LastU(int i) const;
321  inline double EdgeLength(int i) const;
325  inline bool IsReversed(int i) const;
329  SMESH_MesherHelper* FaceHelper() const;
330 
331 protected:
332 
333  void reverseProxySubmesh( const TopoDS_Edge& E );
334 
335  // DON't FORGET to update Reverse() when adding one more vector!
336  TopoDS_Face myFace;
337  std::vector<uvPtStruct> myPoints, myFalsePoints;
338  std::vector<TopoDS_Edge> myEdge;
339  std::vector<int> myEdgeID;
340  std::vector<Handle(Geom2d_Curve)> myC2d;
341  std::vector<GeomAdaptor_Curve> myC3dAdaptor;
342  std::vector<double> myFirst, myLast;
343  std::vector<double> myNormPar;
344  std::vector<double> myEdgeLength;
345  std::vector<int> myIsUniform;
346  double myLength;
347  int myNbPonits, myNbSegments;
348  SMESH_ProxyMesh::Ptr myProxyMesh;
349  bool myMissingVertexNodes, myIgnoreMediumNodes;
350  gp_Pnt2d myDefaultPnt2d;
352 };
353 
354 
355 //================================================================================
361 //================================================================================
362 
363 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
364 {
365  int i = myNormPar.size() - 1;
366  while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
367  return i;
368 }
369 
370 //================================================================================
378 //================================================================================
379 
380 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
381 {
382  int i = EdgeIndex( U );
383  edge = myEdge[ i ];
384  double prevU = i ? myNormPar[ i-1 ] : 0;
385  double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
386  return myFirst[i] * ( 1 - r ) + myLast[i] * r;
387 }
388 
389 //================================================================================
397 //================================================================================
398 
399 inline double StdMeshers_FaceSide::Parameter(double U, int & edgeID) const
400 {
401  int i = EdgeIndex( U );
402  edgeID = myEdgeID[ i ];
403  double prevU = i ? myNormPar[ i-1 ] : 0;
404  double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
405  return myFirst[i] * ( 1 - r ) + myLast[i] * r;
406 }
407 
408 //================================================================================
412 //================================================================================
413 
414 inline double StdMeshers_FaceSide::FirstParameter(int i) const
415 {
416  return i==0 ? 0. : i<(int)myNormPar.size() ? myNormPar[i-1] : 1.;
417 }
418 
419 //================================================================================
423 //================================================================================
424 
425 inline double StdMeshers_FaceSide::LastParameter(int i) const
426 {
427  return i < (int)myNormPar.size() ? myNormPar[i] : 1;
428 }
429 
430 //================================================================================
434 //================================================================================
435 
436 inline double StdMeshers_FaceSide::FirstU(int i) const
437 {
438  return myFirst[ i % myFirst.size() ];
439 }
440 
441 //================================================================================
445 //================================================================================
446 
447 inline double StdMeshers_FaceSide::LastU(int i) const
448 {
449  return myLast[ i % myLast.size() ];
450 }
451 
452 //================================================================================
456 //================================================================================
457 
458 inline int StdMeshers_FaceSide::EdgeID(int i) const
459 {
460  return myEdgeID[ i % myEdgeID.size() ];
461 }
462 
463 //================================================================================
467 //================================================================================
468 
469 inline Handle(Geom2d_Curve) StdMeshers_FaceSide::Curve2d(int i) const
470 {
471  return myC2d[ i % myC2d.size() ];
472 }
473 
474 //================================================================================
478  //================================================================================
479 
480 inline double StdMeshers_FaceSide::EdgeLength(int i) const
481 {
482  return myEdgeLength[ i % myEdgeLength.size() ];
483 }
484 
485 //================================================================================
489  //================================================================================
490 
491 inline bool StdMeshers_FaceSide::IsReversed(int i) const
492 {
493  return myFirst[i] > myLast[i];
494 }
495 
496 #endif