[vtkusers] Size of the vtkImplicitPlaneWidget?

Chunyan Jiang jiang at TI.FhG.DE
Fri Dec 27 10:36:13 EST 2002


Dear vtk-users,
I would like to use vtkImplicitPlaneWidget to realize arbitrary clipping.
When I render vtkImplicitPlaneWidget with one vtkConeSource. It works well.
The vtkImplicitPlaneWidget has appropriate size comparing with the
vtkConeSource, and the cone lies in the centre of the vtkImplicitPlaneWidget
. However, when I render the vtkImplicitPlaneWidget with one vtkDataset
whose size is 50*40*10, the vtkImplicitPlaneWidget is very very small
comparing with this data cube, and it lies at one corner of the cube.
How can I set the suitable size of the vtkImplicitPlaneWidget? The following
is my example code.

void RenderCone()
{
	ren=vtkRenderer::New();
	renWin->AddRenderer( ren);



	vtkConeSource *cone=vtkConeSource::New();
	vtkPolyDataMapper *coneMapper=vtkPolyDataMapper::New();
	coneMapper->SetInput(cone->GetOutput());
	vtkActor *coneActor=vtkActor::New();
	coneActor->SetMapper(coneMapper);

    ren->AddActor(coneActor);
	ren->SetBackground( 0.1, 0.2, 0.4);
	ren->SetViewport(0,0,0.5,1);

}
void RenderDataset()
{
	int SizeX,SizeY,SizeZ;
	int s,i,j,k;
	SizeX=50;SizeY=40;SizeZ=10;
	ren=vtkRenderer::New();
	renWin->AddRenderer( ren);


	DataSet=new unsigned char[SizeX*SizeY*SizeZ];
	s=0;
	for(i=0;i<SizeZ;i++)
	{
		for(j=0;j<SizeY;j++)
		{
			for(k=0;k<SizeX;k++)
			{
				DataSet[k+SizeX*(j+SizeY*i)]=(unsigned char)s;
				s++;
				if(s>255)
					s=0;
			}
		}
	}
	importer1 = vtkImageImport::New();
	importer1->SetWholeExtent(1,SizeX,1,SizeY,1,SizeZ);
	importer1->SetDataExtentToWholeExtent();
	importer1->SetDataScalarTypeToUnsignedChar();

	importer1->SetDataOrigin(0,0,0);
      importer1->SetDataSpacing(1.0,1.0,1.0);
	importer1->SetImportVoidPointer(DataSet);

	DataObject=vtkStructuredPoints::New();
	its=vtkImageToStructuredPoints::New();
	its->SetInput(importer1->GetOutput());
	DataObject=its->GetOutput();

	vtkDataSetMapper *DataMapper=vtkDataSetMapper::New();
	DataMapper->SetInput(DataObject);

	vtkActor *DataActor=vtkActor::New();
      DataActor->SetMapper( DataMapper);
      DataActor->VisibilityOn();

      ren->AddActor(DataActor);
	ren->SetBackground( 0.1, 0.2, 0.4);
	ren->SetViewport(0,0,0.5,1);
}

void DrawPlaneWidget()
{

	planeWidget=vtkImplicitPlaneWidget::New();
      planeWidget->SetInteractor( iren);
      planeWidget->PlaceWidget();
	planeWidget->On();

}

Any help is quite appreciated!

Chunyan

***********************************************************************
Chunyan Jiang, Dipl.-Inform.,
Institut for Telematic
Bahnhofstrasse 30-32, D-54292 Trier, Germany
Phone: (+49) (0)651-97551-34
Fax: (+49) (0)651-97551-12
***********************************************************************




More information about the vtkusers mailing list