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

Method CalculateDynamicEdgeCost

Filters/Modeling/vtkDijkstraImageGeodesicPath.cxx:185–217  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

183
184//------------------------------------------------------------------------------
185double vtkDijkstraImageGeodesicPath::CalculateDynamicEdgeCost(
186 vtkDataSet* inData, vtkIdType u, vtkIdType v)
187{
188 double cost = 0.0;
189
190 if (this->CurvatureWeight != 0.0)
191 {
192 int t = this->Internals->Predecessors[u];
193 if (t != -1)
194 {
195 vtkImageData* image = vtkImageData::SafeDownCast(inData);
196
197 double p0[3];
198 image->GetPoint(t, p0);
199 double p1[3];
200 image->GetPoint(u, p1);
201 double p2[3];
202 image->GetPoint(v, p2);
203
204 double p10[3] = { p1[0] - p0[0], p1[1] - p0[1], p1[2] - p0[2] };
205 double p21[3] = { p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2] };
206
207 vtkMath::Normalize(p10);
208 vtkMath::Normalize(p21);
209
210 // the range of dot product of two unit vectors is [-1, 1] so normalize
211 // the maximum curvature from 2 to 1
212 cost = this->CurvatureWeight * (0.5 * fabs(vtkMath::Dot(p10, p21) - 1.0));
213 }
214 }
215
216 return cost;
217}
218
219//------------------------------------------------------------------------------
220// This is probably a horribly inefficient way to do it.

Callers 1

ShortestPathMethod · 0.80

Calls 3

NormalizeFunction · 0.50
DotFunction · 0.50
GetPointMethod · 0.45

Tested by

no test coverage detected