Salome HOME
PAL17694 (New Tool About Hexahedral Meshing)
authoreap <eap@opencascade.com>
Thu, 15 Nov 2007 14:35:25 +0000 (14:35 +0000)
committereap <eap@opencascade.com>
Thu, 15 Nov 2007 14:35:25 +0000 (14:35 +0000)
+  SMESH::NodePosition* GetNodePosition(CORBA::Long NodeID);

src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx

index 50fca8a4c1895e9df32a76cd6a169ceddc0484b0..877a0170a29853be4ab3e0cdb13f41a7ede97762 100644 (file)
@@ -44,6 +44,8 @@
 #include "SMESH_Group.hxx"
 #include "SMESH_MeshEditor.hxx"
 #include "SMESH_MesherHelper.hxx"
+#include "SMDS_EdgePosition.hxx"
+#include "SMDS_FacePosition.hxx"
 
 #include "OpUtil.hxx"
 #include "SALOME_NamingService.hxx"
 
 // OCCT Includes
 #include <BRep_Builder.hxx>
-#include <OSD_Path.hxx>
-#include <OSD_File.hxx>
 #include <OSD_Directory.hxx>
+#include <OSD_File.hxx>
+#include <OSD_Path.hxx>
 #include <OSD_Protection.hxx>
-#include <TColStd_MapOfInteger.hxx>
 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS_Compound.hxx>
 
 // STL Includes
@@ -2014,6 +2017,56 @@ SMESH::long_array* SMESH_Mesh_i::GetNodeInverseElements(const CORBA::Long id)
   return aResult._retn();
 }
 
+//=============================================================================
+/*!
+ * \brief Return position of a node on shape
+ */
+//=============================================================================
+
+SMESH::NodePosition* SMESH_Mesh_i::GetNodePosition(CORBA::Long NodeID)
+{
+  SMESH::NodePosition* aNodePosition = new SMESH::NodePosition();
+  aNodePosition->shapeID = 0;
+  aNodePosition->shapeType = GEOM::SHAPE;
+
+  SMESHDS_Mesh* mesh = _impl->GetMeshDS();
+  if ( !mesh ) return aNodePosition;
+
+  if ( const SMDS_MeshNode* aNode = mesh->FindNode(NodeID) )
+  {
+    if ( SMDS_PositionPtr pos = aNode->GetPosition() )
+    {
+      aNodePosition->shapeID = pos->GetShapeId();
+      switch ( pos->GetTypeOfPosition() ) {
+      case SMDS_TOP_EDGE:
+        aNodePosition->shapeType = GEOM::EDGE;
+        aNodePosition->params.length(1);
+        aNodePosition->params[0] =
+          static_cast<SMDS_EdgePosition*>( pos.get() )->GetUParameter();
+        break;
+      case SMDS_TOP_FACE:
+        aNodePosition->shapeType = GEOM::FACE;
+        aNodePosition->params.length(2);
+        aNodePosition->params[0] =
+          static_cast<SMDS_FacePosition*>( pos.get() )->GetUParameter();
+        aNodePosition->params[1] =
+          static_cast<SMDS_FacePosition*>( pos.get() )->GetVParameter();
+        break;
+      case SMDS_TOP_VERTEX:
+        aNodePosition->shapeType = GEOM::VERTEX;
+        break;
+      case SMDS_TOP_3DSPACE:
+        if ( TopExp_Explorer(_impl->GetShapeToMesh(), TopAbs_SOLID).More() )
+          aNodePosition->shapeType = GEOM::SOLID;
+        else if ( TopExp_Explorer(_impl->GetShapeToMesh(), TopAbs_SHELL).More() )
+          aNodePosition->shapeType = GEOM::SHELL;
+        break;
+      default:;
+      }
+    }
+  }
+  return aNodePosition;
+}
 
 //=============================================================================
 /*!
index 2f1a65b60c2efb7feaf8b442cfcc7f44bbf88309..74fe46d3dd72467ee0e16ab4c63b6ae570b00c46 100644 (file)
@@ -347,6 +347,11 @@ public:
    */
   SMESH::long_array* GetNodeInverseElements(const CORBA::Long id);
 
+  /*!
+   * \brief Return position of a node on shape
+   */
+  SMESH::NodePosition* GetNodePosition(CORBA::Long NodeID);
+
   /*!
    * If given element is node returns IDs of shape from position
    * If there is not node for given ID - returns -1