Salome HOME
Merging with WPdev
[modules/smesh.git] / src / StdMeshers / StdMeshers_Quadrangle_2D.hxx
1 //  SMESH SMESH : implementaion of SMESH idl descriptions
2 //
3 //  Copyright (C) 2003  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 //
23 //
24 //  File   : StdMeshers_Quadrangle_2D.hxx
25 //           Moved here from SMESH_Quadrangle_2D.hxx
26 //  Author : Paul RASCLE, EDF
27 //  Module : SMESH
28 //  $Header$
29
30 #ifndef _SMESH_QUADRANGLE_2D_HXX_
31 #define _SMESH_QUADRANGLE_2D_HXX_
32
33 #include "SMESH_StdMeshers.hxx"
34
35 #include "SMESH_2D_Algo.hxx"
36 #include "SMESH_Mesh.hxx"
37 #include "Utils_SALOME_Exception.hxx"
38
39 #include "gp_XY.hxx"
40
41 #include "SMESH_MesherHelper.hxx"
42
43 //class SMDS_MeshNode;
44
45 typedef struct uvPtStruct
46 {
47   double param;
48   double normParam;
49   double u; // original 2d parameter
50   double v;
51   double x; // 2d parameter, normalized [0,1]
52   double y; 
53   const SMDS_MeshNode * node;
54 } UVPtStruct;
55
56 typedef struct faceQuadStruct
57 {
58   int nbPts[4];
59   TopoDS_Edge edge[4];
60   double first[4];
61   double last[4];
62   bool isEdgeForward[4];
63   bool isEdgeOut[4]; // true, if an edge has more nodes, than the opposite
64   UVPtStruct* uv_edges[4];
65   UVPtStruct* uv_grid;
66 } FaceQuadStruct;
67
68 class STDMESHERS_EXPORT StdMeshers_Quadrangle_2D:
69   public SMESH_2D_Algo
70 {
71 public:
72   StdMeshers_Quadrangle_2D(int hypId, int studyId, SMESH_Gen* gen);
73   virtual ~StdMeshers_Quadrangle_2D();
74
75   virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
76                                const TopoDS_Shape& aShape,
77                                SMESH_Hypothesis::Hypothesis_Status& aStatus);
78
79   virtual bool Compute(SMESH_Mesh& aMesh,
80                        const TopoDS_Shape& aShape)
81     throw (SALOME_Exception);
82
83   FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
84                                     const TopoDS_Shape& aShape,
85                                     const bool CreateQuadratic)
86     throw (SALOME_Exception);
87
88   static void QuadDelete(FaceQuadStruct* quad);
89
90   /**
91    * Returns NLinkNodeMap from myTool
92    */
93   const NLinkNodeMap& GetNLinkNodeMap() { return myTool->GetNLinkNodeMap(); }
94
95   ostream & SaveTo(ostream & save);
96   istream & LoadFrom(istream & load);
97   friend ostream & operator << (ostream & save, StdMeshers_Quadrangle_2D & hyp);
98   friend istream & operator >> (istream & load, StdMeshers_Quadrangle_2D & hyp);
99
100 protected:
101
102   FaceQuadStruct* CheckNbEdges(SMESH_Mesh& aMesh,
103                                const TopoDS_Shape& aShape)
104     throw (SALOME_Exception);
105
106   void SetNormalizedGrid(SMESH_Mesh& aMesh,
107                          const TopoDS_Shape& aShape,
108                          FaceQuadStruct*& quad)
109     throw (SALOME_Exception);
110
111   /**
112    * Special function for creation only quandrangle faces
113    */
114   bool ComputeQuadPref(SMESH_Mesh& aMesh,
115                        const TopoDS_Shape& aShape,
116                        FaceQuadStruct* quad)
117     throw (SALOME_Exception);
118
119   UVPtStruct* LoadEdgePoints2(SMESH_Mesh& aMesh,
120                               const TopoDS_Face& F, const TopoDS_Edge& E,
121                               bool IsReverse);
122
123   UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh,
124                              const TopoDS_Face& F, const TopoDS_Edge& E,
125                              double first, double last);
126
127   UVPtStruct* MakeEdgePoints(SMESH_Mesh& aMesh,
128                              const TopoDS_Face& F, const TopoDS_Edge& E,
129                              double first, double last, int nb_segm);
130
131   // true if QuadranglePreference hypothesis is assigned that forces
132   // construction of quadrangles if the number of nodes on opposite edges
133   // is not the same in the case where the global number of nodes on edges is even
134   bool myQuadranglePreference;
135
136   SMESH_MesherHelper* myTool; // toll for working with quadratic elements
137 };
138
139 #endif