VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataCenterlineProjection.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataCenterlineProjection.cxx,v $
5 Language: C++
6 Date: $Date: 2005/03/31 15:07:48 $
7 Version: $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=========================================================================*/
21
23#include "vtkPointData.h"
24#include "vtkvmtkPolyBallLine.h"
25#include "vtkCell.h"
26#include "vtkInformation.h"
27#include "vtkInformationVector.h"
28#include "vtkObjectFactory.h"
29
30
32
40
42{
43 if (this->Centerlines)
44 {
45 this->Centerlines->Delete();
46 this->Centerlines = NULL;
47 }
48
50 {
51 delete[] this->CenterlineRadiusArrayName;
52 this->CenterlineRadiusArrayName = NULL;
53 }
54}
55
57 vtkInformation *vtkNotUsed(request),
58 vtkInformationVector **inputVector,
59 vtkInformationVector *outputVector)
60{
61 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
62 vtkInformation *outInfo = outputVector->GetInformationObject(0);
63
64 vtkPolyData *input = vtkPolyData::SafeDownCast(
65 inInfo->Get(vtkDataObject::DATA_OBJECT()));
66 vtkPolyData *output = vtkPolyData::SafeDownCast(
67 outInfo->Get(vtkDataObject::DATA_OBJECT()));
68
69 if (!this->Centerlines)
70 {
71 vtkErrorMacro(<<"Centerlines not set");
72 return 1;
73 }
74
75 if (this->UseRadiusInformation)
76 {
78 {
79 vtkErrorMacro(<<"CenterlineRadiusArrayName not set.");
80 return 1;
81 }
82
83 vtkDataArray* centerlineRadiusArray = this->Centerlines->GetPointData()->GetArray(this->CenterlineRadiusArrayName);
84
85 if (!centerlineRadiusArray)
86 {
87 vtkErrorMacro(<<"CenterlineRadiusArrayName with name specified does not exist.");
88 return 1;
89 }
90 }
91
92 int numberOfInputPoints = input->GetNumberOfPoints();
93
94 output->DeepCopy(input);
95
96 vtkPointData* outputPointData = output->GetPointData();
97 vtkPointData* referencePointData = this->Centerlines->GetPointData();
98
99 outputPointData->InterpolateAllocate(referencePointData,numberOfInputPoints);
100
102 tube->SetInput(this->Centerlines);
104 if (this->UseRadiusInformation)
105 {
107 }
108
109 double point[3];
110 for (int i=0; i<numberOfInputPoints; i++)
111 {
112 input->GetPoint(i,point);
113 tube->EvaluateFunction(point);
114 vtkIdType cellId = tube->GetLastPolyBallCellId();
115 vtkIdType subId = tube->GetLastPolyBallCellSubId();
116 double pcoord = tube->GetLastPolyBallCellPCoord();
117 vtkCell* cell = this->Centerlines->GetCell(cellId);
118// FIXME: for some reason EvaluateLocation fails on the PolyLine - weights are funny. Copy from the closest subId for the moment.
119// double pcoords[3];
120// pcoords[0] = pcoord;
121// pcoords[1] = pcoords[2] = 0.0;
122// double* weights = new double[cell->GetNumberOfPoints()];
123// double locationPoint[3];
124// cell->EvaluateLocation(subId,pcoords,locationPoint,weights);
125// outputPointData->InterpolatePoint(referencePointData,i,cell->GetPointIds(),weights);
126// delete[] weights;
127 if (pcoord < 0.5)
128 {
129 outputPointData->CopyData(referencePointData,cell->GetPointId(subId),i);
130 }
131 else
132 {
133 outputPointData->CopyData(referencePointData,cell->GetPointId(subId+1),i);
134 }
135 }
136
137 tube->Delete();
138
139 return 1;
140}
Implements vtkImplicitFunction to evaluate the minimum sphere function for an envelope created by an ...
virtual double GetLastPolyBallCellPCoord()
virtual void SetInput(vtkPolyData *)
virtual void SetPolyBallRadiusArrayName(const char *)
virtual void SetUseRadiusInformation(int)
virtual vtkIdType GetLastPolyBallCellId()
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
virtual vtkIdType GetLastPolyBallCellSubId()
Project all point data from a centerline onto a surface.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
vtkStandardNewMacro(vtkvmtkPolyDataCenterlineProjection)