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