1 // Copyright (C) 2007-2011 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>
39 #include "BLSURFPlugin_Attractor.hxx"
41 // Parameters for work of BLSURF
43 class BLSURFPlugin_Hypothesis: public SMESH_Hypothesis
46 BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
64 TopoDS_Shape entryToShape(std::string entry);
66 void SetTopology(Topology theTopology);
67 Topology GetTopology() const { return _topology; }
69 void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
70 PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
72 void SetPhySize(double thePhySize);
73 double GetPhySize() const { return _phySize; }
75 void SetPhyMin(double theMinSize);
76 double GetPhyMin() const { return _phyMin; }
78 void SetPhyMax(double theMaxSize);
79 double GetPhyMax() const { return _phyMax; }
81 void SetGeometricMesh(GeometricMesh theGeometricMesh);
82 GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
84 void SetAngleMeshS(double theAngle);
85 double GetAngleMeshS() const { return _angleMeshS; }
87 void SetAngleMeshC(double theAngle);
88 double GetAngleMeshC() const { return _angleMeshC; }
90 void SetGeoMin(double theMinSize);
91 double GetGeoMin() const { return _hgeoMin; }
93 void SetGeoMax(double theMaxSize);
94 double GetGeoMax() const { return _hgeoMax; }
96 void SetGradation(double theGradation);
97 double GetGradation() const { return _gradation; }
99 void SetQuadAllowed(bool theVal);
100 bool GetQuadAllowed() const { return _quadAllowed; }
102 void SetDecimesh(bool theVal);
103 bool GetDecimesh() const { return _decimesh; }
105 void SetVerbosity(int theVal);
106 int GetVerbosity() const { return _verb; }
108 void ClearEntry(const std::string& entry);
109 void ClearSizeMaps();
111 typedef std::map<std::string,std::string> TSizeMap;
113 void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
114 std::string GetSizeMapEntry(const std::string& entry);
115 const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
117 * \brief Return the size maps
119 static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
122 void SetAttractorEntry(const std::string& entry,const std::string& attractor );
123 std::string GetAttractorEntry(const std::string& entry);
124 const TSizeMap& _GetAttractorEntries() const { return _attractors; };
126 * \brief Return the attractors
128 static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
132 void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
133 std::string GetCustomSizeMapEntry(const std::string& entry);
134 void UnsetCustomSizeMap(const std::string& entry);
135 const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
138 typedef std::map< std::string, BLSURFPlugin_Attractor* > TAttractorMap;
139 typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO à finir
141 void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius);
142 std::string GetClassAttractorEntry(const std::string& entry);
143 const TAttractorMap& _GetClassAttractorEntries() const { return _classAttractors; }
145 * \brief Return the attractors entries
147 static TAttractorMap GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
150 * To set/get/unset an enforced vertex
153 typedef std::string TEnfName;
155 typedef std::string TEntry;
157 typedef std::set<TEntry> TEntryList;
159 typedef std::string TEnfGroupName;
161 typedef std::vector<double> TEnfVertexCoords;
162 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
168 TEnfVertexCoords coords;
169 TEnfGroupName grpName;
170 TEntryList faceEntries;
173 struct CompareEnfVertices
175 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
177 if (e1->coords.size() && e2->coords.size())
178 return (e1->coords < e2->coords);
180 return (e1->geomEntry < e2->geomEntry);
186 // List of enforced vertices
187 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
189 // Map Face Entry / List of enforced vertices
190 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
192 // Map Face Entry / List of coords
193 typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
195 // Map Face Entry / List of Vertex entry
196 typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
198 // Map Coords / Enforced vertex
199 typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
201 // Map Vertex entry / Enforced vertex
202 typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
204 typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
206 // Map Group Name / List of enforced vertices
207 typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
211 bool SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
212 double x = 0.0, double y = 0.0, double z = 0.0);
213 TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
214 TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
215 TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
216 TEnfVertex* GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
217 TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
218 void AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
219 std::set<int> GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
220 void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
222 bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
223 bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
225 void ClearAllEnforcedVertices();
227 const TFaceEntryEnfVertexListMap _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
228 const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; }
230 const TFaceEntryCoordsListMap _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
231 const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
233 const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
234 const TEnfVertexEntryEnfVertexMap _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
237 // const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
241 * \brief Return the enforced vertices
243 static TFaceEntryEnfVertexListMap GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
244 static TEnfVertexList GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
246 static TFaceEntryCoordsListMap GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
247 static TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
249 static TFaceEntryEnfVertexEntryListMap GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
250 static TEnfVertexEntryEnfVertexMap GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
254 * \brief Set/get node group to an enforced vertex
257 void SetEnforcedVertexGroupName(double x, double y, double z, const TEnfGroupName& groupName) throw (std::invalid_argument);
258 TEnfGroupName GetEnforcedVertexGroupName(double x, double y, double z) throw (std::invalid_argument);
259 TEnfVertexList GetEnforcedVertexByGroupName(TEnfGroupName& groupName) throw (std::invalid_argument);
262 static Topology GetDefaultTopology();
263 static PhysicalMesh GetDefaultPhysicalMesh();
264 static double GetDefaultPhySize();
265 static double GetDefaultMaxSize();
266 static double GetDefaultMinSize();
267 static GeometricMesh GetDefaultGeometricMesh();
268 static double GetDefaultAngleMeshS();
269 static double GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
270 static double GetDefaultGradation();
271 static bool GetDefaultQuadAllowed();
272 static bool GetDefaultDecimesh();
273 static int GetDefaultVerbosity() { return 10; }
274 static TSizeMap GetDefaultSizeMap() { return TSizeMap();}
275 static TAttractorMap GetDefaultAttractorMap() { return TAttractorMap(); }
277 static TFaceEntryEnfVertexListMap GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
278 static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); }
279 static TFaceEntryCoordsListMap GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
280 static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
281 static TFaceEntryEnfVertexEntryListMap GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
282 static TEnfVertexEntryEnfVertexMap GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
283 static TGroupNameNodeIDMap GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
286 static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
287 static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
290 static double undefinedDouble() { return -1.0; }
292 typedef std::map< std::string, std::string > TOptionValues;
293 typedef std::set< std::string > TOptionNames;
295 void SetOptionValue(const std::string& optionName,
296 const std::string& optionValue) throw (std::invalid_argument);
297 std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
298 void ClearOption(const std::string& optionName);
299 const TOptionValues& GetOptionValues() const { return _option2value; }
302 virtual std::ostream & SaveTo(std::ostream & save);
303 virtual std::istream & LoadFrom(std::istream & load);
304 friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
305 friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
308 * \brief Does nothing
309 * \param theMesh - the built mesh
310 * \param theShape - the geometry of interest
311 * \retval bool - always false
313 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
316 * \brief Initialize my parameter values by default parameters.
317 * \retval bool - true if parameter values have been successfully defined
319 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
324 PhysicalMesh _physicalMesh;
325 double _phySize, _phyMin, _phyMax;
326 GeometricMesh _geometricMesh;
327 double _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
332 TOptionValues _option2value;
333 TOptionNames _doubleOptions, _charOptions;
335 TSizeMap _attractors;
336 TAttractorMap _classAttractors;
338 TParamsMap _attParams;
340 TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap;
341 TEnfVertexList _enfVertexList;
342 // maps to get "manual" enf vertex (through their coordinates)
343 TFaceEntryCoordsListMap _faceEntryCoordsListMap;
344 TCoordsEnfVertexMap _coordsEnfVertexMap;
345 // maps to get "geom" enf vertex (through their geom entries)
346 TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
347 TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap;
348 TGroupNameNodeIDMap _groupNameNodeIDMap;
351 TGroupNameEnfVertexListMap _groupNameEnfVertexListMap;
353 // TSizeMap _customSizeMap;