Version: 9.12.0
StdMeshers_FaceSide.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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;
53 struct SMESH_ComputeError;
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  const 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 "constructors"
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  const 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  const TopoDS_Edge& theEdge = TopoDS_Edge(),
146  SMESH_Mesh* theMesh = 0)
147  {
148  return StdMeshers_FaceSidePtr( new StdMeshers_FaceSide( theSideNodes, theFace, theEdge, theMesh ));
149  }
150 
154  static TSideVector GetFaceWires(const TopoDS_Face& theFace,
155  SMESH_Mesh & theMesh,
156  const bool theIgnoreMediumNodes,
157  TError & theError,
158  SMESH_MesherHelper* theFaceHelper = NULL,
160  const bool theCheckVertexNodes = true);
164  void Reverse();
168  void SetIgnoreMediumNodes(bool toIgnore);
169 
175  smIdType NbPoints(const bool update = false) const;
181  smIdType NbSegments(const bool update = false) const;
185  SMESH_Mesh* GetMesh() const { return myProxyMesh->GetMesh(); }
189  bool MissVertexNode() const { return myMissingVertexNodes; }
190 
199  const UVPtStructVec& GetUVPtStruct( bool isXConst = 0, double constValue = 0 ) const;
205  const UVPtStructVec& SimulateUVPtStruct(int nbSeg,
206  bool isXConst = 0,
207  double constValue = 0) const;
213  std::vector<const SMDS_MeshNode*> GetOrderedNodes( int iE = ALL_EDGES ) const;
214 
220  bool GetEdgeNodes(const size_t i,
221  std::vector<const SMDS_MeshNode*>& nodes,
222  bool inlude1stVertex=true,
223  bool inludeLastVertex=true) const;
224 
229  const SMDS_MeshNode* VertexNode(std::size_t i, bool* isMoved = 0) const;
230 
231  /*
232  * \brief Return edge and parameter on edge by normalized parameter
233  */
234  inline double Parameter(double U, TopoDS_Edge & edge) const;
235  /*
236  * \brief Return edge ID and parameter on edge by normalized parameter
237  */
238  inline double Parameter(double U, int & edgeID) const;
242  gp_Pnt2d Value2d(double U) const;
246  gp_Pnt Value3d(double U) const;
250  Adaptor2d_Curve2d* GetCurve2d() const;
254  BRepAdaptor_CompCurve* GetCurve3d() const;
258  int NbEdges() const { return (int)myEdge.size(); }
262  const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
266  const std::vector<TopoDS_Edge>& Edges() const { return myEdge; }
270  const TopoDS_Face& Face() const { return myFace; }
274  TopoDS_Vertex FirstVertex(int i=0) const;
278  TopoDS_Vertex LastVertex(int i = LAST_EDGE) const;
282  bool IsClosed() const;
286  double Length() const { return myLength; }
290  inline int EdgeIndex( double U ) const;
291 
292  void dump(const char* msg=0) const;
293 
297  inline int EdgeID(int i) const;
301  inline Handle(Geom2d_Curve) Curve2d(int i) const;
305  inline double FirstParameter(int i) const;
309  inline double LastParameter(int i) const;
314  inline double FirstU(int i) const;
319  inline double LastU(int i) const;
323  inline double EdgeLength(int i) const;
327  inline bool IsReversed(int i) const;
331  SMESH_MesherHelper* FaceHelper() const;
332 
333 protected:
334 
335  void reverseProxySubmesh( const TopoDS_Edge& E );
336 
337  // DON't FORGET to update Reverse() when adding one more vector!
338  TopoDS_Face myFace;
339  std::vector<uvPtStruct> myPoints, myFalsePoints;
340  std::vector<TopoDS_Edge> myEdge;
341  std::vector<int> myEdgeID;
342  std::vector<Handle(Geom2d_Curve)> myC2d;
343  std::vector<GeomAdaptor_Curve> myC3dAdaptor;
344  std::vector<double> myFirst, myLast;
345  std::vector<double> myNormPar;
346  std::vector<double> myEdgeLength;
347  std::vector<int> myIsUniform;
348  double myLength;
349  smIdType myNbPonits, myNbSegments;
351  bool myMissingVertexNodes, myIgnoreMediumNodes;
352  gp_Pnt2d myDefaultPnt2d;
354 };
355 
356 
357 //================================================================================
363 //================================================================================
364 
365 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
366 {
367  int i = (int)myNormPar.size() - 1;
368  while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
369  return i;
370 }
371 
372 //================================================================================
380 //================================================================================
381 
382 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
383 {
384  int i = EdgeIndex( U );
385  edge = myEdge[ i ];
386  double prevU = i ? myNormPar[ i-1 ] : 0;
387  double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
388  return myFirst[i] * ( 1 - r ) + myLast[i] * r;
389 }
390 
391 //================================================================================
399 //================================================================================
400 
401 inline double StdMeshers_FaceSide::Parameter(double U, int & edgeID) const
402 {
403  int i = EdgeIndex( U );
404  edgeID = myEdgeID[ i ];
405  double prevU = i ? myNormPar[ i-1 ] : 0;
406  double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
407  return myFirst[i] * ( 1 - r ) + myLast[i] * r;
408 }
409 
410 //================================================================================
414 //================================================================================
415 
416 inline double StdMeshers_FaceSide::FirstParameter(int i) const
417 {
418  return i==0 ? 0. : i<(int)myNormPar.size() ? myNormPar[i-1] : 1.;
419 }
420 
421 //================================================================================
425 //================================================================================
426 
427 inline double StdMeshers_FaceSide::LastParameter(int i) const
428 {
429  return i < (int)myNormPar.size() ? myNormPar[i] : 1;
430 }
431 
432 //================================================================================
436 //================================================================================
437 
438 inline double StdMeshers_FaceSide::FirstU(int i) const
439 {
440  return myFirst[ i % myFirst.size() ];
441 }
442 
443 //================================================================================
447 //================================================================================
448 
449 inline double StdMeshers_FaceSide::LastU(int i) const
450 {
451  return myLast[ i % myLast.size() ];
452 }
453 
454 //================================================================================
458 //================================================================================
459 
460 inline int StdMeshers_FaceSide::EdgeID(int i) const
461 {
462  return myEdgeID[ i % myEdgeID.size() ];
463 }
464 
465 //================================================================================
469 //================================================================================
470 
471 inline Handle(Geom2d_Curve) StdMeshers_FaceSide::Curve2d(int i) const
472 {
473  return myC2d[ i % myC2d.size() ];
474 }
475 
476 //================================================================================
480  //================================================================================
481 
482 inline double StdMeshers_FaceSide::EdgeLength(int i) const
483 {
484  return myEdgeLength[ i % myEdgeLength.size() ];
485 }
486 
487 //================================================================================
491  //================================================================================
492 
493 inline bool StdMeshers_FaceSide::IsReversed(int i) const
494 {
495  return myFirst[i] > myLast[i];
496 }
497 
498 #endif
Handle(SALOME_InteractiveObject) GeomSelectionTools
Return the first selected Salome Interactive Object (Handle(Salome_InteractiveObject))
Definition: GeomSelectionTools.cxx:97
#define STDMESHERS_EXPORT
Definition: SMESH_StdMeshers.hxx:38
std::vector< UVPtStruct > UVPtStructVec
Definition: SMESH_TypeDefs.hxx:256
std::vector< StdMeshers_FaceSidePtr > TSideVector
Definition: StdMeshers_FaceSide.hxx:57
boost::shared_ptr< SMESH_ComputeError > TError
Definition: StdMeshers_FaceSide.hxx:53
boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr
Definition: StdMeshers_FaceSide.hxx:56
Definition: SMDS_MeshNode.hxx:36
Definition: SMESH_Mesh.hxx:80
It helps meshers to add elements and provides other utilities.
Definition: SMESH_MesherHelper.hxx:84
boost::shared_ptr< SMESH_ProxyMesh > Ptr
Definition: SMESH_ProxyMesh.hxx:54
Represents a side of a quasi quadrilateral face.
Definition: StdMeshers_FaceSide.hxx:67
int EdgeID(int i) const
Return ID of i-th wrapped edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:460
double myLength
Definition: StdMeshers_FaceSide.hxx:348
std::vector< TopoDS_Edge > myEdge
Definition: StdMeshers_FaceSide.hxx:340
int EdgeIndex(double U) const
Return edge index corresponding to normalized parameter.
Definition: StdMeshers_FaceSide.hxx:365
std::vector< double > myEdgeLength
Definition: StdMeshers_FaceSide.hxx:346
double LastU(int i) const
Return last parameter of the i-th edge (count starts from zero).
Definition: StdMeshers_FaceSide.hxx:449
std::vector< Handle(Geom2d_Curve)> myC2d
Definition: StdMeshers_FaceSide.hxx:342
const std::vector< TopoDS_Edge > & Edges() const
Return all edges.
Definition: StdMeshers_FaceSide.hxx:266
gp_Pnt2d myDefaultPnt2d
Definition: StdMeshers_FaceSide.hxx:352
double FirstParameter(int i) const
Return first normalized parameter of the i-th edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:416
static StdMeshers_FaceSidePtr New(const TopoDS_Face &Face, const TopoDS_Edge &Edge, SMESH_Mesh *Mesh, const bool IsForward, const bool IgnoreMediumNodes, SMESH_MesherHelper *FaceHelper=NULL, SMESH_ProxyMesh::Ptr ProxyMesh=SMESH_ProxyMesh::Ptr())
Definition: StdMeshers_FaceSide.hxx:113
TopoDS_Face myFace
Definition: StdMeshers_FaceSide.hxx:338
static StdMeshers_FaceSidePtr New(const StdMeshers_FaceSide *Side, const SMDS_MeshNode *Node, const gp_Pnt2d *Pnt2d1, const gp_Pnt2d *Pnt2d2=NULL, const Handle(Geom2d_Curve)&C2d=NULL, const double UFirst=0., const double ULast=1.)
Definition: StdMeshers_FaceSide.hxx:133
std::vector< double > myNormPar
Definition: StdMeshers_FaceSide.hxx:345
bool MissVertexNode() const
Return true if there are vertices without nodes.
Definition: StdMeshers_FaceSide.hxx:189
const TopoDS_Edge & Edge(int i) const
Return i-th edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:262
std::vector< int > myEdgeID
Definition: StdMeshers_FaceSide.hxx:341
const TopoDS_Face & Face() const
Return the FACE.
Definition: StdMeshers_FaceSide.hxx:270
bool IsReversed(int i) const
Return orientation of i-th wrapped edge (count starts from zero)
double EdgeLength(int i) const
Return length of i-th wrapped edge (count starts from zero)
SMESH_Mesh * GetMesh() const
Return mesh.
Definition: StdMeshers_FaceSide.hxx:185
double Parameter(double U, TopoDS_Edge &edge) const
Return an edge and parameter on the edge by a normalized parameter.
Definition: StdMeshers_FaceSide.hxx:382
bool myIgnoreMediumNodes
Definition: StdMeshers_FaceSide.hxx:351
static StdMeshers_FaceSidePtr New(const TopoDS_Face &Face, const std::list< TopoDS_Edge > &Edges, SMESH_Mesh *Mesh, const bool IsForward, const bool IgnoreMediumNodes, SMESH_MesherHelper *FaceHelper=NULL, SMESH_ProxyMesh::Ptr ProxyMesh=SMESH_ProxyMesh::Ptr())
Definition: StdMeshers_FaceSide.hxx:123
double FirstU(int i) const
Return first parameter of the i-th edge (count starts from zero).
Definition: StdMeshers_FaceSide.hxx:438
SMESH_MesherHelper * myHelper
Definition: StdMeshers_FaceSide.hxx:353
std::vector< double > myLast
Definition: StdMeshers_FaceSide.hxx:344
std::vector< double > myFirst
Definition: StdMeshers_FaceSide.hxx:344
double Length() const
Return side length.
Definition: StdMeshers_FaceSide.hxx:286
int NbEdges() const
Return nb of wrapped edges.
Definition: StdMeshers_FaceSide.hxx:258
std::vector< uvPtStruct > myFalsePoints
Definition: StdMeshers_FaceSide.hxx:339
smIdType myNbPonits
Definition: StdMeshers_FaceSide.hxx:349
static StdMeshers_FaceSidePtr New(UVPtStructVec &theSideNodes, const TopoDS_Face &theFace=TopoDS_Face(), const TopoDS_Edge &theEdge=TopoDS_Edge(), SMESH_Mesh *theMesh=0)
Definition: StdMeshers_FaceSide.hxx:143
double LastParameter(int i) const
Return last normalized parameter of the i-th edge (count starts from zero)
Definition: StdMeshers_FaceSide.hxx:427
std::vector< GeomAdaptor_Curve > myC3dAdaptor
Definition: StdMeshers_FaceSide.hxx:343
Handle(Geom2d_Curve) Curve2d(int i) const
Return p-curve of i-th wrapped edge (count starts from zero)
std::vector< int > myIsUniform
Definition: StdMeshers_FaceSide.hxx:347
SMESH_ProxyMesh::Ptr myProxyMesh
Definition: StdMeshers_FaceSide.hxx:350
@ Face
Selection of faces.
Definition: libSMESH_Swig.h:56
@ Edge
Selection of edges.
Definition: libSMESH_Swig.h:55
@ Node
Selection of mesh nodes.
Definition: libSMESH_Swig.h:52
int GetEdgeNodes(SVTK_Selector *theSelector, const TVisualObjPtr &theVisualObject, ::smIdType &theId1, ::smIdType &theId2)
Definition: SMESHGUI_VTKUtils.cxx:1228
Contains an algorithm and description of an occurred error.
Definition: SMESH_ComputeError.hxx:74