[vtkusers] [EXTERNAL] Re: Java vtkPointToCellData

Gerrick Bivins Gerrick.Bivins at halliburton.com
Fri Sep 25 10:11:43 EDT 2015

Hi James
Glad you got that part working.
It sounds like you want to do something like this:


From: James Labiak [mailto:jim at jslengineeringsoftware.com]
Sent: Friday, September 25, 2015 8:55 AM
To: Sebastien Jourdain; Gerrick Bivins
Cc: vtkusers
Subject: Re: [EXTERNAL] Re: [vtkusers] Java vtkPointToCellData

I got the verts to work and can plot the points, but am struggling to create a surface through the points. Any recommendations on an approach? The geometry is similar to: cut a rectangle through a sphere and slide the piece out; the sphere faces that remain are similar to my geometry (just small deviations), but I am focusing on simply trying to create one surface on one face.
On 9/22/2015 9:36 AM, Sebastien Jourdain wrote:
I wasn't sure at first based on your comment, but I don't think vtkPointDataToCellData is meant to create Cells.
And if you don't create any cell, then you won't be able to see anything.
You can create a single polyverts with all the points ids.

vtkCellArray verts = new vtkCellArray();
verts.InsertNextCell( points.GetNumberOfPoints() );
for(int i=0; i < points.GetNumberOfPoints(); i++) {


The code above, should create the expected cells. Just be aware that it was written in a mail with uncertainty regarding the method names and class names.
But that should be enough to get you started with an appropriate IDE.


On Tue, Sep 22, 2015 at 6:35 AM, Gerrick Bivins <Gerrick.Bivins at halliburton.com<mailto:Gerrick.Bivins at halliburton.com>> wrote:
The vtp file seems invalid. It looks like the cells aren’t defined.
Even if the polydata is just points, I think you still have to define the
“Verts” cell array of the polydata.

[cid:image001.jpg at 01D0F772.31EC5A50]

From: vtkusers [mailto:vtkusers-bounces at vtk.org<mailto:vtkusers-bounces at vtk.org>] On Behalf Of James Labiak
Sent: Monday, September 21, 2015 8:05 PM
To: Sebastien Jourdain
Cc: vtkusers
Subject: [EXTERNAL] Re: [vtkusers] Java vtkPointToCellData

Hi Sebastien,
I made the change, but it still seems not to be running the filter. Attached is a java file and a .vtp data file to see what's happening. Also below is the code.

package com.profiles;

import vtk.*;

public class PlotSomePolyDataFromFileRead {

    public static void main(String[] args) {
        try {
            new PlotSomePolyDataFromFileRead();
        } catch (Exception ex_new_PlotSomePolyDataFromFileRead) {
            System.out.println("[main] Exception at new PlotSomePolyDataFromFileRead()");

    // Load VTK libraries
    static {
        if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
                for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {
                    if (!lib.IsLoaded())
                                .println(lib.GetLibraryName() + " not loaded");
                System.out.println("Make sure the search path is correct: ");

    private PlotSomePolyDataFromFileRead() {

        // Read the polyData from the data file
        vtkXMLPolyDataReader xmlReader = new vtkXMLPolyDataReader();

        // Use the filter vtkPointDataToCellData to create the
        // cells from the point data that's in the vtkPolyData from the reader
        // *The vtkPolyData from the reader intentionally only includes vtkPoints
        // and their scalars (that's the given data from the application output)
        vtkPointDataToCellData polyDataCreateCells = new vtkPointDataToCellData();

        // In order to check if the vtkPointDataToCellData filter worked:
        // Create new polyData, retrieve polyData (with cells now) from
        // polyDataCreateCells filter, check values during debug operation
        vtkPolyData polyDataWithCells = new vtkPolyData();
        polyDataWithCells = polyDataCreateCells.GetPolyDataOutput();
        // At this point, polyDataWithCells has (when I run it)
        // point data but not cell data, nor scalar data
        // and it should have all 3

        vtkPolyDataMapper polyMapper = new vtkPolyDataMapper();

        vtkActor polyActor = new vtkActor();
        polyActor.GetProperty().SetColor(1.0, 1.0, 1.0);

        vtkRenderer renderer = new vtkRenderer();
        renderer.SetBackground(0.0, 0.0, 0.0);

        vtkRenderWindow renderWindow = new vtkRenderWindow();
        renderWindow.SetSize(800, 800);

        vtkRenderWindowInteractor renderWindowInteractor = new vtkRenderWindowInteractor();

On 9/21/2015 10:38 AM, Sebastien Jourdain wrote:
Try that

vtkPointDataToCellData polyDataCreateCells = new vtkPointDataToCellData();
polyDataCreateCells.Update();  // <==== For the execution of the filter

// Create new polyData, retrieve completed polyData from polyDataCreateCells
vtkPolyData polyDataComplete = polyDataCreateCells.GetPolyDataOutput(); // No need to create a polydata just get a ref from the filter

On Mon, Sep 21, 2015 at 8:20 AM, James Labiak <jim at jslengineeringsoftware.com<mailto:jim at jslengineeringsoftware.com>> wrote:
Hello all,
I created a pipeline that seems to make sense to me, but always my polyDataComplete is empty. Any ideas why this code doesn't work? The only vtkPointToCellData example on the web that I can find uses blow.vtk, which doesn't exist on my 6.0.0 installation anywhere. The polyData variable gets correctly populated with the points and their scalars below.

        // Create a new, empty polyData
        polyData = new vtkPolyData();

        // populate the polyData points

        // populate the polyData scalars

        vtkPointDataToCellData polyDataCreateCells = new vtkPointDataToCellData();

        // Create new polyData, retrieve completed polyData from polyDataCreateCells
        vtkPolyData polyDataComplete = new vtkPolyData();
        polyDataComplete = polyDataCreateCells.GetPolyDataOutput();

        vtkPolyDataMapper polyMapper = new vtkPolyDataMapper();
        polyMapper.SetScalarRange(scalarMin, scalarMax);

        vtkActor polyActor = new vtkActor();
        polyActor.GetProperty().SetColor(1.0, 1.0, 1.0);

// ...Usual render stuff...


Powered by www.kitware.com<http://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

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:

This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.


James Labiak

JSL Engineering and Software

Mobile: 231-638-3725

email: jim at jslengineeringsoftware.com<mailto:jim at jslengineeringsoftware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150925/a83aae1b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 37966 bytes
Desc: image001.jpg
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150925/a83aae1b/attachment.jpg>

More information about the vtkusers mailing list