[vtkusers] RE: vtkusers Digest, Vol 2, Issue 34

Goodwin Lawlor goodwin.lawlor at ucd.ie
Fri Jun 11 09:31:37 EDT 2004


Hi Petru,
Have a look a vtkVectorDot to create some scalars for you.

I'm guessing you're getting a NULL output because:
1. You created point normals not cell normals. Use
filter->GetOutput->GetPointData()->GetNormals()
2. You need to call Update() before you go looking for your output data.

Hth,

Goodwin


Date: Fri, 11 Jun 2004 10:41:31 +0200
From: Petru Pau <ppau at risc.uni-linz.ac.at>
Subject: [vtkusers] how to get the normal to a cell?
To: vtkusers at vtk.org
Message-ID: <40C9703B.1010107 at risc.uni-linz.ac.at>
Content-Type: text/plain; charset="us-ascii"

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




More information about the vtkusers mailing list