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

Method Contour

Common/DataModel/vtkPixel.cxx:310–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308static int edges[4][2] = { { 0, 1 }, { 1, 3 }, { 2, 3 }, { 0, 2 } };
309
310void vtkPixel::Contour(double value, vtkDataArray* cellScalars, vtkIncrementalPointLocator* locator,
311 vtkCellArray* vtkNotUsed(verts), vtkCellArray* lines, vtkCellArray* vtkNotUsed(polys),
312 vtkPointData* inPd, vtkPointData* outPd, vtkCellData* inCd, vtkIdType cellId, vtkCellData* outCd)
313{
314 static const int CASE_MASK[4] = { 1, 2, 8, 4 }; // note differenceom quad!
315 vtkMarchingSquaresLineCases* lineCase;
316 int* edge;
317 int i, j, index, *vert;
318 int newCellId;
319 vtkIdType pts[2];
320 double t, x1[3], x2[3], x[3];
321
322 // Build the case table
323 for (i = 0, index = 0; i < 4; i++)
324 {
325 if (cellScalars->GetComponent(i, 0) >= value)
326 {
327 index |= CASE_MASK[i];
328 }
329 }
330
331 lineCase = vtkMarchingSquaresLineCases::GetCases() + index;
332 edge = lineCase->edges;
333
334 for (; edge[0] > -1; edge += 2)
335 {
336 for (i = 0; i < 2; i++) // insert line
337 {
338 vert = edges[edge[i]];
339 t = (value - cellScalars->GetComponent(vert[0], 0)) /
340 (cellScalars->GetComponent(vert[1], 0) - cellScalars->GetComponent(vert[0], 0));
341 this->Points->GetPoint(vert[0], x1);
342 this->Points->GetPoint(vert[1], x2);
343 for (j = 0; j < 3; j++)
344 {
345 x[j] = x1[j] + t * (x2[j] - x1[j]);
346 }
347 if (locator->InsertUniquePoint(x, pts[i]))
348 {
349 if (outPd)
350 {
351 int p1 = this->PointIds->GetId(vert[0]);
352 int p2 = this->PointIds->GetId(vert[1]);
353 outPd->InterpolateEdge(inPd, pts[i], p1, p2, t);
354 }
355 }
356 }
357 // check for degenerate line
358 if (pts[0] != pts[1])
359 {
360 newCellId = lines->InsertNextCell(2, pts);
361 if (outCd)
362 {
363 outCd->CopyData(inCd, cellId, newCellId);
364 }
365 }
366 }
367}

Callers

nothing calls this directly

Calls 7

GetComponentMethod · 0.45
GetPointMethod · 0.45
InsertUniquePointMethod · 0.45
GetIdMethod · 0.45
InterpolateEdgeMethod · 0.45
InsertNextCellMethod · 0.45
CopyDataMethod · 0.45

Tested by

no test coverage detected