[vtkusers] Connect a vtkCutter to an imageWriter

TINGAUD Frederic Frederic.TINGAUD at murex.com
Fri Mar 15 09:46:43 EDT 2013


Hi all,

 

I have a structured grid, that I cut using a vtkCutter. This part is
working well, but I would now like to connect this vtkCutter to a
vtkPNGWriter or any image writer that would allow me to put the
resulting plane into an image in memory, in order to use it elsewhere.
Is it possible? If yes, what should I use to connect them?

 

I join a minimal test case of what I am doing to obtain the vtkCutter I
would like to extract, in case it is of some interest (sorry it is in
Java...).

 

Regards,

 

Frederic

 

 

public static void main(String[] args) throws InterruptedException,
InvocationTargetException {

    final vtkRenderWindowPanel rwp = new vtkRenderWindowPanel();

 

    vtkPoints pts = new vtkPoints();

    for(int i = 0; i < 3; ++i) {

        for(int j = 0; j < 3; ++j) {

            for(int k = 0; k < 3; ++k) {

                pts.InsertNextPoint(k, j, i);

            }

        }

    }

 

    Random rand = new Random();

    vtkDoubleArray scalars = new vtkDoubleArray();

    for(int i = 0; i < 27; ++i) {

        scalars.InsertNextValue(rand.nextInt(100));

    }

 

    vtkStructuredGrid grid = new vtkStructuredGrid();

    grid.SetDimensions(3, 3, 3);

    grid.SetPoints(pts);

    grid.GetPointData().SetScalars(scalars);

 

    vtkDataSetMapper mapper = new vtkDataSetMapper();

    mapper.SetInputData(grid);

    mapper.SetScalarRange(scalars.GetRange()[0], scalars.GetRange()[1]);

 

    vtkPlane plane = new vtkPlane();

    plane.SetNormal(new double[] { 0, 1, 0 });

    vtkCutter cutter = new vtkCutter();

    cutter.SetInputData(grid);

    cutter.SetCutFunction(plane);

    cutter.SetValue(0, 0.5);

 

    vtkDataSetMapper cutterMapper = new vtkDataSetMapper();

    cutterMapper.SetInputConnection(cutter.GetOutputPort());

    cutterMapper.SetScalarRange(scalars.GetRange()[0],
scalars.GetRange()[1]);

 

    final vtkActor gridAct = new vtkActor();

    gridAct.SetMapper(mapper);

    gridAct.GetProperty().SetOpacity(0.2);

 

    final vtkActor cutActor = new vtkActor();

    cutActor.SetMapper(cutterMapper);

 

    EventQueue.invokeAndWait(new Runnable() {

        @Override

        public void run() {

            JFrame frame = new JFrame();

            vtkRenderer r = rwp.GetRenderer();

            r.AddActor(gridAct);

            r.AddActor(cutActor);

            frame.setLayout(new BorderLayout());

            frame.add(rwp, BorderLayout.CENTER);

            frame.setVisible(true);

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        }

    });

}

*******************************

This e-mail contains information for the intended recipient only. It may contain proprietary material or confidential information. If you are not the intended recipient you are not authorised to distribute, copy or use this e-mail or any attachment to it. Murex cannot guarantee that it is virus free and accepts no responsibility for any loss or damage arising from its use. If you have received this e-mail in error please notify immediately the sender and delete the original email received, any attachments and all copies from your system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130315/d679ec07/attachment.htm>


More information about the vtkusers mailing list