[vtk-developers] vtkContourLineInterpolator bug
Dean Inglis
dean.inglis at sympatico.ca
Wed Aug 20 16:22:11 EDT 2008
Hi all,
in working on the aforementioned shortest image path
classes, I've uncovered what I consider to be buggy
behaviour in vtkContourLineInterpolator and any of its
subclasses that do not re-implement the GetSpan method.
For example, if you lay out a terrain path using
vtkPolygonalSurfaceContourLineInterpolator and then try
to pick and move the first node using vtkContourWidget,
you end up moving only the first node and the line segment
between it and the next interpolated point. What I think should happen
is that then entire path up to the next node should be interpolated:
ie. reverse of if you move the next node to the first, the entire path
back to the first node is updated. A fix is to
use a modified version of the implementation used in
vtkBezierContourLineInterpolator (edits are shown as comments):
//----------------------------------------------------------------------
void vtkBezierContourLineInterpolator::GetSpan( int nodeIndex,
vtkIntArray *nodeIndices,
vtkContourRepresentation *rep)
{
int start = nodeIndex - 2;
// CHANGE TO
// int start = nodeIndex - 1;
int end = nodeIndex - 1;
// CHANGE TO
// int end = nodeIndex;
int index[2];
// Clear the array
nodeIndices->Reset();
nodeIndices->Squeeze();
nodeIndices->SetNumberOfComponents(2);
for ( int i = 0; i < 4; i++ )
// CHANGE TO
// for ( int i = 0; i < 3; i++ )
{
index[0] = start++;
index[1] = end++;
if ( rep->GetClosedLoop() )
{
if ( index[0] < 0 )
{
index[0] += rep->GetNumberOfNodes();
}
if ( index[1] < 0 )
{
index[1] += rep->GetNumberOfNodes();
}
if ( index[0] >= rep->GetNumberOfNodes() )
{
index[0] -= rep->GetNumberOfNodes();
}
if ( index[1] >= rep->GetNumberOfNodes() )
{
index[1] -= rep->GetNumberOfNodes();
}
}
if ( index[0] >= 0 && index[0] < rep->GetNumberOfNodes() &&
index[1] >= 0 && index[1] < rep->GetNumberOfNodes() )
{
nodeIndices->InsertNextTupleValue( index );
}
}
}
A bonus for shortest path interpolators that use graphs is that if an
intermediate
node is moved, the paths to the preceding and following nodes are
re-calculated.
Currently, only the path back to the preceding node is re-calculated.
If there are no objections, I will commit this change to
vtkContourLineInterpolator.cxx
Dean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20080820/637a13ee/attachment.html>
More information about the vtk-developers
mailing list