Salome HOME
0022876: EDF 8425 SMESH: Get the normal of a face in the GUI
authorvsr <vsr@opencascade.com>
Fri, 20 Feb 2015 08:07:49 +0000 (11:07 +0300)
committervsr <vsr@opencascade.com>
Fri, 20 Feb 2015 08:07:49 +0000 (11:07 +0300)
src/SMESHGUI/SMESHGUI_MeshInfo.cxx
src/SMESHGUI/SMESHGUI_MeshInfo.h
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts
src/SMESHGUI/SMESH_msg_ja.ts

index ef9a1b31368d7295e677e3a6596558a3eaf4a348..1cc3df96a30de8497c48b9dda8fc9c0547e2b74d 100644 (file)
@@ -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<const SMDS_MeshFace*>( 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<long>& ids )
         // Gravity center
         XYZ gc = gravityCenter( e );
         myInfo->append( QString( "<b>%1:</b> (%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( "<b>%1:</b> (%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<long>& 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 ) {
index d87ff62415b52b8b01dc0d7ac6b91dc69bbe7926..5b00585aa01044b362cb09fd4694cef055d70055 100644 (file)
@@ -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 );
index d5d08ad1769f142efe6e1aa9b036985bb8777651..ca99ab64ac87933d2af511a004abd220271e27b5 100644 (file)
@@ -7102,6 +7102,10 @@ as they are of improper type:
         <source>GRAVITY_CENTER</source>
         <translation>Gravity Center</translation>
     </message>
+    <message>
+        <source>NORMAL_VECTOR</source>
+        <translation>Normal</translation>
+    </message>
     <message>
         <source>NODE</source>
         <translation>Node</translation>
index 4148a30f3de1de0a1663673fb3fd6b593bf040f9..24ae38d9969be7ee32f50451d9fe9e72e8c2b5d7 100755 (executable)
@@ -7103,6 +7103,10 @@ en raison de leurs types incompatibles:
         <source>GRAVITY_CENTER</source>
         <translation>CENTRE DE GRAVITÉ</translation>
     </message>
+    <message>
+        <source>NORMAL_VECTOR</source>
+        <translation>Normal</translation>
+    </message>
     <message>
         <source>NODE</source>
         <translation>Nœud</translation>
index ae78bc09b99d5bc5b498d3fbbba5ef1f896d65f3..0c544fbc9576cb13deb5a95eab480e30a4efb63d 100644 (file)
       <source>GRAVITY_CENTER</source>
       <translation>重心</translation>
     </message>
+    <message>
+      <source>NORMAL_VECTOR</source>
+      <translation>通常</translation>
+    </message>
     <message>
       <source>NODE</source>
       <translation>ノード</translation>