Salome HOME
PAL18352, PAL19290: Conflict in objects selections when switching modules
[modules/smesh.git] / src / StdMeshers / StdMeshers_Penta_3D.hxx
1 //  SMESH StdMeshers : 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_Penta_3D.hxx
25 //  Module : SMESH
26
27 #ifndef StdMeshers_Penta_3D_HeaderFile
28 #define StdMeshers_Penta_3D_HeaderFile
29
30 #include <map>
31
32 ////////////////////////////////////////////////////////////////////////
33 //
34 //  class StdMeshers_SMESHBlock
35 //
36 ////////////////////////////////////////////////////////////////////////
37 #include <gp_Pnt.hxx>
38 #include <gp_XYZ.hxx>
39 #include <TopoDS_Vertex.hxx>
40 #include <TopoDS_Shell.hxx>
41 #include <TopTools_IndexedMapOfOrientedShape.hxx>
42 #include <TColStd_MapOfInteger.hxx>
43
44 #include "SMESH_Block.hxx"
45 #include "SMESH_ComputeError.hxx"
46 #include "SMESH_MesherHelper.hxx"
47
48 typedef std::map< double, std::vector<const SMDS_MeshNode*> > StdMeshers_IJNodeMap;
49
50 class StdMeshers_SMESHBlock {
51  
52 public:
53   //
54   StdMeshers_SMESHBlock();
55   
56   void Load (const TopoDS_Shell& theShell);
57   
58   void Load (const TopoDS_Shell& theShell,
59              const TopoDS_Vertex& theV000,
60              const TopoDS_Vertex& theV001);
61   
62   void ComputeParameters(const gp_Pnt& thePnt, 
63                          gp_XYZ& theXYZ);
64   
65   void ComputeParameters(const gp_Pnt& thePnt,
66                          const TopoDS_Shape& theShape,
67                          gp_XYZ& theXYZ);
68   
69   void ComputeParameters(const double& theU,
70                          const TopoDS_Shape& theShape,
71                          gp_XYZ& theXYZ);
72   
73   void Point(const gp_XYZ& theParams, 
74              gp_Pnt& thePnt);
75   
76   void Point(const gp_XYZ& theParams,
77              const TopoDS_Shape& theShape, 
78              gp_Pnt& thePnt);
79   
80   int ShapeID(const TopoDS_Shape& theShape); 
81   
82   const TopoDS_Shape& Shape(const int theID);
83
84   SMESH_Block & Block() { return myTBlock; }
85
86   bool IsForwadEdge(const int theEdgeID);
87
88   int  ErrorStatus() const;
89
90   SMESH_ComputeErrorPtr GetError() const;
91
92
93 protected:
94   TopoDS_Shell                       myShell;
95   TopTools_IndexedMapOfOrientedShape myShapeIDMap;
96   SMESH_Block                        myTBlock;
97   TopoDS_Shape                       myEmptyShape;
98   vector<int>                        myIsEdgeForward;
99   //
100   int myErrorStatus;
101 };
102
103 ////////////////////////////////////////////////////////////////////////
104 //
105 //  class StdMeshers_TNode
106 //
107 ////////////////////////////////////////////////////////////////////////
108 #include "SMDS_MeshNode.hxx"
109
110 class StdMeshers_TNode {
111
112 public:
113   
114   StdMeshers_TNode(){
115     myNode=NULL;
116     myXYZ.SetCoord(99., 99., 99.);
117     myShapeSupportID=-1;
118     myBaseNodeID=-1;
119   }
120   
121   void SetNode(const SMDS_MeshNode* theNode) {
122     myNode=(SMDS_MeshNode*) theNode;
123   }
124   
125   const SMDS_MeshNode* Node()const {
126     return myNode;
127   }
128
129   void SetShapeSupportID (const int theID) {
130     myShapeSupportID=theID;
131   }
132   
133   int ShapeSupportID()const {
134     return myShapeSupportID;
135   }
136   
137   void SetNormCoord (const gp_XYZ& theXYZ) {
138     myXYZ=theXYZ;
139   }
140
141   const gp_XYZ& NormCoord ()const{
142     return myXYZ;
143   }
144   
145   void SetBaseNodeID (const int theID) {
146     myBaseNodeID=theID;
147   }
148   
149   int BaseNodeID ()const{
150     return myBaseNodeID;
151   }
152
153 private:
154   SMDS_MeshNode* myNode;
155   int  myShapeSupportID;
156   gp_XYZ         myXYZ;
157   int            myBaseNodeID;
158 };
159
160 ////////////////////////////////////////////////////////////////////////
161 //
162 //  class StdMeshers_Penta_3D
163 //
164 ////////////////////////////////////////////////////////////////////////
165 #include "SMESH_Mesh.hxx"
166 #include <TopoDS_Shape.hxx>
167 //
168 class StdMeshers_Penta_3D {
169 //
170   public: // methods
171     StdMeshers_Penta_3D();
172     
173     ~StdMeshers_Penta_3D();
174     
175     bool Compute(SMESH_Mesh& , const TopoDS_Shape& );
176     
177     int ErrorStatus() const {
178       if (myErrorStatus->IsOK())
179         return 0;
180       return myErrorStatus->myName;
181     }
182
183     SMESH_ComputeErrorPtr GetComputeError() const {
184       return myErrorStatus;
185     }
186    
187     void SetTolerance(const double theTol3D) {
188       myTol3D=theTol3D;
189     }
190     
191     double Tolerance() const {
192       return myTol3D;
193     }
194
195     bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
196                      const TopoDS_Face&     theFace,
197                      const TopoDS_Edge&     theBaseEdge,
198                      SMESHDS_Mesh*          theMesh);
199     // Load nodes bound to theFace into column (vectors) and rows
200     // of theIJNodes.
201     // The value of theIJNodes map is a vector of ordered nodes so
202     // that the 0-the one lies on theBaseEdge.
203     // The key of theIJNodes map is a normalized parameter of each
204     // 0-the node on theBaseEdge.
205
206
207   protected: // methods
208     
209     void CheckData();
210     
211     void MakeBlock();
212
213     void MakeNodes();
214
215     double SetHorizEdgeXYZ(const gp_XYZ&                  aBNXYZ,
216                            const int                      aFaceID,
217                            vector<const SMDS_MeshNode*>*& aCol1,
218                            vector<const SMDS_MeshNode*>*& aCol2);
219
220     void ShapeSupportID(const bool theIsUpperLayer,
221                         const SMESH_Block::TShapeID theBNSSID,
222                         SMESH_Block::TShapeID& theSSID);
223
224     void FindNodeOnShape(const TopoDS_Shape& aS,
225                          const gp_XYZ& aParams,
226                          const int z,
227                          StdMeshers_TNode& aTN);
228
229     void CreateNode(const bool theIsUpperLayer,
230                     const gp_XYZ& aParams,
231                     StdMeshers_TNode& aTN);
232
233     void ClearMeshOnFxy1();
234
235     void MakeMeshOnFxy1();
236
237     void MakeConnectingMap();
238
239     int GetIndexOnLayer(const int aID);
240
241     void MakeVolumeMesh();
242   
243     void SetMesh(SMESH_Mesh& theMesh) {
244       myMesh=(void *)&theMesh;
245     }
246     
247     SMESH_Mesh* GetMesh()const {
248       return (SMESH_Mesh*)myMesh;
249     }
250     
251   protected: // fields
252     TopoDS_Shape              myShape;
253     StdMeshers_SMESHBlock     myBlock;
254     void *                    myMesh;
255     SMESH_ComputeErrorPtr     myErrorStatus;
256     //
257     vector <StdMeshers_TNode> myTNodes;
258     int                       myISize;
259     int                       myJSize;
260     double                    myTol3D;        // Tolerance value     
261     std::map < int, int >     myConnectingMap;
262     //
263     vector<StdMeshers_IJNodeMap> myWallNodesMaps; // nodes on a face
264     vector<gp_XYZ>            myShapeXYZ; // point on each sub-shape
265
266     bool myCreateQuadratic;
267     SMESH_MesherHelper* myTool; // tool building quadratic elements
268 };
269
270 #endif