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

Compute the geodesic (graph) distance from a set of seed points over a surface mesh using Dijkstra's algorithm. More...

#include <vtkvmtkPolyDataDijkstraDistanceToPoints.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkPolyDataDijkstraDistanceToPoints * NewInstance () const
virtual void SetSeedIds (vtkIdList *)
virtual vtkIdList * GetSeedIds ()
virtual void SetDistanceOffset (double)
virtual double GetDistanceOffset ()
virtual void SetDistanceScale (double)
virtual double GetDistanceScale ()
virtual void SetMinDistance (double)
virtual double GetMinDistance ()
virtual void SetMaxDistance (double)
virtual double GetMaxDistance ()
virtual void SetDijkstraDistanceToPointsArrayName (const char *)
virtual char * GetDijkstraDistanceToPointsArrayName ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

char * DijkstraDistanceToPointsArrayName
vtkIdList * SeedIds
double DistanceOffset
double DistanceScale
double MinDistance
double MaxDistance

Detailed Description

Compute the geodesic (graph) distance from a set of seed points over a surface mesh using Dijkstra's algorithm.

For each point of the input surface, vtkvmtkPolyDataDijkstraDistanceToPoints computes the shortest path distance, along the mesh edges, to the closest of a set of user-specified seed points (SeedIds), and outputs the result as a point data array named DijkstraDistanceToPointsArrayName. The raw Dijkstra distance is transformed as (DistanceOffset + DistanceScale * rawDistance), clamped from below by MinDistance and, if MaxDistance is positive, from above by MaxDistance (a non-positive MaxDistance, the default, means unbounded).

Definition at line 47 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.

Member Typedef Documentation

◆ Superclass

Constructor & Destructor Documentation

◆ vtkvmtkPolyDataDijkstraDistanceToPoints()

◆ ~vtkvmtkPolyDataDijkstraDistanceToPoints()

vtkvmtkPolyDataDijkstraDistanceToPoints::~vtkvmtkPolyDataDijkstraDistanceToPoints ( )
protected

Definition at line 56 of file vtkvmtkPolyDataDijkstraDistanceToPoints.cxx.

57{
59 {
62 }
63
64 if (this->SeedIds)
65 {
66 this->SeedIds->Delete();
67 this->SeedIds = NULL;
68 }
69}

Member Function Documentation

◆ New()

vtkvmtkPolyDataDijkstraDistanceToPoints * vtkvmtkPolyDataDijkstraDistanceToPoints::New ( )
static

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkPolyDataDijkstraDistanceToPoints::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkPolyDataDijkstraDistanceToPoints * vtkvmtkPolyDataDijkstraDistanceToPoints::NewInstance ( ) const

◆ SetSeedIds()

virtual void vtkvmtkPolyDataDijkstraDistanceToPoints::SetSeedIds ( vtkIdList * )
virtual

Set/get the ids of the input surface points to use as Dijkstra seeds, i.e. the points from which the geodesic distance is measured.

◆ GetSeedIds()

virtual vtkIdList * vtkvmtkPolyDataDijkstraDistanceToPoints::GetSeedIds ( )
virtual

Set/get the ids of the input surface points to use as Dijkstra seeds, i.e. the points from which the geodesic distance is measured.

◆ SetDistanceOffset()

virtual void vtkvmtkPolyDataDijkstraDistanceToPoints::SetDistanceOffset ( double )
virtual

Set/get the constant added to the raw Dijkstra distance before scaling and clamping. Default: 0.

◆ GetDistanceOffset()

virtual double vtkvmtkPolyDataDijkstraDistanceToPoints::GetDistanceOffset ( )
virtual

Set/get the constant added to the raw Dijkstra distance before scaling and clamping. Default: 0.

◆ SetDistanceScale()

virtual void vtkvmtkPolyDataDijkstraDistanceToPoints::SetDistanceScale ( double )
virtual

Set/get the factor the raw Dijkstra distance is multiplied by (after adding DistanceOffset). Default: 1.

◆ GetDistanceScale()

virtual double vtkvmtkPolyDataDijkstraDistanceToPoints::GetDistanceScale ( )
virtual

Set/get the factor the raw Dijkstra distance is multiplied by (after adding DistanceOffset). Default: 1.

◆ SetMinDistance()

virtual void vtkvmtkPolyDataDijkstraDistanceToPoints::SetMinDistance ( double )
virtual

Set/get the lower bound the (offset and scaled) distance is clamped to. Default: 0.

◆ GetMinDistance()

virtual double vtkvmtkPolyDataDijkstraDistanceToPoints::GetMinDistance ( )
virtual

Set/get the lower bound the (offset and scaled) distance is clamped to. Default: 0.

◆ SetMaxDistance()

virtual void vtkvmtkPolyDataDijkstraDistanceToPoints::SetMaxDistance ( double )
virtual

Set/get the upper bound the (offset and scaled) distance is clamped to. A non-positive value (the default, -1) means unbounded.

◆ GetMaxDistance()

virtual double vtkvmtkPolyDataDijkstraDistanceToPoints::GetMaxDistance ( )
virtual

Set/get the upper bound the (offset and scaled) distance is clamped to. A non-positive value (the default, -1) means unbounded.

◆ SetDijkstraDistanceToPointsArrayName()

virtual void vtkvmtkPolyDataDijkstraDistanceToPoints::SetDijkstraDistanceToPointsArrayName ( const char * )
virtual

Set/get the name of the output point data array holding the computed distance values. Commonly named "DijkstraDistanceToPoints".

◆ GetDijkstraDistanceToPointsArrayName()

virtual char * vtkvmtkPolyDataDijkstraDistanceToPoints::GetDijkstraDistanceToPointsArrayName ( )
virtual

Set/get the name of the output point data array holding the computed distance values. Commonly named "DijkstraDistanceToPoints".

◆ RequestData()

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

Definition at line 71 of file vtkvmtkPolyDataDijkstraDistanceToPoints.cxx.

75{
76 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
77 vtkInformation *outInfo = outputVector->GetInformationObject(0);
78
79 vtkPolyData *input = vtkPolyData::SafeDownCast(
80 inInfo->Get(vtkDataObject::DATA_OBJECT()));
81 vtkPolyData *output = vtkPolyData::SafeDownCast(
82 outInfo->Get(vtkDataObject::DATA_OBJECT()));
83
85 {
86 vtkErrorMacro(<<"DijkstraDistanceToPointsArrayName not set.");
87 return 1;
88 }
89
90 if (!this->SeedIds)
91 {
92 vtkErrorMacro(<<"SeedIds not set");
93 return 1;
94 }
95
96 int numberOfInputPoints = input->GetNumberOfPoints();
97
98 output->DeepCopy(input);
99
100
101 vtkDataArray* distanceToPointsArray = output->GetPointData()->GetArray(this->DijkstraDistanceToPointsArrayName);
102
103 bool createArray = !distanceToPointsArray;
104
105 if (createArray)
106 {
107 distanceToPointsArray = vtkDoubleArray::New();
108 distanceToPointsArray->SetName(this->DijkstraDistanceToPointsArrayName);
109 distanceToPointsArray->SetNumberOfComponents(1);
110 distanceToPointsArray->SetNumberOfTuples(numberOfInputPoints);
111 distanceToPointsArray->FillComponent(0, VTK_VMTK_LARGE_DOUBLE);
112
113 output->GetPointData()->AddArray(distanceToPointsArray);
114 }
115
116 int numberOfSeeds = this->SeedIds->GetNumberOfIds();
117
118 vtkDijkstraGraphGeodesicPath *dijkstraAlgo = vtkDijkstraGraphGeodesicPath::New();
119 dijkstraAlgo->SetInputData(input);
120 dijkstraAlgo->StopWhenEndReachedOff();
121 dijkstraAlgo->UseScalarWeightsOff();
122
123 double maxd = this->MaxDistance > 0 ? this->MaxDistance : VTK_VMTK_LARGE_DOUBLE;
124
125 for (int i=0; i<numberOfSeeds; i++)
126 {
127 dijkstraAlgo->SetStartVertex(SeedIds->GetId(i));
128 dijkstraAlgo->Update();
129 vtkDoubleArray *seedDistances = vtkDoubleArray::New();
130 dijkstraAlgo->GetCumulativeWeights(seedDistances);
131 for (int i=0;i<numberOfInputPoints;i++)
132 {
133 double newDist = this->DistanceOffset + this->DistanceScale*seedDistances->GetValue(i);
134 if (newDist<this->MinDistance) newDist = this->MinDistance;
135 if (newDist>maxd) newDist = maxd;
136 if (newDist<distanceToPointsArray->GetComponent(i,0)) distanceToPointsArray->SetComponent(i,0,newDist);
137 }
138 seedDistances->Delete();
139 }
140
141
142 if (createArray) distanceToPointsArray->Delete();
143
144 return 1;
145}
#define VTK_VMTK_LARGE_DOUBLE

Member Data Documentation

◆ DijkstraDistanceToPointsArrayName

char* vtkvmtkPolyDataDijkstraDistanceToPoints::DijkstraDistanceToPointsArrayName
protected

Definition at line 114 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.

◆ SeedIds

vtkIdList* vtkvmtkPolyDataDijkstraDistanceToPoints::SeedIds
protected

Definition at line 116 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.

◆ DistanceOffset

double vtkvmtkPolyDataDijkstraDistanceToPoints::DistanceOffset
protected

Definition at line 118 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.

◆ DistanceScale

double vtkvmtkPolyDataDijkstraDistanceToPoints::DistanceScale
protected

Definition at line 119 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.

◆ MinDistance

double vtkvmtkPolyDataDijkstraDistanceToPoints::MinDistance
protected

Definition at line 120 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.

◆ MaxDistance

double vtkvmtkPolyDataDijkstraDistanceToPoints::MaxDistance
protected

Definition at line 121 of file vtkvmtkPolyDataDijkstraDistanceToPoints.h.


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