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