1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //=============================================================================
21 // File : HYBRIDPlugin_Hypothesis.cxx
22 // Created : Wed Apr 2 12:36:29 2008
23 // Author : Edward AGAPOV (eap)
24 //=============================================================================
26 #include "HYBRIDPlugin_Hypothesis.hxx"
28 #include <SMESHDS_Mesh.hxx>
30 #include <TopExp_Explorer.hxx>
34 #define getpid _getpid
37 //=======================================================================
38 //function : HYBRIDPlugin_Hypothesis
39 //=======================================================================
41 HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
42 : SMESH_Hypothesis(hypId, studyId, gen),
43 myToMeshHoles(DefaultMeshHoles()),
44 myLayersOnAllWrap(DefaultLayersOnAllWrap()),
45 myToMakeGroupsOfDomains(DefaultToMakeGroupsOfDomains()),
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())
81 _name = "HYBRID_Parameters";
85 //=======================================================================
86 //function : SetLayersOnAllWrap
87 //=======================================================================
89 void HYBRIDPlugin_Hypothesis::SetLayersOnAllWrap(bool toMesh)
91 if ( myLayersOnAllWrap != toMesh ) {
92 myLayersOnAllWrap = toMesh;
93 NotifySubMeshesHypothesisModification();
97 //=======================================================================
98 //function : GetLayersOnAllWrap
99 //=======================================================================
101 bool HYBRIDPlugin_Hypothesis::GetLayersOnAllWrap(bool checkFreeOption) const
103 return myLayersOnAllWrap;
106 //=======================================================================
107 //function : SetFacesWithLayers
108 //purpose : Set IDs of faces to grow the layers on
109 //=======================================================================
111 bool HYBRIDPlugin_Hypothesis::SetFacesWithLayers(const std::vector<int>& theVal)
113 if ( myFacesWithLayers != theVal )
115 myFacesWithLayers = theVal;
116 NotifySubMeshesHypothesisModification();
122 //=======================================================================
123 //function : GetFacesWithLayers
124 //purpose : Return IDs of faces to grow the layers on
125 //=======================================================================
127 const std::vector<int>& HYBRIDPlugin_Hypothesis::GetFacesWithLayers() const
129 return myFacesWithLayers;
132 //=======================================================================
133 //function : SetToMeshHoles
134 //=======================================================================
136 void HYBRIDPlugin_Hypothesis::SetToMeshHoles(bool toMesh)
138 if ( myToMeshHoles != toMesh ) {
139 myToMeshHoles = toMesh;
140 NotifySubMeshesHypothesisModification();
144 //=======================================================================
145 //function : GetToMeshHoles
146 //=======================================================================
148 bool HYBRIDPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const
150 if (checkFreeOption && !myTextOption.empty()) {
151 if ( myTextOption.find("-c 0"))
153 if ( myTextOption.find("-c 1"))
156 return myToMeshHoles;
159 //=======================================================================
160 //function : SetToMakeGroupsOfDomains
161 //=======================================================================
163 void HYBRIDPlugin_Hypothesis::SetToMakeGroupsOfDomains(bool toMakeGroups)
165 if ( myToMakeGroupsOfDomains != toMakeGroups ) {
166 myToMakeGroupsOfDomains = toMakeGroups;
167 NotifySubMeshesHypothesisModification();
171 //=======================================================================
172 //function : GetToMakeGroupsOfDomains
173 //=======================================================================
175 bool HYBRIDPlugin_Hypothesis::GetToMakeGroupsOfDomains() const
177 return myToMakeGroupsOfDomains;
180 //=======================================================================
181 //function : GetToMakeGroupsOfDomains
182 //=======================================================================
184 bool HYBRIDPlugin_Hypothesis::GetToMakeGroupsOfDomains(const HYBRIDPlugin_Hypothesis* hyp)
187 if ( hyp ) res = /*hyp->GetToMeshHoles(true) &&*/ hyp->GetToMakeGroupsOfDomains();
188 else res = /*DefaultMeshHoles() &&*/ DefaultToMakeGroupsOfDomains();
192 //=======================================================================
193 //function : SetMaximumMemory
194 //=======================================================================
196 void HYBRIDPlugin_Hypothesis::SetMaximumMemory(double MB)
198 if ( myMaximumMemory != MB ) {
199 myMaximumMemory = MB;
200 NotifySubMeshesHypothesisModification();
204 //=======================================================================
205 //function : GetMaximumMemory
206 // * automatic memory adjustment mode. Default is zero
207 //=======================================================================
209 double HYBRIDPlugin_Hypothesis::GetMaximumMemory() const
211 return myMaximumMemory;
214 //=======================================================================
215 //function : SetInitialMemory
216 //=======================================================================
218 void HYBRIDPlugin_Hypothesis::SetInitialMemory(double MB)
220 if ( myInitialMemory != MB ) {
221 myInitialMemory = MB;
222 NotifySubMeshesHypothesisModification();
226 //=======================================================================
227 //function : GetInitialMemory
228 //=======================================================================
230 double HYBRIDPlugin_Hypothesis::GetInitialMemory() const
232 return myInitialMemory;
235 //=======================================================================
236 //function : SetOptimizationLevel
237 //=======================================================================
239 void HYBRIDPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level)
241 if ( myOptimizationLevel != level ) {
242 myOptimizationLevel = level;
243 NotifySubMeshesHypothesisModification();
247 //=======================================================================
248 //function : GetOptimizationLevel
249 //=======================================================================
250 HYBRIDPlugin_Hypothesis::OptimizationLevel HYBRIDPlugin_Hypothesis::GetOptimizationLevel() const
252 return (OptimizationLevel) myOptimizationLevel;
255 //=======================================================================
256 //function : SetCollisionMode
257 //=======================================================================
258 void HYBRIDPlugin_Hypothesis::SetCollisionMode(CollisionMode mode)
260 if ( myCollisionMode != mode ) {
261 myCollisionMode = mode;
262 NotifySubMeshesHypothesisModification();
266 //=======================================================================
267 //function : GetCollisionMode
268 //=======================================================================
269 HYBRIDPlugin_Hypothesis::CollisionMode HYBRIDPlugin_Hypothesis::GetCollisionMode() const
271 return (CollisionMode) myCollisionMode;
274 //=======================================================================
275 //function : SetBoundaryLayersGrowth
276 //=======================================================================
277 void HYBRIDPlugin_Hypothesis::SetBoundaryLayersGrowth(BoundaryLayersGrowth mode)
279 if ( myBoundaryLayersGrowth != mode ) {
280 myBoundaryLayersGrowth = mode;
281 NotifySubMeshesHypothesisModification();
285 //=======================================================================
286 //function : GetBoundaryLayersGrowth
287 //=======================================================================
288 HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth HYBRIDPlugin_Hypothesis::GetBoundaryLayersGrowth() const
290 return (BoundaryLayersGrowth) myBoundaryLayersGrowth;
293 //=======================================================================
294 //function : SetElementGeneration
295 //=======================================================================
296 void HYBRIDPlugin_Hypothesis::SetElementGeneration(ElementGeneration mode)
298 if ( myElementGeneration != mode ) {
299 myElementGeneration = mode;
300 NotifySubMeshesHypothesisModification();
304 //=======================================================================
305 //function : GetElementGeneration
306 //=======================================================================
307 HYBRIDPlugin_Hypothesis::ElementGeneration HYBRIDPlugin_Hypothesis::GetElementGeneration() const
309 return (ElementGeneration) myElementGeneration;
312 //=======================================================================
313 //function : SetAddMultinormals
314 //=======================================================================
315 void HYBRIDPlugin_Hypothesis::SetAddMultinormals(bool toAddMultinormals)
317 if ( myAddMultinormals != toAddMultinormals ) {
318 myAddMultinormals = toAddMultinormals;
319 NotifySubMeshesHypothesisModification();
323 //=======================================================================
324 //function : GetAddMultinormals
325 //=======================================================================
327 bool HYBRIDPlugin_Hypothesis::GetAddMultinormals() const
329 return myAddMultinormals;
332 //=======================================================================
333 //function : SetSmoothNormals
334 //=======================================================================
336 void HYBRIDPlugin_Hypothesis::SetSmoothNormals(bool toSmoothNormals)
338 if ( mySmoothNormals != toSmoothNormals ) {
339 mySmoothNormals = toSmoothNormals;
340 NotifySubMeshesHypothesisModification();
344 //=======================================================================
345 //function : GetSmoothNormals
346 //=======================================================================
348 bool HYBRIDPlugin_Hypothesis::GetSmoothNormals() const
350 return mySmoothNormals;
353 //=======================================================================
354 //function : SetHeightFirstLayer
355 //=======================================================================
357 void HYBRIDPlugin_Hypothesis::SetHeightFirstLayer(double toHeightFirstLayer)
359 if ( myHeightFirstLayer != toHeightFirstLayer ) {
360 myHeightFirstLayer = toHeightFirstLayer;
361 NotifySubMeshesHypothesisModification();
365 //=======================================================================
366 //function : GetHeightFirstLayer
367 //=======================================================================
369 double HYBRIDPlugin_Hypothesis::GetHeightFirstLayer() const
371 return myHeightFirstLayer;
374 //=======================================================================
375 //function : SetBoundaryLayersProgression
376 //=======================================================================
378 void HYBRIDPlugin_Hypothesis::SetBoundaryLayersProgression(double toBoundaryLayersProgression)
380 if ( myBoundaryLayersProgression != toBoundaryLayersProgression ) {
381 myBoundaryLayersProgression = toBoundaryLayersProgression;
382 NotifySubMeshesHypothesisModification();
386 //=======================================================================
387 //function : GetBoundaryLayersProgression
388 //=======================================================================
390 double HYBRIDPlugin_Hypothesis::GetBoundaryLayersProgression() const
392 return myBoundaryLayersProgression;
395 //=======================================================================
396 //function : SetCoreSize
397 //=======================================================================
399 void HYBRIDPlugin_Hypothesis::SetCoreSize(double toCoreSize)
401 if ( myCoreSize != toCoreSize ) {
402 myCoreSize = toCoreSize;
403 NotifySubMeshesHypothesisModification();
407 //=======================================================================
408 //function : GetCoreSize
409 //=======================================================================
411 double HYBRIDPlugin_Hypothesis::GetCoreSize() const
416 //=======================================================================
417 //function : SetMultinormalsAngle
418 //=======================================================================
420 void HYBRIDPlugin_Hypothesis::SetMultinormalsAngle(double toMultinormalsAngle)
422 if ( myMultinormalsAngle != toMultinormalsAngle ) {
423 myMultinormalsAngle = toMultinormalsAngle;
424 NotifySubMeshesHypothesisModification();
428 //=======================================================================
429 //function : GetMultinormalsAngle
430 //=======================================================================
432 double HYBRIDPlugin_Hypothesis::GetMultinormalsAngle() const
434 return myMultinormalsAngle;
437 //=======================================================================
438 //function : SetNbOfBoundaryLayers
439 //=======================================================================
441 void HYBRIDPlugin_Hypothesis::SetNbOfBoundaryLayers(short toNbOfBoundaryLayers)
443 if ( myNbOfBoundaryLayers != toNbOfBoundaryLayers ) {
444 myNbOfBoundaryLayers = toNbOfBoundaryLayers;
445 NotifySubMeshesHypothesisModification();
449 //=======================================================================
450 //function : GetCoreSize
451 //=======================================================================
453 short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const
455 return myNbOfBoundaryLayers;
459 /////////////////////////////////////////////////////////////////////////
462 //=======================================================================
463 //function : SetWorkingDirectory
464 //=======================================================================
466 void HYBRIDPlugin_Hypothesis::SetWorkingDirectory(const std::string& path)
468 if ( myWorkingDirectory != path ) {
469 myWorkingDirectory = path;
470 NotifySubMeshesHypothesisModification();
474 //=======================================================================
475 //function : GetWorkingDirectory
476 //=======================================================================
478 std::string HYBRIDPlugin_Hypothesis::GetWorkingDirectory() const
480 return myWorkingDirectory;
483 //=======================================================================
484 //function : SetKeepFiles
485 //=======================================================================
487 void HYBRIDPlugin_Hypothesis::SetKeepFiles(bool toKeep)
489 if ( myKeepFiles != toKeep ) {
490 myKeepFiles = toKeep;
491 NotifySubMeshesHypothesisModification();
495 //=======================================================================
496 //function : GetKeepFiles
497 //=======================================================================
499 bool HYBRIDPlugin_Hypothesis::GetKeepFiles() const
504 //=======================================================================
505 //function : SetVerboseLevel
506 //=======================================================================
508 void HYBRIDPlugin_Hypothesis::SetVerboseLevel(short level)
510 if ( myVerboseLevel != level ) {
511 myVerboseLevel = level;
512 NotifySubMeshesHypothesisModification();
516 //=======================================================================
517 //function : GetVerboseLevel
518 //=======================================================================
520 short HYBRIDPlugin_Hypothesis::GetVerboseLevel() const
522 return myVerboseLevel;
525 //=======================================================================
526 //function : SetToCreateNewNodes
527 //=======================================================================
529 void HYBRIDPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate)
531 if ( myToCreateNewNodes != toCreate ) {
532 myToCreateNewNodes = toCreate;
533 NotifySubMeshesHypothesisModification();
537 //=======================================================================
538 //function : GetToCreateNewNodes
539 //=======================================================================
541 bool HYBRIDPlugin_Hypothesis::GetToCreateNewNodes() const
543 return myToCreateNewNodes;
546 //=======================================================================
547 //function : SetToUseBoundaryRecoveryVersion
548 //=======================================================================
550 void HYBRIDPlugin_Hypothesis::SetToUseBoundaryRecoveryVersion(bool toUse)
552 if ( myToUseBoundaryRecoveryVersion != toUse ) {
553 myToUseBoundaryRecoveryVersion = toUse;
554 NotifySubMeshesHypothesisModification();
558 //=======================================================================
559 //function : GetToUseBoundaryRecoveryVersion
560 //=======================================================================
562 bool HYBRIDPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const
564 return myToUseBoundaryRecoveryVersion;
567 //=======================================================================
568 //function : SetFEMCorrection
569 //=======================================================================
571 void HYBRIDPlugin_Hypothesis::SetFEMCorrection(bool toUseFem)
573 if ( myToUseFemCorrection != toUseFem ) {
574 myToUseFemCorrection = toUseFem;
575 NotifySubMeshesHypothesisModification();
579 //=======================================================================
580 //function : GetFEMCorrection
581 //=======================================================================
583 bool HYBRIDPlugin_Hypothesis::GetFEMCorrection() const
585 return myToUseFemCorrection;
588 //=======================================================================
589 //function : SetToRemoveCentralPoint
590 //=======================================================================
592 void HYBRIDPlugin_Hypothesis::SetToRemoveCentralPoint(bool toRemove)
594 if ( myToRemoveCentralPoint != toRemove ) {
595 myToRemoveCentralPoint = toRemove;
596 NotifySubMeshesHypothesisModification();
600 //=======================================================================
601 //function : GetToRemoveCentralPoint
602 //=======================================================================
604 bool HYBRIDPlugin_Hypothesis::GetToRemoveCentralPoint() const
606 return myToRemoveCentralPoint;
609 //=======================================================================
610 //function : SetAdvancedOption
611 //=======================================================================
613 void HYBRIDPlugin_Hypothesis::SetAdvancedOption(const std::string& option)
615 if ( myTextOption != option ) {
616 myTextOption = option;
617 NotifySubMeshesHypothesisModification();
621 //=======================================================================
622 //function : GetAdvancedOption
623 //=======================================================================
625 std::string HYBRIDPlugin_Hypothesis::GetAdvancedOption() const
630 //=======================================================================
631 //function : SetGradation
632 //=======================================================================
634 void HYBRIDPlugin_Hypothesis::SetGradation(double gradation)
636 if ( myGradation != gradation ) {
637 myGradation = gradation;
638 NotifySubMeshesHypothesisModification();
642 //=======================================================================
643 //function : GetGradation
644 //=======================================================================
646 double HYBRIDPlugin_Hypothesis::GetGradation() const
651 //=======================================================================
652 //function : SetStandardOutputLog
653 //=======================================================================
655 void HYBRIDPlugin_Hypothesis::SetStandardOutputLog(bool logInStandardOutput)
657 if ( myLogInStandardOutput != logInStandardOutput ) {
658 myLogInStandardOutput = logInStandardOutput;
659 NotifySubMeshesHypothesisModification();
663 //=======================================================================
664 //function : GetStandardOutputLog
665 //=======================================================================
667 bool HYBRIDPlugin_Hypothesis::GetStandardOutputLog() const
669 return myLogInStandardOutput;
672 //=======================================================================
673 //function : SetRemoveLogOnSuccess
674 //=======================================================================
676 void HYBRIDPlugin_Hypothesis::SetRemoveLogOnSuccess(bool removeLogOnSuccess)
678 if ( myRemoveLogOnSuccess != removeLogOnSuccess ) {
679 myRemoveLogOnSuccess = removeLogOnSuccess;
680 NotifySubMeshesHypothesisModification();
684 //=======================================================================
685 //function : GetRemoveLogOnSuccess
686 //=======================================================================
688 bool HYBRIDPlugin_Hypothesis::GetRemoveLogOnSuccess() const
690 return myRemoveLogOnSuccess;
693 //=======================================================================
694 //function : SetEnforcedVertex
695 //=======================================================================
697 bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string theEntry, std::string theGroupName,
698 double size, double x, double y, double z, bool isCompound)
700 bool toNotify = false;
701 bool toCreate = true;
703 THYBRIDEnforcedVertex *oldEnVertex;
704 THYBRIDEnforcedVertex *newEnfVertex = new THYBRIDEnforcedVertex();
705 newEnfVertex->name = theName;
706 newEnfVertex->geomEntry = theEntry;
707 newEnfVertex->coords.clear();
709 newEnfVertex->coords.push_back(x);
710 newEnfVertex->coords.push_back(y);
711 newEnfVertex->coords.push_back(z);
713 newEnfVertex->groupName = theGroupName;
714 newEnfVertex->size = size;
715 newEnfVertex->isCompound = isCompound;
718 // update _enfVertexList
719 THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(newEnfVertex);
720 if (it != _enfVertexList.end()) {
723 if (oldEnVertex->name != theName) {
724 oldEnVertex->name = theName;
727 if (oldEnVertex->groupName != theGroupName) {
728 oldEnVertex->groupName = theGroupName;
731 if (oldEnVertex->size != size) {
732 oldEnVertex->size = size;
736 // update map coords / enf vertex if needed
737 if (oldEnVertex->coords.size()) {
738 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
739 _enfVertexCoordsSizeList[oldEnVertex->coords] = size;
742 // update map geom entry / enf vertex if needed
743 if (oldEnVertex->geomEntry != "") {
744 _geomEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
745 _enfVertexEntrySizeList[oldEnVertex->geomEntry] = size;
750 // //////// CREATE ////////////
753 _enfVertexList.insert(newEnfVertex);
754 if (theEntry == "") {
755 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
756 _enfVertexCoordsSizeList[newEnfVertex->coords] = size;
759 _geomEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
760 _enfVertexEntrySizeList[newEnfVertex->geomEntry] = size;
765 NotifySubMeshesHypothesisModification();
771 //=======================================================================
772 //function : SetEnforcedMesh
773 //=======================================================================
774 bool HYBRIDPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
776 TIDSortedElemSet theElemSet;
777 SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
778 while ( eIt->more() )
779 theElemSet.insert( eIt->next() );
780 bool added = SetEnforcedElements( theElemSet, elementType, groupName);
782 THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
783 newEnfMesh->persistID = theMesh.GetMeshDS()->GetPersistentId();
784 newEnfMesh->name = name;
785 newEnfMesh->entry = entry;
786 newEnfMesh->elementType = elementType;
787 newEnfMesh->groupName = groupName;
789 THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
790 if (it == _enfMeshList.end()) {
791 _entryEnfMeshMap[entry].insert(newEnfMesh);
792 _enfMeshList.insert(newEnfMesh);
801 //=======================================================================
802 //function : SetEnforcedGroup
803 //=======================================================================
804 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)
806 TIDSortedElemSet theElemSet;
807 if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");}
808 for ( CORBA::ULong i = 0; i < theIDs->length(); i++) {
809 CORBA::Long ind = theIDs[i];
810 if (elementType == SMESH::NODE)
812 const SMDS_MeshNode * node = theMeshDS->FindNode(ind);
814 theElemSet.insert( node );
818 const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
820 theElemSet.insert( elem );
824 // SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements();
825 // while ( it->more() )
826 // theElemSet.insert( it->next() );
828 bool added = SetEnforcedElements( theElemSet, elementType, groupName);
830 THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
831 newEnfMesh->name = name;
832 newEnfMesh->entry = entry;
833 newEnfMesh->elementType = elementType;
834 newEnfMesh->groupName = groupName;
836 THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
837 if (it == _enfMeshList.end()) {
838 _entryEnfMeshMap[entry].insert(newEnfMesh);
839 _enfMeshList.insert(newEnfMesh);
845 //=======================================================================
846 //function : SetEnforcedElements
847 //=======================================================================
848 bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName)
850 TIDSortedElemSet::const_iterator it = theElemSet.begin();
851 const SMDS_MeshElement* elem;
852 const SMDS_MeshNode* node;
854 std::pair<TIDSortedNodeGroupMap::iterator,bool> nodeRet;
855 std::pair<TIDSortedElemGroupMap::iterator,bool> elemRet;
857 for (;it != theElemSet.end();++it)
860 switch (elementType) {
862 node = dynamic_cast<const SMDS_MeshNode*>(elem);
864 nodeRet = _enfNodes.insert(make_pair(node,groupName));
865 added = added && nodeRet.second;
866 std::string msg = added ? "yes":"no";
869 SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
870 for (;nodeIt->more();) {
871 node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
872 nodeRet = _enfNodes.insert(make_pair(node,groupName));
873 added = added && nodeRet.second;
879 if (elem->GetType() == SMDSAbs_Edge) {
880 elemRet = _enfEdges.insert(make_pair(elem,groupName));
881 added = added && elemRet.second;
883 else if (elem->GetType() > SMDSAbs_Edge) {
884 SMDS_ElemIteratorPtr it = elem->edgesIterator();
886 const SMDS_MeshElement* anEdge = it->next();
887 elemRet = _enfEdges.insert(make_pair(anEdge,groupName));
888 added = added && elemRet.second;
893 if (elem->GetType() == SMDSAbs_Face)
895 if (elem->NbCornerNodes() == 3) {
896 elemRet = _enfTriangles.insert(make_pair(elem,groupName));
897 added = added && elemRet.second;
900 else if (elem->GetType() > SMDSAbs_Face) { // Group of faces
901 SMDS_ElemIteratorPtr it = elem->facesIterator();
903 const SMDS_MeshElement* aFace = it->next();
904 if (aFace->NbCornerNodes() == 3) {
905 elemRet = _enfTriangles.insert(make_pair(aFace,groupName));
906 added = added && elemRet.second;
916 NotifySubMeshesHypothesisModification();
921 //=======================================================================
922 //function : GetEnforcedVertex
923 //=======================================================================
925 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* HYBRIDPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z)
926 throw (std::invalid_argument)
928 std::vector<double> coord(3);
932 if (_coordsEnfVertexMap.count(coord)>0)
933 return _coordsEnfVertexMap[coord];
934 std::ostringstream msg ;
935 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
936 throw std::invalid_argument(msg.str());
939 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* HYBRIDPlugin_Hypothesis::GetEnforcedVertex(const std::string theEntry)
940 throw (std::invalid_argument)
942 if (_geomEntryEnfVertexMap.count(theEntry)>0)
943 return _geomEntryEnfVertexMap[theEntry];
945 std::ostringstream msg ;
946 msg << "No enforced vertex with entry " << theEntry;
947 throw std::invalid_argument(msg.str());
950 //=======================================================================
951 //function : RemoveEnforcedVertex
952 //=======================================================================
954 bool HYBRIDPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, const std::string theEntry)
955 throw (std::invalid_argument)
957 bool toNotify = false;
958 std::ostringstream msg;
959 THYBRIDEnforcedVertex *oldEnfVertex;
960 std::vector<double> coords(3);
965 // check that enf vertex with given enf vertex entry exists
966 TGeomEntryHYBRIDEnforcedVertexMap::iterator it_enfVertexEntry = _geomEntryEnfVertexMap.find(theEntry);
967 if (it_enfVertexEntry != _geomEntryEnfVertexMap.end()) {
969 oldEnfVertex = it_enfVertexEntry->second;
970 _geomEntryEnfVertexMap.erase(it_enfVertexEntry);
973 // check that enf vertex with given coords exists
974 TCoordsHYBRIDEnforcedVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
975 if (it_coords_enf != _coordsEnfVertexMap.end()) {
977 oldEnfVertex = it_coords_enf->second;
978 _coordsEnfVertexMap.erase(it_coords_enf);
979 _enfVertexCoordsSizeList.erase(_enfVertexCoordsSizeList.find(coords));
982 throw std::invalid_argument(msg.str());
987 // update _enfVertexList
988 THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
989 if (it != _enfVertexList.end()) {
990 if ((*it)->groupName != "")
991 _groupsToRemove.insert((*it)->groupName);
992 _enfVertexList.erase(it);
997 NotifySubMeshesHypothesisModification();
1002 //=======================================================================
1003 //function : ClearEnforcedVertices
1004 //=======================================================================
1005 void HYBRIDPlugin_Hypothesis::ClearEnforcedVertices()
1007 THYBRIDEnforcedVertexList::const_iterator it = _enfVertexList.begin();
1008 for(;it != _enfVertexList.end();++it) {
1009 if ((*it)->groupName != "")
1010 _groupsToRemove.insert((*it)->groupName);
1012 _enfVertexList.clear();
1013 _coordsEnfVertexMap.clear();
1014 _geomEntryEnfVertexMap.clear();
1015 _enfVertexCoordsSizeList.clear();
1016 _enfVertexEntrySizeList.clear();
1017 NotifySubMeshesHypothesisModification();
1020 //=======================================================================
1021 //function : ClearEnforcedMeshes
1022 //=======================================================================
1023 void HYBRIDPlugin_Hypothesis::ClearEnforcedMeshes()
1025 THYBRIDEnforcedMeshList::const_iterator it = _enfMeshList.begin();
1026 for(;it != _enfMeshList.end();++it) {
1027 if ((*it)->groupName != "")
1028 _groupsToRemove.insert((*it)->groupName);
1032 _enfTriangles.clear();
1033 _nodeIDToSizeMap.clear();
1034 _enfMeshList.clear();
1035 _entryEnfMeshMap.clear();
1036 NotifySubMeshesHypothesisModification();
1039 //================================================================================
1041 * \brief At mesh loading, restore enforced elements by just loaded enforced meshes
1043 //================================================================================
1045 void HYBRIDPlugin_Hypothesis::RestoreEnfElemsByMeshes()
1047 THYBRIDEnforcedMeshList::const_iterator it = _enfMeshList.begin();
1048 for(;it != _enfMeshList.end();++it) {
1049 THYBRIDEnforcedMesh* enfMesh = *it;
1050 if ( SMESH_Mesh* mesh = GetMeshByPersistentID( enfMesh->persistID ))
1051 SetEnforcedMesh( *mesh,
1052 enfMesh->elementType,
1055 enfMesh->groupName );
1056 enfMesh->persistID = -1; // not to restore again
1060 //=======================================================================
1061 //function : SetGroupsToRemove
1062 //=======================================================================
1064 void HYBRIDPlugin_Hypothesis::ClearGroupsToRemove()
1066 _groupsToRemove.clear();
1070 //=======================================================================
1071 //function : DefaultLayersOnAllWrap
1072 //=======================================================================
1074 bool HYBRIDPlugin_Hypothesis::DefaultLayersOnAllWrap()
1079 //=======================================================================
1080 //function : DefaultMeshHoles
1081 //=======================================================================
1083 bool HYBRIDPlugin_Hypothesis::DefaultMeshHoles()
1085 return false; // PAL19680
1088 //=======================================================================
1089 //function : DefaultToMakeGroupsOfDomains
1090 //=======================================================================
1092 bool HYBRIDPlugin_Hypothesis::DefaultToMakeGroupsOfDomains()
1094 return false; // issue 0022172
1097 //=======================================================================
1098 //function : DefaultMaximumMemory
1099 //=======================================================================
1102 #include <windows.h>
1103 #elif !defined(__APPLE__)
1104 #include <sys/sysinfo.h>
1107 double HYBRIDPlugin_Hypothesis::DefaultMaximumMemory()
1110 // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
1111 MEMORYSTATUSEX statex;
1112 statex.dwLength = sizeof (statex);
1113 int err = GlobalMemoryStatusEx (&statex);
1116 statex.ullTotalPhys / 1024 / 1024 +
1117 statex.ullTotalPageFile / 1024 / 1024 +
1118 statex.ullTotalVirtual / 1024 / 1024;
1119 return ( 0.7 * totMB );
1121 #elif !defined(__APPLE__)
1123 int err = sysinfo( &si );
1125 int ramMB = si.totalram * si.mem_unit / 1024 / 1024;
1126 return ( 0.7 * ramMB );
1132 //=======================================================================
1133 //function : DefaultInitialMemory
1134 //=======================================================================
1136 double HYBRIDPlugin_Hypothesis::DefaultInitialMemory()
1138 return DefaultMaximumMemory();
1141 //=======================================================================
1142 //function : DefaultCollisionMode
1143 //=======================================================================
1144 short HYBRIDPlugin_Hypothesis::DefaultCollisionMode()
1149 //=======================================================================
1150 //function : DefaultBoundaryLayersGrowth
1151 //=======================================================================
1152 short HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersGrowth()
1154 return Layer_Growth_Inward;
1157 //=======================================================================
1158 //function : DefaultElementGeneration
1159 //=======================================================================
1160 short HYBRIDPlugin_Hypothesis::DefaultElementGeneration()
1162 return Generation_Tetra_Dominant;
1165 //=======================================================================
1166 //function : DefaultOptimizationLevel
1167 //=======================================================================
1168 short HYBRIDPlugin_Hypothesis::DefaultOptimizationLevel()
1173 //=======================================================================
1174 //function : DefaultWorkingDirectory
1175 //=======================================================================
1177 std::string HYBRIDPlugin_Hypothesis::DefaultWorkingDirectory()
1179 std::string aTmpDir;
1181 char *Tmp_dir = getenv("SALOME_TMP_DIR");
1182 if(Tmp_dir != NULL) {
1195 //=======================================================================
1196 //function : DefaultKeepFiles
1197 //=======================================================================
1199 bool HYBRIDPlugin_Hypothesis::DefaultKeepFiles()
1204 //=======================================================================
1205 //function : DefaultRemoveLogOnSuccess
1206 //=======================================================================
1208 bool HYBRIDPlugin_Hypothesis::DefaultRemoveLogOnSuccess()
1214 //=======================================================================
1215 //function : DefaultVerboseLevel
1216 //=======================================================================
1218 short HYBRIDPlugin_Hypothesis::DefaultVerboseLevel()
1223 //=======================================================================
1224 //function : DefaultToCreateNewNodes
1225 //=======================================================================
1227 bool HYBRIDPlugin_Hypothesis::DefaultToCreateNewNodes()
1232 //=======================================================================
1233 //function : DefaultToUseBoundaryRecoveryVersion
1234 //=======================================================================
1236 bool HYBRIDPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion()
1241 //=======================================================================
1242 //function : DefaultToUseFEMCorrection
1243 //=======================================================================
1245 bool HYBRIDPlugin_Hypothesis::DefaultToUseFEMCorrection()
1250 //=======================================================================
1251 //function : DefaultToRemoveCentralPoint
1252 //=======================================================================
1254 bool HYBRIDPlugin_Hypothesis::DefaultToRemoveCentralPoint()
1259 //=======================================================================
1260 //function : DefaultGradation
1261 //=======================================================================
1263 double HYBRIDPlugin_Hypothesis::DefaultGradation()
1268 //=======================================================================
1269 //function : DefaultStandardOutputLog
1270 //=======================================================================
1272 bool HYBRIDPlugin_Hypothesis::DefaultStandardOutputLog()
1277 // //=======================================================================
1278 // //function : DefaultID2SizeMap
1279 // //=======================================================================
1281 // HYBRIDPlugin_Hypothesis::TID2SizeMap HYBRIDPlugin_Hypothesis::DefaultID2SizeMap()
1283 // return HYBRIDPlugin_Hypothesis::TID2SizeMap();
1286 //=======================================================================
1287 //function : DefaultAddMultinormals
1288 //=======================================================================
1289 bool HYBRIDPlugin_Hypothesis::DefaultAddMultinormals()
1294 //=======================================================================
1295 //function : DefaultSmoothNormals
1296 //=======================================================================
1297 bool HYBRIDPlugin_Hypothesis::DefaultSmoothNormals()
1302 //=======================================================================
1303 //function : DefaultHeightFirstLayer
1304 //=======================================================================
1305 double HYBRIDPlugin_Hypothesis::DefaultHeightFirstLayer()
1307 return 0.0; //or epsilon?
1310 //=======================================================================
1311 //function : DefaultBoundaryLayersProgression
1312 //=======================================================================
1313 double HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersProgression()
1318 //=======================================================================
1319 //function : DefaultCoreSize
1320 //=======================================================================
1321 double HYBRIDPlugin_Hypothesis::DefaultCoreSize()
1326 //=======================================================================
1327 //function : DefaultMultinormalsAngle
1328 //=======================================================================
1329 double HYBRIDPlugin_Hypothesis::DefaultMultinormalsAngle()
1334 //=======================================================================
1335 //function : DefaultNbOfBoundaryLayers
1336 //=======================================================================
1337 short HYBRIDPlugin_Hypothesis::DefaultNbOfBoundaryLayers()
1342 //=======================================================================
1344 //=======================================================================
1346 std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save)
1348 save << (int) myBoundaryLayersGrowth << " ";
1349 save << (int) myElementGeneration << " ";
1350 save << (int) myAddMultinormals << " ";
1351 save << (int) mySmoothNormals << " ";
1352 save << (int) myLayersOnAllWrap << " ";
1354 save << myNbOfBoundaryLayers << " ";
1355 save << myHeightFirstLayer << " ";
1356 save << myBoundaryLayersProgression << " ";
1357 save << myMultinormalsAngle << " ";
1359 save << (int) myKeepFiles << " ";
1360 save << myWorkingDirectory << " ";
1361 save << myVerboseLevel << " ";
1362 save << myCoreSize << " ";
1364 if (!myTextOption.empty()) {
1365 save << "__OPTIONS_BEGIN__ ";
1366 save << myTextOption << " ";
1367 save << "__OPTIONS_END__ ";
1371 THYBRIDEnforcedVertexList::iterator it = _enfVertexList.begin();
1372 if (it != _enfVertexList.end()) {
1373 save << " " << "__ENFORCED_VERTICES_BEGIN__ ";
1374 for ( ; it != _enfVertexList.end(); ++it ) {
1375 THYBRIDEnforcedVertex *enfVertex = (*it);
1376 save << " " << "__BEGIN_VERTEX__";
1377 if (!enfVertex->name.empty()) {
1378 save << " " << "__BEGIN_NAME__";
1379 save << " " << enfVertex->name;
1380 save << " " << "__END_NAME__";
1382 if (!enfVertex->geomEntry.empty()) {
1383 save << " " << "__BEGIN_ENTRY__";
1384 save << " " << enfVertex->geomEntry;
1385 save << " " << enfVertex->isCompound;
1386 save << " " << "__END_ENTRY__";
1388 if (!enfVertex->groupName.empty()) {
1389 save << " " << "__BEGIN_GROUP__";
1390 save << " " << enfVertex->groupName;
1391 save << " " << "__END_GROUP__";
1393 if (enfVertex->coords.size()) {
1394 save << " " << "__BEGIN_COORDS__";
1395 for ( size_t i = 0; i < enfVertex->coords.size(); i++ )
1396 save << " " << enfVertex->coords[i];
1397 save << " " << "__END_COORDS__";
1399 save << " " << "__BEGIN_SIZE__";
1400 save << " " << enfVertex->size;
1401 save << " " << "__END_SIZE__";
1402 save << " " << "__END_VERTEX__";
1404 save << " " << "__ENFORCED_VERTICES_END__ ";
1407 THYBRIDEnforcedMeshList::iterator it_mesh = _enfMeshList.begin();
1408 if (it_mesh != _enfMeshList.end()) {
1409 save << " " << "__ENFORCED_MESHES_BEGIN__ ";
1410 for ( ; it_mesh != _enfMeshList.end(); ++it_mesh ) {
1411 THYBRIDEnforcedMesh *enfMesh = (*it_mesh);
1412 save << " " << "__BEGIN_ENF_MESH__";
1414 save << " " << "__BEGIN_NAME__";
1415 save << " " << enfMesh->name;
1416 save << " " << "__END_NAME__";
1418 save << " " << "__BEGIN_ENTRY__";
1419 save << " " << enfMesh->entry;
1420 save << " " << "__END_ENTRY__";
1422 save << " " << "__BEGIN_ELEM_TYPE__";
1423 save << " " << (int)enfMesh->elementType;
1424 save << " " << "__END_ELEM_TYPE__";
1426 if (!enfMesh->groupName.empty()) {
1427 save << " " << "__BEGIN_GROUP__";
1428 save << " " << enfMesh->groupName;
1429 save << " " << "__END_GROUP__";
1431 save << " " << "__PERSIST_ID__";
1432 save << " " << enfMesh->persistID;
1433 save << " " << "__END_ENF_MESH__";
1434 std::cout << "Saving of enforced mesh " << enfMesh->name.c_str() << " done" << std::endl;
1436 save << " " << "__ENFORCED_MESHES_END__ ";
1439 save << " " << myFacesWithLayers.size();
1440 for ( size_t i = 0; i < myFacesWithLayers.size(); ++i )
1441 save << " " << myFacesWithLayers[i];
1446 //=======================================================================
1447 //function : LoadFrom
1448 //=======================================================================
1450 std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load)
1456 isOK = static_cast<bool>(load >> i);
1458 myBoundaryLayersGrowth = (short) i;
1460 load.clear(ios::badbit | load.rdstate());
1462 isOK = static_cast<bool>(load >> i);
1464 myElementGeneration = (short) i;
1466 load.clear(ios::badbit | load.rdstate());
1468 isOK = static_cast<bool>(load >> i);
1470 myAddMultinormals = (bool) i;
1472 load.clear(ios::badbit | load.rdstate());
1474 isOK = static_cast<bool>(load >> i);
1476 mySmoothNormals = (bool) i;
1478 load.clear(ios::badbit | load.rdstate());
1480 isOK = static_cast<bool>(load >> i);
1482 myLayersOnAllWrap = (bool) i;
1484 load.clear(ios::badbit | load.rdstate());
1486 isOK = static_cast<bool>(load >> i);
1488 myNbOfBoundaryLayers = (short) i;
1490 load.clear(ios::badbit | load.rdstate());
1492 isOK = static_cast<bool>(load >> d);
1494 myHeightFirstLayer = d;
1496 load.clear(ios::badbit | load.rdstate());
1498 isOK = static_cast<bool>(load >> d);
1500 myBoundaryLayersProgression = d;
1502 load.clear(ios::badbit | load.rdstate());
1504 isOK = static_cast<bool>(load >> d);
1506 myMultinormalsAngle = d;
1508 load.clear(ios::badbit | load.rdstate());
1510 isOK = static_cast<bool>(load >> i);
1512 myKeepFiles = (bool) i;
1514 load.clear(ios::badbit | load.rdstate());
1516 isOK = static_cast<bool>(load >> myWorkingDirectory);
1518 if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
1519 myKeepFiles = false;
1520 myWorkingDirectory.clear();
1522 else if ( myWorkingDirectory == "1" ) {
1524 myWorkingDirectory.clear();
1528 load.clear(ios::badbit | load.rdstate());
1530 isOK = static_cast<bool>(load >> i);
1532 myVerboseLevel = (short) i;
1534 load.clear(ios::badbit | load.rdstate());
1536 isOK = static_cast<bool>(load >> d);
1540 load.clear(ios::badbit | load.rdstate());
1542 std::string separator;
1543 bool hasOptions = false;
1544 bool hasEnforcedVertices = false;
1545 bool hasEnforcedMeshes = false;
1546 isOK = static_cast<bool>(load >> separator);
1548 if ( isOK && ( separator == "0" || separator == "1" ))
1550 myToMakeGroupsOfDomains = ( separator == "1" );
1551 isOK = static_cast<bool>(load >> separator);
1555 if (separator == "__OPTIONS_BEGIN__")
1557 else if (separator == "__ENFORCED_VERTICES_BEGIN__")
1558 hasEnforcedVertices = true;
1559 else if (separator == "__ENFORCED_MESHES_BEGIN__")
1560 hasEnforcedMeshes = true;
1566 isOK = static_cast<bool>(load >> txt);
1568 if (txt == "__OPTIONS_END__") {
1569 if (!myTextOption.empty()) {
1570 // Remove last space
1571 myTextOption.erase(myTextOption.end()-1);
1576 myTextOption += txt;
1577 myTextOption += " ";
1583 isOK = static_cast<bool>(load >> separator);
1584 if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__")
1585 hasEnforcedVertices = true;
1586 if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
1587 hasEnforcedMeshes = true;
1590 if (hasEnforcedVertices) {
1591 std::string txt, name, entry, groupName;
1592 double size, coords[3];
1594 bool hasCoords = false;
1595 isOK = static_cast<bool>(load >> txt); // __BEGIN_VERTEX__
1597 if (txt == "__ENFORCED_VERTICES_END__")
1600 THYBRIDEnforcedVertex *enfVertex = new THYBRIDEnforcedVertex();
1602 isOK = static_cast<bool>(load >> txt);
1603 if (txt == "__END_VERTEX__") {
1604 enfVertex->name = name;
1605 enfVertex->geomEntry = entry;
1606 enfVertex->isCompound = isCompound;
1607 enfVertex->groupName = groupName;
1608 enfVertex->coords.clear();
1610 enfVertex->coords.assign(coords,coords+3);
1612 _enfVertexList.insert(enfVertex);
1614 if (enfVertex->coords.size())
1615 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
1616 if (!enfVertex->geomEntry.empty())
1617 _geomEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
1626 if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
1627 while (isOK && (txt != "__END_NAME__")) {
1628 isOK = static_cast<bool>(load >> txt);
1629 if (txt != "__END_NAME__") {
1637 if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
1638 isOK = static_cast<bool>(load >> entry);
1639 isOK = static_cast<bool>(load >> isCompound);
1640 isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
1641 if (txt != "__END_ENTRY__")
1642 throw std::exception();
1645 if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
1646 while (isOK && (txt != "__END_GROUP__")) {
1647 isOK = static_cast<bool>(load >> txt);
1648 if (txt != "__END_GROUP__") {
1649 if (!groupName.empty())
1656 if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
1658 isOK = static_cast<bool>(load >> coords[0] >> coords[1] >> coords[2]);
1659 isOK = static_cast<bool>(load >> txt); // __END_COORDS__
1660 if (txt != "__END_COORDS__")
1661 throw std::exception();
1664 if (txt == "__BEGIN_SIZE__") { // __BEGIN_ENTRY__
1665 isOK = static_cast<bool>(load >> size);
1666 isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
1667 if (txt != "__END_SIZE__") {
1668 throw std::exception();
1672 isOK = static_cast<bool>(load >> txt); // __BEGIN_VERTEX__
1676 if (hasEnforcedVertices) {
1677 isOK = static_cast<bool>(load >> separator);
1678 if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
1679 hasEnforcedMeshes = true;
1682 if (hasEnforcedMeshes) {
1683 std::string txt, name, entry, groupName;
1684 int elementType = -1, persistID = -1;
1685 isOK = static_cast<bool>(load >> txt); // __BEGIN_ENF_MESH__
1688 if (txt == "__ENFORCED_MESHES_END__")
1691 THYBRIDEnforcedMesh *enfMesh = new THYBRIDEnforcedMesh();
1693 isOK = static_cast<bool>(load >> txt);
1694 if (txt == "__END_ENF_MESH__") {
1695 enfMesh->name = name;
1696 enfMesh->entry = entry;
1697 enfMesh->elementType = (SMESH::ElementType)elementType;
1698 enfMesh->groupName = groupName;
1699 enfMesh->persistID = persistID;
1701 _enfMeshList.insert(enfMesh);
1702 std::cout << "Restoring of enforced mesh " <<name << " done" << std::endl;
1712 if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
1713 while (isOK && (txt != "__END_NAME__")) {
1714 isOK = static_cast<bool>(load >> txt);
1715 if (txt != "__END_NAME__") {
1723 if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
1724 isOK = static_cast<bool>(load >> entry);
1725 isOK = static_cast<bool>(load >> txt); // __END_ENTRY__
1726 if (txt != "__END_ENTRY__")
1727 throw std::exception();
1730 if (txt == "__BEGIN_ELEM_TYPE__") { // __BEGIN_ELEM_TYPE__
1731 isOK = static_cast<bool>(load >> elementType);
1732 isOK = static_cast<bool>(load >> txt); // __END_ELEM_TYPE__
1733 if (txt != "__END_ELEM_TYPE__")
1734 throw std::exception();
1737 if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
1738 while (isOK && (txt != "__END_GROUP__")) {
1739 isOK = static_cast<bool>(load >> txt);
1740 if (txt != "__END_GROUP__") {
1741 if (!groupName.empty())
1748 if (txt == "__PERSIST_ID__") {
1749 isOK = static_cast<bool>(load >> persistID);
1751 std::cout << "isOK: " << isOK << std::endl;
1754 isOK = static_cast<bool>(load >> txt); // __BEGIN_ENF_MESH__
1758 if ( hasEnforcedMeshes )
1759 isOK = static_cast<bool>(load >> separator);
1763 i = atoi( separator.c_str() );
1767 myFacesWithLayers.reserve( i );
1768 while (( myFacesWithLayers.size() < myFacesWithLayers.capacity() ) &&
1769 ( isOK = static_cast<bool>(load >> i)) )
1770 myFacesWithLayers.push_back( i );
1776 //=======================================================================
1777 //function : SetParametersByMesh
1778 //=======================================================================
1780 bool HYBRIDPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&)
1786 //================================================================================
1788 * \brief Sets myToMakeGroupsOfDomains depending on whether theMesh is on shape or not
1790 //================================================================================
1792 bool HYBRIDPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts,
1793 const SMESH_Mesh* /*theMesh*/)
1795 myToMakeGroupsOfDomains = ( !dflts._shape || dflts._shape->IsNull() );
1799 //================================================================================
1801 * \brief Return command to run hybrid mesher excluding file prefix (-f)
1803 //================================================================================
1805 std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp,
1808 SMESH_Comment cmd = GetExeName();
1809 // check if any option is overridden by hyp->myTextOption
1810 bool p_h = ( hyp && hyp->myTextOption.find("-h") != std::string::npos );
1811 bool p_v = ( hyp && hyp->myTextOption.find("-v") != std::string::npos );
1812 bool p_i = ( hyp && hyp->myTextOption.find("-i") != std::string::npos );
1813 bool p_o = ( hyp && hyp->myTextOption.find("-o") != std::string::npos );
1814 bool p_mnot = ( hyp && hyp->myTextOption.find("--max_number_of_threads ") != std::string::npos );
1815 bool p_blsi = ( hyp && hyp->myTextOption.find("--boundary_layer_surface_tags ") != std::string::npos );
1816 bool p_blii = ( hyp && hyp->myTextOption.find("--boundary_layer_imprint_tags ") != std::string::npos );
1817 bool p_blsd = ( hyp && hyp->myTextOption.find("--normal_direction ") != std::string::npos );
1818 bool p_hotfl = ( hyp && hyp->myTextOption.find("--boundary_layer_global_initial_height ") != std::string::npos );
1819 bool p_nobl = ( hyp && hyp->myTextOption.find("--number_of_boundary_layers ") != std::string::npos );
1820 bool p_blgp = ( hyp && hyp->myTextOption.find("--boundary_layer_geometric_progression ") != std::string::npos );
1821 bool p_eg = ( hyp && hyp->myTextOption.find("--element_generation ") != std::string::npos );
1822 bool p_cm = ( hyp && hyp->myTextOption.find("--collision_mode ") != std::string::npos );
1823 bool p_am = ( hyp && hyp->myTextOption.find("--add_multinormals ") != std::string::npos );
1824 bool p_cs = ( hyp && hyp->myTextOption.find("--global_physical_size ") != std::string::npos );
1825 bool p_mat = ( hyp && hyp->myTextOption.find("--multinormal_angle_threshold ") != std::string::npos );
1826 bool p_sn = ( hyp && hyp->myTextOption.find("--smooth_normals ") != std::string::npos );
1829 //- boundary_layer_max_element_angle
1831 bool nolayers = false;
1832 bool layersOnAllWrap = hyp ? hyp->myLayersOnAllWrap : DefaultLayersOnAllWrap();
1840 std::cout << "!!!!! CommandToRun help only !!!! " << cmd << std::endl;
1845 cmd << " --verbose " << hyp->myVerboseLevel;
1847 if ( !p_mnot && hyp )
1848 cmd << " --max_number_of_threads " << 8; //TODO getenv NB CPU
1851 if ( !p_nobl && hyp ) {
1852 if ( hyp->myNbOfBoundaryLayers < 1 ) nolayers = true;
1854 if ( !p_hotfl && hyp ) {
1855 if ( hyp->myHeightFirstLayer < 1e-50 ) nolayers = true;
1858 if ( !p_blsd && hyp ) {
1859 if ( hyp->myBoundaryLayersGrowth >= 0 && hyp->myBoundaryLayersGrowth <= 1 ) {
1860 const char* value[] = { "-1" , "1" }; // -1 == inside
1861 cmd << " --normal_direction " << value[ hyp->myBoundaryLayersGrowth ];
1865 if ( !p_hotfl && hyp ) {
1866 cmd << " --boundary_layer_global_initial_height " << hyp->myHeightFirstLayer;
1869 if ( !p_nobl && hyp ) {
1870 cmd << " --number_of_boundary_layers " << ( nolayers ? 0 : hyp->myNbOfBoundaryLayers );
1873 if ( !p_blgp && hyp ) {
1874 cmd << " --boundary_layer_geometric_progression " << hyp->myBoundaryLayersProgression;
1877 if ( !nolayers && hyp )
1879 cmd << " --boundary_layer_size_mode " << ( layersOnAllWrap ? "global" : "local" );
1880 cmd << " --boundary_layer_surface_tags ";
1881 if ( layersOnAllWrap )
1887 const std::vector<int>& faceIDs = hyp->GetFacesWithLayers();
1888 const bool hasEnforcedTria = !HYBRIDPlugin_Hypothesis::GetEnforcedTriangles(hyp).empty();
1889 for ( size_t i = 0; i < faceIDs.size(); ++i )
1890 cmd << faceIDs[i] << ",";
1891 if ( hasEnforcedTria )
1892 cmd << EnforcedTag();
1893 cmd << " --boundary_layer_initial_height_on_surface_tags ";
1894 for ( size_t i = 0; i < faceIDs.size() + hasEnforcedTria; ++i )
1895 cmd << hyp->myHeightFirstLayer << ",";
1899 if ( !p_eg && hyp ) {
1900 if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 2 ) {
1901 const char* value[] = { "tetra-dominant" , "hexa-dominant", "cartesian_core" };
1902 cmd << " --element_generation " << value[ hyp->myElementGeneration ];
1906 if ( !p_cs && hyp ) {
1907 if ( hyp->myCoreSize >= 0 ) {
1908 cmd << " --global_physical_size " << hyp->myCoreSize;
1912 if ( !p_cm && hyp ) {
1913 if ( hyp->myCollisionMode >= 0 && hyp->myCollisionMode <= 1 ) {
1914 const char* value[] = { "decrease" , "stop" };
1915 cmd << " --collision_mode " << value[ hyp->myCollisionMode ];
1919 if ( !p_am && hyp ) {
1920 int res = hyp->myAddMultinormals ? 0 : 1 ;
1921 const char* value[] = { "yes" , "no" };
1922 cmd << " --add_multinormals " << value[ res ];
1925 if ( !p_mat && hyp ) {
1926 cmd << " --multinormal_angle_threshold " << hyp->myMultinormalsAngle;
1929 if ( !p_sn && hyp ) {
1930 int res = hyp->mySmoothNormals ? 0 : 1 ;
1931 const char* value[] = { "yes" , "no" };
1932 cmd << " --smooth_normals " << value[ res ];
1938 //std::cout << "!!!!!CommandToRun end " << cmd << std::endl;
1943 //================================================================================
1945 * \brief Return a unique file name
1947 //================================================================================
1949 std::string HYBRIDPlugin_Hypothesis::GetFileName(const HYBRIDPlugin_Hypothesis* hyp)
1951 std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory();
1952 const char lastChar = *aTmpDir.rbegin();
1954 if(lastChar != '\\') aTmpDir+='\\';
1956 if(lastChar != '/') aTmpDir+='/';
1959 SMESH_Comment aGenericName = aTmpDir;
1960 aGenericName << "HYBRID_";
1961 aGenericName << getpid();
1962 aGenericName << "_";
1963 aGenericName << Abs((Standard_Integer)(long) aGenericName.c_str());
1965 return aGenericName;
1968 //================================================================================
1970 * Return the name of executable
1972 //================================================================================
1974 std::string HYBRIDPlugin_Hypothesis::GetExeName()
1976 //call mg-hybrid.bash is script which assumes new project version(s) mg-hybrid.exe in the prerequisite base and special? licence.
1978 return "mg-hybrid.exe";
1980 return "mg-hybrid.bash";
1984 //================================================================================
1986 * \brief Return the enforced vertices
1988 //================================================================================
1990 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList HYBRIDPlugin_Hypothesis::GetEnforcedVertices(const HYBRIDPlugin_Hypothesis* hyp)
1992 return hyp ? hyp->_GetEnforcedVertices():DefaultHYBRIDEnforcedVertexList();
1995 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues HYBRIDPlugin_Hypothesis::GetEnforcedVerticesCoordsSize (const HYBRIDPlugin_Hypothesis* hyp)
1997 return hyp ? hyp->_GetEnforcedVerticesCoordsSize(): DefaultHYBRIDEnforcedVertexCoordsValues();
2000 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexEntryValues HYBRIDPlugin_Hypothesis::GetEnforcedVerticesEntrySize (const HYBRIDPlugin_Hypothesis* hyp)
2002 return hyp ? hyp->_GetEnforcedVerticesEntrySize(): DefaultHYBRIDEnforcedVertexEntryValues();
2005 HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap HYBRIDPlugin_Hypothesis::GetEnforcedVerticesByCoords (const HYBRIDPlugin_Hypothesis* hyp)
2007 return hyp ? hyp->_GetEnforcedVerticesByCoords(): DefaultCoordsHYBRIDEnforcedVertexMap();
2010 HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap HYBRIDPlugin_Hypothesis::GetEnforcedVerticesByEntry (const HYBRIDPlugin_Hypothesis* hyp)
2012 return hyp ? hyp->_GetEnforcedVerticesByEntry(): DefaultGeomEntryHYBRIDEnforcedVertexMap();
2015 HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedNodes(const HYBRIDPlugin_Hypothesis* hyp)
2017 return hyp ? hyp->_GetEnforcedNodes():DefaultIDSortedNodeGroupMap();
2020 HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedEdges(const HYBRIDPlugin_Hypothesis* hyp)
2022 return hyp ? hyp->_GetEnforcedEdges():DefaultIDSortedElemGroupMap();
2025 HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedTriangles(const HYBRIDPlugin_Hypothesis* hyp)
2027 return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemGroupMap();
2030 HYBRIDPlugin_Hypothesis::TID2SizeMap HYBRIDPlugin_Hypothesis::GetNodeIDToSizeMap(const HYBRIDPlugin_Hypothesis* hyp)
2032 return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap();
2035 HYBRIDPlugin_Hypothesis::TSetStrings HYBRIDPlugin_Hypothesis::GetGroupsToRemove(const HYBRIDPlugin_Hypothesis* hyp)
2037 return hyp ? hyp->_GetGroupsToRemove(): DefaultGroupsToRemove();