[vtkusers] LineInterpolator called 3 times when loop is closed - bug or feature?

itkvtk123 at gmx.net itkvtk123 at gmx.net
Thu Oct 29 13:55:22 EDT 2009


Hi vtkusers,

why is the LineInterpolator called 3 times, when the loop gets closed using vtkContourWidget?
In my opinion, it should be called only once, for the line between the current point and the last point (= first point in closed loop).
But in reality, the LineInterpolator is not only called for this line, but also for the neighboring lines. Thus, the interpolator is called 3 times.

The same happens, when you draw a rectangle and you delete one node (so you have a triangle now).
Instead of just calling the line interpolator once (for the line between the neighboring points of the deleted node), the interpolator is again called 3 times (for the new line and the neighboring lines of the new line).

I do not understand this behaviour. Is it a bug or is it a feature?
In case it is a feature, what is the sense of it and in which scenario is the current implementation beneficial?


Minimal code example to see how often the interpolator is called:

#include "vtkImageViewer2.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkContourWidget.h"
#include "vtkContourLineInterpolator.h"
#include "vtkOrientedGlyphContourRepresentation.h"
#include "vtkPNGReader.h"

class MyInterpolator : public vtkContourLineInterpolator
{
public:
	static MyInterpolator* New()
	{
		return new MyInterpolator;
	}

	int InterpolateLine(vtkRenderer* ren, vtkContourRepresentation* rep, int idx1, int idx2)
	{
		if(rep->GetClosedLoop())
		{
			cout << "closed loop - interpolating line..." << endl;
		}
		else
		{
			cout << "open loop - interpolating line..." << endl;
		}
		return 0;
	}
};

int main()
{
	//Setting up Viewer	
	vtkImageViewer2* viewer = vtkImageViewer2::New();
	vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
	viewer->SetupInteractor(iren);

	//Load Image into Viewer
	vtkPNGReader* reader = vtkPNGReader::New();
	reader->SetFileName("BrainProtonDensitySlice.png");
	reader->Update();
	viewer->SetInput(reader->GetOutput());

	//Setting up Contour Widget
	vtkContourWidget* widget = vtkContourWidget::New();
	vtkOrientedGlyphContourRepresentation* rep = vtkOrientedGlyphContourRepresentation::New();
	widget->SetRepresentation(rep);
	widget->SetCurrentRenderer(viewer->GetRenderer());
	widget->SetInteractor(iren);
	
	//Setting up Line Interpolator
	rep->SetLineInterpolator(MyInterpolator::New());

	//Start Interaction
	widget->On();
	viewer->Render();
	iren->Start();
}



Thank you so much
-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser



More information about the vtkusers mailing list