-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathvtkPolyDataToGraphTest.cxx
More file actions
42 lines (35 loc) · 1.52 KB
/
Copy pathvtkPolyDataToGraphTest.cxx
File metadata and controls
42 lines (35 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkImageData.h>
#include <vtkSphereSource.h>
#include <vtkGraphToPolyData.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkExtractEdges.h>
#include "vtkPolyDataToGraph.h"
int main (int argc, char *argv[])
{
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->Update();
vtkSmartPointer<vtkExtractEdges> extractEdges =
vtkSmartPointer<vtkExtractEdges>::New();
extractEdges->SetInputConnection(sphereSource->GetOutputPort());
extractEdges->Update();
vtkSmartPointer<vtkPolyDataToGraph> polyDataToGraphFilter =
vtkSmartPointer<vtkPolyDataToGraph>::New();
polyDataToGraphFilter->SetInputConnection(extractEdges->GetOutputPort());
polyDataToGraphFilter->Update();
if(extractEdges->GetOutput()->GetNumberOfPoints() != polyDataToGraphFilter->GetOutput()->GetNumberOfVertices())
{
std::cerr << "Number of points " << extractEdges->GetOutput()->GetNumberOfPoints()
<< " does not match number of vertices " << polyDataToGraphFilter->GetOutput()->GetNumberOfVertices() << " !";
return EXIT_FAILURE;
}
if(extractEdges->GetOutput()->GetNumberOfCells() != polyDataToGraphFilter->GetOutput()->GetNumberOfEdges())
{
std::cerr << "Number of cells(lines) " << extractEdges->GetOutput()->GetNumberOfCells()
<< " does not match number of edges " << polyDataToGraphFilter->GetOutput()->GetNumberOfEdges() << " !";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}