[vtkusers] vtkSplineWidget doesn't go through all handles

Willem Ridderhof w.ridderhof at gmail.com
Wed Mar 28 10:44:03 EDT 2007


Hi all,

I'm using VTK 5.0 with MSVS-8. I'm trying to create a vtkSplineWidget
containing, let's say, 8 handles. However, the spline only
interpolates between 5 of them. Is this intended? How can I circumvent
it?

Hope somebody can help!

Example code to reproduce the problem:
----------------------------------------------------------------------------------------------------------------
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkPoints.h"
#include "vtkSplineWidget.h"

int main( int argc, char** argv )
{
	//create a renderer
	vtkRenderer* renderer = vtkRenderer::New();

	//create a render window
	vtkRenderWindow* renWin = vtkRenderWindow::New();
	renWin->SetSize( 1024, 1024 );
	renWin->AddRenderer( renderer );

	//create an interactor
	vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
	iren->SetRenderWindow( renWin );

	renWin->SetInteractor( iren );
	renderer->SetRenderWindow( renWin );
	renderer->SetBackground( 0.4392, 0.5020, 0.5647 );


	//create some spline handles
	vtkPoints* points = vtkPoints::New();
	points->InsertNextPoint(100, 100, 0);
	points->InsertNextPoint(200, 100, 0);
	points->InsertNextPoint(300, 200, 0);
	points->InsertNextPoint(800, 50, 0);
	points->InsertNextPoint(500, 200, 0);
	points->InsertNextPoint(800, 500, 0);
	points->InsertNextPoint(900, 500, 0);
	points->InsertNextPoint(1000, 500, 0);
	//create a splinewidget
	vtkSplineWidget* spline = vtkSplineWidget::New();
	spline->SetCurrentRenderer( renderer );
	spline->SetDefaultRenderer( renderer );	
	spline->SetInteractor( iren );
	spline->PlaceWidget( 0.0, 1000.0, 0.0, 500.0, 0.0, 0.0 );
	spline->SetNumberOfHandles( points->GetNumberOfPoints() );	
	spline->InitializeHandles( points );
	spline->On();


	//start the rendering
	renWin->Render();
	iren->Start();

	//release VTK components
	points->Delete();
	spline->Delete();
	renWin->Delete();
	iren->Delete();
	renderer->Delete();

	return 0;
}
----------------------------------------------------------------------------------------------------------------

Regards,

Willem



More information about the vtkusers mailing list