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>
37 vtkStandardNewMacro(VISU_UsedPointsFilter);
39 VISU_UsedPointsFilter::VISU_UsedPointsFilter(){
40 PercentsOfUsedPoints = 1.0;
43 VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){}
45 void VISU_UsedPointsFilter::Execute(){
46 vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
47 anOutput->GetPointData()->CopyAllOff();
48 anOutput->GetCellData()->CopyAllOff();
49 anOutput->CopyStructure(anInput);
51 vtkPoints* aPoints = vtkPoints::New();
52 vtkIdList *anIdList = vtkIdList::New();
53 vtkIdType iEnd = anInput->GetNumberOfPoints();
54 for(vtkIdType i = 0; i < iEnd; i++){
55 anInput->GetPointCells(i,anIdList);
56 if(anIdList->GetNumberOfIds() > 0)
57 aPoints->InsertNextPoint(anInput->GetPoint(i));
59 vtkPoints* aNewPoints = vtkPoints::New();
60 iEnd = aPoints->GetNumberOfPoints();
61 if (PercentsOfUsedPoints > 0){
62 vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
63 if(anOffset < 1) anOffset = 1;
64 for(vtkIdType i = 0; i < iEnd; i += anOffset)
65 aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
67 anOutput->SetPoints(aNewPoints);