------------------------------------------------------------------------------
| 137 | |
| 138 | //------------------------------------------------------------------------------ |
| 139 | double 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. |
no test coverage detected