Commit 254789ee65f8e2b0f9e795664e42bf98d154ab89
1 parent
81df591f
Exists in
master
and in
6 other branches
ENH: Remove temp file
Showing
1 changed file
with
10 additions
and
6 deletions
Show diff stats
invesalius/data/surface.py
... | ... | @@ -297,10 +297,10 @@ class SurfaceManager(): |
297 | 297 | |
298 | 298 | # Update progress value in GUI |
299 | 299 | |
300 | - filename = tempfile.mktemp() | |
300 | + filename_img = tempfile.mktemp() | |
301 | 301 | |
302 | 302 | writer = vtk.vtkXMLImageDataWriter() |
303 | - writer.SetFileName(filename) | |
303 | + writer.SetFileName(filename_img) | |
304 | 304 | writer.SetInput(imagedata) |
305 | 305 | writer.Write() |
306 | 306 | |
... | ... | @@ -308,7 +308,7 @@ class SurfaceManager(): |
308 | 308 | UpdateProgress = vu.ShowProgress(pipeline_size) |
309 | 309 | |
310 | 310 | conn_in, conn_out = multiprocessing.Pipe() |
311 | - sp = SurfaceProcess(conn_in, filename, mode, min_value, max_value, | |
311 | + sp = SurfaceProcess(conn_in, filename_img, mode, min_value, max_value, | |
312 | 312 | decimate_reduction, smooth_relaxation_factor, |
313 | 313 | smooth_iterations) |
314 | 314 | sp.start() |
... | ... | @@ -319,10 +319,10 @@ class SurfaceManager(): |
319 | 319 | break |
320 | 320 | UpdateProgress(msg[0],msg[1]) |
321 | 321 | |
322 | - filename = conn_out.recv() | |
322 | + filename_polydata = conn_out.recv() | |
323 | 323 | |
324 | 324 | reader = vtk.vtkXMLPolyDataReader() |
325 | - reader.SetFileName(filename) | |
325 | + reader.SetFileName(filename_polydata) | |
326 | 326 | reader.Update() |
327 | 327 | |
328 | 328 | polydata = reader.GetOutput() |
... | ... | @@ -351,7 +351,11 @@ class SurfaceManager(): |
351 | 351 | # Set actor colour and transparency |
352 | 352 | actor.GetProperty().SetColor(colour) |
353 | 353 | actor.GetProperty().SetOpacity(1-surface.transparency) |
354 | - | |
354 | + | |
355 | + #Remove all temp file | |
356 | + os.remove(filename_img) | |
357 | + os.remove(filename_polydata) | |
358 | + | |
355 | 359 | # Append surface into Project.surface_dict |
356 | 360 | proj = prj.Project() |
357 | 361 | index = proj.AddSurface(surface) | ... | ... |