Commit e62d86bdf8dd2c234db54e87b909b1f57c111b71
1 parent
a061025c
Exists in
master
and in
5 other branches
FIX: Fixed error in generate surface in the win32 and win64 ticket #271
Showing
3 changed files
with
60 additions
and
1 deletions
Show diff stats
.gitattributes
@@ -135,6 +135,7 @@ icons/zh_TW.bmp -text | @@ -135,6 +135,7 @@ icons/zh_TW.bmp -text | ||
135 | invesalius/.svnignore -text | 135 | invesalius/.svnignore -text |
136 | invesalius/data/bases.py -text | 136 | invesalius/data/bases.py -text |
137 | invesalius/data/co_registration.py -text | 137 | invesalius/data/co_registration.py -text |
138 | +invesalius/data/converters.py -text | ||
138 | invesalius/gui/preferences.py -text | 139 | invesalius/gui/preferences.py -text |
139 | locale/de/LC_MESSAGES/invesalius.mo -text | 140 | locale/de/LC_MESSAGES/invesalius.mo -text |
140 | locale/el/LC_MESSAGES/invesalius.mo -text | 141 | locale/el/LC_MESSAGES/invesalius.mo -text |
@@ -0,0 +1,58 @@ | @@ -0,0 +1,58 @@ | ||
1 | +#-------------------------------------------------------------------------- | ||
2 | +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas | ||
3 | +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer | ||
4 | +# Homepage: http://www.softwarepublico.gov.br | ||
5 | +# Contact: invesalius@cti.gov.br | ||
6 | +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt) | ||
7 | +#-------------------------------------------------------------------------- | ||
8 | +# Este programa e software livre; voce pode redistribui-lo e/ou | ||
9 | +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme | ||
10 | +# publicada pela Free Software Foundation; de acordo com a versao 2 | ||
11 | +# da Licenca. | ||
12 | +# | ||
13 | +# Este programa eh distribuido na expectativa de ser util, mas SEM | ||
14 | +# QUALQUER GARANTIA; sem mesmo a garantia implicita de | ||
15 | +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM | ||
16 | +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais | ||
17 | +# detalhes. | ||
18 | +#-------------------------------------------------------------------------- | ||
19 | + | ||
20 | +import numpy | ||
21 | +import vtk | ||
22 | +from vtk.util import numpy_support | ||
23 | + | ||
24 | +def to_vtk(n_array, spacing, slice_number, orientation): | ||
25 | + try: | ||
26 | + dz, dy, dx = n_array.shape | ||
27 | + except ValueError: | ||
28 | + dy, dx = n_array.shape | ||
29 | + dz = 1 | ||
30 | + | ||
31 | + v_image = numpy_support.numpy_to_vtk(n_array.flat) | ||
32 | + | ||
33 | + if orientation == 'AXIAL': | ||
34 | + extent = (0, dx -1, 0, dy -1, slice_number, slice_number + dz - 1) | ||
35 | + elif orientation == 'SAGITAL': | ||
36 | + dx, dy, dz = dz, dx, dy | ||
37 | + extent = (slice_number, slice_number + dx - 1, 0, dy - 1, 0, dz - 1) | ||
38 | + elif orientation == 'CORONAL': | ||
39 | + dx, dy, dz = dx, dz, dy | ||
40 | + extent = (0, dx - 1, slice_number, slice_number + dy - 1, 0, dz - 1) | ||
41 | + | ||
42 | + # Generating the vtkImageData | ||
43 | + image = vtk.vtkImageData() | ||
44 | + image.SetOrigin(0, 0, 0) | ||
45 | + image.SetSpacing(spacing) | ||
46 | + image.SetNumberOfScalarComponents(1) | ||
47 | + image.SetDimensions(dx, dy, dz) | ||
48 | + image.SetExtent(extent) | ||
49 | + image.SetScalarType(numpy_support.get_vtk_array_type(n_array.dtype)) | ||
50 | + image.AllocateScalars() | ||
51 | + image.GetPointData().SetScalars(v_image) | ||
52 | + image.Update() | ||
53 | + | ||
54 | + image_copy = vtk.vtkImageData() | ||
55 | + image_copy.DeepCopy(image) | ||
56 | + image_copy.Update() | ||
57 | + | ||
58 | + return image_copy |
invesalius/data/surface_process.py
@@ -6,7 +6,7 @@ import numpy | @@ -6,7 +6,7 @@ import numpy | ||
6 | import vtk | 6 | import vtk |
7 | 7 | ||
8 | import i18n | 8 | import i18n |
9 | -import converters | 9 | +import data.converters |
10 | from scipy import ndimage | 10 | from scipy import ndimage |
11 | 11 | ||
12 | class SurfaceProcess(multiprocessing.Process): | 12 | class SurfaceProcess(multiprocessing.Process): |