[vtkusers] How to find the vtkSphereSource object
tao sun
colddiesun at gmail.com
Sat Nov 23 02:33:33 EST 2013
Hi Madz,
Thanks, I will take a look at it.
Regards,
Sun Tao
2013/11/22 madz <madaramh at gmail.com>
> Here's a complete program.
>
> #include <vtkSphereSource.h>
> #include <vtkPolyData.h>
> #include <vtkSmartPointer.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkActor.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkInteractorStyleTrackballCamera.h>
> #include <vtkObjectFactory.h>
> #include <vtkProperty.h>
>
> vtkSmartPointer<vtkRenderer> renderer;
> vtkSmartPointer<vtkSphereSource> sphereSource;
>
> vtkSmartPointer<vtkPolyDataMapper> mapper ;
>
> vtkSmartPointer<vtkActor> actor;
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor ;
> bool isDeleted;
> class MouseInteractorStyle4 : public vtkInteractorStyleTrackballCamera
> {
> public:
> static MouseInteractorStyle4* New();
> vtkTypeMacro(MouseInteractorStyle4,
> vtkInteractorStyleTrackballCamera);
>
> virtual void OnLeftButtonDown()
> {
>
> // Forward events
> vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
> }
>
> virtual void OnMiddleButtonDown()
> {
>
> vtkInteractorStyleTrackballCamera::OnMiddleButtonDown();
> }
>
> virtual void OnRightButtonDown()
> {
> renderer->RemoveActor(actor);
>
> if(!isDeleted)
> {
> isDeleted = true;
> sphereSource->Delete();
> mapper->Delete();
> actor->Delete();
> }
>
> renderWindowInteractor->GetRenderWindow()->Render();
> }
> };
>
> vtkStandardNewMacro(MouseInteractorStyle4);
>
>
> int main(int, char *[])
> {
>
> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
> sphereSource->SetCenter(0.0, 0.0, 0.0);
> sphereSource->SetRadius(5.0);
>
> mapper =
> vtkSmartPointer<vtkPolyDataMapper>::New();
> mapper->SetInputConnection(sphereSource->GetOutputPort());
>
> actor =
> vtkSmartPointer<vtkActor>::New();
> actor->SetMapper(mapper);
>
> renderer =
> vtkSmartPointer<vtkRenderer>::New();
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
> renderWindow->AddRenderer(renderer);
>
>
> renderWindowInteractor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>
> vtkSmartPointer<MouseInteractorStyle4> style =
> vtkSmartPointer<MouseInteractorStyle4>::New();
>
> renderWindowInteractor->SetInteractorStyle(style);
> renderWindowInteractor->SetRenderWindow(renderWindow);
>
> renderer->AddActor(actor);
> renderer->SetBackground(.3, .6, .3); // Background color green
>
> renderWindow->Render();
> renderWindowInteractor->Start();
>
>
> return EXIT_SUCCESS;
> }
>
>
>
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/How-to-find-the-vtkSphereSource-object-tp5724567p5724570.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131123/842d9fee/attachment.htm>
More information about the vtkusers
mailing list