VMTK
Loading...
Searching...
No Matches
vtkvmtkCenterlineEndpointExtractor.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3Program: VMTK
4Module: $RCSfile: vtkvmtkCenterlineEndpointExtractor.cxx,v $
5Language: C++
6Date: $Date: 2005/10/06 11:01:44 $
7Version: $Revision: 1.6 $
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 "vtkPolyLine.h"
26#include "vtkObjectFactory.h"
27
28
30
37
41
43{
45
46 if (this->SubIds)
47 {
48 delete[] this->SubIds;
49 this->SubIds = NULL;
50 }
51
52 if (this->PCoords)
53 {
54 delete[] this->PCoords;
55 this->PCoords = NULL;
56 }
57
58 if (this->TractBlanking)
59 {
60 delete[] this->TractBlanking;
61 this->TractBlanking = NULL;
62 }
63
64 vtkCell* centerline = input->GetCell(cellId);
65
66 if (centerline->GetCellType() != VTK_LINE && centerline->GetCellType() != VTK_POLY_LINE)
67 {
68 return;
69 }
70
73 {
75 }
76
77 this->SubIds = new vtkIdType[this->NumberOfSplittingPoints];
78 this->PCoords = new double[this->NumberOfSplittingPoints];
79
80 vtkIdType firstSubId, lastSubId;
81 double firstPCoord, lastPCoord;
82
83 firstSubId = 0;
84 firstPCoord = 0.0;
85
86 lastSubId = centerline->GetNumberOfPoints() - 2;
87 lastPCoord = 1.0;
88
90 {
91 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,firstSubId,firstPCoord,this->NumberOfEndpointSpheres,this->SubIds[0],this->PCoords[0],false);
92 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,this->SubIds[0],this->PCoords[0],this->NumberOfGapSpheres,this->SubIds[1],this->PCoords[1],false);
93 }
94 else if (this->ExtractionMode == VTK_VMTK_LAST_ENDPOINT)
95 {
96 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,lastSubId,lastPCoord,this->NumberOfEndpointSpheres,this->SubIds[1],this->PCoords[1],true);
97 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,this->SubIds[1],this->PCoords[1],this->NumberOfGapSpheres,this->SubIds[0],this->PCoords[0],true);
98 if (this->SubIds[0] == -1)
99 {
100 this->SubIds[0] = 0;
101 this->PCoords[0] = 0.0;
102 }
103 if (this->SubIds[1] == -1)
104 {
105 this->SubIds[1] = 0;
106 this->PCoords[1] = 0.0;
107 }
108 }
109 else
110 {
111 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,firstSubId,firstPCoord,this->NumberOfEndpointSpheres,this->SubIds[0],this->PCoords[0],false);
112 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,this->SubIds[0],this->PCoords[0],this->NumberOfGapSpheres,this->SubIds[1],this->PCoords[1],false);
113 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,lastSubId,lastPCoord,this->NumberOfEndpointSpheres,this->SubIds[3],this->PCoords[3],true);
114 vtkvmtkCenterlineSphereDistance::FindNTouchingSphereCenter(input,this->RadiusArrayName,cellId,this->SubIds[3],this->PCoords[3],this->NumberOfGapSpheres,this->SubIds[2],this->PCoords[2],true);
115 }
116
117 this->TractBlanking = new int[this->NumberOfSplittingPoints+1];
118
120 {
121 this->TractBlanking[0] = 0;
122 this->TractBlanking[1] = 1;
123 this->TractBlanking[2] = 0;
124 }
125 else
126 {
127 this->TractBlanking[0] = 0;
128 this->TractBlanking[1] = 1;
129 this->TractBlanking[2] = 0;
130 this->TractBlanking[3] = 1;
131 this->TractBlanking[4] = 0;
132 }
133}
134
135void vtkvmtkCenterlineEndpointExtractor::PrintSelf(std::ostream& os, vtkIndent indent)
136{
137 this->Superclass::PrintSelf(os,indent);
138}
Split a centerline into tracts which can be used to mark endpoints of the centerline.
void PrintSelf(std::ostream &os, vtkIndent indent) override
virtual void ComputeCenterlineSplitting(vtkPolyData *input, vtkIdType cellId) override
static void FindNTouchingSphereCenter(vtkPolyData *centerlines, const char *radiusArrayName, vtkIdType cellId, vtkIdType subId, double pcoord, int numberOfTouchingSpheres, vtkIdType &touchingSubId, double &touchingPCoord, bool forward=true)
void PrintSelf(std::ostream &os, vtkIndent indent) override
vtkStandardNewMacro(vtkvmtkCenterlineEndpointExtractor)