Salome HOME
Update Help for VISU module.
[modules/visu.git] / src / PIPELINE / SALOME_ExtractGeometry.cxx
index d4b03f4ebc9398ef83a1694bbe3ed14db6603778..13655093f9dec9d295721a61059706aff983f355 100755 (executable)
@@ -1,21 +1,21 @@
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  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. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  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.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 
 
 #include "SALOME_ExtractGeometry.h"
 
 using namespace std;
 
+#if defined __GNUC__
+  #if __GNUC__ == 2
+    #define __GNUC_2__
+  #endif
+#endif
+
 
 vtkStandardNewMacro(SALOME_ExtractGeometry);
 
@@ -41,21 +47,38 @@ vtkStandardNewMacro(SALOME_ExtractGeometry);
 SALOME_ExtractGeometry::SALOME_ExtractGeometry()
 {}
 
+SALOME_ExtractGeometry::~SALOME_ExtractGeometry()
+{}
 
-SALOME_ExtractGeometry::~SALOME_ExtractGeometry(){}
+vtkIdType SALOME_ExtractGeometry::GetElemObjId(int theVtkID)
+{
+  if (myElemVTK2ObjIds.empty())
+    return theVtkID;
 
+  if (theVtkID < 0 || myElemVTK2ObjIds.size() <= theVtkID)
+    return -1;
 
-vtkIdType SALOME_ExtractGeometry::GetElemObjId(int theID){
-  if(myElemVTK2ObjIds.empty() || theID > myElemVTK2ObjIds.size()) 
-    return theID;
-  return myElemVTK2ObjIds[theID];
+#if defined __GNUC_2__
+  return myElemVTK2ObjIds[theVtkID];
+#else
+  return myElemVTK2ObjIds.at(theVtkID);
+#endif
 }
 
 
-vtkIdType SALOME_ExtractGeometry::GetNodeObjId(int theID){
-  if(myNodeVTK2ObjIds.empty() || theID > myNodeVTK2ObjIds.size()) 
-    return theID;
-  return myNodeVTK2ObjIds[theID];
+vtkIdType SALOME_ExtractGeometry::GetNodeObjId(int theVtkID)
+{
+  if (myNodeVTK2ObjIds.empty())
+    return theVtkID;
+
+  if (theVtkID < 0 || myNodeVTK2ObjIds.size() <= theVtkID)
+    return -1;
+
+#if defined __GNUC_2__
+  return myNodeVTK2ObjIds[theVtkID];
+#else
+  return myNodeVTK2ObjIds.at(theVtkID);
+#endif
 }
 
 
@@ -78,8 +101,12 @@ void SALOME_ExtractGeometry::Execute()
   if(myImplicitBoolean.GetPointer()){
     if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){
       if(aFunction->GetNumberOfItems() == 0){
+        myElemVTK2ObjIds.clear();
+        myNodeVTK2ObjIds.clear();
+
        vtkDebugMacro(<< "Extracting geometry - ShallowCopy");
        GetOutput()->ShallowCopy(GetInput());
+        Modified();
        return;
       }
     }
@@ -106,7 +133,7 @@ void SALOME_ExtractGeometry::Execute2()
   int npts;
   numCells = input->GetNumberOfCells();
   numPts = input->GetNumberOfPoints();
-  
+
   vtkDebugMacro(<< "Extracting geometry");
 
   if ( ! this->ImplicitFunction )
@@ -122,7 +149,7 @@ void SALOME_ExtractGeometry::Execute2()
     {
     multiplier = 1.0;
     }
-  else 
+  else
     {
     multiplier = -1.0;
     }
@@ -142,7 +169,7 @@ void SALOME_ExtractGeometry::Execute2()
   outputPD->CopyAllocate(pd);
   outputCD->CopyAllocate(cd);
   vtkFloatArray *newScalars = NULL;
-  
+
   if(myStoreMapping){
     myElemVTK2ObjIds.clear();
     myElemVTK2ObjIds.reserve(numCells);
@@ -214,7 +241,7 @@ void SALOME_ExtractGeometry::Execute2()
           }
         }
       } //if don't want to extract boundary cells
-    
+
     else //want boundary cells
       {
       for ( npts=0, i=0; i < numCellPts; i++ )
@@ -242,7 +269,7 @@ void SALOME_ExtractGeometry::Execute2()
           }
         }//a boundary or interior cell
       }//if mapping boundary cells
-      
+
     if ( npts >= numCellPts || (this->ExtractBoundaryCells && npts > 0) )
       {
       newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts);
@@ -257,7 +284,7 @@ void SALOME_ExtractGeometry::Execute2()
   newCellPts->Delete();
   output->SetPoints(newPts);
   newPts->Delete();
-  
+
   if ( this->ExtractBoundaryCells )
     {
     newScalars->Delete();