Salome HOME
0020832: EDF 1359 SMESH : Automatic meshing of boundary layers
[plugins/ghs3dplugin.git] / src / GHS3DPlugin_Hypothesis.hxx
1 //  Copyright (C) 2004-2010  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.
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 //  GHS3DPlugin : C++ implementation
21 // File      : GHS3DPlugin_Hypothesis.hxx
22 // Created   : Wed Apr  2 12:21:17 2008
23 // Author    : Edward AGAPOV (eap)
24 //
25 #ifndef GHS3DPlugin_Hypothesis_HeaderFile
26 #define GHS3DPlugin_Hypothesis_HeaderFile
27
28 #include "GHS3DPlugin_Defs.hxx"
29
30 #include <SMESH_Hypothesis.hxx>
31 #include <utilities.h>
32
33 #include <stdexcept>
34 #include <map>
35 #include <vector>
36 #include <cstdio>
37
38 class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis: public SMESH_Hypothesis
39 {
40 public:
41
42   GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
43
44   /*!
45    * To mesh "holes" in a solid or not. Default is to mesh.
46    */
47   void SetToMeshHoles(bool toMesh);
48   bool GetToMeshHoles(bool checkFreeOption = false) const;
49   /*!
50    * Maximal size of memory to be used by the algorithm (in Megabytes)
51    */
52   void SetMaximumMemory(short MB);
53   short GetMaximumMemory() const;
54   /*!
55    * Initial size of memory to be used by the algorithm (in Megabytes) in
56    * automatic memory adjustment mode. Default is zero
57    */
58   void SetInitialMemory(short MB);
59   short GetInitialMemory() const;
60   /*!
61    * Optimization level: 0-none, 1-light, 2-medium, 3-standard+, 4-strong. Default is medium
62    */
63   enum OptimizationLevel { None = 0, Light, Medium, StandardPlus, Strong };
64   void SetOptimizationLevel(OptimizationLevel level);
65   OptimizationLevel GetOptimizationLevel() const;
66   /*!
67    * Path to working directory
68    */
69   void SetWorkingDirectory(const std::string& path);
70   std::string GetWorkingDirectory() const;
71   /*!
72    * To keep working files or remove them. Log file remains in case of errors anyway.
73    */
74   void SetKeepFiles(bool toKeep);
75   bool GetKeepFiles() const;
76   /*!
77    * Verbose level [0-10]
78    *  0 - no standard output,
79    *  2 - prints the data, quality statistics of the skin and final meshes and
80    *     indicates when the final mesh is being saved. In addition the software
81    *     gives indication regarding the CPU time.
82    * 10 - same as 2 plus the main steps in the computation, quality statistics
83    *     histogram of the skin mesh, quality statistics histogram together with
84    *     the characteristics of the final mesh.
85    */
86   void SetVerboseLevel(short level);
87   short GetVerboseLevel() const;
88   /*!
89    * To create new nodes
90    */
91   void SetToCreateNewNodes(bool toCreate);
92   bool GetToCreateNewNodes() const;
93   /*!
94    * To use boundary recovery version which tries to create mesh on a very poor
95    * quality surface mesh
96    */
97   void SetToUseBoundaryRecoveryVersion(bool toUse);
98   bool GetToUseBoundaryRecoveryVersion() const;
99   /*!
100    * Applies finite-element correction by replacing overconstrained elements where
101    * it is possible. The process is cutting first the overconstrained edges and
102    * second the overconstrained facets. This insure that no edges have two boundary
103    * vertices and that no facets have three boundary vertices.
104    */
105   void SetFEMCorrection(bool toUseFem);
106   bool GetFEMCorrection() const;
107   /*!
108    * To removes initial central point.
109    */
110   void SetToRemoveCentralPoint(bool toRemove);
111   bool GetToRemoveCentralPoint() const;
112   /*!
113    * To set hiden/undocumented/advanced options
114    */
115   void SetTextOption(const std::string& option);
116   std::string GetTextOption() const;
117   /*!
118    * To set an enforced vertex
119    */
120   typedef std::map<std::vector<double>,double> TEnforcedVertexValues;
121   void SetEnforcedVertex(double x, double y, double z, double size);
122   double GetEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
123   void RemoveEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
124   const TEnforcedVertexValues _GetEnforcedVertices() const { return myEnforcedVertices; }
125   void ClearEnforcedVertices();
126
127   static bool   DefaultMeshHoles();
128   static short  DefaultMaximumMemory();
129   static short  DefaultInitialMemory();
130   static short  DefaultOptimizationLevel();
131   static std::string DefaultWorkingDirectory();
132   static bool   DefaultKeepFiles();
133   static short  DefaultVerboseLevel();
134   static bool   DefaultToCreateNewNodes();
135   static bool   DefaultToUseBoundaryRecoveryVersion();
136   static bool   DefaultToUseFEMCorrection();
137   static bool   DefaultToRemoveCentralPoint();
138   static TEnforcedVertexValues DefaultEnforcedVertices();
139
140   /*!
141    * \brief Return command to run ghs3d mesher excluding file prefix (-f)
142    */
143   static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
144                                   const bool                    hasShapeToMesh=true);
145   /*!
146    * \brief Return a unique file name
147    */
148   static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp);
149   /*!
150    * \brief Return the enforced vertices
151    */
152   static TEnforcedVertexValues GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp);
153
154   // Persistence
155   virtual std::ostream & SaveTo(std::ostream & save);
156   virtual std::istream & LoadFrom(std::istream & load);
157   friend GHS3DPLUGIN_EXPORT std::ostream & operator <<(std::ostream & save, GHS3DPlugin_Hypothesis & hyp);
158   friend GHS3DPLUGIN_EXPORT std::istream & operator >>(std::istream & load, GHS3DPlugin_Hypothesis & hyp);
159
160   /*!
161    * \brief Does nothing
162    */
163   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
164
165   /*!
166    * \brief Does nothing
167    */
168   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
169
170 private:
171
172   bool   myToMeshHoles;
173   short  myMaximumMemory;
174   short  myInitialMemory;
175   short  myOptimizationLevel;
176   bool   myKeepFiles;
177   std::string myWorkingDirectory;
178   short  myVerboseLevel;
179   bool   myToCreateNewNodes;
180   bool   myToUseBoundaryRecoveryVersion;
181   bool   myToUseFemCorrection;
182   bool   myToRemoveCentralPoint;
183   std::string myTextOption;
184   TEnforcedVertexValues myEnforcedVertices;
185   
186 };
187
188
189 #endif