------------------------------------------------------------------------------ Interpolate the input scalars and create intermediate points between v1 and v2 at the contour values. The point ids are returned in the edgePts array, arranged from v1 to v2 if v1<v2 or vice-versa. The input array edgePts must be large enough to hold the point ids. Return the number of intersection points created in edg
| 165 | // The input array edgePts must be large enough to hold the point ids. |
| 166 | // Return the number of intersection points created in edgePts. |
| 167 | int vtkBandedPolyDataContourFilter::ClipEdge(int v1, int v2, vtkPoints* newPts, |
| 168 | vtkDataArray* inScalars, vtkDoubleArray* outScalars, vtkPointData* inPD, vtkPointData* outPD, |
| 169 | vtkIdType edgePts[]) |
| 170 | { |
| 171 | double low = inScalars->GetComponent(v1, this->Component); |
| 172 | double high = inScalars->GetComponent(v2, this->Component); |
| 173 | auto b = this->Internal->ComputeClipValue(low); |
| 174 | auto e = this->Internal->ComputeClipValue(high); |
| 175 | assert(e != this->Internal->ClipValues.end()); |
| 176 | |
| 177 | if (b == e) |
| 178 | { |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | // Insert from back to front if point ids are not ordered by increasing id |
| 183 | bool reverse = (v1 > v2); |
| 184 | |
| 185 | // We iterate from lowest to highest end point |
| 186 | bool swap = (low > high); |
| 187 | if (swap) |
| 188 | { |
| 189 | std::swap(low, high); |
| 190 | std::swap(b, e); |
| 191 | reverse = !reverse; |
| 192 | } |
| 193 | |
| 194 | // start with the first clip value larger than low |
| 195 | ++b; |
| 196 | |
| 197 | // ComputeClipValue may have accepted a slightly too large value for the high |
| 198 | // clip value. If the difference between high and low is in the order of the |
| 199 | // internal clip tolerance this may lead to an interpolation factor that |
| 200 | // is significantly larger than 1. To prevent this only include the last |
| 201 | // clip value if it doesn't cause an overshoot of more than .01% |
| 202 | if ((*e - low) / (high - low) < 1.0001) |
| 203 | { |
| 204 | ++e; |
| 205 | } |
| 206 | |
| 207 | if (b == e) |
| 208 | { |
| 209 | return 0; |
| 210 | } |
| 211 | |
| 212 | // Interpolate between x1 and x2 |
| 213 | double x1[3]; |
| 214 | double x2[3]; |
| 215 | if (!swap) |
| 216 | { |
| 217 | newPts->GetPoint(v1, x1); |
| 218 | newPts->GetPoint(v2, x2); |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | newPts->GetPoint(v2, x1); |
| 223 | newPts->GetPoint(v1, x2); |
| 224 | } |
no test coverage detected