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