From: eap Date: Thu, 26 Dec 2013 15:07:24 +0000 (+0000) Subject: 22368: EDF SMESH: Pattern mapping to assign new nodes to sub-shapes X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1d6cfba4c10cf9b91b8489d58c0d89e11e929566;p=modules%2Fsmesh.git 22368: EDF SMESH: Pattern mapping to assign new nodes to sub-shapes + /*! + * Returns three components of normal of given mesh face. + */ + double_array GetFaceNormal(in long faceId); --- diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index fb85b15af..ff60e68ad 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -925,6 +925,11 @@ module SMESH */ long_array GetElemFaceNodes(in long elemId, in short faceIndex); + /*! + * Returns three components of normal of given mesh face (or an empty array in KO case) + */ + double_array GetFaceNormal(in long faceId); + /*! * Returns an element based on all given nodes. */ diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 812d3c0cd..f6beb92d5 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -44,6 +44,7 @@ #include "SMESH_Gen_i.hxx" #include "SMESH_Group.hxx" #include "SMESH_Group_i.hxx" +#include "SMESH_MeshAlgos.hxx" #include "SMESH_MeshEditor.hxx" #include "SMESH_MeshEditor_i.hxx" #include "SMESH_MeshPartDS.hxx" @@ -4023,6 +4024,32 @@ SMESH::long_array* SMESH_Mesh_i::GetElemFaceNodes(CORBA::Long elemId, return aResult._retn(); } +//======================================================================= +//function : GetElemFaceNodes +//purpose : Returns three components of normal of given mesh face. +//======================================================================= + +SMESH::double_array* SMESH_Mesh_i::GetFaceNormal(CORBA::Long elemId) +{ + if ( _preMeshInfo ) + _preMeshInfo->FullLoadFromFile(); + + SMESH::double_array_var aResult = new SMESH::double_array(); + + if ( SMESHDS_Mesh* mesh = _impl->GetMeshDS() ) + { + gp_XYZ normal; + if ( SMESH_MeshAlgos::FaceNormal( mesh->FindElement(elemId), normal, /*normalized=*/true )) + { + aResult->length( 3 ); + aResult[ 0 ] = normal.X(); + aResult[ 1 ] = normal.Y(); + aResult[ 2 ] = normal.Z(); + } + } + return aResult._retn(); +} + //======================================================================= //function : FindElementByNodes //purpose : Returns an element based on all given nodes. diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index c52699bb2..2615bef48 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -532,6 +532,11 @@ public: */ SMESH::long_array* GetElemFaceNodes(CORBA::Long elemId, CORBA::Short faceIndex); + /*! + * Returns three components of normal of given mesh face (or an empty array in KO case) + */ + SMESH::double_array* GetFaceNormal(CORBA::Long faceId); + /*! * Returns an element based on all given nodes. */ diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index cbf8f5cba..fb41de62f 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -2418,6 +2418,12 @@ class Mesh: def GetElemFaceNodes(self,elemId, faceIndex): return self.mesh.GetElemFaceNodes(elemId, faceIndex) + ## Returns three components of normal of given mesh face + # (or an empty array in KO case) + # @ingroup l1_meshinfo + def GetFaceNormal(self, faceId): + return self.mesh.GetFaceNormal(faceId) + ## Returns an element based on all given nodes. # @ingroup l1_meshinfo def FindElementByNodes(self,nodes): @@ -3181,7 +3187,8 @@ class Mesh: # Note that nodes built on edges and boundary nodes are always fixed. # @param MaxNbOfIterations the maximum number of iterations # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @param Method is either Laplacian (SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH) + # or Centroidal (SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH) # @return TRUE in case of success, FALSE otherwise. # @ingroup l2_modif_smooth def Smooth(self, IDsOfElements, IDsOfFixedNodes, @@ -3199,7 +3206,8 @@ class Mesh: # Note that nodes built on edges and boundary nodes are always fixed. # @param MaxNbOfIterations the maximum number of iterations # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @param Method is either Laplacian (SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH) + # or Centroidal (SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH) # @return TRUE in case of success, FALSE otherwise. # @ingroup l2_modif_smooth def SmoothObject(self, theObject, IDsOfFixedNodes, @@ -3215,7 +3223,8 @@ class Mesh: # Note that nodes built on edges and boundary nodes are always fixed. # @param MaxNbOfIterations the maximum number of iterations # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @param Method is either Laplacian (SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH) + # or Centroidal (SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH) # @return TRUE in case of success, FALSE otherwise. # @ingroup l2_modif_smooth def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes, @@ -3233,7 +3242,8 @@ class Mesh: # Note that nodes built on edges and boundary nodes are always fixed. # @param MaxNbOfIterations the maximum number of iterations # @param MaxAspectRatio varies in range [1.0, inf] - # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH) + # @param Method is either Laplacian (SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH) + # or Centroidal (SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH) # @return TRUE in case of success, FALSE otherwise. # @ingroup l2_modif_smooth def SmoothParametricObject(self, theObject, IDsOfFixedNodes,