VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataToUnstructuredGridFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3Program: VMTK
4Module: $RCSfile: vtkvmtkPolyDataToUnstructuredGridFilter.cxx,v $
5Language: C++
6Date: $Date: 2005/03/31 15:49:05 $
7Version: $Revision: 1.3 $
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=========================================================================*/
22
23#include "vtkPolyData.h"
24#include "vtkUnstructuredGrid.h"
25#include "vtkPointData.h"
26#include "vtkCellData.h"
27#include "vtkPoints.h"
28#include "vtkCellArray.h"
29#include "vtkIdList.h"
30#include "vtkInformation.h"
31#include "vtkInformationVector.h"
32#include "vtkObjectFactory.h"
33
34
36
38{
39 info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
40 return 1;
41}
42
44 vtkInformation *vtkNotUsed(request),
45 vtkInformationVector **inputVector,
46 vtkInformationVector *outputVector)
47{
48 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
49 vtkInformation *outInfo = outputVector->GetInformationObject(0);
50
51 vtkPolyData *input = vtkPolyData::SafeDownCast(
52 inInfo->Get(vtkDataObject::DATA_OBJECT()));
53 vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
54 outInfo->Get(vtkDataObject::DATA_OBJECT()));
55
56 output->SetPoints(input->GetPoints());
57 output->GetPointData()->PassData(input->GetPointData());
58 output->GetCellData()->PassData(input->GetCellData());
59
60 vtkCellArray* cellArray = vtkCellArray::New();
61
62 int numberOfCells = input->GetNumberOfCells();
63
64 input->BuildCells();
65
66 int* cellTypes = new int[numberOfCells];
67
68 vtkIdType npts;
69 const vtkIdType *pts;
70 int cellType;
71 for (int i=0; i<numberOfCells; i++)
72 {
73 input->GetCellPoints(i,npts,pts);
74 cellType = input->GetCellType(i);
75
76 cellArray->InsertNextCell(npts,pts);
77 cellTypes[i] = cellType;
78 }
79
80 output->SetCells(cellTypes,cellArray);
81
82 cellArray->Delete();
83 delete[] cellTypes;
84
85 return 1;
86}
87
88void vtkvmtkPolyDataToUnstructuredGridFilter::PrintSelf(std::ostream& os, vtkIndent indent)
89{
90 this->Superclass::PrintSelf(os,indent);
91}
Repackage a vtkPolyData surface as a vtkUnstructuredGrid, unchanged otherwise.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
int FillInputPortInformation(int, vtkInformation *info) override
void PrintSelf(std::ostream &os, vtkIndent indent) override
vtkStandardNewMacro(vtkvmtkPolyDataToUnstructuredGridFilter)