Commit 7d82f0c0a33e35b812520a4da8eabe4aaaf3515a
1 parent
b5d8f652
Exists in
surface_area
Calculating surface area
Showing
2 changed files
with
30 additions
and
12 deletions
Show diff stats
invesalius/data/surface.py
@@ -59,7 +59,8 @@ class Surface(): | @@ -59,7 +59,8 @@ class Surface(): | ||
59 | self.polydata = '' | 59 | self.polydata = '' |
60 | self.colour = '' | 60 | self.colour = '' |
61 | self.transparency = const.SURFACE_TRANSPARENCY | 61 | self.transparency = const.SURFACE_TRANSPARENCY |
62 | - self.volume = 0 | 62 | + self.volume = 0.0 |
63 | + self.area = 0.0 | ||
63 | self.is_shown = 1 | 64 | self.is_shown = 1 |
64 | if not name: | 65 | if not name: |
65 | self.name = const.SURFACE_NAME_PATTERN %(self.index+1) | 66 | self.name = const.SURFACE_NAME_PATTERN %(self.index+1) |
@@ -81,6 +82,7 @@ class Surface(): | @@ -81,6 +82,7 @@ class Surface(): | ||
81 | 'transparency': self.transparency, | 82 | 'transparency': self.transparency, |
82 | 'visible': bool(self.is_shown), | 83 | 'visible': bool(self.is_shown), |
83 | 'volume': self.volume, | 84 | 'volume': self.volume, |
85 | + 'area': self.area, | ||
84 | } | 86 | } |
85 | plist_filename = filename + '.plist' | 87 | plist_filename = filename + '.plist' |
86 | #plist_filepath = os.path.join(dir_temp, filename + '.plist') | 88 | #plist_filepath = os.path.join(dir_temp, filename + '.plist') |
@@ -100,6 +102,10 @@ class Surface(): | @@ -100,6 +102,10 @@ class Surface(): | ||
100 | self.transparency = sp['transparency'] | 102 | self.transparency = sp['transparency'] |
101 | self.is_shown = sp['visible'] | 103 | self.is_shown = sp['visible'] |
102 | self.volume = sp['volume'] | 104 | self.volume = sp['volume'] |
105 | + try: | ||
106 | + self.area = sp['area'] | ||
107 | + except KeyError: | ||
108 | + self.area = 0.0 | ||
103 | self.polydata = pu.Import(os.path.join(dirpath, sp['polydata'])) | 109 | self.polydata = pu.Import(os.path.join(dirpath, sp['polydata'])) |
104 | Surface.general_index = max(Surface.general_index, self.index) | 110 | Surface.general_index = max(Surface.general_index, self.index) |
105 | 111 | ||
@@ -299,7 +305,9 @@ class SurfaceManager(): | @@ -299,7 +305,9 @@ class SurfaceManager(): | ||
299 | measured_polydata.SetInputConnection(triangle_filter.GetOutputPort()) | 305 | measured_polydata.SetInputConnection(triangle_filter.GetOutputPort()) |
300 | measured_polydata.Update() | 306 | measured_polydata.Update() |
301 | volume = measured_polydata.GetVolume() | 307 | volume = measured_polydata.GetVolume() |
308 | + area = measured_polydata.GetSurfaceArea() | ||
302 | surface.volume = volume | 309 | surface.volume = volume |
310 | + surface.area = area | ||
303 | print ">>>>", surface.volume | 311 | print ">>>>", surface.volume |
304 | else: | 312 | else: |
305 | surface.volume = volume | 313 | surface.volume = volume |
@@ -377,8 +385,8 @@ class SurfaceManager(): | @@ -377,8 +385,8 @@ class SurfaceManager(): | ||
377 | # The following lines have to be here, otherwise all volumes disappear | 385 | # The following lines have to be here, otherwise all volumes disappear |
378 | Publisher.sendMessage('Update surface info in GUI', | 386 | Publisher.sendMessage('Update surface info in GUI', |
379 | (surface.index, surface.name, | 387 | (surface.index, surface.name, |
380 | - surface.colour, surface.volume, | ||
381 | - surface.transparency)) | 388 | + surface.colour, surface.volume, |
389 | + surface.area, surface.transparency)) | ||
382 | if not surface.is_shown: | 390 | if not surface.is_shown: |
383 | self.ShowActor(key, False) | 391 | self.ShowActor(key, False) |
384 | 392 | ||
@@ -727,7 +735,9 @@ class SurfaceManager(): | @@ -727,7 +735,9 @@ class SurfaceManager(): | ||
727 | # measured_polydata.ReleaseDataFlagOn() | 735 | # measured_polydata.ReleaseDataFlagOn() |
728 | measured_polydata.SetInputData(to_measure) | 736 | measured_polydata.SetInputData(to_measure) |
729 | volume = float(measured_polydata.GetVolume()) | 737 | volume = float(measured_polydata.GetVolume()) |
738 | + area = float(measured_polydata.GetSurfaceArea()) | ||
730 | surface.volume = volume | 739 | surface.volume = volume |
740 | + surface.area = area | ||
731 | self.last_surface_index = surface.index | 741 | self.last_surface_index = surface.index |
732 | del measured_polydata | 742 | del measured_polydata |
733 | del to_measure | 743 | del to_measure |
@@ -745,6 +755,7 @@ class SurfaceManager(): | @@ -745,6 +755,7 @@ class SurfaceManager(): | ||
745 | Publisher.sendMessage('Update surface info in GUI', | 755 | Publisher.sendMessage('Update surface info in GUI', |
746 | (surface.index, surface.name, | 756 | (surface.index, surface.name, |
747 | surface.colour, surface.volume, | 757 | surface.colour, surface.volume, |
758 | + surface.area, | ||
748 | surface.transparency)) | 759 | surface.transparency)) |
749 | 760 | ||
750 | #When you finalize the progress. The bar is cleaned. | 761 | #When you finalize the progress. The bar is cleaned. |
invesalius/gui/data_notebook.py
@@ -769,12 +769,14 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -769,12 +769,14 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
769 | self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) | 769 | self.InsertColumn(0, "", wx.LIST_FORMAT_CENTER) |
770 | self.InsertColumn(1, _("Name")) | 770 | self.InsertColumn(1, _("Name")) |
771 | self.InsertColumn(2, _(u"Volume (mm³)")) | 771 | self.InsertColumn(2, _(u"Volume (mm³)")) |
772 | - self.InsertColumn(3, _("Transparency"), wx.LIST_FORMAT_RIGHT) | 772 | + self.InsertColumn(3, _(u"Area (mm²)")) |
773 | + self.InsertColumn(4, _("Transparency"), wx.LIST_FORMAT_RIGHT) | ||
773 | 774 | ||
774 | self.SetColumnWidth(0, 25) | 775 | self.SetColumnWidth(0, 25) |
775 | self.SetColumnWidth(1, 85) | 776 | self.SetColumnWidth(1, 85) |
776 | self.SetColumnWidth(2, 85) | 777 | self.SetColumnWidth(2, 85) |
777 | - self.SetColumnWidth(3, 80) | 778 | + self.SetColumnWidth(3, 85) |
779 | + self.SetColumnWidth(4, 80) | ||
778 | 780 | ||
779 | def __init_image_list(self): | 781 | def __init_image_list(self): |
780 | self.imagelist = wx.ImageList(16, 16) | 782 | self.imagelist = wx.ImageList(16, 16) |
@@ -834,7 +836,8 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -834,7 +836,8 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
834 | name = pubsub_evt.data[1] | 836 | name = pubsub_evt.data[1] |
835 | colour = pubsub_evt.data[2] | 837 | colour = pubsub_evt.data[2] |
836 | volume = "%.3f"%pubsub_evt.data[3] | 838 | volume = "%.3f"%pubsub_evt.data[3] |
837 | - transparency = "%d%%"%(int(100*pubsub_evt.data[4])) | 839 | + area = "%.3f"%pubsub_evt.data[4] |
840 | + transparency = "%d%%"%(int(100*pubsub_evt.data[5])) | ||
838 | 841 | ||
839 | if index not in self.surface_list_index: | 842 | if index not in self.surface_list_index: |
840 | image = self.CreateColourBitmap(colour) | 843 | image = self.CreateColourBitmap(colour) |
@@ -844,25 +847,29 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | @@ -844,25 +847,29 @@ class SurfacesListCtrlPanel(wx.ListCtrl, listmix.TextEditMixin): | ||
844 | self.surface_list_index[index] = image_index | 847 | self.surface_list_index[index] = image_index |
845 | 848 | ||
846 | if (index in index_list) and index_list: | 849 | if (index in index_list) and index_list: |
847 | - self.UpdateItemInfo(index, name, volume, transparency, colour) | 850 | + self.UpdateItemInfo(index, name, volume, area, transparency, colour) |
848 | else: | 851 | else: |
849 | - self.InsertNewItem(index, name, volume, transparency, colour) | 852 | + self.InsertNewItem(index, name, volume, area, transparency, colour) |
850 | 853 | ||
851 | def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3", | 854 | def InsertNewItem(self, index=0, label="Surface 1", volume="0 mm3", |
852 | - transparency="0%%", colour=None): | 855 | + area="0 mm2", transparency="0%%", colour=None): |
853 | self.InsertStringItem(index, "") | 856 | self.InsertStringItem(index, "") |
857 | + print ">>>>AREA<<<<<<", area | ||
858 | + print ">>>>AREA<<<<<<", transparency | ||
854 | self.SetStringItem(index, 1, label, | 859 | self.SetStringItem(index, 1, label, |
855 | imageId = self.surface_list_index[index]) | 860 | imageId = self.surface_list_index[index]) |
856 | self.SetStringItem(index, 2, volume) | 861 | self.SetStringItem(index, 2, volume) |
857 | - self.SetStringItem(index, 3, transparency) | 862 | + self.SetStringItem(index, 3, area) |
863 | + self.SetStringItem(index, 4, transparency) | ||
858 | self.SetItemImage(index, 1) | 864 | self.SetItemImage(index, 1) |
859 | 865 | ||
860 | def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3", | 866 | def UpdateItemInfo(self, index=0, label="Surface 1", volume="0 mm3", |
861 | - transparency="0%%", colour=None): | 867 | + area="0 mm2", transparency="0%%", colour=None): |
862 | self.SetStringItem(index, 1, label, | 868 | self.SetStringItem(index, 1, label, |
863 | imageId = self.surface_list_index[index]) | 869 | imageId = self.surface_list_index[index]) |
864 | self.SetStringItem(index, 2, volume) | 870 | self.SetStringItem(index, 2, volume) |
865 | - self.SetStringItem(index, 3, transparency) | 871 | + self.SetStringItem(index, 3, area) |
872 | + self.SetStringItem(index, 4, transparency) | ||
866 | self.SetItemImage(index, 1) | 873 | self.SetItemImage(index, 1) |
867 | 874 | ||
868 | def CreateColourBitmap(self, colour): | 875 | def CreateColourBitmap(self, colour): |