Commit 38def2d6dfe7b1fabfd4b9b40b0cdddea51d1bdc
1 parent
d6bfae4f
Exists in
master
and in
68 other branches
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 | 224 | for key in surface_dict: |
| 225 | 225 | surface = surface_dict[key] |
| 226 | 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 | 239 | mapper = vtk.vtkPolyDataMapper() |
| 228 | - mapper.SetInput(surface.polydata) | |
| 240 | + mapper.SetInput(stripper.GetOutput()) | |
| 229 | 241 | mapper.ScalarVisibilityOff() |
| 230 | 242 | |
| 231 | 243 | # Represent an object (geometry & properties) in the rendered scene |
| ... | ... | @@ -316,13 +328,19 @@ class SurfaceManager(): |
| 316 | 328 | reader.Update() |
| 317 | 329 | |
| 318 | 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 | 339 | stripper = vtk.vtkStripper() |
| 321 | - stripper.SetInput(polydata) | |
| 340 | + stripper.SetInput(normals.GetOutput()) | |
| 322 | 341 | stripper.PassThroughCellIdsOn() |
| 323 | 342 | stripper.PassThroughPointIdsOn() |
| 324 | 343 | |
| 325 | - | |
| 326 | 344 | # Map polygonal data (vtkPolyData) to graphics primitives. |
| 327 | 345 | mapper = vtk.vtkPolyDataMapper() |
| 328 | 346 | mapper.SetInput(stripper.GetOutput()) | ... | ... |