[vtkusers] Plane Widget and OpenGL ES
Lonni Besançon
lonni.besancon at gmail.com
Mon Feb 1 05:30:47 EST 2016
Sorry for the late reply, here is my code:
/foo->plane = vtkSmartPointer<vtkPlane>::New();
foo->clipper = vtkSmartPointer<vtkClipPolyData>::New();
foo->clipper->SetClipFunction(foo->plane);
foo->clipper->InsideOutOn();
foo->reader = vtkSmartPointer<vtkXMLPolyDataReader>::New() ;
foo->reader->SetFileName(filename.c_str()) ;
foo->clipper->SetInputConnection(foo->reader->GetOutputPort()) ;
// Create a mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(foo->clipper->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
vtkSmartPointer<vtkProperty> backFaces =
vtkSmartPointer<vtkProperty>::New();
backFaces->SetDiffuseColor(.8, .8, .4);
foo->mainActor->SetBackfaceProperty(backFaces);
// The callback will do the work of updating the view
vtkSmartPointer<vtkIPWCallback> myCallback =
vtkSmartPointer<vtkIPWCallback>::New();
myCallback->Plane = foo->plane;
myCallback->Actor = foo->mainActor;
foo->planerep = vtkSmartPointer<vtkImplicitPlaneRepresentation>::New();
foo->planerep->SetPlaceFactor(1.25); // This must be set prior to placing
the widget
foo->planerep->PlaceWidget(foo->mainActor->GetBounds());
foo->planerep->SetNormal(foo->plane->GetNormal());
//planerep->SetNormal(0,1,0);
foo->planerep->SetOrigin(0,0,50); //this doesn't seem to work?
foo->planeWidget = vtkSmartPointer<vtkImplicitPlaneWidget2>::New();
foo->planeWidget->SetInteractor(foo->Interactor);
foo->planeWidget->SetRepresentation(foo->planerep);
foo->planeWidget->AddObserver(vtkCommand::InteractionEvent,myCallback);
foo->Renderer->AddActor(actor);
foo->planeWidget->On();/
As for the callback (probably not needed) but here it is:
class vtkIPWCallback : public vtkCommand
{
public:
static vtkIPWCallback *New()
{
return new vtkIPWCallback;
}
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkImplicitPlaneWidget2 *planeWidget =
reinterpret_cast<vtkImplicitPlaneWidget2*>(caller);
vtkImplicitPlaneRepresentation *rep =
reinterpret_cast<vtkImplicitPlaneRepresentation*>(planeWidget->GetRepresentation());
rep->GetPlane(this->Plane);
}
vtkIPWCallback():Plane(0),Actor(0) {}
vtkPlane *Plane;
vtkActor *Actor;
};
I guess it should work because I have seen some running program with the
cutting plane. Unfortunately can't get my hands on the code to check what
may be wrong with mine.
Thanks again for the help
--
View this message in context: http://vtk.1045678.n5.nabble.com/Plane-Widget-and-OpenGL-ES-tp5736252p5736284.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list