Salome HOME
a8639884fe79bcb82c066b9b1c965adb40e49289
[plugins/hexoticplugin.git] / src / HexoticPlugin / HexoticPlugin_Hexotic.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   : HexoticPlugin_Hexotic.hxx
22 // Author : Lioka RAZAFINDRAZAKA (CEA)
23 // ---
24 //
25 #ifndef _HexoticPlugin_Hexotic_HXX_
26 #define _HexoticPlugin_Hexotic_HXX_
27
28 #include "HexoticPlugin_Defs.hxx"
29 #include "HexoticPlugin_Hypothesis.hxx"
30
31 #include "SMESH_Algo.hxx"
32 #include "SMESH_Mesh.hxx"
33 #include "Utils_SALOME_Exception.hxx"
34
35 #ifdef WITH_BLSURFPLUGIN
36 #include "BLSURFPlugin_Hypothesis.hxx"
37 #endif
38
39 #include <string>
40
41 #include "DriverGMF_Read.hxx"
42 #include "DriverGMF_Write.hxx"
43
44 #include <SALOMEconfig.h>
45 #include CORBA_CLIENT_HEADER(GEOM_Gen)
46 #include <SMESH_Gen_i.hxx>
47
48 class HexoticPlugin_Hypothesis;
49 class TCollection_AsciiString;
50 class gp_Pnt;
51 class MG_Hexotic_API;
52
53 class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hexotic: public SMESH_3D_Algo
54 {
55 public:
56   HexoticPlugin_Hexotic(int hypId, int studyId, SMESH_Gen* gen);
57   virtual ~HexoticPlugin_Hexotic();
58
59 #ifdef WITH_BLSURFPLUGIN
60   bool CheckBLSURFHypothesis(SMESH_Mesh&         aMesh,
61                              const TopoDS_Shape& aShape);
62 #endif
63
64   virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
65                                const TopoDS_Shape&                  aShape,
66                                SMESH_Hypothesis::Hypothesis_Status& aStatus);
67
68   void SetParameters(const HexoticPlugin_Hypothesis* hyp);
69
70   virtual bool Compute(SMESH_Mesh& aMesh,  const TopoDS_Shape& aShape);
71
72   virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
73
74   virtual void CancelCompute();
75   bool computeCanceled() { return _computeCanceled; }
76
77   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
78                         MapShapeNbElems& aResMap);
79
80 protected:
81   const HexoticPlugin_Hypothesis* _hypothesis;
82
83 private:
84
85   std::string getHexoticCommand(const TCollection_AsciiString& Hexotic_In,
86                                 const TCollection_AsciiString& Hexotic_Out,
87                                 const TCollection_AsciiString& Hexotic_Sol,
88                                 const bool                     forExecutable) const;
89   
90   GEOM::GEOM_Object_var entryToGeomObj(std::string entry);
91   TopoDS_Shape     entryToShape(std::string entry);
92
93   std::vector<std::string> writeSizeMapFile(MG_Hexotic_API* mgOutput,
94                                             std::string     fileName);
95   
96   // Functions to get sample point from shapes
97   void createControlPoints( const TopoDS_Shape& theShape, 
98                             const double& theSize, 
99                             std::vector< Control_Pnt >& thePoints );
100   void createPointsSampleFromEdge( const TopoDS_Shape& aShape, 
101                                    const double& theSize, 
102                                    std::vector<Control_Pnt>& thePoints );
103   void createPointsSampleFromFace( const TopoDS_Shape& aShape, 
104                                    const double& theSize, 
105                                    std::vector<Control_Pnt>& thePoints );
106   void createPointsSampleFromSolid( const TopoDS_Shape& aShape, 
107                                     const double& theSize, 
108                                     std::vector<Control_Pnt>& thePoints );
109   
110   // Some functions for surface sampling
111   void subdivideTriangle( const gp_Pnt& p1, 
112                           const gp_Pnt& p2, 
113                           const gp_Pnt& p3, 
114                           const double& theSize, 
115                           std::vector<Control_Pnt>& thePoints );
116   
117   std::vector<gp_Pnt> computePointsForSplitting( const gp_Pnt& p1, 
118                                                  const gp_Pnt& p2, 
119                                                  const gp_Pnt& p3 );
120   gp_Pnt tangencyPoint(const gp_Pnt& p1, 
121                        const gp_Pnt& p2, 
122                        const gp_Pnt& Center);
123   
124
125   int  _iShape;
126   int  _nbShape;
127   int  _hexesMinLevel;
128   int  _hexesMaxLevel;
129   double _hexesMinSize;
130   double _hexesMaxSize;
131   bool _hexoticIgnoreRidges;
132   bool _hexoticInvalidElements;
133   bool _hexoticFilesKept;
134   int  _hexoticSharpAngleThreshold;
135   int  _hexoticNbProc;
136   std::string  _hexoticWorkingDirectory;
137   int _hexoticVerbosity;
138   int _hexoticMaxMemory;
139   int _hexoticSdMode;
140   std::string _textOptions;
141   HexoticPlugin_Hypothesis::THexoticSizeMaps _sizeMaps;
142   int    _nbLayers;
143   double _firstLayerSize;
144   bool   _direction;
145   double _growth;
146   std::vector<int> _facesWithLayers;
147   std::vector<int> _imprintedFaces;
148   SMDS_MeshNode** _tabNode;
149   
150 #ifdef WITH_BLSURFPLUGIN
151   const BLSURFPlugin_Hypothesis* _blsurfHypo;
152 #endif
153
154
155   SALOMEDS::Study_var myStudy;
156   SMESH_Gen_i*        smeshGen_i;
157
158 };
159
160 #endif