| 20 | #define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New() |
| 21 | |
| 22 | void PerformAlgorithm(vtkRenderer* ren, vtkAlgorithm* alg, double xoffset, double yoffset, |
| 23 | const char* vertColorArray, double vertMin, double vertMax, const char* edgeColorArray = nullptr, |
| 24 | double edgeMin = 0, double edgeMax = 0) |
| 25 | { |
| 26 | VTK_CREATE(vtkGraphToPolyData, graphToPoly); |
| 27 | graphToPoly->SetInputConnection(alg->GetOutputPort()); |
| 28 | |
| 29 | VTK_CREATE(vtkGlyphSource2D, glyph); |
| 30 | glyph->SetGlyphTypeToVertex(); |
| 31 | VTK_CREATE(vtkGlyph3D, vertexGlyph); |
| 32 | vertexGlyph->SetInputConnection(0, graphToPoly->GetOutputPort()); |
| 33 | vertexGlyph->SetInputConnection(1, glyph->GetOutputPort()); |
| 34 | VTK_CREATE(vtkPolyDataMapper, vertexMapper); |
| 35 | vertexMapper->SetInputConnection(vertexGlyph->GetOutputPort()); |
| 36 | vertexMapper->SetScalarModeToUsePointFieldData(); |
| 37 | if (vertColorArray) |
| 38 | { |
| 39 | vertexMapper->SelectColorArray(vertColorArray); |
| 40 | vertexMapper->SetScalarRange(vertMin, vertMax); |
| 41 | } |
| 42 | VTK_CREATE(vtkActor, vertexActor); |
| 43 | vertexActor->SetMapper(vertexMapper); |
| 44 | vertexActor->GetProperty()->SetPointSize(10.0); |
| 45 | vertexActor->SetPosition(xoffset, yoffset, 0.001); |
| 46 | |
| 47 | VTK_CREATE(vtkPolyDataMapper, edgeMapper); |
| 48 | edgeMapper->SetInputConnection(graphToPoly->GetOutputPort()); |
| 49 | edgeMapper->SetScalarModeToUseCellFieldData(); |
| 50 | if (edgeColorArray) |
| 51 | { |
| 52 | edgeMapper->SelectColorArray(edgeColorArray); |
| 53 | edgeMapper->SetScalarRange(edgeMin, edgeMax); |
| 54 | } |
| 55 | VTK_CREATE(vtkActor, edgeActor); |
| 56 | edgeActor->SetMapper(edgeMapper); |
| 57 | edgeActor->SetPosition(xoffset, yoffset, 0); |
| 58 | |
| 59 | ren->AddActor(vertexActor); |
| 60 | ren->AddActor(edgeActor); |
| 61 | } |
| 62 | |
| 63 | int TestGraphAlgorithms(int argc, char* argv[]) |
| 64 | { |
no test coverage detected