From: eap Date: Fri, 10 Feb 2017 18:20:38 +0000 (+0300) Subject: Fix crash of SALOME_TESTS/Grids/smesh/bugs_13/N9 X-Git-Tag: V8_3_0a2~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=913aaa14de1406e2640ada90bbce495c95106966;p=modules%2Fsmesh.git Fix crash of SALOME_TESTS/Grids/smesh/bugs_13/N9 (SMDS_VolumeTool.cxx) Add "Show IDs" check box to Mesh Information dlg Avoid warning in Choose Entity dialog when no entities are selected, disable [OK] button instead --- diff --git a/doc/salome/gui/SMESH/images/eleminfo1.png b/doc/salome/gui/SMESH/images/eleminfo1.png old mode 100755 new mode 100644 index 74c76db63..9f9e03a41 Binary files a/doc/salome/gui/SMESH/images/eleminfo1.png and b/doc/salome/gui/SMESH/images/eleminfo1.png differ diff --git a/doc/salome/gui/SMESH/images/eleminfo2.png b/doc/salome/gui/SMESH/images/eleminfo2.png old mode 100755 new mode 100644 index b7a785bc9..34061d913 Binary files a/doc/salome/gui/SMESH/images/eleminfo2.png and b/doc/salome/gui/SMESH/images/eleminfo2.png differ diff --git a/doc/salome/gui/SMESH/input/mesh_infos.doc b/doc/salome/gui/SMESH/input/mesh_infos.doc index 49a5a5ce4..e20375251 100644 --- a/doc/salome/gui/SMESH/input/mesh_infos.doc +++ b/doc/salome/gui/SMESH/input/mesh_infos.doc @@ -78,6 +78,9 @@ The user can either input the ID of a node or element he wants to analyze directly in the dialog box or select the node(s) or element(s) in the 3D viewer. +If Show IDs is activated, IDs of selected nodes or elements are +displayed in the 3D viewer. + \note The information about the groups, to which the node or element belongs, can be shown in a short or in a detailed form. By default, for performance reasons, this information is shown in a short form (group names diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx index dca32c258..d7dd7f826 100644 --- a/src/SMDS/SMDS_VolumeTool.cxx +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -425,11 +425,13 @@ struct SMDS_VolumeTool::SaveFacet SaveFacet( SMDS_VolumeTool::Facet& facet ): myToRestore( facet ) { mySaved = facet; + mySaved.myNodes.swap( facet.myNodes ); } ~SaveFacet() { if ( myToRestore.myIndex != mySaved.myIndex ) myToRestore = mySaved; + myToRestore.myNodes.swap( mySaved.myNodes ); } }; diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 31f16a61f..705afa376 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -4383,6 +4383,7 @@ void SMESHGUI::initialize( CAM_Application* app ) hasNodes("(numberOfNodes > 0 ) && hasActor"), hasElems("(count( elemTypes ) > 0)"), hasDifferentElems("(count( elemTypes ) > 1)"), + hasDifferentObjElems("(count( objElemTypes ) > 1)"), hasBalls("({'BallElem'} in elemTypes)"), hasElems0d("({'Elem0d'} in elemTypes)"), hasEdges("({'Edge'} in elemTypes)"), @@ -4532,7 +4533,7 @@ void SMESHGUI::initialize( CAM_Application* app ) popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( action( SMESHOp::OpDEChoose ), anId, -1 ); - popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentElems, QtxPopupMgr::VisibleRule ); + popupMgr()->setRule( action( SMESHOp::OpDEChoose ), aClient + "&& $type in {" + mesh + "} &&" + hasDifferentObjElems, QtxPopupMgr::VisibleRule ); popupMgr()->insert( separator(), anId, -1 ); diff --git a/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.cxx b/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.cxx index 8c9ac135b..5af7f7815 100644 --- a/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.cxx @@ -97,6 +97,7 @@ SMESHGUI_DisplayEntitiesDlg::SMESHGUI_DisplayEntitiesDlg( QWidget* parent ) hl->addWidget( nb0DElemsLab, 0, 1 ); my0DElemsTB->setEnabled( nbElements ); nb0DElemsLab->setEnabled( nbElements ); + myNbTypes += ( nbElements > 0 ); // Edges nbElements = myActor ? myActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) : aMesh->NbEdges(); @@ -112,6 +113,7 @@ SMESHGUI_DisplayEntitiesDlg::SMESHGUI_DisplayEntitiesDlg( QWidget* parent ) hl->addWidget( nbEdgesLab, 1, 1 ); myEdgesTB->setEnabled( nbElements ); nbEdgesLab->setEnabled( nbElements ); + myNbTypes += ( nbElements > 0 ); // Faces nbElements = myActor ? myActor->GetObject()->GetNbEntities( SMDSAbs_Face ) : aMesh->NbFaces(); @@ -127,6 +129,7 @@ SMESHGUI_DisplayEntitiesDlg::SMESHGUI_DisplayEntitiesDlg( QWidget* parent ) hl->addWidget( nbFacesLab, 2, 1 ); myFacesTB->setEnabled( nbElements ); nbFacesLab->setEnabled( nbElements ); + myNbTypes += ( nbElements > 0 ); // Volumes nbElements = myActor ? myActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) : aMesh->NbVolumes(); @@ -142,6 +145,7 @@ SMESHGUI_DisplayEntitiesDlg::SMESHGUI_DisplayEntitiesDlg( QWidget* parent ) hl->addWidget( nbVolumesLab, 3, 1 ); myVolumesTB->setEnabled( nbElements ); nbVolumesLab->setEnabled( nbElements ); + myNbTypes += ( nbElements > 0 ); // Balls nbElements = myActor ? myActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) : aMesh->NbBalls(); @@ -157,6 +161,7 @@ SMESHGUI_DisplayEntitiesDlg::SMESHGUI_DisplayEntitiesDlg( QWidget* parent ) hl->addWidget( nbBallsLab, 4, 1 ); myBallsTB->setEnabled( nbElements ); nbBallsLab->setEnabled( nbElements ); + myNbTypes += ( nbElements > 0 ); QVBoxLayout* aDlgLay = new QVBoxLayout( mainFrame() ); aDlgLay->setMargin( 0 ); @@ -165,8 +170,10 @@ SMESHGUI_DisplayEntitiesDlg::SMESHGUI_DisplayEntitiesDlg( QWidget* parent ) button( OK )->setText( tr( "SMESH_BUT_OK" ) ); - connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); - connect( this, SIGNAL( dlgOk() ), this, SLOT( onOk() ) ); + connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() )); + connect( this, SIGNAL( dlgOk() ), this, SLOT( onOk() )); + + updateButtons(); } /* @@ -192,14 +199,6 @@ void SMESHGUI_DisplayEntitiesDlg::InverseEntityMode(unsigned int& theOutputMode, void SMESHGUI_DisplayEntitiesDlg::onChangeEntityMode( bool isChecked ) { QCheckBox* aSender = (QCheckBox*)sender(); - if ( myNbCheckedButtons == 1 && !isChecked ) { - SUIT_MessageBox::warning(this, tr("SMESH_WRN_WARNING"), - tr("WRN_AT_LEAST_ONE")); - disconnect( aSender, SIGNAL(toggled(bool)), this, SLOT(onChangeEntityMode(bool)) ); - aSender->setChecked( true ); - connect( aSender, SIGNAL(toggled(bool)), this, SLOT(onChangeEntityMode(bool)) ); - return; - } if ( my0DElemsTB == aSender ) InverseEntityMode( myEntityMode, SMESH_Actor::e0DElements ); else if ( myEdgesTB == aSender ) @@ -210,9 +209,9 @@ void SMESHGUI_DisplayEntitiesDlg::onChangeEntityMode( bool isChecked ) InverseEntityMode( myEntityMode, SMESH_Actor::eVolumes ); else if ( myBallsTB == aSender ) InverseEntityMode( myEntityMode, SMESH_Actor::eBallElem ); - + isChecked ? myNbCheckedButtons++ : myNbCheckedButtons--; - + updateButtons(); } /*! @@ -248,3 +247,11 @@ void SMESHGUI_DisplayEntitiesDlg::onOk() SMESH::UpdateView( wnd, SMESH::eDisplay, entry ); } } + +/*! + * \brief Enable/disable OK button depending on nb of selected entities + */ +void SMESHGUI_DisplayEntitiesDlg::updateButtons() +{ + setButtonEnabled( myNbCheckedButtons > 0 || myNbTypes == 0, OK ); +} diff --git a/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.h b/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.h index e6305b2d6..4901bd6ce 100644 --- a/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.h +++ b/src/SMESHGUI/SMESHGUI_DisplayEntitiesDlg.h @@ -40,6 +40,7 @@ public: private: void InverseEntityMode( unsigned int& theOutputMode, unsigned int theMode ); + void updateButtons(); private slots: void onOk(); @@ -51,6 +52,7 @@ private: unsigned int myEntityMode; SMESH_Actor *myActor; int myNbCheckedButtons; + int myNbTypes; QCheckBox* my0DElemsTB; QCheckBox* myEdgesTB; QCheckBox* myFacesTB; diff --git a/src/SMESHGUI/SMESHGUI_IdPreview.h b/src/SMESHGUI/SMESHGUI_IdPreview.h index 6c72b1fd5..6890f1df6 100644 --- a/src/SMESHGUI/SMESHGUI_IdPreview.h +++ b/src/SMESHGUI/SMESHGUI_IdPreview.h @@ -55,6 +55,14 @@ public: void SetPointsData( SMDS_Mesh* theMesh, const TColStd_MapOfInteger & theNodesIdMap ); void SetElemsData ( const std::vector & theElemsIdMap, const std::list & theGrCentersXYZ ); + template< class INT_ITER, class XYZ_ITER > + void SetElemsData ( INT_ITER theElemsBegin, INT_ITER theElemsEnd, + XYZ_ITER theGrCentersBegin, XYZ_ITER theGrCentersEnd ) + { + std::vector elemsIds( theElemsBegin, theElemsEnd ); + std::list gcXYZ( theGrCentersBegin, theGrCentersEnd ); + SetElemsData( elemsIds, gcXYZ ); + } void SetPointsLabeled( bool theIsPointsLabeled, bool theIsActorVisible = true ); void AddToRender ( vtkRenderer* theRenderer ); diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index b8328b4a6..f85d5d3f7 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -33,6 +33,7 @@ #include "SMESHDS_Mesh.hxx" #include "SMESHGUI.h" #include "SMESHGUI_FilterUtils.h" +#include "SMESHGUI_IdPreview.h" #include "SMESHGUI_IdValidator.h" #include "SMESHGUI_SpinBox.h" #include "SMESHGUI_Utils.h" @@ -2826,7 +2827,7 @@ void SMESHGUI_AddInfo::saveInfo( QTextStream &out ) \param page specifies the dialog page to be shown at the start-up */ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) -: QDialog( parent ), myActor( 0 ) + : QDialog( parent ), myActor( 0 ) { setModal( false ); setAttribute( Qt::WA_DeleteOnClose, true ); @@ -2835,13 +2836,13 @@ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) myTabWidget = new QTabWidget( this ); - // base info + // base info myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget ); myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) ); // elem info - + QWidget* w = new QWidget( myTabWidget ); myMode = new QButtonGroup( this ); @@ -2850,11 +2851,13 @@ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) myMode->button( NodeMode )->setChecked( true ); myID = new QLineEdit( w ); myID->setValidator( new SMESHGUI_IdValidator( this ) ); + myIDPreviewCheck = new QCheckBox( tr( "SHOW_IDS" ), w ); + myIDPreview = new SMESHGUI_IdPreview( SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() )); int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 ); mode = qMin( 1, qMax( 0, mode ) ); - - if ( mode == 0 ) + + if ( mode == 0 ) myElemInfo = new SMESHGUI_SimpleElemInfo( w ); else myElemInfo = new SMESHGUI_TreeElemInfo( w ); @@ -2864,9 +2867,10 @@ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) elemLayout->setSpacing( SPACING ); elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 ); elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 ); - elemLayout->addWidget( myID, 0, 2 ); - elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 ); - + elemLayout->addWidget( myID, 0, 2 ); + elemLayout->addWidget( myIDPreviewCheck, 1, 0, 1, 2 ); + elemLayout->addWidget( myElemInfo, 2, 0, 1, 3 ); + myTabWidget->addTab( w, tr( "ELEM_INFO" ) ); // additional info @@ -2905,18 +2909,19 @@ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) l->addWidget( myTabWidget ); l->addLayout( btnLayout ); - myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) ); + myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ))); - connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - connect( dumpBtn, SIGNAL( clicked() ), this, SLOT( dump() ) ); - connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() ) ); - connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() ) ); - connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() ) ); - connect( myID, SIGNAL( textChanged( QString ) ), this, SLOT( idChanged() ) ); - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) ); - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) ); - connect( myElemInfo, SIGNAL( itemInfo( int ) ), this, SLOT( showItemInfo( int ) ) ); - connect( myElemInfo, SIGNAL( itemInfo( QString ) ), this, SLOT( showItemInfo( QString ) ) ); + connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() )); + connect( dumpBtn, SIGNAL( clicked() ), this, SLOT( dump() )); + connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() )); + connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() )); + connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() )); + connect( myID, SIGNAL( textChanged( QString ) ), this, SLOT( idChanged() )); + connect( myIDPreviewCheck, SIGNAL( toggled(bool) ), this, SLOT( idPreviewChange(bool) )); + connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() )); + connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() )); + connect( myElemInfo, SIGNAL( itemInfo( int ) ), this, SLOT( showItemInfo( int ))); + connect( myElemInfo, SIGNAL( itemInfo( QString ) ), this, SLOT( showItemInfo( QString ))); updateSelection(); } @@ -2926,6 +2931,7 @@ SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page ) */ SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg() { + delete myIDPreview; } /*! @@ -2983,6 +2989,7 @@ void SMESHGUI_MeshInfoDlg::reject() if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) aViewWindow->SetSelectionMode( ActorSelection ); QDialog::reject(); + myIDPreview->SetPointsLabeled(false); } /*! @@ -3016,7 +3023,9 @@ void SMESHGUI_MeshInfoDlg::updateSelection() disconnect( selMgr, 0, this, 0 ); selMgr->clearFilters(); - if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo || myTabWidget->currentIndex() == CtrlInfo ) { + if ( myTabWidget->currentIndex() == BaseInfo || + myTabWidget->currentIndex() == AddInfo || + myTabWidget->currentIndex() == CtrlInfo ) { SMESH::SetPointRepresentation( false ); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) aViewWindow->SetSelectionMode( ActorSelection ); @@ -3106,28 +3115,48 @@ void SMESHGUI_MeshInfoDlg::modeChanged() } /*! - \brief Caled when users prints mesh element ID in the corresponding field. + \brief Called when users prints mesh element ID in the corresponding field. */ void SMESHGUI_MeshInfoDlg::idChanged() { + myIDPreview->SetPointsLabeled( false ); + SVTK_Selector* selector = SMESH::GetSelector(); if ( myActor && selector ) { Handle(SALOME_InteractiveObject) IO = myActor->getIO(); TColStd_MapOfInteger ID; - QSet ids; + QSet ids; + std::vector idVec; + std::list< gp_XYZ > aGrCentersXYZ; QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts ); foreach ( QString tid, idTxt ) { long id = tid.trimmed().toLong(); - const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ? + const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ? myActor->GetObject()->GetMesh()->FindElement( id ) : myActor->GetObject()->GetMesh()->FindNode( id ); if ( e ) { ID.Add( id ); ids << id; + if ( myMode->checkedId() == ElemMode ) + { + idVec.push_back( id ); + aGrCentersXYZ.push_back( myElemInfo->getGravityCenter( e )); + } } } selector->AddOrRemoveIndex( IO, ID, false ); if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) { + + if ( myMode->checkedId() == NodeMode ) + myIDPreview->SetPointsData( myActor->GetObject()->GetMesh(), ID ); + else + myIDPreview->SetElemsData( idVec, aGrCentersXYZ ); + + bool showIDs = ( !ID.IsEmpty() && + myIDPreviewCheck->isChecked() && + myTabWidget->currentIndex() == ElemInfo ); + myIDPreview->SetPointsLabeled( showIDs, myActor->GetVisibility() ); + aViewWindow->highlight( IO, true, true ); aViewWindow->Repaint(); } @@ -3135,6 +3164,16 @@ void SMESHGUI_MeshInfoDlg::idChanged() } } +/*! + * \brief Show IDs clicked + */ +void SMESHGUI_MeshInfoDlg::idPreviewChange( bool isOn ) +{ + myIDPreview->SetPointsLabeled( isOn && !myID->text().simplified().isEmpty() ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) + aViewWindow->Repaint(); +} + void SMESHGUI_MeshInfoDlg::showItemInfo( int id ) { if ( id > 0 && myActor->GetObject()->GetMesh()->FindNode( id ) ) { diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.h b/src/SMESHGUI/SMESHGUI_MeshInfo.h index 2edf2e58a..843a37f5b 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.h @@ -52,17 +52,19 @@ class QAbstractButton; class QButtonGroup; +class QCheckBox; class QContextMenuEvent; +class QGridLayout; class QLabel; class QLineEdit; class QPushButton; class QTabWidget; class QTextBrowser; -class QGridLayout; -class SMESH_Actor; -class SMDS_MeshNode; class SMDS_MeshElement; +class SMDS_MeshNode; +class SMESHGUI_IdPreview; class SMESHGUI_SpinBox; +class SMESH_Actor; class ExtraWidget; @@ -157,6 +159,8 @@ public: void clear(); virtual void saveInfo( QTextStream &out ) = 0; + gp_XYZ getGravityCenter( const SMDS_MeshElement* e ) { return gravityCenter(e); } + protected: struct XYZ { @@ -168,6 +172,7 @@ protected: double x() const { return myX; } double y() const { return myY; } double z() const { return myZ; } + operator gp_XYZ() const { return gp_XYZ( myX, myY, myZ ); } }; typedef QMap< int, QList > Connectivity; @@ -382,19 +387,22 @@ private slots: void deactivate(); void modeChanged(); void idChanged(); + void idPreviewChange(bool); void showItemInfo( int ); void showItemInfo( const QString& ); void dump(); private: - QTabWidget* myTabWidget; - SMESHGUI_MeshInfo* myBaseInfo; - QButtonGroup* myMode; - QLineEdit* myID; - SMESHGUI_ElemInfo* myElemInfo; - SMESHGUI_AddInfo* myAddInfo; - SMESHGUI_CtrlInfo* myCtrlInfo; - SMESH_Actor* myActor; + QTabWidget* myTabWidget; + SMESHGUI_MeshInfo* myBaseInfo; + QButtonGroup* myMode; + QLineEdit* myID; + QCheckBox* myIDPreviewCheck; + SMESHGUI_IdPreview* myIDPreview; + SMESHGUI_ElemInfo* myElemInfo; + SMESHGUI_AddInfo* myAddInfo; + SMESHGUI_CtrlInfo* myCtrlInfo; + SMESH_Actor* myActor; Handle(SALOME_InteractiveObject) myIO; }; diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 2cf05756e..b6976df86 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -120,7 +120,8 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const if ( p=="client" ) val = QVariant( LightApp_Selection::parameter( p ) ); else if ( p=="type" ) val = QVariant( myTypes[ind] ); else if ( p=="hasActor" ) val = QVariant( getActor( ind ) != 0 ); - else if ( p=="elemTypes" ) val = QVariant( elemTypes( ind ) ); + else if ( p=="elemTypes" ) val = QVariant( elemTypes( ind, false ) ); + else if ( p=="objElemTypes" ) val = QVariant( elemTypes( ind, true ) ); else if ( p=="isAutoColor" ) val = QVariant( isAutoColor( ind ) ); else if ( p=="numberOfNodes" ) val = QVariant( numberOfNodes( ind ) ); else if ( p=="dim" ) val = QVariant( dim( ind ) ); @@ -168,7 +169,7 @@ QVariant SMESHGUI_Selection::parameter( const QString& p ) const //======================================================================= //function : getVtkOwner -//purpose : +//purpose : //======================================================================= SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const @@ -184,18 +185,42 @@ SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem'} at most //======================================================================= -QList SMESHGUI_Selection::elemTypes( int ind ) const +QList SMESHGUI_Selection::elemTypes( int ind, bool fromObj ) const { QList types; SMESH_Actor* actor = getActor( ind ); if ( actor ) { TVisualObjPtr object = actor->GetObject(); if ( object ) { - if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" ); - if ( object->GetNbEntities( SMDSAbs_Ball )) types.append( "BallElem" ); if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" ); if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" ); if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" ); + if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" ); + if ( object->GetNbEntities( SMDSAbs_Ball )) types.append( "BallElem" ); + } + } + else if ( fromObj ) + { + if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) + { + _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() ); + SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj ); + if ( !CORBA::is_nil( idSrc ) ) + { + SMESH::array_of_ElementType_var typeVar = idSrc->GetTypes(); + for ( CORBA::ULong i = 0; i < typeVar->length(); ++i ) + switch ( typeVar[i] ) { + case SMESH::EDGE: types.append( "Edge" ); break; + case SMESH::FACE: types.append( "Face" ); break; + case SMESH::VOLUME: types.append( "Volume" ); break; + case SMESH::ELEM0D: types.append( "Elem0d" ); break; + case SMESH::BALL: types.append( "BallElem" ); break; + case SMESH::ALL: + case SMESH::NODE: + case SMESH::NB_ELEMENT_TYPES: break; + } + } } } return types; @@ -439,13 +464,10 @@ bool SMESHGUI_Selection::isAutoColor( int ind ) const if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" ) { _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); - CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() ); - - if ( !CORBA::is_nil( obj ) ) { - SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj ); - if ( !CORBA::is_nil( mesh ) ) - return mesh->GetAutoColor(); - } + CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() ); + SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj ); + if ( !CORBA::is_nil( mesh ) ) + return mesh->GetAutoColor(); } return false; } diff --git a/src/SMESHGUI/SMESHGUI_Selection.h b/src/SMESHGUI/SMESHGUI_Selection.h index 5847126f7..71690c713 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.h +++ b/src/SMESHGUI/SMESHGUI_Selection.h @@ -71,8 +71,8 @@ public: virtual int nbChildren( int ) const; virtual bool isContainer( int ) const; - // parameters got from actor return nothing if an actor is not visible - virtual QList elemTypes( int ) const; + // parameters got from actor, return nothing if an actor is not visible + virtual QList elemTypes( int, bool ) const; // == objElemTypes w/o actor virtual QList labeledTypes( int ) const; virtual QString displayMode( int ) const; virtual QString shrinkMode( int ) const; diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index ec5537169..c3d9d8579 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -7422,6 +7422,10 @@ as they are of improper type: ELEM_MODE Element + + SHOW_IDS + Show IDs + BUT_DUMP_MESH &Dump diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index 1112eb973..464a06813 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -459,6 +459,7 @@ struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher _ebbTree[i] = NULL; _ebbTreeHeight[i] = -1; } + _elementType = SMDSAbs_All; } virtual ~SMESH_ElementSearcherImpl() { @@ -878,10 +879,10 @@ SMESH_ElementSearcherImpl::FindClosestTo( const gp_Pnt& point, TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point) { - double tolerance = getTolerance(); - _elementType = SMDSAbs_Face; + double tolerance = getTolerance(); + ElementBndBoxTree*& ebbTree = _ebbTree[ SMDSAbs_Face ]; if ( !ebbTree ) ebbTree = new ElementBndBoxTree( *_mesh, _elementType, _meshPartIt ); diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index f289a5fe7..748d4baaf 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -1469,7 +1469,7 @@ class Mesh: errText = "code %s" % -err.code if errText: errText += ". " errText += err.comment - if allReasons != "":allReasons += "\n" + if allReasons: allReasons += "\n" if ok: allReasons += '- "%s"%s - %s' %(err.algoName, shapeText, errText) else: @@ -1507,7 +1507,7 @@ class Mesh: reason = ("For unknown reason. " "Developer, revise Mesh.Compute() implementation in smeshBuilder.py!") pass - if allReasons != "":allReasons += "\n" + if allReasons: allReasons += "\n" allReasons += "- " + reason pass if not ok or allReasons != "": diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index f84fc5b5e..e977252e6 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -445,6 +445,7 @@ namespace VISCOUS_3D bool Is ( int flag ) const { return _flags & flag; } void Set ( int flag ) { _flags |= flag; } void Unset( int flag ) { _flags &= ~flag; } + std::string DumpFlags() const; // debug void SetNewLength( double len, _EdgesOnShape& eos, SMESH_MesherHelper& helper ); bool SetNewLength2d( Handle(Geom_Surface)& surface, @@ -9199,10 +9200,48 @@ void _LayerEdge::SmoothPos( const vector< double >& segLen, const double tol ) //================================================================================ /*! - * \brief Create layers of prisms + * \brief Print flags */ //================================================================================ +std::string _LayerEdge::DumpFlags() const +{ + SMESH_Comment dump; + for ( int flag = 1; flag < 0x1000000; flag *= 2 ) + if ( _flags & flag ) + { + EFlags f = (EFlags) flag; + switch ( f ) { + case TO_SMOOTH: dump << "TO_SMOOTH"; break; + case MOVED: dump << "MOVED"; break; + case SMOOTHED: dump << "SMOOTHED"; break; + case DIFFICULT: dump << "DIFFICULT"; break; + case ON_CONCAVE_FACE: dump << "ON_CONCAVE_FACE"; break; + case BLOCKED: dump << "BLOCKED"; break; + case INTERSECTED: dump << "INTERSECTED"; break; + case NORMAL_UPDATED: dump << "NORMAL_UPDATED"; break; + case MARKED: dump << "MARKED"; break; + case MULTI_NORMAL: dump << "MULTI_NORMAL"; break; + case NEAR_BOUNDARY: dump << "NEAR_BOUNDARY"; break; + case SMOOTHED_C1: dump << "SMOOTHED_C1"; break; + case DISTORTED: dump << "DISTORTED"; break; + case RISKY_SWOL: dump << "RISKY_SWOL"; break; + case SHRUNK: dump << "SHRUNK"; break; + case UNUSED_FLAG: dump << "UNUSED_FLAG"; break; + } + dump << " "; + } + cout << dump << endl; + return dump; +} + +//================================================================================ +/*! + case brief: + default: +*/ +//================================================================================ + bool _ViscousBuilder::refine(_SolidData& data) { SMESH_MesherHelper& helper = data.GetHelper();