Hi everybody,<br>It has been quite a long time I try to visualize a
polygon resulting from the simple cut of a sphere by a plane. However,
using the code below, I can't see anything with the original camera
setup. I guess that I have problem because my cut is in the camera
focal plane but I don't know how to solve the problem. Do you have any
idea to make this code working (I wouldn't like to change the camera
position and focal point) ?<br>
Thanks a lot,<br><br>Bruno<br><br>#include <vtkSphereSource.h><br>#include <vtkPolyData.h><br>#include <vtkPlane.h><br>#include <vtkCutter.h><br>#include <vtkPolyDataMapper.h><br>#include <vtkActor.h><br>
#include <vtkProperty.h><br>#include <vtkRenderer.h><br>#include <vtkCamera.h><br>#include <vtkRenderWindow.h><br>#include <vtkRenderWindowInteractor.h><br><br>int main(int argc, char **argv) <br>
{<br> vtkSphereSource *sphere = vtkSphereSource::New();<br> <br> vtkPlane *plane = vtkPlane::New();<br> plane->SetOrigin(0., 0., 0.);<br> plane->SetNormal(0., 0., 1.);<br> <br> vtkCutter *cutter = vtkCutter::New();<br>
cutter->SetCutFunction(plane);<br> cutter->SetInput(sphere->GetOutput());<br> <br> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br> mapper->SetInput(cutter->GetOutput());<br> <br>
vtkActor *actor = vtkActor::New();<br> actor->SetMapper(mapper);<br> actor->GetProperty()->SetColor(1., 0., 0.);<br> actor->GetProperty()->SetLineWidth(5.);<br> <br> vtkRenderer *renderer = vtkRenderer::New();<br>
renderer->AddActor(actor);<br> renderer->GetActiveCamera()->ParallelProjectionOn();<br> renderer->GetActiveCamera()->SetFocalPoint(0., 0., 0);<br> renderer->GetActiveCamera()->SetPosition(0., 0., 1.);<br>
renderer->ResetCameraClippingRange(-1., 1., -1., 1., 0, 1);<br> <br> vtkRenderWindow *renderwindow = vtkRenderWindow::New();<br> renderwindow->AddRenderer(renderer);<br> <br> vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New();<br>
interactor->SetRenderWindow(renderwindow);<br> interactor->Initialize();<br> renderwindow->Render();<br> interactor->Start();<br><br> sphere->Delete();<br> plane->Delete();<br> cutter->Delete();<br>
mapper->Delete();<br> actor->Delete();<br> renderer->Delete();<br> renderwindow->Delete();<br> interactor->Delete();<br><br> return 0;<br>}<br>