From 15963fa362143c7a99ae91a6e6f2e10860160250 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 20 Feb 2015 11:07:49 +0300 Subject: [PATCH] 0022876: EDF 8425 SMESH: Get the normal of a face in the GUI --- src/SMESHGUI/SMESHGUI_MeshInfo.cxx | 33 ++++++++++++++++++++++++++++++ src/SMESHGUI/SMESHGUI_MeshInfo.h | 2 ++ src/SMESHGUI/SMESH_msg_en.ts | 4 ++++ src/SMESHGUI/SMESH_msg_fr.ts | 4 ++++ src/SMESHGUI/SMESH_msg_ja.ts | 4 ++++ 5 files changed, 47 insertions(+) diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index ef9a1b313..1cc3df96a 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -1046,6 +1046,16 @@ SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::gravityCenter( const SMDS_MeshElement* return xyz; } +/*! + \brief Calculate normal vector to the mesh face + \param element mesh face +*/ +SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::normal( const SMDS_MeshElement* element ) +{ + gp_XYZ n = SMESH::getNormale( dynamic_cast( element ) ); + return XYZ(n.X(), n.Y(), n.Z()); +} + /*! \brief This slot is called from "Show Previous" button click. Shows information on the previous group of the items. @@ -1423,6 +1433,12 @@ void SMESHGUI_SimpleElemInfo::information( const QList& ids ) // Gravity center XYZ gc = gravityCenter( e ); myInfo->append( QString( "%1: (%2, %3, %4)" ).arg( SMESHGUI_ElemInfo::tr( "GRAVITY_CENTER" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) ); + + // Normal vector + if( e->GetType() == SMDSAbs_Face ) { + XYZ gc = normal( e ); + myInfo->append( QString( "%1: (%2, %3, %4)" ).arg( SMESHGUI_ElemInfo::tr( "NORMAL_VECTOR" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) ); + } // Element position if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) { @@ -1967,6 +1983,23 @@ void SMESHGUI_TreeElemInfo::information( const QList& ids ) QTreeWidgetItem* zItem = createItem( gcItem ); zItem->setText( 0, "Z" ); zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + + // normal vector + if( e->GetType() == SMDSAbs_Face ) { + XYZ gc = normal( e ); + QTreeWidgetItem* nItem = createItem( elemItem, Bold ); + nItem->setText( 0, SMESHGUI_ElemInfo::tr( "NORMAL_VECTOR" ) ); + QTreeWidgetItem* xItem = createItem( nItem ); + xItem->setText( 0, "X" ); + xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + QTreeWidgetItem* yItem = createItem( nItem ); + yItem->setText( 0, "Y" ); + yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + QTreeWidgetItem* zItem = createItem( nItem ); + zItem->setText( 0, "Z" ); + zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) ); + } + // element position SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer(); if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) { diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.h b/src/SMESHGUI/SMESHGUI_MeshInfo.h index d87ff6241..5b00585aa 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.h @@ -158,6 +158,7 @@ protected: { double myX, myY, myZ; XYZ() { myX = myY = myZ = 0.0; } + XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; } void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; } void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } } double x() const { return myX; } @@ -176,6 +177,7 @@ protected: Connectivity nodeConnectivity( const SMDS_MeshNode* ); QString formatConnectivity( Connectivity, int ); XYZ gravityCenter( const SMDS_MeshElement* ); + XYZ normal( const SMDS_MeshElement* ); signals: void itemInfo( int ); diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index d5d08ad17..ca99ab64a 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -7102,6 +7102,10 @@ as they are of improper type: GRAVITY_CENTER Gravity Center + + NORMAL_VECTOR + Normal + NODE Node diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 4148a30f3..24ae38d99 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -7103,6 +7103,10 @@ en raison de leurs types incompatibles: GRAVITY_CENTER CENTRE DE GRAVITÉ + + NORMAL_VECTOR + Normal + NODE Nœud diff --git a/src/SMESHGUI/SMESH_msg_ja.ts b/src/SMESHGUI/SMESH_msg_ja.ts index ae78bc09b..0c544fbc9 100644 --- a/src/SMESHGUI/SMESH_msg_ja.ts +++ b/src/SMESHGUI/SMESH_msg_ja.ts @@ -6988,6 +6988,10 @@ GRAVITY_CENTER 重心 + + NORMAL_VECTOR + 通常 + NODE ノード -- 2.39.2