[vtkusers] How should I get the right normal of a polygon defined in vtkCellArray?

Amy Squillacote amy.squillacote at kitware.com
Thu Sep 29 08:59:36 EDT 2005


The normals created by this filter are in a float array in CellData, 
not in a vtkCellArray (which only provides information about how 
points are connected to form each cell). To apply the filter to your 
data and then access the normal of each polygon, do the following.

vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
normals->SetInput(yourData);
normals->ComputeCellNormalsOn();
normals->ComputePointNormalsOff();
normals->Update();

vtkFloatArray *normArray = 
vtkFloatArray::SafeDownCast(normals->GetOutput()->GetCellData()->GetNormals());
int i;

float point[3];
for (i = 0; i < normArray->GetNumberOfTuples(); i++)
{
     point[0] = normArray->GetValue(i, 0);  // x-component of normal
     point[1] = normArray->GetValue(i, 1);  // y-component of normal
     point[2] = normArray->GetValue(i, 2);  // z-component of normal

// Do whatever you need to do to write this value to a file here.
}

- Amy

At 08:43 AM 9/29/2005, michal you wrote:
>Thanks,Amy.
>But after I do as you suggested,how should I access the normal of 
>each polygon mannually?I want to read out the polygon information 
>and write into other file formats.But vtkCellArray doesn't seem to 
>provide such method to get the normal of a polygon ,it just offer 
>the vertex infomation.
>Thanks again.
>
>
>>From: Amy Squillacote <amy.squillacote at kitware.com>
>>To: "michal you" <higherone at msn.com>, vtkusers at vtk.org
>>CC: vtkusers-request at vtk.org
>>Subject: Re: [vtkusers] How should I get the right normal of a polygon
>>defined in vtkCellArray?
>>Date: Thu, 29 Sep 2005 08:33:50 -0400
>>
>>Have you tried using the vtkPolyDataNormals filter with 
>>ComputeCellNormals turned on and ComputePointNormals turned off?
>>
>>- Amy
>>
>>At 08:00 AM 9/29/2005, michal you wrote:
>>>I must distinguish which side of the polygon is the inner side or 
>>>outer side?Is there any way I can do this?Thanks for any suggestions.
>>>
>>>_________________________________________________________________
>>>Don't just search. Find. Check out the new MSN Search! 
>>>http://search.msn.com/
>>>
>>>_______________________________________________
>>>This is the private VTK discussion list. Please keep messages 
>>>on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>>Follow this link to subscribe/unsubscribe:
>>>http://www.vtk.org/mailman/listinfo/vtkusers
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today it's 
>FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




More information about the vtkusers mailing list