[vtkusers] how to get the normal to a cell?

Petru Pau ppau at risc.uni-linz.ac.at
Fri Jun 11 04:41:31 EDT 2004


Hi,

I have a vtkPolyData, and I need to partition its (polygonal) cells 
according to the
normal in each cell.

More exactly, I want to assign a scalar value to each cell: this value 
should be the angle
made by the normal to that cell with the plane xOy. This scalar value 
will then be used to
extract subsets of cells (using, e.g., vtkThreshold).

The sequence of commands should be simple:

            // "model" is the variable that stores the initial vtkPolyData
            //
            // compute the normals
            vtkPolyDataNormals normals = vtkPolyDataNormals.New();
            normals.SetInput(model);

            vtkPolyData output = normals.GetOutput();
            output.Update();

            // extract the cell data
            vtkCellData cellData = output.GetCellData();
            vtkDataArray cellNormals = cellData.GetNormals();

            // ... use cellNormals to set some scalar values

The only problem is that cellNormals is null.

 From the documentation of vtkPolyDataNormals, and using personal deduction
skills, I inferred that the output of this filter is a vtkPolyData 
identical to the input,
additionally having normal data. I guess though that some of my 
assumptions are wrong.
Therefore I come and ask: Where are the normals? How can I access
them, for every single cell?

There is another direction to look at my problem: I do not exclude the 
existence of
a simpler way to associate scalar data which are related to normal data. 
Is there a filter
that uses the normals to generate scalars? I've studied a few examples 
that use
vtkPolyDataNormals, but found nothing.

Petru

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040611/5f2c2f70/attachment.htm>


More information about the vtkusers mailing list