Salome HOME
86087577202b7dd482a6399e628f9e6d90f538ec
[plugins/hybridplugin.git] / src / HYBRIDPlugin / HYBRIDPlugin_HYBRID.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File   : HYBRIDPlugin_HYBRID.hxx
22 // Author : Christian VAN WAMBEKE (CEA) (from GHS3D plugin V730)
23 // ---
24 //
25 #ifndef _HYBRIDPlugin_HYBRID_HXX_
26 #define _HYBRIDPlugin_HYBRID_HXX_
27
28 #include "SMESH_Algo.hxx"
29 #include "SMESH_Gen.hxx"
30 #include "SMESH_Gen_i.hxx"
31
32 #include <map>
33 #include <vector>
34
35 extern "C"
36 {
37   #include "libmesh5.h"
38 }
39
40 #ifndef GMFVERSION
41 #define GMFVERSION GmfDouble
42 #endif
43 #define GMFDIMENSION 3
44
45 class HYBRIDPlugin_Hypothesis;
46 class SMDS_MeshNode;
47 class SMESH_Mesh;
48 class StdMeshers_ViscousLayers;
49 class TCollection_AsciiString;
50 class _Ghs2smdsConvertor;
51 class TopoDS_Shape;
52
53 class HYBRIDPlugin_HYBRID: public SMESH_3D_Algo
54 {
55 public:
56   HYBRIDPlugin_HYBRID(int hypId, int studyId, SMESH_Gen* gen);
57   virtual ~HYBRIDPlugin_HYBRID();
58
59   virtual bool CheckHypothesis(SMESH_Mesh&         aMesh,
60                                const TopoDS_Shape& aShape,
61                                Hypothesis_Status&  aStatus);
62
63   virtual bool Compute(SMESH_Mesh&         aMesh,
64                        const TopoDS_Shape& aShape);
65
66   virtual void CancelCompute();
67   bool         computeCanceled() { return _compute_canceled;};
68
69   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
70                         MapShapeNbElems& aResMap);
71
72   virtual bool Compute(SMESH_Mesh&         theMesh,
73                        SMESH_MesherHelper* aHelper);
74
75   virtual void SubmeshRestored(SMESH_subMesh* subMesh);
76
77   virtual void SetEventListener(SMESH_subMesh* subMesh);
78
79   bool         importGMFMesh(const char* aGMFFileName, SMESH_Mesh& aMesh);
80
81   static const char* Name() { return "HYBRID_3D"; }
82
83 protected:
84   const HYBRIDPlugin_Hypothesis*   _hyp;
85   const StdMeshers_ViscousLayers* _viscousLayersHyp;
86   std::string                     _genericName;
87    
88 private:
89
90   bool         storeErrorDescription(const TCollection_AsciiString& logFile,
91                                      const _Ghs2smdsConvertor &     toSmdsConvertor );
92   TopoDS_Shape entryToShape(std::string entry);
93   
94   int  _iShape;
95   int  _nbShape;
96   bool _keepFiles;
97   bool _removeLogOnSuccess;
98   bool _logInStandardOutput;
99   SALOMEDS::Study_var myStudy;
100   SMESH_Gen_i* smeshGen_i;
101
102   volatile bool _compute_canceled;
103 };
104
105 /*!
106  * \brief Convertor of HYBRID elements to SMDS ones
107  */
108 class _Ghs2smdsConvertor
109 {
110   const std::map <int,const SMDS_MeshNode*> * _ghs2NodeMap;
111   const std::vector <const SMDS_MeshNode*> *  _nodeByGhsId;
112
113 public:
114   _Ghs2smdsConvertor( const std::map <int,const SMDS_MeshNode*> & ghs2NodeMap);
115
116   _Ghs2smdsConvertor( const std::vector <const SMDS_MeshNode*> &  nodeByGhsId);
117
118   const SMDS_MeshElement* getElement(const std::vector<int>& ghsNodes) const;
119 };
120
121 #endif