[vtkusers] graph

Wylie, Brian bnwylie at sandia.gov
Fri Jun 1 14:08:12 EDT 2007


Oh, sorry,

The call should be SetJitter and not vtkSetJitter.... 

So you just want to see edges? 

You can (same file) change   

this->VertexActor->VisibilityOn();
to
this->VertexActor->VisibilityOff();


Also, from a higher perspective..., if you familiar with VTK you might
not want to use the vtkGraphLayoutViewer... That class combines lots of
functionality (including layout) into a meta class. 

If you want to have lots of flexibility and you don't want layout,
vertices, etc... You can simply use the vtkGraphToPolyData class

This takes any vtkGraph data structure and converts it to simple
vtkPolyData... Then you could do whatever you want... Put tubes around
the edges... Have your own glyphs for the vertices, etc...

  Brian Wylie - Org 1424
  Sandia National Laboratories
  MS 0822 - Building 880/A1-J
  (505)844-2238 FAX(505)845-0833    
       _______ __
      /_  __(_) /_____ _____
       / / / / __/ __ `/ __ \
      / / / / /_/ /_/ / / / /
     /_/ /_/\__/\__,_/_/ /_/
            VTK Informatics Toolkit
  

> -----Original Message-----
> From: debbie larson [mailto:debbielarson_9 at hotmail.com] 
> Sent: Friday, June 01, 2007 12:00 PM
> To: Wylie, Brian; vtkusers at vtk.org
> Subject: RE: [vtkusers] graph
> 
> 
> Thanks Brian. Yes that did change things. But regarding your 
> code below, I get an error message on
> vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->vtkSetJitter(false);
> 
> (doesnt know about vtkSetJitter). Also how can I get rid of 
> the gliphs that 
> represent the vertices?
> 
> I basically want to see a graph whose layout looks like this
> 
>                        **
>                      /    \
>                     **    **
>                      \     /
>                         **
> Is this possible?
> 
> Thanks
> 
> deb
> >From: "Wylie, Brian" <bnwylie at sandia.gov>
> >To: "debbie larson" <debbielarson_9 at hotmail.com>,vtkusers at vtk.org
> >Subject: RE: [vtkusers] graph
> >Date: Fri, 1 Jun 2007 11:18:08 -0600
> >
> >Hmmmm...
> >
> >Well good news and bad news....
> >
> >The good news is that in our sandbox we have a 
> vtkPassThrough strategy
> >that doesn't change the position of the vertices at all... 
> The bad news
> >is that it's not yet in vtk. :(
> >
> >I think the best way to "hack" it until we get that in VTK 
> (like 2 weeks
> >from now probably) is to do the following....
> >
> >In vtkGraphLayoutViewer.cxx line 415 ish...
> >
> >   else if (!strcmp(strategyName, "Simple2D"))
> >     {
> >     strategy = vtkSimple2DLayoutStrategy::New();
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->SetMaxNumberOfIterations(100);
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->SetIterationsPerLayout(100);
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->SetInitialTemperature(1);
> >     }
> >
> >Change to something like....
> >
> >   else if (!strcmp(strategyName, "Simple2D"))
> >     {
> >     strategy = vtkSimple2DLayoutStrategy::New();
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->SetMaxNumberOfIterations(0);
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->SetIterationsPerLayout(0);
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->SetInitialTemperature(0);
> >     vtkSimple2DLayoutStrategy::SafeDownCast(strategy)
> >       ->vtkSetJitter(false);
> >     }
> >
> >This means the layout basically shouldn't DO anything
> >
> >
> >Should work.... Sorry for making you hack the code... Like I said the
> >'pass-through' strategy should be in soon....
> >
> >   Brian Wylie - Org 1424
> >   Sandia National Laboratories
> >   MS 0822 - Building 880/A1-J
> >   (505)844-2238 FAX(505)845-0833
> >        _______ __
> >       /_  __(_) /_____ _____
> >        / / / / __/ __ `/ __ \
> >       / / / / /_/ /_/ / / / /
> >      /_/ /_/\__/\__,_/_/ /_/
> >             VTK Informatics Toolkit
> >
> >
> > > -----Original Message-----
> > > From: vtkusers-bounces+bnwylie=sandia.gov at vtk.org
> > > [mailto:vtkusers-bounces+bnwylie=sandia.gov at vtk.org] On
> > > Behalf Of debbie larson
> > > Sent: Friday, June 01, 2007 10:44 AM
> > > To: vtkusers at vtk.org
> > > Subject: Re: [vtkusers] graph
> > >
> > > Hi,
> > >
> > > I tried to set the coordinates of the vertices and then
> > > visualize the graph with vtkGraphLayout but it seems it
> > > doesnt care about the positions of the vertices. I must be
> > > missing something when I set the coordinates of those
> > > vertices. But what? Here it is the code
> > >
> > > //Add vertices
> > > VTK_CREATE(vtkPoints,pts);
> > > VTK_CREATE(vtkGraph,graph);
> > > graph->AddVertex();
> > > for loop
> > >       pts->InsertNextPoint(x,y,0);
> > >        graph->AddVertex();
> > > end loop
> > > graph->SetPoints(pts);
> > >
> > > //Add Edges
> > > for loop
> > >    graph->AddEdge(v,p);
> > > end loop
> > >
> > > //view
> > > VTK_CREATE(vtkGraphLayoutViewer,viewer);
> > >   viewer->SetInput(graph);
> > >    viewer->SetLayoutStrategy("Simple2D");//Tried also 
> ForceDirected
> > >
> > >    VTK_CREATE(vtkRenderer,ren);
> > >    VTK_CREATE(vtkRenderWindow,win);
> > >      win->AddRenderer(ren);
> > >      VTK_CREATE(vtkRenderWindowInteractor,interact);
> > >      interact->SetRenderWindow(win);
> > >      viewer->SetRenderWindow(win);
> > >      win->GetInteractor()->Initialize();
> > >      win->GetInteractor()->Start();
> > >
> > >
> > > Thanks
> > >
> > > deb
> > > >From: "Jeff Baumes" <jeff.baumes at kitware.com>
> > > >To: "debbie larson" <debbielarson_9 at hotmail.com>
> > > >CC: vtkusers at vtk.org
> > > >Subject: Re: [vtkusers] graph
> > > >Date: Thu, 31 May 2007 09:17:22 -0400
> > > >
> > > >If you use the CVS version of VTK, the following should 
> give you a
> > > >start.  Recyclying the vertex points and using a low initial
> > > >temperature on the layout strategy gives a jittery but reasonable
> > > >dynamic layout.  I should also point you to
> > > vtkGraphLayoutViewer, which
> > > >wraps most of this stuff up (but doesn't allow access to 
> the inner
> > > >workings to do the dynamic graph layout like this), and to
> > > >vtkDynamic2DLabelMapper in VTK/Graphics if you want to label the
> > > >vertices.
> > > >
> > > >I'm using the simple macro
> > > >#define VTK_CREATE(type, name) \
> > > >  vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
> > > >
> > > >int main()
> > > >{
> > > >  // Create initial cycle graph
> > > >  VTK_CREATE(vtkGraph, graph);
> > > >  for (int i = 0; i < 100; i++)
> > > >    {
> > > >    graph->AddEdge(i, (i+1)%100);
> > > >    }
> > > >
> > > >  // Set up graph layout pipeline
> > > >  VTK_CREATE(vtkSimple2DLayoutStrategy, strategy);
> > > > strategy->SetInitialTemperature(0.5);
> > > >  VTK_CREATE(vtkGraphLayout, layout);
> > > >  layout->SetInput(graph);
> > > >  layout->SetLayoutStrategy(strategy);
> > > >  VTK_CREATE(vtkGraphToPolyData, poly);
> > > > poly->SetInputConnection(layout->GetOutputPort());
> > > >  VTK_CREATE(vtkPolyDataMapper, mapper);
> > > > mapper->SetInputConnection(poly->GetOutputPort());
> > > >  VTK_CREATE(vtkActor, actor);
> > > >  actor->SetMapper(mapper);
> > > >  VTK_CREATE(vtkGlyphSource2D, glyphSource);
> > > > glyphSource->SetGlyphTypeToVertex();
> > > >  VTK_CREATE(vtkGlyph3D, glyph);
> > > >  glyph->SetInputConnection(0, poly->GetOutputPort());
> > > > glyph->SetInputConnection(1, glyphSource->GetOutputPort());
> > > > VTK_CREATE(vtkPolyDataMapper, vmapper);
> > > > vmapper->SetInputConnection(glyph->GetOutputPort());
> > > >  VTK_CREATE(vtkActor, vactor);
> > > >  vactor->SetMapper(vmapper);
> > > >  vactor->GetProperty()->SetPointSize(5);
> > > >  vactor->GetProperty()->SetColor(1, 0, 0);
> > > >
> > > >  // Setup renderer / render window
> > > >  VTK_CREATE(vtkRenderer, ren);
> > > >  VTK_CREATE(vtkRenderWindow, win);
> > > >  win->AddRenderer(ren);
> > > >  VTK_CREATE(vtkRenderWindowInteractor, iren);
> > > > iren->SetRenderWindow(win);  VTK_CREATE(vtkInteractorStyleImage,
> > > > style);  iren->SetInteractorStyle(style);  ren->AddActor(actor);
> > > > ren->AddActor(vactor);  iren->Initialize();
> > > >
> > > >  // Render in a loop
> > > >  for (int i = 0; i < 400; i++)
> > > >    {
> > > >    // Start the layout with the existing layout
> > > >    graph->SetPoints(layout->GetOutput()->GetPoints());
> > > >    graph->AddEdge((int)(vtkMath::Random()*100),
> > > >(int)(vtkMath::Random()*100));
> > > >    graph->Modified();
> > > >    ren->ResetCamera();
> > > >    iren->Render();
> > > >    }
> > > >  iren->Start();
> > > >  return 0;
> > > >}
> > > >
> > > >Jeff
> > > >
> > > >On 5/28/07, debbie larson <debbielarson_9 at hotmail.com> wrote:
> > > >>Hi,
> > > >>
> > > >>I would like to plot an evolving (directed) graph. I.e. I
> > > would like
> > > >>to display it as nodes and edges are added. The graph is
> > > being updated
> > > >>by some computer code and I want to redraw the graph after a few
> > > >>node/edge additions to see how it is evolving. I would like
> > > to display
> > > >>it in a 2D layout (hopefully without edges intersecting
> > > each other).
> > > >>Can this be done in vtk?
> > > >>Any pointers would be appreciated.
> > > >>
> > > >>Thanks
> > > >>
> > > >>deb
> > > >>
> > > 
> >>_________________________________________________________________
> > > >>More photos, more messages, more storage-get 2GB with 
> Windows Live
> > > >>Hotmail.
> > > >>http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TX
> > > T_TAGHM_mi
> > > >>gration_HM_mini_2G_0507
> > > >>
> > > >>_______________________________________________
> > > >>This is the private VTK discussion list.
> > > >>Please keep messages on-topic. Check the FAQ at:
> > > >>http://www.vtk.org/Wiki/VTK_FAQ
> > > >>Follow this link to subscribe/unsubscribe:
> > > >>http://www.vtk.org/mailman/listinfo/vtkusers
> > > >>
> > > >
> > > >
> > > >--
> > > >Jeff Baumes
> > > >R&D Engineer, Kitware Inc.
> > > >(518) 371-3971 x132
> > > >jeff.baumes at kitware.com
> > >
> > > _________________________________________________________________
> > > Need a break? Find your escape route with Live Search Maps.
> > > http://maps.live.com/default.aspx?ss=Restaurants~Hotels~Amusem
> > > ent%20Park&cp=33.832922~-117.915659&style=r&lvl=13&tilt=-90&di
> > > r=0&alt=-1000&scene=1118863&encType=1&FORM=MGAC01
> > >
> > > _______________________________________________
> > > This is the private VTK discussion list.
> > > Please keep messages on-topic. Check the FAQ at:
> > > http://www.vtk.org/Wiki/VTK_FAQ Follow this link to
> > > subscribe/unsubscribe:
> > > http://www.vtk.org/mailman/listinfo/vtkusers
> > >
> > >
> >
> 
> _________________________________________________________________
> PC Magazine's 2007 editors' choice for best Web 
> mail-award-winning Windows 
> Live Hotmail. 
> http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_
TAGHM_migration_HM_mini_pcmag_0507
> 
> 
> 




More information about the vtkusers mailing list