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

R K Shyam Prakash ramakrishna.prakash at quest-global.com
Fri Jun 11 05:02:45 EDT 2004


Petru,
        Use  normals.ComputeCellNormalsOn() and you should be fine.
 
--Shyam

-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of Petru Pau
Sent: Friday, June 11, 2004 2:12 PM
To: vtkusers at vtk.org
Subject: [vtkusers] how to get the normal to a cell?


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/4e8a253d/attachment.htm>


More information about the vtkusers mailing list