Commit 9e1e532619cbd016be742e14b789fa702a869699
Committed by
Thiago Franco de Moraes
1 parent
50f903c2
Exists in
master
create polydata from the imported stl (#210)
Showing
3 changed files
with
14 additions
and
7 deletions
Show diff stats
invesalius/data/viewer_volume.py
| ... | ... | @@ -184,6 +184,7 @@ class Viewer(wx.Panel): |
| 184 | 184 | self.aim_actor = None |
| 185 | 185 | self.dummy_coil_actor = None |
| 186 | 186 | self.target_mode = False |
| 187 | + self.polydata = None | |
| 187 | 188 | self.anglethreshold = const.COIL_ANGLES_THRESHOLD |
| 188 | 189 | self.distthreshold = const.COIL_COORD_THRESHOLD |
| 189 | 190 | |
| ... | ... | @@ -916,7 +917,10 @@ class Viewer(wx.Panel): |
| 916 | 917 | self.aim_actor = aim_actor |
| 917 | 918 | self.ren.AddActor(aim_actor) |
| 918 | 919 | |
| 919 | - obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) | |
| 920 | + if self.polydata: | |
| 921 | + obj_polydata = self.polydata | |
| 922 | + else: | |
| 923 | + obj_polydata = self.CreateObjectPolyData(os.path.join(inv_paths.OBJ_DIR, "magstim_fig8_coil_no_handle.stl")) | |
| 920 | 924 | |
| 921 | 925 | transform = vtk.vtkTransform() |
| 922 | 926 | transform.RotateZ(90) |
| ... | ... | @@ -1254,9 +1258,10 @@ class Viewer(wx.Panel): |
| 1254 | 1258 | |
| 1255 | 1259 | self.Refresh() |
| 1256 | 1260 | |
| 1257 | - def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): | |
| 1261 | + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None, polydata=None): | |
| 1258 | 1262 | if flag: |
| 1259 | 1263 | self.obj_name = obj_name |
| 1264 | + self.polydata = polydata | |
| 1260 | 1265 | if not self.obj_actor: |
| 1261 | 1266 | self.AddObjectActor(self.obj_name) |
| 1262 | 1267 | else: | ... | ... |
invesalius/gui/dialogs.py
| ... | ... | @@ -3328,6 +3328,7 @@ class ObjectCalibrationDialog(wx.Dialog): |
| 3328 | 3328 | self.trk_init = nav_prop[1] |
| 3329 | 3329 | self.obj_ref_id = 2 |
| 3330 | 3330 | self.obj_name = None |
| 3331 | + self.polydata = None | |
| 3331 | 3332 | |
| 3332 | 3333 | self.obj_fiducials = np.full([5, 3], np.nan) |
| 3333 | 3334 | self.obj_orients = np.full([5, 3], np.nan) |
| ... | ... | @@ -3471,6 +3472,7 @@ class ObjectCalibrationDialog(wx.Dialog): |
| 3471 | 3472 | reader.SetFileName(self.obj_name) |
| 3472 | 3473 | reader.Update() |
| 3473 | 3474 | polydata = reader.GetOutput() |
| 3475 | + self.polydata = polydata | |
| 3474 | 3476 | |
| 3475 | 3477 | if polydata.GetNumberOfPoints() == 0: |
| 3476 | 3478 | wx.MessageBox(_("InVesalius was not able to import this surface"), _("Import surface error")) |
| ... | ... | @@ -3588,7 +3590,7 @@ class ObjectCalibrationDialog(wx.Dialog): |
| 3588 | 3590 | self.obj_ref_id = 0 |
| 3589 | 3591 | |
| 3590 | 3592 | def GetValue(self): |
| 3591 | - return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name | |
| 3593 | + return self.obj_fiducials, self.obj_orients, self.obj_ref_id, self.obj_name, self.polydata | |
| 3592 | 3594 | |
| 3593 | 3595 | |
| 3594 | 3596 | class SurfaceProgressWindow(object): | ... | ... |
invesalius/gui/task_navigator.py
| ... | ... | @@ -251,7 +251,7 @@ class InnerFoldPanel(wx.Panel): |
| 251 | 251 | def OnExternalTrigger(self, evt, ctrl): |
| 252 | 252 | Publisher.sendMessage('Update trigger state', trigger_state=ctrl.GetValue()) |
| 253 | 253 | |
| 254 | - def OnShowObject(self, evt=None, flag=None, obj_name=None): | |
| 254 | + def OnShowObject(self, evt=None, flag=None, obj_name=None, polydata=None): | |
| 255 | 255 | if not evt: |
| 256 | 256 | if flag: |
| 257 | 257 | self.checkobj.Enable(True) |
| ... | ... | @@ -436,7 +436,7 @@ class NeuronavigationPanel(wx.Panel): |
| 436 | 436 | self.obj_reg = None |
| 437 | 437 | self.obj_reg_status = False |
| 438 | 438 | |
| 439 | - def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None): | |
| 439 | + def UpdateTrackObjectState(self, evt=None, flag=None, obj_name=None, polydata=None): | |
| 440 | 440 | self.track_obj = flag |
| 441 | 441 | |
| 442 | 442 | def UpdateTriggerState(self, trigger_state): |
| ... | ... | @@ -882,7 +882,7 @@ class ObjectRegistrationPanel(wx.Panel): |
| 882 | 882 | dialog = dlg.ObjectCalibrationDialog(self.nav_prop) |
| 883 | 883 | try: |
| 884 | 884 | if dialog.ShowModal() == wx.ID_OK: |
| 885 | - self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name = dialog.GetValue() | |
| 885 | + self.obj_fiducials, self.obj_orients, self.obj_ref_mode, self.obj_name, polydata = dialog.GetValue() | |
| 886 | 886 | if np.isfinite(self.obj_fiducials).all() and np.isfinite(self.obj_orients).all(): |
| 887 | 887 | self.checktrack.Enable(1) |
| 888 | 888 | Publisher.sendMessage('Update object registration', |
| ... | ... | @@ -891,7 +891,7 @@ class ObjectRegistrationPanel(wx.Panel): |
| 891 | 891 | label=_("Ready")) |
| 892 | 892 | # Enable automatically Track object, Show coil and disable Vol. Camera |
| 893 | 893 | self.checktrack.SetValue(True) |
| 894 | - Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name) | |
| 894 | + Publisher.sendMessage('Update track object state', flag=True, obj_name=self.obj_name, polydata=polydata) | |
| 895 | 895 | Publisher.sendMessage('Change camera checkbox', status=False) |
| 896 | 896 | |
| 897 | 897 | except wx._core.PyAssertionError: # TODO FIX: win64 | ... | ... |