1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File: VISU_StreamLinesPL.cxx
24 // Author: Alexey PETROV
27 #include "VISU_MaskPointsFilter.hxx"
29 #include <vtkObjectFactory.h>
30 #include <vtkPointSet.h>
31 #include <vtkPointData.h>
32 #include <vtkCellData.h>
33 #include <vtkPoints.h>
34 #include <vtkIdList.h>
36 vtkStandardNewMacro(VISU_MaskPointsFilter);
38 VISU_MaskPointsFilter::VISU_MaskPointsFilter(){
39 PercentsOfUsedPoints = 1.0;
42 VISU_MaskPointsFilter::~VISU_MaskPointsFilter(){}
44 void VISU_MaskPointsFilter::Execute(){
45 vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput();
46 anOutput->GetPointData()->CopyAllOff();
47 anOutput->GetCellData()->CopyAllOff();
48 anOutput->CopyStructure(anInput);
50 vtkPoints* aPoints = vtkPoints::New();
51 vtkIdList *anIdList = vtkIdList::New();
52 vtkIdType iEnd = anInput->GetNumberOfPoints();
53 for(vtkIdType i = 0; i < iEnd; i++){
54 anInput->GetPointCells(i,anIdList);
55 if(anIdList->GetNumberOfIds() > 0)
56 aPoints->InsertNextPoint(anInput->GetPoint(i));
58 vtkPoints* aNewPoints = vtkPoints::New();
59 iEnd = aPoints->GetNumberOfPoints();
60 if (PercentsOfUsedPoints > 0){
61 vtkIdType anOffset = vtkIdType(1.0/PercentsOfUsedPoints);
62 if(anOffset < 1) anOffset = 1;
63 for(vtkIdType i = 0; i < iEnd; i += anOffset)
64 aNewPoints->InsertNextPoint(aPoints->GetPoint(i));
66 anOutput->SetPoints(aNewPoints);