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

itkvtk123 at gmx.net itkvtk123 at gmx.net
Sun Dec 6 23:18:16 EST 2009


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



More information about the vtkusers mailing list