1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File: VISU_StreamLinesPL.cxx
24 // Author: Alexey PETROV
28 #include "VISU_UsedPointsFilter.hxx"
30 #include <vtkObjectFactory.h>
31 #include <vtkPointSet.h>
32 #include <vtkPointData.h>
33 #include <vtkCellData.h>
34 #include <vtkPoints.h>
35 #include <vtkIdList.h>
38 static int MYDEBUG = 0;
40 static int MYDEBUG = 0;
43 vtkStandardNewMacro(VISU_UsedPointsFilter);
45 VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
46 PercentsOfUsedPoints = 0.1;
49 VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
51 void VISU_UsedPointsFilter::Execute(){
52 vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
53 anOutput->GetPointData()->CopyAllOff();
54 anOutput->GetCellData()->CopyAllOff();
55 vtkPoints* aPoints = vtkPoints::New();
56 vtkIdType aCellSize = anInput->GetMaxCellSize();
57 vtkIdList *anIdList = vtkIdList::New();
58 vtkIdType iEnd = anInput->GetNumberOfPoints();
59 for(vtkIdType i = 0; i < iEnd; i++){
60 anInput->GetPointCells(i,anIdList);
61 if(anIdList->GetNumberOfIds() > 0)
62 aPoints->InsertNextPoint(anInput->GetPoint(i));
64 static float EPS = 1E-5;
65 if(PercentsOfUsedPoints < EPS){
66 anOutput->SetPoints(aPoints);
68 vtkPoints* aNewPoints = vtkPoints::New();
69 iEnd = aPoints->GetNumberOfPoints();
70 vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
71 if(anOffset < 1) anOffset = 1;
72 for(vtkIdType i = 0; i < iEnd; i += anOffset)
73 aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
74 anOutput->SetPoints(aNewPoints);