[vtkusers] Bug in vtkContourRepresentation? Intermediate Points added twice or with inaccuracy

Karthik Krishnan karthik.krishnan at kitware.com
Mon Dec 7 02:51:04 EST 2009


Hello itkvtk123:

What you see is the result of contention between (a) you wanting to
specify a set of intermediate points between nodes (control points)
and (b) the contour line interpolator dictating the interpolation
strategy to adopt between the control points.
  The default interpolator is a bezier interpolator and adds
intermediate points to satisfy the bezier constraint between the
nodes.


Update VTK. I just added an interpolator : vtkLinearContourLineInterpolator.



This is a trivial interpolator, tantamount to doing no interpolation
between the nodes at all, ie just using a straight line..

Your code should look like :

vtkLinearContourLineInteroplator * linearInterp =
vtkLinearContourLineINterpolator::New();
contour->SetContourLineInterpolator( linearInterp );
 ....

And you shouldn't notice an arbitrary addition of points.


-----

In general though, using the API "AddIntermediatePointWorldPosition"
is not advised, since this is meant to be invoked by the contour
interpolator on the representation. The right solution is to sublcass
the vtkContourLineInterpolator and add intermediate points between
nodes as per your strategy.

Otherwise, you will shoot yourself in the foot with two different code
snippets adding differing intermediate points.


On Sun, Dec 6, 2009 at 11:18 PM,  <itkvtk123 at gmx.net> wrote:
> Hey guys,
>
> I have a *very* annoying problem with the vtkContourRepresentation and I don't know why.
>
> I'm adding two nodes and then I add two intermediate points between those two nodes.
>
> When I output the result, I see, that not only two intermediate points have been added, but four intermediate points.
>
> Minimal code:
>
> #include "vtkOrientedGlyphContourRepresentation.h"
> #include "vtkImageViewer2.h"
>
> int main()
> {
>        double worldPos[3];
>
>        vtkImageViewer2* viewer = vtkImageViewer2::New();
>        vtkRenderer* renderer = viewer->GetRenderer();
>
>        vtkOrientedGlyphContourRepresentation* contour =
>                vtkOrientedGlyphContourRepresentation::New();
>        contour->SetRenderer(renderer);
>
>        worldPos[0] = 0;
>        worldPos[1] = 0;
>        worldPos[2] = 0;
>        contour->AddNodeAtWorldPosition(worldPos);
>
>        worldPos[0] = 3;
>        worldPos[1] = 3;
>        worldPos[2] = 3;
>        contour->AddNodeAtWorldPosition(worldPos);
>
>        worldPos[0] = 1;
>        worldPos[1] = 1;
>        worldPos[2] = 1;
>        contour->AddIntermediatePointWorldPosition(0, worldPos);
>
>        worldPos[0] = 2;
>        worldPos[1] = 2;
>        worldPos[2] = 2;
>        contour->AddIntermediatePointWorldPosition(0, worldPos);
>
>        for(unsigned short a = 0; a < contour->GetNumberOfNodes(); a++)
>        {
>                contour->GetNthNodeWorldPosition(a, worldPos);
>                cout << worldPos[0] << ", " << worldPos[1] << ", " << worldPos[2] << endl;
>
>                for(unsigned short b = 0; b < contour->GetNumberOfIntermediatePoints(a); b++)
>                {
>                        contour->GetIntermediatePointWorldPosition(a, b, worldPos);
>                        cout << worldPos[0] << ", " << worldPos[1] << ", " << worldPos[2] << endl;
>                }
>        }
>
>        system("pause");
>        return 0;
> }
>
>
>
> Output:
>
> 0, 0, 0
> 0.999, 0.999, 0.999
> 2.001, 2.001, 2.001
> 1, 1, 1
> 2, 2, 2
> 3, 3, 3
>
> The output should be:
> 0, 0, 0
> 1, 1, 1
> 2, 2, 2
> 3, 3, 3
>
>
> When I add only 1 node, then the intermediate points and then the other node, I get the output
>
> 0, 0, 0
> 0.999, 0.999, 0.999
> 2.001, 2.001, 2.001
> 3, 3, 3
>
> So the intermediate points are not added twice in this case, but with some strange inaccuracy.
>
> Is this a known bug or do I use the API in a wrong way?
>
> Best regards,
> itkvtk123
> --
> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
_________________________________
Karthik Krishnan
Ph: +1 5188814919, +91 9538477060



More information about the vtkusers mailing list