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