1 // Copyright (C) 2004-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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"
27 #include <SMESH_ProxyMesh.hxx>
28 #include <SMESH_Group.hxx>
29 #include <StdMeshers_QuadToTriaAdaptor.hxx>
31 #include <TCollection_AsciiString.hxx>
35 #define getpid _getpid
38 //=======================================================================
39 //function : HYBRIDPlugin_Hypothesis
40 //=======================================================================
42 HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
43 : SMESH_Hypothesis(hypId, studyId, gen),
44 myToMeshHoles(DefaultMeshHoles()),
45 myToMakeGroupsOfDomains(DefaultToMakeGroupsOfDomains()),
48 myOptimizationLevel(DefaultOptimizationLevel()),
49 myBoundaryLayersInward(DefaultBoundaryLayersInward()),
50 myElemGenTetraDominant(DefaultElemGenTetraDominant()),
51 myAddMultinormals(DefaultAddMultinormals()),
52 mySmoothNormals(DefaultSmoothNormals()),
53 myHeightFirstLayer(DefaultHeightFirstLayer()),
54 myBoundaryLayersProgression(DefaultBoundaryLayersProgression()),
55 myMultinormalsAngle(DefaultMultinormalsAngle()),
56 myNbOfBoundaryLayers(DefaultNbOfBoundaryLayers()),
57 myWorkingDirectory(DefaultWorkingDirectory()),
58 myKeepFiles(DefaultKeepFiles()),
59 myVerboseLevel(DefaultVerboseLevel()),
60 myToCreateNewNodes(DefaultToCreateNewNodes()),
61 myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()),
62 myToUseFemCorrection(DefaultToUseFEMCorrection()),
63 myToRemoveCentralPoint(DefaultToRemoveCentralPoint()),
64 myGradation(DefaultGradation()),
65 myLogInStandardOutput(DefaultStandardOutputLog()),
66 _enfVertexList(DefaultHYBRIDEnforcedVertexList()),
67 _enfVertexCoordsSizeList(DefaultHYBRIDEnforcedVertexCoordsValues()),
68 _enfVertexEntrySizeList(DefaultHYBRIDEnforcedVertexEntryValues()),
69 _coordsEnfVertexMap(DefaultCoordsHYBRIDEnforcedVertexMap()),
70 _geomEntryEnfVertexMap(DefaultGeomEntryHYBRIDEnforcedVertexMap()),
71 _enfMeshList(DefaultHYBRIDEnforcedMeshList()),
72 _entryEnfMeshMap(DefaultEntryHYBRIDEnforcedMeshListMap()),
73 _enfNodes(TIDSortedNodeGroupMap()),
74 _enfEdges(TIDSortedElemGroupMap()),
75 _enfTriangles(TIDSortedElemGroupMap()),
76 _nodeIDToSizeMap(DefaultID2SizeMap()),
77 _groupsToRemove(DefaultGroupsToRemove())
79 _name = "HYBRID_Parameters";
83 //=======================================================================
84 //function : SetToMeshHoles
85 //=======================================================================
87 void HYBRIDPlugin_Hypothesis::SetToMeshHoles(bool toMesh)
89 if ( myToMeshHoles != toMesh ) {
90 myToMeshHoles = toMesh;
91 NotifySubMeshesHypothesisModification();
95 //=======================================================================
96 //function : GetToMeshHoles
97 //=======================================================================
99 bool HYBRIDPlugin_Hypothesis::GetToMeshHoles(bool checkFreeOption) const
101 if (checkFreeOption && !myTextOption.empty()) {
102 if ( myTextOption.find("-c 0"))
104 if ( myTextOption.find("-c 1"))
107 return myToMeshHoles;
110 //=======================================================================
111 //function : SetToMakeGroupsOfDomains
112 //=======================================================================
114 void HYBRIDPlugin_Hypothesis::SetToMakeGroupsOfDomains(bool toMakeGroups)
116 if ( myToMakeGroupsOfDomains != toMakeGroups ) {
117 myToMakeGroupsOfDomains = toMakeGroups;
118 NotifySubMeshesHypothesisModification();
122 //=======================================================================
123 //function : GetToMakeGroupsOfDomains
124 //=======================================================================
126 bool HYBRIDPlugin_Hypothesis::GetToMakeGroupsOfDomains() const
128 return myToMakeGroupsOfDomains;
131 //=======================================================================
132 //function : GetToMakeGroupsOfDomains
133 //=======================================================================
135 bool HYBRIDPlugin_Hypothesis::GetToMakeGroupsOfDomains(const HYBRIDPlugin_Hypothesis* hyp)
138 if ( hyp ) res = /*hyp->GetToMeshHoles(true) &&*/ hyp->GetToMakeGroupsOfDomains();
139 else res = /*DefaultMeshHoles() &&*/ DefaultToMakeGroupsOfDomains();
143 //=======================================================================
144 //function : SetMaximumMemory
145 //=======================================================================
147 void HYBRIDPlugin_Hypothesis::SetMaximumMemory(double MB)
149 if ( myMaximumMemory != MB ) {
150 myMaximumMemory = MB;
151 NotifySubMeshesHypothesisModification();
155 //=======================================================================
156 //function : GetMaximumMemory
157 // * automatic memory adjustment mode. Default is zero
158 //=======================================================================
160 double HYBRIDPlugin_Hypothesis::GetMaximumMemory() const
162 return myMaximumMemory;
165 //=======================================================================
166 //function : SetInitialMemory
167 //=======================================================================
169 void HYBRIDPlugin_Hypothesis::SetInitialMemory(double MB)
171 if ( myInitialMemory != MB ) {
172 myInitialMemory = MB;
173 NotifySubMeshesHypothesisModification();
177 //=======================================================================
178 //function : GetInitialMemory
179 //=======================================================================
181 double HYBRIDPlugin_Hypothesis::GetInitialMemory() const
183 return myInitialMemory;
186 //=======================================================================
187 //function : SetOptimizationLevel
188 //=======================================================================
190 void HYBRIDPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level)
192 if ( myOptimizationLevel != level ) {
193 myOptimizationLevel = level;
194 NotifySubMeshesHypothesisModification();
198 //=======================================================================
199 //function : GetOptimizationLevel
200 //=======================================================================
202 HYBRIDPlugin_Hypothesis::OptimizationLevel HYBRIDPlugin_Hypothesis::GetOptimizationLevel() const
204 return (OptimizationLevel) myOptimizationLevel;
208 //=======================================================================
209 //function : SetBoundaryLayersInward
210 //=======================================================================
212 void HYBRIDPlugin_Hypothesis::SetBoundaryLayersInward(bool toBoundaryLayersInward)
214 if ( myBoundaryLayersInward != toBoundaryLayersInward ) {
215 myBoundaryLayersInward = toBoundaryLayersInward;
216 NotifySubMeshesHypothesisModification();
220 //=======================================================================
221 //function : GetBoundaryLayersInward
222 //=======================================================================
224 bool HYBRIDPlugin_Hypothesis::GetBoundaryLayersInward() const
226 return myBoundaryLayersInward;
229 //=======================================================================
230 //function : SetElemGenTetraDominant
231 //=======================================================================
233 void HYBRIDPlugin_Hypothesis::SetElemGenTetraDominant(bool toElemGenTetraDominant)
235 if ( myElemGenTetraDominant != toElemGenTetraDominant ) {
236 myElemGenTetraDominant = toElemGenTetraDominant;
237 NotifySubMeshesHypothesisModification();
241 //=======================================================================
242 //function : GetElemGenTetraDominant
243 //=======================================================================
245 bool HYBRIDPlugin_Hypothesis::GetElemGenTetraDominant() const
247 return myElemGenTetraDominant;
250 //=======================================================================
251 //function : SetAddMultinormals
252 //=======================================================================
254 void HYBRIDPlugin_Hypothesis::SetAddMultinormals(bool toAddMultinormals)
256 if ( myAddMultinormals != toAddMultinormals ) {
257 myAddMultinormals = toAddMultinormals;
258 NotifySubMeshesHypothesisModification();
262 //=======================================================================
263 //function : GetAddMultinormals
264 //=======================================================================
266 bool HYBRIDPlugin_Hypothesis::GetAddMultinormals() const
268 return myAddMultinormals;
271 //=======================================================================
272 //function : SetSmoothNormals
273 //=======================================================================
275 void HYBRIDPlugin_Hypothesis::SetSmoothNormals(bool toSmoothNormals)
277 if ( mySmoothNormals != toSmoothNormals ) {
278 mySmoothNormals = toSmoothNormals;
279 NotifySubMeshesHypothesisModification();
283 //=======================================================================
284 //function : GetSmoothNormals
285 //=======================================================================
287 bool HYBRIDPlugin_Hypothesis::GetSmoothNormals() const
289 return mySmoothNormals;
292 //=======================================================================
293 //function : SetHeightFirstLayer
294 //=======================================================================
296 void HYBRIDPlugin_Hypothesis::SetHeightFirstLayer(double toHeightFirstLayer)
298 if ( myHeightFirstLayer != toHeightFirstLayer ) {
299 myHeightFirstLayer = toHeightFirstLayer;
300 NotifySubMeshesHypothesisModification();
304 //=======================================================================
305 //function : GetHeightFirstLayer
306 //=======================================================================
308 double HYBRIDPlugin_Hypothesis::GetHeightFirstLayer() const
310 return myHeightFirstLayer;
313 //=======================================================================
314 //function : SetBoundaryLayersProgression
315 //=======================================================================
317 void HYBRIDPlugin_Hypothesis::SetBoundaryLayersProgression(double toBoundaryLayersProgression)
319 if ( myBoundaryLayersProgression != toBoundaryLayersProgression ) {
320 myBoundaryLayersProgression = toBoundaryLayersProgression;
321 NotifySubMeshesHypothesisModification();
325 //=======================================================================
326 //function : GetBoundaryLayersProgression
327 //=======================================================================
329 double HYBRIDPlugin_Hypothesis::GetBoundaryLayersProgression() const
331 return myBoundaryLayersProgression;
334 //=======================================================================
335 //function : SetMultinormalsAngle
336 //=======================================================================
338 void HYBRIDPlugin_Hypothesis::SetMultinormalsAngle(double toMultinormalsAngle)
340 if ( myMultinormalsAngle != toMultinormalsAngle ) {
341 myMultinormalsAngle = toMultinormalsAngle;
342 NotifySubMeshesHypothesisModification();
346 //=======================================================================
347 //function : GetMultinormalsAngle
348 //=======================================================================
350 double HYBRIDPlugin_Hypothesis::GetMultinormalsAngle() const
352 return myMultinormalsAngle;
355 //=======================================================================
356 //function : SetNbOfBoundaryLayers
357 //=======================================================================
359 void HYBRIDPlugin_Hypothesis::SetNbOfBoundaryLayers(short toNbOfBoundaryLayers)
361 if ( myNbOfBoundaryLayers != toNbOfBoundaryLayers ) {
362 myNbOfBoundaryLayers = toNbOfBoundaryLayers;
363 NotifySubMeshesHypothesisModification();
367 //=======================================================================
368 //function : GetMultinormalsAngle
369 //=======================================================================
371 short HYBRIDPlugin_Hypothesis::GetNbOfBoundaryLayers() const
373 return myNbOfBoundaryLayers;
377 /////////////////////////////////////////////////////////////////////////
380 //=======================================================================
381 //function : SetWorkingDirectory
382 //=======================================================================
384 void HYBRIDPlugin_Hypothesis::SetWorkingDirectory(const std::string& path)
386 if ( myWorkingDirectory != path ) {
387 myWorkingDirectory = path;
388 NotifySubMeshesHypothesisModification();
392 //=======================================================================
393 //function : GetWorkingDirectory
394 //=======================================================================
396 std::string HYBRIDPlugin_Hypothesis::GetWorkingDirectory() const
398 return myWorkingDirectory;
401 //=======================================================================
402 //function : SetKeepFiles
403 //=======================================================================
405 void HYBRIDPlugin_Hypothesis::SetKeepFiles(bool toKeep)
407 if ( myKeepFiles != toKeep ) {
408 myKeepFiles = toKeep;
409 NotifySubMeshesHypothesisModification();
413 //=======================================================================
414 //function : GetKeepFiles
415 //=======================================================================
417 bool HYBRIDPlugin_Hypothesis::GetKeepFiles() const
422 //=======================================================================
423 //function : SetVerboseLevel
424 //=======================================================================
426 void HYBRIDPlugin_Hypothesis::SetVerboseLevel(short level)
428 if ( myVerboseLevel != level ) {
429 myVerboseLevel = level;
430 NotifySubMeshesHypothesisModification();
434 //=======================================================================
435 //function : GetVerboseLevel
436 //=======================================================================
438 short HYBRIDPlugin_Hypothesis::GetVerboseLevel() const
440 return myVerboseLevel;
443 //=======================================================================
444 //function : SetToCreateNewNodes
445 //=======================================================================
447 void HYBRIDPlugin_Hypothesis::SetToCreateNewNodes(bool toCreate)
449 if ( myToCreateNewNodes != toCreate ) {
450 myToCreateNewNodes = toCreate;
451 NotifySubMeshesHypothesisModification();
455 //=======================================================================
456 //function : GetToCreateNewNodes
457 //=======================================================================
459 bool HYBRIDPlugin_Hypothesis::GetToCreateNewNodes() const
461 return myToCreateNewNodes;
464 //=======================================================================
465 //function : SetToUseBoundaryRecoveryVersion
466 //=======================================================================
468 void HYBRIDPlugin_Hypothesis::SetToUseBoundaryRecoveryVersion(bool toUse)
470 if ( myToUseBoundaryRecoveryVersion != toUse ) {
471 myToUseBoundaryRecoveryVersion = toUse;
472 NotifySubMeshesHypothesisModification();
476 //=======================================================================
477 //function : GetToUseBoundaryRecoveryVersion
478 //=======================================================================
480 bool HYBRIDPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const
482 return myToUseBoundaryRecoveryVersion;
485 //=======================================================================
486 //function : SetFEMCorrection
487 //=======================================================================
489 void HYBRIDPlugin_Hypothesis::SetFEMCorrection(bool toUseFem)
491 if ( myToUseFemCorrection != toUseFem ) {
492 myToUseFemCorrection = toUseFem;
493 NotifySubMeshesHypothesisModification();
497 //=======================================================================
498 //function : GetFEMCorrection
499 //=======================================================================
501 bool HYBRIDPlugin_Hypothesis::GetFEMCorrection() const
503 return myToUseFemCorrection;
506 //=======================================================================
507 //function : SetToRemoveCentralPoint
508 //=======================================================================
510 void HYBRIDPlugin_Hypothesis::SetToRemoveCentralPoint(bool toRemove)
512 if ( myToRemoveCentralPoint != toRemove ) {
513 myToRemoveCentralPoint = toRemove;
514 NotifySubMeshesHypothesisModification();
518 //=======================================================================
519 //function : GetToRemoveCentralPoint
520 //=======================================================================
522 bool HYBRIDPlugin_Hypothesis::GetToRemoveCentralPoint() const
524 return myToRemoveCentralPoint;
527 //=======================================================================
528 //function : SetTextOption
529 //=======================================================================
531 void HYBRIDPlugin_Hypothesis::SetTextOption(const std::string& option)
533 if ( myTextOption != option ) {
534 myTextOption = option;
535 NotifySubMeshesHypothesisModification();
539 //=======================================================================
540 //function : GetTextOption
541 //=======================================================================
543 std::string HYBRIDPlugin_Hypothesis::GetTextOption() const
548 //=======================================================================
549 //function : SetGradation
550 //=======================================================================
552 void HYBRIDPlugin_Hypothesis::SetGradation(double gradation)
554 if ( myGradation != gradation ) {
555 myGradation = gradation;
556 NotifySubMeshesHypothesisModification();
560 //=======================================================================
561 //function : GetGradation
562 //=======================================================================
564 double HYBRIDPlugin_Hypothesis::GetGradation() const
569 //=======================================================================
570 //function : SetStandardOutputLog
571 //=======================================================================
573 void HYBRIDPlugin_Hypothesis::SetStandardOutputLog(bool logInStandardOutput)
575 if ( myLogInStandardOutput != logInStandardOutput ) {
576 myLogInStandardOutput = logInStandardOutput;
577 NotifySubMeshesHypothesisModification();
581 //=======================================================================
582 //function : GetStandardOutputLog
583 //=======================================================================
585 bool HYBRIDPlugin_Hypothesis::GetStandardOutputLog() const
587 return myLogInStandardOutput;
590 //=======================================================================
591 //function : SetRemoveLogOnSuccess
592 //=======================================================================
594 void HYBRIDPlugin_Hypothesis::SetRemoveLogOnSuccess(bool removeLogOnSuccess)
596 if ( myRemoveLogOnSuccess != removeLogOnSuccess ) {
597 myRemoveLogOnSuccess = removeLogOnSuccess;
598 NotifySubMeshesHypothesisModification();
602 //=======================================================================
603 //function : GetRemoveLogOnSuccess
604 //=======================================================================
606 bool HYBRIDPlugin_Hypothesis::GetRemoveLogOnSuccess() const
608 return myRemoveLogOnSuccess;
611 //=======================================================================
612 //function : SetEnforcedVertex
613 //=======================================================================
615 bool HYBRIDPlugin_Hypothesis::SetEnforcedVertex(std::string theName, std::string theEntry, std::string theGroupName,
616 double size, double x, double y, double z, bool isCompound)
618 MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedVertex(\""<< theName << "\", \""<< theEntry << "\", \"" << theGroupName << "\", "
619 << size << ", " << x << ", " << y << ", " << z << ", "<< isCompound << ")");
621 bool toNotify = false;
622 bool toCreate = true;
624 THYBRIDEnforcedVertex *oldEnVertex;
625 THYBRIDEnforcedVertex *newEnfVertex = new THYBRIDEnforcedVertex();
626 newEnfVertex->name = theName;
627 newEnfVertex->geomEntry = theEntry;
628 newEnfVertex->coords.clear();
630 newEnfVertex->coords.push_back(x);
631 newEnfVertex->coords.push_back(y);
632 newEnfVertex->coords.push_back(z);
634 newEnfVertex->groupName = theGroupName;
635 newEnfVertex->size = size;
636 newEnfVertex->isCompound = isCompound;
639 // update _enfVertexList
640 THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(newEnfVertex);
641 if (it != _enfVertexList.end()) {
644 MESSAGE("Enforced Vertex was found => Update");
645 if (oldEnVertex->name != theName) {
646 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theName << "\"");
647 oldEnVertex->name = theName;
650 if (oldEnVertex->groupName != theGroupName) {
651 MESSAGE("Update group name from \"" << oldEnVertex->groupName << "\" to \"" << theGroupName << "\"");
652 oldEnVertex->groupName = theGroupName;
655 if (oldEnVertex->size != size) {
656 MESSAGE("Update size from \"" << oldEnVertex->size << "\" to \"" << size << "\"");
657 oldEnVertex->size = size;
661 // update map coords / enf vertex if needed
662 if (oldEnVertex->coords.size()) {
663 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
664 _enfVertexCoordsSizeList[oldEnVertex->coords] = size;
667 // update map geom entry / enf vertex if needed
668 if (oldEnVertex->geomEntry != "") {
669 _geomEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
670 _enfVertexEntrySizeList[oldEnVertex->geomEntry] = size;
675 // //////// CREATE ////////////
678 MESSAGE("Creating new enforced vertex");
679 _enfVertexList.insert(newEnfVertex);
680 if (theEntry == "") {
681 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
682 _enfVertexCoordsSizeList[newEnfVertex->coords] = size;
685 _geomEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
686 _enfVertexEntrySizeList[newEnfVertex->geomEntry] = size;
691 NotifySubMeshesHypothesisModification();
693 MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedVertex END");
698 //=======================================================================
699 //function : SetEnforcedMesh
700 //=======================================================================
701 bool HYBRIDPlugin_Hypothesis::SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName)
703 TIDSortedElemSet theElemSet;
704 SMDS_ElemIteratorPtr eIt = theMesh.GetMeshDS()->elementsIterator(SMDSAbs_ElementType(elementType));
705 while ( eIt->more() )
706 theElemSet.insert( eIt->next() );
707 MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source mesh");
708 bool added = SetEnforcedElements( theElemSet, elementType, groupName);
710 THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
711 newEnfMesh->persistID = theMesh.GetMeshDS()->GetPersistentId();
712 newEnfMesh->name = name;
713 newEnfMesh->entry = entry;
714 newEnfMesh->elementType = elementType;
715 newEnfMesh->groupName = groupName;
717 THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
718 if (it == _enfMeshList.end()) {
719 _entryEnfMeshMap[entry].insert(newEnfMesh);
720 _enfMeshList.insert(newEnfMesh);
729 //=======================================================================
730 //function : SetEnforcedGroup
731 //=======================================================================
732 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)
734 MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedGroup");
735 TIDSortedElemSet theElemSet;
736 if ( theIDs->length() == 0 ){MESSAGE("The source group is empty");}
737 for (int i=0; i < theIDs->length(); i++) {
738 CORBA::Long ind = theIDs[i];
739 if (elementType == SMESH::NODE)
741 const SMDS_MeshNode * node = theMeshDS->FindNode(ind);
743 theElemSet.insert( node );
747 const SMDS_MeshElement * elem = theMeshDS->FindElement(ind);
749 theElemSet.insert( elem );
753 // SMDS_ElemIteratorPtr it = theGroup->GetGroupDS()->GetElements();
754 // while ( it->more() )
755 // theElemSet.insert( it->next() );
757 MESSAGE("Add "<<theElemSet.size()<<" types["<<elementType<<"] from source group ");
758 bool added = SetEnforcedElements( theElemSet, elementType, groupName);
760 THYBRIDEnforcedMesh* newEnfMesh = new THYBRIDEnforcedMesh();
761 newEnfMesh->name = name;
762 newEnfMesh->entry = entry;
763 newEnfMesh->elementType = elementType;
764 newEnfMesh->groupName = groupName;
766 THYBRIDEnforcedMeshList::iterator it = _enfMeshList.find(newEnfMesh);
767 if (it == _enfMeshList.end()) {
768 _entryEnfMeshMap[entry].insert(newEnfMesh);
769 _enfMeshList.insert(newEnfMesh);
775 //=======================================================================
776 //function : SetEnforcedElements
777 //=======================================================================
778 bool HYBRIDPlugin_Hypothesis::SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName)
780 MESSAGE("HYBRIDPlugin_Hypothesis::SetEnforcedElements");
781 TIDSortedElemSet::const_iterator it = theElemSet.begin();
782 const SMDS_MeshElement* elem;
783 const SMDS_MeshNode* node;
785 pair<TIDSortedNodeGroupMap::iterator,bool> nodeRet;
786 pair<TIDSortedElemGroupMap::iterator,bool> elemRet;
788 for (;it != theElemSet.end();++it)
791 switch (elementType) {
793 node = dynamic_cast<const SMDS_MeshNode*>(elem);
795 nodeRet = _enfNodes.insert(make_pair(node,groupName));
796 added = added && nodeRet.second;
797 string msg = added ? "yes":"no";
798 MESSAGE( "Node (" <<node->X()<<","<<node->Y()<<","<<node->Z()<< ") with ID " << node->GetID() <<" added ? " << msg);
801 SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
802 for (;nodeIt->more();) {
803 node = dynamic_cast<const SMDS_MeshNode*>(nodeIt->next());
804 nodeRet = _enfNodes.insert(make_pair(node,groupName));
805 added = added && nodeRet.second;
811 if (elem->GetType() == SMDSAbs_Edge) {
812 elemRet = _enfEdges.insert(make_pair(elem,groupName));
813 added = added && elemRet.second;
815 else if (elem->GetType() > SMDSAbs_Edge) {
816 SMDS_ElemIteratorPtr it = elem->edgesIterator();
818 const SMDS_MeshElement* anEdge = it->next();
819 elemRet = _enfEdges.insert(make_pair(anEdge,groupName));
820 added = added && elemRet.second;
825 if (elem->GetType() == SMDSAbs_Face)
827 if (elem->NbCornerNodes() == 3) {
828 elemRet = _enfTriangles.insert(make_pair(elem,groupName));
829 added = added && elemRet.second;
832 else if (elem->GetType() > SMDSAbs_Face) { // Group of faces
833 SMDS_ElemIteratorPtr it = elem->facesIterator();
835 const SMDS_MeshElement* aFace = it->next();
836 if (aFace->NbCornerNodes() == 3) {
837 elemRet = _enfTriangles.insert(make_pair(aFace,groupName));
838 added = added && elemRet.second;
848 NotifySubMeshesHypothesisModification();
853 //=======================================================================
854 //function : GetEnforcedVertex
855 //=======================================================================
857 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* HYBRIDPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z)
858 throw (std::invalid_argument)
860 std::vector<double> coord(3);
864 if (_coordsEnfVertexMap.count(coord)>0)
865 return _coordsEnfVertexMap[coord];
866 std::ostringstream msg ;
867 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
868 throw std::invalid_argument(msg.str());
871 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertex* HYBRIDPlugin_Hypothesis::GetEnforcedVertex(const std::string theEntry)
872 throw (std::invalid_argument)
874 if (_geomEntryEnfVertexMap.count(theEntry)>0)
875 return _geomEntryEnfVertexMap[theEntry];
877 std::ostringstream msg ;
878 msg << "No enforced vertex with entry " << theEntry;
879 throw std::invalid_argument(msg.str());
882 //=======================================================================
883 //function : RemoveEnforcedVertex
884 //=======================================================================
886 bool HYBRIDPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z, const std::string theEntry)
887 throw (std::invalid_argument)
889 bool toNotify = false;
890 std::ostringstream msg;
891 THYBRIDEnforcedVertex *oldEnfVertex;
892 std::vector<double> coords(3);
897 // check that enf vertex with given enf vertex entry exists
898 TGeomEntryHYBRIDEnforcedVertexMap::iterator it_enfVertexEntry = _geomEntryEnfVertexMap.find(theEntry);
899 if (it_enfVertexEntry != _geomEntryEnfVertexMap.end()) {
901 MESSAGE("Found enforced vertex with geom entry " << theEntry);
902 oldEnfVertex = it_enfVertexEntry->second;
903 _geomEntryEnfVertexMap.erase(it_enfVertexEntry);
906 MESSAGE("Enforced vertex with geom entry " << theEntry << " not found");
907 // check that enf vertex with given coords exists
908 TCoordsHYBRIDEnforcedVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
909 if (it_coords_enf != _coordsEnfVertexMap.end()) {
911 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
912 oldEnfVertex = it_coords_enf->second;
913 _coordsEnfVertexMap.erase(it_coords_enf);
914 _enfVertexCoordsSizeList.erase(_enfVertexCoordsSizeList.find(coords));
917 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
918 throw std::invalid_argument(msg.str());
922 MESSAGE("Remove enf vertex from _enfVertexList");
924 // update _enfVertexList
925 THYBRIDEnforcedVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
926 if (it != _enfVertexList.end()) {
927 if ((*it)->groupName != "")
928 _groupsToRemove.insert((*it)->groupName);
929 _enfVertexList.erase(it);
935 NotifySubMeshesHypothesisModification();
940 //=======================================================================
941 //function : ClearEnforcedVertices
942 //=======================================================================
943 void HYBRIDPlugin_Hypothesis::ClearEnforcedVertices()
945 THYBRIDEnforcedVertexList::const_iterator it = _enfVertexList.begin();
946 for(;it != _enfVertexList.end();++it) {
947 if ((*it)->groupName != "")
948 _groupsToRemove.insert((*it)->groupName);
950 _enfVertexList.clear();
951 _coordsEnfVertexMap.clear();
952 _geomEntryEnfVertexMap.clear();
953 _enfVertexCoordsSizeList.clear();
954 _enfVertexEntrySizeList.clear();
955 NotifySubMeshesHypothesisModification();
958 //=======================================================================
959 //function : ClearEnforcedMeshes
960 //=======================================================================
961 void HYBRIDPlugin_Hypothesis::ClearEnforcedMeshes()
963 THYBRIDEnforcedMeshList::const_iterator it = _enfMeshList.begin();
964 for(;it != _enfMeshList.end();++it) {
965 if ((*it)->groupName != "")
966 _groupsToRemove.insert((*it)->groupName);
970 _enfTriangles.clear();
971 _nodeIDToSizeMap.clear();
972 _enfMeshList.clear();
973 _entryEnfMeshMap.clear();
974 NotifySubMeshesHypothesisModification();
977 //================================================================================
979 * \brief At mesh loading, restore enforced elements by just loaded enforced meshes
981 //================================================================================
983 void HYBRIDPlugin_Hypothesis::RestoreEnfElemsByMeshes()
985 THYBRIDEnforcedMeshList::const_iterator it = _enfMeshList.begin();
986 for(;it != _enfMeshList.end();++it) {
987 THYBRIDEnforcedMesh* enfMesh = *it;
988 if ( SMESH_Mesh* mesh = GetMeshByPersistentID( enfMesh->persistID ))
989 SetEnforcedMesh( *mesh,
990 enfMesh->elementType,
993 enfMesh->groupName );
994 enfMesh->persistID = -1; // not to restore again
998 //=======================================================================
999 //function : SetGroupsToRemove
1000 //=======================================================================
1002 void HYBRIDPlugin_Hypothesis::ClearGroupsToRemove()
1004 _groupsToRemove.clear();
1008 //=======================================================================
1009 //function : DefaultMeshHoles
1010 //=======================================================================
1012 bool HYBRIDPlugin_Hypothesis::DefaultMeshHoles()
1014 return false; // PAL19680
1017 //=======================================================================
1018 //function : DefaultToMakeGroupsOfDomains
1019 //=======================================================================
1021 bool HYBRIDPlugin_Hypothesis::DefaultToMakeGroupsOfDomains()
1023 return false; // issue 0022172
1026 //=======================================================================
1027 //function : DefaultMaximumMemory
1028 //=======================================================================
1031 #include <sys/sysinfo.h>
1033 #include <windows.h>
1036 double HYBRIDPlugin_Hypothesis::DefaultMaximumMemory()
1040 int err = sysinfo( &si );
1042 int ramMB = si.totalram * si.mem_unit / 1024 / 1024;
1043 return ( 0.7 * ramMB );
1046 // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
1047 MEMORYSTATUSEX statex;
1048 statex.dwLength = sizeof (statex);
1049 int err = GlobalMemoryStatusEx (&statex);
1052 statex.ullTotalPhys / 1024 / 1024 +
1053 statex.ullTotalPageFile / 1024 / 1024 +
1054 statex.ullTotalVirtual / 1024 / 1024;
1055 return ( 0.7 * totMB );
1061 //=======================================================================
1062 //function : DefaultInitialMemory
1063 //=======================================================================
1065 double HYBRIDPlugin_Hypothesis::DefaultInitialMemory()
1067 return DefaultMaximumMemory();
1070 //=======================================================================
1071 //function : DefaultOptimizationLevel
1072 //=======================================================================
1074 short HYBRIDPlugin_Hypothesis::DefaultOptimizationLevel()
1079 //=======================================================================
1080 //function : DefaultWorkingDirectory
1081 //=======================================================================
1083 std::string HYBRIDPlugin_Hypothesis::DefaultWorkingDirectory()
1085 TCollection_AsciiString aTmpDir;
1087 char *Tmp_dir = getenv("SALOME_TMP_DIR");
1088 if(Tmp_dir != NULL) {
1093 aTmpDir = TCollection_AsciiString("C:\\");
1095 aTmpDir = TCollection_AsciiString("/tmp/");
1098 return aTmpDir.ToCString();
1101 //=======================================================================
1102 //function : DefaultKeepFiles
1103 //=======================================================================
1105 bool HYBRIDPlugin_Hypothesis::DefaultKeepFiles()
1110 //=======================================================================
1111 //function : DefaultRemoveLogOnSuccess
1112 //=======================================================================
1114 bool HYBRIDPlugin_Hypothesis::DefaultRemoveLogOnSuccess()
1120 //=======================================================================
1121 //function : DefaultVerboseLevel
1122 //=======================================================================
1124 short HYBRIDPlugin_Hypothesis::DefaultVerboseLevel()
1129 //=======================================================================
1130 //function : DefaultToCreateNewNodes
1131 //=======================================================================
1133 bool HYBRIDPlugin_Hypothesis::DefaultToCreateNewNodes()
1138 //=======================================================================
1139 //function : DefaultToUseBoundaryRecoveryVersion
1140 //=======================================================================
1142 bool HYBRIDPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion()
1147 //=======================================================================
1148 //function : DefaultToUseFEMCorrection
1149 //=======================================================================
1151 bool HYBRIDPlugin_Hypothesis::DefaultToUseFEMCorrection()
1156 //=======================================================================
1157 //function : DefaultToRemoveCentralPoint
1158 //=======================================================================
1160 bool HYBRIDPlugin_Hypothesis::DefaultToRemoveCentralPoint()
1165 //=======================================================================
1166 //function : DefaultGradation
1167 //=======================================================================
1169 double HYBRIDPlugin_Hypothesis::DefaultGradation()
1174 //=======================================================================
1175 //function : DefaultStandardOutputLog
1176 //=======================================================================
1178 bool HYBRIDPlugin_Hypothesis::DefaultStandardOutputLog()
1183 // //=======================================================================
1184 // //function : DefaultID2SizeMap
1185 // //=======================================================================
1187 // HYBRIDPlugin_Hypothesis::TID2SizeMap HYBRIDPlugin_Hypothesis::DefaultID2SizeMap()
1189 // return HYBRIDPlugin_Hypothesis::TID2SizeMap();
1192 //=======================================================================
1193 //function : DefaultBoundaryLayersInward
1194 //=======================================================================
1195 bool HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersInward()
1200 //=======================================================================
1201 //function : DefaultElemGenTetraDominant
1202 //=======================================================================
1203 bool HYBRIDPlugin_Hypothesis::DefaultElemGenTetraDominant()
1208 //=======================================================================
1209 //function : DefaultAddMultinormals
1210 //=======================================================================
1211 bool HYBRIDPlugin_Hypothesis::DefaultAddMultinormals()
1216 //=======================================================================
1217 //function : DefaultSmoothNormals
1218 //=======================================================================
1219 bool HYBRIDPlugin_Hypothesis::DefaultSmoothNormals()
1224 //=======================================================================
1225 //function : DefaultHeightFirstLayer
1226 //=======================================================================
1227 double HYBRIDPlugin_Hypothesis::DefaultHeightFirstLayer()
1229 return 0.0; //or epsilon?
1232 //=======================================================================
1233 //function : DefaultBoundaryLayersProgression
1234 //=======================================================================
1235 double HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersProgression()
1240 //=======================================================================
1241 //function : DefaultMultinormalsAngle
1242 //=======================================================================
1243 double HYBRIDPlugin_Hypothesis::DefaultMultinormalsAngle()
1248 //=======================================================================
1249 //function : DefaultNbOfBoundaryLayers
1250 //=======================================================================
1251 short HYBRIDPlugin_Hypothesis::DefaultNbOfBoundaryLayers()
1256 //=======================================================================
1258 //=======================================================================
1260 std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save)
1262 save << (int) myBoundaryLayersInward << " ";
1263 save << (int) myElemGenTetraDominant << " ";
1264 save << (int) myAddMultinormals << " ";
1265 save << (int) mySmoothNormals << " ";
1267 save << myNbOfBoundaryLayers << " ";
1268 save << myHeightFirstLayer << " ";
1269 save << myBoundaryLayersProgression << " ";
1270 save << myMultinormalsAngle << " ";
1272 save << (int) myKeepFiles << " ";
1273 save << myWorkingDirectory << " ";
1274 save << myVerboseLevel << " ";
1275 if (!myTextOption.empty()) {
1276 save << "__OPTIONS_BEGIN__ ";
1277 save << myTextOption << " ";
1278 save << "__OPTIONS_END__ ";
1282 THYBRIDEnforcedVertexList::iterator it = _enfVertexList.begin();
1283 if (it != _enfVertexList.end()) {
1284 save << " " << "__ENFORCED_VERTICES_BEGIN__ ";
1285 for ( ; it != _enfVertexList.end(); ++it ) {
1286 THYBRIDEnforcedVertex *enfVertex = (*it);
1287 save << " " << "__BEGIN_VERTEX__";
1288 if (!enfVertex->name.empty()) {
1289 save << " " << "__BEGIN_NAME__";
1290 save << " " << enfVertex->name;
1291 save << " " << "__END_NAME__";
1293 if (!enfVertex->geomEntry.empty()) {
1294 save << " " << "__BEGIN_ENTRY__";
1295 save << " " << enfVertex->geomEntry;
1296 save << " " << enfVertex->isCompound;
1297 save << " " << "__END_ENTRY__";
1299 if (!enfVertex->groupName.empty()) {
1300 save << " " << "__BEGIN_GROUP__";
1301 save << " " << enfVertex->groupName;
1302 save << " " << "__END_GROUP__";
1304 if (enfVertex->coords.size()) {
1305 save << " " << "__BEGIN_COORDS__";
1306 for (int i=0;i<enfVertex->coords.size();i++)
1307 save << " " << enfVertex->coords[i];
1308 save << " " << "__END_COORDS__";
1310 save << " " << "__BEGIN_SIZE__";
1311 save << " " << enfVertex->size;
1312 save << " " << "__END_SIZE__";
1313 save << " " << "__END_VERTEX__";
1315 save << " " << "__ENFORCED_VERTICES_END__ ";
1318 THYBRIDEnforcedMeshList::iterator it_mesh = _enfMeshList.begin();
1319 if (it_mesh != _enfMeshList.end()) {
1320 save << " " << "__ENFORCED_MESHES_BEGIN__ ";
1321 for ( ; it_mesh != _enfMeshList.end(); ++it_mesh ) {
1322 THYBRIDEnforcedMesh *enfMesh = (*it_mesh);
1323 save << " " << "__BEGIN_ENF_MESH__";
1325 save << " " << "__BEGIN_NAME__";
1326 save << " " << enfMesh->name;
1327 save << " " << "__END_NAME__";
1329 save << " " << "__BEGIN_ENTRY__";
1330 save << " " << enfMesh->entry;
1331 save << " " << "__END_ENTRY__";
1333 save << " " << "__BEGIN_ELEM_TYPE__";
1334 save << " " << (int)enfMesh->elementType;
1335 save << " " << "__END_ELEM_TYPE__";
1337 if (!enfMesh->groupName.empty()) {
1338 save << " " << "__BEGIN_GROUP__";
1339 save << " " << enfMesh->groupName;
1340 save << " " << "__END_GROUP__";
1342 save << " " << "__PERSIST_ID__";
1343 save << " " << enfMesh->persistID;
1344 save << " " << "__END_ENF_MESH__";
1345 std::cout << "Saving of enforced mesh " << enfMesh->name.c_str() << " done" << std::endl;
1347 save << " " << "__ENFORCED_MESHES_END__ ";
1352 //=======================================================================
1353 //function : LoadFrom
1354 //=======================================================================
1356 std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load)
1364 myBoundaryLayersInward = (bool) i;
1366 load.clear(ios::badbit | load.rdstate());
1370 myElemGenTetraDominant = (bool) i;
1372 load.clear(ios::badbit | load.rdstate());
1376 myAddMultinormals = (bool) i;
1378 load.clear(ios::badbit | load.rdstate());
1382 mySmoothNormals = (bool) i;
1384 load.clear(ios::badbit | load.rdstate());
1388 myNbOfBoundaryLayers = (short) i;
1390 load.clear(ios::badbit | load.rdstate());
1394 myHeightFirstLayer = d;
1396 load.clear(ios::badbit | load.rdstate());
1400 myBoundaryLayersProgression = d;
1402 load.clear(ios::badbit | load.rdstate());
1406 myMultinormalsAngle = d;
1408 load.clear(ios::badbit | load.rdstate());
1412 myKeepFiles = (bool) i;
1414 load.clear(ios::badbit | load.rdstate());
1416 isOK = (load >> myWorkingDirectory);
1418 if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
1419 myKeepFiles = false;
1420 myWorkingDirectory.clear();
1422 else if ( myWorkingDirectory == "1" ) {
1424 myWorkingDirectory.clear();
1428 load.clear(ios::badbit | load.rdstate());
1430 if ( !myWorkingDirectory.empty() ) {
1435 load.clear(ios::badbit | load.rdstate());
1440 myVerboseLevel = (short) i;
1442 load.clear(ios::badbit | load.rdstate());
1445 std::string separator;
1446 bool hasOptions = false;
1447 bool hasEnforcedVertices = false;
1448 bool hasEnforcedMeshes = false;
1449 isOK = (load >> separator);
1451 if ( isOK && ( separator == "0" || separator == "1" ))
1453 myToMakeGroupsOfDomains = ( separator == "1" );
1454 isOK = (load >> separator);
1458 if (separator == "__OPTIONS_BEGIN__")
1460 else if (separator == "__ENFORCED_VERTICES_BEGIN__")
1461 hasEnforcedVertices = true;
1462 else if (separator == "__ENFORCED_MESHES_BEGIN__")
1463 hasEnforcedMeshes = true;
1469 isOK = (load >> txt);
1471 if (txt == "__OPTIONS_END__") {
1472 if (!myTextOption.empty()) {
1473 // Remove last space
1474 myTextOption.erase(myTextOption.end()-1);
1479 myTextOption += txt;
1480 myTextOption += " ";
1486 isOK = (load >> separator);
1487 if (isOK && separator == "__ENFORCED_VERTICES_BEGIN__")
1488 hasEnforcedVertices = true;
1489 if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
1490 hasEnforcedMeshes = true;
1493 if (hasEnforcedVertices) {
1494 std::string txt, name, entry, groupName;
1495 double size, coords[3];
1497 bool hasCoords = false;
1498 isOK = (load >> txt); // __BEGIN_VERTEX__
1500 if (txt == "__ENFORCED_VERTICES_END__")
1503 THYBRIDEnforcedVertex *enfVertex = new THYBRIDEnforcedVertex();
1505 isOK = (load >> txt);
1506 if (txt == "__END_VERTEX__") {
1507 enfVertex->name = name;
1508 enfVertex->geomEntry = entry;
1509 enfVertex->isCompound = isCompound;
1510 enfVertex->groupName = groupName;
1511 enfVertex->coords.clear();
1513 enfVertex->coords.assign(coords,coords+3);
1515 _enfVertexList.insert(enfVertex);
1517 if (enfVertex->coords.size())
1518 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
1519 if (!enfVertex->geomEntry.empty())
1520 _geomEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
1529 if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
1530 while (isOK && (txt != "__END_NAME__")) {
1531 isOK = (load >> txt);
1532 if (txt != "__END_NAME__") {
1538 MESSAGE("name: " <<name);
1541 if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
1542 isOK = (load >> entry);
1543 isOK = (load >> isCompound);
1544 isOK = (load >> txt); // __END_ENTRY__
1545 if (txt != "__END_ENTRY__")
1546 throw std::exception();
1547 MESSAGE("entry: " << entry);
1550 if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
1551 while (isOK && (txt != "__END_GROUP__")) {
1552 isOK = (load >> txt);
1553 if (txt != "__END_GROUP__") {
1554 if (!groupName.empty())
1559 MESSAGE("groupName: " << groupName);
1562 if (txt == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
1564 isOK = (load >> coords[0] >> coords[1] >> coords[2]);
1565 isOK = (load >> txt); // __END_COORDS__
1566 if (txt != "__END_COORDS__")
1567 throw std::exception();
1568 MESSAGE("coords: " << coords[0] <<","<< coords[1] <<","<< coords[2]);
1571 if (txt == "__BEGIN_SIZE__") { // __BEGIN_ENTRY__
1572 isOK = (load >> size);
1573 isOK = (load >> txt); // __END_ENTRY__
1574 if (txt != "__END_SIZE__") {
1575 throw std::exception();
1577 MESSAGE("size: " << size);
1580 isOK = (load >> txt); // __BEGIN_VERTEX__
1584 if (hasEnforcedVertices) {
1585 isOK = (load >> separator);
1586 if (isOK && separator == "__ENFORCED_MESHES_BEGIN__")
1587 hasEnforcedMeshes = true;
1590 if (hasEnforcedMeshes) {
1591 std::string txt, name, entry, groupName;
1592 int elementType = -1, persistID = -1;
1593 isOK = (load >> txt); // __BEGIN_ENF_MESH__
1596 if (txt == "__ENFORCED_MESHES_END__")
1599 THYBRIDEnforcedMesh *enfMesh = new THYBRIDEnforcedMesh();
1601 isOK = (load >> txt);
1602 if (txt == "__END_ENF_MESH__") {
1603 enfMesh->name = name;
1604 enfMesh->entry = entry;
1605 enfMesh->elementType = (SMESH::ElementType)elementType;
1606 enfMesh->groupName = groupName;
1607 enfMesh->persistID = persistID;
1609 _enfMeshList.insert(enfMesh);
1610 std::cout << "Restoring of enforced mesh " <<name << " done" << std::endl;
1620 if (txt == "__BEGIN_NAME__") { // __BEGIN_NAME__
1621 while (isOK && (txt != "__END_NAME__")) {
1622 isOK = (load >> txt);
1623 if (txt != "__END_NAME__") {
1629 MESSAGE("name: " <<name);
1632 if (txt == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
1633 isOK = (load >> entry);
1634 isOK = (load >> txt); // __END_ENTRY__
1635 if (txt != "__END_ENTRY__")
1636 throw std::exception();
1637 MESSAGE("entry: " << entry);
1640 if (txt == "__BEGIN_ELEM_TYPE__") { // __BEGIN_ELEM_TYPE__
1641 isOK = (load >> elementType);
1642 isOK = (load >> txt); // __END_ELEM_TYPE__
1643 if (txt != "__END_ELEM_TYPE__")
1644 throw std::exception();
1645 MESSAGE("elementType: " << elementType);
1648 if (txt == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
1649 while (isOK && (txt != "__END_GROUP__")) {
1650 isOK = (load >> txt);
1651 if (txt != "__END_GROUP__") {
1652 if (!groupName.empty())
1657 MESSAGE("groupName: " << groupName);
1660 if (txt == "__PERSIST_ID__") {
1661 isOK = (load >> persistID);
1662 MESSAGE("persistID: " << persistID);
1664 std::cout << "isOK: " << isOK << std::endl;
1667 isOK = (load >> txt); // __BEGIN_ENF_MESH__
1674 //=======================================================================
1675 //function : SetParametersByMesh
1676 //=======================================================================
1678 bool HYBRIDPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&)
1684 //================================================================================
1686 * \brief Sets myToMakeGroupsOfDomains depending on whether theMesh is on shape or not
1688 //================================================================================
1690 bool HYBRIDPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts,
1691 const SMESH_Mesh* /*theMesh*/)
1693 myToMakeGroupsOfDomains = ( !dflts._shape || dflts._shape->IsNull() );
1697 //================================================================================
1699 * \brief Return command to run hybrid mesher excluding file prefix (-f)
1701 //================================================================================
1703 std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp,
1704 const bool hasShapeToMesh)
1706 TCollection_AsciiString cmd = GetExeName().c_str();
1707 // check if any option is overridden by hyp->myTextOption
1708 bool p_v = hyp ? ( hyp->myTextOption.find("-v") == std::string::npos ) : true;
1709 //bool p_i = hyp ? ( hyp->myTextOption.find("-i") == std::string::npos ) : true;
1710 bool p_o = hyp ? ( hyp->myTextOption.find("-o") == std::string::npos ) : true;
1711 bool p_blsi = hyp ? ( hyp->myTextOption.find("-blsi") == std::string::npos ) : true;
1712 bool p_blsd = hyp ? ( hyp->myTextOption.find("-blsd") == std::string::npos ) : true;
1713 bool p_hotfl = hyp ? ( hyp->myTextOption.find("-hotfl") == std::string::npos ) : true;
1714 bool p_nobl = hyp ? ( hyp->myTextOption.find("-nobl") == std::string::npos ) : true;
1715 bool p_blgp = hyp ? ( hyp->myTextOption.find("-blgp") == std::string::npos ) : true;
1716 bool p_eg = hyp ? ( hyp->myTextOption.find("-eg") == std::string::npos ) : true;
1717 bool p_am = hyp ? ( hyp->myTextOption.find("-am") == std::string::npos ) : true;
1718 bool p_mat = hyp ? ( hyp->myTextOption.find("-mat") == std::string::npos ) : true;
1719 bool p_sn = hyp ? ( hyp->myTextOption.find("-sn") == std::string::npos ) : true;
1724 cmd += hyp->myVerboseLevel;
1728 if ( hyp && !hyp->myTextOption.empty() ) {
1730 cmd += (char*) hyp->myTextOption.c_str();
1737 return cmd.ToCString();
1740 //================================================================================
1742 * \brief Return a unique file name
1744 //================================================================================
1746 std::string HYBRIDPlugin_Hypothesis::GetFileName(const HYBRIDPlugin_Hypothesis* hyp)
1748 std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory();
1749 const char lastChar = *aTmpDir.rbegin();
1751 if(lastChar != '\\') aTmpDir+='\\';
1753 if(lastChar != '/') aTmpDir+='/';
1756 TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str();
1757 aGenericName += "HYBRID_";
1758 aGenericName += getpid();
1759 aGenericName += "_";
1760 aGenericName += Abs((Standard_Integer)(long) aGenericName.ToCString());
1762 return aGenericName.ToCString();
1765 //================================================================================
1767 * Return the name of executable
1769 //================================================================================
1771 std::string HYBRIDPlugin_Hypothesis::GetExeName()
1773 return "mg-hybrid.exe";
1776 //================================================================================
1778 * \brief Return the enforced vertices
1780 //================================================================================
1782 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexList HYBRIDPlugin_Hypothesis::GetEnforcedVertices(const HYBRIDPlugin_Hypothesis* hyp)
1784 return hyp ? hyp->_GetEnforcedVertices():DefaultHYBRIDEnforcedVertexList();
1787 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexCoordsValues HYBRIDPlugin_Hypothesis::GetEnforcedVerticesCoordsSize (const HYBRIDPlugin_Hypothesis* hyp)
1789 return hyp ? hyp->_GetEnforcedVerticesCoordsSize(): DefaultHYBRIDEnforcedVertexCoordsValues();
1792 HYBRIDPlugin_Hypothesis::THYBRIDEnforcedVertexEntryValues HYBRIDPlugin_Hypothesis::GetEnforcedVerticesEntrySize (const HYBRIDPlugin_Hypothesis* hyp)
1794 return hyp ? hyp->_GetEnforcedVerticesEntrySize(): DefaultHYBRIDEnforcedVertexEntryValues();
1797 HYBRIDPlugin_Hypothesis::TCoordsHYBRIDEnforcedVertexMap HYBRIDPlugin_Hypothesis::GetEnforcedVerticesByCoords (const HYBRIDPlugin_Hypothesis* hyp)
1799 return hyp ? hyp->_GetEnforcedVerticesByCoords(): DefaultCoordsHYBRIDEnforcedVertexMap();
1802 HYBRIDPlugin_Hypothesis::TGeomEntryHYBRIDEnforcedVertexMap HYBRIDPlugin_Hypothesis::GetEnforcedVerticesByEntry (const HYBRIDPlugin_Hypothesis* hyp)
1804 return hyp ? hyp->_GetEnforcedVerticesByEntry(): DefaultGeomEntryHYBRIDEnforcedVertexMap();
1807 HYBRIDPlugin_Hypothesis::TIDSortedNodeGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedNodes(const HYBRIDPlugin_Hypothesis* hyp)
1809 return hyp ? hyp->_GetEnforcedNodes():DefaultIDSortedNodeGroupMap();
1812 HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedEdges(const HYBRIDPlugin_Hypothesis* hyp)
1814 return hyp ? hyp->_GetEnforcedEdges():DefaultIDSortedElemGroupMap();
1817 HYBRIDPlugin_Hypothesis::TIDSortedElemGroupMap HYBRIDPlugin_Hypothesis::GetEnforcedTriangles(const HYBRIDPlugin_Hypothesis* hyp)
1819 return hyp ? hyp->_GetEnforcedTriangles():DefaultIDSortedElemGroupMap();
1822 HYBRIDPlugin_Hypothesis::TID2SizeMap HYBRIDPlugin_Hypothesis::GetNodeIDToSizeMap(const HYBRIDPlugin_Hypothesis* hyp)
1824 return hyp ? hyp->_GetNodeIDToSizeMap(): DefaultID2SizeMap();
1827 HYBRIDPlugin_Hypothesis::TSetStrings HYBRIDPlugin_Hypothesis::GetGroupsToRemove(const HYBRIDPlugin_Hypothesis* hyp)
1829 return hyp ? hyp->_GetGroupsToRemove(): DefaultGroupsToRemove();