From 7473cd4458c8a31fa904d522ea26596599cfd18e Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Tue, 16 Apr 2013 23:00:06 +0100 Subject: [PATCH] Slightly simplify the Python code in the example This is in preparation for the Python bindings manual chapter I'm writing at the moment. --- examples/Python/PythonExample.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/Python/PythonExample.py b/examples/Python/PythonExample.py index 2a688971..2d194e9d 100755 --- a/examples/Python/PythonExample.py +++ b/examples/Python/PythonExample.py @@ -39,17 +39,15 @@ sphereRadius = 30 for z in range(vol.getDepth()): for y in range(vol.getHeight()): for x in range(vol.getWidth()): - #Store our current position as a vector... - v3dCurrentPos = pv.Vector3Dint32_t(x,y,z) - #And compute how far the current position is from the center of the volume - fDistToCenter = (v3dCurrentPos - v3dVolCenter).length() - - uVoxelValue = 0 + #Compute how far the current position is from the center of the volume + fDistToCenter = (pv.Vector3Dint32_t(x,y,z) - v3dVolCenter).length() #If the current voxel is less than 'radius' units from the center then we make it solid. if(fDistToCenter <= sphereRadius): #Our new voxel value uVoxelValue = 255 + else: + uVoxelValue = 0 #Write the voxel value into the volume vol.setVoxelAt(x, y, z, uVoxelValue);