VMTK
Loading...
Searching...
No Matches
vtkvmtkCellDimensionFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkCellDimensionFilter.cxx,v $
5 Language: C++
6 Date: $$
7 Version: $$
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notices for more information.
19
20 Note: this class was contributed by
21 Tangui Morvan
22 Kalkulo AS
23 Simula Research Laboratory
24=========================================================================*/
25
27#include "vtkUnstructuredGrid.h"
28#include "vtkThreshold.h"
29#include "vtkIntArray.h"
30#include "vtkCell.h"
31#include "vtkCellData.h"
32#include "vtkInformation.h"
33#include "vtkInformationVector.h"
34#include "vtkObjectFactory.h"
35#include "vtkVersion.h"
36
37
39
41{
42 this->Threshold = vtkThreshold::New();
43}
44
46{
47 if (this->Threshold)
48 {
49 this->Threshold->Delete();
50 }
51}
52
54{
55 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
56 return 1;
57}
58
59
61{
62#if VTK_MAJOR_VERSION >= 9
63 Threshold->SetLowerThreshold(lower);
64 Threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_LOWER);
65#else
66 Threshold->ThresholdByLower(lower);
67#endif
68}
69
71{
72#if VTK_MAJOR_VERSION >= 9
73 Threshold->SetUpperThreshold(upper);
74 Threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_UPPER);
75#else
76 Threshold->ThresholdByUpper(upper);
77#endif
78}
79
81{
82#if VTK_MAJOR_VERSION >= 9
83 Threshold->SetLowerThreshold(lower);
84 Threshold->SetUpperThreshold(upper);
85 Threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN);
86#else
87 Threshold->ThresholdBetween(lower,upper);
88#endif
89}
90
92{
93 return Threshold->GetLowerThreshold();
94}
95
97{
98 return Threshold->GetUpperThreshold();
99}
100
101
103 vtkInformation *vtkNotUsed(request),
104 vtkInformationVector **inputVector,
105 vtkInformationVector *outputVector)
106{
107 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
108 vtkInformation *outInfo = outputVector->GetInformationObject(0);
109
110 vtkDataSet *input = vtkDataSet::SafeDownCast(
111 inInfo->Get(vtkDataObject::DATA_OBJECT()));
112 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
113 outInfo->Get(vtkUnstructuredGrid::DATA_OBJECT()));
114
115 vtkIdType numberOfCells = input->GetNumberOfCells();
116
117 vtkIntArray *cellDimensionArray = vtkIntArray::New();
118 cellDimensionArray->SetName("CellDimensionArray");
119 cellDimensionArray->SetNumberOfComponents(1);
120 cellDimensionArray->SetNumberOfTuples(numberOfCells);
121
122 for (int i=0; i<numberOfCells; i++)
123 {
124 cellDimensionArray->SetValue(i,input->GetCell(i)->GetCellDimension());
125
126 }
127 input->GetCellData()->AddArray(cellDimensionArray);
128
129 Threshold->SetInputData(input);
130 Threshold->SetInputArrayToProcess(0,0,0,1,"CellDimensionArray");
131 Threshold->Update();
132 output->DeepCopy(Threshold->GetOutput());
133
134
135
136 input->GetCellData()->RemoveArray("CellDimensionArray");
137 cellDimensionArray->Delete();
138
139 return 1;
140}
141
142void vtkvmtkCellDimensionFilter::PrintSelf(std::ostream& os, vtkIndent indent)
143{
144 this->Superclass::PrintSelf(os,indent);
145}
Threshold all cells of a given dimension, output to an unstructured grid.
void ThresholdBetween(int lower, int upper)
virtual int FillInputPortInformation(int port, vtkInformation *info) override
void PrintSelf(std::ostream &os, vtkIndent indent) override
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkStandardNewMacro(vtkvmtkCellDimensionFilter)