Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_UsedPointsFilter.cxx
index 9e2e261211f8ebbea0d298f72ea5f2a662088388..311248cf0a57e3546e09f5b570a6bb8d30e67f85 100644 (file)
@@ -1,23 +1,23 @@
 //  VISU OBJECT : interactive object for VISU entities implementation
 //
 //  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
 //
 //
 // File:    VISU_StreamLinesPL.cxx
 #include <vtkPoints.h>
 #include <vtkIdList.h>
 
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
 vtkStandardNewMacro(VISU_UsedPointsFilter);
 
 VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
-  PercentsOfUsedPoints = 0.1;
+  PercentsOfUsedPoints = 1.0;
 }
 
 VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
@@ -52,27 +46,25 @@ void VISU_UsedPointsFilter::Execute(){
   vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
   anOutput->GetPointData()->CopyAllOff();
   anOutput->GetCellData()->CopyAllOff();
+  anOutput->CopyStructure(anInput);
+
   vtkPoints* aPoints = vtkPoints::New();
-  vtkIdType aCellSize = anInput->GetMaxCellSize();
-  vtkIdList *anIdList = vtkIdList::New(); 
+  vtkIdList *anIdList = vtkIdList::New();
   vtkIdType iEnd = anInput->GetNumberOfPoints();
   for(vtkIdType i = 0; i < iEnd; i++){
     anInput->GetPointCells(i,anIdList);
     if(anIdList->GetNumberOfIds() > 0)
       aPoints->InsertNextPoint(anInput->GetPoint(i));
   }
-  static float EPS = 1E-5;
-  if(PercentsOfUsedPoints < EPS){
-    anOutput->SetPoints(aPoints);
-  }else{
-    vtkPoints* aNewPoints = vtkPoints::New();
-    iEnd = aPoints->GetNumberOfPoints();
+  vtkPoints* aNewPoints = vtkPoints::New();
+  iEnd = aPoints->GetNumberOfPoints();
+  if (PercentsOfUsedPoints > 0){
     vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
     if(anOffset < 1) anOffset = 1;
     for(vtkIdType i = 0; i < iEnd; i += anOffset)
       aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
-    anOutput->SetPoints(aNewPoints);
-    aNewPoints->Delete();
   }
+  anOutput->SetPoints(aNewPoints);
+  aNewPoints->Delete();
   aPoints->Delete();
 }