Commit 0158ec5bee055134c74258b561b601b5f489ca5c
1 parent
1582c8e8
Exists in
master
and in
68 other branches
ADD: Surface connectivity tools
Showing
3 changed files
with
15 additions
and
5 deletions
Show diff stats
invesalius/data/polydata_utils.py
@@ -159,7 +159,7 @@ def SplitDisconectedParts(polydata): | @@ -159,7 +159,7 @@ def SplitDisconectedParts(polydata): | ||
159 | 159 | ||
160 | polydata_collection = [] | 160 | polydata_collection = [] |
161 | 161 | ||
162 | - for region in nregions: | 162 | + for region in xrange(nregions): |
163 | conn.InitializeSpecifiedRegionList() | 163 | conn.InitializeSpecifiedRegionList() |
164 | conn.AddSpecifiedRegion(region) | 164 | conn.AddSpecifiedRegion(region) |
165 | conn.Update() | 165 | conn.Update() |
invesalius/data/surface.py
@@ -127,6 +127,7 @@ class SurfaceManager(): | @@ -127,6 +127,7 @@ class SurfaceManager(): | ||
127 | 127 | ||
128 | def OnSeedSurface(self, pubsub_evt): | 128 | def OnSeedSurface(self, pubsub_evt): |
129 | index, points_id_list = pubsub_evt.data | 129 | index, points_id_list = pubsub_evt.data |
130 | + index = self.last_surface_index | ||
130 | proj = prj.Project() | 131 | proj = prj.Project() |
131 | surface = proj.surface_dict[index] | 132 | surface = proj.surface_dict[index] |
132 | 133 | ||
@@ -136,6 +137,7 @@ class SurfaceManager(): | @@ -136,6 +137,7 @@ class SurfaceManager(): | ||
136 | 137 | ||
137 | def OnSplitSurface(self, pubsub_evt): | 138 | def OnSplitSurface(self, pubsub_evt): |
138 | index = pubsub_evt.data | 139 | index = pubsub_evt.data |
140 | + index = self.last_surface_index | ||
139 | proj = prj.Project() | 141 | proj = prj.Project() |
140 | surface = proj.surface_dict[index] | 142 | surface = proj.surface_dict[index] |
141 | 143 | ||
@@ -145,11 +147,13 @@ class SurfaceManager(): | @@ -145,11 +147,13 @@ class SurfaceManager(): | ||
145 | 147 | ||
146 | def OnLargestSurface(self, pubsub_evt): | 148 | def OnLargestSurface(self, pubsub_evt): |
147 | index = pubsub_evt.data | 149 | index = pubsub_evt.data |
150 | + index = self.last_surface_index | ||
148 | proj = prj.Project() | 151 | proj = prj.Project() |
149 | surface = proj.surface_dict[index] | 152 | surface = proj.surface_dict[index] |
150 | 153 | ||
151 | new_polydata = pu.SelectLargestPart(surface.polydata) | 154 | new_polydata = pu.SelectLargestPart(surface.polydata) |
152 | self.CreateSurfaceFromPolydata(new_polydata) | 155 | self.CreateSurfaceFromPolydata(new_polydata) |
156 | + #TODO: Hide previous | ||
153 | 157 | ||
154 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): | 158 | def CreateSurfaceFromPolydata(self, polydata, overwrite=False): |
155 | mapper = vtk.vtkPolyDataMapper() | 159 | mapper = vtk.vtkPolyDataMapper() |
@@ -170,6 +174,7 @@ class SurfaceManager(): | @@ -170,6 +174,7 @@ class SurfaceManager(): | ||
170 | # Set actor colour and transparency | 174 | # Set actor colour and transparency |
171 | actor.GetProperty().SetColor(surface.colour) | 175 | actor.GetProperty().SetColor(surface.colour) |
172 | actor.GetProperty().SetOpacity(1-surface.transparency) | 176 | actor.GetProperty().SetOpacity(1-surface.transparency) |
177 | + self.actors_dict[surface.index] = actor | ||
173 | 178 | ||
174 | # Append surface into Project.surface_dict | 179 | # Append surface into Project.surface_dict |
175 | proj = prj.Project() | 180 | proj = prj.Project() |
@@ -185,8 +190,6 @@ class SurfaceManager(): | @@ -185,8 +190,6 @@ class SurfaceManager(): | ||
185 | 190 | ||
186 | # The following lines have to be here, otherwise all volumes disappear | 191 | # The following lines have to be here, otherwise all volumes disappear |
187 | measured_polydata = vtk.vtkMassProperties() | 192 | measured_polydata = vtk.vtkMassProperties() |
188 | - measured_polydata.AddObserver("ProgressEvent", lambda obj,evt: | ||
189 | - UpdateProgress(obj, _("Generating 3D surface..."))) | ||
190 | measured_polydata.SetInput(polydata) | 193 | measured_polydata.SetInput(polydata) |
191 | volume = measured_polydata.GetVolume() | 194 | volume = measured_polydata.GetVolume() |
192 | surface.volume = volume | 195 | surface.volume = volume |
@@ -194,6 +197,11 @@ class SurfaceManager(): | @@ -194,6 +197,11 @@ class SurfaceManager(): | ||
194 | 197 | ||
195 | ps.Publisher().sendMessage('Load surface actor into viewer', actor) | 198 | ps.Publisher().sendMessage('Load surface actor into viewer', actor) |
196 | 199 | ||
200 | + ps.Publisher().sendMessage('Update surface info in GUI', | ||
201 | + (surface.index, surface.name, | ||
202 | + surface.colour, surface.volume, | ||
203 | + surface.transparency)) | ||
204 | + | ||
197 | 205 | ||
198 | def OnCloseProject(self, pubsub_evt): | 206 | def OnCloseProject(self, pubsub_evt): |
199 | self.CloseProject() | 207 | self.CloseProject() |
invesalius/gui/task_surface.py
@@ -327,6 +327,7 @@ class SurfaceTools(wx.Panel): | @@ -327,6 +327,7 @@ class SurfaceTools(wx.Panel): | ||
327 | self.SelectSeed() | 327 | self.SelectSeed() |
328 | 328 | ||
329 | def OnButton(self, evt): | 329 | def OnButton(self, evt): |
330 | + id = evt.GetId() | ||
330 | if id == BTN_LARGEST: | 331 | if id == BTN_LARGEST: |
331 | self.SelectLargest() | 332 | self.SelectLargest() |
332 | elif id == BTN_SPLIT: | 333 | elif id == BTN_SPLIT: |
@@ -336,11 +337,12 @@ class SurfaceTools(wx.Panel): | @@ -336,11 +337,12 @@ class SurfaceTools(wx.Panel): | ||
336 | 337 | ||
337 | def SelectLargest(self): | 338 | def SelectLargest(self): |
338 | index = self.combo_surface_name.GetSelection() | 339 | index = self.combo_surface_name.GetSelection() |
339 | - ps.Publisher().sendMessage('Split surface', index) | 340 | + ps.Publisher().sendMessage('Create surface from largest region', index) |
340 | 341 | ||
341 | def SplitSurface(self): | 342 | def SplitSurface(self): |
342 | index = self.combo_surface_name.GetSelection() | 343 | index = self.combo_surface_name.GetSelection() |
343 | - ps.Publisher().sendMessage('Create surface from largest region', index) | 344 | + ps.Publisher().sendMessage('Split surface', index) |
345 | + | ||
344 | # surface_manager | 346 | # surface_manager |
345 | 347 | ||
346 | def SelectSeed(self): | 348 | def SelectSeed(self): |