Salome HOME
22833: [CEA 1346] to extrude a group of faces following the normal of each face
[modules/smesh.git] / src / OBJECT / SMESH_Object.cxx
index 94cf59d5fed22152a22ca40ad3e87d85dde2f79c..038a2a2bc092de49aaee6083a690cb055abb6d14 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -151,48 +151,56 @@ SMESH_VisualObjDef::~SMESH_VisualObjDef()
 //=================================================================================
 vtkIdType SMESH_VisualObjDef::GetNodeObjId( int theVTKID )
 {
-        if (myLocalGrid)
-        {
-                TMapOfIds::const_iterator i = myVTK2SMDSNodes.find(theVTKID);
-                return i == myVTK2SMDSNodes.end() ? -1 : i->second;
-        }
-  return this->GetMesh()->FindNodeVtk(theVTKID)->GetID();
+  if (myLocalGrid)
+  {
+    TMapOfIds::const_iterator i = myVTK2SMDSNodes.find(theVTKID);
+    return i == myVTK2SMDSNodes.end() ? -1 : i->second;
+  }
+  const SMDS_MeshNode* aNode = 0;
+  if( this->GetMesh() )
+    aNode = this->GetMesh()->FindNodeVtk( theVTKID );
+
+  return aNode ? aNode->GetID() : -1;
 }
 
 vtkIdType SMESH_VisualObjDef::GetNodeVTKId( int theObjID )
 {
-        if (myLocalGrid)
-        {
-                TMapOfIds::const_iterator i = mySMDS2VTKNodes.find(theObjID);
+  if (myLocalGrid)
+  {
+    TMapOfIds::const_iterator i = mySMDS2VTKNodes.find(theObjID);
     return i == mySMDS2VTKNodes.end() ? -1 : i->second;
-        }
+  }
 
-        const SMDS_MeshNode* aNode = 0;
-        if( this->GetMesh() ) {
-          aNode = this->GetMesh()->FindNode(theObjID);
-        }
-        return aNode ? aNode->getVtkId() : -1;
+  const SMDS_MeshNode* aNode = 0;
+  if( this->GetMesh() ) {
+    aNode = this->GetMesh()->FindNode(theObjID);
+  }
+  return aNode ? aNode->getVtkId() : -1;
 }
 
 vtkIdType SMESH_VisualObjDef::GetElemObjId( int theVTKID )
 {
-        if (myLocalGrid)
-        {
-                TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
-                return i == myVTK2SMDSElems.end() ? -1 : i->second;
-        }
+  if (myLocalGrid)
+  {
+    TMapOfIds::const_iterator i = myVTK2SMDSElems.find(theVTKID);
+    return i == myVTK2SMDSElems.end() ? -1 : i->second;
+  }
   return this->GetMesh()->fromVtkToSmds(theVTKID);
 }
 
 vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID )
 {
-        if (myLocalGrid)
-        {
-                TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID);
-                return i == mySMDS2VTKElems.end() ? -1 : i->second;
-        }
-  return this->GetMesh()->FindElement(theObjID)->getVtkId();
-  //return this->GetMesh()->fromSmdsToVtk(theObjID);
+  if (myLocalGrid)
+  {
+    TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID);
+    return i == mySMDS2VTKElems.end() ? -1 : i->second;
+  }
+
+  const SMDS_MeshElement* e = 0;
+  if ( this->GetMesh() )
+    e = this->GetMesh()->FindElement(theObjID);
+
+  return e ? e->getVtkId() : -1;
 }
 
 //=================================================================================