MCPcopy Create free account
hub / github.com/Kitware/VTK / CalculateStaticEdgeCost

Method CalculateStaticEdgeCost

Filters/Modeling/vtkDijkstraGraphGeodesicPath.cxx:139–169  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

137
138//------------------------------------------------------------------------------
139double vtkDijkstraGraphGeodesicPath::CalculateStaticEdgeCost(
140 vtkDataSet* inData, vtkIdType u, vtkIdType v)
141{
142 double p1[3];
143 inData->GetPoint(u, p1);
144 double p2[3];
145 inData->GetPoint(v, p2);
146
147 double w = sqrt(vtkMath::Distance2BetweenPoints(p1, p2));
148
149 if (this->UseScalarWeights)
150 {
151 double s2 = 0.0;
152 // Note this edge cost is not symmetric!
153 if (inData->GetPointData())
154 {
155 vtkFloatArray* scalars = vtkFloatArray::SafeDownCast(inData->GetPointData()->GetScalars());
156 if (scalars)
157 {
158 s2 = static_cast<double>(scalars->GetValue(v));
159 }
160 }
161
162 double wt = s2 * s2;
163 if (wt != 0.0)
164 {
165 w /= wt;
166 }
167 }
168 return w;
169}
170
171//------------------------------------------------------------------------------
172// This is probably a horribly inefficient way to do it.

Callers 1

BuildAdjacencyMethod · 0.95

Calls 5

sqrtFunction · 0.50
GetPointMethod · 0.45
GetPointDataMethod · 0.45
GetScalarsMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected