1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_HypothesesUtils.cxx
25 // Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
28 #include "SMESHGUI_HypothesesUtils.h"
31 #include "SMESHGUI_GEOMGenUtils.h"
32 #include "SMESHGUI_Hypotheses.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_XmlHandler.h"
37 #include <SMESH_Actor.h>
38 #include <SMESH_TryCatch.hxx>
40 // SALOME GUI includes
41 #include <SUIT_Desktop.h>
42 #include <SUIT_MessageBox.h>
43 #include <SUIT_OverrideCursor.h>
44 #include <SUIT_ResourceMgr.h>
46 #include <SalomeApp_Study.h>
47 #include <SalomeApp_Tools.h>
49 // SALOME KERNEL includes
50 #include <utilities.h>
67 #define LibHandle HMODULE
68 #define LoadLib( name ) LoadLibrary( name )
69 #define GetProc GetProcAddress
70 #define UnLoadLib( handle ) FreeLibrary( handle );
73 #define LibHandle void*
75 #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_LOCAL )
76 #else // DYNLOAD_LOCAL
77 #define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL )
78 #endif // DYNLOAD_LOCAL
80 #define UnLoadLib( handle ) dlclose( handle );
86 typedef IMap<QString,HypothesisData*> THypothesisDataMap;
87 THypothesisDataMap myHypothesesMap;
88 THypothesisDataMap myAlgorithmsMap;
91 //typedef QMap<QString,SMESHGUI_GenericHypothesisCreator*> THypCreatorMap;
92 //THypCreatorMap myHypCreatorMap;
94 QList<HypothesesSet*> myListOfHypothesesSets;
96 void processHypothesisStatus(const int theHypStatus,
97 SMESH::SMESH_Hypothesis_ptr theHyp,
98 const bool theIsAddition,
99 const char* theError = 0)
101 if (theHypStatus > SMESH::HYP_OK) {
103 QString aHypName ("NULL Hypothesis");
104 if (!CORBA::is_nil(theHyp)) {
105 _PTR(SObject) Shyp = SMESH::FindSObject(theHyp);
108 aHypName = Shyp->GetName().c_str();
112 CORBA::String_var hypType = theHyp->GetName();
113 aHypName = GetHypothesisData( hypType.in() )->Label;
118 bool isFatal = (theHypStatus >= SMESH::HYP_UNKNOWN_FATAL);
121 aMsg = (isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN");
123 aMsg = (isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN");
125 aMsg = QObject::tr(aMsg.toLatin1().data()).arg(aHypName);
127 if ( theError && theError[0] )
133 aMsg += QObject::tr(QString("SMESH_HYP_%1").arg(theHypStatus).toLatin1().data());
135 if ( theHypStatus == SMESH::HYP_HIDDEN_ALGO ) { // PAL18501
136 CORBA::String_var hypType = theHyp->GetName();
137 if ( HypothesisData* hd = GetHypothesisData( hypType.in() ))
138 aMsg = aMsg.arg( hd->Dim[0] );
141 SUIT_MessageBox::warning(SMESHGUI::desktop(),
142 QObject::tr("SMESH_WRN_WARNING"),
147 //================================================================================
149 * \brief Prepends dimension and appends '[custom]' to the name of hypothesis set
151 //================================================================================
153 static QString mangledHypoSetName(HypothesesSet* hypSet)
155 QString name = hypSet->name();
158 int dim = hypSet->maxDim();
160 name = QString("%1D: %2").arg(dim).arg(name);
163 if ( hypSet->getIsCustom() )
164 name = QString("%1 [custom]").arg(name);
169 //================================================================================
171 * \brief Removes dimension and '[custom]' from the name of hypothesis set
173 //================================================================================
175 static QString demangledHypoSetName(QString name)
177 name.remove(QRegExp("[0-3]D: "));
178 name.remove(" [custom]");
182 void InitAvailableHypotheses()
184 SUIT_OverrideCursor wc;
185 if ( myHypothesesMap.empty() && myAlgorithmsMap.empty() )
188 SUIT_ResourceMgr* resMgr = SMESHGUI::resourceMgr();
191 // Find name of a resource XML file ("SMESH_Meshers.xml");
193 char* cenv = getenv("SMESH_MeshersList");
195 HypsXml.sprintf("%s", cenv);
197 QStringList HypsXmlList = HypsXml.split(env_sep, QString::SkipEmptyParts);
198 if (HypsXmlList.count() == 0) {
199 SUIT_MessageBox::critical(SMESHGUI::desktop(),
200 QObject::tr("SMESH_WRN_WARNING"),
201 QObject::tr("MESHERS_FILE_NO_VARIABLE"));
204 // get full names of xml files from HypsXmlList
205 QStringList xmlFiles;
206 xmlFiles.append( QDir::home().filePath("CustomMeshers.xml")); // may be inexistent
207 for (int i = 0; i < HypsXmlList.count(); i++) {
208 QString HypsXml = HypsXmlList[ i ];
210 // Find full path to the resource XML file
211 QString xmlFile = resMgr->path("resources", "SMESH", HypsXml + ".xml");
212 if ( xmlFile.isEmpty() ) // try PLUGIN resources
213 xmlFile = resMgr->path("resources", HypsXml, HypsXml + ".xml");
214 if ( !xmlFile.isEmpty() )
215 xmlFiles.append( xmlFile );
219 QString aNoAccessFiles;
220 for (int i = 0; i < xmlFiles.count(); i++)
222 QString xmlFile = xmlFiles[ i ];
223 QFile file (xmlFile);
224 if (file.exists() && file.open(QIODevice::ReadOnly))
228 SMESHGUI_XmlHandler* aXmlHandler = new SMESHGUI_XmlHandler();
231 QXmlInputSource source (&file);
232 QXmlSimpleReader reader;
233 reader.setContentHandler(aXmlHandler);
234 reader.setErrorHandler(aXmlHandler);
235 bool ok = reader.parse(source);
239 THypothesisDataMap::ConstIterator it1 = aXmlHandler->myHypothesesMap.begin();
241 for( ;it1 != aXmlHandler->myHypothesesMap.end(); it1++)
242 myHypothesesMap.insert( it1.key(), it1.value() );
244 it1 = aXmlHandler->myAlgorithmsMap.begin();
245 for( ;it1 != aXmlHandler->myAlgorithmsMap.end(); it1++)
246 myAlgorithmsMap.insert( it1.key(), it1.value() );
248 QList<HypothesesSet*>::iterator it;
249 for ( it = aXmlHandler->myListOfHypothesesSets.begin();
250 it != aXmlHandler->myListOfHypothesesSets.end();
253 (*it)->setIsCustom( i == 0 );
254 myListOfHypothesesSets.append( *it );
258 SUIT_MessageBox::critical(SMESHGUI::desktop(),
259 QObject::tr("INF_PARSE_ERROR"),
260 QObject::tr(aXmlHandler->errorProtocol().toLatin1().data()));
264 else if ( i > 0 ) { // 1st is ~/CustomMeshers.xml
265 if (aNoAccessFiles.isEmpty())
266 aNoAccessFiles = xmlFile;
268 aNoAccessFiles += ", " + xmlFile;
270 } // end loop on xmlFiles
273 if (!aNoAccessFiles.isEmpty()) {
274 QString aMess = QObject::tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n";
275 aMess += QObject::tr("MESHERS_FILE_CHECK_VARIABLE");
277 SUIT_MessageBox::warning(SMESHGUI::desktop(),
278 QObject::tr("SMESH_WRN_WARNING"),
286 QStringList GetAvailableHypotheses( const bool isAlgo,
289 const bool hasGeometry,
290 const bool isSubMesh)
292 QStringList aHypList;
294 // Init list of available hypotheses, if needed
295 InitAvailableHypotheses();
296 bool checkGeometry = ( isAlgo );
297 const char* context = isSubMesh ? "LOCAL" : "GLOBAL";
298 // fill list of hypotheses/algorithms
299 THypothesisDataMap& pMap = isAlgo ? myAlgorithmsMap : myHypothesesMap;
300 THypothesisDataMap::ConstIterator anIter;
301 for ( anIter = pMap.begin(); anIter != pMap.end(); anIter++ )
303 HypothesisData* aData = anIter.value();
304 if (( aData && !aData->Label.isEmpty() ) &&
305 ( theDim < 0 || aData->Dim.contains( theDim )) &&
306 ( isAlgo || aData->IsAuxOrNeedHyp == isAux ) &&
307 ( aData->Context == "ANY" || aData->Context == context ) &&
308 ( !checkGeometry || (!aData->IsNeedGeometry ||
309 ( aData->IsNeedGeometry > 0 ) == hasGeometry)))
311 aHypList.append(anIter.key());
318 QStringList GetHypothesesSets(int maxDim)
320 QStringList aSetNameList;
322 // Init list of available hypotheses, if needed
323 InitAvailableHypotheses();
324 QList<HypothesesSet*>::iterator hypoSet;
325 for ( hypoSet = myListOfHypothesesSets.begin();
326 hypoSet != myListOfHypothesesSets.end();
328 HypothesesSet* aSet = *hypoSet;
329 if ( aSet && 0 <= aSet->maxDim() && aSet->maxDim() <= maxDim )
331 aSetNameList.append( mangledHypoSetName( aSet ));
334 aSetNameList.removeDuplicates();
337 // reverse order of aSetNameList
338 QStringList reversedNames;
339 for ( int i = 0; i < aSetNameList.count(); ++i )
340 reversedNames.prepend( aSetNameList[i] );
342 return reversedNames;
345 HypothesesSet* GetHypothesesSet(const QString& theSetName)
347 QString name = demangledHypoSetName( theSetName );
348 QList<HypothesesSet*>::iterator hypoSet;
349 for ( hypoSet = myListOfHypothesesSets.begin();
350 hypoSet != myListOfHypothesesSets.end();
352 HypothesesSet* aSet = *hypoSet;
353 if ( aSet && aSet->name() == name )
359 HypothesisData* GetHypothesisData (const QString& aHypType)
361 HypothesisData* aHypData = 0;
363 // Init list of available hypotheses, if needed
364 InitAvailableHypotheses();
366 if (myHypothesesMap.contains(aHypType)) {
367 aHypData = myHypothesesMap[aHypType];
369 else if (myAlgorithmsMap.contains(aHypType)) {
370 aHypData = myAlgorithmsMap[aHypType];
375 //================================================================================
377 * \brief Return the HypothesisData holding a name of a group of hypotheses
378 * a given hypothesis belongs to
380 //================================================================================
382 HypothesisData* GetGroupTitle( const HypothesisData* hyp, const bool isAlgo )
384 static std::vector< std::vector< HypothesisData > > theGroups;
385 if ( theGroups.empty() )
387 theGroups.resize(14); // 14: isAlgo * 10 + dim
389 QString dummyS("GROUP");
390 QList<int> dummyIL; dummyIL << 1;
392 HypothesisData group( dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,dummyS,-1,-1,
393 dummyIL, 0, dummySL,dummySL,dummySL,dummySL,0,0 );
396 theGroups[ key ].push_back( group );
401 group.Label = "GROUP:" + QObject::tr( "SMESH_1D_ALGO_GROUP_BASIC" );
402 theGroups[ key ].push_back( group );
404 group.Label = "GROUP:" + QObject::tr( "SMESH_1D_ALGO_GROUP_ADVANCED" );
405 theGroups[ key ].push_back( group );
410 group.Label = "GROUP:" + QObject::tr( "SMESH_1D_HYP_GROUP_BASIC" );
411 theGroups[ key ].push_back( group );
413 group.Label = "GROUP:" + QObject::tr( "SMESH_1D_HYP_GROUP_PROGRESSION" );
414 theGroups[ key ].push_back( group );
416 group.Label = "GROUP:" + QObject::tr( "SMESH_1D_HYP_GROUP_ADVANCED" );
417 theGroups[ key ].push_back( group );
422 group.Label = "GROUP:" + QObject::tr( "SMESH_2D_ALGO_GROUP_REGULAR" );
423 theGroups[ key ].push_back( group );
425 group.Label = "GROUP:" + QObject::tr( "SMESH_2D_ALGO_GROUP_FREE" );
426 theGroups[ key ].push_back( group );
428 group.Label = "GROUP:" + QObject::tr( "SMESH_2D_ALGO_GROUP_ADVANCED" );
429 theGroups[ key ].push_back( group );
434 group.Label = "GROUP:" + QObject::tr( "SMESH_3D_ALGO_GROUP_REGULAR" );
435 theGroups[ key ].push_back( group );
437 group.Label = "GROUP:" + QObject::tr( "SMESH_3D_ALGO_GROUP_FREE" );
438 theGroups[ key ].push_back( group );
440 group.Label = "GROUP:" + QObject::tr( "SMESH_3D_ALGO_GROUP_ADVANCED" );
441 theGroups[ key ].push_back( group );
444 size_t key = 0, groupID = 0;
445 if ( hyp && !hyp->Dim.isEmpty() )
447 key = hyp->Dim[0] + isAlgo * 10;
448 groupID = hyp->GroupID;
451 if ( key < theGroups.size() && !theGroups[ key ].empty() )
453 std::vector< HypothesisData > & group = theGroups[ key ];
454 return & ( groupID < group.size() ? group[ groupID ] : group.back() );
456 return & theGroups[ 0 ][ 0 ];
459 bool IsAvailableHypothesis(const HypothesisData* algoData,
460 const QString& hypType,
466 if ( algoData->BasicHypos.contains( hypType ))
468 if ( algoData->OptionalHypos.contains( hypType )) {
475 bool IsCompatibleAlgorithm(const HypothesisData* algo1Data,
476 const HypothesisData* algo2Data)
478 if ( !algo1Data || !algo2Data )
480 const HypothesisData* algoIn = algo1Data, *algoMain = algo2Data;
481 if ( algoIn->Dim.first() > algoMain->Dim.first() ) {
482 algoIn = algo2Data; algoMain = algo1Data;
484 // look for any output type of algoIn between input types of algoMain
485 QStringList::const_iterator inElemType = algoIn->OutputTypes.begin();
486 for ( ; inElemType != algoIn->OutputTypes.end(); ++inElemType )
487 if ( algoMain->InputTypes.contains( *inElemType ))
492 SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator(const QString& aHypType)
494 MESSAGE("Get HypothesisCreator for " << aHypType.toLatin1().data());
496 SMESHGUI_GenericHypothesisCreator* aCreator = 0;
498 // check, if creator for this hypothesis type already exists
500 //if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) {
501 // aCreator = myHypCreatorMap[aHypType];
505 // 1. Init list of available hypotheses, if needed
506 InitAvailableHypotheses();
508 // 2. Get names of plugin libraries
509 HypothesisData* aHypData = GetHypothesisData(aHypType);
513 QString aClientLibName = aHypData->ClientLibName;
514 QString aServerLibName = aHypData->ServerLibName;
516 // 3. Load Client Plugin Library
518 // load plugin library
519 MESSAGE("Loading client meshers plugin library ...");
522 LPTSTR path = new TCHAR[aClientLibName.length() + 1];
523 path[aClientLibName.toWCharArray(path)] = '\0';
525 QByteArray baPath = aClientLibName.toUtf8();
526 const char* path = baPath.data();
529 QByteArray baPath = aClientLibName.toUtf8();
530 char* path = baPath.data();
532 LibHandle libHandle = LoadLib( path );
533 #if defined(WIN32) && defined(UNICODE)
537 // report any error, if occurred
540 const char* anError = "Can't load client meshers plugin library";
542 const char* anError = dlerror();
544 INFOS(anError); // always display this kind of error !
548 // get method, returning hypothesis creator
549 MESSAGE("Find GetHypothesisCreator() method ...");
550 typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \
552 GetHypothesisCreator procHandle =
553 (GetHypothesisCreator)GetProc(libHandle, "GetHypothesisCreator");
555 MESSAGE("bad hypothesis client plugin library");
556 UnLoadLib(libHandle);
559 // get hypothesis creator
560 MESSAGE("Get Hypothesis Creator for " << aHypType.toLatin1().data());
561 aCreator = procHandle( aHypType );
563 MESSAGE("no such a hypothesis in this plugin");
566 // map hypothesis creator to a hypothesis name
568 //myHypCreatorMap[aHypType] = aCreator;
570 //rnv : This dynamic property of the QObject stores the name of the plugin.
571 // It is used to obtain plugin root dir environment variable
572 // in the SMESHGUI_HypothesisDlg class. Plugin root dir environment
573 // variable is used to display documentation.
574 aCreator->setProperty(SMESH::Plugin_Name(),aHypData->PluginName);
579 catch (const SALOME::SALOME_Exception& S_ex) {
580 SalomeApp_Tools::QtCatchCorbaException(S_ex);
588 SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const QString& aHypType,
589 const QString& aHypName,
590 const bool /*isAlgo*/)
592 MESSAGE("Create " << aHypType.toLatin1().data() <<
593 " with name " << aHypName.toLatin1().data());
594 HypothesisData* aHypData = GetHypothesisData(aHypType);
595 QString aServLib = aHypData->ServerLibName;
597 SMESH::SMESH_Hypothesis_var aHypothesis;
598 aHypothesis = SMESHGUI::GetSMESHGen()->CreateHypothesis(aHypType.toLatin1().data(),
599 aServLib.toUtf8().data());
600 if (!aHypothesis->_is_nil()) {
601 _PTR(SObject) aHypSObject = SMESH::FindSObject(aHypothesis.in());
603 if (!aHypName.isEmpty())
604 SMESH::SetName(aHypSObject, aHypName);
605 SMESHGUI::Modified();
606 SMESHGUI::GetSMESHGUI()->updateObjBrowser();
607 return aHypothesis._retn();
610 } catch (const SALOME::SALOME_Exception & S_ex) {
611 SalomeApp_Tools::QtCatchCorbaException(S_ex);
614 return SMESH::SMESH_Hypothesis::_nil();
617 bool IsApplicable(const QString& aHypType,
618 GEOM::GEOM_Object_ptr theGeomObject,
619 const bool toCheckAll)
621 if ( getenv("NO_LIMIT_ALGO_BY_SHAPE")) // allow a workaround for a case if
622 return true; // IsApplicable() returns false due to a bug
624 HypothesisData* aHypData = GetHypothesisData(aHypType);
625 QString aServLib = aHypData->ServerLibName;
627 return SMESHGUI::GetSMESHGen()->IsApplicable( aHypType.toLatin1().data(),
628 aServLib.toUtf8().data(),
631 SMESH_CATCH( SMESH::printErrorInDebugMode );
636 bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
638 MESSAGE ("SMESHGUI::AddHypothesisOnMesh");
639 int res = SMESH::HYP_UNKNOWN_FATAL;
640 SUIT_OverrideCursor wc;
642 if (!aMesh->_is_nil()) {
643 _PTR(SObject) SM = SMESH::FindSObject(aMesh);
644 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM);
646 CORBA::String_var error;
647 res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out());
648 if (res > SMESH::HYP_OK) {
650 processHypothesisStatus(res, aHyp, true, error.in() );
654 catch(const SALOME::SALOME_Exception& S_ex) {
656 SalomeApp_Tools::QtCatchCorbaException(S_ex);
657 res = SMESH::HYP_UNKNOWN_FATAL;
660 return res < SMESH::HYP_UNKNOWN_FATAL;
664 bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp)
666 MESSAGE("SMESHGUI::AddHypothesisOnSubMesh() ");
667 int res = SMESH::HYP_UNKNOWN_FATAL;
668 SUIT_OverrideCursor wc;
670 if ( !aSubMesh->_is_nil() && !aHyp->_is_nil() ) {
672 SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather();
673 _PTR(SObject) SsubM = SMESH::FindSObject(aSubMesh);
674 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SsubM);
675 if (!aMesh->_is_nil() && SsubM && !aShapeObject->_is_nil())
677 CORBA::String_var error;
678 res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() );
679 if (res > SMESH::HYP_OK) {
681 processHypothesisStatus( res, aHyp, true, error.in() );
686 SCRUTE(aHyp->_is_nil());
687 SCRUTE(aMesh->_is_nil());
689 SCRUTE(aShapeObject->_is_nil());
692 catch(const SALOME::SALOME_Exception& S_ex) {
694 SalomeApp_Tools::QtCatchCorbaException(S_ex);
695 res = SMESH::HYP_UNKNOWN_FATAL;
699 SCRUTE(aSubMesh->_is_nil());
700 SCRUTE(aHyp->_is_nil());
702 return res < SMESH::HYP_UNKNOWN_FATAL;
705 bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject)
707 int res = SMESH::HYP_UNKNOWN_FATAL;
708 SUIT_OverrideCursor wc;
711 _PTR(Study) aStudy = getStudy();
712 _PTR(SObject) aHypObj = aStudy->FindObjectID( IObject->getEntry() );
715 _PTR(SObject) MorSM = SMESH::GetMeshOrSubmesh( aHypObj );
716 _PTR(SObject) aRealHypo;
717 if( aHypObj->ReferencedObject( aRealHypo ) )
719 SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aRealHypo ) );
720 RemoveHypothesisOrAlgorithmOnMesh( MorSM, hypo );
724 SMESH_Hypothesis_var hypo = SMESH_Hypothesis::_narrow( SObjectToObject( aHypObj ) );
725 SObjectList meshList = GetMeshesUsingAlgoOrHypothesis( hypo );
726 for( size_t i = 0; i < meshList.size(); i++ )
727 RemoveHypothesisOrAlgorithmOnMesh( meshList[ i ], hypo );
731 catch(const SALOME::SALOME_Exception& S_ex)
734 SalomeApp_Tools::QtCatchCorbaException(S_ex);
735 res = SMESH::HYP_UNKNOWN_FATAL;
737 return res < SMESH::HYP_UNKNOWN_FATAL;
740 bool RemoveHypothesisOrAlgorithmOnMesh (_PTR(SObject) MorSM,
741 SMESH::SMESH_Hypothesis_ptr anHyp)
743 int res = SMESH::HYP_UNKNOWN_FATAL;
744 SUIT_OverrideCursor wc;
748 GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM);
749 SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>(MorSM);
750 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface<SMESH::SMESH_subMesh>(MorSM);
752 if (!aSubMesh->_is_nil())
753 aMesh = aSubMesh->GetFather();
755 if (!aMesh->_is_nil()) {
756 if (aMesh->HasShapeToMesh() && !aShapeObject->_is_nil()) {
757 res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
759 else if(!aMesh->HasShapeToMesh()){
760 res = aMesh->RemoveHypothesis(aShapeObject, anHyp);
762 if (res > SMESH::HYP_OK) {
764 processHypothesisStatus(res, anHyp, false);
767 if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) )
769 if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() ))
770 if( actor->GetVisibility() )
774 } catch(const SALOME::SALOME_Exception& S_ex) {
776 SalomeApp_Tools::QtCatchCorbaException(S_ex);
777 res = SMESH::HYP_UNKNOWN_FATAL;
780 return res < SMESH::HYP_UNKNOWN_FATAL;
783 SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp)
785 SObjectList listSOmesh;
786 listSOmesh.resize(0);
788 unsigned int index = 0;
789 if (!AlgoOrHyp->_is_nil()) {
790 _PTR(SObject) SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp);
792 SObjectList listSO = SMESH::getStudy()->FindDependances(SO_Hypothesis);
794 MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<<listSO.size());
795 for (unsigned int i = 0; i < listSO.size(); i++) {
796 _PTR(SObject) SO = listSO[i];
798 _PTR(SObject) aFather = SO->GetFather();
800 _PTR(SObject) SOfatherFather = aFather->GetFather();
801 if (SOfatherFather) {
802 MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list");
804 listSOmesh.resize(index);
805 listSOmesh[index - 1] = SOfatherFather;
812 MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed");
816 #define CASE2MESSAGE(enum) case SMESH::enum: msg = QObject::tr( "STATE_" #enum ); break;
817 QString GetMessageOnAlgoStateErrors(const algo_error_array& errors)
819 QString resMsg; // PAL14861 = QObject::tr("SMESH_WRN_MISSING_PARAMETERS") + ":\n";
820 for ( size_t i = 0; i < errors.length(); ++i ) {
821 const SMESH::AlgoStateError & error = errors[ i ];
822 const bool hasAlgo = ( strlen( error.algoName ) != 0 );
825 msg = QObject::tr( "STATE_ALGO_MISSING" );
827 switch( error.state ) {
828 CASE2MESSAGE( HYP_MISSING );
829 CASE2MESSAGE( HYP_NOTCONFORM );
830 CASE2MESSAGE( HYP_BAD_PARAMETER );
831 CASE2MESSAGE( HYP_BAD_GEOMETRY );
834 // apply args to message:
837 msg = msg.arg( error.algoName.in() );
839 msg = msg.arg( error.algoDim );
841 msg = msg.arg( QObject::tr( error.isGlobalAlgo ? "GLOBAL_ALGO" : "LOCAL_ALGO" ));
842 // %4 - hypothesis dim == algoDim
843 msg = msg.arg( error.algoDim );
845 if ( i ) resMsg += ";\n";
850 } // end of namespace SMESH