[vtkusers] Clipping with SetClippingPlanes and vtkBoxWidget2

frankeadi adrian.franke at tu-ilmenau.de
Tue Apr 28 05:50:06 EDT 2015


Hello,

i am trying to clip a volume with the vtkBoxWidget2, but when i try to get
the vtkPlanes from the vtkBoxWidget2 representation vtkBoxRepresentation,
they are empty. Is there another way to get the planes of the vtkBoxWidget2?

class vtkBoxCallback : public vtkCommand
{
public:
	static vtkBoxCallback *New()
	{
		return new vtkBoxCallback;
	}


	virtual void SetMapper(vtkFixedPointVolumeRayCastMapper * mapp)
	{
		mapper = reinterpret_cast<vtkFixedPointVolumeRayCastMapper*>(mapp);
	}


	virtual void Execute(vtkObject *caller, unsigned long, void*)
	{

		vtkBoxWidget2 *boxWidget =
			reinterpret_cast<vtkBoxWidget2*>(caller);

		vtkPlanes *planes = vtkPlanes::New();
	
reinterpret_cast<vtkBoxRepresentation*>(boxWidget->GetRepresentation())->GetPlanes(planes);	
		mapper->SetClippingPlanes(planes);
		planes->Delete();

	}
	vtkBoxCallback(){}
	
	vtkFixedPointVolumeRayCastMapper *mapper;

	//vtkPlanes *planes;
	
};


vtkSmartPointer<vtkBoxWidget2> boxWidget =
		vtkSmartPointer<vtkBoxWidget2>::New();
	boxWidget->SetInteractor(interactor);
	boxWidget->SetCurrentRenderer(renderer);
	boxWidget->RotationEnabledOff();

	vtkSmartPointer<vtkBoxRepresentation> boxRep =
	    vtkSmartPointer<vtkBoxRepresentation>::New();
	boxRep->SetPlaceFactor(1.0);
	boxRep->PlaceWidget(volume->GetBounds());
	
	boxWidget->SetRepresentation(boxRep);

	vtkSmartPointer<vtkBoxCallback> boxCallback =
		vtkSmartPointer<vtkBoxCallback>::New();

	boxCallback->SetMapper(volumeMapper);
	boxWidget->AddObserver(vtkCommand::InteractionEvent, boxCallback);


Thanks in advance,

Adrian 



--
View this message in context: http://vtk.1045678.n5.nabble.com/Clipping-with-SetClippingPlanes-and-vtkBoxWidget2-tp5731653.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list