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"
38 #include <utilities.h>
40 // Parameters for work of BLSURF
42 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
45 BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
63 void SetTopology(Topology theTopology);
64 Topology GetTopology() const { return _topology; }
66 void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
67 PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
69 void SetPhySize(double thePhySize);
70 double GetPhySize() const { return _phySize; }
72 void SetPhyMin(double theMinSize);
73 double GetPhyMin() const { return _phyMin; }
75 void SetPhyMax(double theMaxSize);
76 double GetPhyMax() const { return _phyMax; }
78 void SetGeometricMesh(GeometricMesh theGeometricMesh);
79 GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
81 void SetAngleMeshS(double theAngle);
82 double GetAngleMeshS() const { return _angleMeshS; }
84 void SetAngleMeshC(double theAngle);
85 double GetAngleMeshC() const { return _angleMeshC; }
87 void SetGeoMin(double theMinSize);
88 double GetGeoMin() const { return _hgeoMin; }
90 void SetGeoMax(double theMaxSize);
91 double GetGeoMax() const { return _hgeoMax; }
93 void SetGradation(double theGradation);
94 double GetGradation() const { return _gradation; }
96 void SetQuadAllowed(bool theVal);
97 bool GetQuadAllowed() const { return _quadAllowed; }
99 void SetDecimesh(bool theVal);
100 bool GetDecimesh() const { return _decimesh; }
102 void SetVerbosity(int theVal);
103 int GetVerbosity() const { return _verb; }
105 void ClearEntry(const std::string& entry);
106 void ClearSizeMaps();
108 typedef std::map<std::string,std::string> TSizeMap;
110 void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
111 std::string GetSizeMapEntry(const std::string& entry);
112 const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
114 * \brief Return the size maps
116 static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
119 void SetAttractorEntry(const std::string& entry,const std::string& attractor );
120 std::string GetAttractorEntry(const std::string& entry);
121 const TSizeMap& _GetAttractorEntries() const { return _attractors; };
123 * \brief Return the attractors
125 static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
129 void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
130 std::string GetCustomSizeMapEntry(const std::string& entry);
131 void UnsetCustomSizeMap(const std::string& entry);
132 const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
136 * To set/get/unset an enforced vertex
139 typedef std::string TEntry;
141 typedef std::set<TEntry> TEntryList;
143 typedef std::string TEnfName;
145 typedef std::string TEnfGroupName;
147 typedef std::vector<double> TEnfVertexCoords;
148 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
154 TEnfVertexCoords coords;
155 TEnfGroupName grpName;
156 TEntryList faceEntries;
159 struct CompareEnfVertices
161 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
163 if (e1->coords.size() && e2->coords.size())
164 return (e1->coords < e2->coords);
166 return (e1->geomEntry < e2->geomEntry);
172 // List of enforced vertices
173 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
175 // Map Face Entry / List of enforced vertices
176 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
178 // Map Face Entry / List of coords
179 typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
181 // Map Face Entry / List of Vertex entry
182 typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
184 // Map Coords / Enforced vertex
185 typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
187 // Map Vertex entry / Enforced vertex
188 typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
190 typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
192 // Map Group Name / List of enforced vertices
193 typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
198 // void SetEnforcedVertex(const TEntry& entry, double x, double y, double z, const TEnfGroupName& groupName="");
199 bool SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
200 double x = 0.0, double y = 0.0, double z = 0.0);
201 TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
202 TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
203 TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
204 TEnfVertex* GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
205 TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
206 void AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
207 std::set<int> GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
208 void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
210 bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
211 bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
213 void ClearAllEnforcedVertices();
215 const TFaceEntryEnfVertexListMap _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
216 const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; }
218 const TFaceEntryCoordsListMap _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
219 const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
221 const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
222 const TEnfVertexEntryEnfVertexMap _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
225 // const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
229 * \brief Return the enforced vertices
231 static TFaceEntryEnfVertexListMap GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
232 static TEnfVertexList GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
234 static TFaceEntryCoordsListMap GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
235 static TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
237 static TFaceEntryEnfVertexEntryListMap GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
238 static TEnfVertexEntryEnfVertexMap GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
242 * \brief Set/get node group to an enforced vertex
245 void SetEnforcedVertexGroupName(double x, double y, double z, const TEnfGroupName& groupName) throw (std::invalid_argument);
246 TEnfGroupName GetEnforcedVertexGroupName(double x, double y, double z) throw (std::invalid_argument);
247 TEnfVertexList GetEnforcedVertexByGroupName(TEnfGroupName& groupName) throw (std::invalid_argument);
250 static Topology GetDefaultTopology();
251 static PhysicalMesh GetDefaultPhysicalMesh();
252 static double GetDefaultPhySize();
253 static double GetDefaultMaxSize();
254 static double GetDefaultMinSize();
255 static GeometricMesh GetDefaultGeometricMesh();
256 static double GetDefaultAngleMeshS();
257 static double GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
258 static double GetDefaultGradation();
259 static bool GetDefaultQuadAllowed();
260 static bool GetDefaultDecimesh();
261 static int GetDefaultVerbosity() { return 10; }
262 static TSizeMap GetDefaultSizeMap() { return TSizeMap();}
264 static TFaceEntryEnfVertexListMap GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
265 static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); }
266 static TFaceEntryCoordsListMap GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
267 static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
268 static TFaceEntryEnfVertexEntryListMap GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
269 static TEnfVertexEntryEnfVertexMap GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
270 static TGroupNameNodeIDMap GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
273 static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
274 static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
277 static double undefinedDouble() { return -1.0; }
279 typedef std::map< std::string, std::string > TOptionValues;
280 typedef std::set< std::string > TOptionNames;
282 void SetOptionValue(const std::string& optionName,
283 const std::string& optionValue) throw (std::invalid_argument);
284 std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
285 void ClearOption(const std::string& optionName);
286 const TOptionValues& GetOptionValues() const { return _option2value; }
289 virtual std::ostream & SaveTo(std::ostream & save);
290 virtual std::istream & LoadFrom(std::istream & load);
291 friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
292 friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
295 * \brief Does nothing
296 * \param theMesh - the built mesh
297 * \param theShape - the geometry of interest
298 * \retval bool - always false
300 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
303 * \brief Initialize my parameter values by default parameters.
304 * \retval bool - true if parameter values have been successfully defined
306 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
311 PhysicalMesh _physicalMesh;
312 double _phySize, _phyMin, _phyMax;
313 GeometricMesh _geometricMesh;
314 double _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
319 TOptionValues _option2value;
320 TOptionNames _doubleOptions, _charOptions;
322 TSizeMap _attractors;
324 TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap;
325 TEnfVertexList _enfVertexList;
326 // maps to get "manual" enf vertex (through their coordinates)
327 TFaceEntryCoordsListMap _faceEntryCoordsListMap;
328 TCoordsEnfVertexMap _coordsEnfVertexMap;
329 // maps to get "geom" enf vertex (through their geom entries)
330 TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
331 TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap;
332 TGroupNameNodeIDMap _groupNameNodeIDMap;
335 TGroupNameEnfVertexListMap _groupNameEnfVertexListMap;
337 // TSizeMap _customSizeMap;