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

Create an approximated network graph (preliminary to centerline) from an input surface with at least one hole in it. More...

#include <vtkvmtkPolyDataNetworkExtraction.h>

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

Public Types

enum  {
  STEP_ITERATION_PROCEED , STEP_ITERATION_REDEFINE , STEP_ITERATION_STOP_END , STEP_ITERATION_STOP_BIFURCATION ,
  STEP_ITERATION_STOP_CLOSED
}
enum  { NON_VISITED , VISITED , GLOBAL }
typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataNetworkExtraction * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual int GetTotalMarkedPoints ()
virtual double GetMinimumStep ()
virtual vtkPolyData * GetGraphLayout ()
virtual void SetMarksArrayName (const char *)
virtual char * GetMarksArrayName ()
virtual void SetRadiusArrayName (const char *)
virtual char * GetRadiusArrayName ()
virtual void SetTopologyArrayName (const char *)
virtual char * GetTopologyArrayName ()
virtual void SetAdvancementRatio (double)
virtual double GetAdvancementRatio ()

Static Public Member Functions

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

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkPolyDataNetworkExtraction ()
 ~vtkvmtkPolyDataNetworkExtraction ()
void BoundaryExtractor (vtkPolyData *polyInput, vtkPolyData *boundary)
void BoundarySeparator (vtkPolyData *appendedBoundaries, vtkPolyDataCollection *boundaries)
void InsertInEdgeTable (vtkIdTypeArray *edgeTable, vtkIdType pointId0, vtkIdType pointId1)
bool InsertUniqueInEdgeTable (vtkIdTypeArray *edgeTable, vtkIdType pointId0, vtkIdType pointId1)
void GetFromEdgeTable (vtkIdTypeArray *edgeTable, vtkIdType position, vtkIdType edge[2])
void UpdateEdgeTableCollectionReal (vtkPolyData *model, vtkPolyDataCollection *profiles, vtkCollection *edgeTables)
double Distance (double point1[3], double point2[3])
double GetFurthestDistance (vtkPolyDataCollection *polyDataCollection, double fromPoint[3])
void Barycenter (vtkPoints *points, double barycenter[3])
void ProfileBarycenter (vtkPoints *points, double barycenter[3])
void DefineVirtualSphere (vtkPolyDataCollection *baseProfiles, double center[3], double &radius, double ratio)
vtkIdType CurrentPointId (vtkPolyData *model, vtkIdType currentEdge[2])
void InsertEdgeForNewProfiles (vtkPolyData *model, vtkIdType *edge, vtkIdTypeArray *edgeTable, vtkIdTypeArray *cellPairs, vtkIdList *pointIds)
bool LookForNeighbors (vtkPolyData *model, vtkIdType pointId, vtkIdList *notVisitedIds, vtkIdTypeArray *edgeTableForIncludedGlobalProfiles)
void PropagateFromBaseProfilePoint (vtkPolyData *model, vtkIdList *toVisitPointIds, double center[3], double radius, vtkIdTypeArray *edgeTableForNewProfiles, vtkIdTypeArray *cellPairsForNewProfiles, vtkIdList *pointIdsForNewProfiles, vtkPoints *markedPoints, vtkIdList *markedPointIds, vtkIdTypeArray *edgeTableForIncludedGlobalProfiles)
void LocateVirtualPoint (vtkIdType edge[2], double center[3], double radius, vtkIdList *pointIdsForNewProfiles, vtkPoints *pointsForNewProfiles, vtkDoubleArray *pointDistancesForNewProfiles, double virtualPoint[3])
void ReconstructNewProfiles (vtkPoints *virtualPoints, vtkIdTypeArray *edgeTable, vtkIdTypeArray *cellPairs, vtkPolyDataCollection *newProfiles, vtkCollection *newProfilesEdgeTables)
void GenerateNewProfiles (vtkPolyData *model, double center[3], double radius, vtkIdTypeArray *edgeTableForNewProfiles, vtkIdTypeArray *cellPairsForNewProfiles, vtkIdList *pointIdsForNewProfiles, vtkPolyDataCollection *newProfiles, vtkCollection *newProfilesEdgeTables)
void UnmarkPoints (vtkPolyData *model, vtkIdList *markedPointIds)
double ComputeStepRadius (vtkPoints *points, double point1[3], double point2[3])
double ComputeMeanRadius (vtkPoints *points, double point1[3])
void PointsForRadius (vtkPoints *markedPoints, vtkPolyDataCollection *baseProfiles, vtkPolyDataCollection *newProfiles, vtkPoints *pointsForRadius)
void LookForIntersectingPoint (vtkPoints *segmentPoints, double center[3], double radius, vtkIdType &intersectingPointId)
vtkIdType StepIteration (vtkPolyData *model, vtkPolyDataCollection *baseProfiles, vtkCollection *baseProfilesEdgeTables, vtkPolyDataCollection *globalProfiles, vtkCollection *globalProfilesEdgeTables, vtkPolyDataCollection *newProfiles, vtkCollection *newProfilesEdgeTables, vtkPoints *segmentPoints, vtkDoubleArray *segmentRadii, vtkPoints *bifurcationPoints, vtkDoubleArray *bifurcationRadii, double oldCenter[3], double &oldRadius, double advancementRatio)
void MarkModelGlobalProfile (vtkPolyData *model, vtkIdTypeArray *newGlobalProfileEdgeTable)
void SegmentTopology (vtkCollection *bifurcations, vtkCollection *bifurcationsRadii, double firstSegmentPoint[3], double lastSegmentPoint[3], double firstPoint[3], double &firstRadius, double lastPoint[3], double &lastRadius, vtkIdType segmentTopology[2])
void BuildSegment (vtkPoints *segmentPoints, vtkDoubleArray *segmentRadii, vtkIdType segmentTopology[2], double firstPoint[3], double firstRadius, double lastPoint[3], double lastRadius, const double *centralPoint, vtkPolyData *segment)
void InsertNewBifurcation (vtkCollection *bifurcations, vtkCollection *bifurcationsRadii, vtkPoints *bifurcationPoints, vtkDoubleArray *bifurcationRadii, vtkPolyDataCollection *additionalSegments)
void SegmentIteration (vtkPolyData *model, vtkPolyData *initialProfile, vtkIdTypeArray *initialProfileEdgeTable, vtkPolyDataCollection *globalProfiles, vtkCollection *globalProfilesEdgeTables, vtkCollection *bifurcations, vtkCollection *bifurcationsRadii, vtkPolyDataCollection *segments, double advancementRatio)
void JoinSegments (vtkPolyData *segment0, vtkPolyData *segment1, bool first0, bool first1, vtkPolyData *segment)
void RemoveDegenerateBifurcations (vtkPolyDataCollection *segments, vtkCollection *bifurcations)
void GlobalIteration (vtkPolyData *model, vtkPolyDataCollection *globalProfiles, vtkPolyData *network, double advancementRatio)
void MarkModelRealBoundary (vtkPolyData *model, vtkPolyData *modelBoundary)
void Graph (vtkPolyData *network, vtkPolyData *graphLayout)
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

vtkPolyData * GraphLayout
char * MarksArrayName
char * RadiusArrayName
char * TopologyArrayName
double MinimumStep
double AdvancementRatio
vtkIdType TotalMarkedPoints

Detailed Description

Create an approximated network graph (preliminary to centerline) from an input surface with at least one hole in it.

Starting from an open boundary of the input surface, advances a series of inscribed spheres along the (approximate) medial axis of the tubular structure, stepping each sphere outward by AdvancementRatio times the local radius, splitting into new branches at bifurcations and stopping at free ends or closed caps. The result is a coarse network graph (a fast, approximate predecessor to full centerline extraction – see vtkvmtkPolyDataCenterlines – useful for quickly identifying topology/seed points on very large or complex models). This is the filter behind the vmtknetworkextraction pype script.

See also
vtkvmtkPolyDataCenterlines

Definition at line 45 of file vtkvmtkPolyDataNetworkExtraction.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkPolyDataNetworkExtraction::Superclass

Definition at line 48 of file vtkvmtkPolyDataNetworkExtraction.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Return values of the internal per-step propagation state machine (StepIteration): whether to keep advancing, redefine the current step, or stop because a free end, bifurcation, or closed cap was reached.

Enumerator
STEP_ITERATION_PROCEED 
STEP_ITERATION_REDEFINE 
STEP_ITERATION_STOP_END 
STEP_ITERATION_STOP_BIFURCATION 
STEP_ITERATION_STOP_CLOSED 

Definition at line 116 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ anonymous enum

anonymous enum

Values stored in the MarksArrayName point data array, tracking each surface point's visitation status during network propagation.

Enumerator
NON_VISITED 
VISITED 
GLOBAL 

Definition at line 131 of file vtkvmtkPolyDataNetworkExtraction.h.

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataNetworkExtraction()

vtkvmtkPolyDataNetworkExtraction::vtkvmtkPolyDataNetworkExtraction ( )
protected

Definition at line 48 of file vtkvmtkPolyDataNetworkExtraction.cxx.

49{
50 this->MarksArrayName = new char[256];
51 strcpy(this->MarksArrayName,"Marks");
52 this->RadiusArrayName = new char[256];
53 strcpy(this->RadiusArrayName,"Radius");
54 this->TopologyArrayName = new char[256];
55 strcpy(this->TopologyArrayName,"Topology");
56
57 this->MinimumStep = 5E-4;
58 this->TotalMarkedPoints = 0;
59
60 this->GraphLayout = NULL;
61}

◆ ~vtkvmtkPolyDataNetworkExtraction()

vtkvmtkPolyDataNetworkExtraction::~vtkvmtkPolyDataNetworkExtraction ( )
protected

Definition at line 63 of file vtkvmtkPolyDataNetworkExtraction.cxx.

64{
65 if (this->MarksArrayName)
66 {
67 delete[] this->MarksArrayName;
68 this->MarksArrayName = NULL;
69 }
70 if (this->RadiusArrayName)
71 {
72 delete[] this->RadiusArrayName;
73 this->RadiusArrayName = NULL;
74 }
75 if (this->TopologyArrayName)
76 {
77 delete[] this->TopologyArrayName;
78 this->TopologyArrayName = NULL;
79 }
80 if (this->GraphLayout)
81 {
82 this->GraphLayout->Delete();
83 this->GraphLayout = NULL;
84 }
85}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataNetworkExtraction::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataNetworkExtraction * vtkvmtkPolyDataNetworkExtraction::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 1949 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1950{
1951 this->Superclass::PrintSelf(os,indent);
1952}

◆ New()

vtkvmtkPolyDataNetworkExtraction * vtkvmtkPolyDataNetworkExtraction::New ( )
static

◆ SetMarksArrayName()

virtual void vtkvmtkPolyDataNetworkExtraction::SetMarksArrayName ( const char * )
virtual

Set/Get the name of the point data array used internally to mark points of the input surface as visited during network propagation (see the NON_VISITED/VISITED/GLOBAL enum). Default: "Marks".

◆ GetMarksArrayName()

virtual char * vtkvmtkPolyDataNetworkExtraction::GetMarksArrayName ( )
virtual

Set/Get the name of the point data array used internally to mark points of the input surface as visited during network propagation (see the NON_VISITED/VISITED/GLOBAL enum). Default: "Marks".

◆ SetRadiusArrayName()

virtual void vtkvmtkPolyDataNetworkExtraction::SetRadiusArrayName ( const char * )
virtual

Set/Get the name of the point data array of the output network where the local inscribed sphere radius is stored at each network point. Default: "Radius".

◆ GetRadiusArrayName()

virtual char * vtkvmtkPolyDataNetworkExtraction::GetRadiusArrayName ( )
virtual

Set/Get the name of the point data array of the output network where the local inscribed sphere radius is stored at each network point. Default: "Radius".

◆ SetTopologyArrayName()

virtual void vtkvmtkPolyDataNetworkExtraction::SetTopologyArrayName ( const char * )
virtual

Set/Get the name of the cell data array of the output network where topology information (segment connectivity) is stored. Default: "Topology".

◆ GetTopologyArrayName()

virtual char * vtkvmtkPolyDataNetworkExtraction::GetTopologyArrayName ( )
virtual

Set/Get the name of the cell data array of the output network where topology information (segment connectivity) is stored. Default: "Topology".

◆ SetAdvancementRatio()

virtual void vtkvmtkPolyDataNetworkExtraction::SetAdvancementRatio ( double )
virtual

Set/Get the ratio between the propagation step size and the local maximum radius: at each step, the next inscribed sphere is advanced by AdvancementRatio times the current radius. Values closer to 1 produce a denser, more accurate network at higher computational cost. Default: not set by the class itself; the vmtknetworkextraction pype script defaults it to 1.05.

◆ GetAdvancementRatio()

virtual double vtkvmtkPolyDataNetworkExtraction::GetAdvancementRatio ( )
virtual

Set/Get the ratio between the propagation step size and the local maximum radius: at each step, the next inscribed sphere is advanced by AdvancementRatio times the current radius. Values closer to 1 produce a denser, more accurate network at higher computational cost. Default: not set by the class itself; the vmtknetworkextraction pype script defaults it to 1.05.

◆ GetTotalMarkedPoints()

virtual int vtkvmtkPolyDataNetworkExtraction::GetTotalMarkedPoints ( )
virtual

Get the total number of surface points visited (marked) during network propagation. Valid only after Update() has been called.

◆ GetMinimumStep()

virtual double vtkvmtkPolyDataNetworkExtraction::GetMinimumStep ( )
virtual

Get the smallest propagation step size encountered during network extraction. Valid only after Update() has been called.

◆ GetGraphLayout()

virtual vtkPolyData * vtkvmtkPolyDataNetworkExtraction::GetGraphLayout ( )
virtual

Get a simplified graph-layout representation of the extracted network (nodes and edges only, no geometric radius information), useful for visualization/inspection of the network topology. Valid only after Update() has been called.

◆ BoundaryExtractor()

void vtkvmtkPolyDataNetworkExtraction::BoundaryExtractor ( vtkPolyData * polyInput,
vtkPolyData * boundary )
protected

Definition at line 87 of file vtkvmtkPolyDataNetworkExtraction.cxx.

88{
89 if (polyInput->GetNumberOfCells()==0)
90 {
91 return;
92 }
93
94 vtkFeatureEdges *boundaryExtractor = vtkFeatureEdges::New();
95 boundaryExtractor->BoundaryEdgesOn();
96 boundaryExtractor->FeatureEdgesOff();
97 boundaryExtractor->NonManifoldEdgesOff();
98 boundaryExtractor->ManifoldEdgesOff();
99 boundaryExtractor->SetInputData(polyInput);
100 boundaryExtractor->Update();
101
102 if (boundaryExtractor->GetOutput()->GetNumberOfCells()==0)
103 {
104 boundaryExtractor->Delete();
105 return;
106 }
107
108 vtkCleanPolyData *boundaryExtractorCleaner = vtkCleanPolyData::New();
109 boundaryExtractorCleaner->SetInputConnection(boundaryExtractor->GetOutputPort());
110
111 vtkStripper *boundaryExtractorStripper = vtkStripper::New();
112 boundaryExtractorStripper->SetInputConnection(boundaryExtractorCleaner->GetOutputPort());
113 boundaryExtractorStripper->Update();
114
115 boundary->DeepCopy(boundaryExtractorStripper->GetOutput());
116
117 boundaryExtractorStripper->Delete();
118 boundaryExtractorCleaner->Delete();
119 boundaryExtractor->Delete();
120}

◆ BoundarySeparator()

void vtkvmtkPolyDataNetworkExtraction::BoundarySeparator ( vtkPolyData * appendedBoundaries,
vtkPolyDataCollection * boundaries )
protected

Definition at line 122 of file vtkvmtkPolyDataNetworkExtraction.cxx.

123{
124 appendedBoundaries->BuildLinks();
125
126 vtkIdType i;
127 for (i=0; i<appendedBoundaries->GetNumberOfCells(); i++)
128 {
129 vtkPoints* boundaryPoints = vtkPoints::New();
130 vtkCellArray* boundaryCellArray = vtkCellArray::New();
131 vtkIdType npts;
132 const vtkIdType *pts;
133 appendedBoundaries->GetCellPoints(i,npts,pts);
134 boundaryCellArray->InsertNextCell(npts+1);
135 vtkIdType j;
136 for (j=0; j<npts; j++)
137 {
138 boundaryPoints->InsertNextPoint(appendedBoundaries->GetPoint(pts[j]));
139 boundaryCellArray->InsertCellPoint(j);
140 }
141 boundaryCellArray->InsertCellPoint(0);
142 vtkPolyData* boundary = vtkPolyData::New();
143 boundary->SetPoints(boundaryPoints);
144 boundary->SetLines(boundaryCellArray);
145 boundaries->AddItem(boundary);
146 boundary->Delete();
147 boundaryPoints->Delete();
148 boundaryCellArray->Delete();
149 }
150}

◆ InsertInEdgeTable()

void vtkvmtkPolyDataNetworkExtraction::InsertInEdgeTable ( vtkIdTypeArray * edgeTable,
vtkIdType pointId0,
vtkIdType pointId1 )
protected

Definition at line 152 of file vtkvmtkPolyDataNetworkExtraction.cxx.

153{
154 vtkIdType edge[2];
155 edge[0] = pointId0;
156 edge[1] = pointId1;
157 edgeTable->InsertNextTypedTuple(edge);
158}

◆ InsertUniqueInEdgeTable()

bool vtkvmtkPolyDataNetworkExtraction::InsertUniqueInEdgeTable ( vtkIdTypeArray * edgeTable,
vtkIdType pointId0,
vtkIdType pointId1 )
protected

Definition at line 160 of file vtkvmtkPolyDataNetworkExtraction.cxx.

161{
162 vtkIdType edge[2];
163 edge[0] = pointId0;
164 edge[1] = pointId1;
165 vtkIdType i;
166 for (i=0; i<edgeTable->GetNumberOfTuples(); i++)
167 {
168 vtkIdType currentEdge[2];
169 edgeTable->GetTypedTuple(i, currentEdge);
170 if (currentEdge[0]==edge[0] && currentEdge[1]==edge[1])
171 {
172 return false;
173 }
174 }
175
176 edgeTable->InsertNextTypedTuple(edge);
177
178 return true;
179}

◆ GetFromEdgeTable()

void vtkvmtkPolyDataNetworkExtraction::GetFromEdgeTable ( vtkIdTypeArray * edgeTable,
vtkIdType position,
vtkIdType edge[2] )
protected

Definition at line 181 of file vtkvmtkPolyDataNetworkExtraction.cxx.

182{
183 edgeTable->GetTypedTuple(position, edge);
184}

◆ UpdateEdgeTableCollectionReal()

void vtkvmtkPolyDataNetworkExtraction::UpdateEdgeTableCollectionReal ( vtkPolyData * model,
vtkPolyDataCollection * profiles,
vtkCollection * edgeTables )
protected

Definition at line 186 of file vtkvmtkPolyDataNetworkExtraction.cxx.

187{
188 profiles->InitTraversal();
189 vtkIdType j;
190 for (j=0; j<profiles->GetNumberOfItems(); j++)
191 {
192 vtkPolyData* profile=profiles->GetNextItem();
193 vtkIdTypeArray* edgeTable = vtkIdTypeArray::New();
194 edgeTable->SetNumberOfComponents(2);
195 vtkIdType i;
196 for (i=0; i<profile->GetNumberOfPoints(); i++)
197 {
198 vtkIdType modelPointId = model->FindPoint(profile->GetPoint(i));
199 this->InsertInEdgeTable(edgeTable,modelPointId,modelPointId);
200 }
201 edgeTables->AddItem(edgeTable);
202 edgeTable->Delete();
203 }
204}
void InsertInEdgeTable(vtkIdTypeArray *edgeTable, vtkIdType pointId0, vtkIdType pointId1)

◆ Distance()

double vtkvmtkPolyDataNetworkExtraction::Distance ( double point1[3],
double point2[3] )
protected

Definition at line 206 of file vtkvmtkPolyDataNetworkExtraction.cxx.

207{
208 return sqrt(vtkMath::Distance2BetweenPoints(point1,point2));
209}

◆ GetFurthestDistance()

double vtkvmtkPolyDataNetworkExtraction::GetFurthestDistance ( vtkPolyDataCollection * polyDataCollection,
double fromPoint[3] )
protected

Definition at line 211 of file vtkvmtkPolyDataNetworkExtraction.cxx.

212{
213 vtkIdType i,j;
214 double dist, maxDist = 0.0;
215 polyDataCollection->InitTraversal();
216 for (i=0; i<polyDataCollection->GetNumberOfItems(); i++)
217 {
218 vtkPolyData* item = polyDataCollection->GetNextItem();
219 for (j=0; j<item->GetNumberOfPoints(); j++)
220 {
221 dist = vtkMath::Distance2BetweenPoints(item->GetPoint(j),fromPoint);
222 if (dist > maxDist)
223 {
224 maxDist = dist;
225 }
226 }
227 }
228
229 return sqrt(maxDist);
230}

◆ Barycenter()

void vtkvmtkPolyDataNetworkExtraction::Barycenter ( vtkPoints * points,
double barycenter[3] )
protected

Definition at line 232 of file vtkvmtkPolyDataNetworkExtraction.cxx.

233{
234 vtkIdType numberOfPoints = points->GetNumberOfPoints();
235 vtkIdType i,j;
236 for (i=0; i<3; i++)
237 {
238 double sum = 0.0;
239 for (j=0; j<numberOfPoints; j++)
240 {
241 sum = sum + ((points->GetPoint(j))[i]);
242 }
243 barycenter[i] = sum / numberOfPoints;
244 }
245}

◆ ProfileBarycenter()

void vtkvmtkPolyDataNetworkExtraction::ProfileBarycenter ( vtkPoints * points,
double barycenter[3] )
protected

Definition at line 247 of file vtkvmtkPolyDataNetworkExtraction.cxx.

248{
249 vtkIdType numberOfPoints = points->GetNumberOfPoints();
250
251 if (numberOfPoints == 0)
252 {
253 barycenter[0] = barycenter[1] = barycenter[2] = 0.0;
254 return;
255 }
256
257 vtkDoubleArray* lineLengths = vtkDoubleArray::New();
258 double totalLength = 0.0;
259 vtkIdType i;
260 for (i=0; i<numberOfPoints; i++)
261 {
262 double point0[3], point1[3];
263 points->GetPoint(i,point0);
264 if (i < numberOfPoints-1)
265 {
266 points->GetPoint(i+1,point1);
267 }
268 else
269 {
270 points->GetPoint(0,point1);
271 }
272 double lineLength = sqrt(vtkMath::Distance2BetweenPoints(point0,point1));
273 lineLengths->InsertNextValue(lineLength);
274 totalLength += lineLength;
275 }
276
277 if (totalLength == 0.0)
278 {
279 points->GetPoint(0,barycenter);
280 lineLengths->Delete();
281 return;
282 }
283
284 vtkDoubleArray* pointWeights = vtkDoubleArray::New();
285 for (i=0; i<numberOfPoints; i++)
286 {
287 double length0 = 0.0;
288 if (i != 0)
289 {
290 length0 = lineLengths->GetValue(i-1);
291 }
292 else
293 {
294 length0 = lineLengths->GetValue(numberOfPoints-1);
295 }
296 double length1 = lineLengths->GetValue(i);
297 double pointWeight = (length0 + length1) / 2.0;
298 pointWeights->InsertNextValue(pointWeight);
299 }
300
301 for (i=0; i<3; i++)
302 {
303 double sum = 0.0;
304 vtkIdType j;
305 for (j=0; j<numberOfPoints; j++)
306 {
307 double pointCoord = points->GetPoint(j)[i];
308 double weight = pointWeights->GetValue(j);
309 sum += pointCoord * weight;
310 }
311 barycenter[i] = sum / totalLength;
312 }
313
314 lineLengths->Delete();
315 pointWeights->Delete();
316}

◆ DefineVirtualSphere()

void vtkvmtkPolyDataNetworkExtraction::DefineVirtualSphere ( vtkPolyDataCollection * baseProfiles,
double center[3],
double & radius,
double ratio )
protected

Definition at line 318 of file vtkvmtkPolyDataNetworkExtraction.cxx.

319{
320 vtkPoints* barycenters = vtkPoints::New();
321 baseProfiles->InitTraversal();
322 vtkIdType i;
323 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
324 {
325 vtkPolyData* baseProfile = baseProfiles->GetNextItem();
326 double barycenter[3];
327 this->ProfileBarycenter(baseProfile->GetPoints(),barycenter);
328 barycenters->InsertNextPoint(barycenter);
329 }
330 this->Barycenter(barycenters,center);
331 barycenters->Delete();
332 double distance = this->GetFurthestDistance(baseProfiles,center);
333 radius = distance * ratio;
334}
double GetFurthestDistance(vtkPolyDataCollection *polyDataCollection, double fromPoint[3])
void Barycenter(vtkPoints *points, double barycenter[3])
void ProfileBarycenter(vtkPoints *points, double barycenter[3])

◆ CurrentPointId()

vtkIdType vtkvmtkPolyDataNetworkExtraction::CurrentPointId ( vtkPolyData * model,
vtkIdType currentEdge[2] )
protected

Definition at line 336 of file vtkvmtkPolyDataNetworkExtraction.cxx.

337{
338 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
339
340 vtkIdType currentPointId;
341 if (currentEdge[0] != currentEdge[1])
342 {
343 if (marksArray->GetValue(currentEdge[1]) == NON_VISITED)
344 {
345 currentPointId = currentEdge[1];
346 }
347 else if (marksArray->GetValue(currentEdge[0]) == NON_VISITED)
348 {
349 currentPointId = currentEdge[0];
350 }
351 else
352 {
353 currentPointId = -1;
354 }
355 }
356 else
357 {
358 currentPointId = currentEdge[0];
359 }
360
361 return currentPointId;
362}

◆ InsertEdgeForNewProfiles()

void vtkvmtkPolyDataNetworkExtraction::InsertEdgeForNewProfiles ( vtkPolyData * model,
vtkIdType * edge,
vtkIdTypeArray * edgeTable,
vtkIdTypeArray * cellPairs,
vtkIdList * pointIds )
protected

Definition at line 364 of file vtkvmtkPolyDataNetworkExtraction.cxx.

365{
366 if (this->InsertUniqueInEdgeTable(edgeTable,edge[0],edge[1]))
367 {
368 vtkIdType ncells0;
369 vtkIdType *cell0;
370 model->GetPointCells(edge[0],ncells0,cell0);
371 vtkIdType ncells1;
372 vtkIdType *cell1;
373 model->GetPointCells(edge[1],ncells1,cell1);
374
375 vtkIdType cellPair[2];
376 cellPair[0] = -1;
377 cellPair[1] = -1;
378 vtkIdType i,j;
379 for (i=0; i<ncells0; i++)
380 {
381 for (j=0; j<ncells1; j++)
382 {
383 if (cell0[i]==cell1[j])
384 {
385 if (cellPair[0]==-1)
386 {
387 cellPair[0]=cell0[i];
388 }
389 else
390 {
391 cellPair[1]=cell0[i];
392 }
393 }
394 }
395 }
396
397 this->InsertInEdgeTable(cellPairs,cellPair[0],cellPair[1]);
398
399 pointIds->InsertUniqueId(edge[0]);
400 pointIds->InsertUniqueId(edge[1]);
401 }
402}
bool InsertUniqueInEdgeTable(vtkIdTypeArray *edgeTable, vtkIdType pointId0, vtkIdType pointId1)

◆ LookForNeighbors()

bool vtkvmtkPolyDataNetworkExtraction::LookForNeighbors ( vtkPolyData * model,
vtkIdType pointId,
vtkIdList * notVisitedIds,
vtkIdTypeArray * edgeTableForIncludedGlobalProfiles )
protected

Definition at line 405 of file vtkvmtkPolyDataNetworkExtraction.cxx.

406{
407 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
408
409 bool someNeighborsFound = false;
410 // return non visited neighbors, and true if there are any, false otherwise
411 vtkIdType ncells;
412 vtkIdType *cell;
413 model->GetPointCells(pointId,ncells,cell);
414 vtkIdType i;
415 for (i=0; i<ncells; i++)
416 {
417 vtkIdType npts;
418 const vtkIdType *pts;
419 model->GetCellPoints(cell[i],npts,pts);
420 vtkIdType j;
421 for (j=0; j<npts; j++)
422 {
423 if (pts[j]!=pointId)
424 {
425 vtkIdType scalar = marksArray->GetValue(pts[j]);
426 if (scalar == NON_VISITED)
427 {
428 notVisitedIds->InsertUniqueId(pts[j]);
429 someNeighborsFound=true;
430 }
431 else if (scalar == GLOBAL)
432 {
433 this->InsertInEdgeTable(edgeTableForIncludedGlobalProfiles,pointId,pts[j]);
434 }
435 }
436 }
437 }
438
439 return someNeighborsFound;
440}

◆ PropagateFromBaseProfilePoint()

void vtkvmtkPolyDataNetworkExtraction::PropagateFromBaseProfilePoint ( vtkPolyData * model,
vtkIdList * toVisitPointIds,
double center[3],
double radius,
vtkIdTypeArray * edgeTableForNewProfiles,
vtkIdTypeArray * cellPairsForNewProfiles,
vtkIdList * pointIdsForNewProfiles,
vtkPoints * markedPoints,
vtkIdList * markedPointIds,
vtkIdTypeArray * edgeTableForIncludedGlobalProfiles )
protected

Definition at line 442 of file vtkvmtkPolyDataNetworkExtraction.cxx.

443{
444 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
445
446 while (toVisitPointIds->GetNumberOfIds())
447 {
448 vtkIdType currentPointId = toVisitPointIds->GetId(0);
449 if (marksArray->GetValue(currentPointId) == NON_VISITED)
450 {
451 marksArray->InsertValue(currentPointId,VISITED);
452 if (markedPointIds->IsId(currentPointId)==-1)
453 {
454 double markedPoint[3];
455 model->GetPoint(currentPointId,markedPoint);
456 markedPoints->InsertNextPoint(markedPoint);
457 markedPointIds->InsertNextId(currentPointId);
458 }
459 }
460
461 // call LookForNeighbors, compare distances and call PropagateFromBaseProfilePovtkIdType again is povtkIdType
462 // is non visited and falls inside the sphere. If it falls outside add edge to edge list
463 vtkIdList* notVisitedNeighbors = vtkIdList::New();
464 if (LookForNeighbors(model,currentPointId,notVisitedNeighbors,edgeTableForIncludedGlobalProfiles))
465 {
466 marksArray->InsertValue(currentPointId,VISITED);
467 vtkIdType edge[2];
468 vtkIdType i;
469 for (i=0; i<notVisitedNeighbors->GetNumberOfIds(); i++)
470 {
471 double point[3];
472 model->GetPoint(notVisitedNeighbors->GetId(i),point);
473 if (this->Distance(center,point) > radius)
474 {
475 edge[0]=currentPointId; edge[1]=notVisitedNeighbors->GetId(i);
476 this->InsertEdgeForNewProfiles(model,edge,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles);
477 }
478 else
479 {
480 toVisitPointIds->InsertUniqueId(notVisitedNeighbors->GetId(i));
481 }
482 }
483 }
484 toVisitPointIds->DeleteId(currentPointId);
485 notVisitedNeighbors->Delete();
486 }
487}
void InsertEdgeForNewProfiles(vtkPolyData *model, vtkIdType *edge, vtkIdTypeArray *edgeTable, vtkIdTypeArray *cellPairs, vtkIdList *pointIds)
double Distance(double point1[3], double point2[3])
bool LookForNeighbors(vtkPolyData *model, vtkIdType pointId, vtkIdList *notVisitedIds, vtkIdTypeArray *edgeTableForIncludedGlobalProfiles)

◆ LocateVirtualPoint()

void vtkvmtkPolyDataNetworkExtraction::LocateVirtualPoint ( vtkIdType edge[2],
double center[3],
double radius,
vtkIdList * pointIdsForNewProfiles,
vtkPoints * pointsForNewProfiles,
vtkDoubleArray * pointDistancesForNewProfiles,
double virtualPoint[3] )
protected

Definition at line 489 of file vtkvmtkPolyDataNetworkExtraction.cxx.

490{
491 virtualPoint[0] = virtualPoint[1] = virtualPoint[2] = 0.0;
492
493 vtkIdType position0 = pointIdsForNewProfiles->IsId(edge[0]);
494 vtkIdType position1 = pointIdsForNewProfiles->IsId(edge[1]);
495
496 double point0[3], point1[3];
497 pointsForNewProfiles->GetPoint(position0,point0);
498 pointsForNewProfiles->GetPoint(position1,point1);
499
500 double distance0 = pointDistancesForNewProfiles->GetValue(position0);
501 double distance1 = pointDistancesForNewProfiles->GetValue(position1);
502
503 double distance2 = vtkMath::Distance2BetweenPoints(point0,point1);
504
505 if (radius > 0.0 && distance2 > 1E-12)
506 {
507 double h2 = vtkLine::DistanceToLine(center,point0,point1);
508
509 double distance = sqrt(distance2);
510
511 double b = 0.0;
512 if (radius*radius - h2 > 0.0)
513 {
514 b = sqrt(radius*radius - h2);
515 }
516
517 double a = 0.0;
518 if (distance0*distance0 - h2 > 0.0)
519 {
520 a = sqrt(distance0*distance0 - h2);
521 }
522
523 double parametricCoordinate = 0.0;
524 if (distance2 < (distance1*distance1 - h2))
525 {
526 parametricCoordinate = b - a;
527 }
528 else
529 {
530 parametricCoordinate = b + a;
531 }
532
533 virtualPoint[0] = point0[0] + parametricCoordinate * (point1[0]-point0[0]) / distance;
534 virtualPoint[1] = point0[1] + parametricCoordinate * (point1[1]-point0[1]) / distance;
535 virtualPoint[2] = point0[2] + parametricCoordinate * (point1[2]-point0[2]) / distance;
536 }
537 else
538 {
539 if (distance0<distance1)
540 {
541 virtualPoint[0] = point0[0];
542 virtualPoint[1] = point0[1];
543 virtualPoint[2] = point0[2];
544 }
545 else
546 {
547 virtualPoint[0] = point1[0];
548 virtualPoint[1] = point1[1];
549 virtualPoint[2] = point1[2];
550 }
551 }
552}

◆ ReconstructNewProfiles()

void vtkvmtkPolyDataNetworkExtraction::ReconstructNewProfiles ( vtkPoints * virtualPoints,
vtkIdTypeArray * edgeTable,
vtkIdTypeArray * cellPairs,
vtkPolyDataCollection * newProfiles,
vtkCollection * newProfilesEdgeTables )
protected

Definition at line 554 of file vtkvmtkPolyDataNetworkExtraction.cxx.

555{
556 // reconstruct using adjacent triangles
557 vtkIdList* notVisitedIds = vtkIdList::New();
558 vtkIdType i;
559 for (i=0; i<virtualPoints->GetNumberOfPoints(); i++)
560 {
561 notVisitedIds->InsertNextId(i);
562 }
563
564 while (notVisitedIds->GetNumberOfIds())
565 {
566 vtkPolyData* newProfile = vtkPolyData::New();
567 vtkPoints* newProfilePoints = vtkPoints::New();
568 newProfile->SetPoints(newProfilePoints);
569
570 vtkIdTypeArray* newProfileEdgeTable = vtkIdTypeArray::New();
571 newProfileEdgeTable->SetNumberOfComponents(2);
572 vtkIdType cellPair0[2];
573 vtkIdType position1 = notVisitedIds->GetId(0);
574 this->GetFromEdgeTable(cellPairs,position1,cellPair0);
575 vtkIdType initialCellId = cellPair0[0];
576 vtkIdType cellIdToSearch = cellPair0[1];
577 newProfile->GetPoints()->InsertNextPoint(virtualPoints->GetPoint(position1));
578 vtkIdType newProfileEdge[2];
579 this->GetFromEdgeTable(edgeTable,position1,newProfileEdge);
580 notVisitedIds->DeleteId(position1);
581 this->InsertInEdgeTable(newProfileEdgeTable,newProfileEdge[0],newProfileEdge[1]);
582
583 bool closed = false;
584 vtkIdType cellPair1[2];
585 while (!closed)
586 {
587 bool foundNext = false;
588 vtkIdType j = 0;
589 while (!foundNext)
590 {
591 if (j >= notVisitedIds->GetNumberOfIds())
592 {
593 vtkErrorMacro(<<"Error: can't reconstruct new profile.");
594 return;
595 }
596
597 vtkIdType position2 = notVisitedIds->GetId(j);
598 this->GetFromEdgeTable(cellPairs,position2,cellPair1);
599 if (cellPair1[0] == cellIdToSearch)
600 {
601 double virtualPoint[3];
602 virtualPoints->GetPoint(position2,virtualPoint);
603 newProfile->GetPoints()->InsertNextPoint(virtualPoint);
604 this->GetFromEdgeTable(edgeTable,position2,newProfileEdge);
605 this->InsertInEdgeTable(newProfileEdgeTable,newProfileEdge[0],newProfileEdge[1]);
606 foundNext = true;
607 notVisitedIds->DeleteId(position2);
608 cellIdToSearch = cellPair1[1];
609 }
610 else if (cellPair1[1] == cellIdToSearch)
611 {
612 double virtualPoint[3];
613 virtualPoints->GetPoint(position2,virtualPoint);
614 newProfile->GetPoints()->InsertNextPoint(virtualPoint);
615 this->GetFromEdgeTable(edgeTable,position2,newProfileEdge);
616 this->InsertInEdgeTable(newProfileEdgeTable,newProfileEdge[0],newProfileEdge[1]);
617 foundNext = true;
618 notVisitedIds->DeleteId(position2);
619 cellIdToSearch = cellPair1[0];
620 }
621 j++;
622 }
623
624 if (cellIdToSearch == initialCellId)
625 {
626 closed = true;
627 }
628 }
629
630 vtkCellArray* newProfileLines = vtkCellArray::New();
631 newProfileLines->InsertNextCell(newProfile->GetNumberOfPoints() + 1);
632 vtkIdType i;
633 for (i=0; i<newProfile->GetNumberOfPoints(); i++)
634 {
635 newProfileLines->InsertCellPoint(i);
636 }
637 newProfileLines->InsertCellPoint(0);
638 newProfile->SetLines(newProfileLines);
639 newProfiles->AddItem(newProfile);
640 newProfilesEdgeTables->AddItem(newProfileEdgeTable);
641 newProfile->Delete();
642 newProfilePoints->Delete();
643 newProfileLines->Delete();
644 newProfileEdgeTable->Delete();
645 }
646 notVisitedIds->Delete();
647}
void GetFromEdgeTable(vtkIdTypeArray *edgeTable, vtkIdType position, vtkIdType edge[2])

◆ GenerateNewProfiles()

void vtkvmtkPolyDataNetworkExtraction::GenerateNewProfiles ( vtkPolyData * model,
double center[3],
double radius,
vtkIdTypeArray * edgeTableForNewProfiles,
vtkIdTypeArray * cellPairsForNewProfiles,
vtkIdList * pointIdsForNewProfiles,
vtkPolyDataCollection * newProfiles,
vtkCollection * newProfilesEdgeTables )
protected

Definition at line 649 of file vtkvmtkPolyDataNetworkExtraction.cxx.

650{
651 if (edgeTableForNewProfiles->GetNumberOfTuples())
652 {
653 vtkPoints* pointsForNewProfiles = vtkPoints::New();
654 vtkDoubleArray* pointDistancesForNewProfiles = vtkDoubleArray::New();
655
656 vtkIdType i;
657 for (i=0; i<pointIdsForNewProfiles->GetNumberOfIds(); i++)
658 {
659 double point[3];
660 model->GetPoint(pointIdsForNewProfiles->GetId(i),point);
661 pointsForNewProfiles->InsertNextPoint(point);
662 pointDistancesForNewProfiles->InsertNextValue(Distance(center,point));
663 }
664
665 vtkPoints* virtualPointsForNewProfiles = vtkPoints::New();
666 vtkIdType edge[2];
667 for (i=0; i<edgeTableForNewProfiles->GetNumberOfTuples(); i++)
668 {
669 this->GetFromEdgeTable(edgeTableForNewProfiles,i,edge);
670 double virtualPoint[3];
671 this->LocateVirtualPoint(edge,center,radius,pointIdsForNewProfiles,pointsForNewProfiles,pointDistancesForNewProfiles,virtualPoint);
672 virtualPointsForNewProfiles->InsertNextPoint(virtualPoint);
673 }
674
675 this->ReconstructNewProfiles(virtualPointsForNewProfiles,edgeTableForNewProfiles,cellPairsForNewProfiles,newProfiles,newProfilesEdgeTables);
676
677 pointsForNewProfiles->Delete();
678 pointDistancesForNewProfiles->Delete();
679 virtualPointsForNewProfiles->Delete();
680 }
681}
void ReconstructNewProfiles(vtkPoints *virtualPoints, vtkIdTypeArray *edgeTable, vtkIdTypeArray *cellPairs, vtkPolyDataCollection *newProfiles, vtkCollection *newProfilesEdgeTables)
void LocateVirtualPoint(vtkIdType edge[2], double center[3], double radius, vtkIdList *pointIdsForNewProfiles, vtkPoints *pointsForNewProfiles, vtkDoubleArray *pointDistancesForNewProfiles, double virtualPoint[3])

◆ UnmarkPoints()

void vtkvmtkPolyDataNetworkExtraction::UnmarkPoints ( vtkPolyData * model,
vtkIdList * markedPointIds )
protected

Definition at line 683 of file vtkvmtkPolyDataNetworkExtraction.cxx.

684{
685 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
686 vtkIdType i;
687 for (i=0; i<markedPointIds->GetNumberOfIds(); i++)
688 {
689 marksArray->InsertValue(markedPointIds->GetId(i),NON_VISITED);
690 }
691}

◆ ComputeStepRadius()

double vtkvmtkPolyDataNetworkExtraction::ComputeStepRadius ( vtkPoints * points,
double point1[3],
double point2[3] )
protected

Definition at line 693 of file vtkvmtkPolyDataNetworkExtraction.cxx.

694{
695 vtkIdType i;
696 double radius = 0.0;
697 for (i=0; i<points->GetNumberOfPoints(); i++)
698 {
699 double point[3];
700 points->GetPoint(i,point);
701 radius += sqrt(vtkLine::DistanceToLine(point,point1,point2));
702 }
703 radius /= points->GetNumberOfPoints();
704 return radius;
705}

◆ ComputeMeanRadius()

double vtkvmtkPolyDataNetworkExtraction::ComputeMeanRadius ( vtkPoints * points,
double point1[3] )
protected

Definition at line 707 of file vtkvmtkPolyDataNetworkExtraction.cxx.

708{
709 vtkIdType i;
710 double radius = 0.0;
711 for (i=0; i<points->GetNumberOfPoints(); i++)
712 {
713 double point[3];
714 points->GetPoint(i,point);
715 radius += sqrt(vtkMath::Distance2BetweenPoints(point,point1));
716 }
717 radius /= points->GetNumberOfPoints();
718 return radius;
719}

◆ PointsForRadius()

void vtkvmtkPolyDataNetworkExtraction::PointsForRadius ( vtkPoints * markedPoints,
vtkPolyDataCollection * baseProfiles,
vtkPolyDataCollection * newProfiles,
vtkPoints * pointsForRadius )
protected

Definition at line 722 of file vtkvmtkPolyDataNetworkExtraction.cxx.

723{
724 vtkIdType i,j;
725 if (markedPoints)
726 {
727 for (i=0; i<markedPoints->GetNumberOfPoints(); i++)
728 {
729 pointsForRadius->InsertNextPoint(markedPoints->GetPoint(i));
730 }
731 }
732
733 if (baseProfiles)
734 {
735 baseProfiles->InitTraversal();
736 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
737 {
738 vtkPoints *baseProfilePoints = baseProfiles->GetNextItem()->GetPoints();
739 for (j=0; j<baseProfilePoints->GetNumberOfPoints(); j++)
740 {
741 pointsForRadius->InsertNextPoint(baseProfilePoints->GetPoint(j));
742 }
743 }
744 }
745
746 if (newProfiles)
747 {
748 newProfiles->InitTraversal();
749 for (i=0; i<newProfiles->GetNumberOfItems(); i++)
750 {
751 vtkPoints *newProfilePoints = newProfiles->GetNextItem()->GetPoints();
752 for (j=0; j<newProfilePoints->GetNumberOfPoints(); j++)
753 {
754 pointsForRadius->InsertNextPoint(newProfilePoints->GetPoint(j));
755 }
756 }
757 }
758}

◆ LookForIntersectingPoint()

void vtkvmtkPolyDataNetworkExtraction::LookForIntersectingPoint ( vtkPoints * segmentPoints,
double center[3],
double radius,
vtkIdType & intersectingPointId )
protected

Definition at line 760 of file vtkvmtkPolyDataNetworkExtraction.cxx.

761{
762 intersectingPointId = segmentPoints->GetNumberOfPoints()-1;
763 vtkIdType i;
764 for (i=segmentPoints->GetNumberOfPoints()-2; i>=0; i--)
765 {
766 double segmentPoint[3];
767 segmentPoints->GetPoint(i,segmentPoint);
768 if (this->Distance(center,segmentPoint)>radius)
769 {
770 intersectingPointId = i+1;
771 break;
772 }
773 }
774}

◆ StepIteration()

vtkIdType vtkvmtkPolyDataNetworkExtraction::StepIteration ( vtkPolyData * model,
vtkPolyDataCollection * baseProfiles,
vtkCollection * baseProfilesEdgeTables,
vtkPolyDataCollection * globalProfiles,
vtkCollection * globalProfilesEdgeTables,
vtkPolyDataCollection * newProfiles,
vtkCollection * newProfilesEdgeTables,
vtkPoints * segmentPoints,
vtkDoubleArray * segmentRadii,
vtkPoints * bifurcationPoints,
vtkDoubleArray * bifurcationRadii,
double oldCenter[3],
double & oldRadius,
double advancementRatio )
protected

Definition at line 776 of file vtkvmtkPolyDataNetworkExtraction.cxx.

777{
778 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
779
780 double center[3];
781 double radius;
782 this->DefineVirtualSphere(baseProfiles,center,radius,advancementRatio);
783
784 bool sameCenter = false;
785 if (oldRadius > 0.0)
786 {
787 if (this->Distance(center,oldCenter) < this->MinimumStep && radius <= oldRadius)
788 {
789 radius = 2.0 * oldRadius;
790 sameCenter = true;
791 }
792 }
793
794 // now propagate and build virtual profile(s)
795 vtkIdTypeArray* edgeTableForNewProfiles = vtkIdTypeArray::New();
796 edgeTableForNewProfiles->SetNumberOfComponents(2);
797 vtkIdTypeArray* cellPairsForNewProfiles = vtkIdTypeArray::New();
798 cellPairsForNewProfiles->SetNumberOfComponents(2);
799 vtkIdList* pointIdsForNewProfiles = vtkIdList::New(); //for doubleScalars mapping
800
801 vtkIdTypeArray* edgeTableForIncludedGlobalProfiles = vtkIdTypeArray::New();
802 edgeTableForIncludedGlobalProfiles->SetNumberOfComponents(2);
803
804 vtkPoints* markedPoints = vtkPoints::New();
805 vtkIdList* markedPointIds = vtkIdList::New();
806
807 vtkIdType i;
808 baseProfiles->InitTraversal();
809 baseProfilesEdgeTables->InitTraversal();
810 vtkIdList* old2MarkedPointIds = vtkIdList::New();
811 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
812 {
813 vtkPolyData* baseProfile = baseProfiles->GetNextItem();
814 vtkIdTypeArray* baseProfileEdgeTable = (vtkIdTypeArray*)baseProfilesEdgeTables->GetNextItemAsObject();
815 vtkIdType j;
816 for (j=0; j<baseProfile->GetNumberOfPoints(); j++)
817 {
818 vtkIdType currentEdge[2];
819 this->GetFromEdgeTable(baseProfileEdgeTable,j,currentEdge);
820 if (marksArray->GetValue(currentEdge[0]) == GLOBAL)
821 {
822 marksArray->InsertValue(currentEdge[0],VISITED);
823 old2MarkedPointIds->InsertNextId(currentEdge[0]);
824 }
825 }
826 }
827
828 // propagate from base profiles
829 baseProfiles->InitTraversal();
830 baseProfilesEdgeTables->InitTraversal();
831
832 vtkIdList* toVisitPointIds = vtkIdList::New();
833 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
834 {
835 vtkPolyData* baseProfile = baseProfiles->GetNextItem();
836 vtkIdTypeArray* baseProfileEdgeTable = (vtkIdTypeArray*)baseProfilesEdgeTables->GetNextItemAsObject();
837
838 vtkIdType j;
839 for (j=0; j<baseProfile->GetNumberOfPoints(); j++)
840 {
841 vtkIdType currentEdge[2];
842 this->GetFromEdgeTable(baseProfileEdgeTable,j,currentEdge);
843 vtkIdType currentPointId = CurrentPointId(model,currentEdge);
844
845 if (marksArray->GetValue(currentEdge[1]) == GLOBAL)
846 {
847 this->InsertInEdgeTable(edgeTableForIncludedGlobalProfiles,currentEdge[0],currentEdge[1]);
848 }
849
850 if (currentPointId!=-1)
851 {
852 if (this->Distance(model->GetPoint(currentPointId),center)>radius)
853 {
854 this->InsertEdgeForNewProfiles(model,currentEdge,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles);
855 }
856 else
857 {
858 toVisitPointIds->InsertNextId(currentPointId);
859 }
860 }
861 }
862 }
863
864 this->PropagateFromBaseProfilePoint(model,toVisitPointIds,center,radius,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles,markedPoints,markedPointIds,edgeTableForIncludedGlobalProfiles);
865
866 toVisitPointIds->Delete();
867
868 for (i=0; i<old2MarkedPointIds->GetNumberOfIds(); i++)
869 {
870 marksArray->InsertValue(old2MarkedPointIds->GetId(i),GLOBAL);
871 }
872
873 old2MarkedPointIds->Delete();
874
875 if (edgeTableForIncludedGlobalProfiles->GetNumberOfTuples() > 0)
876 {
877 vtkIdTypeArray* edgeTableForEffectiveIncludedGlobalProfiles = vtkIdTypeArray::New();
878 edgeTableForEffectiveIncludedGlobalProfiles->SetNumberOfComponents(2);
879
880 vtkIdType i;
881 for (i=0; i<edgeTableForIncludedGlobalProfiles->GetNumberOfTuples(); i++)
882 {
883 vtkIdType edgeForIncludedGlobalProfile[2];
884 this->GetFromEdgeTable(edgeTableForIncludedGlobalProfiles,i,edgeForIncludedGlobalProfile);
885 if (this->Distance(model->GetPoint(edgeForIncludedGlobalProfile[1]),center) <= radius)
886 {
887 this->InsertInEdgeTable(edgeTableForEffectiveIncludedGlobalProfiles,edgeForIncludedGlobalProfile[0],edgeForIncludedGlobalProfile[1]);
888 }
889 }
890
891 if (edgeTableForEffectiveIncludedGlobalProfiles->GetNumberOfTuples() > 0)
892 {
893 vtkIdList* includedGlobalProfilesIds = vtkIdList::New();
894 for (i=0; i<edgeTableForEffectiveIncludedGlobalProfiles->GetNumberOfTuples(); i++)
895 {
896 vtkIdType edgeForIncludedGlobalProfile[2];
897 this->GetFromEdgeTable(edgeTableForEffectiveIncludedGlobalProfiles,i,edgeForIncludedGlobalProfile);
898 globalProfiles->InitTraversal();
899 globalProfilesEdgeTables->InitTraversal();
900 vtkIdType j;
901 for (j=0; j<globalProfiles->GetNumberOfItems(); j++)
902 {
903// vtkPolyData* globalProfile = globalProfiles->GetNextItem();
904 vtkIdTypeArray* globalProfileEdgeTable = (vtkIdTypeArray*)globalProfilesEdgeTables->GetNextItemAsObject();
905 vtkIdType k;
906 for (k=0; k<globalProfileEdgeTable->GetNumberOfTuples(); k++)
907 {
908 vtkIdType globalProfileEdge[2];
909 this->GetFromEdgeTable(globalProfileEdgeTable,k,globalProfileEdge);
910 if (globalProfileEdge[0]!=globalProfileEdge[1])
911 {
912 if ((edgeForIncludedGlobalProfile[0] == globalProfileEdge[0] && edgeForIncludedGlobalProfile[1] == globalProfileEdge[1]) || (edgeForIncludedGlobalProfile[0] == globalProfileEdge[1] && edgeForIncludedGlobalProfile[1] == globalProfileEdge[0]))
913 {
914 includedGlobalProfilesIds->InsertUniqueId(j);
915 }
916 }
917 else if (globalProfileEdge[0] == globalProfileEdge[1])
918 {
919 if (edgeForIncludedGlobalProfile[0] == globalProfileEdge[0] || edgeForIncludedGlobalProfile[1] == globalProfileEdge[0])
920 {
921 includedGlobalProfilesIds->InsertUniqueId(j);
922 }
923 }
924 }
925 }
926 }
927
928 vtkPolyDataCollection* includedGlobalProfiles = vtkPolyDataCollection::New();
929 vtkCollection* includedGlobalProfilesEdgeTables = vtkCollection::New();
930 globalProfiles->InitTraversal();
931 globalProfilesEdgeTables->InitTraversal();
932 for (i=0; i<globalProfiles->GetNumberOfItems(); i++)
933 {
934 vtkPolyData* globalProfile = globalProfiles->GetNextItem();
935 vtkIdTypeArray* globalProfileEdgeTable = (vtkIdTypeArray*)globalProfilesEdgeTables->GetNextItemAsObject();
936 if (includedGlobalProfilesIds->IsId(i) != -1)
937 {
938 includedGlobalProfiles->AddItem(globalProfile);
939 baseProfiles->AddItem(globalProfile);
940 includedGlobalProfilesEdgeTables->AddItem(globalProfileEdgeTable);
941 baseProfilesEdgeTables->AddItem(globalProfileEdgeTable);
942 }
943 }
944
945 includedGlobalProfiles->InitTraversal();
946 includedGlobalProfilesEdgeTables->InitTraversal();
947 for (i=0; i<includedGlobalProfiles->GetNumberOfItems(); i++)
948 {
949 globalProfiles->RemoveItem(includedGlobalProfiles->GetNextItem());
950 globalProfilesEdgeTables->RemoveItem(includedGlobalProfilesEdgeTables->GetNextItemAsObject());
951 }
952
953 this->UnmarkPoints(model,markedPointIds);
954
955 edgeTableForNewProfiles->Delete();
956 cellPairsForNewProfiles->Delete();
957 pointIdsForNewProfiles->Delete();
958 edgeTableForIncludedGlobalProfiles->Delete();
959 markedPoints->Delete();
960 markedPointIds->Delete();
961 edgeTableForEffectiveIncludedGlobalProfiles->Delete();
962
963 includedGlobalProfilesIds->Delete();
964
965 includedGlobalProfiles->Delete();
966 includedGlobalProfilesEdgeTables->Delete();
968 }
969 else
970 {
971 for (i=0; i<edgeTableForIncludedGlobalProfiles->GetNumberOfTuples(); i++)
972 {
973 vtkIdType currentEdge[2];
974 this->GetFromEdgeTable(edgeTableForIncludedGlobalProfiles,i,currentEdge);
975 this->InsertEdgeForNewProfiles(model,currentEdge,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles);
976 }
977 }
978 edgeTableForEffectiveIncludedGlobalProfiles->Delete();
979 }
980
981 // build new profiles from lists (virtual points and connectivity)
982 this->GenerateNewProfiles(model,center,radius,edgeTableForNewProfiles,cellPairsForNewProfiles,pointIdsForNewProfiles,newProfiles,newProfilesEdgeTables);
983
984 this->TotalMarkedPoints += markedPointIds->GetNumberOfIds();
985
986 // classify step counting base and new profiles
987 vtkIdType numberOfBaseProfiles = baseProfiles->GetNumberOfItems();
988 vtkIdType numberOfNewProfiles = newProfiles->GetNumberOfItems();
989
990 if (numberOfBaseProfiles == 1 && numberOfNewProfiles == 0)
991 {
992 segmentPoints->InsertNextPoint(center);
993 edgeTableForNewProfiles->Delete();
994 cellPairsForNewProfiles->Delete();
995 pointIdsForNewProfiles->Delete();
996 edgeTableForIncludedGlobalProfiles->Delete();
997 markedPoints->Delete();
998 markedPointIds->Delete();
999
1001 }
1002 else if (numberOfBaseProfiles == 2 && numberOfNewProfiles == 0)
1003 {
1004 baseProfiles->InitTraversal();
1005 vtkPolyData* profile;
1006 profile = baseProfiles->GetNextItem();
1007 double point1[3];
1008 this->ProfileBarycenter(profile->GetPoints(),point1);
1009 segmentPoints->InsertNextPoint(point1);
1010 profile = baseProfiles->GetNextItem();
1011 double point2[3];
1012 this->ProfileBarycenter(profile->GetPoints(),point2);
1013 segmentPoints->InsertNextPoint(point2);
1014
1015 vtkPoints *pointsForRadius = vtkPoints::New();
1016 this->PointsForRadius(markedPoints,baseProfiles,NULL,pointsForRadius);
1017 segmentRadii->InsertNextValue(ComputeStepRadius(pointsForRadius,point1,point2));
1018
1019 pointsForRadius->Delete();
1020
1021 edgeTableForNewProfiles->Delete();
1022 cellPairsForNewProfiles->Delete();
1023 pointIdsForNewProfiles->Delete();
1024 edgeTableForIncludedGlobalProfiles->Delete();
1025 markedPoints->Delete();
1026 markedPointIds->Delete();
1027
1029 }
1030 else if (numberOfBaseProfiles + numberOfNewProfiles > 2)
1031 {
1032 double lastCenter[3];
1033 if (numberOfBaseProfiles==1)
1034 {
1035 lastCenter[0] = center[0];
1036 lastCenter[1] = center[1];
1037 lastCenter[2] = center[2];
1038 }
1039 else
1040 {
1041 baseProfiles->InitTraversal();
1042 vtkPolyData* profile;
1043 profile = baseProfiles->GetNextItem();
1044 this->ProfileBarycenter(profile->GetPoints(),lastCenter);
1045 }
1046
1047 segmentPoints->InsertNextPoint(lastCenter);
1048
1049 double firstBranchRadius = 0.0;
1050 vtkIdType intersectingPointId = -1;
1051 if (segmentRadii->GetNumberOfTuples() > 0)
1052 {
1053 this->LookForIntersectingPoint(segmentPoints,center,radius,intersectingPointId);
1054
1055 vtkIdType i;
1056 vtkPoints* backupSegmentPoints = vtkPoints::New();
1057 for (i=0; i<segmentPoints->GetNumberOfPoints(); i++)
1058 {
1059 backupSegmentPoints->InsertNextPoint(segmentPoints->GetPoint(i));
1060 }
1061 vtkDoubleArray* backupSegmentRadii = vtkDoubleArray::New();
1062 for (i=0; i<segmentRadii->GetNumberOfTuples(); i++)
1063 {
1064 backupSegmentRadii->InsertNextValue(segmentRadii->GetValue(i));
1065 }
1066
1067 segmentPoints->Initialize();
1068 for (i=0; i<=intersectingPointId; i++)
1069 {
1070 segmentPoints->InsertNextPoint(backupSegmentPoints->GetPoint(i));
1071 }
1072 segmentRadii->Initialize();
1073 for (i=0; i<intersectingPointId; i++)
1074 {
1075 segmentRadii->InsertNextValue(backupSegmentRadii->GetValue(i));
1076 }
1077
1078 firstBranchRadius = backupSegmentRadii->GetValue(intersectingPointId-1);
1079
1080 backupSegmentPoints->Delete();
1081 backupSegmentRadii->Delete();
1082 }
1083
1084 double bifurcationBarycenter[3];
1085 bifurcationBarycenter[0] = center[0];
1086 bifurcationBarycenter[1] = center[1];
1087 bifurcationBarycenter[2] = center[2];
1088
1089 bifurcationPoints->InsertNextPoint(bifurcationBarycenter);
1090 bifurcationRadii->InsertNextValue(0.0);
1091
1092 vtkPolyData* profile;
1093 baseProfiles->InitTraversal();
1094 vtkIdType i;
1095 double bifurcationPoint[3];
1096 for (i=0; i<baseProfiles->GetNumberOfItems(); i++)
1097 {
1098 profile=baseProfiles->GetNextItem();
1099 if (i==0 && segmentRadii->GetNumberOfTuples())
1100 {
1101 bifurcationPoints->InsertNextPoint(segmentPoints->GetPoint(intersectingPointId));
1102 bifurcationRadii->InsertNextValue(firstBranchRadius);
1103 }
1104 else
1105 {
1106 this->ProfileBarycenter(profile->GetPoints(),bifurcationPoint);
1107 bifurcationPoints->InsertNextPoint(bifurcationPoint);
1108 bifurcationRadii->InsertNextValue(this->ComputeMeanRadius(profile->GetPoints(),bifurcationPoint));
1109 }
1110 }
1111 newProfiles->InitTraversal();
1112 for (i=0; i<newProfiles->GetNumberOfItems(); i++)
1113 {
1114 profile=newProfiles->GetNextItem();
1115 this->ProfileBarycenter(profile->GetPoints(),bifurcationPoint);
1116 bifurcationPoints->InsertNextPoint(bifurcationPoint);
1117 bifurcationRadii->InsertNextValue(this->ComputeMeanRadius(profile->GetPoints(),bifurcationPoint));
1118 }
1119
1120 vtkIdType j;
1121 bifurcationBarycenter[0] = bifurcationBarycenter[1] = bifurcationBarycenter[2] = 0.0;
1122 double weightSum = 0.0;
1123 for (i=1; i<bifurcationPoints->GetNumberOfPoints(); i++)
1124 {
1125 double bifurcationPoint[3];
1126 bifurcationPoints->GetPoint(i,bifurcationPoint);
1127 double bifurcationPointRadius = bifurcationRadii->GetValue(i);
1128 weightSum+=bifurcationPointRadius;
1129 for (j=0; j<3; j++)
1130 {
1131 bifurcationBarycenter[j] += bifurcationPoint[j] * bifurcationPointRadius;
1132 }
1133 }
1134 for (j=0; j<3; j++)
1135 {
1136 bifurcationBarycenter[j] /= weightSum;
1137 }
1138 bifurcationPoints->InsertPoint(0,bifurcationBarycenter);
1139
1140 edgeTableForNewProfiles->Delete();
1141 cellPairsForNewProfiles->Delete();
1142 pointIdsForNewProfiles->Delete();
1143 edgeTableForIncludedGlobalProfiles->Delete();
1144 markedPoints->Delete();
1145 markedPointIds->Delete();
1146
1148 }
1149
1150 vtkPoints *pointsForRadius = vtkPoints::New();
1151 this->PointsForRadius(markedPoints,baseProfiles,newProfiles,pointsForRadius);
1152
1153 newProfiles->InitTraversal();
1154 double profileBarycenter[3];
1155 this->ProfileBarycenter(newProfiles->GetNextItem()->GetPoints(),profileBarycenter);
1156 double stepRadius = this->ComputeStepRadius(pointsForRadius,center,profileBarycenter);
1157
1158 pointsForRadius->Delete();
1159
1160 if (!sameCenter)
1161 {
1162 segmentRadii->InsertNextValue(stepRadius);
1163 segmentPoints->InsertNextPoint(center);
1164 }
1165 else
1166 {
1167 segmentRadii->InsertValue(segmentRadii->GetNumberOfTuples()-1,stepRadius);
1168 segmentPoints->InsertPoint(segmentPoints->GetNumberOfPoints()-1,center);
1169 }
1170
1171 oldCenter[0] = center[0];
1172 oldCenter[1] = center[1];
1173 oldCenter[2] = center[2];
1174 oldRadius = radius;
1175
1176 edgeTableForNewProfiles->Delete();
1177 cellPairsForNewProfiles->Delete();
1178 pointIdsForNewProfiles->Delete();
1179 edgeTableForIncludedGlobalProfiles->Delete();
1180 markedPoints->Delete();
1181 markedPointIds->Delete();
1182
1184}
void PropagateFromBaseProfilePoint(vtkPolyData *model, vtkIdList *toVisitPointIds, double center[3], double radius, vtkIdTypeArray *edgeTableForNewProfiles, vtkIdTypeArray *cellPairsForNewProfiles, vtkIdList *pointIdsForNewProfiles, vtkPoints *markedPoints, vtkIdList *markedPointIds, vtkIdTypeArray *edgeTableForIncludedGlobalProfiles)
double ComputeStepRadius(vtkPoints *points, double point1[3], double point2[3])
vtkIdType CurrentPointId(vtkPolyData *model, vtkIdType currentEdge[2])
double ComputeMeanRadius(vtkPoints *points, double point1[3])
void GenerateNewProfiles(vtkPolyData *model, double center[3], double radius, vtkIdTypeArray *edgeTableForNewProfiles, vtkIdTypeArray *cellPairsForNewProfiles, vtkIdList *pointIdsForNewProfiles, vtkPolyDataCollection *newProfiles, vtkCollection *newProfilesEdgeTables)
void UnmarkPoints(vtkPolyData *model, vtkIdList *markedPointIds)
void DefineVirtualSphere(vtkPolyDataCollection *baseProfiles, double center[3], double &radius, double ratio)
void PointsForRadius(vtkPoints *markedPoints, vtkPolyDataCollection *baseProfiles, vtkPolyDataCollection *newProfiles, vtkPoints *pointsForRadius)
void LookForIntersectingPoint(vtkPoints *segmentPoints, double center[3], double radius, vtkIdType &intersectingPointId)

◆ MarkModelGlobalProfile()

void vtkvmtkPolyDataNetworkExtraction::MarkModelGlobalProfile ( vtkPolyData * model,
vtkIdTypeArray * newGlobalProfileEdgeTable )
protected

Definition at line 1187 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1188{
1189 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
1190 vtkIdType i;
1191 for (i=0; i<newGlobalProfileEdgeTable->GetNumberOfTuples(); i++)
1192 {
1193 // the first is currentId, the second is not yet visited
1194 vtkIdType edge[2];
1195 this->GetFromEdgeTable(newGlobalProfileEdgeTable,i,edge);
1196 marksArray->InsertValue(edge[0],GLOBAL);
1197 }
1198}

◆ SegmentTopology()

void vtkvmtkPolyDataNetworkExtraction::SegmentTopology ( vtkCollection * bifurcations,
vtkCollection * bifurcationsRadii,
double firstSegmentPoint[3],
double lastSegmentPoint[3],
double firstPoint[3],
double & firstRadius,
double lastPoint[3],
double & lastRadius,
vtkIdType segmentTopology[2] )
protected

Definition at line 1200 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1201{
1202 segmentTopology[0] = segmentTopology[1] = 0;
1203
1204 bool firstPointFound = false;
1205 bool lastPointFound = false;
1206 if (!lastSegmentPoint)
1207 {
1208 segmentTopology[1] = -1;
1209 lastPointFound = true;
1210 }
1211
1212 vtkIdType i;
1213 bifurcations->InitTraversal();
1214 bifurcationsRadii->InitTraversal();
1215 for (i=0; i<bifurcations->GetNumberOfItems(); i++)
1216 {
1217 vtkPoints* bifurcation = (vtkPoints*)bifurcations->GetNextItemAsObject();
1218 vtkDoubleArray* bifurcationRadii = (vtkDoubleArray*)bifurcationsRadii->GetNextItemAsObject();
1219 vtkIdType j;
1220 for (j=0; j<bifurcation->GetNumberOfPoints(); j++)
1221 {
1222 if (i == 0 || (i > 0 && j > 0))
1223 {
1224 double point[3];
1225 bifurcation->GetPoint(j,point);
1226 if (!firstPointFound)
1227 {
1228 if (point[0] == firstSegmentPoint[0] && point[1] == firstSegmentPoint[1] && point[2] == firstSegmentPoint[2])
1229 {
1230 segmentTopology[0] = i;
1231 if (j > 0)
1232 {
1233 bifurcation->GetPoint(0,firstPoint);
1234 firstRadius = bifurcationRadii->GetValue(j);
1235 }
1236 firstPointFound = true;
1237 }
1238 }
1239 if (lastSegmentPoint && !lastPointFound)
1240 {
1241 if (point[0] == lastSegmentPoint[0] && point[1] == lastSegmentPoint[1] && point[2] == lastSegmentPoint[2])
1242 {
1243 segmentTopology[1] = i;
1244 if (j>0)
1245 {
1246 bifurcation->GetPoint(0,lastPoint);
1247 lastRadius = bifurcationRadii->GetValue(j);
1248 }
1249 lastPointFound = true;
1250 }
1251 }
1252 }
1253 if (firstPointFound && lastPointFound)
1254 {
1255 break;
1256 }
1257 }
1258 if (firstPointFound && lastPointFound)
1259 {
1260 break;
1261 }
1262 }
1263}

◆ BuildSegment()

void vtkvmtkPolyDataNetworkExtraction::BuildSegment ( vtkPoints * segmentPoints,
vtkDoubleArray * segmentRadii,
vtkIdType segmentTopology[2],
double firstPoint[3],
double firstRadius,
double lastPoint[3],
double lastRadius,
const double * centralPoint,
vtkPolyData * segment )
protected

Definition at line 1265 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1266{
1267 vtkPoints* segmentPolyPoints = vtkPoints::New();
1268 vtkDoubleArray* segmentPolyScalars = vtkDoubleArray::New();
1269 segmentPolyScalars->SetName(RadiusArrayName);
1270 vtkIdTypeArray* segmentTopologyArray = vtkIdTypeArray::New();
1271 segmentTopologyArray->SetName(TopologyArrayName);
1272 segmentTopologyArray->SetNumberOfComponents(2);
1273 segmentTopologyArray->InsertNextTypedTuple(segmentTopology);
1274
1275 // start
1276 if (segmentTopology[0] > 0)
1277 {
1278 segmentPolyPoints->InsertNextPoint(firstPoint);
1279 segmentPolyScalars->InsertNextValue(firstRadius);
1280 segmentPolyScalars->InsertNextValue(firstRadius);
1281 }
1282 else
1283 {
1284 segmentPolyScalars->InsertNextValue(0.0);
1285 }
1286
1287 vtkIdType i;
1288 // mid
1289 if (segmentPoints)
1290 {
1291 for (i=0; i<segmentPoints->GetNumberOfPoints(); i++)
1292 {
1293 segmentPolyPoints->InsertNextPoint(segmentPoints->GetPoint(i));
1294 }
1295 for (i=0; i<segmentRadii->GetNumberOfTuples(); i++)
1296 {
1297 segmentPolyScalars->InsertNextValue(segmentRadii->GetValue(i));
1298 }
1299 }
1300 else
1301 {
1302 segmentPolyPoints->InsertNextPoint(centralPoint);
1303 }
1304
1305 // end
1306 if (segmentTopology[1] > 0)
1307 {
1308 segmentPolyScalars->InsertNextValue(lastRadius);
1309 segmentPolyPoints->InsertNextPoint(lastPoint);
1310 segmentPolyScalars->InsertNextValue(lastRadius);
1311 }
1312 else
1313 {
1314 segmentPolyScalars->InsertNextValue(0.0);
1315 }
1316
1317 vtkCellArray* segmentPolyLine = vtkCellArray::New();
1318 segmentPolyLine->InsertNextCell(segmentPolyPoints->GetNumberOfPoints());
1319 vtkIdType j;
1320 for (j=0; j<segmentPolyPoints->GetNumberOfPoints(); j++)
1321 {
1322 segmentPolyLine->InsertCellPoint(j);
1323 }
1324 segment->SetPoints(segmentPolyPoints);
1325
1326 segment->GetPointData()->AddArray(segmentPolyScalars);
1327 segment->GetCellData()->AddArray(segmentTopologyArray);
1328 segment->SetLines(segmentPolyLine);
1329
1330 segmentPolyPoints->Delete();
1331 segmentPolyScalars->Delete();
1332 segmentPolyLine->Delete();
1333 segmentTopologyArray->Delete();
1334}

◆ InsertNewBifurcation()

void vtkvmtkPolyDataNetworkExtraction::InsertNewBifurcation ( vtkCollection * bifurcations,
vtkCollection * bifurcationsRadii,
vtkPoints * bifurcationPoints,
vtkDoubleArray * bifurcationRadii,
vtkPolyDataCollection * additionalSegments )
protected

Definition at line 1336 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1337{
1338 vtkIdType i;
1339 bifurcations->InitTraversal();
1340 bifurcationsRadii->InitTraversal();
1341 for (i=0; i<bifurcations->GetNumberOfItems(); i++)
1342 {
1343 vtkPoints* currentBifurcationPoints = (vtkPoints*)bifurcations->GetNextItemAsObject();
1344 vtkDoubleArray* currentBifurcationRadii = (vtkDoubleArray*)bifurcationsRadii->GetNextItemAsObject();
1345 vtkIdType j;
1346 for (j=0; j<currentBifurcationPoints->GetNumberOfPoints(); j++)
1347 {
1348 if (i == 0 || (i > 0 && j > 0))
1349 {
1350 double currentBifurcationPoint[3];
1351 currentBifurcationPoints->GetPoint(j,currentBifurcationPoint);
1352 vtkIdType k;
1353 for (k=0; k<bifurcationPoints->GetNumberOfPoints(); k++)
1354 {
1355 double bifurcationPoint[3];
1356 bifurcationPoints->GetPoint(k,bifurcationPoint);
1357 if ((currentBifurcationPoint[0]==bifurcationPoint[0]) && (currentBifurcationPoint[1]==bifurcationPoint[1]) && (currentBifurcationPoint[2]==bifurcationPoint[2]))
1358 {
1359 vtkIdType additionalSegmentTopology[2];
1360 additionalSegmentTopology[0] = i;
1361 additionalSegmentTopology[1] = bifurcations->GetNumberOfItems();
1362 double currentBifurcationPoint0[3], bifurcationPoint0[3];
1363 currentBifurcationPoints->GetPoint(0,currentBifurcationPoint0);
1364 bifurcationPoints->GetPoint(0,bifurcationPoint0);
1365 vtkPolyData* additionalSegment = vtkPolyData::New();
1366 this->BuildSegment(NULL,NULL,additionalSegmentTopology,currentBifurcationPoint0,currentBifurcationRadii->GetValue(j),bifurcationPoint0,bifurcationRadii->GetValue(k),bifurcationPoint,additionalSegment);
1367 additionalSegments->AddItem(additionalSegment);
1368 additionalSegment->Delete();
1369 }
1370 }
1371 }
1372 }
1373 }
1374
1375 bifurcations->AddItem(bifurcationPoints);
1376 bifurcationsRadii->AddItem(bifurcationRadii);
1377}
void BuildSegment(vtkPoints *segmentPoints, vtkDoubleArray *segmentRadii, vtkIdType segmentTopology[2], double firstPoint[3], double firstRadius, double lastPoint[3], double lastRadius, const double *centralPoint, vtkPolyData *segment)

◆ SegmentIteration()

void vtkvmtkPolyDataNetworkExtraction::SegmentIteration ( vtkPolyData * model,
vtkPolyData * initialProfile,
vtkIdTypeArray * initialProfileEdgeTable,
vtkPolyDataCollection * globalProfiles,
vtkCollection * globalProfilesEdgeTables,
vtkCollection * bifurcations,
vtkCollection * bifurcationsRadii,
vtkPolyDataCollection * segments,
double advancementRatio )
protected

Definition at line 1379 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1380{
1381 vtkPolyDataCollection* baseProfiles = vtkPolyDataCollection::New();
1382 baseProfiles->AddItem(initialProfile);
1383 vtkCollection* baseProfilesEdgeTables = vtkCollection::New();
1384 baseProfilesEdgeTables->AddItem(initialProfileEdgeTable);
1385
1386 vtkPolyDataCollection* newProfiles = vtkPolyDataCollection::New();
1387 vtkCollection* newProfilesEdgeTables = vtkCollection::New();
1388
1389 vtkPoints* segmentPoints = vtkPoints::New();
1390 vtkDoubleArray* segmentRadii = vtkDoubleArray::New();
1391 vtkPoints* bifurcationPoints = vtkPoints::New();
1392 vtkDoubleArray* bifurcationRadii = vtkDoubleArray::New();
1393
1394 double oldCenter[3];
1395 double oldRadius = 0.0;
1396 vtkIdType stepIterationState = STEP_ITERATION_PROCEED;
1397
1398 while (stepIterationState == STEP_ITERATION_PROCEED || stepIterationState == STEP_ITERATION_REDEFINE)
1399 {
1400 stepIterationState = STEP_ITERATION_PROCEED;
1401 stepIterationState = this->StepIteration(model,baseProfiles,baseProfilesEdgeTables,globalProfiles,globalProfilesEdgeTables,newProfiles,newProfilesEdgeTables,segmentPoints,segmentRadii,bifurcationPoints,bifurcationRadii,oldCenter,oldRadius,advancementRatio);
1402
1403 // avoid zero steps
1404 if (stepIterationState == STEP_ITERATION_PROCEED && oldRadius == 0.0)
1405 {
1406 stepIterationState = STEP_ITERATION_STOP_CLOSED;
1407 }
1408
1409 if (stepIterationState == STEP_ITERATION_PROCEED)
1410 {
1411 baseProfiles->RemoveAllItems();
1412 baseProfilesEdgeTables->RemoveAllItems();
1413 newProfiles->InitTraversal();
1414 newProfilesEdgeTables->InitTraversal();
1415 baseProfiles->AddItem(newProfiles->GetNextItem());
1416 baseProfilesEdgeTables->AddItem(newProfilesEdgeTables->GetNextItemAsObject());
1417 newProfiles->RemoveAllItems();
1418 newProfilesEdgeTables->RemoveAllItems();
1419 }
1420 }
1421
1422 vtkPolyData* segment = vtkPolyData::New();
1423 vtkPolyDataCollection* additionalSegments = vtkPolyDataCollection::New();
1424 vtkIdType segmentTopology[2];
1425 double firstPoint[3], lastPoint[3];
1426 double firstRadius, lastRadius;
1427 if (stepIterationState == STEP_ITERATION_STOP_BIFURCATION)
1428 {
1429 vtkIdType i;
1430 newProfiles->InitTraversal();
1431 newProfilesEdgeTables->InitTraversal();
1432 for (i=0; i<newProfiles->GetNumberOfItems(); i++)
1433 {
1434 globalProfiles->AddItem(newProfiles->GetNextItem());
1435 vtkIdTypeArray* newGlobalProfileEdgeTable = (vtkIdTypeArray*)newProfilesEdgeTables->GetNextItemAsObject();
1436 globalProfilesEdgeTables->AddItem(newGlobalProfileEdgeTable);
1437 this->MarkModelGlobalProfile(model,newGlobalProfileEdgeTable);
1438 }
1439
1440 // adjacent check
1441 this->InsertNewBifurcation(bifurcations,bifurcationsRadii,bifurcationPoints,bifurcationRadii,additionalSegments);
1442
1443 if (segmentPoints->GetNumberOfPoints()>=2)
1444 {
1445 double segmentPoint0[3], segmentPoint1[3];
1446 segmentPoints->GetPoint(0,segmentPoint0);
1447 segmentPoints->GetPoint(segmentPoints->GetNumberOfPoints()-1,segmentPoint1);
1448 this->SegmentTopology(bifurcations,bifurcationsRadii,segmentPoint0,segmentPoint1,firstPoint,firstRadius,lastPoint,lastRadius,segmentTopology);
1449 this->BuildSegment(segmentPoints,segmentRadii,segmentTopology,firstPoint,firstRadius,lastPoint,lastRadius,NULL,segment);
1450 segments->AddItem(segment);
1451 }
1452 }
1453 else if (stepIterationState == STEP_ITERATION_STOP_END)
1454 {
1455 if (segmentPoints->GetNumberOfPoints() >= 2)
1456 {
1457 double segmentPoint0[3], segmentPoint1[3];
1458 segmentPoints->GetPoint(0,segmentPoint0);
1459 segmentPoints->GetPoint(segmentPoints->GetNumberOfPoints()-1,segmentPoint1);
1460 this->SegmentTopology(bifurcations,bifurcationsRadii,segmentPoint0,segmentPoint1,firstPoint,firstRadius,lastPoint,lastRadius,segmentTopology);
1461 this->BuildSegment(segmentPoints,segmentRadii,segmentTopology,firstPoint,firstRadius,lastPoint,lastRadius,NULL,segment);
1462 segments->AddItem(segment);
1463 }
1464 }
1465 else if (stepIterationState == STEP_ITERATION_STOP_CLOSED)
1466 {
1467 if (segmentPoints->GetNumberOfPoints() >= 2)
1468 {
1469 double segmentPoint0[3];
1470 segmentPoints->GetPoint(0,segmentPoint0);
1471 this->SegmentTopology(bifurcations,bifurcationsRadii,segmentPoint0,NULL,firstPoint,firstRadius,lastPoint,lastRadius,segmentTopology);
1472 this->BuildSegment(segmentPoints,segmentRadii,segmentTopology,firstPoint,firstRadius,lastPoint,lastRadius,NULL,segment);
1473 segments->AddItem(segment);
1474 }
1475 }
1476 segment->Delete();
1477
1478 additionalSegments->InitTraversal();
1479 vtkIdType k;
1480 for (k=0; k<additionalSegments->GetNumberOfItems(); k++)
1481 {
1482 segments->AddItem(additionalSegments->GetNextItem());
1483 }
1484
1485 additionalSegments->Delete();
1486
1487 baseProfiles->Delete();
1488 baseProfilesEdgeTables->Delete();
1489 newProfiles->Delete();
1490 newProfilesEdgeTables->Delete();
1491 segmentPoints->Delete();
1492 segmentRadii->Delete();
1493 bifurcationPoints->Delete();
1494 bifurcationRadii->Delete();
1495}
void SegmentTopology(vtkCollection *bifurcations, vtkCollection *bifurcationsRadii, double firstSegmentPoint[3], double lastSegmentPoint[3], double firstPoint[3], double &firstRadius, double lastPoint[3], double &lastRadius, vtkIdType segmentTopology[2])
void InsertNewBifurcation(vtkCollection *bifurcations, vtkCollection *bifurcationsRadii, vtkPoints *bifurcationPoints, vtkDoubleArray *bifurcationRadii, vtkPolyDataCollection *additionalSegments)
vtkIdType StepIteration(vtkPolyData *model, vtkPolyDataCollection *baseProfiles, vtkCollection *baseProfilesEdgeTables, vtkPolyDataCollection *globalProfiles, vtkCollection *globalProfilesEdgeTables, vtkPolyDataCollection *newProfiles, vtkCollection *newProfilesEdgeTables, vtkPoints *segmentPoints, vtkDoubleArray *segmentRadii, vtkPoints *bifurcationPoints, vtkDoubleArray *bifurcationRadii, double oldCenter[3], double &oldRadius, double advancementRatio)
void MarkModelGlobalProfile(vtkPolyData *model, vtkIdTypeArray *newGlobalProfileEdgeTable)

◆ JoinSegments()

void vtkvmtkPolyDataNetworkExtraction::JoinSegments ( vtkPolyData * segment0,
vtkPolyData * segment1,
bool first0,
bool first1,
vtkPolyData * segment )
protected

Definition at line 1497 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1498{
1499 vtkPoints* segmentPoints = vtkPoints::New();
1500 vtkDoubleArray* radiusArray = vtkDoubleArray::New();
1501 radiusArray->SetName(RadiusArrayName);
1502 vtkIdTypeArray* topologyArray = vtkIdTypeArray::New();
1503 topologyArray->SetNumberOfComponents(2);
1504 topologyArray->SetName(TopologyArrayName);
1505
1506 vtkDoubleArray* segment0RadiusArray = vtkDoubleArray::SafeDownCast(segment0->GetPointData()->GetArray(RadiusArrayName));
1507 vtkDoubleArray* segment1RadiusArray = vtkDoubleArray::SafeDownCast(segment1->GetPointData()->GetArray(RadiusArrayName));
1508
1509 vtkIdTypeArray* segment0TopologyArray = vtkIdTypeArray::SafeDownCast(segment0->GetCellData()->GetArray(TopologyArrayName));
1510 vtkIdTypeArray* segment1TopologyArray = vtkIdTypeArray::SafeDownCast(segment1->GetCellData()->GetArray(TopologyArrayName));
1511
1512 vtkIdType segmentTopology0[2];
1513 vtkIdType segmentTopology1[2];
1514
1515 segment0TopologyArray->GetTypedTuple(0, segmentTopology0);
1516 segment1TopologyArray->GetTypedTuple(0, segmentTopology1);
1517
1518 vtkIdType segmentTopology[2];
1519
1520 vtkIdType i;
1521 if (first0)
1522 {
1523 segmentTopology[0] = segmentTopology0[1];
1524 for (i=segment0->GetNumberOfPoints()-1; i>=1; i--)
1525 {
1526 segmentPoints->InsertNextPoint(segment0->GetPoint(i));
1527 radiusArray->InsertNextValue(segment0RadiusArray->GetValue(i));
1528 }
1529 }
1530 else
1531 {
1532 segmentTopology[0] = segmentTopology0[0];
1533 for (i=0; i<segment0->GetNumberOfPoints()-1; i++)
1534 {
1535 segmentPoints->InsertNextPoint(segment0->GetPoint(i));
1536 radiusArray->InsertNextValue(segment0RadiusArray->GetValue(i));
1537 }
1538 }
1539
1540 if (first1)
1541 {
1542 segmentTopology[1] = segmentTopology1[1];
1543 for (i=1; i<segment1->GetNumberOfPoints(); i++)
1544 {
1545 segmentPoints->InsertNextPoint(segment1->GetPoint(i));
1546 radiusArray->InsertNextValue(segment1RadiusArray->GetValue(i));
1547 }
1548 }
1549 else
1550 {
1551 segmentTopology[1] = segmentTopology1[1];
1552 for (i=segment1->GetNumberOfPoints()-2; i>=0; i--)
1553 {
1554 segmentPoints->InsertNextPoint(segment1->GetPoint(i));
1555 radiusArray->InsertNextValue(segment1RadiusArray->GetValue(i));
1556 }
1557 }
1558
1559 topologyArray->InsertNextTypedTuple(segmentTopology);
1560
1561 vtkCellArray* segmentCell = vtkCellArray::New();
1562 segmentCell->InsertNextCell(segmentPoints->GetNumberOfPoints());
1563 for (i=0; i<segmentPoints->GetNumberOfPoints(); i++)
1564 {
1565 segmentCell->InsertCellPoint(i);
1566 }
1567
1568 segment->SetPoints(segmentPoints);
1569 segment->SetLines(segmentCell);
1570 segment->GetPointData()->AddArray(radiusArray);
1571 segment->GetCellData()->AddArray(topologyArray);
1572
1573 radiusArray->Delete();
1574 topologyArray->Delete();
1575 segmentPoints->Delete();
1576 segmentCell->Delete();
1577}

◆ RemoveDegenerateBifurcations()

void vtkvmtkPolyDataNetworkExtraction::RemoveDegenerateBifurcations ( vtkPolyDataCollection * segments,
vtkCollection * bifurcations )
protected

Definition at line 1579 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1580{
1581 vtkIdList* realBifurcations = vtkIdList::New();
1582 realBifurcations->InsertNextId(0);
1583 vtkIdList* degenerateBifurcations = vtkIdList::New();
1584 vtkIdTypeArray* bifurcationFrequency = vtkIdTypeArray::New();
1585 bifurcations->InitTraversal();
1586 vtkIdType i;
1587 for (i=0; i<bifurcations->GetNumberOfItems(); i++)
1588 {
1589 bifurcationFrequency->InsertNextValue(0);
1590 }
1591 segments->InitTraversal();
1592 for (i=0; i<segments->GetNumberOfItems(); i++)
1593 {
1594 vtkPolyData* segment = segments->GetNextItem();
1595// vtkDoubleArray* radiusArray = vtkDoubleArray::SafeDownCast(segment->GetPointData()->GetArray(RadiusArrayName));
1596 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(segment->GetCellData()->GetArray(TopologyArrayName));
1597 vtkIdType topology[2];
1598 topologyArray->GetTypedTuple(0, topology);
1599 vtkIdType bifurcation0 = topology[0];
1600 if (bifurcation0 > 0)
1601 {
1602 vtkIdType frequency0 = bifurcationFrequency->GetValue(bifurcation0);
1603 bifurcationFrequency->InsertValue(bifurcation0,frequency0+1);
1604 }
1605
1606 vtkIdType bifurcation1 = topology[1];
1607 if (bifurcation1 > 0)
1608 {
1609 vtkIdType frequency1 = bifurcationFrequency->GetValue(bifurcation1);
1610 bifurcationFrequency->InsertValue(bifurcation1,frequency1+1);
1611 }
1612 }
1613 for (i=0; i<bifurcationFrequency->GetNumberOfTuples(); i++)
1614 {
1615 if (i > 0)
1616 {
1617 if (bifurcationFrequency->GetValue(i) < 3)
1618 {
1619 degenerateBifurcations->InsertNextId(i);
1620 }
1621 else
1622 {
1623 realBifurcations->InsertNextId(i);
1624 }
1625 }
1626 }
1627
1628// vtkIdType n = degenerateBifurcations->GetNumberOfIds();
1629 while (degenerateBifurcations->GetNumberOfIds() > 0)
1630 {
1631 segments->InitTraversal();
1632 vtkPolyData* segment0 = NULL,* segment1 = NULL,* currentSegment;
1633 vtkIdType degenerateId = -1;
1634 bool first0, first1;
1635 first0 = first1 = false;
1636 for (i=0; i<segments->GetNumberOfItems(); i++)
1637 {
1638 currentSegment = segments->GetNextItem();
1639// vtkDoubleArray* radiusArray = vtkDoubleArray::SafeDownCast(currentSegment->GetPointData()->GetArray(RadiusArrayName));
1640 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(currentSegment->GetCellData()->GetArray(TopologyArrayName));
1641 vtkIdType topology[2];
1642 topologyArray->GetTypedTuple(0,topology);
1643 if (!segment0)
1644 {
1645 degenerateId = topology[0];
1646 if (degenerateBifurcations->IsId(degenerateId) != -1)
1647 {
1648 segment0 = currentSegment;
1649 first0 = true;
1650 degenerateBifurcations->DeleteId(degenerateId);
1651 }
1652 if (!segment0)
1653 {
1654 degenerateId = topology[1];
1655 if (degenerateBifurcations->IsId(degenerateId) != -1)
1656 {
1657 segment0 = currentSegment;
1658 first0 = false;
1659 degenerateBifurcations->DeleteId(degenerateId);
1660 }
1661 }
1662 }
1663 else if (!segment1)
1664 {
1665 if (topology[0] == degenerateId)
1666 {
1667 segment1 = currentSegment;
1668 first1 = true;
1669 }
1670 if (topology[1] == degenerateId)
1671 {
1672 segment1 = currentSegment;
1673 first1 = false;
1674 }
1675 }
1676 }
1677 if (segment0 && segment1)
1678 {
1679 segment0->Register((vtkObjectBase*)NULL);
1680 segment1->Register((vtkObjectBase*)NULL);
1681 segments->RemoveItem(segment0);
1682 segments->RemoveItem(segment1);
1683 vtkPolyData* joinedSegment = vtkPolyData::New();
1684 this->JoinSegments(segment0,segment1,first0,first1,joinedSegment);
1685 segments->AddItem(joinedSegment);
1686 joinedSegment->Delete();
1687 segment0->UnRegister((vtkObjectBase*)NULL);
1688 segment1->UnRegister((vtkObjectBase*)NULL);
1689 }
1690 }
1691
1692 // rename bifurcations
1693 segments->InitTraversal();
1694 vtkIdType scalar0, scalar1, position0, position1;
1695 for (i=0; i<segments->GetNumberOfItems(); i++)
1696 {
1697 vtkPolyData* currentSegment = segments->GetNextItem();
1698// vtkDoubleArray* radiusArray = vtkDoubleArray::SafeDownCast(currentSegment->GetPointData()->GetArray(RadiusArrayName));
1699 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(currentSegment->GetCellData()->GetArray(TopologyArrayName));
1700 vtkIdType topology[2];
1701 topologyArray->GetTypedTuple(0, topology);
1702 scalar0 = topology[0];
1703 scalar1 = topology[1];
1704 if (scalar0 > 0)
1705 {
1706 position0 = realBifurcations->InsertUniqueId(scalar0);
1707 topology[0] = position0;
1708 }
1709 if (scalar1>0)
1710 {
1711 position1=realBifurcations->InsertUniqueId(scalar1);
1712 topology[1] = position1;
1713 }
1714 topologyArray->InsertTypedTuple(0,topology);
1715 }
1716
1717 realBifurcations->Delete();
1718 degenerateBifurcations->Delete();
1719 bifurcationFrequency->Delete();
1720}
void JoinSegments(vtkPolyData *segment0, vtkPolyData *segment1, bool first0, bool first1, vtkPolyData *segment)

◆ GlobalIteration()

void vtkvmtkPolyDataNetworkExtraction::GlobalIteration ( vtkPolyData * model,
vtkPolyDataCollection * globalProfiles,
vtkPolyData * network,
double advancementRatio )
protected

Definition at line 1723 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1724{
1725 vtkCollection* globalProfilesEdgeTables = vtkCollection::New();
1726 this->UpdateEdgeTableCollectionReal(model,globalProfiles,globalProfilesEdgeTables);
1727
1728 vtkCollection* bifurcations = vtkCollection::New();
1729 vtkCollection* bifurcationsRadii = vtkCollection::New();
1730 vtkPolyDataCollection* segments = vtkPolyDataCollection::New();
1731
1732 vtkPoints* globalBoundaryBarycenters = vtkPoints::New();
1733 vtkDoubleArray* globalBoundaryRadii = vtkDoubleArray::New();
1734 vtkPolyData* profile;
1735 vtkIdType i;
1736 globalProfiles->InitTraversal();
1737 for (i=0; i<globalProfiles->GetNumberOfItems(); i++)
1738 {
1739 profile=globalProfiles->GetNextItem();
1740 double barycenter[3];
1741 this->ProfileBarycenter(profile->GetPoints(),barycenter);
1742 globalBoundaryBarycenters->InsertNextPoint(barycenter);
1743 globalBoundaryRadii->InsertNextValue(ComputeMeanRadius(profile->GetPoints(),barycenter));
1744 }
1745
1746 bifurcations->AddItem(globalBoundaryBarycenters);
1747 bifurcationsRadii->AddItem(globalBoundaryRadii);
1748
1749 while (globalProfiles->GetNumberOfItems())
1750 {
1751 globalProfiles->InitTraversal();
1752 vtkPolyData* initialProfile = globalProfiles->GetNextItem();
1753 initialProfile->Register((vtkObjectBase*)NULL);
1754 globalProfiles->RemoveItem(initialProfile);
1755
1756 globalProfilesEdgeTables->InitTraversal();
1757 vtkIdTypeArray* initialProfileEdgeTable = (vtkIdTypeArray*)globalProfilesEdgeTables->GetNextItemAsObject();
1758 initialProfileEdgeTable->Register((vtkObjectBase*)NULL);
1759 globalProfilesEdgeTables->RemoveItem(initialProfileEdgeTable);
1760
1761 this->SegmentIteration(model,initialProfile,initialProfileEdgeTable,globalProfiles,globalProfilesEdgeTables,bifurcations,bifurcationsRadii,segments,advancementRatio);
1762
1763 double progress = (double)this->TotalMarkedPoints/(double)model->GetNumberOfPoints();
1764 this->InvokeEvent(vtkCommand::ProgressEvent,&progress);
1765
1766 initialProfile->UnRegister((vtkObjectBase*)NULL);
1767 initialProfileEdgeTable->UnRegister((vtkObjectBase*)NULL);
1768 }
1769
1770 this->RemoveDegenerateBifurcations(segments,bifurcations);
1771
1772 vtkIdTypeArray* topologyArray = vtkIdTypeArray::New();
1773 topologyArray->SetName(TopologyArrayName);
1774 topologyArray->SetNumberOfComponents(2);
1775
1776 segments->InitTraversal();
1777 for (i=0; i<segments->GetNumberOfItems(); i++)
1778 {
1779 vtkIdType topology[2];
1780 vtkIdTypeArray* segmentTopologyArray = vtkIdTypeArray::SafeDownCast(segments->GetNextItem()->GetCellData()->GetArray(TopologyArrayName));
1781 segmentTopologyArray->GetTypedTuple(0, topology);
1782 topologyArray->InsertNextTypedTuple(topology);
1783 }
1784
1785 vtkAppendPolyData* segmentsAppended = vtkAppendPolyData::New();
1786 segments->InitTraversal();
1787 for (i=0; i<segments->GetNumberOfItems(); i++)
1788 {
1789 segmentsAppended->AddInputData(segments->GetNextItem());
1790 }
1791 segmentsAppended->Update();
1792
1793 network->DeepCopy(segmentsAppended->GetOutput());
1794 network->GetCellData()->AddArray(topologyArray);
1795
1796 globalProfilesEdgeTables->Delete();
1797 bifurcations->Delete();
1798 bifurcationsRadii->Delete();
1799 segments->Delete();
1800 globalBoundaryBarycenters->Delete();
1801 globalBoundaryRadii->Delete();
1802 segmentsAppended->Delete();
1803 topologyArray->Delete();
1804}
void SegmentIteration(vtkPolyData *model, vtkPolyData *initialProfile, vtkIdTypeArray *initialProfileEdgeTable, vtkPolyDataCollection *globalProfiles, vtkCollection *globalProfilesEdgeTables, vtkCollection *bifurcations, vtkCollection *bifurcationsRadii, vtkPolyDataCollection *segments, double advancementRatio)
void RemoveDegenerateBifurcations(vtkPolyDataCollection *segments, vtkCollection *bifurcations)
void UpdateEdgeTableCollectionReal(vtkPolyData *model, vtkPolyDataCollection *profiles, vtkCollection *edgeTables)

◆ MarkModelRealBoundary()

void vtkvmtkPolyDataNetworkExtraction::MarkModelRealBoundary ( vtkPolyData * model,
vtkPolyData * modelBoundary )
protected

Definition at line 1806 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1807{
1808 vtkIdTypeArray* marksArray = vtkIdTypeArray::SafeDownCast(model->GetPointData()->GetArray(MarksArrayName));
1809 vtkIdType i;
1810 for (i=0; i<model->GetNumberOfPoints(); i++)
1811 {
1812 marksArray->InsertValue(i,NON_VISITED);
1813 }
1814 for (i=0; i<modelBoundary->GetNumberOfPoints(); i++)
1815 {
1816 marksArray->InsertValue(model->FindPoint(modelBoundary->GetPoint(i)),GLOBAL);
1817 }
1818}

◆ Graph()

void vtkvmtkPolyDataNetworkExtraction::Graph ( vtkPolyData * network,
vtkPolyData * graphLayout )
protected

Definition at line 1820 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1821{
1822 vtkPoints* graphPoints = vtkPoints::New();
1823 vtkCellArray* graphLines = vtkCellArray::New();
1824 vtkDoubleArray* graphRadiusArray = vtkDoubleArray::New();
1825 graphRadiusArray->SetName(this->RadiusArrayName);
1826
1827 graphLayout->SetPoints(graphPoints);
1828 graphLayout->SetLines(graphLines);
1829 graphLayout->GetCellData()->AddArray(graphRadiusArray);
1830
1831 vtkIdType numberOfPoints = network->GetNumberOfPoints();
1832 vtkIdType numberOfCells = network->GetNumberOfCells();
1833
1834 vtkIdTypeArray* isPointInserted = vtkIdTypeArray::New();
1835 isPointInserted->SetNumberOfTuples(numberOfPoints);
1836 isPointInserted->FillComponent(0,-1);
1837
1838 vtkDoubleArray* radiusArray = vtkDoubleArray::SafeDownCast(network->GetPointData()->GetArray(this->RadiusArrayName));
1839 vtkIdTypeArray* topologyArray = vtkIdTypeArray::SafeDownCast(network->GetCellData()->GetArray(this->TopologyArrayName));
1840
1841 for (int i=0; i<numberOfCells; i++)
1842 {
1843 vtkCell* cell = network->GetCell(i);
1844 vtkIdType topology[2];
1845 topologyArray->GetTypedTuple(i, topology);
1846
1847 vtkIdType numberOfCellPoints = cell->GetNumberOfPoints();
1848 double meanRadius = 0.0;
1849 for (int j=0; j<numberOfCellPoints; j++)
1850 {
1851 double radius = radiusArray->GetValue(cell->GetPointId(j));
1852 meanRadius += radius;
1853 }
1854 meanRadius /= numberOfCellPoints;
1855 vtkIdType pointId0 = cell->GetPointId(0);
1856 vtkIdType pointId1 = cell->GetPointId(numberOfCellPoints-1);
1857 vtkIdType newPointId0 = -1;
1858 vtkIdType newPointId1 = -1;
1859 if (isPointInserted->GetValue(pointId0) == -1)
1860 {
1861 newPointId0 = graphPoints->InsertNextPoint(network->GetPoint(pointId0));
1862 isPointInserted->SetValue(pointId0,newPointId0);
1863 }
1864 else
1865 {
1866 newPointId0 = isPointInserted->GetValue(pointId0);
1867 }
1868 if (isPointInserted->GetValue(pointId1) == -1)
1869 {
1870 newPointId1 = graphPoints->InsertNextPoint(network->GetPoint(pointId1));
1871 isPointInserted->SetValue(pointId1,newPointId1);
1872 }
1873 else
1874 {
1875 newPointId1 = isPointInserted->GetValue(pointId1);
1876 }
1877 graphLines->InsertNextCell(2);
1878 graphLines->InsertCellPoint(newPointId0);
1879 graphLines->InsertCellPoint(newPointId1);
1880 graphRadiusArray->InsertNextValue(meanRadius);
1881 }
1882
1883 graphPoints->Delete();
1884 graphLines->Delete();
1885 graphRadiusArray->Delete();
1886 isPointInserted->Delete();
1887}

◆ RequestData()

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

Definition at line 1889 of file vtkvmtkPolyDataNetworkExtraction.cxx.

1890{
1891 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
1892 vtkInformation *outInfo = outputVector->GetInformationObject(0);
1893
1894 vtkPolyData *input = vtkPolyData::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
1895 vtkPolyData *output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
1896
1897 this->TotalMarkedPoints = 0;
1898
1899 vtkPolyData* model = vtkPolyData::New();
1900 model->DeepCopy(input);
1901
1902 vtkIdTypeArray* marksArray = vtkIdTypeArray::New();
1903 marksArray->SetName(this->MarksArrayName);
1904 marksArray->SetNumberOfTuples(model->GetNumberOfPoints());
1905 model->GetPointData()->AddArray(marksArray);
1906
1907 vtkPolyData* modelBoundary = vtkPolyData::New();
1908 this->BoundaryExtractor(model,modelBoundary);
1909
1910 vtkPolyData* network = vtkPolyData::New();
1911
1912 if (modelBoundary->GetNumberOfPoints() > 0)
1913 {
1914 this->MarkModelRealBoundary(model,modelBoundary);
1915
1916 model->BuildCells();
1917 model->BuildLinks();
1918
1919 vtkPolyDataCollection* globalProfiles = vtkPolyDataCollection::New();
1920 this->BoundarySeparator(modelBoundary,globalProfiles);
1921
1922 this->GlobalIteration(model,globalProfiles,network,this->AdvancementRatio);
1923 globalProfiles->Delete();
1924 }
1925
1926 marksArray->Delete();
1927 modelBoundary->Delete();
1928 model->Delete();
1929
1930 double progress = 1.0;
1931 this->InvokeEvent(vtkCommand::ProgressEvent,&progress);
1932
1933 output->DeepCopy(network);
1934
1935 if (this->GraphLayout)
1936 {
1937 this->GraphLayout->Delete();
1938 this->GraphLayout = NULL;
1939 }
1940
1941 this->GraphLayout = vtkPolyData::New();
1942 this->Graph(network,this->GraphLayout);
1943
1944 network->Delete();
1945
1946 return 1;
1947}
void GlobalIteration(vtkPolyData *model, vtkPolyDataCollection *globalProfiles, vtkPolyData *network, double advancementRatio)
void BoundaryExtractor(vtkPolyData *polyInput, vtkPolyData *boundary)
void Graph(vtkPolyData *network, vtkPolyData *graphLayout)
void BoundarySeparator(vtkPolyData *appendedBoundaries, vtkPolyDataCollection *boundaries)
void MarkModelRealBoundary(vtkPolyData *model, vtkPolyData *modelBoundary)

Member Data Documentation

◆ GraphLayout

vtkPolyData* vtkvmtkPolyDataNetworkExtraction::GraphLayout
protected

Definition at line 180 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ MarksArrayName

char* vtkvmtkPolyDataNetworkExtraction::MarksArrayName
protected

Definition at line 182 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ RadiusArrayName

char* vtkvmtkPolyDataNetworkExtraction::RadiusArrayName
protected

Definition at line 183 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ TopologyArrayName

char* vtkvmtkPolyDataNetworkExtraction::TopologyArrayName
protected

Definition at line 184 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ MinimumStep

double vtkvmtkPolyDataNetworkExtraction::MinimumStep
protected

Definition at line 186 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ AdvancementRatio

double vtkvmtkPolyDataNetworkExtraction::AdvancementRatio
protected

Definition at line 188 of file vtkvmtkPolyDataNetworkExtraction.h.

◆ TotalMarkedPoints

vtkIdType vtkvmtkPolyDataNetworkExtraction::TotalMarkedPoints
protected

Definition at line 190 of file vtkvmtkPolyDataNetworkExtraction.h.


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