VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataCylinderHarmonicMappingFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataCylinderHarmonicMappingFilter.cxx,v $
5 Language: C++
6 Date: $Date: 2005/03/31 15:07:53 $
7 Version: $Revision: 1.5 $
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=========================================================================*/
21
23#include "vtkPolyData.h"
24#include "vtkPointData.h"
25#include "vtkCell.h"
27#include "vtkInformation.h"
28#include "vtkInformationVector.h"
29#include "vtkObjectFactory.h"
30#include "vtkVersion.h"
31
32
34
38
42
44 vtkInformation *request,
45 vtkInformationVector **inputVector,
46 vtkInformationVector *outputVector)
47{
48 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
49
50 vtkPolyData *input = vtkPolyData::SafeDownCast(
51 inInfo->Get(vtkDataObject::DATA_OBJECT()));
52
54 boundaryExtractor->SetInputData(input);
55 boundaryExtractor->Update();
56
57 vtkPolyData* boundaries = boundaryExtractor->GetOutput();
58
59 int numberOfBoundaries = boundaries->GetNumberOfCells();
60
61 if (numberOfBoundaries != 2)
62 {
63 vtkWarningMacro(<<"Input poly data is not topologically a cylinder.");
64 boundaryExtractor->Delete();
65 this->GetOutput()->DeepCopy(input);
66 return 1;
67 }
68
69 if (this->BoundaryPointIds)
70 {
71 this->BoundaryPointIds->Delete();
72 }
73
74 if (this->BoundaryValues)
75 {
76 this->BoundaryValues->Delete();
77 }
78
79 this->BoundaryPointIds = vtkIdList::New();
80 this->BoundaryValues = vtkDoubleArray::New();
81
82 for (int i=0; i<numberOfBoundaries; i++)
83 {
84 vtkCell* boundaryCell = boundaries->GetCell(i);
85
86 for (int j=0; j<boundaryCell->GetNumberOfPoints(); j++)
87 {
88 this->BoundaryPointIds->InsertNextId(static_cast<vtkIdType>(boundaries->GetPointData()->GetScalars()->GetTuple1(boundaryCell->GetPointId(j))));
89 this->BoundaryValues->InsertNextTuple1(static_cast<double>(i));
90 }
91 }
92
93 Superclass::RequestData(request,inputVector,outputVector);
94
95 this->BoundaryPointIds->Delete();
96 this->BoundaryPointIds = NULL;
97
98 this->BoundaryValues->Delete();
99 this->BoundaryValues = NULL;
100
101 return 1;
102}
Extract boundary edges as poly lines.
static vtkvmtkPolyDataBoundaryExtractor * New()
Create a single instance wrapping a harmonic function over a cylinder so that mapping can be applied ...
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkStandardNewMacro(vtkvmtkPolyDataCylinderHarmonicMappingFilter)