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 = 1.0;
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 anOutput->CopyStructure(anInput);
57 vtkPoints* aPoints = vtkPoints::New();
58 vtkIdType aCellSize = anInput->GetMaxCellSize();
59 vtkIdList *anIdList = vtkIdList::New();
60 vtkIdType iEnd = anInput->GetNumberOfPoints();
61 for(vtkIdType i = 0; i < iEnd; i++){
62 anInput->GetPointCells(i,anIdList);
63 if(anIdList->GetNumberOfIds() > 0)
64 aPoints->InsertNextPoint(anInput->GetPoint(i));
66 vtkPoints* aNewPoints = vtkPoints::New();
67 iEnd = aPoints->GetNumberOfPoints();
68 if (PercentsOfUsedPoints > 0){
69 vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
70 if(anOffset < 1) anOffset = 1;
71 for(vtkIdType i = 0; i < iEnd; i += anOffset)
72 aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
74 anOutput->SetPoints(aNewPoints);