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