From 04a0c33ea9241d0d7cb5e1672c853c869919b4d8 Mon Sep 17 00:00:00 2001 From: ptv Date: Mon, 1 Dec 2008 12:18:59 +0000 Subject: [PATCH] Imp 19925 - Mesh preview --- src/SMESHGUI/SMESHGUI.cxx | 21 +- src/SMESHGUI/SMESHGUI_ComputeDlg.cxx | 705 +++++++++++++++++++++++---- src/SMESHGUI/SMESHGUI_ComputeDlg.h | 128 ++++- src/SMESHGUI/SMESH_images.ts | 4 + src/SMESHGUI/SMESH_msg_en.ts | 44 ++ src/SMESH_I/SMESH_Gen_i.cxx | 194 +++++++- src/SMESH_I/SMESH_Gen_i.hxx | 11 + src/SMESH_I/SMESH_Mesh_i.cxx | 20 +- src/SMESH_I/SMESH_Mesh_i.hxx | 3 + src/SMESH_SWIG/smeshDC.py | 10 + 10 files changed, 1014 insertions(+), 126 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 07f2044b3..5ccf0626b 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -1564,21 +1564,17 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } case 701: // COMPUTE MESH + case 711: // PRECOMPUTE MESH { if (checkLock(aStudy)) break; - - startOperation( 701 ); + startOperation( theCommandID ); } break; - case 702: // Create mesh - startOperation( 702 ); - break; - case 703: // Create sub-mesh - startOperation( 703 ); - break; + case 702: // Create mesh + case 703: // Create sub-mesh case 704: // Edit mesh/sub-mesh - startOperation( 704 ); + startOperation( theCommandID ); break; case 710: // Build compound mesh { @@ -2605,6 +2601,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createSMESHAction( 703, "CREATE_SUBMESH", "ICON_DLG_ADD_SUBMESH" ); createSMESHAction( 704, "EDIT_MESHSUBMESH","ICON_DLG_EDIT_MESH" ); createSMESHAction( 710, "BUILD_COMPOUND", "ICON_BUILD_COMPOUND" ); + createSMESHAction( 711, "PRECOMPUTE", "ICON_PRECOMPUTE" ); createSMESHAction( 806, "CREATE_GEO_GROUP","ICON_CREATE_GEO_GROUP" ); createSMESHAction( 801, "CREATE_GROUP", "ICON_CREATE_GROUP" ); createSMESHAction( 802, "CONSTRUCT_GROUP", "ICON_CONSTRUCT_GROUP" ); @@ -2741,6 +2738,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createMenu( 710, meshId, -1 ); createMenu( separator(), meshId, -1 ); createMenu( 701, meshId, -1 ); + createMenu( 711, meshId, -1 ); createMenu( separator(), meshId, -1 ); createMenu( 801, meshId, -1 ); createMenu( 806, meshId, -1 ); @@ -2838,6 +2836,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createTool( 710, meshTb ); createTool( separator(), meshTb ); createTool( 701, meshTb ); + createTool( 711, meshTb ); createTool( separator(), meshTb ); createTool( 801, meshTb ); createTool( 806, meshTb ); @@ -2947,6 +2946,7 @@ void SMESHGUI::initialize( CAM_Application* app ) createPopupItem( 803, OB, group ); // EDIT_GROUP popupMgr()->insert( separator(), -1, 0 ); createPopupItem( 701, OB, mesh, "&& isComputable" ); // COMPUTE + createPopupItem( 711, OB, mesh, "&& isComputable" ); // PRECOMPUTE createPopupItem( 214, OB, mesh_group ); // UPDATE createPopupItem( 900, OB, mesh_group ); // ADV_INFO createPopupItem( 902, OB, mesh ); // STD_INFO @@ -3689,6 +3689,9 @@ LightApp_Operation* SMESHGUI::createOperation( const int id ) const case 704: // Edit mesh/sub-mesh op = new SMESHGUI_MeshOp( false ); break; + case 711: // Precompute mesh + op = new SMESHGUI_PrecomputeOp(); + break; case 806: // Create group on geom op = new SMESHGUI_GroupOnShapeOp(); break; diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index d62255d86..e818a76fa 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -50,8 +50,10 @@ #include #include #include +#include // SALOME KERNEL includes +#include #include // OCCT includes @@ -84,10 +86,6 @@ // VTK includes #include -// IDL includes -#include -#include CORBA_SERVER_HEADER(SMESH_Gen) - // STL includes #include #include @@ -790,7 +788,8 @@ void SMESHGUI_MeshInfosBox::SetInfoByMesh(SMESH::SMESH_Mesh_var mesh) */ //======================================================================= -SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg(): SMESHGUI_Dialog( 0, false, true, Close/* | Help*/ ) +SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent ) + : SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ ) { QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame()); aDlgLay->setMargin( 0 ); @@ -803,6 +802,16 @@ SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg(): SMESHGUI_Dialog( 0, false, true, Clo aDlgLay->setStretchFactor(aMainFrame, 1); } +// ========================================================================================= +/*! + * \brief Destructor + */ +//======================================================================= + +SMESHGUI_ComputeDlg::~SMESHGUI_ComputeDlg() +{ +} + //======================================================================= // function : createMainFrame() // purpose : Create frame containing dialog's fields @@ -920,37 +929,43 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent) */ //================================================================================ -SMESHGUI_ComputeOp::SMESHGUI_ComputeOp() +SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp() + : SMESHGUI_Operation(), + myCompDlg( 0 ) { - myDlg = new SMESHGUI_ComputeDlg; myTShapeDisplayer = new SMESH::TShapeDisplayer(); myBadMeshDisplayer = 0; //myHelpFileName = "/files/about_meshes.htm"; // V3 myHelpFileName = "about_meshes_page.html"; // V4 - - // connect signals and slots - connect(myDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape())); - connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape())); - connect(myDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh())); - connect(table(), SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged())); - connect(table(), SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged())); } -//======================================================================= -// function : startOperation() -// purpose : Init dialog fields, connect signals and slots, show dialog -//======================================================================= +//================================================================================ +/*! + * \brief Start operation + * \purpose Init dialog fields, connect signals and slots, show dialog + */ +//================================================================================ -void SMESHGUI_ComputeOp::startOperation() +void SMESHGUI_BaseComputeOp::startOperation() { - SMESHGUI_Operation::startOperation(); - - // check selection + if ( !myCompDlg ) + { + myCompDlg = new SMESHGUI_ComputeDlg( desktop() ); + // connect signals and slots + connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape())); + connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape())); + connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh())); + + QTableWidget* aTable = table(); + connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged())); + connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged())); + } myMesh = SMESH::SMESH_Mesh::_nil(); myMainShape = GEOM::GEOM_Object::_nil(); + // check selection LightApp_SelectionMgr *Sel = selectionMgr(); SALOME_ListIO selected; Sel->selectedObjects( selected ); @@ -963,16 +978,28 @@ void SMESHGUI_ComputeOp::startOperation() return; } - Handle(SALOME_InteractiveObject) IObject = selected.First(); - myMesh = SMESH::GetMeshByIO(IObject); + myIObject = selected.First(); + myMesh = SMESH::GetMeshByIO(myIObject); if (myMesh->_is_nil()) { SUIT_MessageBox::warning(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_NO_AVAILABLE_DATA")); onCancel(); - return; + } + myMainShape = myMesh->GetShapeToMesh(); + SMESHGUI_Operation::startOperation(); +} + +//================================================================================ +/*! + * \brief computeMesh() +*/ +//================================================================================ + +void SMESHGUI_BaseComputeOp::computeMesh() +{ // COMPUTE MESH SMESH::MemoryReserve aMemoryReserve; @@ -983,12 +1010,11 @@ void SMESHGUI_ComputeOp::startOperation() bool computeFailed = true, memoryLack = false; _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh); - myMainShape = myMesh->GetShapeToMesh(); bool hasShape = myMesh->HasShapeToMesh(); bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape; if ( shapeOK && aMeshSObj ) { - myDlg->myMeshName->setText( aMeshSObj->GetName().c_str() ); + myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() ); SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen(); SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape); if ( errors->length() > 0 ) { @@ -1031,7 +1057,7 @@ void SMESHGUI_ComputeOp::startOperation() #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - SMESH::Update(IObject, true); + SMESH::Update(myIObject, true); } catch (...) { #ifdef _DEBUG_ @@ -1045,77 +1071,119 @@ void SMESHGUI_ComputeOp::startOperation() } } } - Sel->setSelectedObjects( selected ); + LightApp_SelectionMgr *Sel = selectionMgr(); + if ( Sel ) + { + SALOME_ListIO selected; + selected.Append( myIObject ); + Sel->setSelectedObjects( selected ); + } } } if ( memoryLack ) aMemoryReserve.release(); - myDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED")); - myDlg->myMemoryLackGroup->hide(); + myCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED")); // SHOW ERRORS - + bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 ); bool noHypoError = ( aHypErrors.isEmpty() ); - if ( memoryLack ) + SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() ); + int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" ); + + bool isShowResultDlg = true; + switch( aNotifyMode ) { + case 0: // show the mesh computation result dialog NEVER + isShowResultDlg = false; + commit(); + break; + case 1: // show the mesh computation result dialog if there are some errors + if ( memoryLack || !noCompError || !noHypoError ) + isShowResultDlg = true; + else + { + isShowResultDlg = false; + commit(); + } + break; + default: // show the result dialog after each mesh computation + isShowResultDlg = true; + } + + // SHOW RESULTS + if ( isShowResultDlg ) + showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors ); +} + +void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack, + const bool theNoCompError, + SMESH::compute_error_array_var& theCompErrors, + const bool theNoHypoError, + const QString& theHypErrors ) +{ + bool hasShape = myMesh->HasShapeToMesh(); + SMESHGUI_ComputeDlg* aCompDlg = computeDlg(); + aCompDlg->myMemoryLackGroup->hide(); + + if ( theMemoryLack ) { - myDlg->myMemoryLackGroup->show(); - myDlg->myFullInfo->hide(); - myDlg->myBriefInfo->hide(); - myDlg->myHypErrorGroup->hide(); - myDlg->myCompErrorGroup->hide(); + aCompDlg->myMemoryLackGroup->show(); + aCompDlg->myFullInfo->hide(); + aCompDlg->myBriefInfo->hide(); + aCompDlg->myHypErrorGroup->hide(); + aCompDlg->myCompErrorGroup->hide(); } - else if ( noCompError && noHypoError ) + else if ( theNoCompError && theNoHypoError ) { - myDlg->myFullInfo->SetInfoByMesh( myMesh ); - myDlg->myFullInfo->show(); - myDlg->myBriefInfo->hide(); - myDlg->myHypErrorGroup->hide(); - myDlg->myCompErrorGroup->hide(); + aCompDlg->myFullInfo->SetInfoByMesh( myMesh ); + aCompDlg->myFullInfo->show(); + aCompDlg->myBriefInfo->hide(); + aCompDlg->myHypErrorGroup->hide(); + aCompDlg->myCompErrorGroup->hide(); } else { - QTableWidget* tbl = myDlg->myTable; - myDlg->myBriefInfo->SetInfoByMesh( myMesh ); - myDlg->myBriefInfo->show(); - myDlg->myFullInfo->hide(); + QTableWidget* tbl = aCompDlg->myTable; + aCompDlg->myBriefInfo->SetInfoByMesh( myMesh ); + aCompDlg->myBriefInfo->show(); + aCompDlg->myFullInfo->hide(); - if ( noHypoError ) { - myDlg->myHypErrorGroup->hide(); + if ( theNoHypoError ) { + aCompDlg->myHypErrorGroup->hide(); } else { - myDlg->myHypErrorGroup->show(); - myDlg->myHypErrorLabel->setText( aHypErrors ); + aCompDlg->myHypErrorGroup->show(); + aCompDlg->myHypErrorLabel->setText( theHypErrors ); } - if ( noCompError ) { - myDlg->myCompErrorGroup->hide(); + if ( theNoCompError ) { + aCompDlg->myCompErrorGroup->hide(); } else { - myDlg->myCompErrorGroup->show(); + aCompDlg->myCompErrorGroup->show(); if ( !hasShape ) { - myDlg->myPublishBtn->hide(); - myDlg->myShowBtn->hide(); + aCompDlg->myPublishBtn->hide(); + aCompDlg->myShowBtn->hide(); } else { - myDlg->myPublishBtn->show(); - myDlg->myShowBtn->show(); + aCompDlg->myPublishBtn->show(); + aCompDlg->myShowBtn->show(); } // fill table of errors - tbl->setRowCount( aCompErrors->length() ); + tbl->setRowCount( theCompErrors->length() ); if ( !hasShape ) tbl->hideColumn( COL_SHAPE ); else tbl->showColumn( COL_SHAPE ); tbl->setColumnWidth( COL_ERROR, 200 ); bool hasBadMesh = false; - for ( int row = 0; row < aCompErrors->length(); ++row ) + for ( int row = 0; row < theCompErrors->length(); ++row ) { - SMESH::ComputeError & err = aCompErrors[ row ]; + SMESH::ComputeError & err = theCompErrors[ row ]; QString text = err.algoName.in(); if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) ); @@ -1149,31 +1217,15 @@ void SMESHGUI_ComputeOp::startOperation() tbl->resizeColumnToContents( COL_SHAPE ); if ( hasBadMesh ) - myDlg->myBadMeshBtn->show(); + aCompDlg->myBadMeshBtn->show(); else - myDlg->myBadMeshBtn->hide(); + aCompDlg->myBadMeshBtn->hide(); tbl->setCurrentCell(0,0); currentCellChanged(); // to update buttons } } - SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() ); - int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" ); - - switch( aNotifyMode ) { - case 0: // show the mesh computation result dialog NEVER - commit(); - break; - case 1: // show the mesh computation result dialog if there are some errors - if ( memoryLack || !noCompError || !noHypoError ) - myDlg->show(); - else - commit(); - break; - default: // show the result dialog after each mesh computation - myDlg->show(); - } - + aCompDlg->show(); } //================================================================================ @@ -1182,10 +1234,11 @@ void SMESHGUI_ComputeOp::startOperation() */ //================================================================================ -void SMESHGUI_ComputeOp::stopOperation() +void SMESHGUI_BaseComputeOp::stopOperation() { SMESHGUI_Operation::stopOperation(); - myTShapeDisplayer->SetVisibility( false ); + if ( myTShapeDisplayer ) + myTShapeDisplayer->SetVisibility( false ); if ( myBadMeshDisplayer ) { myBadMeshDisplayer->SetVisibility( false ); // delete it in order not to have problems at its destruction when the viewer @@ -1193,6 +1246,7 @@ void SMESHGUI_ComputeOp::stopOperation() delete myBadMeshDisplayer; myBadMeshDisplayer = 0; } + myIObject.Nullify(); } //================================================================================ @@ -1201,7 +1255,7 @@ void SMESHGUI_ComputeOp::stopOperation() */ //================================================================================ -void SMESHGUI_ComputeOp::onPublishShape() +void SMESHGUI_BaseComputeOp::onPublishShape() { GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy(); @@ -1250,7 +1304,7 @@ void SMESHGUI_ComputeOp::onPublishShape() */ //================================================================================ -void SMESHGUI_ComputeOp::onShowBadMesh() +void SMESHGUI_BaseComputeOp::onShowBadMesh() { myTShapeDisplayer->SetVisibility( false ); QList rows; @@ -1283,7 +1337,7 @@ void SMESHGUI_ComputeOp::onShowBadMesh() */ //================================================================================ -void SMESHGUI_ComputeOp::currentCellChanged() +void SMESHGUI_BaseComputeOp::currentCellChanged() { myTShapeDisplayer->SetVisibility( false ); if ( myBadMeshDisplayer ) @@ -1313,9 +1367,9 @@ void SMESHGUI_ComputeOp::currentCellChanged() if ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() ) hasBadMesh = true; } - myDlg->myPublishBtn->setEnabled( publishEnable ); - myDlg->myShowBtn ->setEnabled( showEnable ); - myDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 )); + myCompDlg->myPublishBtn->setEnabled( publishEnable ); + myCompDlg->myShowBtn ->setEnabled( showEnable ); + myCompDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 )); } //================================================================================ @@ -1324,7 +1378,7 @@ void SMESHGUI_ComputeOp::currentCellChanged() */ //================================================================================ -void SMESHGUI_ComputeOp::onPreviewShape() +void SMESHGUI_BaseComputeOp::onPreviewShape() { if ( myTShapeDisplayer ) { @@ -1352,13 +1406,84 @@ void SMESHGUI_ComputeOp::onPreviewShape() */ //================================================================================ -SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp() +SMESHGUI_BaseComputeOp::~SMESHGUI_BaseComputeOp() { + delete myCompDlg; + myCompDlg = 0; delete myTShapeDisplayer; if ( myBadMeshDisplayer ) delete myBadMeshDisplayer; } +//================================================================================ +/*! + * \brief Gets dialog of compute operation + * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation + */ +//================================================================================ + +SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::computeDlg() const +{ + return myCompDlg; +} + +//================================================================================ +/*! + * \brief Return a table + */ +//================================================================================ + +QTableWidget* SMESHGUI_BaseComputeOp::table() +{ + return myCompDlg->myTable; +} + + +//================================================================================ +/*! + * \brief Constructor +*/ +//================================================================================ + +SMESHGUI_ComputeOp::SMESHGUI_ComputeOp() + : SMESHGUI_BaseComputeOp() +{ +} + + +//================================================================================ +/*! + * \brief Desctructor +*/ +//================================================================================ + +SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp() +{ +} + +//================================================================================ +/*! + * \brief perform it's intention action: compute mesh + */ +//================================================================================ + +void SMESHGUI_ComputeOp::startOperation() +{ + SMESHGUI_BaseComputeOp::startOperation(); + computeMesh(); +} + +//================================================================================ +/*! + * \brief perform it's intention action: compute mesh + */ +//================================================================================ + +bool SMESHGUI_ComputeOp::onApply() +{ + return true; +} + //================================================================================ /*! * \brief Gets dialog of this operation @@ -1368,27 +1493,413 @@ SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp() LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const { - return myDlg; + return computeDlg(); } //================================================================================ /*! - * \brief perform it's intention action: compute mesh + * \brief Constructor +*/ +//================================================================================ + +SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp() + : SMESHGUI_BaseComputeOp(), + myDlg( 0 ), + myActiveDlg( 0 ), + myPreviewDisplayer( 0 ) +{ + myHelpFileName = "preview_meshes_page.html"; // V4 +} + +//================================================================================ +/*! + * \brief Destructor */ //================================================================================ -bool SMESHGUI_ComputeOp::onApply() +SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp() +{ + delete myDlg; + myDlg = 0; + myActiveDlg = 0; + if ( myPreviewDisplayer ) + delete myPreviewDisplayer; + myPreviewDisplayer = 0; +} + +//================================================================================ +/*! + * \brief Gets current dialog of this operation + * \retval LightApp_Dialog* - pointer to dialog of this operation + */ +//================================================================================ + +LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const +{ + return myActiveDlg; +} + +//================================================================================ +/*! + * \brief perform it's intention action: prepare data + */ +//================================================================================ + +void SMESHGUI_PrecomputeOp::startOperation() +{ + if ( !myDlg ) + { + myDlg = new SMESHGUI_PrecomputeDlg( desktop() ); + + // connect signals + connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) ); + } + myActiveDlg = myDlg; + + // connect signal to compute dialog. which will be shown after Compute mesh operation + SMESHGUI_ComputeDlg* cmpDlg = computeDlg(); + if ( cmpDlg ) + { + // disconnect signals + disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); + disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); + disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); + disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); + disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); + + // connect signals + if( cmpDlg->testButtonFlags( QtxDialog::OK ) ) + connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); + if( cmpDlg->testButtonFlags( QtxDialog::Apply ) ) + connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); + if( cmpDlg->testButtonFlags( QtxDialog::Help ) ) + connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); + if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) ) + connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) ); + if( cmpDlg->testButtonFlags( QtxDialog::Close ) ) + connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) ); + } + + SMESHGUI_BaseComputeOp::startOperation(); + + myDlg->show(); +} + +//================================================================================ +/*! + * \brief Stops operation + */ +//================================================================================ + +void SMESHGUI_PrecomputeOp::stopOperation() +{ + if ( myPreviewDisplayer ) + { + myPreviewDisplayer->SetVisibility( false ); + delete myPreviewDisplayer; + myPreviewDisplayer = 0; + } + myMapShapeId.clear(); + SMESHGUI_BaseComputeOp::stopOperation(); +} + +//================================================================================ +/*! + * \brief perform it's intention action: reinitialise dialog + */ +//================================================================================ + +void SMESHGUI_PrecomputeOp::resumeOperation() { + if ( myActiveDlg == myDlg ) + initDialog(); + SMESHGUI_BaseComputeOp::resumeOperation(); +} + +void SMESHGUI_PrecomputeOp::initDialog() +{ + QList modes; + QMap modeMap; + _PTR(SObject) aHypRoot; + _PTR(GenericAttribute) anAttr; + int aPart = SMESH::Tag_RefOnAppliedAlgorithms; + + _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() ); + if ( pMesh && pMesh->FindSubObject( aPart, aHypRoot ) ) + { + _PTR(ChildIterator) anIter = + SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot ); + for ( ; anIter->More(); anIter->Next() ) + { + _PTR(SObject) anObj = anIter->Value(); + _PTR(SObject) aRefObj; + if ( anObj->ReferencedObject( aRefObj ) ) + anObj = aRefObj; + else + continue; + + if ( anObj->FindAttribute( anAttr, "AttributeName" ) ) + { + CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject(); + if ( CORBA::is_nil( aVar ) ) + continue; + + SMESH::SMESH_Algo_var algo = SMESH::SMESH_3D_Algo::_narrow( aVar ); + if ( !algo->_is_nil() ) + { + modeMap[ SMESH::DIM_1D ] = 0; + modeMap[ SMESH::DIM_2D ] = 0; + } + else + { + algo = SMESH::SMESH_2D_Algo::_narrow( aVar ); + if ( !algo->_is_nil() ) + modeMap[ SMESH::DIM_2D ] = 0; + } + } + } + } + if ( modeMap.contains( SMESH::DIM_1D ) ) + modes.append( SMESH::DIM_1D ); + if ( modeMap.contains( SMESH::DIM_2D ) ) + modes.append( SMESH::DIM_2D ); + + myDlg->setPreviewModes( modes ); +} + +//================================================================================ +/*! + * \brief perform it's intention action: + */ +//================================================================================ + +bool SMESHGUI_PrecomputeOp::onApply() +{ + QObject* obj = sender(); + if ( obj != myDlg && myActiveDlg == myDlg ) + return true; // just return from error messages + if ( myActiveDlg == myDlg ) + { + myDlg->hide(); + myMapShapeId.clear(); + myActiveDlg = computeDlg(); + computeMesh(); + } + return true; } //================================================================================ /*! - * \brief Return a table + * \brief perform it's intention action: compute mesh */ //================================================================================ -QTableWidget* SMESHGUI_ComputeOp::table() +void SMESHGUI_PrecomputeOp::onCancel() +{ + QObject* curDlg = sender(); + if ( curDlg == computeDlg() ) + { + if ( myActiveDlg == myDlg ) // return from error messages + myDlg->show(); + + return; + } + + if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() ) + { + // ask to remove already computed mesh elements + if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ), + tr( "CLEAR_SUBMESH_QUESTION" ), + tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 ) + { + // remove all submeshes for collected shapes + QMap::const_iterator it = myMapShapeId.constBegin(); + for ( ; it != myMapShapeId.constEnd(); ++it ) + myMesh->ClearSubMesh( *it ); + } + } + myMapShapeId.clear(); + SMESHGUI_BaseComputeOp::onCancel(); +} + +//================================================================================ +/*! + * \brief perform it's intention action: preview mesh + */ +//================================================================================ + +void SMESHGUI_PrecomputeOp::onPreview() +{ + if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() ) + return; + + _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh); + if ( !aMeshSObj ) + return; + // Compute preview of mesh, + // i.e. compute mesh till indicated dimension + int dim = myDlg->getPreviewMode(); + + SMESH::MemoryReserve aMemoryReserve; + + SMESH::compute_error_array_var aCompErrors; + QString aHypErrors; + + bool computeFailed = true, memoryLack = false; + + SMESHGUI_ComputeDlg* aCompDlg = computeDlg(); + aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() ); + + SMESHGUI* gui = getSMESHGUI(); + SMESH::SMESH_Gen_var gen = gui->GetSMESHGen(); + SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape); + if ( errors->length() > 0 ) { + aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() ); + } + + SUIT_OverrideCursor aWaitCursor; + + SVTK_ViewWindow* view = SMESH::GetViewWindow( gui ); + if ( myPreviewDisplayer ) delete myPreviewDisplayer; + myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view ); + + SMESH::long_array_var aShapesId = new SMESH::long_array(); + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + + SMESH::MeshPreviewStruct_var previewData = + gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId); + if ( previewData.operator->() ) + { + computeFailed = false; + myPreviewDisplayer->SetData( previewData._retn() ); + // append shape indeces with computed mesh entities + for ( int i = 0, n = aShapesId->length(); i < n; i++ ) + myMapShapeId[ aShapesId[ i ] ] = 0; + } + else + myPreviewDisplayer->SetVisibility(false); + } + catch(const SALOME::SALOME_Exception & S_ex){ + memoryLack = true; + myPreviewDisplayer->SetVisibility(false); + } + + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + aCompErrors = gen->GetComputeErrors( myMesh, myMainShape ); + // check if there are memory problems + for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i ) + memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB ); + } + catch(const SALOME::SALOME_Exception & S_ex){ + memoryLack = true; + } + + if ( memoryLack ) + aMemoryReserve.release(); + + bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 ); + bool noHypoError = ( aHypErrors.isEmpty() ); + + SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui ); + int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" ); + + bool isShowError = true; + switch( aNotifyMode ) { + case 0: // show the mesh computation result dialog NEVER + isShowError = false; + break; + case 1: // show the mesh computation result dialog if there are some errors + default: // show the result dialog after each mesh computation + if ( !computeFailed && !memoryLack && noCompError && noHypoError ) + isShowError = false; + break; + } + + // SHOW ERRORS + if ( isShowError ) + { + myDlg->hide(); + aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED")); + showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors ); + } +} + + +//================================================================================ +/*! + * \brief Constructor +*/ +//================================================================================ + +SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent ) + : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help ) +{ + setWindowTitle( tr( "CAPTION" ) ); + + setButtonText( OK, tr( "COMPUTE" ) ); + QFrame* main = mainFrame(); + + QVBoxLayout* layout = new QVBoxLayout( main ); + + QFrame* frame = new QFrame( main ); + layout->setMargin(0); layout->setSpacing(0); + layout->addWidget( frame ); + + QHBoxLayout* frameLay = new QHBoxLayout( frame ); + frameLay->setMargin(0); frameLay->setSpacing(SPACING); + + myPreviewMode = new QtxComboBox( frame ); + frameLay->addWidget( myPreviewMode ); + + myPreviewBtn = new QPushButton( tr( "PREVIEW" ), frame ); + frameLay->addWidget( myPreviewBtn ); + + connect( myPreviewBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( preview() ) ); +} + +//================================================================================ +/*! + * \brief Destructor +*/ +//================================================================================ + +SMESHGUI_PrecomputeDlg::~SMESHGUI_PrecomputeDlg() +{ +} + +//================================================================================ +/*! + * \brief Sets available preview modes +*/ +//================================================================================ + +void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList& theModes ) +{ + myPreviewMode->clear(); + QList::const_iterator it = theModes.constBegin(); + for ( int i = 0; it != theModes.constEnd(); ++it, i++ ) + { + QString mode = QString( "PREVIEW_%1" ).arg( *it ); + myPreviewMode->addItem( tr( mode.toLatin1().data() ) ); + myPreviewMode->setId( i, *it ); + } + myPreviewBtn->setEnabled( !theModes.isEmpty() ); +} + +//================================================================================ +/*! + * \brief Returns current preview mesh mode +*/ +//================================================================================ + +int SMESHGUI_PrecomputeDlg::getPreviewMode() const { - return myDlg->myTable; + return myPreviewMode->currentId(); } diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.h b/src/SMESHGUI/SMESHGUI_ComputeDlg.h index cab75f2ad..b931a1917 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.h +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.h @@ -30,29 +30,82 @@ #include "SMESHGUI_Dialog.h" #include "SMESHGUI_Operation.h" +// SALOME GUI includes +#include + // Qt includes +#include +#include #include // IDL includes #include +#include CORBA_SERVER_HEADER(SMESH_Gen) #include CORBA_SERVER_HEADER(SMESH_Mesh) class QFrame; class QPushButton; class QTableWidget; class QLabel; +class QtxComboBox; class SMESHGUI_ComputeDlg; +class SMESHGUI_PrecomputeDlg; class SMESHGUI_MeshEditPreview; +class SMESH::compute_error_array; + namespace SMESH { class TShapeDisplayer; } +/*! + * \brief Base operation to compute a mesh and show computation errors + */ +class SMESHGUI_EXPORT SMESHGUI_BaseComputeOp: public SMESHGUI_Operation +{ + Q_OBJECT + +public: + SMESHGUI_BaseComputeOp(); + virtual ~SMESHGUI_BaseComputeOp(); + +protected: + virtual void startOperation(); + virtual void stopOperation(); + + SMESHGUI_ComputeDlg* computeDlg() const; + void computeMesh(); + void showComputeResult( const bool, + const bool, + SMESH::compute_error_array_var&, + const bool, + const QString& ); + +protected slots: + void onPreviewShape(); + void onPublishShape(); + void onShowBadMesh(); + void currentCellChanged(); + +private: + QTableWidget* table(); + +private: + QPointer myCompDlg; + +protected: + SMESH::SMESH_Mesh_var myMesh; + GEOM::GEOM_Object_var myMainShape; + SMESH::TShapeDisplayer* myTShapeDisplayer; + SMESHGUI_MeshEditPreview* myBadMeshDisplayer; + Handle(SALOME_InteractiveObject) myIObject; +}; + /*! * \brief Operation to compute a mesh and show computation errors */ -class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_Operation +class SMESHGUI_EXPORT SMESHGUI_ComputeOp: public SMESHGUI_BaseComputeOp { Q_OBJECT @@ -62,28 +115,45 @@ public: virtual LightApp_Dialog* dlg() const; +protected: + virtual void startOperation(); + +protected slots: + virtual bool onApply(); +}; + +/*! + * \brief Operation to preview and compute a mesh and show computation errors + */ +class SMESHGUI_EXPORT SMESHGUI_PrecomputeOp: public SMESHGUI_BaseComputeOp +{ + Q_OBJECT + +public: + SMESHGUI_PrecomputeOp(); + virtual ~SMESHGUI_PrecomputeOp(); + + virtual LightApp_Dialog* dlg() const; + protected: virtual void startOperation(); virtual void stopOperation(); + virtual void resumeOperation(); + + virtual void initDialog(); protected slots: virtual bool onApply(); + virtual void onCancel(); private slots: - void onPreviewShape(); - void onPublishShape(); - void onShowBadMesh(); - void currentCellChanged(); + void onPreview(); private: - QTableWidget* table(); - - SMESHGUI_ComputeDlg* myDlg; - - SMESH::SMESH_Mesh_var myMesh; - GEOM::GEOM_Object_var myMainShape; - SMESH::TShapeDisplayer* myTShapeDisplayer; - SMESHGUI_MeshEditPreview* myBadMeshDisplayer; + QMap< int, int > myMapShapeId; + QPointer myActiveDlg; + QPointer myDlg; + SMESHGUI_MeshEditPreview* myPreviewDisplayer; }; /*! @@ -142,9 +212,10 @@ class SMESHGUI_EXPORT SMESHGUI_ComputeDlg : public SMESHGUI_Dialog Q_OBJECT public: - SMESHGUI_ComputeDlg(); + SMESHGUI_ComputeDlg( QWidget* ); + virtual ~SMESHGUI_ComputeDlg(); -private: +protected: QFrame* createMainFrame( QWidget* ); QLabel* myMeshName; @@ -160,7 +231,32 @@ private: SMESHGUI_MeshInfosBox* myBriefInfo; SMESHGUI_MeshInfosBox* myFullInfo; - friend class SMESHGUI_ComputeOp; + friend class SMESHGUI_BaseComputeOp; + friend class SMESHGUI_PrecomputeOp; +}; + +/*! + * \brief Dialog to preview and compute a mesh and show computation errors + */ + +class SMESHGUI_EXPORT SMESHGUI_PrecomputeDlg : public SMESHGUI_Dialog +{ + Q_OBJECT + +public: + SMESHGUI_PrecomputeDlg( QWidget* ); + virtual ~SMESHGUI_PrecomputeDlg(); + + void setPreviewModes( const QList& ); + int getPreviewMode() const; + +signals: + void preview(); + +private: + QPushButton* myPreviewBtn; + QtxComboBox* myPreviewMode; }; + #endif // SMESHGUI_COMPUTEDLG_H diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index c8a223159..1171832c0 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -34,6 +34,10 @@ ICON_COMPUTE mesh_compute.png + + ICON_PRECOMPUTE + mesh_precompute.png + ICON_CONNECTION mesh_multi_edges.png diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index c03686d56..f99e4cb4d 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -154,6 +154,10 @@ MEN_COMPUTE Compute + + MEN_PRECOMPUTE + Preview + MEN_CONNECTION Borders at Multi-Connection @@ -1916,6 +1920,10 @@ Consider saving your work before application crash STB_COMPUTE Compute + + STB_PRECOMPUTE + Preview + STB_CONNECTION Borders at Multi-Connection @@ -2380,6 +2388,10 @@ Consider saving your work before application crash TOP_COMPUTE Compute + + TOP_PRECOMPUTE + Preview + TOP_CONNECTION Borders at Multi-Connection @@ -3109,6 +3121,38 @@ Please, create VTK viewer and try again Show bad Mesh + + SMESHGUI_PrecomputeDlg + + CAPTION + Preview and Compute mesh + + + PREVIEW + Preview + + + PREVIEW_1 + 1D Mesh + + + PREVIEW_2 + 2D Mesh + + + COMPUTE + Compute + + + + SMESHGUI_PrecomputeOp + + CLEAR_SUBMESH_QUESTION + A temporary submeshes on the selected geometry + created during preview operation. + Do you want to remove all this submeshes? + + SMESHGUI_ConvToQuadDlg diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index a339e684f..5bb47f630 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1364,6 +1364,194 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, return false; } +//============================================================================= +/*! + * SMESH_Gen_i::Precompute + * + * Compute mesh as preview till indicated dimension on shape + */ +//============================================================================= + +SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShapeObject, + SMESH::Dimension theDimension, + SMESH::long_array& theShapesId) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Precompute" ); + + if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) + THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", + SALOME::BAD_PARAM ); + + if ( CORBA::is_nil( theMesh ) ) + THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", + SALOME::BAD_PARAM ); + + SMESH::MeshPreviewStruct_var result = 0; + try { + // get mesh servant + SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( theMesh ).in() ); + ASSERT( meshServant ); + if ( meshServant ) { + // NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation" + meshServant->CheckGeomGroupModif(); + // get local TopoDS_Shape + TopoDS_Shape myLocShape; + if(theMesh->HasShapeToMesh()) + myLocShape = GeomObjectToShape( theShapeObject ); + else + return result._retn();; + + // call implementation compute + ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); + TSetOfInt shapeIds; + ::MeshDimension aDim = (MeshDimension)theDimension; + if ( myGen.Compute( myLocMesh, myLocShape, false, aDim, &shapeIds ) ) + { + int nbShapeId = shapeIds.size(); + theShapesId.length( nbShapeId ); + // iterates on shapes and collect mesh entities into mesh preview + result = new SMESH::MeshPreviewStruct; + TSetOfInt::const_iterator idIt = shapeIds.begin(); + TSetOfInt::const_iterator idEnd = shapeIds.end(); + std::map< int, int > mapOfShIdNb; + std::set< SMESH_TLink > setOfEdge; + std::list< SMDSAbs_ElementType > listOfElemType; + typedef map TNode2LocalIDMap; + typedef TNode2LocalIDMap::iterator TNodeLocalID; + TNode2LocalIDMap mapNode2LocalID; + list< TNodeLocalID > connectivity; + int i, nbConnNodes = 0; + std::set< const SMESH_subMesh* > setOfVSubMesh; + // iterates on shapes + for ( ; idIt != idEnd; idIt++ ) + { + if ( mapOfShIdNb.find( *idIt ) != mapOfShIdNb.end() ) + continue; + SMESH_subMesh* sm = myLocMesh.GetSubMeshContaining(*idIt); + if ( !sm || !sm->IsMeshComputed() ) + continue; + + const TopoDS_Shape& aSh = sm->GetSubShape(); + const int shDim = myGen.GetShapeDim( aSh ); + if ( shDim < 1 || shDim > theDimension ) + continue; + + mapOfShIdNb[ *idIt ] = 0; + theShapesId[ mapOfShIdNb.size() - 1 ] = *idIt; + + SMESHDS_SubMesh* smDS = sm->GetSubMeshDS(); + if ( !smDS ) continue; + + if ( theDimension == SMESH::DIM_2D ) + { + SMDS_ElemIteratorPtr faceIt = smDS->GetElements(); + while ( faceIt->more() ) + { + const SMDS_MeshElement* face = faceIt->next(); + int aNbNode = face->NbNodes(); + if ( aNbNode > 4 ) + aNbNode /= 2; // do not take into account additional middle nodes + + SMDS_MeshNode* node1 = (SMDS_MeshNode*)face->GetNode( 1 ); + for ( int nIndx = 1; nIndx <= aNbNode; nIndx++ ) + { + SMDS_MeshNode* node2 = (SMDS_MeshNode*)face->GetNode( nIndx < aNbNode ? nIndx+1 : 1 ); + if ( setOfEdge.insert( SMESH_TLink ( node1, node2 ) ).second ) + { + listOfElemType.push_back( SMDSAbs_Edge ); + connectivity.push_back + ( mapNode2LocalID.insert( make_pair( node1, ++nbConnNodes)).first ); + connectivity.push_back + ( mapNode2LocalID.insert( make_pair( node2, ++nbConnNodes)).first ); + } + node1 = node2; + } + } + } + else if ( theDimension == SMESH::DIM_1D ) + { + SMDS_NodeIteratorPtr nodeIt = smDS->GetNodes(); + while ( nodeIt->more() ) + { + listOfElemType.push_back( SMDSAbs_Node ); + connectivity.push_back + ( mapNode2LocalID.insert( make_pair( nodeIt->next(), ++nbConnNodes)).first ); + } + // add corner nodes by first vertex from edge + SMESH_subMeshIteratorPtr edgeSmIt = + sm->getDependsOnIterator(/*includeSelf*/false, + /*complexShapeFirst*/false); + while ( edgeSmIt->more() ) + { + SMESH_subMesh* vertexSM = edgeSmIt->next(); + // check that vertex is not already treated + if ( !setOfVSubMesh.insert( vertexSM ).second ) + continue; + if ( vertexSM->GetSubShape().ShapeType() != TopAbs_VERTEX ) + continue; + + const SMESHDS_SubMesh* vertexSmDS = vertexSM->GetSubMeshDS(); + SMDS_NodeIteratorPtr nodeIt = vertexSmDS->GetNodes(); + while ( nodeIt->more() ) + { + listOfElemType.push_back( SMDSAbs_Node ); + connectivity.push_back + ( mapNode2LocalID.insert( make_pair( nodeIt->next(), ++nbConnNodes)).first ); + } + } + } + } + + // fill node coords and assign local ids to the nodes + int nbNodes = mapNode2LocalID.size(); + result->nodesXYZ.length( nbNodes ); + TNodeLocalID node2ID = mapNode2LocalID.begin(); + for ( i = 0; i < nbNodes; ++i, ++node2ID ) { + node2ID->second = i; + const SMDS_MeshNode* node = (const SMDS_MeshNode*) node2ID->first; + result->nodesXYZ[i].x = node->X(); + result->nodesXYZ[i].y = node->Y(); + result->nodesXYZ[i].z = node->Z(); + } + // fill connectivity + result->elementConnectivities.length( nbConnNodes ); + list< TNodeLocalID >::iterator connIt = connectivity.begin(); + for ( i = 0; i < nbConnNodes; ++i, ++connIt ) { + result->elementConnectivities[i] = (*connIt)->second; + } + + // fill element types + result->elementTypes.length( listOfElemType.size() ); + std::list< SMDSAbs_ElementType >::const_iterator typeIt = listOfElemType.begin(); + std::list< SMDSAbs_ElementType >::const_iterator typeEnd = listOfElemType.end(); + for ( i = 0; typeIt != typeEnd; ++i, ++typeIt ) + { + SMDSAbs_ElementType elemType = *typeIt; + result->elementTypes[i].SMDS_ElementType = (SMESH::ElementType)elemType; + result->elementTypes[i].isPoly = false; + result->elementTypes[i].nbNodesInElement = elemType == SMDSAbs_Edge ? 2 : 1; + } + + // correct number of shapes + theShapesId.length( mapOfShIdNb.size() ); + } + } + } + catch ( std::bad_alloc ) { + INFOS( "Precompute(): lack of memory" ); + } + catch ( SALOME_Exception& S_ex ) { + INFOS( "Precompute(): catch exception "<< S_ex.what() ); + } + catch ( ... ) { + INFOS( "Precompute(): unknown exception " ); + } + return result._retn(); +} + //================================================================================ /*! * \brief Return geometrical object the given element is built on @@ -3538,9 +3726,9 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // "Nodes on Faces" - ID of node on face // "Face U positions" - U parameter of node on face // "Face V positions" - V parameter of node on face - char* aEid_DSName = "Nodes on Edges"; - char* aEu_DSName = "Edge positions"; - char* aFu_DSName = "Face U positions"; + const char* aEid_DSName = "Nodes on Edges"; + const char* aEu_DSName = "Edge positions"; + const char* aFu_DSName = "Face U positions"; //char* aFid_DSName = "Nodes on Faces"; //char* aFv_DSName = "Face V positions"; diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 06601716a..1a548d41b 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -237,6 +237,17 @@ public: CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ); + + /*! + * Calculate Mesh as preview till indicated dimension on shape + * First, verify list of hypothesis associated with the subShape. + * Return mesh preview structure + */ + SMESH::MeshPreviewStruct* Precompute( SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theSubObject, + SMESH::Dimension theDimension, + SMESH::long_array& theShapesId ) + throw ( SALOME::SALOME_Exception ); // Returns errors of hypotheses definintion SMESH::algo_error_array* GetAlgoState( SMESH::SMESH_Mesh_ptr theMesh, diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 67433400f..933f62939 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -209,6 +209,24 @@ void SMESH_Mesh_i::Clear() throw (SALOME::SALOME_Exception) TPythonDump() << _this() << ".Clear()"; } +//================================================================================ +/*! + * \brief Remove all nodes and elements for indicated shape + */ +//================================================================================ + +void SMESH_Mesh_i::ClearSubMesh(CORBA::Long ShapeID) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + try { + _impl->ClearSubMesh( ShapeID ); + } + catch(SALOME_Exception & S_ex) { + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); + } +} + //============================================================================= /*! * @@ -1976,7 +1994,7 @@ void SMESH_Mesh_i::ExportToMED (const char* file, // Perform Export PrepareForWriting(file); - char* aMeshName = "Mesh"; + const char* aMeshName = "Mesh"; SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); if ( !aStudy->_is_nil() ) { SALOMEDS::SObject_var aMeshSO = _gen_i->ObjectToSObject( aStudy, _this() ); diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 05a5c358c..83bccf2f6 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -77,6 +77,9 @@ public: void Clear() throw (SALOME::SALOME_Exception); + void ClearSubMesh(CORBA::Long ShapeID) + throw (SALOME::SALOME_Exception); + SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) throw (SALOME::SALOME_Exception); diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index 93f2e22f0..7bd3fd783 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -928,6 +928,16 @@ class Mesh: smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) salome.sg.updateObjBrowser(1) + ## Removes all nodes and elements of indicated shape + # @ingroup l2_construct + def ClearSubMesh(self, geomId): + self.mesh.ClearSubMesh(geomId) + if salome.sg.hasDesktop(): + smeshgui = salome.ImportComponentGUI("SMESH") + smeshgui.Init(salome.myStudyId) + smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True ) + salome.sg.updateObjBrowser(1) + ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN # @param fineness [0,-1] defines mesh fineness # @return True or False -- 2.39.2