[vtkusers] Creating a polydata of edges (lines) from a vtkGraph

David Doria daviddoria+vtk at gmail.com
Wed Nov 11 13:54:13 EST 2009


> If you are setting the points directly, you don't need to use vtkGraphLayout
> at all. vtkAssignCoordinates is for setting the points on a graph from x, y,
> z arrays in the VertexData.
> Jeff
>

With the following:
  vtkSmartPointer<vtkMutableUndirectedGraph> G =
vtkSmartPointer<vtkMutableUndirectedGraph>::New();

  vtkIdType V1 = G->AddVertex();
  vtkIdType V2 = G->AddVertex();
  vtkIdType V3 = G->AddVertex();
  vtkIdType V4 = G->AddVertex();

  G->AddEdge ( V1, V2 );
  G->AddEdge ( V1, V3 );
  G->AddEdge ( V1, V4 );

  vtkSmartPointer<vtkPoints> Points = vtkSmartPointer<vtkPoints>::New();
  Points->InsertNextPoint(0.0, 0.0, 0.0);
  Points->InsertNextPoint(1.0, 0.0, 0.0);
  Points->InsertNextPoint(0.0, 1.0, 0.0);
  Points->InsertNextPoint(0.0, 0.0, 1.0);

  G->SetPoints(Points);

  vtkSmartPointer<vtkGraphLayout> GraphLayout =
vtkSmartPointer<vtkGraphLayout>::New();
  GraphLayout->SetInput(G);
  GraphLayout->Update();

I get:

vtkGraphLayout (0x8d92f68): Layout strategy must be non-null.

That's why I tried to use a LayoutStrategy. I don't see any flags to
NOT use a layout strategy - how would you do this?

Thanks,

David



More information about the vtkusers mailing list