Commit 38def2d6dfe7b1fabfd4b9b40b0cdddea51d1bdc

Authored by Paulo Henrique Junqueira Amorim
1 parent d6bfae4f

FIX: #67 3D model "strange", problem load normals

Showing 1 changed file with 22 additions and 4 deletions   Show diff stats
invesalius/data/surface.py
@@ -224,8 +224,20 @@ class SurfaceManager(): @@ -224,8 +224,20 @@ class SurfaceManager():
224 for key in surface_dict: 224 for key in surface_dict:
225 surface = surface_dict[key] 225 surface = surface_dict[key]
226 # Map polygonal data (vtkPolyData) to graphics primitives. 226 # Map polygonal data (vtkPolyData) to graphics primitives.
  227 +
  228 + normals = vtk.vtkPolyDataNormals()
  229 + normals.SetInput(surface.polydata)
  230 + normals.SetFeatureAngle(80)
  231 + normals.AutoOrientNormalsOn()
  232 + normals.GetOutput().ReleaseDataFlagOn()
  233 +
  234 + stripper = vtk.vtkStripper()
  235 + stripper.SetInput(normals.GetOutput())
  236 + stripper.PassThroughCellIdsOn()
  237 + stripper.PassThroughPointIdsOn()
  238 +
227 mapper = vtk.vtkPolyDataMapper() 239 mapper = vtk.vtkPolyDataMapper()
228 - mapper.SetInput(surface.polydata) 240 + mapper.SetInput(stripper.GetOutput())
229 mapper.ScalarVisibilityOff() 241 mapper.ScalarVisibilityOff()
230 242
231 # Represent an object (geometry & properties) in the rendered scene 243 # Represent an object (geometry & properties) in the rendered scene
@@ -316,13 +328,19 @@ class SurfaceManager(): @@ -316,13 +328,19 @@ class SurfaceManager():
316 reader.Update() 328 reader.Update()
317 329
318 polydata = reader.GetOutput() 330 polydata = reader.GetOutput()
319 - 331 +
  332 + # Orient normals from inside to outside
  333 + normals = vtk.vtkPolyDataNormals()
  334 + normals.SetInput(polydata)
  335 + normals.SetFeatureAngle(80)
  336 + normals.AutoOrientNormalsOn()
  337 + normals.GetOutput().ReleaseDataFlagOn()
  338 +
320 stripper = vtk.vtkStripper() 339 stripper = vtk.vtkStripper()
321 - stripper.SetInput(polydata) 340 + stripper.SetInput(normals.GetOutput())
322 stripper.PassThroughCellIdsOn() 341 stripper.PassThroughCellIdsOn()
323 stripper.PassThroughPointIdsOn() 342 stripper.PassThroughPointIdsOn()
324 343
325 -  
326 # Map polygonal data (vtkPolyData) to graphics primitives. 344 # Map polygonal data (vtkPolyData) to graphics primitives.
327 mapper = vtk.vtkPolyDataMapper() 345 mapper = vtk.vtkPolyDataMapper()
328 mapper.SetInput(stripper.GetOutput()) 346 mapper.SetInput(stripper.GetOutput())