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