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

Trace the steepest descent line over a polygonal non-manifold. More...

#include <vtkvmtkSteepestDescentLineTracer.h>

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

Public Types

typedef vtkvmtkNonManifoldSteepestDescent Superclass
Public Types inherited from vtkvmtkNonManifoldSteepestDescent
typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkSteepestDescentLineTracer * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetSeeds (vtkIdList *)
virtual vtkIdList * GetSeeds ()
virtual void SetTargets (vtkIdList *)
virtual vtkIdList * GetTargets ()
virtual vtkIdList * GetHitTargets ()
virtual void SetStopOnTargets (int)
virtual int GetStopOnTargets ()
virtual void StopOnTargetsOn ()
virtual void StopOnTargetsOff ()
virtual void SetDataArrayName (const char *)
virtual char * GetDataArrayName ()
virtual void SetEdgeArrayName (const char *)
virtual char * GetEdgeArrayName ()
virtual void SetEdgePCoordArrayName (const char *)
virtual char * GetEdgePCoordArrayName ()
virtual void SetMergePaths (int)
virtual int GetMergePaths ()
virtual void MergePathsOn ()
virtual void MergePathsOff ()
virtual void SetMergeTolerance (double)
virtual double GetMergeTolerance ()
Public Member Functions inherited from vtkvmtkNonManifoldSteepestDescent
vtkvmtkNonManifoldSteepestDescent * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetDescentArrayName (const char *)
virtual char * GetDescentArrayName ()
virtual void SetDirection (int)
virtual int GetDirection ()
void SetDirectionToDownward ()
void SetDirectionToUpward ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkSteepestDescentLineTracer * SafeDownCast (vtkObjectBase *o)
static vtkvmtkSteepestDescentLineTracer * New ()
Static Public Member Functions inherited from vtkvmtkNonManifoldSteepestDescent
static int IsTypeOf (const char *type)
static vtkvmtkNonManifoldSteepestDescent * SafeDownCast (vtkObjectBase *o)
static vtkvmtkNonManifoldSteepestDescent * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkSteepestDescentLineTracer ()
 ~vtkvmtkSteepestDescentLineTracer ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
void Backtrace (vtkPolyData *input, vtkIdType seedId)
Protected Member Functions inherited from vtkvmtkNonManifoldSteepestDescent
 vtkvmtkNonManifoldSteepestDescent ()
 ~vtkvmtkNonManifoldSteepestDescent ()
double GetSteepestDescent (vtkPolyData *input, vtkIdType *edge, double s, vtkIdType *steepestDescentEdge, double &steepestDescentS)
double GetSteepestDescentInCell (vtkPolyData *input, vtkIdType cellId, vtkIdType *edge, double s, vtkIdType *steepestDescentEdge, double &steepestDescentS, double &steepestDescentLength)

Protected Attributes

vtkIdList * Seeds
vtkIdList * Targets
vtkIdList * HitTargets
int StopOnTargets
char * DataArrayName
char * EdgeArrayName
char * EdgePCoordArrayName
char * MinDistanceArrayName
int MergePaths
double MergeTolerance
vtkIntArray * Edges
vtkDoubleArray * EdgeParCoords
vtkIdList * EdgePointIds
vtkIntArray * CellIdsArray
vtkDoubleArray * PCoordsArray
vtkDoubleArray * MinDistanceArray
vtkDataArray * LineDataArray
int MergeWithExistingPaths
vtkPolyData * ExistingPaths
char * ExistingPathsEdgeArrayName
char * ExistingPathsEdgePCoordArrayName
vtkIntArray * ExistingPathsEdges
vtkDoubleArray * ExistingPathsEdgeParCoords
Protected Attributes inherited from vtkvmtkNonManifoldSteepestDescent
vtkDataArray * DescentArray
char * DescentArrayName
int NumberOfEdgeSubdivisions
int Direction

Detailed Description

Trace the steepest descent line over a polygonal non-manifold.

This class takes in input a non-manifold surface made of convex polygons (such as a Voronoi diagram) on which a scalar field is defined (as a point data array) and produces steepest descent paths from an id list of seeds to a target, basically solving the ordinary differential equation

\[\frac{d\gamma(\tau)}{d\tau}=-\nabla T(\mathbf{x})\]

where \(\gamma(\tau)\) is a path and T(x) is a scalar field defined over the polygonal non-manifold domain.

The class uses the members of its base class vtkNonManifoldSteepestDescent to compute the steepest descent point at each step. The computed paths are polylines whose points always lie on input polygon edges.

This class is meant to be used for backtracing centerlines after solving the Eikonal equation on the Voronoi diagram of a shape (by means of vtkNonManifoldFastMarching). If MergePaths is off, one polyline for each seed point is produced (the cell id of each polyline corresponds to the list id of input seeds). If MergePaths is on, polylines are merged if they intersect the same Voronoi diagram edge and their distance is below a user-defined tolerance. Actually, if a path visits an edge which has already been visited by a previous path, its endpoint is set to the previous path point, so that a T junction is produced.

The user can specify a point data array whose values are interpolated on path points and presented in output as point data.

If 1) EdgeArrayName and/or 2) EdgePCoordArrayName are provided, the output will contain 1) a 2-component vtkIntArray in which the point ids of the edges intersected by the paths are stored and 2) a 1-component vtkDoubleArray in which the parametric coordinate of the intersection is stored.

See also
vtkNonManifoldFastMarching vtkVoronoiDiagram3D

Definition at line 50 of file vtkvmtkSteepestDescentLineTracer.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkSteepestDescentLineTracer()

vtkvmtkSteepestDescentLineTracer::vtkvmtkSteepestDescentLineTracer ( )
protected

Definition at line 37 of file vtkvmtkSteepestDescentLineTracer.cxx.

38{
39 this->Seeds = NULL;
40 this->Targets = NULL;
41 this->StopOnTargets = 0;
42 this->DataArrayName = NULL;
43 this->EdgeArrayName = NULL;
44 this->EdgePCoordArrayName = NULL;
45
46 this->MergePaths = 0;
48
49 this->LineDataArray = NULL;
50
51 this->HitTargets = vtkIdList::New();
52}
#define VTK_VMTK_DOUBLE_TOL

◆ ~vtkvmtkSteepestDescentLineTracer()

vtkvmtkSteepestDescentLineTracer::~vtkvmtkSteepestDescentLineTracer ( )
protected

Definition at line 54 of file vtkvmtkSteepestDescentLineTracer.cxx.

55{
56 this->HitTargets->Delete();
57
58 if (this->Seeds)
59 {
60 this->Seeds->Delete();
61 this->Seeds = NULL;
62 }
63
64 if (this->Targets)
65 {
66 this->Targets->Delete();
67 this->Targets = NULL;
68 }
69
70 if (this->EdgePCoordArrayName)
71 {
72 delete [] this->EdgePCoordArrayName;
73 this->EdgePCoordArrayName = NULL;
74 }
75
76 if (this->EdgeArrayName)
77 {
78 delete [] this->EdgeArrayName;
79 this->EdgeArrayName = NULL;
80 }
81
82 if (this->DescentArrayName)
83 {
84 delete[] this->DescentArrayName;
85 this->DescentArrayName = NULL;
86 }
87
88 if (this->DataArrayName)
89 {
90 delete[] this->DataArrayName;
91 this->DataArrayName = NULL;
92 }
93
94}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

Reimplemented from vtkvmtkNonManifoldSteepestDescent.

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkSteepestDescentLineTracer::NewInstanceInternal ( ) const
protectedvirtual

Reimplemented from vtkvmtkNonManifoldSteepestDescent.

◆ NewInstance()

vtkvmtkSteepestDescentLineTracer * vtkvmtkSteepestDescentLineTracer::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 472 of file vtkvmtkSteepestDescentLineTracer.cxx.

473{
474 this->Superclass::PrintSelf(os,indent);
475}
void PrintSelf(std::ostream &os, vtkIndent indent) override

◆ New()

vtkvmtkSteepestDescentLineTracer * vtkvmtkSteepestDescentLineTracer::New ( )
static

◆ SetSeeds()

virtual void vtkvmtkSteepestDescentLineTracer::SetSeeds ( vtkIdList * )
virtual

Set/Get the id of the seeds from which steepest descent starts.

◆ GetSeeds()

virtual vtkIdList * vtkvmtkSteepestDescentLineTracer::GetSeeds ( )
virtual

Set/Get the id of the seeds from which steepest descent starts.

◆ SetTargets()

virtual void vtkvmtkSteepestDescentLineTracer::SetTargets ( vtkIdList * )
virtual

Set/Get the id of the point on which steepest descent must terminate.

◆ GetTargets()

virtual vtkIdList * vtkvmtkSteepestDescentLineTracer::GetTargets ( )
virtual

Set/Get the id of the point on which steepest descent must terminate.

◆ GetHitTargets()

virtual vtkIdList * vtkvmtkSteepestDescentLineTracer::GetHitTargets ( )
virtual

Set/Get the id of the point on which steepest descent has terminated for each seed point.

◆ SetStopOnTargets()

virtual void vtkvmtkSteepestDescentLineTracer::SetStopOnTargets ( int )
virtual

Toggle stopping the backtrace of each path as soon as it reaches one of the points in Targets (on), instead of always following the steepest descent to a local minimum of DataArrayName (off). Default: off.

◆ GetStopOnTargets()

virtual int vtkvmtkSteepestDescentLineTracer::GetStopOnTargets ( )
virtual

Toggle stopping the backtrace of each path as soon as it reaches one of the points in Targets (on), instead of always following the steepest descent to a local minimum of DataArrayName (off). Default: off.

◆ StopOnTargetsOn()

virtual void vtkvmtkSteepestDescentLineTracer::StopOnTargetsOn ( )
virtual

Toggle stopping the backtrace of each path as soon as it reaches one of the points in Targets (on), instead of always following the steepest descent to a local minimum of DataArrayName (off). Default: off.

◆ StopOnTargetsOff()

virtual void vtkvmtkSteepestDescentLineTracer::StopOnTargetsOff ( )
virtual

Toggle stopping the backtrace of each path as soon as it reaches one of the points in Targets (on), instead of always following the steepest descent to a local minimum of DataArrayName (off). Default: off.

◆ SetDataArrayName()

virtual void vtkvmtkSteepestDescentLineTracer::SetDataArrayName ( const char * )
virtual

Set/Get the name of the point data array from which path point data is generated.

◆ GetDataArrayName()

virtual char * vtkvmtkSteepestDescentLineTracer::GetDataArrayName ( )
virtual

Set/Get the name of the point data array from which path point data is generated.

◆ SetEdgeArrayName()

virtual void vtkvmtkSteepestDescentLineTracer::SetEdgeArrayName ( const char * )
virtual

Set/Get the name of output point data array where the point ids of the edges intersected by the paths are going to be stored. Commonly named "EdgeArray".

◆ GetEdgeArrayName()

virtual char * vtkvmtkSteepestDescentLineTracer::GetEdgeArrayName ( )
virtual

Set/Get the name of output point data array where the point ids of the edges intersected by the paths are going to be stored. Commonly named "EdgeArray".

◆ SetEdgePCoordArrayName()

virtual void vtkvmtkSteepestDescentLineTracer::SetEdgePCoordArrayName ( const char * )
virtual

Set/Get the name of output point data array where the parametric coordinate of the intersection point with input edges are going to be stored. Commonly named "EdgePCoordArray".

◆ GetEdgePCoordArrayName()

virtual char * vtkvmtkSteepestDescentLineTracer::GetEdgePCoordArrayName ( )
virtual

Set/Get the name of output point data array where the parametric coordinate of the intersection point with input edges are going to be stored. Commonly named "EdgePCoordArray".

◆ SetMergePaths()

virtual void vtkvmtkSteepestDescentLineTracer::SetMergePaths ( int )
virtual

Turn on/off merging paths if they intersect the same Voronoi edge. Paths are merged with T junctions in the same order as defined in the seed list.

◆ GetMergePaths()

virtual int vtkvmtkSteepestDescentLineTracer::GetMergePaths ( )
virtual

Turn on/off merging paths if they intersect the same Voronoi edge. Paths are merged with T junctions in the same order as defined in the seed list.

◆ MergePathsOn()

virtual void vtkvmtkSteepestDescentLineTracer::MergePathsOn ( )
virtual

Turn on/off merging paths if they intersect the same Voronoi edge. Paths are merged with T junctions in the same order as defined in the seed list.

◆ MergePathsOff()

virtual void vtkvmtkSteepestDescentLineTracer::MergePathsOff ( )
virtual

Turn on/off merging paths if they intersect the same Voronoi edge. Paths are merged with T junctions in the same order as defined in the seed list.

◆ SetMergeTolerance()

virtual void vtkvmtkSteepestDescentLineTracer::SetMergeTolerance ( double )
virtual

Set/Get the (absolute) tolerance with which two points intersecting the same Voronoi diagram edge are considered coincident. If set to a large value, two paths are merged if they intersect the same Voronoi diagram edge (default behaviour).

◆ GetMergeTolerance()

virtual double vtkvmtkSteepestDescentLineTracer::GetMergeTolerance ( )
virtual

Set/Get the (absolute) tolerance with which two points intersecting the same Voronoi diagram edge are considered coincident. If set to a large value, two paths are merged if they intersect the same Voronoi diagram edge (default behaviour).

◆ RequestData()

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

Reimplemented from vtkvmtkNonManifoldSteepestDescent.

Definition at line 327 of file vtkvmtkSteepestDescentLineTracer.cxx.

331{
332 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
333 vtkInformation *outInfo = outputVector->GetInformationObject(0);
334
335 vtkPolyData *input = vtkPolyData::SafeDownCast(
336 inInfo->Get(vtkDataObject::DATA_OBJECT()));
337 vtkPolyData *output = vtkPolyData::SafeDownCast(
338 outInfo->Get(vtkDataObject::DATA_OBJECT()));
339
340 vtkIdType i;
341 vtkPoints* newPoints;
342 vtkCellArray* newLines;
343 vtkDoubleArray* newScalars;
344
345 if (!this->DescentArrayName)
346 {
347 vtkErrorMacro("Descent array name not specified.");
348 return 1;
349 }
350
351 if (!input->GetPointData()->GetArray(this->DescentArrayName))
352 {
353 vtkErrorMacro(<< "Descent array with name specified does not exist!");
354 return 1;
355 }
356
357 if (!this->Seeds)
358 {
359 vtkErrorMacro("No Seeds set");
360 return 1;
361 }
362
363 if (!this->Seeds->GetNumberOfIds())
364 {
365 vtkErrorMacro("Empty Seeds list");
366 return 1;
367 }
368
369 for (i=0; i<this->Seeds->GetNumberOfIds(); i++)
370 {
371 if ((this->Seeds->GetId(i)<0) || (this->Seeds->GetId(i)>input->GetNumberOfPoints()))
372 {
373 vtkErrorMacro("Seed id invalid or exceeds input number of points.");
374 return 1;
375 }
376 }
377
378 if (this->StopOnTargets)
379 {
380 for (i=0; i<this->Targets->GetNumberOfIds(); i++)
381 {
382 if ((this->Targets->GetId(i)<0) || (this->Targets->GetId(i) > input->GetNumberOfPoints()))
383 {
384 vtkErrorMacro("Invalid target id.");
385 return 1;
386 }
387 }
388 }
389
390 this->DescentArray = input->GetPointData()->GetArray(this->DescentArrayName);
391
392 if (this->DataArrayName)
393 {
394 this->LineDataArray = input->GetPointData()->GetArray(this->DataArrayName);
395 if (!this->LineDataArray)
396 {
397 vtkErrorMacro(<< "Line data array with name specified does not exist!");
398 return 1;
399 }
400 }
401 else
402 {
403 this->SetDataArrayName("Data Array");
404 this->LineDataArray = this->DescentArray;
405 }
406
407 this->Edges = vtkIntArray::New();
408 this->EdgeParCoords = vtkDoubleArray::New();
409 this->CellIdsArray = vtkIntArray::New();
410 this->PCoordsArray = vtkDoubleArray::New();
411
412 this->Edges->SetNumberOfComponents(2);
413 this->CellIdsArray->SetNumberOfComponents(2);
414
415 if (this->EdgeArrayName)
416 {
417 this->Edges->SetName(this->EdgeArrayName);
418 }
419 else
420 {
421 this->Edges->SetName("Edges");
422 }
423
424 if (this->EdgePCoordArrayName)
425 {
426 this->EdgeParCoords->SetName(this->EdgePCoordArrayName);
427 }
428 else
429 {
430 this->EdgeParCoords->SetName("EdgePCoords");
431 }
432
433 newPoints = vtkPoints::New();
434 newLines = vtkCellArray::New();
435 newScalars = vtkDoubleArray::New();
436 newScalars->SetName(this->DataArrayName);
437
439 {
441 }
442
443 output->SetPoints(newPoints);
444 output->SetLines(newLines);
445 output->GetPointData()->AddArray(newScalars);
446
447 newPoints->Delete();
448 newLines->Delete();
449 newScalars->Delete();
450
451 input->BuildCells();
452 input->BuildLinks();
453
454 this->HitTargets->Initialize();
455
456 for (i=0; i<this->Seeds->GetNumberOfIds(); i++)
457 {
458 this->Backtrace(input,this->Seeds->GetId(i));
459 }
460
461 output->GetPointData()->AddArray(this->Edges);
462 output->GetPointData()->AddArray(this->EdgeParCoords);
463
464 this->Edges->Delete();
465 this->EdgeParCoords->Delete();
466 this->CellIdsArray->Delete();
467 this->PCoordsArray->Delete();
468
469 return 1;
470}
virtual void SetDataArrayName(const char *)
void Backtrace(vtkPolyData *input, vtkIdType seedId)

◆ Backtrace()

void vtkvmtkSteepestDescentLineTracer::Backtrace ( vtkPolyData * input,
vtkIdType seedId )
protected

Definition at line 96 of file vtkvmtkSteepestDescentLineTracer.cxx.

97{
98 bool done;
99 double startingPoint[3], endingPoint[3], currentPoint[3], currentScalar;
100 double currentS;
101 double currentRadius;
102 vtkIdType currentEdge[2], steepestDescentEdge[2], previousEdge[2], previousEdge2[2];
103 double steepestDescentS, steepestDescent;
104 double previousS, previousS2;
105 double previousPoint[3];
106 double directionFactor;
107 vtkIdList* neighborCells;
108 vtkIdType pointId, j, targetId;
109 vtkIdList* lineIds;
110
111 vtkPoints* newPoints;
112 vtkDataArray* newScalars;
113 vtkCellArray* newLines;
114
115 newPoints = this->GetOutput()->GetPoints();
116 newScalars = this->GetOutput()->GetPointData()->GetArray(this->DataArrayName);
117 newLines = this->GetOutput()->GetLines();
118
119 neighborCells = vtkIdList::New();
120 lineIds = vtkIdList::New();
121
122 directionFactor = 0.0;
123 if (this->Direction==VTK_VMTK_DOWNWARD)
124 {
125 directionFactor = 1.0;
126 }
127 else if (this->Direction==VTK_VMTK_UPWARD)
128 {
129 directionFactor = - 1.0;
130 }
131
132 done = false;
133
134 input->GetPoint(seedId,startingPoint);
135
136 currentPoint[0] = startingPoint[0];
137 currentPoint[1] = startingPoint[1];
138 currentPoint[2] = startingPoint[2];
139
140 pointId = newPoints->InsertNextPoint(startingPoint);
141
142 currentScalar = this->DescentArray->GetTuple1(seedId);
143 currentRadius = this->LineDataArray->GetTuple1(seedId);
144 lineIds->InsertNextId(pointId);
145
146 currentEdge[0] = seedId;
147 currentEdge[1] = seedId;
148 currentS = 0.0;
149
150 previousS = 0.0;
151 previousS2 = 0.0;
152
153 newScalars->InsertComponent(pointId,0,currentRadius);
154 this->Edges->InsertComponent(pointId,0,currentEdge[0]);
155 this->Edges->InsertComponent(pointId,1,currentEdge[1]);
156 this->EdgeParCoords->InsertValue(pointId,currentS);
157
158 std::size_t numIterations = 0;
159
160 previousEdge[0] = currentEdge[0];
161 previousEdge[1] = currentEdge[1];
162
163 previousEdge2[0] = -1;
164 previousEdge2[1] = -1;
165
166 while (!done)
167 {
168 if ((this->StopOnTargets) && ((this->Targets->IsId(currentEdge[0]) != -1) || (this->Targets->IsId(currentEdge[1]) != -1)))
169 {
170 if (this->Targets->IsId(currentEdge[0]) != -1)
171 {
172 targetId = currentEdge[0];
173 }
174 else
175 {
176 targetId = currentEdge[1];
177 }
178
179 input->GetPoint(targetId,endingPoint);
180 if (vtkMath::Distance2BetweenPoints(currentPoint,endingPoint) > VTK_VMTK_DOUBLE_TOL)
181 {
182 pointId = newPoints->InsertNextPoint(endingPoint);
183 currentScalar = this->DescentArray->GetTuple1(targetId);
184 currentRadius = this->LineDataArray->GetTuple1(targetId);
185 lineIds->InsertNextId(pointId);
186
187 currentEdge[0] = targetId;
188 currentEdge[1] = targetId;
189 currentS = 0.0;
190
191 newScalars->InsertTuple1(pointId,currentRadius);
192 this->Edges->InsertComponent(pointId,0,currentEdge[0]);
193 this->Edges->InsertComponent(pointId,1,currentEdge[1]);
194 this->EdgeParCoords->InsertValue(pointId,currentS);
195 }
196
197 this->HitTargets->InsertNextId(targetId);
198
199 done = true;
200 break;
201 }
202 if (done)
203 {
204 break;
205 }
206
207 input->GetCellEdgeNeighbors(-1,currentEdge[0],currentEdge[1],neighborCells);
208
209 steepestDescent = this->GetSteepestDescent(input,currentEdge,currentS,steepestDescentEdge,steepestDescentS);
210
211 if (steepestDescentEdge[0] == -1 || steepestDescentEdge[1] == -1)
212 {
213 vtkWarningMacro(<<"Can't find a steepest descent edge. Target not reached.");
214 done = true;
215 break;
216 }
217
218 if (directionFactor*steepestDescent < VTK_VMTK_DOUBLE_TOL)
219 {
220 if (!this->StopOnTargets)
221 //if (!this->StopOnTargets || (previousEdge[0] == currentEdge[0] && previousEdge[1] == currentEdge[1]))
222 {
223 vtkWarningMacro(<<"Target not reached.");
224 done = true; // these two lines were outside the if (!this->StopOnTarget), but that may lead to unnecessary failure.
225 break; // Need of better detection of stall.
226 }
227 }
228
229 currentEdge[0] = steepestDescentEdge[0];
230 currentEdge[1] = steepestDescentEdge[1];
231 currentS = steepestDescentS;
232
233 if (numIterations > 0 &&
234 (
235 ((currentEdge[0] == previousEdge2[0] && currentEdge[1] == previousEdge2[1] && fabs(previousS2 - currentS) < VTK_VMTK_DOUBLE_TOL)) ||
236 ((currentEdge[0] == previousEdge2[1] && currentEdge[1] == previousEdge2[0]) && fabs(1.0 - previousS2 - currentS) < VTK_VMTK_DOUBLE_TOL)
237 )
238 )
239 {
240 vtkWarningMacro(<<"Degenerate descent detected. Target not reached.");
241 done = true;
242 break;
243 }
244
245 previousPoint[0] = currentPoint[0];
246 previousPoint[1] = currentPoint[1];
247 previousPoint[2] = currentPoint[2];
248
249 // Do not call GetPoint(id) twice in one expression: with float points VTK
250 // returns a shared temporary buffer, so the second call overwrites the first
251 // (VTK 9). Copy into locals first (same pattern as GetSteepestDescentInCell).
252 {
253 double edgePoint0[3], edgePoint1[3];
254 input->GetPoint(currentEdge[0], edgePoint0);
255 input->GetPoint(currentEdge[1], edgePoint1);
256 currentPoint[0] = edgePoint0[0] * (1.0 - currentS) + edgePoint1[0] * currentS;
257 currentPoint[1] = edgePoint0[1] * (1.0 - currentS) + edgePoint1[1] * currentS;
258 currentPoint[2] = edgePoint0[2] * (1.0 - currentS) + edgePoint1[2] * currentS;
259 }
260
261 currentScalar = this->DescentArray->GetTuple1(currentEdge[0]) * (1.0 - currentS) + this->DescentArray->GetTuple1(currentEdge[1]) * currentS;
262 currentRadius = this->LineDataArray->GetTuple1(currentEdge[0]) * (1.0 - currentS) + this->LineDataArray->GetTuple1(currentEdge[1]) * currentS;
263
264 if (this->MergePaths)
265 {
266 for (j=newPoints->GetNumberOfPoints()-1; j>=0; j--)
267 {
268 if (((this->Edges->GetComponent(j,0)==currentEdge[0])&&(this->Edges->GetComponent(j,1)==currentEdge[1]))||
269 ((this->Edges->GetComponent(j,0)==currentEdge[1])&&(this->Edges->GetComponent(j,1)==currentEdge[0])))
270 {
271 double newPoint[3];
272 newPoints->GetPoint(j,newPoint);
273 if (sqrt(vtkMath::Distance2BetweenPoints(currentPoint,newPoint)) <= this->MergeTolerance)
274 {
275 pointId = j;
276 lineIds->InsertNextId(pointId);
277 done = true;
278 break;
279 }
280 }
281 }
282 if (done)
283 break;
284 }
285
286 pointId = newPoints->InsertNextPoint(currentPoint);
287 lineIds->InsertNextId(pointId);
288
289 newScalars->InsertTuple1(pointId,currentRadius);
290 this->Edges->InsertComponent(pointId,0,currentEdge[0]);
291 this->Edges->InsertComponent(pointId,1,currentEdge[1]);
292 this->EdgeParCoords->InsertValue(pointId,currentS);
293
294 previousEdge2[0] = previousEdge[0];
295 previousEdge2[1] = previousEdge[1];
296 previousS2 = previousS;
297
298 previousEdge[0] = currentEdge[0];
299 previousEdge[1] = currentEdge[1];
300 previousS = currentS;
301
302 ++numIterations;
303 }
304
305 if (numIterations == 0)
306 {
307 // If no points can be added then we would end up with a line cell
308 // with a single point, which would make VTK9 crash.
309 // Until VTK is fixed (https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9341)
310 // this change can be used to avoid the crash; once VTK fix is merged then this
311 // modification may be removed.
312 // Add the current point again to have a valid cell.
313 pointId = newPoints->InsertNextPoint(currentPoint);
314 lineIds->InsertNextId(pointId);
315 newScalars->InsertTuple1(pointId, currentRadius);
316 this->Edges->InsertComponent(pointId, 0, currentEdge[0]);
317 this->Edges->InsertComponent(pointId, 1, currentEdge[1]);
318 this->EdgeParCoords->InsertValue(pointId, currentS);
319 }
320
321 newLines->InsertNextCell(lineIds);
322
323 neighborCells->Delete();
324 lineIds->Delete();
325}
double GetSteepestDescent(vtkPolyData *input, vtkIdType *edge, double s, vtkIdType *steepestDescentEdge, double &steepestDescentS)

Member Data Documentation

◆ Seeds

vtkIdList* vtkvmtkSteepestDescentLineTracer::Seeds
protected

Definition at line 148 of file vtkvmtkSteepestDescentLineTracer.h.

◆ Targets

vtkIdList* vtkvmtkSteepestDescentLineTracer::Targets
protected

Definition at line 149 of file vtkvmtkSteepestDescentLineTracer.h.

◆ HitTargets

vtkIdList* vtkvmtkSteepestDescentLineTracer::HitTargets
protected

Definition at line 151 of file vtkvmtkSteepestDescentLineTracer.h.

◆ StopOnTargets

int vtkvmtkSteepestDescentLineTracer::StopOnTargets
protected

Definition at line 153 of file vtkvmtkSteepestDescentLineTracer.h.

◆ DataArrayName

char* vtkvmtkSteepestDescentLineTracer::DataArrayName
protected

Definition at line 155 of file vtkvmtkSteepestDescentLineTracer.h.

◆ EdgeArrayName

char* vtkvmtkSteepestDescentLineTracer::EdgeArrayName
protected

Definition at line 157 of file vtkvmtkSteepestDescentLineTracer.h.

◆ EdgePCoordArrayName

char* vtkvmtkSteepestDescentLineTracer::EdgePCoordArrayName
protected

Definition at line 158 of file vtkvmtkSteepestDescentLineTracer.h.

◆ MinDistanceArrayName

char* vtkvmtkSteepestDescentLineTracer::MinDistanceArrayName
protected

Definition at line 159 of file vtkvmtkSteepestDescentLineTracer.h.

◆ MergePaths

int vtkvmtkSteepestDescentLineTracer::MergePaths
protected

Definition at line 161 of file vtkvmtkSteepestDescentLineTracer.h.

◆ MergeTolerance

double vtkvmtkSteepestDescentLineTracer::MergeTolerance
protected

Definition at line 162 of file vtkvmtkSteepestDescentLineTracer.h.

◆ Edges

vtkIntArray* vtkvmtkSteepestDescentLineTracer::Edges
protected

Definition at line 164 of file vtkvmtkSteepestDescentLineTracer.h.

◆ EdgeParCoords

vtkDoubleArray* vtkvmtkSteepestDescentLineTracer::EdgeParCoords
protected

Definition at line 165 of file vtkvmtkSteepestDescentLineTracer.h.

◆ EdgePointIds

vtkIdList* vtkvmtkSteepestDescentLineTracer::EdgePointIds
protected

Definition at line 167 of file vtkvmtkSteepestDescentLineTracer.h.

◆ CellIdsArray

vtkIntArray* vtkvmtkSteepestDescentLineTracer::CellIdsArray
protected

Definition at line 168 of file vtkvmtkSteepestDescentLineTracer.h.

◆ PCoordsArray

vtkDoubleArray* vtkvmtkSteepestDescentLineTracer::PCoordsArray
protected

Definition at line 169 of file vtkvmtkSteepestDescentLineTracer.h.

◆ MinDistanceArray

vtkDoubleArray* vtkvmtkSteepestDescentLineTracer::MinDistanceArray
protected

Definition at line 170 of file vtkvmtkSteepestDescentLineTracer.h.

◆ LineDataArray

vtkDataArray* vtkvmtkSteepestDescentLineTracer::LineDataArray
protected

Definition at line 172 of file vtkvmtkSteepestDescentLineTracer.h.

◆ MergeWithExistingPaths

int vtkvmtkSteepestDescentLineTracer::MergeWithExistingPaths
protected

Definition at line 174 of file vtkvmtkSteepestDescentLineTracer.h.

◆ ExistingPaths

vtkPolyData* vtkvmtkSteepestDescentLineTracer::ExistingPaths
protected

Definition at line 175 of file vtkvmtkSteepestDescentLineTracer.h.

◆ ExistingPathsEdgeArrayName

char* vtkvmtkSteepestDescentLineTracer::ExistingPathsEdgeArrayName
protected

Definition at line 176 of file vtkvmtkSteepestDescentLineTracer.h.

◆ ExistingPathsEdgePCoordArrayName

char* vtkvmtkSteepestDescentLineTracer::ExistingPathsEdgePCoordArrayName
protected

Definition at line 177 of file vtkvmtkSteepestDescentLineTracer.h.

◆ ExistingPathsEdges

vtkIntArray* vtkvmtkSteepestDescentLineTracer::ExistingPathsEdges
protected

Definition at line 178 of file vtkvmtkSteepestDescentLineTracer.h.

◆ ExistingPathsEdgeParCoords

vtkDoubleArray* vtkvmtkSteepestDescentLineTracer::ExistingPathsEdgeParCoords
protected

Definition at line 179 of file vtkvmtkSteepestDescentLineTracer.h.


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