]> SALOME platform Git repositories - plugins/hybridplugin.git/blob - src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx
Salome HOME
Update copyrights
[plugins/hybridplugin.git] / src / HYBRIDPlugin / HYBRIDPlugin_Hypothesis.cxx
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //=============================================================================
21 // File      : HYBRIDPlugin_Hypothesis.cxx
22 // Created   : Wed Apr  2 12:36:29 2008
23 // Author    : Edward AGAPOV (eap)
24 //=============================================================================
25 //
26 #include "HYBRIDPlugin_Hypothesis.hxx"
27
28 #include <SMESHDS_Mesh.hxx>
29
30 #include <TopExp_Explorer.hxx>
31
32 #ifdef WIN32
33 #include <process.h>
34 #define getpid _getpid
35 #endif
36
37 //=======================================================================
38 //function : HYBRIDPlugin_Hypothesis
39 //=======================================================================
40
41 HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, SMESH_Gen * gen)
42   : SMESH_Hypothesis(hypId, gen),
43   myToMeshHoles(DefaultMeshHoles()),
44   myLayersOnAllWrap(DefaultLayersOnAllWrap()),
45   myToMakeGroupsOfDomains(DefaultToMakeGroupsOfDomains()),
46   myMaximumMemory(-1),
47   myInitialMemory(-1),
48   myOptimizationLevel(DefaultOptimizationLevel()),
49   myCollisionMode(DefaultCollisionMode()),
50   myBoundaryLayersGrowth(DefaultBoundaryLayersGrowth()),
51   myElementGeneration(DefaultElementGeneration()),
52   myKeepFiles(DefaultKeepFiles()),
53   myWorkingDirectory(DefaultWorkingDirectory()),
54   myVerboseLevel(DefaultVerboseLevel()),
55   myToCreateNewNodes(DefaultToCreateNewNodes()),
56   myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()),
57   myToUseFemCorrection(DefaultToUseFEMCorrection()),
58   myToRemoveCentralPoint(DefaultToRemoveCentralPoint()),
59   myLogInStandardOutput(DefaultStandardOutputLog()),
60   myGradation(DefaultGradation()),
61   myAddMultinormals(DefaultAddMultinormals()),
62   mySmoothNormals(DefaultSmoothNormals()),
63   myHeightFirstLayer(DefaultHeightFirstLayer()),
64   myBoundaryLayersProgression(DefaultBoundaryLayersProgression()),
65   myCoreSize(DefaultCoreSize()),
66   myMultinormalsAngle(DefaultMultinormalsAngle()),
67   myNbOfBoundaryLayers(DefaultNbOfBoundaryLayers()),
68   _enfVertexList(DefaultHYBRIDEnforcedVertexList()),
69   _enfVertexCoordsSizeList(DefaultHYBRIDEnforcedVertexCoordsValues()),
70   _enfVertexEntrySizeList(DefaultHYBRIDEnforcedVertexEntryValues()),
71   _coordsEnfVertexMap(DefaultCoordsHYBRIDEnforcedVertexMap()),
72   _geomEntryEnfVertexMap(DefaultGeomEntryHYBRIDEnforcedVertexMap()),
73   _enfMeshList(DefaultHYBRIDEnforcedMeshList()),
74   _entryEnfMeshMap(DefaultEntryHYBRIDEnforcedMeshListMap()),
75   _enfNodes(TIDSortedNodeGroupMap()),
76   _enfEdges(TIDSortedElemGroupMap()),
77   _enfTriangles(TIDSortedElemGroupMap()),
78   _nodeIDToSizeMap(DefaultID2SizeMap()),
79   _groupsToRemove(DefaultGroupsToRemove())
80 {
81   _name = "HYBRID_Parameters";
82   _param_algo_dim = 3;
83 }
84
85 //=======================================================================
86 //function : SetLayersOnAllWrap
87 //=======================================================================
88
89 void HYBRIDPlugin_Hypothesis::SetLayersOnAllWrap(bool toMesh)
90 {
91   if ( myLayersOnAllWrap != toMesh ) {
92     myLayersOnAllWrap = toMesh;
93     NotifySubMeshesHypothesisModification();
94   }
95 }
96
97 //=======================================================================
98 //function : GetLayersOnAllWrap
99 //=======================================================================
100
101 bool HYBRIDPlugin_Hypothesis::GetLayersOnAllWrap(bool checkFreeOption) const
102 {
103   return myLayersOnAllWrap;
104 }
105
106 //=======================================================================
107 //function : SetFacesWithLayers
108 //purpose  : Set IDs of faces to grow the layers on
109 //=======================================================================
110
111 bool HYBRIDPlugin_Hypothesis::SetFacesWithLayers(const std::vector<int>& theVal)
112 {
113   if ( myFacesWithLayers != theVal )
114   {
115     myFacesWithLayers = theVal;
116     NotifySubMeshesHypothesisModification();
117     return true;
118   }
119   return false;
120 }
121
122 //=======================================================================
123 //function : GetFacesWithLayers
124 //purpose  : Return IDs of faces to grow the layers on
125 //=======================================================================
126
127 const std::vector<int>& HYBRIDPlugin_Hypothesis::GetFacesWithLayers() const
128 {
129   return myFacesWithLayers;
130 }
131
132 //=======================================================================
133 //function : SetFacesWithImprinting
134 //purpose  : Set IDs of faces to grow the layers on
135 //=======================================================================
136
137 bool HYBRIDPlugin_Hypothesis::SetFacesWithImprinting(const std::vector<int>& theVal)
138 {
139   if ( myFacesWithImprinting != theVal )
140   {
141     myFacesWithImprinting = theVal;
142     NotifySubMeshesHypothesisModification();
143     return true;
144   }
145   return false;
146 }
147
148 //=======================================================================
149 //function : GetFacesWithImprinting
150 //purpose  : Return IDs of faces to grow the layers on
151 //=======================================================================
152
153 const std::vector<int>& HYBRIDPlugin_Hypothesis::GetFacesWithImprinting() const
154 {
155   return myFacesWithImprinting;
156 }
157
158 //=======================================================================
159 //function : SetFacesWithSnapping
160 //purpose  : Set IDs of faces that already have surface layers
161 //=======================================================================
162
163 bool HYBRIDPlugin_Hypothesis::SetFacesWithSnapping(const std::vector<int>& theVal)
164 {
165   if ( myFacesWithSnapping != theVal )
166   {
167     myFacesWithSnapping = theVal;
168     NotifySubMeshesHypothesisModification();
169     return true;
170   }
171   return false;
172 }
173
174 //=======================================================================
175 //function : GetFacesWithSnapping
176 //purpose  : Return IDs of faces that already have surface layers
177 //=======================================================================
178
179 const std::vector<int>& HYBRIDPlugin_Hypothesis::GetFacesWithSnapping() const
180 {
181   return myFacesWithSnapping;
182 }
183
184 //=======================================================================
185 //function : SetToMeshHoles
186 //=======================================================================
187
188 void HYBRIDPlugin_Hypothesis::SetToMeshHoles(bool toMesh)
189 {
190   if ( myToMeshHoles != toMesh ) {
191     myToMeshHoles = toMesh;
192     NotifySubMeshesHypothesisModification();
193   }
194 }
195
196 //=======================================================================
197 //function : GetToMeshHoles
198 //=======================================================================
199
200 bool HYBRIDPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const
201 {
202   if (checkFreeOption && !myTextOption.empty()) {
203     if ( myTextOption.find("-c 0"))
204       return true;
205     if ( myTextOption.find("-c 1"))
206       return false;
207   }
208   return myToMeshHoles;
209 }
210
211 //=======================================================================
212 //function : SetToMakeGroupsOfDomains
213 //=======================================================================
214
215 void HYBRIDPlugin_Hypothesis::SetToMakeGroupsOfDomains(bool toMakeGroups)
216 {
217   if ( myToMakeGroupsOfDomains != toMakeGroups ) {
218     myToMakeGroupsOfDomains = toMakeGroups;
219     NotifySubMeshesHypothesisModification();
220   }
221 }
222
223 //=======================================================================
224 //function : GetToMakeGroupsOfDomains
225 //=======================================================================
226
227 bool HYBRIDPlugin_Hypothesis::GetToMakeGroupsOfDomains() const
228 {
229   return myToMakeGroupsOfDomains;
230 }
231
232 //=======================================================================
233 //function : GetToMakeGroupsOfDomains
234 //=======================================================================
235
236 bool HYBRIDPlugin_Hypothesis::GetToMakeGroupsOfDomains(const HYBRIDPlugin_Hypothesis* hyp)
237 {
238   bool res;
239   if ( hyp ) res = /*hyp->GetToMeshHoles(true) &&*/ hyp->GetToMakeGroupsOfDomains();
240   else       res = /*DefaultMeshHoles()        &&*/ DefaultToMakeGroupsOfDomains();
241   return res;
242 }
243
244 //=======================================================================
245 //function : SetMaximumMemory
246 //=======================================================================
247
248 void HYBRIDPlugin_Hypothesis::SetMaximumMemory(double MB)
249 {
250   if ( myMaximumMemory != MB ) {
251     myMaximumMemory = MB;
252     NotifySubMeshesHypothesisModification();
253   }
254 }
255
256 //=======================================================================
257 //function : GetMaximumMemory
258 //           * automatic memory adjustment mode. Default is zero
259 //=======================================================================
260
261 double HYBRIDPlugin_Hypothesis::GetMaximumMemory() const
262 {
263   return myMaximumMemory;
264 }
265
266 //=======================================================================
267 //function : SetInitialMemory
268 //=======================================================================
269
270 void HYBRIDPlugin_Hypothesis::SetInitialMemory(double MB)
271 {
272   if ( myInitialMemory != MB ) {
273     myInitialMemory = MB;
274     NotifySubMeshesHypothesisModification();
275   }
276 }
277
278 //=======================================================================
279 //function : GetInitialMemory
280 //=======================================================================
281
282 double HYBRIDPlugin_Hypothesis::GetInitialMemory() const
283 {
284   return myInitialMemory;
285 }
286
287 //=======================================================================
288 //function : SetOptimizationLevel
289 //=======================================================================
290
291 void HYBRIDPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level)
292 {
293   if ( myOptimizationLevel != level ) {
294     myOptimizationLevel = level;
295     NotifySubMeshesHypothesisModification();
296   }
297 }
298
299 //=======================================================================
300 //function : GetOptimizationLevel
301 //=======================================================================
302 HYBRIDPlugin_Hypothesis::OptimizationLevel HYBRIDPlugin_Hypothesis::GetOptimizationLevel() const
303 {
304   return (OptimizationLevel) myOptimizationLevel;
305 }
306
307 //=======================================================================
308 //function : SetCollisionMode
309 //=======================================================================
310 void HYBRIDPlugin_Hypothesis::SetCollisionMode(CollisionMode mode)
311 {
312   if ( myCollisionMode != mode ) {
313     myCollisionMode = mode;
314     NotifySubMeshesHypothesisModification();
315   }
316 }
317
318 //=======================================================================
319 //function : GetCollisionMode
320 //=======================================================================
321 HYBRIDPlugin_Hypothesis::CollisionMode HYBRIDPlugin_Hypothesis::GetCollisionMode() const
322 {
323   return (CollisionMode) myCollisionMode;
324 }
325
326 //=======================================================================
327 //function : SetBoundaryLayersGrowth
328 //=======================================================================
329 void HYBRIDPlugin_Hypothesis::SetBoundaryLayersGrowth(BoundaryLayersGrowth mode)
330 {
331   if ( myBoundaryLayersGrowth != mode ) {
332     myBoundaryLayersGrowth = mode;
333     NotifySubMeshesHypothesisModification();
334   }
335 }
336
337 //=======================================================================
338 //function : GetBoundaryLayersGrowth
339 //=======================================================================
340 HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth HYBRIDPlugin_Hypothesis::GetBoundaryLayersGrowth() const
341 {
342   return (BoundaryLayersGrowth) myBoundaryLayersGrowth;
343 }
344
345 //=======================================================================
346 //function : SetElementGeneration
347 //=======================================================================
348 void HYBRIDPlugin_Hypothesis::SetElementGeneration(ElementGeneration mode)
349 {
350   if ( myElementGeneration != mode ) {
351     myElementGeneration = mode;
352     NotifySubMeshesHypothesisModification();
353   }
354 }
355
356 //=======================================================================
357 //function : GetElementGeneration
358 //=======================================================================
359 HYBRIDPlugin_Hypothesis::ElementGeneration HYBRIDPlugin_Hypothesis::GetElementGeneration() const
360 {
361   return (ElementGeneration) myElementGeneration;
362 }
363
364 //=======================================================================
365 //function : SetAddMultinormals
366 //=======================================================================
367 void HYBRIDPlugin_Hypothesis::SetAddMultinormals(bool toAddMultinormals)
368 {
369   if ( myAddMultinormals != toAddMultinormals ) {
370     myAddMultinormals = toAddMultinormals;
371     NotifySubMeshesHypothesisModification();
372   }
373 }
374
375 //=======================================================================
376 //function : GetAddMultinormals
377 //=======================================================================
378
379 bool HYBRIDPlugin_Hypothesis::GetAddMultinormals() const
380 {
381   return myAddMultinormals;
382 }
383
384 //=======================================================================
385 //function : SetSmoothNormals
386 //=======================================================================
387
388 void HYBRIDPlugin_Hypothesis::SetSmoothNormals(bool toSmoothNormals)
389 {
390   if ( mySmoothNormals != toSmoothNormals ) {
391     mySmoothNormals = toSmoothNormals;
392     NotifySubMeshesHypothesisModification();
393   }
394 }
395
396 //=======================================================================
397 //function : GetSmoothNormals
398 //=======================================================================
399
400 bool HYBRIDPlugin_Hypothesis::GetSmoothNormals() const
401 {
402   return mySmoothNormals;
403 }
404
405 //=======================================================================
406 //function : SetHeightFirstLayer
407 //=======================================================================
408
409 void HYBRIDPlugin_Hypothesis::SetHeightFirstLayer(double toHeightFirstLayer)
410 {
411   if ( myHeightFirstLayer != toHeightFirstLayer ) {
412     myHeightFirstLayer = toHeightFirstLayer;
413     NotifySubMeshesHypothesisModification();
414   }
415 }
416
417 //=======================================================================
418 //function : GetHeightFirstLayer
419 //=======================================================================
420
421 double HYBRIDPlugin_Hypothesis::GetHeightFirstLayer() const
422 {
423   return myHeightFirstLayer;
424 }
425
426 //=======================================================================
427 //function : SetBoundaryLayersProgression
428 //=======================================================================
429
430 void HYBRIDPlugin_Hypothesis::SetBoundaryLayersProgression(double toBoundaryLayersProgression)
431 {
432   if ( myBoundaryLayersProgression != toBoundaryLayersProgression ) {
433     myBoundaryLayersProgression = toBoundaryLayersProgression;
434     NotifySubMeshesHypothesisModification();
435   }
436 }
437
438 //=======================================================================
439 //function : GetBoundaryLayersProgression
440 //=======================================================================
441
442 double HYBRIDPlugin_Hypothesis::GetBoundaryLayersProgression() const
443 {
444   return myBoundaryLayersProgression;
445 }
446
447 //=======================================================================
448 //function : SetCoreSize
449 //=======================================================================
450
451 void HYBRIDPlugin_Hypothesis::SetCoreSize(double toCoreSize)
452 {
453   if ( myCoreSize != toCoreSize ) {
454     myCoreSize = toCoreSize;
455     NotifySubMeshesHypothesisModification();
456   }
457 }
458
459 //=======================================================================
460 //function : GetCoreSize
461 //=======================================================================
462
463 double HYBRIDPlugin_Hypothesis::GetCoreSize() const
464 {
465   return myCoreSize;
466 }
467
468 //=======================================================================
469 //function : SetMultinormalsAngle
470 //=======================================================================
471
472 void HYBRIDPlugin_Hypothesis::SetMultinormalsAngle(double toMultinormalsAngle)
473 {
474   if ( myMultinormalsAngle != toMultinormalsAngle ) {
475     myMultinormalsAngle = toMultinormalsAngle;
476     NotifySubMeshesHypothesisModification();
477   }
478 }
479
480 //=======================================================================
481 //function : GetMultinormalsAngle
482 //=======================================================================
483
484 double HYBRIDPlugin_Hypothesis::GetMultinormalsAngle() const
485 {
486   return myMultinormalsAngle;
487 }
488
489 //=======================================================================
490 //function : SetNbOfBoundaryLayers
491 //=======================================================================
492
493 void HYBRIDPlugin_Hypothesis::SetNbOfBoundaryLayers(short toNbOfBoundaryLayers)
494 {
495   if ( myNbOfBoundaryLayers != toNbOfBoundaryLayers ) {
496     myNbOfBoundaryLayers = toNbOfBoundaryLayers;
497     NotifySubMeshesHypothesisModification();
498   }
499 }
500
501 //=======================================================================
502 //function : GetCoreSize
503 //=======================================================================
504
505 short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const
506 {
507   return myNbOfBoundaryLayers;
508 }
509
510
511 /////////////////////////////////////////////////////////////////////////
512
513
514 //=======================================================================
515 //function : SetWorkingDirectory
516 //=======================================================================
517
518 void HYBRIDPlugin_Hypothesis::SetWorkingDirectory(const std::string& path)
519 {
520   if ( myWorkingDirectory != path ) {
521     myWorkingDirectory = path;
522     NotifySubMeshesHypothesisModification();
523   }
524 }
525
526 //=======================================================================
527 //function : GetWorkingDirectory
528 //=======================================================================
529
530 std::string HYBRIDPlugin_Hypothesis::GetWorkingDirectory() const
531 {
532   return myWorkingDirectory;
533 }
534
535 //=======================================================================
536 //function : SetKeepFiles
537 //=======================================================================
538
539 void HYBRIDPlugin_Hypothesis::SetKeepFiles(bool toKeep)
540 {
541   if ( myKeepFiles != toKeep ) {
542     myKeepFiles = toKeep;
543     NotifySubMeshesHypothesisModification();
544   }
545 }
546
547 //=======================================================================
548 //function : GetKeepFiles
549 //=======================================================================
550
551 bool HYBRIDPlugin_Hypothesis::GetKeepFiles() const
552 {
553   return myKeepFiles;
554 }
555
556 //=======================================================================
557 //function : SetVerboseLevel
558 //=======================================================================
559
560 void HYBRIDPlugin_Hypothesis::SetVerboseLevel(short level)
561 {
562   if ( myVerboseLevel != level ) {
563     myVerboseLevel = level;
564     NotifySubMeshesHypothesisModification();
565   }
566 }
567
568 //=======================================================================
569 //function : GetVerboseLevel
570 //=======================================================================
571
572 short HYBRIDPlugin_Hypothesis::GetVerboseLevel() const
573 {
574   return myVerboseLevel;
575 }
576
577 //=======================================================================
578 //function : SetToCreateNewNodes
579 //=======================================================================
580
581 void HYBRIDPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate)
582 {
583   if ( myToCreateNewNodes != toCreate ) {
584     myToCreateNewNodes = toCreate;
585     NotifySubMeshesHypothesisModification();
586   }
587 }
588
589 //=======================================================================
590 //function : GetToCreateNewNodes
591 //=======================================================================
592
593 bool HYBRIDPlugin_Hypothesis::GetToCreateNewNodes() const
594 {
595   return myToCreateNewNodes;
596 }
597
598 //=======================================================================
599 //function : SetToUseBoundaryRecoveryVersion
600 //=======================================================================
601
602 void HYBRIDPlugin_Hypothesis::SetToUseBoundaryRecoveryVersion(bool toUse)
603 {
604   if ( myToUseBoundaryRecoveryVersion != toUse ) {
605     myToUseBoundaryRecoveryVersion = toUse;
606     NotifySubMeshesHypothesisModification();
607   }
608 }
609
610 //=======================================================================
611 //function : GetToUseBoundaryRecoveryVersion
612 //=======================================================================
613
614 bool HYBRIDPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const
615 {
616   return myToUseBoundaryRecoveryVersion;
617 }
618
619 //=======================================================================
620 //function : SetFEMCorrection
621 //=======================================================================
622
623 void HYBRIDPlugin_Hypothesis::SetFEMCorrection(bool toUseFem)
624 {
625   if ( myToUseFemCorrection != toUseFem ) {
626     myToUseFemCorrection = toUseFem;
627     NotifySubMeshesHypothesisModification();
628   }
629 }
630
631 //=======================================================================
632 //function : GetFEMCorrection
633 //=======================================================================
634
635 bool HYBRIDPlugin_Hypothesis::GetFEMCorrection() const
636 {
637   return myToUseFemCorrection;
638 }
639
640 //=======================================================================
641 //function : SetToRemoveCentralPoint
642 //=======================================================================
643
644 void HYBRIDPlugin_Hypothesis::SetToRemoveCentralPoint(bool toRemove)
645 {
646   if ( myToRemoveCentralPoint != toRemove ) {
647     myToRemoveCentralPoint = toRemove;
648     NotifySubMeshesHypothesisModification();
649   }
650 }
651
652 //=======================================================================
653 //function : GetToRemoveCentralPoint
654 //=======================================================================
655
656 bool HYBRIDPlugin_Hypothesis::GetToRemoveCentralPoint() const
657 {
658   return myToRemoveCentralPoint;
659 }
660
661 //=======================================================================
662 //function : SetAdvancedOption
663 //=======================================================================
664
665 void HYBRIDPlugin_Hypothesis::SetAdvancedOption(const std::string& option)
666 {
667   if ( myTextOption != option ) {
668     myTextOption = option;
669     NotifySubMeshesHypothesisModification();
670   }
671 }
672
673 //=======================================================================
674 //function : GetAdvancedOption
675 //=======================================================================
676
677 std::string HYBRIDPlugin_Hypothesis::GetAdvancedOption() const
678 {
679   return myTextOption;
680 }
681
682 //=======================================================================
683 //function : SetGradation
684 //=======================================================================
685
686 void HYBRIDPlugin_Hypothesis::SetGradation(double gradation)
687 {
688   if ( myGradation != gradation ) {
689     myGradation = gradation;
690     NotifySubMeshesHypothesisModification();
691   }
692 }
693
694 //=======================================================================
695 //function : GetGradation
696 //=======================================================================
697
698 double HYBRIDPlugin_Hypothesis::GetGradation() const
699 {
700   return myGradation;
701 }
702
703 //=======================================================================
704 //function : SetStandardOutputLog
705 //=======================================================================
706
707 void HYBRIDPlugin_Hypothesis::SetStandardOutputLog(bool logInStandardOutput)
708 {
709   if ( myLogInStandardOutput != logInStandardOutput ) {
710     myLogInStandardOutput = logInStandardOutput;
711     NotifySubMeshesHypothesisModification();
712   }
713 }
714
715 //=======================================================================
716 //function : GetStandardOutputLog
717 //=======================================================================
718
719 bool HYBRIDPlugin_Hypothesis::GetStandardOutputLog() const
720 {
721   return myLogInStandardOutput;
722 }
723
724 //=======================================================================
725 //function : SetRemoveLogOnSuccess
726 //=======================================================================
727
728 void HYBRIDPlugin_Hypothesis::SetRemoveLogOnSuccess(bool removeLogOnSuccess)
729 {
730   if ( myRemoveLogOnSuccess != removeLogOnSuccess ) {
731     myRemoveLogOnSuccess = removeLogOnSuccess;
732     NotifySubMeshesHypothesisModification();
733   }
734 }
735
736 //=======================================================================
737 //function : GetRemoveLogOnSuccess
738 //=======================================================================
739
740 bool HYBRIDPlugin_Hypothesis::GetRemoveLogOnSuccess() const
741 {
742   return myRemoveLogOnSuccess;
743 }
744
745 //=======================================================================
746 //function : SetEnforcedVertex
747 //=======================================================================
748
749 bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string theEntry, std::string theGroupName,
750                                                double size, double x, double y, double z, bool isCompound)
751 {
752   bool toNotify = false;
753   bool toCreate = true;
754
755   THYBRIDEnforcedVertex *oldEnVertex;
756   THYBRIDEnforcedVertex *newEnfVertex = new THYBRIDEnforcedVertex();
757   newEnfVertex->name = theName;
758   newEnfVertex->geomEntry = theEntry;
759   newEnfVertex->coords.clear();
760   if (!isCompound) {
761     newEnfVertex->coords.push_back(x);
762     newEnfVertex->coords.push_back(y);
763     newEnfVertex->coords.push_back(z);
764   }
765   newEnfVertex->groupName = theGroupName;
766   newEnfVertex->size = size;
767   newEnfVertex->isCompound = isCompound;
768   
769   
770   // update _enfVertexList
771   THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(newEnfVertex);
772   if (it != _enfVertexList.end()) {
773     toCreate = false;
774     oldEnVertex = (*it);
775     if (oldEnVertex->name != theName) {
776       oldEnVertex->name = theName;
777       toNotify = true;
778     }
779     if (oldEnVertex->groupName != theGroupName) {
780       oldEnVertex->groupName = theGroupName;
781       toNotify = true;
782     }
783     if (oldEnVertex->size != size) {
784       oldEnVertex->size = size;
785       toNotify = true;
786     }
787     if (toNotify) {
788       // update map coords / enf vertex if needed
789       if (oldEnVertex->coords.size()) {
790         _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
791         _enfVertexCoordsSizeList[oldEnVertex->coords] = size;
792       }
793
794       // update map geom entry / enf vertex if needed
795       if (oldEnVertex->geomEntry != "") {
796         _geomEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
797         _enfVertexEntrySizeList[oldEnVertex->geomEntry] = size;
798       }
799     }
800   }
801
802 //   //////// CREATE ////////////
803   if (toCreate) {
804     toNotify = true;
805     _enfVertexList.insert(newEnfVertex);
806     if (theEntry == "") {
807       _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
808       _enfVertexCoordsSizeList[newEnfVertex->coords] = size;
809     }
810     else {
811       _geomEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
812       _enfVertexEntrySizeList[newEnfVertex->geomEntry] = size;
813     }
814   }
815
816   if (toNotify)
817     NotifySubMeshesHypothesisModification();
818
819   return toNotify;
820 }
821
822
823 //=======================================================================
824 //function : SetEnforcedMesh
825 //=======================================================================
826 bool HYBRIDPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
827 {
828   TIDSortedElemSet theElemSet;
829   SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
830   while ( eIt->more() )
831     theElemSet.insert( eIt->next() );
832   bool added = SetEnforcedElements( theElemSet, elementType, groupName);
833   if (added) {
834     THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
835     newEnfMesh->persistID   = theMesh.GetMeshDS()->GetPersistentId();
836     newEnfMesh->name        = name;
837     newEnfMesh->entry       = entry;
838     newEnfMesh->elementType = elementType;
839     newEnfMesh->groupName   = groupName;
840     
841     THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
842     if (it == _enfMeshList.end()) {
843       _entryEnfMeshMap[entry].insert(newEnfMesh);
844       _enfMeshList.insert(newEnfMesh);
845     }
846     else {
847       delete newEnfMesh;
848     }
849   }
850   return added;
851 }
852
853 //=======================================================================
854 //function : SetEnforcedGroup
855 //=======================================================================
856 bool HYBRIDPlugin_Hypothesis::SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
857 {
858   TIDSortedElemSet theElemSet;
859     if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");}
860     for ( CORBA::ULong i = 0; i < theIDs->length(); i++) {
861       CORBA::Long ind = theIDs[i];
862       if (elementType == SMESH::NODE)
863       {
864         const SMDS_MeshNode * node = theMeshDS->FindNode(ind);
865         if (node)
866           theElemSet.insert( node );
867       }
868       else
869       {
870         const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
871         if (elem)
872           theElemSet.insert( elem );
873       }
874     }
875
876 //   SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements();
877 //   while ( it->more() ) 
878 //     theElemSet.insert( it->next() );
879
880   bool added = SetEnforcedElements( theElemSet, elementType, groupName);
881   if (added) {
882     THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
883     newEnfMesh->name = name;
884     newEnfMesh->entry = entry;
885     newEnfMesh->elementType = elementType;
886     newEnfMesh->groupName = groupName;
887     
888     THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
889     if (it == _enfMeshList.end()) {
890       _entryEnfMeshMap[entry].insert(newEnfMesh);
891       _enfMeshList.insert(newEnfMesh);
892     }
893   }
894   return added;
895 }
896
897 //=======================================================================
898 //function : SetEnforcedElements
899 //=======================================================================
900 bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName)
901 {
902   TIDSortedElemSet::const_iterator it = theElemSet.begin();
903   const SMDS_MeshElement* elem;
904   const SMDS_MeshNode* node;
905   bool added = true;
906   std::pair<TIDSortedNodeGroupMap::iterator,bool> nodeRet;
907   std::pair<TIDSortedElemGroupMap::iterator,bool> elemRet;
908
909   for (;it != theElemSet.end();++it)
910   {
911     elem = (*it);
912     switch (elementType) {
913       case SMESH::NODE:
914         node = dynamic_cast<const SMDS_MeshNode*>(elem);
915         if (node) {
916           nodeRet = _enfNodes.insert(make_pair(node,groupName));
917           added = added && nodeRet.second;
918           std::string msg = added ? "yes":"no";
919         }
920         else {
921           SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
922           for (;nodeIt->more();) {
923             node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
924             nodeRet = _enfNodes.insert(make_pair(node,groupName));
925             added = added && nodeRet.second;
926           }
927 //          added = true;s
928         }
929         break;
930       case SMESH::EDGE:
931         if (elem->GetType() == SMDSAbs_Edge) {
932           elemRet = _enfEdges.insert(make_pair(elem,groupName));
933           added = added && elemRet.second;
934         }
935         break;
936       case SMESH::FACE:
937         if (elem->GetType() == SMDSAbs_Face)
938         {
939           if (elem->NbCornerNodes() == 3) {
940             elemRet = _enfTriangles.insert(make_pair(elem,groupName));
941             added = added && elemRet.second;
942           }
943         }
944         break;
945       default:
946         break;
947     };
948   }
949   if (added)
950     NotifySubMeshesHypothesisModification();
951   return added;
952 }
953
954
955 //=======================================================================
956 //function : GetEnforcedVertex
957 //=======================================================================
958
959 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* HYBRIDPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z)
960   throw (std::invalid_argument)
961 {
962   std::vector<double> coord(3);
963   coord[0] = x;
964   coord[1] = y;
965   coord[2] = z;
966   if (_coordsEnfVertexMap.count(coord)>0)
967     return _coordsEnfVertexMap[coord];
968   std::ostringstream msg ;
969   msg << "No enforced vertex at " << x << ", " << y << ", " << z;
970   throw std::invalid_argument(msg.str());
971 }
972
973 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* HYBRIDPlugin_Hypothesis::GetEnforcedVertex(const std::string theEntry)
974   throw (std::invalid_argument)
975 {
976   if (_geomEntryEnfVertexMap.count(theEntry)>0)
977     return _geomEntryEnfVertexMap[theEntry];
978   
979   std::ostringstream msg ;
980   msg << "No enforced vertex with entry " << theEntry;
981   throw std::invalid_argument(msg.str());
982 }
983
984 //=======================================================================
985 //function : RemoveEnforcedVertex
986 //=======================================================================
987
988 bool HYBRIDPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, const std::string theEntry)
989   throw (std::invalid_argument)
990 {
991   bool toNotify = false;
992   std::ostringstream msg;
993   THYBRIDEnforcedVertex *oldEnfVertex;
994   std::vector<double> coords(3);
995   coords[0] = x;
996   coords[1] = y;
997   coords[2] = z;
998   
999   // check that enf vertex with given enf vertex entry exists
1000   TGeomEntryHYBRIDEnforcedVertexMap::iterator it_enfVertexEntry = _geomEntryEnfVertexMap.find(theEntry);
1001   if (it_enfVertexEntry != _geomEntryEnfVertexMap.end()) {
1002     // Success
1003     oldEnfVertex = it_enfVertexEntry->second;
1004     _geomEntryEnfVertexMap.erase(it_enfVertexEntry);
1005   } else {
1006     // Fail
1007     // check that enf vertex with given coords exists
1008     TCoordsHYBRIDEnforcedVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
1009     if (it_coords_enf != _coordsEnfVertexMap.end()) {
1010       // Success
1011       oldEnfVertex = it_coords_enf->second;
1012       _coordsEnfVertexMap.erase(it_coords_enf);
1013       _enfVertexCoordsSizeList.erase(_enfVertexCoordsSizeList.find(coords));
1014     } else {
1015       // Fail
1016       throw std::invalid_argument(msg.str());
1017     }
1018   }
1019
1020
1021   // update _enfVertexList
1022   THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
1023   if (it != _enfVertexList.end()) {
1024     if ((*it)->groupName != "")
1025       _groupsToRemove.insert((*it)->groupName);
1026     _enfVertexList.erase(it);
1027     toNotify = true;
1028   }
1029
1030   if (toNotify)
1031     NotifySubMeshesHypothesisModification();
1032
1033   return toNotify;
1034 }
1035
1036 //=======================================================================
1037 //function : ClearEnforcedVertices
1038 //=======================================================================
1039 void HYBRIDPlugin_Hypothesis::ClearEnforcedVertices()
1040 {
1041   THYBRIDEnforcedVertexList::const_iterator it = _enfVertexList.begin();
1042   for(;it != _enfVertexList.end();++it) {
1043     if ((*it)->groupName != "")
1044       _groupsToRemove.insert((*it)->groupName);
1045   }
1046   _enfVertexList.clear();
1047   _coordsEnfVertexMap.clear();
1048   _geomEntryEnfVertexMap.clear();
1049   _enfVertexCoordsSizeList.clear();
1050   _enfVertexEntrySizeList.clear();
1051   NotifySubMeshesHypothesisModification();
1052 }
1053
1054 //=======================================================================
1055 //function : ClearEnforcedMeshes
1056 //=======================================================================
1057 void HYBRIDPlugin_Hypothesis::ClearEnforcedMeshes()
1058 {
1059   THYBRIDEnforcedMeshList::const_iterator it = _enfMeshList.begin();
1060   for(;it != _enfMeshList.end();++it) {
1061     if ((*it)->groupName != "")
1062       _groupsToRemove.insert((*it)->groupName);
1063   }
1064   _enfNodes.clear();
1065   _enfEdges.clear();
1066   _enfTriangles.clear();
1067   _nodeIDToSizeMap.clear();
1068   _enfMeshList.clear();
1069   _entryEnfMeshMap.clear();
1070   NotifySubMeshesHypothesisModification();
1071 }
1072
1073 //================================================================================
1074 /*!
1075  * \brief At mesh loading, restore enforced elements by just loaded enforced meshes
1076  */
1077 //================================================================================
1078
1079 void HYBRIDPlugin_Hypothesis::RestoreEnfElemsByMeshes()
1080 {
1081   THYBRIDEnforcedMeshList::const_iterator it = _enfMeshList.begin();
1082   for(;it != _enfMeshList.end();++it) {
1083     THYBRIDEnforcedMesh* enfMesh = *it;
1084     if ( SMESH_Mesh* mesh = GetMeshByPersistentID( enfMesh->persistID ))
1085       SetEnforcedMesh( *mesh,
1086                        enfMesh->elementType,
1087                        enfMesh->name,
1088                        enfMesh->entry,
1089                        enfMesh->groupName );
1090     enfMesh->persistID = -1; // not to restore again
1091   }
1092 }
1093
1094 //=======================================================================
1095 //function : SetGroupsToRemove
1096 //=======================================================================
1097
1098 void HYBRIDPlugin_Hypothesis::ClearGroupsToRemove()
1099 {
1100   _groupsToRemove.clear();
1101 }
1102
1103
1104 //=======================================================================
1105 //function : DefaultLayersOnAllWrap
1106 //=======================================================================
1107
1108 bool HYBRIDPlugin_Hypothesis::DefaultLayersOnAllWrap()
1109 {
1110   return true;
1111 }
1112
1113 //=======================================================================
1114 //function : DefaultMeshHoles
1115 //=======================================================================
1116
1117 bool HYBRIDPlugin_Hypothesis::DefaultMeshHoles()
1118 {
1119   return false; // PAL19680
1120 }
1121
1122 //=======================================================================
1123 //function : DefaultToMakeGroupsOfDomains
1124 //=======================================================================
1125
1126 bool HYBRIDPlugin_Hypothesis::DefaultToMakeGroupsOfDomains()
1127 {
1128   return false; // issue 0022172
1129 }
1130
1131 //=======================================================================
1132 //function : DefaultMaximumMemory
1133 //=======================================================================
1134
1135 #if defined(WIN32)
1136 #include <windows.h>
1137 #elif !defined(__APPLE__)
1138 #include <sys/sysinfo.h>
1139 #endif
1140
1141 double  HYBRIDPlugin_Hypothesis::DefaultMaximumMemory()
1142 {
1143 #if defined(WIN32)
1144   // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
1145   MEMORYSTATUSEX statex;
1146   statex.dwLength = sizeof (statex);
1147   int err = GlobalMemoryStatusEx (&statex);
1148   if (err != 0) {
1149     int totMB = 
1150       statex.ullTotalPhys / 1024 / 1024 +
1151       statex.ullTotalPageFile / 1024 / 1024 +
1152       statex.ullTotalVirtual / 1024 / 1024;
1153     return ( 0.7 * totMB );
1154   }
1155 #elif !defined(__APPLE__)
1156   struct sysinfo si;
1157   int err = sysinfo( &si );
1158   if ( err == 0 ) {
1159     int ramMB = si.totalram * si.mem_unit / 1024 / 1024;
1160     return ( 0.7 * ramMB );
1161   }
1162 #endif
1163   return 1024;
1164 }
1165
1166 //=======================================================================
1167 //function : DefaultInitialMemory
1168 //=======================================================================
1169
1170 double  HYBRIDPlugin_Hypothesis::DefaultInitialMemory()
1171 {
1172   return DefaultMaximumMemory();
1173 }
1174
1175 //=======================================================================
1176 //function : DefaultCollisionMode
1177 //=======================================================================
1178 short  HYBRIDPlugin_Hypothesis::DefaultCollisionMode()
1179 {
1180   return Decrease;
1181 }
1182
1183 //=======================================================================
1184 //function : DefaultBoundaryLayersGrowth
1185 //=======================================================================
1186 short  HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersGrowth()
1187 {
1188   return Layer_Growth_Inward;
1189 }
1190
1191 //=======================================================================
1192 //function : DefaultElementGeneration
1193 //=======================================================================
1194 short  HYBRIDPlugin_Hypothesis::DefaultElementGeneration()
1195 {
1196   return Generation_Tetra_Dominant;
1197 }
1198
1199 //=======================================================================
1200 //function : DefaultOptimizationLevel
1201 //=======================================================================
1202 short  HYBRIDPlugin_Hypothesis::DefaultOptimizationLevel()
1203 {
1204   return Medium;
1205 }
1206
1207 //=======================================================================
1208 //function : DefaultWorkingDirectory
1209 //=======================================================================
1210
1211 std::string HYBRIDPlugin_Hypothesis::DefaultWorkingDirectory()
1212 {
1213   std::string aTmpDir;
1214
1215   char *Tmp_dir = getenv("SALOME_TMP_DIR");
1216   if(Tmp_dir != NULL) {
1217     aTmpDir = Tmp_dir;
1218   }
1219   else {
1220 #ifdef WIN32
1221     aTmpDir = "C:\\";
1222 #else
1223     aTmpDir = "/tmp/";
1224 #endif
1225   }
1226   return aTmpDir;
1227 }
1228
1229 //=======================================================================
1230 //function : DefaultKeepFiles
1231 //=======================================================================
1232
1233 bool   HYBRIDPlugin_Hypothesis::DefaultKeepFiles()
1234 {
1235   return false;
1236 }
1237
1238 //=======================================================================
1239 //function : DefaultRemoveLogOnSuccess
1240 //=======================================================================
1241
1242 bool   HYBRIDPlugin_Hypothesis::DefaultRemoveLogOnSuccess()
1243 {
1244   return false;
1245 }
1246
1247
1248 //=======================================================================
1249 //function : DefaultVerboseLevel
1250 //=======================================================================
1251
1252 short  HYBRIDPlugin_Hypothesis::DefaultVerboseLevel()
1253 {
1254   return 10;
1255 }
1256
1257 //=======================================================================
1258 //function : DefaultToCreateNewNodes
1259 //=======================================================================
1260
1261 bool HYBRIDPlugin_Hypothesis::DefaultToCreateNewNodes()
1262 {
1263   return true;
1264 }
1265
1266 //=======================================================================
1267 //function : DefaultToUseBoundaryRecoveryVersion
1268 //=======================================================================
1269
1270 bool HYBRIDPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion()
1271 {
1272   return false;
1273 }
1274
1275 //=======================================================================
1276 //function : DefaultToUseFEMCorrection
1277 //=======================================================================
1278
1279 bool HYBRIDPlugin_Hypothesis::DefaultToUseFEMCorrection()
1280 {
1281   return false;
1282 }
1283
1284 //=======================================================================
1285 //function : DefaultToRemoveCentralPoint
1286 //=======================================================================
1287
1288 bool HYBRIDPlugin_Hypothesis::DefaultToRemoveCentralPoint()
1289 {
1290   return false;
1291 }
1292
1293 //=======================================================================
1294 //function : DefaultGradation
1295 //=======================================================================
1296
1297 double HYBRIDPlugin_Hypothesis::DefaultGradation()
1298 {
1299   return 1.05;
1300 }
1301
1302 //=======================================================================
1303 //function : DefaultStandardOutputLog
1304 //=======================================================================
1305
1306 bool HYBRIDPlugin_Hypothesis::DefaultStandardOutputLog()
1307 {
1308   return false;
1309 }
1310
1311 // //=======================================================================
1312 // //function : DefaultID2SizeMap
1313 // //=======================================================================
1314 // 
1315 // HYBRIDPlugin_Hypothesis::TID2SizeMap HYBRIDPlugin_Hypothesis::DefaultID2SizeMap()
1316 // {
1317 //   return HYBRIDPlugin_Hypothesis::TID2SizeMap();
1318 // }
1319
1320 //=======================================================================
1321 //function : DefaultAddMultinormals
1322 //=======================================================================
1323 bool HYBRIDPlugin_Hypothesis::DefaultAddMultinormals()
1324 {
1325   return false;
1326 }
1327
1328 //=======================================================================
1329 //function : DefaultSmoothNormals
1330 //=======================================================================
1331 bool HYBRIDPlugin_Hypothesis::DefaultSmoothNormals()
1332 {
1333   return false;
1334 }
1335
1336 //=======================================================================
1337 //function : DefaultHeightFirstLayer
1338 //=======================================================================
1339 double HYBRIDPlugin_Hypothesis::DefaultHeightFirstLayer()
1340 {
1341   return 0.0; //or epsilon?
1342 }
1343
1344 //=======================================================================
1345 //function : DefaultBoundaryLayersProgression
1346 //=======================================================================
1347 double HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersProgression()
1348 {
1349   return 1.0;
1350 }
1351
1352 //=======================================================================
1353 //function : DefaultCoreSize
1354 //=======================================================================
1355 double HYBRIDPlugin_Hypothesis::DefaultCoreSize()
1356 {
1357   return 0.0;
1358 }
1359
1360 //=======================================================================
1361 //function : DefaultMultinormalsAngle
1362 //=======================================================================
1363 double HYBRIDPlugin_Hypothesis::DefaultMultinormalsAngle()
1364 {
1365   return 30.0;
1366 }
1367
1368 //=======================================================================
1369 //function : DefaultNbOfBoundaryLayers
1370 //=======================================================================
1371 short HYBRIDPlugin_Hypothesis::DefaultNbOfBoundaryLayers()
1372 {
1373   return 1;
1374 }
1375
1376 //=======================================================================
1377 //function : SaveTo
1378 //=======================================================================
1379
1380 std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save)
1381 {
1382   save << (int) myBoundaryLayersGrowth << " ";
1383   save << (int) myElementGeneration << " ";
1384   save << (int) myAddMultinormals << " ";
1385   save << (int) mySmoothNormals << " ";
1386   save << (int) myLayersOnAllWrap << " ";
1387
1388   save << myNbOfBoundaryLayers << " ";
1389   save << myHeightFirstLayer << " ";
1390   save << myBoundaryLayersProgression << " ";
1391   save << myMultinormalsAngle << " ";
1392
1393   save << (int) myKeepFiles << " ";
1394   save << myWorkingDirectory << " ";
1395   save << myVerboseLevel << " ";
1396   save << myCoreSize << " ";
1397
1398   if (!myTextOption.empty()) {
1399     save << "__OPTIONS_BEGIN__ ";
1400     save << myTextOption << " ";
1401     save << "__OPTIONS_END__ ";
1402   }
1403
1404
1405   THYBRIDEnforcedVertexList::iterator it  = _enfVertexList.begin();
1406   if (it != _enfVertexList.end()) {
1407     save << " " << "__ENFORCED_VERTICES_BEGIN__ ";
1408     for ( ; it != _enfVertexList.end(); ++it ) {
1409       THYBRIDEnforcedVertex *enfVertex = (*it);
1410       save << " " << "__BEGIN_VERTEX__";
1411       if (!enfVertex->name.empty()) {
1412         save << " " << "__BEGIN_NAME__";
1413         save << " " << enfVertex->name;
1414         save << " " << "__END_NAME__";
1415       }
1416       if (!enfVertex->geomEntry.empty()) {
1417         save << " " << "__BEGIN_ENTRY__";
1418         save << " " << enfVertex->geomEntry;
1419         save << " " << enfVertex->isCompound;
1420         save << " " << "__END_ENTRY__";
1421       }
1422       if (!enfVertex->groupName.empty()) {
1423         save << " " << "__BEGIN_GROUP__";
1424         save << " " << enfVertex->groupName;
1425         save << " " << "__END_GROUP__";
1426       }
1427       if (enfVertex->coords.size()) {
1428         save << " " << "__BEGIN_COORDS__";
1429         for ( size_t i = 0; i < enfVertex->coords.size(); i++ )
1430           save << " " << enfVertex->coords[i];
1431         save << " " << "__END_COORDS__";
1432       }
1433       save << " " << "__BEGIN_SIZE__";
1434       save << " " << enfVertex->size;
1435       save << " " << "__END_SIZE__";
1436       save << " " << "__END_VERTEX__";
1437     }
1438     save << " " << "__ENFORCED_VERTICES_END__ ";
1439   }
1440
1441   THYBRIDEnforcedMeshList::iterator it_mesh  = _enfMeshList.begin();
1442   if (it_mesh != _enfMeshList.end()) {
1443     save << " " << "__ENFORCED_MESHES_BEGIN__ ";
1444     for ( ; it_mesh != _enfMeshList.end(); ++it_mesh ) {
1445       THYBRIDEnforcedMesh *enfMesh = (*it_mesh);
1446       save << " " << "__BEGIN_ENF_MESH__";
1447
1448       save << " " << "__BEGIN_NAME__";
1449       save << " " << enfMesh->name;
1450       save << " " << "__END_NAME__";
1451
1452       save << " " << "__BEGIN_ENTRY__";
1453       save << " " << enfMesh->entry;
1454       save << " " << "__END_ENTRY__";
1455
1456       save << " " << "__BEGIN_ELEM_TYPE__";
1457       save << " " << (int)enfMesh->elementType;
1458       save << " " << "__END_ELEM_TYPE__";
1459
1460       if (!enfMesh->groupName.empty()) {
1461         save << " " << "__BEGIN_GROUP__";
1462         save << " " << enfMesh->groupName;
1463         save << " " << "__END_GROUP__";
1464       }
1465       save << " " << "__PERSIST_ID__";
1466       save << " " << enfMesh->persistID;
1467       save << " " << "__END_ENF_MESH__";
1468       std::cout << "Saving of enforced mesh " << enfMesh->name.c_str() << " done" << std::endl;
1469     }
1470     save << " "  << "__ENFORCED_MESHES_END__ ";
1471   }
1472
1473   save << " " << myFacesWithLayers.size();
1474   for ( size_t i = 0; i < myFacesWithLayers.size(); ++i )
1475     save << " " << myFacesWithLayers[i];
1476
1477   save << " " << myFacesWithImprinting.size();
1478   for ( size_t i = 0; i < myFacesWithImprinting.size(); ++i )
1479     save << " " << myFacesWithImprinting[i];
1480
1481   save << " " << myFacesWithSnapping.size();
1482   for ( size_t i = 0; i < myFacesWithSnapping.size(); ++i )
1483     save << " " << myFacesWithSnapping[i];
1484
1485   return save;
1486 }
1487
1488 //=======================================================================
1489 //function : LoadFrom
1490 //=======================================================================
1491
1492 std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load)
1493 {
1494   bool isOK = true;
1495   int i;
1496   double d;
1497
1498   isOK = static_cast<bool>(load >> i);
1499   if (isOK)
1500     myBoundaryLayersGrowth = (short) i;
1501   else
1502     load.clear(ios::badbit | load.rdstate());
1503
1504   isOK = static_cast<bool>(load >> i);
1505   if (isOK)
1506     myElementGeneration = (short) i;
1507   else
1508     load.clear(ios::badbit | load.rdstate());
1509
1510   isOK = static_cast<bool>(load >> i);
1511   if (isOK)
1512     myAddMultinormals = (bool) i;
1513   else
1514     load.clear(ios::badbit | load.rdstate());
1515
1516   isOK = static_cast<bool>(load >> i);
1517   if (isOK)
1518     mySmoothNormals = (bool) i;
1519   else
1520     load.clear(ios::badbit | load.rdstate());
1521
1522   isOK = static_cast<bool>(load >> i);
1523   if (isOK)
1524     myLayersOnAllWrap = (bool) i;
1525   else
1526     load.clear(ios::badbit | load.rdstate());
1527
1528   isOK = static_cast<bool>(load >> i);
1529   if (isOK)
1530     myNbOfBoundaryLayers = (short) i;
1531   else
1532     load.clear(ios::badbit | load.rdstate());
1533
1534   isOK = static_cast<bool>(load >> d);
1535   if (isOK)
1536     myHeightFirstLayer = d;
1537   else
1538     load.clear(ios::badbit | load.rdstate());
1539
1540   isOK = static_cast<bool>(load >> d);
1541   if (isOK)
1542     myBoundaryLayersProgression = d;
1543   else
1544     load.clear(ios::badbit | load.rdstate());
1545
1546   isOK = static_cast<bool>(load >> d);
1547   if (isOK)
1548     myMultinormalsAngle = d;
1549   else
1550     load.clear(ios::badbit | load.rdstate());
1551
1552   isOK = static_cast<bool>(load >> i);
1553   if (isOK)
1554     myKeepFiles = (bool) i;
1555   else
1556     load.clear(ios::badbit | load.rdstate());
1557
1558   isOK = static_cast<bool>(load >> myWorkingDirectory);
1559   if (isOK) {
1560     if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
1561       myKeepFiles = false;
1562       myWorkingDirectory.clear();
1563     }
1564     else if ( myWorkingDirectory == "1" ) {
1565       myKeepFiles = true;
1566       myWorkingDirectory.clear();
1567     }
1568   }
1569   else
1570     load.clear(ios::badbit | load.rdstate());
1571
1572   isOK = static_cast<bool>(load >> i);
1573   if (isOK)
1574     myVerboseLevel = (short) i;
1575   else
1576     load.clear(ios::badbit | load.rdstate());
1577
1578   isOK = static_cast<bool>(load >> d);
1579   if (isOK)
1580     myCoreSize = d;
1581   else
1582     load.clear(ios::badbit | load.rdstate());
1583
1584   std::string separator;
1585   bool hasOptions = false;
1586   bool hasEnforcedVertices = false;
1587   bool hasEnforcedMeshes = false;
1588   isOK = static_cast<bool>(load >> separator);
1589
1590   if ( isOK && ( separator == "0" || separator == "1" ))
1591   {
1592     myToMakeGroupsOfDomains = ( separator == "1" );
1593     isOK = static_cast<bool>(load >> separator);
1594   }
1595
1596   if (isOK) {
1597     if (separator == "__OPTIONS_BEGIN__")
1598       hasOptions = true;
1599     else if (separator == "__ENFORCED_VERTICES_BEGIN__")
1600       hasEnforcedVertices = true;
1601     else if (separator == "__ENFORCED_MESHES_BEGIN__")
1602       hasEnforcedMeshes = true;
1603   }
1604
1605   if (hasOptions) {
1606     std::string txt;
1607     while (isOK) {
1608       isOK = static_cast<bool>(load >> txt);
1609       if (isOK) {
1610         if (txt == "__OPTIONS_END__") {
1611           if (!myTextOption.empty()) {
1612             // Remove last space
1613             myTextOption.erase(myTextOption.end()-1);
1614           }
1615           isOK = false;
1616           break;
1617         }
1618         myTextOption += txt;
1619         myTextOption += " ";
1620       }
1621     }
1622   }
1623
1624   if (hasOptions) {
1625     isOK = static_cast<bool>(load >> separator);
1626     if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__")
1627       hasEnforcedVertices = true;
1628     if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
1629       hasEnforcedMeshes = true;
1630   }
1631
1632   if (hasEnforcedVertices) {
1633     std::string txt, name, entry, groupName;
1634     double size, coords[3];
1635     bool isCompound;
1636     bool hasCoords = false;
1637     isOK = static_cast<bool>(load >> txt);  // __BEGIN_VERTEX__
1638     while (isOK) {
1639       if (txt == "__ENFORCED_VERTICES_END__")
1640         isOK = false;
1641
1642       THYBRIDEnforcedVertex *enfVertex = new THYBRIDEnforcedVertex();
1643       while (isOK) {
1644         isOK = static_cast<bool>(load >> txt);
1645         if (txt == "__END_VERTEX__") {
1646           enfVertex->name = name;
1647           enfVertex->geomEntry = entry;
1648           enfVertex->isCompound = isCompound;
1649           enfVertex->groupName = groupName;
1650           enfVertex->coords.clear();
1651           if (hasCoords)
1652             enfVertex->coords.assign(coords,coords+3);
1653
1654           _enfVertexList.insert(enfVertex);
1655
1656           if (enfVertex->coords.size())
1657             _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
1658           if (!enfVertex->geomEntry.empty())
1659             _geomEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
1660
1661           name.clear();
1662           entry.clear();
1663           groupName.clear();
1664           hasCoords = false;
1665           isOK = false;
1666         }
1667
1668         if (txt == "__BEGIN_NAME__") {  // __BEGIN_NAME__
1669           while (isOK && (txt != "__END_NAME__")) {
1670             isOK = static_cast<bool>(load >> txt);
1671             if (txt != "__END_NAME__") {
1672               if (!name.empty())
1673                 name += " ";
1674               name += txt;
1675             }
1676           }
1677         }
1678
1679         if (txt == "__BEGIN_ENTRY__") {  // __BEGIN_ENTRY__
1680           isOK = static_cast<bool>(load >> entry);
1681           isOK = static_cast<bool>(load >> isCompound);
1682           isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
1683           if (txt != "__END_ENTRY__")
1684             throw std::exception();
1685         }
1686
1687         if (txt == "__BEGIN_GROUP__") {  // __BEGIN_GROUP__
1688           while (isOK && (txt != "__END_GROUP__")) {
1689             isOK = static_cast<bool>(load >> txt);
1690             if (txt != "__END_GROUP__") {
1691               if (!groupName.empty())
1692                 groupName += " ";
1693               groupName += txt;
1694             }
1695           }
1696         }
1697
1698         if (txt == "__BEGIN_COORDS__") {  // __BEGIN_COORDS__
1699           hasCoords = true;
1700           isOK = static_cast<bool>(load >> coords[0] >> coords[1] >> coords[2]);
1701           isOK = static_cast<bool>(load >> txt); // __END_COORDS__
1702           if (txt != "__END_COORDS__")
1703             throw std::exception();
1704         }
1705
1706         if (txt == "__BEGIN_SIZE__") {  // __BEGIN_ENTRY__
1707           isOK = static_cast<bool>(load >> size);
1708           isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
1709           if (txt != "__END_SIZE__") {
1710             throw std::exception();
1711           }
1712         }
1713       }
1714       isOK = static_cast<bool>(load >> txt);  // __BEGIN_VERTEX__
1715     }
1716   }
1717
1718   if (hasEnforcedVertices) {
1719     isOK = static_cast<bool>(load >> separator);
1720     if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
1721       hasEnforcedMeshes = true;
1722   }
1723
1724   if (hasEnforcedMeshes) {
1725     std::string txt, name, entry, groupName;
1726     int elementType = -1, persistID = -1;
1727     isOK = static_cast<bool>(load >> txt);  // __BEGIN_ENF_MESH__
1728     while (isOK) {
1729       //                if (isOK) {
1730       if (txt == "__ENFORCED_MESHES_END__")
1731         isOK = false;
1732
1733       THYBRIDEnforcedMesh *enfMesh = new THYBRIDEnforcedMesh();
1734       while (isOK) {
1735         isOK = static_cast<bool>(load >> txt);
1736         if (txt == "__END_ENF_MESH__") {
1737           enfMesh->name = name;
1738           enfMesh->entry = entry;
1739           enfMesh->elementType = (SMESH::ElementType)elementType;
1740           enfMesh->groupName = groupName;
1741           enfMesh->persistID = persistID;
1742
1743           _enfMeshList.insert(enfMesh);
1744           std::cout << "Restoring of enforced mesh " <<name  << " done" << std::endl;
1745
1746           name.clear();
1747           entry.clear();
1748           elementType = -1;
1749           groupName.clear();
1750           persistID = -1;
1751           isOK = false;
1752         }
1753
1754         if (txt == "__BEGIN_NAME__") {  // __BEGIN_NAME__
1755           while (isOK && (txt != "__END_NAME__")) {
1756             isOK = static_cast<bool>(load >> txt);
1757             if (txt != "__END_NAME__") {
1758               if (!name.empty())
1759                 name += " ";
1760               name += txt;
1761             }
1762           }
1763         }
1764
1765         if (txt == "__BEGIN_ENTRY__") {  // __BEGIN_ENTRY__
1766           isOK = static_cast<bool>(load >> entry);
1767           isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
1768           if (txt != "__END_ENTRY__")
1769             throw std::exception();
1770         }
1771
1772         if (txt == "__BEGIN_ELEM_TYPE__") {  // __BEGIN_ELEM_TYPE__
1773           isOK = static_cast<bool>(load >> elementType);
1774           isOK = static_cast<bool>(load >> txt); // __END_ELEM_TYPE__
1775           if (txt != "__END_ELEM_TYPE__")
1776             throw std::exception();
1777         }
1778
1779         if (txt == "__BEGIN_GROUP__") {  // __BEGIN_GROUP__
1780           while (isOK && (txt != "__END_GROUP__")) {
1781             isOK = static_cast<bool>(load >> txt);
1782             if (txt != "__END_GROUP__") {
1783               if (!groupName.empty())
1784                 groupName += " ";
1785               groupName += txt;
1786             }
1787           } // while
1788         } // if
1789
1790         if (txt == "__PERSIST_ID__") {
1791           isOK = static_cast<bool>(load >> persistID);
1792         }
1793         std::cout << "isOK: " << isOK << std::endl;
1794       } // while
1795       //                } // if
1796       isOK = static_cast<bool>(load >> txt);  // __BEGIN_ENF_MESH__
1797     } // while
1798   } // if
1799
1800   if ( hasEnforcedMeshes )
1801     isOK = static_cast<bool>(load >> separator);
1802
1803   if ( isOK )
1804   {
1805     i = atoi( separator.c_str() );
1806     isOK = ( i >= 0 );
1807     if ( isOK )
1808     {
1809       myFacesWithLayers.reserve( i );
1810       while (( myFacesWithLayers.size() < myFacesWithLayers.capacity() ) &&
1811              ( isOK = static_cast<bool>(load >> i)) )
1812         myFacesWithLayers.push_back( i );
1813     }
1814   }
1815
1816   isOK = static_cast<bool>(load >> separator);
1817   if ( isOK )
1818   {
1819     i = atoi( separator.c_str() );
1820     isOK = ( i >= 0 );
1821     if ( isOK )
1822     {
1823       myFacesWithImprinting.reserve( i );
1824       while (( myFacesWithImprinting.size() < myFacesWithImprinting.capacity() ) &&
1825              ( isOK = static_cast<bool>(load >> i)) )
1826         myFacesWithImprinting.push_back( i );
1827     }
1828   }
1829
1830   isOK = static_cast<bool>(load >> separator);
1831   if ( isOK )
1832   {
1833     i = atoi( separator.c_str() );
1834     isOK = ( i >= 0 );
1835     if ( isOK )
1836     {
1837       myFacesWithSnapping.reserve( i );
1838       while (( myFacesWithSnapping.size() < myFacesWithSnapping.capacity() ) &&
1839              ( isOK = static_cast<bool>(load >> i)) )
1840         myFacesWithSnapping.push_back( i );
1841     }
1842   }
1843
1844   return load;
1845 }
1846
1847 //=======================================================================
1848 //function : SetParametersByMesh
1849 //=======================================================================
1850
1851 bool HYBRIDPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&)
1852 {
1853   return false;
1854 }
1855
1856
1857 //================================================================================
1858 /*!
1859  * \brief Sets myToMakeGroupsOfDomains depending on whether theMesh is on shape or not
1860  */
1861 //================================================================================
1862
1863 bool HYBRIDPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  dflts,
1864                                                      const SMESH_Mesh* /*theMesh*/)
1865 {
1866   myToMakeGroupsOfDomains = ( !dflts._shape || dflts._shape->IsNull() );
1867   return true;
1868 }
1869
1870 //================================================================================
1871 /*!
1872  * \brief Return command to run hybrid mesher excluding file prefix (-f)
1873  */
1874 //================================================================================
1875
1876 std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp,
1877                                                   SMESH_Mesh&                    mesh)
1878 {
1879   SMESH_Comment cmd = GetExeName();
1880   // check if any option is overridden by hyp->myTextOption
1881   bool p_h     = ( hyp && hyp->myTextOption.find("-h") != std::string::npos );
1882   bool p_v     = ( hyp && hyp->myTextOption.find("-v") != std::string::npos );
1883   bool p_i     = ( hyp && hyp->myTextOption.find("-i") != std::string::npos );
1884   bool p_o     = ( hyp && hyp->myTextOption.find("-o") != std::string::npos );
1885   bool p_mnot  = ( hyp && hyp->myTextOption.find("--max_number_of_threads ") != std::string::npos );
1886   bool p_blsi  = ( hyp && hyp->myTextOption.find("--boundary_layer_surface_tags ") != std::string::npos );
1887   bool p_blii  = ( hyp && hyp->myTextOption.find("--boundary_layer_imprint_tags ") != std::string::npos );
1888   bool p_blsd  = ( hyp && hyp->myTextOption.find("--normal_direction ") != std::string::npos );
1889   bool p_hotfl = ( hyp && hyp->myTextOption.find("--boundary_layer_global_initial_height ") != std::string::npos );
1890   bool p_nobl  = ( hyp && hyp->myTextOption.find("--number_of_boundary_layers ") != std::string::npos );
1891   bool p_blgp  = ( hyp && hyp->myTextOption.find("--boundary_layer_geometric_progression ") != std::string::npos );
1892   bool p_eg    = ( hyp && hyp->myTextOption.find("--element_generation ") != std::string::npos );
1893   bool p_cm    = ( hyp && hyp->myTextOption.find("--collision_mode ") != std::string::npos );
1894   bool p_am    = ( hyp && hyp->myTextOption.find("--add_multinormals ") != std::string::npos );
1895   bool p_cs    = ( hyp && hyp->myTextOption.find("--global_physical_size ") != std::string::npos );
1896   bool p_mat   = ( hyp && hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos );
1897   bool p_sn    = ( hyp && hyp->myTextOption.find("--smooth_normals ") != std::string::npos );
1898
1899   //missing options :
1900   //- boundary_layer_max_element_angle
1901
1902   bool nolayers = false;
1903   bool layersOnAllWrap = hyp ? hyp->myLayersOnAllWrap : DefaultLayersOnAllWrap();
1904
1905   //help mode
1906   if ( p_h ) {
1907     cmd << " --help ";
1908 #ifdef WIN32
1909     cmd << " < NUL";
1910 #endif
1911     std::cout << "!!!!! CommandToRun help only !!!! " << cmd << std::endl;
1912     return cmd;
1913   }
1914
1915   if ( !p_v && hyp )
1916     cmd << " --verbose " << hyp->myVerboseLevel;
1917
1918   if ( !p_mnot && hyp )
1919     cmd << " --max_number_of_threads " << 8; //TODO getenv NB CPU
1920
1921   //no layers?
1922   if ( !p_nobl && hyp ) {
1923     if ( hyp->myNbOfBoundaryLayers < 1 ) nolayers = true;
1924   }
1925   if ( !p_hotfl && hyp ) {
1926     if ( hyp->myHeightFirstLayer < 1e-50 ) nolayers = true;
1927   }
1928     
1929   if ( !p_blsd && hyp ) {
1930     if ( hyp->myBoundaryLayersGrowth >= 0 && hyp->myBoundaryLayersGrowth <= 1 ) {
1931       const char* value[] = { "-1" , "1" }; // -1 == inside
1932       cmd << " --normal_direction " << value[ hyp->myBoundaryLayersGrowth ];
1933     }
1934   }
1935   
1936   if ( !p_hotfl && hyp ) {
1937     cmd << " --boundary_layer_global_initial_height " << hyp->myHeightFirstLayer;
1938   }
1939   
1940   if ( !p_nobl && hyp ) {
1941     cmd << " --number_of_boundary_layers " << ( nolayers ? 0 :  hyp->myNbOfBoundaryLayers );
1942   }
1943
1944   if ( !p_blgp && hyp ) {
1945     cmd << " --boundary_layer_geometric_progression " << hyp->myBoundaryLayersProgression;
1946   }
1947
1948   if ( !nolayers && hyp )
1949   {
1950     cmd << " --boundary_layer_size_mode " << ( layersOnAllWrap ? "global" : "local" );
1951     
1952     if ( !layersOnAllWrap )
1953     {
1954       // faces with layers
1955       const std::vector<int>& faceLayersIDs = hyp->GetFacesWithLayers();
1956       if ( !faceLayersIDs.empty() )
1957         cmd << " --boundary_layer_surface_tags ";
1958       for ( size_t i = 0; i < faceLayersIDs.size(); ++i )
1959         cmd << faceLayersIDs[i] << ",";
1960       if ( !faceLayersIDs.empty() )
1961         cmd << " --boundary_layer_initial_height_on_surface_tags ";
1962       for ( size_t i = 0; i < faceLayersIDs.size(); ++i )
1963         cmd << hyp->myHeightFirstLayer << ",";
1964
1965       // faces with imprinting
1966       const std::vector<int>& faceImprintingIDs = hyp->GetFacesWithImprinting();
1967       if ( !faceImprintingIDs.empty() )
1968         cmd << " --boundary_layer_imprinting yes --boundary_layer_imprinting_tags ";
1969       for ( size_t i = 0; i < faceImprintingIDs.size(); ++i )
1970         cmd << faceImprintingIDs[i] << ",";
1971
1972       // faces with snapping
1973       const std::vector<int>& faceSnappingIDs = hyp->GetFacesWithSnapping();
1974       if ( !faceSnappingIDs.empty() )
1975         cmd << " --boundary_layer_snapping yes --boundary_layer_snapping_tags ";
1976       for ( size_t i = 0; i < faceSnappingIDs.size(); ++i )
1977         cmd << faceSnappingIDs[i] << ",";
1978     }
1979   }
1980
1981   if ( !p_eg && hyp ) {
1982     if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 2 ) {
1983       const char* value[] = { "tetra-dominant" , "hexa-dominant", "cartesian_core" };
1984       cmd << " --element_generation " << value[ hyp->myElementGeneration ];
1985     }
1986   }
1987
1988   if ( !p_cs && hyp ) {
1989     if ( hyp->myCoreSize >= 0 ) {
1990       cmd << " --global_physical_size " << hyp->myCoreSize;
1991     }
1992   }
1993
1994   if ( !p_cm && hyp ) {
1995     if ( hyp->myCollisionMode >= 0 && hyp->myCollisionMode <= 1 ) {
1996       const char* value[] = { "decrease" , "stop" };
1997       cmd << " --collision_mode " << value[ hyp->myCollisionMode ];
1998     }
1999   }
2000   
2001   if ( !p_am && hyp ) {
2002     int res = hyp->myAddMultinormals ? 0 : 1 ;
2003     const char* value[] = { "yes" , "no" };
2004     cmd << " --add_multinormals " << value[ res ];
2005   }
2006   
2007   if ( !p_mat && hyp ) {
2008     cmd << " --multinormal_angle_threshold " << hyp->myMultinormalsAngle;
2009   }
2010   
2011   if ( !p_sn && hyp ) {
2012     int res = hyp->mySmoothNormals ? 0 : 1 ;
2013     const char* value[] = { "yes" , "no" };
2014     cmd << " --smooth_normals " << value[ res ];
2015   }
2016
2017   // options as text
2018   if ( hyp && !hyp->myTextOption.empty() ) {
2019     cmd += " " + hyp->myTextOption;
2020   }
2021 #ifdef WIN32
2022   cmd << " < NUL";
2023 #endif
2024   //std::cout << "!!!!!CommandToRun end " << cmd << std::endl;
2025     
2026   return cmd;
2027 }
2028
2029 //================================================================================
2030 /*!
2031  * \brief Return a unique file name
2032  */
2033 //================================================================================
2034
2035 std::string HYBRIDPlugin_Hypothesis::GetFileName(const HYBRIDPlugin_Hypothesis* hyp)
2036 {
2037   std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory();
2038   const char lastChar = *aTmpDir.rbegin();
2039 #ifdef WIN32
2040   if(lastChar != '\\') aTmpDir+='\\';
2041 #else
2042   if(lastChar != '/') aTmpDir+='/';
2043 #endif
2044
2045   SMESH_Comment aGenericName = aTmpDir;
2046   aGenericName << "HYBRID_";
2047   aGenericName << getpid();
2048   aGenericName << "_";
2049   aGenericName << Abs((Standard_Integer)(long) aGenericName.c_str());
2050
2051   return aGenericName;
2052 }
2053
2054 //================================================================================
2055 /*
2056  * Return the name of executable
2057  */
2058 //================================================================================
2059
2060 std::string HYBRIDPlugin_Hypothesis::GetExeName()
2061 {
2062   //call mg-hybrid.bash is script which assumes new project version(s) mg-hybrid.exe in the prerequisite base and special? licence.
2063 #ifdef WIN32
2064   return "mg-hybrid.exe";
2065 #else
2066   return "mg-hybrid.bash";
2067 #endif
2068 }
2069
2070 //================================================================================
2071 /*!
2072 * \brief Return the enforced vertices
2073 */
2074 //================================================================================
2075
2076 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList HYBRIDPlugin_Hypothesis::GetEnforcedVertices(const HYBRIDPlugin_Hypothesis* hyp)
2077 {
2078   return hyp ? hyp->_GetEnforcedVertices():DefaultHYBRIDEnforcedVertexList();
2079 }
2080
2081 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues HYBRIDPlugin_Hypothesis::GetEnforcedVerticesCoordsSize (const HYBRIDPlugin_Hypothesis* hyp)
2082 {  
2083   return hyp ? hyp->_GetEnforcedVerticesCoordsSize(): DefaultHYBRIDEnforcedVertexCoordsValues();
2084 }
2085
2086 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexEntryValues HYBRIDPlugin_Hypothesis::GetEnforcedVerticesEntrySize (const HYBRIDPlugin_Hypothesis* hyp)
2087 {  
2088   return hyp ? hyp->_GetEnforcedVerticesEntrySize(): DefaultHYBRIDEnforcedVertexEntryValues();
2089 }
2090
2091 HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap HYBRIDPlugin_Hypothesis::GetEnforcedVerticesByCoords (const HYBRIDPlugin_Hypothesis* hyp)
2092 {  
2093   return hyp ? hyp->_GetEnforcedVerticesByCoords(): DefaultCoordsHYBRIDEnforcedVertexMap();
2094 }
2095
2096 HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap HYBRIDPlugin_Hypothesis::GetEnforcedVerticesByEntry (const HYBRIDPlugin_Hypothesis* hyp)
2097 {  
2098   return hyp ? hyp->_GetEnforcedVerticesByEntry(): DefaultGeomEntryHYBRIDEnforcedVertexMap();
2099 }
2100
2101 HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedNodes(const HYBRIDPlugin_Hypothesis* hyp)
2102 {
2103   return hyp ? hyp->_GetEnforcedNodes():DefaultIDSortedNodeGroupMap();
2104 }
2105
2106 HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedEdges(const HYBRIDPlugin_Hypothesis* hyp)
2107 {
2108   return hyp ? hyp->_GetEnforcedEdges():DefaultIDSortedElemGroupMap();
2109 }
2110
2111 HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedTriangles(const HYBRIDPlugin_Hypothesis* hyp)
2112 {
2113   return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemGroupMap();
2114 }
2115
2116 HYBRIDPlugin_Hypothesis::TID2SizeMap HYBRIDPlugin_Hypothesis::GetNodeIDToSizeMap(const HYBRIDPlugin_Hypothesis* hyp)
2117 {
2118   return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap();
2119 }
2120
2121 HYBRIDPlugin_Hypothesis::TSetStrings HYBRIDPlugin_Hypothesis::GetGroupsToRemove(const HYBRIDPlugin_Hypothesis* hyp)
2122 {
2123   return hyp ? hyp->_GetGroupsToRemove(): DefaultGroupsToRemove();
2124 }