VMTK
Loading...
Searching...
No Matches
vtkvmtkStreamlineOsculatingCentersFilter Class Reference

Compute the osculating (center-of-curvature) points of a set of streamlines. More...

#include <vtkvmtkStreamlineOsculatingCentersFilter.h>

Inheritance diagram for vtkvmtkStreamlineOsculatingCentersFilter:
[legend]
Collaboration diagram for vtkvmtkStreamlineOsculatingCentersFilter:
[legend]

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkStreamlineOsculatingCentersFilter * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual vtkPolyData * GetOsculatingCenters ()
virtual void SetVoronoiDiagram (vtkPolyData *)
virtual vtkPolyData * GetVoronoiDiagram ()
virtual void SetVoronoiSheetIdsArrayName (const char *)
virtual char * GetVoronoiSheetIdsArrayName ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkStreamlineOsculatingCentersFilter * SafeDownCast (vtkObjectBase *o)
static vtkvmtkStreamlineOsculatingCentersFilter * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkStreamlineOsculatingCentersFilter ()
 ~vtkvmtkStreamlineOsculatingCentersFilter ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

vtkPolyData * VoronoiDiagram
char * VoronoiSheetIdsArrayName
vtkPolyData * OsculatingCenters

Detailed Description

Compute the osculating (center-of-curvature) points of a set of streamlines.

Resamples each input polyline (streamline) cell to a fixed point spacing, then, for every interior point, computes the center of the osculating circle defined by it and its two neighbors (i.e. the local center of curvature) and its radius, storing the result as vertex points in the output GetOsculatingCenters() poly data (with "Label" and "Radius" point data arrays). If a VoronoiDiagram is supplied, each osculating center is additionally tagged with the id of the nearest Voronoi "sheet" (VoronoiSheetIdsArrayName), associating the local curvature behavior of the flow with the underlying medial-surface structure of the vessel.

Definition at line 37 of file vtkvmtkStreamlineOsculatingCentersFilter.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkStreamlineOsculatingCentersFilter()

vtkvmtkStreamlineOsculatingCentersFilter::vtkvmtkStreamlineOsculatingCentersFilter ( )
protected

◆ ~vtkvmtkStreamlineOsculatingCentersFilter()

vtkvmtkStreamlineOsculatingCentersFilter::~vtkvmtkStreamlineOsculatingCentersFilter ( )
protected

Definition at line 49 of file vtkvmtkStreamlineOsculatingCentersFilter.cxx.

50{
51 if (this->VoronoiDiagram)
52 {
53 this->VoronoiDiagram->Delete();
54 this->VoronoiDiagram = NULL;
55 }
56 if (this->OsculatingCenters)
57 {
58 this->OsculatingCenters->Delete();
59 this->OsculatingCenters = NULL;
60 }
62 {
63 delete[] this->VoronoiSheetIdsArrayName;
64 this->VoronoiSheetIdsArrayName = NULL;
65 }
66}

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkStreamlineOsculatingCentersFilter::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkStreamlineOsculatingCentersFilter::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkStreamlineOsculatingCentersFilter * vtkvmtkStreamlineOsculatingCentersFilter::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkStreamlineOsculatingCentersFilter::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkStreamlineOsculatingCentersFilter * vtkvmtkStreamlineOsculatingCentersFilter::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkStreamlineOsculatingCentersFilter::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 232 of file vtkvmtkStreamlineOsculatingCentersFilter.cxx.

233{
234 this->Superclass::PrintSelf(os,indent);
235}

◆ New()

vtkvmtkStreamlineOsculatingCentersFilter * vtkvmtkStreamlineOsculatingCentersFilter::New ( )
static

◆ SetVoronoiDiagram()

virtual void vtkvmtkStreamlineOsculatingCentersFilter::SetVoronoiDiagram ( vtkPolyData * )
virtual

Set/Get an optional Voronoi diagram (e.g. as computed during centerline extraction) used to tag each osculating center with its nearest Voronoi "sheet" id. If not set, no sheet-id tagging is performed.

◆ GetVoronoiDiagram()

virtual vtkPolyData * vtkvmtkStreamlineOsculatingCentersFilter::GetVoronoiDiagram ( )
virtual

Set/Get an optional Voronoi diagram (e.g. as computed during centerline extraction) used to tag each osculating center with its nearest Voronoi "sheet" id. If not set, no sheet-id tagging is performed.

◆ SetVoronoiSheetIdsArrayName()

virtual void vtkvmtkStreamlineOsculatingCentersFilter::SetVoronoiSheetIdsArrayName ( const char * )
virtual

Set/Get the name of the cell data array of VoronoiDiagram holding each cell's sheet id; also the name used for the corresponding output point data array on GetOsculatingCenters().

◆ GetVoronoiSheetIdsArrayName()

virtual char * vtkvmtkStreamlineOsculatingCentersFilter::GetVoronoiSheetIdsArrayName ( )
virtual

Set/Get the name of the cell data array of VoronoiDiagram holding each cell's sheet id; also the name used for the corresponding output point data array on GetOsculatingCenters().

◆ GetOsculatingCenters()

virtual vtkPolyData * vtkvmtkStreamlineOsculatingCentersFilter::GetOsculatingCenters ( )
virtual

Get the computed osculating centers, one vertex point per interior point of every resampled input streamline, with "Label" (source streamline id) and "Radius" (osculating circle radius) point data arrays, plus VoronoiSheetIdsArrayName if VoronoiDiagram was supplied. Valid only after Update() has been called.

◆ RequestData()

int vtkvmtkStreamlineOsculatingCentersFilter::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 68 of file vtkvmtkStreamlineOsculatingCentersFilter.cxx.

72{
73 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
74 vtkInformation *outInfo = outputVector->GetInformationObject(0);
75
76 vtkPolyData *input = vtkPolyData::SafeDownCast(
77 inInfo->Get(vtkDataObject::DATA_OBJECT()));
78 vtkPolyData *output = vtkPolyData::SafeDownCast(
79 outInfo->Get(vtkDataObject::DATA_OBJECT()));
80
81 if (input->GetNumberOfPoints() < 1)
82 {
83 return 1;
84 }
85
86 if (this->OsculatingCenters)
87 {
88 this->OsculatingCenters->Delete();
89 this->OsculatingCenters = NULL;
90 }
91
92 this->OsculatingCenters = vtkPolyData::New();
93
94 double resampleLength = 0.1;
95
96 vtkSplineFilter* splineFilter = vtkSplineFilter::New();
97 splineFilter->SetInputData(input);
98 splineFilter->SetSubdivideToLength();
99 splineFilter->SetLength(resampleLength);
100 splineFilter->Update();
101
102 vtkPolyData* streamlines = splineFilter->GetOutput();
103
104 vtkIntArray* voronoiSheetIdsArray = NULL;
105 vtkIntArray* sheetIdsArray = NULL;
106 vtkIntArray* streamlineSheetIdsArray = NULL;
107 vtkCellLocator* cellLocator = NULL;
108 if (this->VoronoiDiagram)
109 {
110 if (!this->VoronoiDiagram->GetCellData()->GetArray(this->VoronoiSheetIdsArrayName))
111 {
112 vtkErrorMacro(<< "VoronoiSheetIdsArray with name specified does not exist!");
113 return 1;
114 }
115 voronoiSheetIdsArray = vtkIntArray::New();
116 voronoiSheetIdsArray->DeepCopy(this->VoronoiDiagram->GetCellData()->GetArray(this->VoronoiSheetIdsArrayName));
117 sheetIdsArray = vtkIntArray::New();
118 sheetIdsArray->SetName(this->VoronoiSheetIdsArrayName);
119 cellLocator = vtkCellLocator::New();
120 cellLocator->SetDataSet(this->VoronoiDiagram);
121 cellLocator->BuildLocator();
122 streamlineSheetIdsArray = vtkIntArray::New();
123 streamlineSheetIdsArray->SetName(this->VoronoiSheetIdsArrayName);
124 streamlineSheetIdsArray->SetNumberOfTuples(streamlines->GetNumberOfPoints());
125 }
126
127 int numberOfCells = streamlines->GetNumberOfCells();
128
129 vtkIntArray* labelArray = vtkIntArray::New();
130 labelArray->SetName("Label");
131
132 vtkDoubleArray* radiusArray = vtkDoubleArray::New();
133 radiusArray->SetName("Radius");
134
135 vtkPoints* outputPoints = vtkPoints::New();
136 vtkCellArray* outputVertices = vtkCellArray::New();
137
138 for (int i=0; i<numberOfCells; i++)
139 {
140 vtkCell* streamline = streamlines->GetCell(i);
141 int numberOfStreamlinePoints = streamline->GetNumberOfPoints();
142 for (int ip=1; ip<numberOfStreamlinePoints-1; ip++)
143 {
144 double x0[3], x1[3], x2[3];
145 streamlines->GetPoint(streamline->GetPointId(ip-1),x0);
146 streamlines->GetPoint(streamline->GetPointId(ip),x1);
147 streamlines->GetPoint(streamline->GetPointId(ip+1),x2);
148 double u[3], a[3];
149 for (int j=0; j<3; j++)
150 {
151 a[j] = 0.5 * (x1[j] + x0[j]);
152 }
153 double x2_x1[3], x1_x0[3];
154 double x2_a[3];
155 for (int j=0; j<3; j++)
156 {
157 x2_x1[j] = x2[j] - x1[j];
158 x1_x0[j] = x1[j] - x0[j];
159 x2_a[j] = x2[j] - a[j];
160 }
161 double a_x2_sq = vtkMath::Distance2BetweenPoints(a,x2);
162 double a_x1_sq = vtkMath::Distance2BetweenPoints(a,x1);
163 double x2_x1_dot_x1_x0 = vtkMath::Dot(x2_x1,x1_x0);
164 double x2_x1_sq = vtkMath::Distance2BetweenPoints(x2,x1);
165 for (int j=0; j<3; j++)
166 {
167 u[j] = (x2[j] - x1[j]) - (x1[j] - x0[j]) * (x2_x1_dot_x1_x0 / x2_x1_sq);
168 }
169 vtkMath::Normalize(u);
170 double u_dot_x2_a = vtkMath::Dot(u, x2_a);
171 if (fabs(u_dot_x2_a) < VTK_VMTK_DOUBLE_TOL)
172 {
173 continue;
174 }
175 double t = (a_x2_sq - a_x1_sq) / (2.0 * u_dot_x2_a);
176 double osculatingCenter[3];
177 for (int j=0; j<3; j++)
178 {
179 osculatingCenter[j] = a[j] + t * u[j];
180 }
181 double radius = sqrt(vtkMath::Distance2BetweenPoints(osculatingCenter,x1));
182 vtkIdType id = outputPoints->InsertNextPoint(osculatingCenter);
183 outputVertices->InsertNextCell(1);
184 outputVertices->InsertCellPoint(id);
185 labelArray->InsertNextValue(i);
186 radiusArray->InsertNextValue(radius);
187 if (this->VoronoiDiagram)
188 {
189 double closestPoint[3], dist2;
190 vtkIdType sheetId, cellId;
191 int subId;
192 cellLocator->FindClosestPoint(osculatingCenter,closestPoint,cellId,subId,dist2);
193 sheetId = voronoiSheetIdsArray->GetValue(cellId);
194 sheetIdsArray->InsertNextValue(sheetId);
195 streamlineSheetIdsArray->InsertValue(streamline->GetPointId(ip),sheetId);
196 }
197 }
198 }
199
200 this->OsculatingCenters->SetPoints(outputPoints);
201 this->OsculatingCenters->SetVerts(outputVertices);
202 this->OsculatingCenters->GetPointData()->AddArray(labelArray);
203 this->OsculatingCenters->GetPointData()->AddArray(radiusArray);
204 if (sheetIdsArray)
205 {
206 this->OsculatingCenters->GetPointData()->AddArray(sheetIdsArray);
207 }
208
209 output->DeepCopy(streamlines);
210 if (sheetIdsArray)
211 {
212 output->GetPointData()->AddArray(streamlineSheetIdsArray);
213 }
214
215 splineFilter->Delete();
216 outputPoints->Delete();
217 outputVertices->Delete();
218 labelArray->Delete();
219 radiusArray->Delete();
220
221 if (voronoiSheetIdsArray)
222 {
223 voronoiSheetIdsArray->Delete();
224 sheetIdsArray->Delete();
225 streamlineSheetIdsArray->Delete();
226 cellLocator->Delete();
227 }
228
229 return 1;
230}
#define VTK_VMTK_DOUBLE_TOL

Member Data Documentation

◆ VoronoiDiagram

vtkPolyData* vtkvmtkStreamlineOsculatingCentersFilter::VoronoiDiagram
protected

Definition at line 78 of file vtkvmtkStreamlineOsculatingCentersFilter.h.

◆ VoronoiSheetIdsArrayName

char* vtkvmtkStreamlineOsculatingCentersFilter::VoronoiSheetIdsArrayName
protected

Definition at line 79 of file vtkvmtkStreamlineOsculatingCentersFilter.h.

◆ OsculatingCenters

vtkPolyData* vtkvmtkStreamlineOsculatingCentersFilter::OsculatingCenters
protected

Definition at line 81 of file vtkvmtkStreamlineOsculatingCentersFilter.h.


The documentation for this class was generated from the following files: