From 712a8ce960f9f03deaab3989492c4eaebc9c6e21 Mon Sep 17 00:00:00 2001 From: mpa Date: Tue, 1 Apr 2014 16:54:27 +0400 Subject: [PATCH] 0022537: EDF 2877 SMESH : wrong information about the numbre of nodes with polyhedra --- src/SMESHGUI/CMakeLists.txt | 1 + src/SMESHGUI/SMESHGUI_MeshInfo.cxx | 160 ++++++++++++++++++----------- src/SMESHGUI/SMESHGUI_MeshInfo.h | 1 + 3 files changed, 102 insertions(+), 60 deletions(-) diff --git a/src/SMESHGUI/CMakeLists.txt b/src/SMESHGUI/CMakeLists.txt index 39f744757..7852ef6de 100644 --- a/src/SMESHGUI/CMakeLists.txt +++ b/src/SMESHGUI/CMakeLists.txt @@ -74,6 +74,7 @@ SET(_link_LIBRARIES ${GEOM_GEOMObject} SMESHFiltersSelection SMDS + SMESHEngine SMESHControls SMESHObject ) diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index c67112d47..4fdf52051 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -29,6 +29,7 @@ #include "SMDS_EdgePosition.hxx" #include "SMDS_FacePosition.hxx" #include "SMDS_Mesh.hxx" +#include "SMESH_Gen_i.hxx" #include "SMESHDS_Mesh.hxx" #include "SMESHGUI.h" #include "SMESHGUI_FilterUtils.h" @@ -1838,66 +1839,34 @@ void SMESHGUI_TreeElemInfo::information( const QList& ids ) // connectivity QTreeWidgetItem* conItem = createItem( elemItem, Bold ); conItem->setText( 0, SMESHGUI_ElemInfo::tr( "CONNECTIVITY" ) ); - SMDS_ElemIteratorPtr nodeIt = e->nodesIterator(); - for ( int idx = 1; nodeIt->more(); idx++ ) { - const SMDS_MeshNode* node = static_cast( nodeIt->next() ); - // node number and ID - QTreeWidgetItem* nodeItem = createItem( conItem, Bold ); - nodeItem->setText( 0, QString( "%1 %2 / %3" ).arg( SMESHGUI_ElemInfo::tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) ); - nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) ); - nodeItem->setData( 1, TypeRole, ElemConnectivity ); - nodeItem->setData( 1, IdRole, node->GetID() ); - nodeItem->setExpanded( false ); - // node coordinates - QTreeWidgetItem* coordItem = createItem( nodeItem ); - coordItem->setText( 0, SMESHGUI_ElemInfo::tr( "COORDINATES" ) ); - QTreeWidgetItem* xItem = createItem( coordItem ); - xItem->setText( 0, "X" ); - xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); - QTreeWidgetItem* yItem = createItem( coordItem ); - yItem->setText( 0, "Y" ); - yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); - QTreeWidgetItem* zItem = createItem( coordItem ); - zItem->setText( 0, "Z" ); - zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); - // node connectivity - QTreeWidgetItem* nconItem = createItem( nodeItem ); - nconItem->setText( 0, SMESHGUI_ElemInfo::tr( "CONNECTIVITY" ) ); - Connectivity connectivity = nodeConnectivity( node ); - if ( !connectivity.isEmpty() ) { - QString con = formatConnectivity( connectivity, SMDSAbs_0DElement ); - if ( !con.isEmpty() ) { - QTreeWidgetItem* i = createItem( nconItem ); - i->setText( 0, SMESHGUI_ElemInfo::tr( "0D_ELEMENTS" ) ); - i->setText( 1, con ); - } - con = formatConnectivity( connectivity, SMDSAbs_Edge ); - if ( !con.isEmpty() ) { - QTreeWidgetItem* i = createItem( nconItem ); - i->setText( 0, SMESHGUI_ElemInfo::tr( "EDGES" ) ); - i->setText( 1, con ); - i->setData( 1, TypeRole, NodeConnectivity ); - } - con = formatConnectivity( connectivity, SMDSAbs_Ball ); - if ( !con.isEmpty() ) { - QTreeWidgetItem* i = createItem( nconItem ); - i->setText( 0, SMESHGUI_ElemInfo::tr( "BALL_ELEMENTS" ) ); - i->setText( 1, con ); - i->setData( 1, TypeRole, NodeConnectivity ); - } - con = formatConnectivity( connectivity, SMDSAbs_Face ); - if ( !con.isEmpty() ) { - QTreeWidgetItem* i = createItem( nconItem ); - i->setText( 0, SMESHGUI_ElemInfo::tr( "FACES" ) ); - i->setText( 1, con ); - i->setData( 1, TypeRole, NodeConnectivity ); - } - con = formatConnectivity( connectivity, SMDSAbs_Volume ); - if ( !con.isEmpty() ) { - QTreeWidgetItem* i = createItem( nconItem ); - i->setText( 0, SMESHGUI_ElemInfo::tr( "VOLUMES" ) ); - i->setText( 1, con ); - i->setData( 1, TypeRole, NodeConnectivity ); + + + if( e->GetGeomType() != SMDSGeom_POLYHEDRA ) { + SMDS_ElemIteratorPtr nodeIt = e->nodesIterator(); + for ( int idx = 1; nodeIt->more(); idx++ ) { + const SMDS_MeshNode* node = static_cast( nodeIt->next() ); + nodeInfo( node, idx, e->NbNodes(), conItem ); + } + } + else { + const SMDS_VtkVolume* aVtkVolume = dynamic_cast(e); + SMDS_ElemIteratorPtr nodeIt = aVtkVolume->uniqueNodesIterator(); + QList uniqueNodes; + while ( nodeIt->more() ) + uniqueNodes.append( nodeIt->next() ); + + SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer(); + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( aMesh ); + const int nbFaces = mesh_i->ElemNbFaces( e->GetID() ); + for( int i = 0; i < nbFaces; i++ ) { + QTreeWidgetItem* faceItem = createItem( conItem, Bold ); + faceItem->setText( 0, QString( "%1 %2 / %3" ).arg( SMESHGUI_ElemInfo::tr( "FACE" ) ).arg( i + 1 ).arg( nbFaces ) ); + faceItem->setExpanded( true ); + + SMESH::long_array_var anNodeIds = mesh_i->GetElemFaceNodes( e->GetID(), i ); + for( CORBA::Long node_id = 0, n = anNodeIds->length(); node_id < n; node_id++ ) { + const SMDS_MeshNode* node = actor()->GetObject()->GetMesh()->FindNode( anNodeIds[node_id] ); + nodeInfo( node, uniqueNodes.indexOf(node) + 1, aVtkVolume->NbUniqueNodes(), faceItem ); } } } @@ -2077,6 +2046,77 @@ void SMESHGUI_TreeElemInfo::information( const QList& ids ) } } +/*! + \brief Show node information + \param node mesh node for showing + \param index index of current node + \param nbNodes number of unique nodes in element + \param parentItem parent item of tree +*/ +void SMESHGUI_TreeElemInfo::nodeInfo( const SMDS_MeshNode* node, int index, + int nbNodes, QTreeWidgetItem* parentItem ) +{ + int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 ); + // node number and ID + QTreeWidgetItem* nodeItem = createItem( parentItem, Bold ); + nodeItem->setText( 0, QString( "%1 %2 / %3" ).arg( SMESHGUI_ElemInfo::tr( "NODE" ) ).arg( index ).arg( nbNodes ) ); + nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) ); + nodeItem->setData( 1, TypeRole, ElemConnectivity ); + nodeItem->setData( 1, IdRole, node->GetID() ); + nodeItem->setExpanded( false ); + // node coordinates + QTreeWidgetItem* coordItem = createItem( nodeItem ); + coordItem->setText( 0, SMESHGUI_ElemInfo::tr( "COORDINATES" ) ); + QTreeWidgetItem* xItem = createItem( coordItem ); + xItem->setText( 0, "X" ); + xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + QTreeWidgetItem* yItem = createItem( coordItem ); + yItem->setText( 0, "Y" ); + yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + QTreeWidgetItem* zItem = createItem( coordItem ); + zItem->setText( 0, "Z" ); + zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + // node connectivity + QTreeWidgetItem* nconItem = createItem( nodeItem ); + nconItem->setText( 0, SMESHGUI_ElemInfo::tr( "CONNECTIVITY" ) ); + Connectivity connectivity = nodeConnectivity( node ); + if ( !connectivity.isEmpty() ) { + QString con = formatConnectivity( connectivity, SMDSAbs_0DElement ); + if ( !con.isEmpty() ) { + QTreeWidgetItem* i = createItem( nconItem ); + i->setText( 0, SMESHGUI_ElemInfo::tr( "0D_ELEMENTS" ) ); + i->setText( 1, con ); + } + con = formatConnectivity( connectivity, SMDSAbs_Edge ); + if ( !con.isEmpty() ) { + QTreeWidgetItem* i = createItem( nconItem ); + i->setText( 0, SMESHGUI_ElemInfo::tr( "EDGES" ) ); + i->setText( 1, con ); + i->setData( 1, TypeRole, NodeConnectivity ); + } + con = formatConnectivity( connectivity, SMDSAbs_Ball ); + if ( !con.isEmpty() ) { + QTreeWidgetItem* i = createItem( nconItem ); + i->setText( 0, SMESHGUI_ElemInfo::tr( "BALL_ELEMENTS" ) ); + i->setText( 1, con ); + i->setData( 1, TypeRole, NodeConnectivity ); + } + con = formatConnectivity( connectivity, SMDSAbs_Face ); + if ( !con.isEmpty() ) { + QTreeWidgetItem* i = createItem( nconItem ); + i->setText( 0, SMESHGUI_ElemInfo::tr( "FACES" ) ); + i->setText( 1, con ); + i->setData( 1, TypeRole, NodeConnectivity ); + } + con = formatConnectivity( connectivity, SMDSAbs_Volume ); + if ( !con.isEmpty() ) { + QTreeWidgetItem* i = createItem( nconItem ); + i->setText( 0, SMESHGUI_ElemInfo::tr( "VOLUMES" ) ); + i->setText( 1, con ); + i->setData( 1, TypeRole, NodeConnectivity ); + } + } +} /*! \brief Internal clean-up (reset widget) */ diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.h b/src/SMESHGUI/SMESHGUI_MeshInfo.h index 69faa42cc..54ee1aca5 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.h @@ -226,6 +226,7 @@ public: protected: void contextMenuEvent( QContextMenuEvent* e ); void information( const QList& ); + void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* ); void clearInternal(); private slots: -- 2.39.2