1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // NETGENPlugin : C++ implementation
24 // File : NETGENPlugin_Hypothesis_2D.cxx
25 // Author : Michael Sazonov (OCN)
28 //=============================================================================
30 #include "NETGENPlugin_Hypothesis_2D.hxx"
32 #include <SMESH_Mesh.hxx>
33 #include <SMESH_Group.hxx>
34 #include <SMESHDS_GroupBase.hxx>
38 //=============================================================================
42 //=============================================================================
43 NETGENPlugin_Hypothesis_2D::NETGENPlugin_Hypothesis_2D (int hypId,
45 : NETGENPlugin_Hypothesis(hypId, gen)/*,
46 _quadAllowed (GetDefaultQuadAllowed())*/
48 _name = "NETGEN_Parameters_2D";
52 //=============================================================================
56 //=============================================================================
57 NETGENPlugin_RemesherHypothesis_2D::
58 NETGENPlugin_RemesherHypothesis_2D (int hypId, SMESH_Gen * gen)
59 : NETGENPlugin_Hypothesis(hypId, gen),
60 _ridgeAngle ( DefaultRidgeAngle() ),
61 _edgeCornerAngle ( DefaultEdgeCornerAngle() ),
62 _chartAngle ( DefaultChartAngle() ),
63 _outerChartAngle ( DefaultOuterChartAngle() ),
64 _restHChartDistFactor ( DefaultRestHChartDistFactor() ),
65 _restHChartDistEnable ( DefaultRestHChartDistEnable() ),
66 _restHLineLengthFactor ( DefaultRestHLineLengthFactor() ),
67 _restHLineLengthEnable ( DefaultRestHLineLengthEnable() ),
68 _restHCloseEdgeFactor ( DefaultRestHCloseEdgeFactor() ),
69 _restHCloseEdgeEnable ( DefaultRestHCloseEdgeEnable() ),
70 _restHSurfCurvFactor ( DefaultRestHSurfCurvFactor() ),
71 _restHSurfCurvEnable ( DefaultRestHSurfCurvEnable() ),
72 _restHEdgeAngleFactor ( DefaultRestHEdgeAngleFactor() ),
73 _restHEdgeAngleEnable ( DefaultRestHEdgeAngleEnable() ),
74 _restHSurfMeshCurvFactor( DefaultRestHSurfMeshCurvFactor()),
75 _restHSurfMeshCurvEnable( DefaultRestHSurfMeshCurvEnable()),
76 _keepExistingEdges ( DefaultKeepExistingEdges() ),
77 _makeGroupsOfSurfaces ( DefaultMakeGroupsOfSurfaces() ),
78 _fixedEdgeGroupID ( -1 ),
79 _loadOnCancel ( false )
81 _name = "NETGEN_RemesherParameters_2D";
85 //=============================================================================
89 //=============================================================================
91 void NETGENPlugin_RemesherHypothesis_2D::SetRidgeAngle( double angle )
93 if ( _ridgeAngle != angle )
96 NotifySubMeshesHypothesisModification();
100 //=======================================================================
101 //function : SetEdgeCornerAngle
103 //=======================================================================
105 void NETGENPlugin_RemesherHypothesis_2D::SetEdgeCornerAngle( double angle )
107 if ( _edgeCornerAngle != angle )
109 _edgeCornerAngle = angle;
110 NotifySubMeshesHypothesisModification();
114 //=======================================================================
115 //function : SetChartAngle
117 //=======================================================================
119 void NETGENPlugin_RemesherHypothesis_2D::SetChartAngle( double angle )
121 if ( _chartAngle != angle )
124 NotifySubMeshesHypothesisModification();
128 //=======================================================================
129 //function : SetOuterChartAngle
131 //=======================================================================
133 void NETGENPlugin_RemesherHypothesis_2D::SetOuterChartAngle( double angle )
135 if ( _outerChartAngle != angle )
137 _outerChartAngle = angle;
138 NotifySubMeshesHypothesisModification();
142 //=======================================================================
143 //function : SetRestHChartDistFactor
145 //=======================================================================
147 void NETGENPlugin_RemesherHypothesis_2D::SetRestHChartDistFactor( double f )
149 if ( _restHChartDistFactor != f )
151 _restHChartDistFactor = f;
152 NotifySubMeshesHypothesisModification();
156 //=======================================================================
157 //function : SetRestHChartDistEnable
159 //=======================================================================
161 void NETGENPlugin_RemesherHypothesis_2D::SetRestHChartDistEnable( bool enable )
163 if ( _restHChartDistEnable != enable )
165 _restHChartDistEnable = enable;
166 NotifySubMeshesHypothesisModification();
170 //=======================================================================
171 //function : SetRestHLineLengthFactor
173 //=======================================================================
175 void NETGENPlugin_RemesherHypothesis_2D::SetRestHLineLengthFactor( double f )
177 if ( _restHLineLengthFactor != f )
179 _restHLineLengthFactor = f;
180 NotifySubMeshesHypothesisModification();
184 //=======================================================================
185 //function : SetRestHLineLengthEnable
187 //=======================================================================
189 void NETGENPlugin_RemesherHypothesis_2D::SetRestHLineLengthEnable( bool enable )
191 if ( _restHLineLengthEnable != enable )
193 _restHLineLengthEnable = enable;
194 NotifySubMeshesHypothesisModification();
198 //=======================================================================
199 //function : SetRestHCloseEdgeFactor
201 //=======================================================================
203 void NETGENPlugin_RemesherHypothesis_2D::SetRestHCloseEdgeFactor( double f )
205 if ( _restHCloseEdgeFactor != f )
207 _restHCloseEdgeFactor = f;
208 NotifySubMeshesHypothesisModification();
212 //=======================================================================
213 //function : SetRestHCloseEdgeEnable
215 //=======================================================================
217 void NETGENPlugin_RemesherHypothesis_2D::SetRestHCloseEdgeEnable( bool enable )
219 if ( _restHCloseEdgeEnable != enable )
221 _restHCloseEdgeEnable = enable;
222 NotifySubMeshesHypothesisModification();
226 //=======================================================================
227 //function : SetRestHSurfCurvFactor
229 //=======================================================================
231 void NETGENPlugin_RemesherHypothesis_2D::SetRestHSurfCurvFactor( double f )
233 if ( _restHSurfCurvFactor != f )
235 _restHSurfCurvFactor = f;
236 NotifySubMeshesHypothesisModification();
240 //=======================================================================
241 //function : SetRestHSurfCurvEnable
243 //=======================================================================
245 void NETGENPlugin_RemesherHypothesis_2D::SetRestHSurfCurvEnable( bool enable )
247 if ( _restHSurfCurvEnable != enable )
249 _restHSurfCurvEnable = enable;
250 NotifySubMeshesHypothesisModification();
254 //=======================================================================
255 //function : SetRestHEdgeAngleFactor
257 //=======================================================================
259 void NETGENPlugin_RemesherHypothesis_2D::SetRestHEdgeAngleFactor( double f )
261 if ( _restHEdgeAngleFactor != f )
263 _restHEdgeAngleFactor = f;
264 NotifySubMeshesHypothesisModification();
268 //=======================================================================
269 //function : SetRestHEdgeAngleEnable
271 //=======================================================================
273 void NETGENPlugin_RemesherHypothesis_2D::SetRestHEdgeAngleEnable( bool enable )
275 if ( _restHEdgeAngleEnable != enable )
277 _restHEdgeAngleEnable = enable;
278 NotifySubMeshesHypothesisModification();
282 //=======================================================================
283 //function : SetRestHSurfMeshCurvFactor
285 //=======================================================================
287 void NETGENPlugin_RemesherHypothesis_2D::SetRestHSurfMeshCurvFactor( double f )
289 if ( _restHSurfMeshCurvFactor != f )
291 _restHSurfMeshCurvFactor = f;
292 NotifySubMeshesHypothesisModification();
296 //=======================================================================
297 //function : SetRestHSurfMeshCurvEnable
299 //=======================================================================
301 void NETGENPlugin_RemesherHypothesis_2D::SetRestHSurfMeshCurvEnable( bool enable )
303 if ( _restHSurfMeshCurvEnable != enable )
305 _restHSurfMeshCurvEnable = enable;
306 NotifySubMeshesHypothesisModification();
310 //=======================================================================
311 //function : SetKeepExistingEdges
313 //=======================================================================
315 void NETGENPlugin_RemesherHypothesis_2D::SetKeepExistingEdges( bool toKeep )
317 if ( _keepExistingEdges != toKeep )
319 _keepExistingEdges = toKeep;
320 NotifySubMeshesHypothesisModification();
324 //=======================================================================
325 //function : SetMakeGroupsOfSurfaces
327 //=======================================================================
329 void NETGENPlugin_RemesherHypothesis_2D::SetMakeGroupsOfSurfaces( bool toMake )
331 if ( _makeGroupsOfSurfaces != toMake )
333 _makeGroupsOfSurfaces = toMake;
334 NotifySubMeshesHypothesisModification();
338 //=======================================================================
339 //function : SetFixedEdgeGroup
340 //purpose : Set a group of edges whose nodes must not be moved
341 //=======================================================================
343 void NETGENPlugin_RemesherHypothesis_2D::SetFixedEdgeGroup( const SMESH_Group* edgeGroup )
345 int id = edgeGroup ? edgeGroup->GetID() : -1;
346 if ( id != _fixedEdgeGroupID )
348 _fixedEdgeGroupID = id;
349 NotifySubMeshesHypothesisModification();
353 //=======================================================================
354 //function : SetLoadMeshOnCancel
355 //purpose : allow getting a current mesh existing upon CancelCompute()
356 //=======================================================================
358 void NETGENPlugin_RemesherHypothesis_2D::SetLoadMeshOnCancel( bool toLoad )
360 if ( toLoad != _loadOnCancel )
362 _loadOnCancel = toLoad;
363 NotifySubMeshesHypothesisModification();
367 //=======================================================================
368 //function : GetFixedEdgeGroup
369 //purpose : Return a group of edges whose nodes must not be moved
370 //=======================================================================
373 NETGENPlugin_RemesherHypothesis_2D::GetFixedEdgeGroup( const SMESH_Mesh& mesh ) const
375 SMESH_Group* group = mesh.GetGroup( _fixedEdgeGroupID );
376 if ( group && group->GetGroupDS()->GetType() != SMDSAbs_Edge )
382 //=============================================================================
386 //=============================================================================
388 std::ostream & NETGENPlugin_RemesherHypothesis_2D::SaveTo(std::ostream & save)
390 NETGENPlugin_Hypothesis::SaveTo( save );
391 save << " " << _ridgeAngle;
393 save << " " << _edgeCornerAngle ;
394 save << " " << _chartAngle ;
395 save << " " << _outerChartAngle ;
396 save << " " << _restHChartDistFactor ;
397 save << " " << _restHChartDistEnable ;
398 save << " " << _restHLineLengthFactor ;
399 save << " " << _restHLineLengthEnable ;
400 save << " " << _restHCloseEdgeFactor ;
401 save << " " << _restHCloseEdgeEnable ;
402 save << " " << _restHSurfCurvFactor ;
403 save << " " << _restHSurfCurvEnable ;
404 save << " " << _restHEdgeAngleFactor ;
405 save << " " << _restHEdgeAngleEnable ;
406 save << " " << _restHSurfMeshCurvFactor;
407 save << " " << _restHSurfMeshCurvEnable;
408 save << " " << _keepExistingEdges ;
409 save << " " << _makeGroupsOfSurfaces ;
410 save << " " << _fixedEdgeGroupID ;
411 save << " " << _loadOnCancel ;
416 //=============================================================================
420 //=============================================================================
422 std::istream & NETGENPlugin_RemesherHypothesis_2D::LoadFrom(std::istream & load)
424 NETGENPlugin_Hypothesis::LoadFrom( load );
426 load.clear(ios::badbit | load.rdstate());
431 _ridgeAngle = DefaultRidgeAngle();
433 load >> _edgeCornerAngle;
435 _edgeCornerAngle = DefaultEdgeCornerAngle();
439 _chartAngle = DefaultChartAngle();
441 load >> _outerChartAngle;
443 _outerChartAngle = DefaultOuterChartAngle();
445 load >> _restHChartDistFactor;
447 _restHChartDistFactor = DefaultRestHChartDistFactor();
449 load >> _restHChartDistEnable;
451 _restHChartDistEnable = DefaultRestHChartDistEnable();
453 load >> _restHLineLengthFactor;
455 _restHLineLengthFactor = DefaultRestHLineLengthFactor();
457 load >> _restHLineLengthEnable;
459 _restHLineLengthEnable = DefaultRestHLineLengthEnable();
461 load >> _restHCloseEdgeFactor;
463 _restHCloseEdgeFactor = DefaultRestHCloseEdgeFactor();
465 load >> _restHCloseEdgeEnable;
467 _restHCloseEdgeEnable = DefaultRestHCloseEdgeEnable();
469 load >> _restHSurfCurvFactor;
471 _restHSurfCurvFactor = DefaultRestHSurfCurvFactor();
473 load >> _restHSurfCurvEnable;
475 _restHSurfCurvEnable = DefaultRestHSurfCurvEnable();
477 load >> _restHEdgeAngleFactor;
479 _restHEdgeAngleFactor = DefaultRestHEdgeAngleFactor();
481 load >> _restHEdgeAngleEnable;
483 _restHEdgeAngleEnable = DefaultRestHEdgeAngleEnable();
485 load >> _restHSurfMeshCurvFactor;
487 _restHSurfMeshCurvFactor = DefaultRestHSurfMeshCurvFactor();
489 load >> _restHSurfMeshCurvEnable;
491 _restHSurfMeshCurvEnable = DefaultRestHSurfMeshCurvEnable();
493 load >> _keepExistingEdges;
495 _keepExistingEdges = DefaultKeepExistingEdges();
497 load >> _makeGroupsOfSurfaces;
499 _makeGroupsOfSurfaces = DefaultMakeGroupsOfSurfaces();
501 load >> _fixedEdgeGroupID;
503 _fixedEdgeGroupID = -1;
505 load >> _loadOnCancel;
507 _loadOnCancel = false;