Sunday, October 29, 2006

Mesh Conversion And Normals

To calculate the normals in the mesh created in the registration process, I converted the itkMesh into a vtkPolyData so that I could use vtkPolyDataNormals to easily find the face normals. ITK has some already made classes like itkMeshTovtkPolyData that contained a class to complete the process. I tried to implement an instance of the class to convert my itkMesh, but ran into problems with the itkMeshTovtkPolyData class complaining that the itkMesh that I was passing was of const type. Therefore, I added the functions that I needed directly into the itkIntensityProfileMetric class. I confirmed that the itkMesh had been converted to a vtkPolyData by checking the number of points and cells. Once this had been completed, I set out to calculated the normals for use in the itkIntensityProfileMetric and the GUI that displays the intensities for the faces of the mesh. However, I kept getting an error from the vtkPolyDataNormals class that stated there has been a segmentation fault. This may be due to the vtkPolyData that I created not having enough information to be considered a true Mesh or some the fields are not instantiated correctly.

Because of the problems that I encountered with the vtkPolyDataNormals class, I just calculated the normals myself. I accomplished this by storing the points in a double matrix then iterated through the triangle cells and computed the normal vector from the three points stored in each cell. Once the normals were computed I stored them in their own double matrix and made them unit vectors by dividing them by their length. After storing the normal vectors, I outputted them to a file for use in the intensity profile viewer. Incorporating the normals and the mesh into the viewer involves changing the way the viewer inputs meshes from .wrl files to just passing it a completed itkMesh or vtkPolyData.

0 Comments:

Post a Comment

<< Home