[vtkusers] Trouble displaying slice created with vtkCutter

ALIZIER Julien AUSY julien.alizier-ausy at irsn.fr
Fri Jul 9 03:43:59 EDT 2004


Hi Jonathan,

Your code looks good to me.
You may try to see if there is really something to be drawn after the cut.

Add this after cutter->Update() :

  int nbCells = cutter->GetOutput()->GetNumberOfCells();
  if (nbCells <= 0)
  {
    int toto = 1; // set a breakpoint here
  }


If the program stops, this would mean that your are cutting away from the
object <=> the cut is empty.

-- Julien





-----Message d'origine-----
De : Jonathan Lin [mailto:jonathan.s.lin at vanderbilt.edu]
Envoyé : vendredi 9 juillet 2004 00:57
À : vtk
Objet : [vtkusers] Trouble displaying slice created with vtkCutter


Hello all,

I cannot display a slice I created using vtkCutter. The render window comes
up, but there is nothing in it. Besides that, my code compiles and executes
just fine. Has any other person had similar or related problems, and could
give me hints? 

I have also tried using vtkClipPolyData, and got the same problem. And when
I used vtkKitwareCutter, I got the whole mesh displayed. My subcommands for
both were equivalent to that seen with vtkCutter below.

I cannot see what's wrong, so hopefully somebody else can. Otherwise, I
would be drawn to think there is a flaw in the toolkit, and I have no wish
to be the first vtk conspiracy theorist, as my stupidity likely has greater
explanatory power.

Regards,
Jonathan

// Creates function with which to cut slice
vtkPlane *plane = vtkPlane::New();
    plane->SetOrigin (0.0, 0.0, 0.0);
    plane->SetNormal (0.0, 1.0, 0.0);
    
// Loads mesh (which is an instance of vtkPolyData) and plane. Use latter to
cut former.
vtkCutter *cutter = vtkCutter::New();
    cutter->SetInput( finalmesh->GetOutput() );
    cutter->SetCutFunction(plane);
    cutter->Update();

// Maps slice to graphics primitives
vtkPolyDataMapper *cutterMapper = vtkPolyDataMapper::New();
    cutterMapper->SetInput ( cutter->GetOutput() );
    cutterMapper->ScalarVisibilityOff();
  
// Creates actor to render slice
vtkActor *cut = vtkActor::New();
    cut->SetMapper (cutterMapper);
    

// Creates renderer, render window, render window interactor
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

// Renders slice
ren1->AddActor(cut);
ren1->SetBackground(.2,.3,.5);
renWin->AddRenderer(ren1);

iren->SetRenderWindow(renWin);
renWin->SetSize(300,300);
renWin->Render();
iren->Start();



More information about the vtkusers mailing list