1 // Copyright (C) 2007-2012 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);
66 static const char* GetHypType() { return "BLSURF_Parameters"; }
68 TopoDS_Shape entryToShape(std::string entry);
70 void SetTopology(Topology theTopology);
71 Topology GetTopology() const { return _topology; }
73 void SetPhysicalMesh(PhysicalMesh thePhysicalMesh);
74 PhysicalMesh GetPhysicalMesh() const { return _physicalMesh; }
76 void SetPhySize(double thePhySize);
77 double GetPhySize() const { return _phySize; }
79 void SetPhyMin(double theMinSize);
80 double GetPhyMin() const { return _phyMin; }
82 void SetPhyMax(double theMaxSize);
83 double GetPhyMax() const { return _phyMax; }
85 void SetGeometricMesh(GeometricMesh theGeometricMesh);
86 GeometricMesh GetGeometricMesh() const { return _geometricMesh; }
88 void SetAngleMeshS(double theAngle);
89 double GetAngleMeshS() const { return _angleMeshS; }
91 void SetAngleMeshC(double theAngle);
92 double GetAngleMeshC() const { return _angleMeshC; }
94 void SetGeoMin(double theMinSize);
95 double GetGeoMin() const { return _hgeoMin; }
97 void SetGeoMax(double theMaxSize);
98 double GetGeoMax() const { return _hgeoMax; }
100 void SetGradation(double theGradation);
101 double GetGradation() const { return _gradation; }
103 void SetQuadAllowed(bool theVal);
104 bool GetQuadAllowed() const { return _quadAllowed; }
106 void SetDecimesh(bool theVal);
107 bool GetDecimesh() const { return _decimesh; }
109 void SetVerbosity(int theVal);
110 int GetVerbosity() const { return _verb; }
112 void ClearEntry(const std::string& entry);
113 void ClearSizeMaps();
115 void SetPreCADMergeEdges(bool theVal);
116 bool GetPreCADMergeEdges() const { return _preCADMergeEdges; }
118 void SetPreCADRemoveNanoEdges(bool theVal);
119 bool GetPreCADRemoveNanoEdges() const { return _preCADRemoveNanoEdges; }
121 void SetPreCADDiscardInput(bool theVal);
122 bool GetPreCADDiscardInput() const { return _preCADDiscardInput; }
124 void SetPreCADEpsNano(double theVal);
125 double GetPreCADEpsNano() const { return _preCADEpsNano; }
127 typedef std::map<std::string,std::string> TSizeMap;
129 void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
130 std::string GetSizeMapEntry(const std::string& entry);
131 const TSizeMap& _GetSizeMapEntries() const { return _sizeMap; }
133 * \brief Return the size maps
135 static TSizeMap GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp);
138 void SetAttractorEntry(const std::string& entry,const std::string& attractor );
139 std::string GetAttractorEntry(const std::string& entry);
140 const TSizeMap& _GetAttractorEntries() const { return _attractors; };
142 * \brief Return the attractors
144 static TSizeMap GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
148 void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
149 std::string GetCustomSizeMapEntry(const std::string& entry);
150 void UnsetCustomSizeMap(const std::string& entry);
151 const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
154 typedef std::map< std::string, BLSURFPlugin_Attractor* > TAttractorMap;
155 typedef std::map< std::string, std::vector<double> > TParamsMap; //TODO à finir
157 void SetClassAttractorEntry(const std::string& entry, const std::string& att_entry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius);
158 std::string GetClassAttractorEntry(const std::string& entry);
159 const TAttractorMap& _GetClassAttractorEntries() const { return _classAttractors; }
161 * \brief Return the attractors entries
163 static TAttractorMap GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp);
166 * To set/get/unset an enforced vertex
169 typedef std::string TEnfName;
171 typedef std::string TEntry;
173 typedef std::set<TEntry> TEntryList;
175 typedef std::string TEnfGroupName;
177 typedef std::vector<double> TEnfVertexCoords;
178 typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList;
184 TEnfVertexCoords coords;
185 TEnfGroupName grpName;
186 TEntryList faceEntries;
189 struct CompareEnfVertices
191 bool operator () (const TEnfVertex* e1, const TEnfVertex* e2) const {
193 if (e1->coords.size() && e2->coords.size())
194 return (e1->coords < e2->coords);
196 return (e1->geomEntry < e2->geomEntry);
202 // List of enforced vertices
203 typedef std::set< TEnfVertex*, CompareEnfVertices > TEnfVertexList;
205 // Map Face Entry / List of enforced vertices
206 typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap;
208 // List of Face Entry with internal enforced vertices activated
209 typedef std::set< TEntry > TFaceEntryInternalVerticesList;
211 // Map Face Entry / List of coords
212 typedef std::map< TEntry, TEnfVertexCoordsList > TFaceEntryCoordsListMap;
214 // Map Face Entry / List of Vertex entry
215 typedef std::map< TEntry, TEntryList > TFaceEntryEnfVertexEntryListMap;
217 // Map Coords / Enforced vertex
218 typedef std::map< TEnfVertexCoords, TEnfVertex* > TCoordsEnfVertexMap;
220 // Map Vertex entry / Enforced vertex
221 typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
223 typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
225 // Map Group Name / List of enforced vertices
226 typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
230 bool SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry, TEnfGroupName theGroupName,
231 double x = 0.0, double y = 0.0, double z = 0.0);
232 TEnfVertexList GetEnfVertexList(const TEntry& theFaceEntry) throw (std::invalid_argument);
233 TEnfVertexCoordsList GetEnfVertexCoordsList(const TEntry& theFaceEntry) throw (std::invalid_argument);
234 TEntryList GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
235 TEnfVertex* GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
236 TEnfVertex* GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
237 void AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
238 std::set<int> GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
239 void RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
241 bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
242 bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
244 void ClearAllEnforcedVertices();
246 const TFaceEntryEnfVertexListMap _GetAllEnforcedVerticesByFace() const { return _faceEntryEnfVertexListMap; }
247 const TEnfVertexList _GetAllEnforcedVertices() const { return _enfVertexList; }
249 const TFaceEntryCoordsListMap _GetAllCoordsByFace() const { return _faceEntryCoordsListMap; }
250 const TCoordsEnfVertexMap _GetAllEnforcedVerticesByCoords() const { return _coordsEnfVertexMap; }
252 const TFaceEntryEnfVertexEntryListMap _GetAllEnfVertexEntriesByFace() const { return _faceEntryEnfVertexEntryListMap; }
253 const TEnfVertexEntryEnfVertexMap _GetAllEnforcedVerticesByEnfVertexEntry() const { return _enfVertexEntryEnfVertexMap; }
256 // const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; }
260 * \brief Return the enforced vertices
262 static TFaceEntryEnfVertexListMap GetAllEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
263 static TEnfVertexList GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp);
265 static TFaceEntryCoordsListMap GetAllCoordsByFace(const BLSURFPlugin_Hypothesis* hyp);
266 static TCoordsEnfVertexMap GetAllEnforcedVerticesByCoords(const BLSURFPlugin_Hypothesis* hyp);
268 static TFaceEntryEnfVertexEntryListMap GetAllEnfVertexEntriesByFace(const BLSURFPlugin_Hypothesis* hyp);
269 static TEnfVertexEntryEnfVertexMap GetAllEnforcedVerticesByEnfVertexEntry(const BLSURFPlugin_Hypothesis* hyp);
272 * \brief Internal enforced vertices
274 void SetInternalEnforcedVertexAllFaces(bool toEnforceInternalVertices);
275 const bool _GetInternalEnforcedVertexAllFaces() const { return _enforcedInternalVerticesAllFaces; }
276 static bool GetInternalEnforcedVertexAllFaces( const BLSURFPlugin_Hypothesis* hyp );
277 void SetInternalEnforcedVertexAllFacesGroup(TEnfGroupName theGroupName);
278 const TEnfGroupName _GetInternalEnforcedVertexAllFacesGroup() const { return _enforcedInternalVerticesAllFacesGroup; }
279 static TEnfGroupName GetInternalEnforcedVertexAllFacesGroup( const BLSURFPlugin_Hypothesis* hyp );
281 // Enable internal enforced vertices on specific face if requested by user
282 // static TFaceEntryInternalVerticesList GetDefaultFaceEntryInternalVerticesMap() { return TFaceEntryInternalVerticesList(); }
283 // const TFaceEntryInternalVerticesList _GetAllInternalEnforcedVerticesByFace() const { return _faceEntryInternalVerticesList; }
284 // static TFaceEntryInternalVerticesList GetAllInternalEnforcedVerticesByFace(const BLSURFPlugin_Hypothesis* hyp);
285 // void SetInternalEnforcedVertex(TEntry theFaceEntry, bool toEnforceInternalVertices, TEnfGroupName theGroupName);
286 // bool GetInternalEnforcedVertex(const TEntry& theFaceEntry);
288 static Topology GetDefaultTopology();
289 static PhysicalMesh GetDefaultPhysicalMesh();
290 static double GetDefaultPhySize();
291 static double GetDefaultMaxSize();
292 static double GetDefaultMinSize();
293 static GeometricMesh GetDefaultGeometricMesh();
294 static double GetDefaultAngleMeshS();
295 static double GetDefaultAngleMeshC() { return GetDefaultAngleMeshS(); }
296 static double GetDefaultGradation();
297 static bool GetDefaultQuadAllowed();
298 static bool GetDefaultDecimesh();
299 static int GetDefaultVerbosity() { return 10; }
301 static bool GetDefaultPreCADMergeEdges() { return false; }
302 static bool GetDefaultPreCADRemoveNanoEdges() { return false; }
303 static bool GetDefaultPreCADDiscardInput() { return false; }
304 static double GetDefaultPreCADEpsNano();
306 static TSizeMap GetDefaultSizeMap() { return TSizeMap();}
307 static TAttractorMap GetDefaultAttractorMap() { return TAttractorMap(); }
309 static TFaceEntryEnfVertexListMap GetDefaultFaceEntryEnfVertexListMap() { return TFaceEntryEnfVertexListMap(); }
310 static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); }
311 static TFaceEntryCoordsListMap GetDefaultFaceEntryCoordsListMap() { return TFaceEntryCoordsListMap(); }
312 static TCoordsEnfVertexMap GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
313 static TFaceEntryEnfVertexEntryListMap GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
314 static TEnfVertexEntryEnfVertexMap GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
315 static TGroupNameNodeIDMap GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
317 static bool GetDefaultInternalEnforcedVertex();
320 static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
321 static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); }
324 static double undefinedDouble() { return -1.0; }
326 typedef std::map< std::string, std::string > TOptionValues;
327 typedef std::set< std::string > TOptionNames;
329 void SetOptionValue(const std::string& optionName,
330 const std::string& optionValue) throw (std::invalid_argument);
331 void SetPreCADOptionValue(const std::string& optionName,
332 const std::string& optionValue) throw (std::invalid_argument);
333 std::string GetOptionValue(const std::string& optionName) throw (std::invalid_argument);
334 std::string GetPreCADOptionValue(const std::string& optionName) throw (std::invalid_argument);
335 void ClearOption(const std::string& optionName);
336 void ClearPreCADOption(const std::string& optionName);
337 const TOptionValues& GetOptionValues() const { return _option2value; }
338 const TOptionValues& GetPreCADOptionValues() const { return _preCADoption2value; }
341 * Sets the file for export resulting mesh in GMF format
343 // void SetGMFFile(const std::string& theFileName, bool isBinary);
344 void SetGMFFile(const std::string& theFileName);
345 std::string GetGMFFile() const { return _GMFFileName; }
346 static std::string GetDefaultGMFFile();
347 // bool GetGMFFileMode() const { return _GMFFileMode; }
350 virtual std::ostream & SaveTo(std::ostream & save);
351 virtual std::istream & LoadFrom(std::istream & load);
352 friend std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp);
353 friend std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp);
356 * \brief Does nothing
357 * \param theMesh - the built mesh
358 * \param theShape - the geometry of interest
359 * \retval bool - always false
361 virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
364 * \brief Initialize my parameter values by default parameters.
365 * \retval bool - true if parameter values have been successfully defined
367 virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
372 PhysicalMesh _physicalMesh;
373 double _phySize, _phyMin, _phyMax;
374 GeometricMesh _geometricMesh;
375 double _angleMeshS, _angleMeshC, _hgeoMin, _hgeoMax;
381 bool _preCADMergeEdges;
382 bool _preCADRemoveNanoEdges;
383 bool _preCADDiscardInput;
384 double _preCADEpsNano;
386 TOptionValues _option2value, _preCADoption2value;
387 TOptionNames _doubleOptions, _charOptions, _preCADdoubleOptions, _preCADcharOptions;
389 TSizeMap _attractors;
390 TAttractorMap _classAttractors;
392 TParamsMap _attParams;
394 TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap;
395 TEnfVertexList _enfVertexList;
396 // maps to get "manual" enf vertex (through their coordinates)
397 TFaceEntryCoordsListMap _faceEntryCoordsListMap;
398 TCoordsEnfVertexMap _coordsEnfVertexMap;
399 // maps to get "geom" enf vertex (through their geom entries)
400 TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
401 TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap;
402 TGroupNameNodeIDMap _groupNameNodeIDMap;
404 // Enable internal enforced vertices on specific face if requested by user
405 // TFaceEntryInternalVerticesList _faceEntryInternalVerticesList;
406 bool _enforcedInternalVerticesAllFaces;
407 TEnfGroupName _enforcedInternalVerticesAllFacesGroup;
409 std::string _GMFFileName;
410 // bool _GMFFileMode;
412 // TSizeMap _customSizeMap;