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