VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataMultipleCylinderHarmonicMappingFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataMultipleCylinderHarmonicMappingFilter.cxx,v $
5 Language: C++
6 Date: $Date: 2006/04/06 16:46:44 $
7 Version: $Revision: 1.7 $
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
24#include "vtkPolyData.h"
25#include "vtkCellArray.h"
26#include "vtkPointData.h"
27#include "vtkDoubleArray.h"
28#include "vtkInformation.h"
29#include "vtkInformationVector.h"
30#include "vtkObjectFactory.h"
31#include "vtkVersion.h"
32
34
35
37
43
58
60 vtkInformation *request,
61 vtkInformationVector **inputVector,
62 vtkInformationVector *outputVector)
63{
64 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
65 vtkInformation *outInfo = outputVector->GetInformationObject(0);
66
67 vtkPolyData *input = vtkPolyData::SafeDownCast(
68 inInfo->Get(vtkDataObject::DATA_OBJECT()));
69 vtkPolyData *output = vtkPolyData::SafeDownCast(
70 outInfo->Get(vtkDataObject::DATA_OBJECT()));
71
72 if (!this->HarmonicMappingArrayName)
73 {
74 vtkErrorMacro(<<"HarmonicMappingArrayName not set.");
75 return 1;
76 }
77
78 if (!this->GroupIdsArrayName)
79 {
80 vtkErrorMacro(<<"GroupIdsArrayName not set.");
81 return 1;
82 }
83
84 vtkDataArray* groupIdsArray = input->GetPointData()->GetArray(this->GroupIdsArrayName);
85
86 if (!groupIdsArray)
87 {
88 vtkErrorMacro(<<"GroupIdsArray with name specified does not exist.");
89 return 1;
90 }
91
92 int numberOfInputPoints = input->GetNumberOfPoints();
93
94 vtkDoubleArray* harmonicMappingArray = vtkDoubleArray::New();
95 harmonicMappingArray->SetName(this->HarmonicMappingArrayName);
96 harmonicMappingArray->SetNumberOfComponents(1);
97 harmonicMappingArray->SetNumberOfTuples(numberOfInputPoints);
98 harmonicMappingArray->FillComponent(0,0.0);
99 output->DeepCopy(input);
100
101 vtkIdList* groupIds = vtkIdList::New();
103
104 int i, j;
105 for (i=0; i<groupIds->GetNumberOfIds(); i++)
106 {
107 vtkIdType groupId = groupIds->GetId(i);
108 vtkPolyData* cylinder = vtkPolyData::New();
109 vtkvmtkPolyDataBranchUtilities::ExtractGroup(input,this->GroupIdsArrayName,groupId,false,cylinder);
110
112 mappingFilter->SetInputData(cylinder);
114 mappingFilter->Update();
115
116 vtkDataArray* cylinderMappingArray = mappingFilter->GetOutput()->GetPointData()->GetArray(this->HarmonicMappingArrayName);
117
118 if (!cylinderMappingArray)
119 {
120 mappingFilter->Delete();
121 continue;
122 }
123
124 double mappingValue;
125 for (j=0; j<numberOfInputPoints; j++)
126 {
127 vtkIdType currentGroupId = static_cast<int>(groupIdsArray->GetComponent(j,0));
128 if (currentGroupId == groupId)
129 {
130 mappingValue = cylinderMappingArray->GetComponent(j,0);
131 harmonicMappingArray->SetComponent(j,0,mappingValue);
132 }
133 }
134
135 mappingFilter->Delete();
136 cylinder->Delete();
137 }
138
139 output->GetPointData()->AddArray(harmonicMappingArray);
140
141 groupIds->Delete();
142 harmonicMappingArray->Delete();
143
144 return 1;
145}
static void ExtractGroup(vtkPolyData *surface, const char *groupIdsArrayName, vtkIdType groupId, bool cleanGroupSurface, vtkPolyData *groupSurface)
static void GetGroupsIdList(vtkPolyData *surface, const char *groupIdsArrayName, vtkIdList *groupIds)
Create a single instance wrapping a harmonic function over a cylinder so that mapping can be applied ...
static vtkvmtkPolyDataCylinderHarmonicMappingFilter * New()
virtual void SetHarmonicMappingArrayName(const char *)
Compute a harmonic mapping over each branch of a bifurcated surface, treating every branch as an inde...
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkStandardNewMacro(vtkvmtkPolyDataMultipleCylinderHarmonicMappingFilter)