Commit 3915e1bbf3a1bab960262da64b0be02cd9ab8d4b
1 parent
ff18a9fc
Exists in
master
and in
68 other branches
ENH: Normal filter add in create surface from polydata
Showing
1 changed file
with
14 additions
and
8 deletions
Show diff stats
invesalius/data/surface.py
@@ -130,7 +130,7 @@ class SurfaceManager(): | @@ -130,7 +130,7 @@ class SurfaceManager(): | ||
130 | index = self.last_surface_index | 130 | index = self.last_surface_index |
131 | proj = prj.Project() | 131 | proj = prj.Project() |
132 | surface = proj.surface_dict[index] | 132 | surface = proj.surface_dict[index] |
133 | - | 133 | + |
134 | new_polydata = pu.JoinSeedsParts(surface.polydata, | 134 | new_polydata = pu.JoinSeedsParts(surface.polydata, |
135 | points_id_list) | 135 | points_id_list) |
136 | self.CreateSurfaceFromPolydata(new_polydata) | 136 | self.CreateSurfaceFromPolydata(new_polydata) |
@@ -156,8 +156,14 @@ class SurfaceManager(): | @@ -156,8 +156,14 @@ class SurfaceManager(): | ||
156 | self.ShowActor(index, False) | 156 | self.ShowActor(index, False) |
157 | 157 | ||
158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): | 158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): |
159 | + | ||
160 | + normals = vtk.vtkPolyDataNormals() | ||
161 | + normals.SetInput(polydata) | ||
162 | + normals.SetFeatureAngle(80) | ||
163 | + normals.AutoOrientNormalsOn() | ||
164 | + | ||
159 | mapper = vtk.vtkPolyDataMapper() | 165 | mapper = vtk.vtkPolyDataMapper() |
160 | - mapper.SetInput(polydata) | 166 | + mapper.SetInput(normals.GetOutput()) |
161 | mapper.ScalarVisibilityOff() | 167 | mapper.ScalarVisibilityOff() |
162 | 168 | ||
163 | actor = vtk.vtkActor() | 169 | actor = vtk.vtkActor() |
@@ -201,7 +207,7 @@ class SurfaceManager(): | @@ -201,7 +207,7 @@ class SurfaceManager(): | ||
201 | (surface.index, surface.name, | 207 | (surface.index, surface.name, |
202 | surface.colour, surface.volume, | 208 | surface.colour, surface.volume, |
203 | surface.transparency)) | 209 | surface.transparency)) |
204 | - | 210 | + |
205 | 211 | ||
206 | def OnCloseProject(self, pubsub_evt): | 212 | def OnCloseProject(self, pubsub_evt): |
207 | self.CloseProject() | 213 | self.CloseProject() |
@@ -218,7 +224,7 @@ class SurfaceManager(): | @@ -218,7 +224,7 @@ class SurfaceManager(): | ||
218 | # self.actors_dict. | 224 | # self.actors_dict. |
219 | proj = prj.Project() | 225 | proj = prj.Project() |
220 | surface = proj.surface_dict[index] | 226 | surface = proj.surface_dict[index] |
221 | - | 227 | + |
222 | ps.Publisher().sendMessage('Update surface info in GUI', | 228 | ps.Publisher().sendMessage('Update surface info in GUI', |
223 | (surface.index, surface.name, | 229 | (surface.index, surface.name, |
224 | surface.colour, surface.volume, | 230 | surface.colour, surface.volume, |
@@ -328,7 +334,7 @@ class SurfaceManager(): | @@ -328,7 +334,7 @@ class SurfaceManager(): | ||
328 | # Update progress value in GUI | 334 | # Update progress value in GUI |
329 | UpdateProgress = vu.ShowProgress(pipeline_size) | 335 | UpdateProgress = vu.ShowProgress(pipeline_size) |
330 | UpdateProgress(0, _("Generating 3D surface...")) | 336 | UpdateProgress(0, _("Generating 3D surface...")) |
331 | - | 337 | + |
332 | filename_img = tempfile.mktemp() | 338 | filename_img = tempfile.mktemp() |
333 | 339 | ||
334 | writer = vtk.vtkXMLImageDataWriter() | 340 | writer = vtk.vtkXMLImageDataWriter() |
@@ -445,7 +451,7 @@ class SurfaceManager(): | @@ -445,7 +451,7 @@ class SurfaceManager(): | ||
445 | 451 | ||
446 | ps.Publisher().sendMessage('Update status text in GUI', | 452 | ps.Publisher().sendMessage('Update status text in GUI', |
447 | _("Ready")) | 453 | _("Ready")) |
448 | - | 454 | + |
449 | ps.Publisher().sendMessage('Update surface info in GUI', | 455 | ps.Publisher().sendMessage('Update surface info in GUI', |
450 | (surface.index, surface.name, | 456 | (surface.index, surface.name, |
451 | surface.colour, surface.volume, | 457 | surface.colour, surface.volume, |
@@ -454,9 +460,9 @@ class SurfaceManager(): | @@ -454,9 +460,9 @@ class SurfaceManager(): | ||
454 | #Destroy Copy original imagedata | 460 | #Destroy Copy original imagedata |
455 | if(imagedata_tmp): | 461 | if(imagedata_tmp): |
456 | del imagedata_tmp | 462 | del imagedata_tmp |
457 | - | 463 | + |
458 | ps.Publisher().sendMessage('End busy cursor') | 464 | ps.Publisher().sendMessage('End busy cursor') |
459 | - | 465 | + |
460 | def RemoveActor(self, index): | 466 | def RemoveActor(self, index): |
461 | """ | 467 | """ |
462 | Remove actor, according to given actor index. | 468 | Remove actor, according to given actor index. |