1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPlugin_Hypothesis.hxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #ifndef _BLSURFPlugin_Hypothesis_HXX_
28 #define _BLSURFPlugin_Hypothesis_HXX_
30 #include "SMESH_Hypothesis.hxx"
37 // Parameters for work of BLSURF
39 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
42 BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
60 void SetTopology(Topology theTopology);
61 Topology GetTopology() const { return _topology; }
63 void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
64 PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
66 void SetPhySize(double thePhySize);
67 double GetPhySize() const { return _phySize; }
69 void SetPhyMin(double theMinSize);
70 double GetPhyMin() const { return _phyMin; }
72 void SetPhyMax(double theMaxSize);
73 double GetPhyMax() const { return _phyMax; }
75 void SetGeometricMesh(GeometricMesh theGeometricMesh);
76 GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
78 void SetAngleMeshS(double theAngle);
79 double GetAngleMeshS() const { return _angleMeshS; }
81 void SetAngleMeshC(double theAngle);
82 double GetAngleMeshC() const { return _angleMeshC; }
84 void SetGeoMin(double theMinSize);
85 double GetGeoMin() const { return _hgeoMin; }
87 void SetGeoMax(double theMaxSize);
88 double GetGeoMax() const { return _hgeoMax; }
90 void SetGradation(double theGradation);
91 double GetGradation() const { return _gradation; }
93 void SetQuadAllowed(bool theVal);
94 bool GetQuadAllowed() const { return _quadAllowed; }
96 void SetDecimesh(bool theVal);
97 bool GetDecimesh() const { return _decimesh; }
99 void SetVerbosity(int theVal);
100 int GetVerbosity() const { return _verb; }
102 void ClearEntry(const std::string& entry);
103 void ClearSizeMaps();
105 typedef std::map<std::string,std::string> TSizeMap;
107 void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
108 std::string GetSizeMapEntry(const std::string& entry);
109 const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
111 * \brief Return the size maps
113 static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
116 void SetAttractorEntry(const std::string& entry,const std::string& attractor );
117 std::string GetAttractorEntry(const std::string& entry);
118 const TSizeMap& _GetAttractorEntries() const { return _attractors; };
120 * \brief Return the attractors
122 static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
126 void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
127 std::string GetCustomSizeMapEntry(const std::string& entry);
128 void UnsetCustomSizeMap(const std::string& entry);
129 const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
133 * To set/get/unset an enforced vertex
136 typedef std::string TEnfEntry;
137 // Enforced vertex = 3 coordinates
138 typedef std::vector<double> TEnfVertex;
139 // List of enforced vertices
140 typedef std::set< TEnfVertex > TEnfVertexList;
141 // Map Entry / List of enforced vertices
142 typedef std::map< TEnfEntry , TEnfVertexList > TEntryEnfVertexListMap;
145 typedef std::string TEnfGroupName;
146 // Map Group Name / List of enforced vertices
147 typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
148 // Map Enforced vertex / Group Name
149 typedef std::map< TEnfVertex , TEnfGroupName > TEnfVertexGroupNameMap;
154 void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z, const TEnfGroupName& groupName="");
156 void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z);
157 // void SetEnforcedVertexList(const TEnfEntry& entry, const TEnfVertexList vertexList);
158 TEnfVertexList GetEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument);
159 void ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) throw (std::invalid_argument);
160 // void ClearEnforcedVertexList(const TEnfEntry& entry, TEnfVertexList vertexList) throw (std::invalid_argument);
161 void ClearEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument);
163 void ClearAllEnforcedVertices();
164 const TEntryEnfVertexListMap _GetAllEnforcedVertices() const { return _entryEnfVertexListMap; }
166 const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
170 * \brief Return the enforced vertices
172 static TEntryEnfVertexListMap GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
175 * \brief Set/get node group to an enforced vertex
178 void SetEnforcedVertexGroupName(double x, double y, double z, const TEnfGroupName& groupName) throw (std::invalid_argument);
179 TEnfGroupName GetEnforcedVertexGroupName(double x, double y, double z) throw (std::invalid_argument);
180 TEnfVertexList GetEnforcedVertexByGroupName(TEnfGroupName& groupName) throw (std::invalid_argument);
183 static Topology GetDefaultTopology();
184 static PhysicalMesh GetDefaultPhysicalMesh();
185 static double GetDefaultPhySize();
186 static double GetDefaultMaxSize();
187 static double GetDefaultMinSize();
188 static GeometricMesh GetDefaultGeometricMesh();
189 static double GetDefaultAngleMeshS();
190 static double GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
191 static double GetDefaultGradation();
192 static bool GetDefaultQuadAllowed();
193 static bool GetDefaultDecimesh();
194 static int GetDefaultVerbosity() { return 10; }
195 static TSizeMap GetDefaultSizeMap() { return TSizeMap();}
196 static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); }
197 static TEntryEnfVertexListMap GetDefaultEntryEnfVertexListMap() { return TEntryEnfVertexListMap(); }
199 static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
200 static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
203 static double undefinedDouble() { return -1.0; }
205 typedef std::map< std::string, std::string > TOptionValues;
206 typedef std::set< std::string > TOptionNames;
208 void SetOptionValue(const std::string& optionName,
209 const std::string& optionValue) throw (std::invalid_argument);
210 std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
211 void ClearOption(const std::string& optionName);
212 const TOptionValues& GetOptionValues() const { return _option2value; }
215 virtual std::ostream & SaveTo(std::ostream & save);
216 virtual std::istream & LoadFrom(std::istream & load);
217 friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
218 friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
221 * \brief Does nothing
222 * \param theMesh - the built mesh
223 * \param theShape - the geometry of interest
224 * \retval bool - always false
226 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
229 * \brief Initialize my parameter values by default parameters.
230 * \retval bool - true if parameter values have been successfully defined
232 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
236 bool _setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument);
241 PhysicalMesh _physicalMesh;
242 double _phySize, _phyMin, _phyMax;
243 GeometricMesh _geometricMesh;
244 double _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
249 TOptionValues _option2value;
250 TOptionNames _doubleOptions, _charOptions;
252 TSizeMap _attractors;
253 TEnfVertexList _enfVertexList;
254 TEntryEnfVertexListMap _entryEnfVertexListMap;
256 TGroupNameEnfVertexListMap _groupNameEnfVertexListMap;
257 TEnfVertexGroupNameMap _enfVertexGroupNameMap;
259 // TSizeMap _customSizeMap;