Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
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
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
91 protected:
92   TopoDS_Shell                       myShell;
93   TopTools_IndexedMapOfOrientedShape myShapeIDMap;
94   SMESH_Block                        myTBlock;
95   TopoDS_Shape                       myEmptyShape;
96   vector<int>                        myIsEdgeForward;
97   //
98   int myErrorStatus;
99 };
100
101 ////////////////////////////////////////////////////////////////////////
102 //
103 //  class StdMeshers_TNode
104 //
105 ////////////////////////////////////////////////////////////////////////
106 #include "SMDS_MeshNode.hxx"
107
108 class StdMeshers_TNode {
109
110 public:
111   
112   StdMeshers_TNode(){
113     myNode=NULL;
114     myXYZ.SetCoord(99., 99., 99.);
115     myShapeSupportID=-1;
116     myBaseNodeID=-1;
117   }
118   
119   void SetNode(const SMDS_MeshNode* theNode) {
120     myNode=(SMDS_MeshNode*) theNode;
121   }
122   
123   const SMDS_MeshNode* Node()const {
124     return myNode;
125   }
126
127   void SetShapeSupportID (const int theID) {
128     myShapeSupportID=theID;
129   }
130   
131   int ShapeSupportID()const {
132     return myShapeSupportID;
133   }
134   
135   void SetNormCoord (const gp_XYZ& theXYZ) {
136     myXYZ=theXYZ;
137   }
138
139   const gp_XYZ& NormCoord ()const{
140     return myXYZ;
141   }
142   
143   void SetBaseNodeID (const int theID) {
144     myBaseNodeID=theID;
145   }
146   
147   int BaseNodeID ()const{
148     return myBaseNodeID;
149   }
150
151 private:
152   SMDS_MeshNode* myNode;
153   int  myShapeSupportID;
154   gp_XYZ         myXYZ;
155   int            myBaseNodeID;
156 };
157
158 ////////////////////////////////////////////////////////////////////////
159 //
160 //  class StdMeshers_Penta_3D
161 //
162 ////////////////////////////////////////////////////////////////////////
163 #include "SMESH_Mesh.hxx"
164 #include <TopoDS_Shape.hxx>
165 //
166 class StdMeshers_Penta_3D {
167 //
168   public: // methods
169     StdMeshers_Penta_3D();
170     
171     ~StdMeshers_Penta_3D();
172     
173     bool Compute(SMESH_Mesh& , const TopoDS_Shape& );
174     
175     int ErrorStatus() const {
176       return myErrorStatus;
177     }
178    
179     void SetTolerance(const double theTol3D) {
180       myTol3D=theTol3D;
181     }
182     
183     double Tolerance() const {
184       return myTol3D;
185     }
186
187     bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
188                      const TopoDS_Face&     theFace,
189                      const TopoDS_Edge&     theBaseEdge,
190                      SMESHDS_Mesh*          theMesh);
191     // Load nodes bound to theFace into column (vectors) and rows
192     // of theIJNodes.
193     // The value of theIJNodes map is a vector of ordered nodes so
194     // that the 0-the one lies on theBaseEdge.
195     // The key of theIJNodes map is a normalized parameter of each
196     // 0-the node on theBaseEdge.
197
198
199   protected: // methods
200     
201     void CheckData();
202     
203     void MakeBlock();
204
205     void MakeNodes();
206
207     double SetHorizEdgeXYZ(const gp_XYZ&                  aBNXYZ,
208                            const int                      aFaceID,
209                            vector<const SMDS_MeshNode*>*& aCol1,
210                            vector<const SMDS_MeshNode*>*& aCol2);
211
212     void ShapeSupportID(const bool theIsUpperLayer,
213                         const SMESH_Block::TShapeID theBNSSID,
214                         SMESH_Block::TShapeID& theSSID);
215
216     void FindNodeOnShape(const TopoDS_Shape& aS,
217                          const gp_XYZ& aParams,
218                          const int z,
219                          StdMeshers_TNode& aTN);
220
221     void CreateNode(const bool theIsUpperLayer,
222                     const gp_XYZ& aParams,
223                     StdMeshers_TNode& aTN);
224
225     void ClearMeshOnFxy1();
226
227     void MakeMeshOnFxy1();
228
229     void MakeConnectingMap();
230
231     int GetIndexOnLayer(const int aID);
232
233     void MakeVolumeMesh();
234   
235     void SetMesh(SMESH_Mesh& theMesh) {
236       myMesh=(void *)&theMesh;
237     }
238     
239     SMESH_Mesh* GetMesh()const {
240       return (SMESH_Mesh*)myMesh;
241     }
242     
243   protected: // fields
244     TopoDS_Shape              myShape;
245     StdMeshers_SMESHBlock     myBlock;
246     void *                    myMesh;
247     int                       myErrorStatus;
248     //
249     vector <StdMeshers_TNode> myTNodes;
250     int                       myISize;
251     int                       myJSize;
252     double                    myTol3D;        // Tolerance value     
253     std::map < int, int >     myConnectingMap;
254     //
255     vector<StdMeshers_IJNodeMap> myWallNodesMaps; // nodes on a face
256     vector<gp_XYZ>            myShapeXYZ; // point on each sub-shape
257
258     bool myCreateQuadratic;
259     SMESH_MesherHelper* myTool; // toll for working with quadratic elements
260 };
261
262 #endif