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