<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#003333">
    04/11/2010 05:50, Bill Lorensen a &eacute;crit&nbsp;:
    <blockquote
      cite="mid:AANLkTik1gyjVt=cCdCWdTcf7bv30-+gfQQTWXioxLNr6@mail.gmail.com"
      type="cite">
      <pre wrap="">Here is a complete working copy. I had to put the plane in the loop also:</pre>
    </blockquote>
    <br>
    <font size="-1"><font face="Tahoma">Thank you very much, I reached
        the same conclusion.<br>
      </font></font><br>
    Le 04/11/2010 05:50, Bill Lorensen a &eacute;crit&nbsp;:
    <blockquote
      cite="mid:AANLkTik1gyjVt=cCdCWdTcf7bv30-+gfQQTWXioxLNr6@mail.gmail.com"
      type="cite">
      <pre wrap="">Here is a complete working copy. I had to put the plane in the loop also:

// slicing of a sphere by a plane. the plane is iteratively rotated all
// around the sphere

#include &lt;vtkSmartPointer.h&gt;
#include &lt;vtkPolyData.h&gt;
#include &lt;vtkTransform.h&gt;
#include &lt;vtkPlane.h&gt;
#include &lt;vtkCutter.h&gt;
#include &lt;vtkMath.h&gt;
#include &lt;vtkAppendPolyData.h&gt;
#include &lt;vtkPolyDataMapper.h&gt;
#include &lt;vtkActor.h&gt;
#include &lt;vtkProperty.h&gt;
#include &lt;vtkRenderer.h&gt;
#include &lt;vtkRenderWindow.h&gt;
#include &lt;vtkRenderWindowInteractor.h&gt;
#include &lt;vtkSphereSource.h&gt;
#include &lt;vtkInteractorStyleTrackballCamera.h&gt;
#include &lt;vector&gt;

int main (int argc, char *argv[])
{
  // The object to cut
  vtkSmartPointer&lt;vtkSphereSource&gt; sph =
    vtkSmartPointer&lt;vtkSphereSource&gt;::New();
  sph-&gt;SetRadius(25.);
  sph-&gt;SetPhiResolution(50);
  sph-&gt;SetThetaResolution(50);

  vtkPolyData *polydata = sph-&gt;GetOutput();

  // Init the cutting plane
  double bounds[6], center[3];
  polydata-&gt;GetBounds(bounds);
  polydata-&gt;GetCenter(center);

  int nbsections = 10;
  double angle = 360./(double)nbsections;

  // Init the transformation
  vtkSmartPointer&lt;vtkTransform&gt; transf =
    vtkSmartPointer&lt;vtkTransform&gt;::New();
  transf-&gt;RotateWXYZ(angle, 0.0, 0.0, 1.0);

  vtkSmartPointer&lt;vtkMatrix4x4&gt; mat =
    vtkSmartPointer&lt;vtkMatrix4x4&gt;::New();
  transf-&gt;GetMatrix(mat);

  vtkSmartPointer&lt;vtkAppendPolyData&gt; appdata =
    vtkSmartPointer&lt;vtkAppendPolyData&gt;::New();

  double normal[4]={
    bounds[0]-center[0],
    bounds[2]-center[1],
    0,
    1};

  double new_normal[4];

  for(int step=0; step&lt;nbsections; step++)
    {
    vtkSmartPointer&lt;vtkPlane&gt; plane =
      vtkSmartPointer&lt;vtkPlane&gt;::New();

    // Rotation of the cutting plane around normal
    mat-&gt;MultiplyPoint(normal, new_normal);
    plane-&gt;SetNormal(new_normal);
    plane-&gt;SetOrigin(center);
    plane-&gt;GetNormal(normal);

    vtkSmartPointer&lt;vtkCutter&gt; cutter =
      vtkSmartPointer&lt;vtkCutter&gt;::New();
    cutter-&gt;SetInput(polydata);
    cutter-&gt;SetCutFunction(plane);

    appdata-&gt;AddInput(cutter-&gt;GetOutput());

    }

  //visualisation
  //1. All slices
  vtkSmartPointer&lt;vtkPolyDataMapper&gt; appmapper =
    vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
  appmapper-&gt;SetInput(appdata-&gt;GetOutput());

  vtkSmartPointer&lt;vtkActor&gt; appactor =
    vtkSmartPointer&lt;vtkActor&gt;::New();
  appactor-&gt;SetMapper(appmapper);
  appactor-&gt;GetProperty()-&gt;SetColor(1,0,0);

  //2. polydata
  vtkSmartPointer&lt;vtkPolyDataMapper&gt; teethmapper =
    vtkSmartPointer&lt;vtkPolyDataMapper&gt;::New();
  teethmapper-&gt;SetInput(polydata);

  vtkSmartPointer&lt;vtkActor&gt; teethactor =
    vtkSmartPointer&lt;vtkActor&gt;::New();
  teethactor-&gt;SetMapper(teethmapper);
  teethactor-&gt;GetProperty()-&gt;SetColor(0.8,0.8,0.8);

  // The usual renderer, render window and interactor
  vtkSmartPointer&lt;vtkRenderer&gt; ren1 =
    vtkSmartPointer&lt;vtkRenderer&gt;::New();
  vtkSmartPointer&lt;vtkRenderWindow&gt; renWin =
    vtkSmartPointer&lt;vtkRenderWindow&gt;::New();
  vtkSmartPointer&lt;vtkRenderWindowInteractor&gt; iren =
    vtkSmartPointer&lt;vtkRenderWindowInteractor&gt;::New();

  ren1-&gt;SetBackground(.1, .2, .3);
  renWin-&gt;AddRenderer(ren1);
  iren-&gt;SetRenderWindow(renWin);

  ren1-&gt;AddActor(appactor);
  ren1-&gt;AddActor(teethactor);

  renWin-&gt;Render();
  iren-&gt;Start();
}

</pre>
    </blockquote>
  </body>
</html>