[vtk-developers] mods to vtkDijkstraGraphGeodesicPath

dean.inglis at camris.ca dean.inglis at camris.ca
Mon Apr 23 17:13:30 EDT 2007


Hi Karthik,

so something like this:

  if ( this->AdjacencyBuildTime.GetMTime() < input->GetMTime() )
    {
    this->Initialize();
    }
  else
    {
    this->Reset();
    }

in RequestData, and then in BuildAdjacency:
this->AdjacencyBuildTime.Modified();

yes?  Also, could the vtkPolygonalSurfaceContourLineInterpolator
maintain an internal graph filter
instead of instantiating anew everytime?

Dean

> 
> From: "Karthik Krishnan" <karthik.krishnan at kitware.com>
> Date: 2007/04/23 Mon PM 05:00:29 EDT
> CC: vtk-developers at vtk.org
> Subject: Re: [vtk-developers] mods to vtkDijkstraGraphGeodesicPath
> 
> Hi Dean,
> 
> I agree. Its wasteful to call Initialize() multiple times, unless the input
> polygonal dataset has changed. As you've suggested, I would prefer a
> time-stamp check against the MTIme of the input polydata before rebuilding
> the adjacency information.
> 
> Thanks
> --
> karthik
> 
> 
> On 4/23/07, dean.inglis at camris.ca <dean.inglis at camris.ca> wrote:
> >
> > Hi,
> >
> > I am developing a filter to do Dijkstra's shortest
> > path algorithm along the lines of vtkDijkstraGraphGeodesicPath
> > which inherits from vtkPolyDataAlgorithm.  My version is
> > directed to vtkImageData and I have also written a
> > vtkContourLineInterpolator so that one can interactively
> > generate polydata paths between vertices.
> >
> > It works but I want to make this more efficient, since in the polydata
> > implementation: vtkPolygonalSurfaceContourLineInterpolator
> > instantiates a new vtkDijkstraGraphGeodesicPath (vtkDGGP) every time
> > a new pair of vertices are identified by the vtkContourWidget.
> > For every instantiation, vtkDGGP has to initialize itself,
> > build an adjacency list etc.  If the input is not changing,
> > this is unnecessary and only two ivars need to be reset:
> >   this->IdList->Reset();
> >   this->Hsize = 0;
> > currently this is done in Initialize, but Initialize could
> > be split with the previous two lines placed in a separate
> > Reset() method.  In this way Initialize could be done at
> > the point of SetInput or SetInputConnection rather than
> > in RequestData.  Am I on the right track here?
> > Would there need to be a time stamp mechanism
> > in the filter's  RequestData so that Initialize is called only when the
> > input to the filter is changed?
> >
> > Dean
> >
> >
> > //----------------------------------------------------------------------------
> > int vtkDijkstraGraphGeodesicPath::RequestData(
> >   vtkInformation *           vtkNotUsed( request ),
> >   vtkInformationVector **    inputVector,
> >   vtkInformationVector *     outputVector)
> > {
> >   vtkInformation * inInfo = inputVector[0]->GetInformationObject(0);
> >   vtkInformation *outInfo =   outputVector->GetInformationObject(0);
> >
> >   vtkPolyData *input = vtkPolyData::SafeDownCast(
> >     inInfo->Get(vtkDataObject::DATA_OBJECT()));
> >   if (!input)
> >     {
> >     return 0;
> >     }
> >
> >   vtkPolyData *output = vtkPolyData::SafeDownCast(
> >     outInfo->Get(vtkDataObject::DATA_OBJECT()));
> >   if (!input)
> >     {
> >     return 0;
> >     }
> >
> > /* HERE IS WHERE SOME FORM OF TIME STAMP CHECKING
> >    COULD BE DONE ???? */
> >
> >   this->Initialize();
> >
> > /* I.E.:
> >    if (this->BuildTime > this->MTime)
> >      this->Reset();
> >   else
> >      this->Initialize();    */
> >
> >
> >   this->ShortestPath(this->StartVertex, this->EndVertex);
> >   this->TraceShortestPath(input, output, this->StartVertex,
> > this->EndVertex);
> >   return 1;
> > }
> >
> >
> > //----------------------------------------------------------------------------
> > void vtkDijkstraGraphGeodesicPath::Initialize()
> > {
> >   vtkPolyData *input = vtkPolyData::SafeDownCast(
> >       this->GetExecutive()->GetInputData(0, 0));
> >
> >   this->BuildAdjacency( input );
> >
> > /*  this->IdList->Reset();  // move out to a method called Reset*/
> >
> >   this->n = input->GetNumberOfPoints();
> >
> >   this->d->SetNumberOfComponents(1);
> >   this->d->SetNumberOfTuples(this->n);
> >   this->pre->SetNumberOfComponents(1);
> >   this->pre->SetNumberOfTuples(this->n);
> >   this->f->SetNumberOfComponents(1);
> >   this->f->SetNumberOfTuples(this->n);
> >   this->s->SetNumberOfComponents(1);
> >   this->s->SetNumberOfTuples(this->n);
> >   this->p->SetNumberOfComponents(1);
> >   this->p->SetNumberOfTuples(this->n);
> >
> >   // The heap has elements from 1 to n
> >   this->H->SetNumberOfComponents(1);
> >   this->H->SetNumberOfTuples(this->n+1);
> >
> > /* this->Hsize = 0;  // move out to a method called Reset*/
> >
> >   this->Reset();  //*** new method
> > }
> >
> >
> > //----------------------------------------------------------------------------
> > void vtkDijkstraGraphGeodesicPath::Reset()
> > {
> >   this->IdList->Reset();
> >   this->Hsize = 0;
> > }
> >
> > _______________________________________________
> > vtk-developers mailing list
> > vtk-developers at vtk.org
> > http://www.vtk.org/mailman/listinfo/vtk-developers
> >
> 
> 
-------------- next part --------------
_______________________________________________
vtk-developers mailing list
vtk-developers at vtk.org
http://www.vtk.org/mailman/listinfo/vtk-developers



More information about the vtk-developers mailing list