VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataCenterlineAbscissaMetricFilter.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataCenterlineAbscissaMetricFilter.cxx,v $
5 Language: C++
6 Date: $Date: 2006/04/06 16:46:43 $
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
23#include "vtkPointData.h"
24#include "vtkCellData.h"
25#include "vtkDoubleArray.h"
26#include "vtkvmtkPolyBallLine.h"
27#include "vtkCell.h"
28#include "vtkMath.h"
29#include "vtkvmtkConstants.h"
30#include "vtkObjectFactory.h"
31
33
34
36
41
50
51void vtkvmtkPolyDataCenterlineAbscissaMetricFilter::EvaluateMetric(vtkIdType pointId, double point[3], vtkIdType groupId, vtkDataArray* metricArray)
52{
53 vtkDataArray* centerlineGroupIdsArray = this->Centerlines->GetCellData()->GetArray(this->CenterlineGroupIdsArrayName);
54 vtkDataArray* centerlineTractIdsArray = this->Centerlines->GetCellData()->GetArray(this->CenterlineTractIdsArrayName);
55 vtkDataArray* blankingArray = this->Centerlines->GetCellData()->GetArray(this->BlankingArrayName);
56 vtkDataArray* centerlineIdsArray = this->Centerlines->GetCellData()->GetArray(this->CenterlineIdsArrayName);
57
59 vtkIdList* centerlineGroupCellIds = vtkIdList::New();
60
61 tube->SetInput(this->Centerlines);
62 tube->SetInputCellIds(centerlineGroupCellIds);
64 if (this->UseRadiusInformation)
65 {
67 }
68
69 double averageAbscissa = 0.0;
70 double weightSum = 0.0;
71
72 int numberOfCenterlineCells = this->Centerlines->GetNumberOfCells();
73 for (int i=0; i<numberOfCenterlineCells; i++)
74 {
75 int centerlineGroupId = static_cast<int>(centerlineGroupIdsArray->GetComponent(i,0));
76 if (centerlineGroupId != groupId)
77 {
78 continue;
79 }
80
81 centerlineGroupCellIds->Initialize();
82 centerlineGroupCellIds->InsertNextId(i);
83
84 if (this->IncludeBifurcations)
85 {
86 int centerlineId = static_cast<int>(centerlineIdsArray->GetComponent(i,0));
87 int centerlineTractId = static_cast<int>(centerlineTractIdsArray->GetComponent(i,0));
88
89 for (int j=0; j<numberOfCenterlineCells; j++)
90 {
91 if (j==i)
92 {
93 continue;
94 }
95
96 int adjacentCenterlineGroupId = static_cast<int>(centerlineGroupIdsArray->GetComponent(j,0));
97 int adjacentCenterlineId = static_cast<int>(centerlineIdsArray->GetComponent(j,0));
98 int adjacentCenterlineTractId = static_cast<int>(centerlineTractIdsArray->GetComponent(j,0));
99 int adjacentBlanking = static_cast<int>(blankingArray->GetComponent(j,0));
100
101 if (adjacentBlanking == 0)
102 {
103 continue;
104 }
105
106 if (adjacentCenterlineGroupId == centerlineGroupId)
107 {
108 continue;
109 }
110
111 if (adjacentCenterlineId != centerlineId)
112 {
113 continue;
114 }
115
116 if (!((adjacentCenterlineTractId == centerlineTractId - 1) ||
117 (adjacentCenterlineTractId == centerlineTractId + 1)))
118 {
119 continue;
120 }
121
122 centerlineGroupCellIds->InsertNextId(j);
123 }
124 }
125
126 tube->EvaluateFunction(point);
127
128 vtkIdType centerlineCellId = tube->GetLastPolyBallCellId();
129 vtkIdType centerlineSubId = tube->GetLastPolyBallCellSubId();
130 double centerlinePCoord = tube->GetLastPolyBallCellPCoord();
131 double radius = 0.0;
132 vtkvmtkCenterlineUtilities::InterpolateTuple1(this->Centerlines,this->RadiusArrayName,centerlineCellId,centerlineSubId,centerlinePCoord,radius);
133 double weight = radius * radius;
134 double abscissa = 0.0;
135 vtkvmtkCenterlineUtilities::InterpolateTuple1(this->Centerlines,this->AbscissasArrayName,centerlineCellId,centerlineSubId,centerlinePCoord,abscissa);
136
137 averageAbscissa += weight * abscissa;
138
139 weightSum += weight;
140 }
141
142 averageAbscissa /= weightSum;
143
144 metricArray->SetComponent(pointId,0,averageAbscissa);
145
146 centerlineGroupCellIds->Delete();
147 tube->Delete();
148}
static void InterpolateTuple1(vtkPolyData *centerlines, const char *arrayName, int cellId, int subId, double pcoord, double &interpolatedTuple1)
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 SetInputCellIds(vtkIdList *)
virtual void SetUseRadiusInformation(int)
virtual vtkIdType GetLastPolyBallCellId()
static vtkvmtkPolyBallLine * New()
double EvaluateFunction(double x[3]) override
virtual vtkIdType GetLastPolyBallCellSubId()
Project the abscissa metric of the nearest centerline point to every point of a surface.
virtual void EvaluateMetric(vtkIdType pointId, double point[3], vtkIdType groupId, vtkDataArray *metricArray) override
vtkStandardNewMacro(vtkvmtkPolyDataCenterlineAbscissaMetricFilter)