0

I'm analyzing several files containing volumetric data reported as Gaussian Cube File Format (click here for the description).

I created this script in Python to compute and represent the isosurfaces using numpy and skimage:

    import numpy as np
    import matplotlib.pyplot as plt
    from mpl_toolkits.mplot3d.art3d import Poly3DCollection
    from skimage import measure
    from skimage.draw import ellipsoid
    import load_cube

# create an object and read in data from file 
    cube=load_cube.CUBE(gaussian_cube_file.cube)

# Obtain the surface mesh setting a specific isovalue (0.2)
    verts, faces = measure.marching_cubes(cube.data, 0.2)

# Display resulting triangular mesh using Matplotlib. 
    fig = plt.figure(figsize=(10, 12))
    ax = fig.add_subplot(111, projection='3d')

# Generate triangles
    mesh = Poly3DCollection(verts[faces])
    ax.add_collection3d(mesh)

    ax.set_xlabel("x-axis: a = 6")
    ax.set_ylabel("y-axis: b = 10")
    ax.set_zlabel("z-axis: c = 16")

    ax.set_xlim(0, 100)  
    ax.set_ylim(0, 100)  
    ax.set_zlim(0, 100) 

    plt.show()

Results from the previous script

The questions are: how I can compute the total area of all isosurfaces showed in the resulting plot? How I can color each triangle on the basis of its value?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • Your isosurface consists of triangles. You can sum up areas of the triangles to get the total area. – paceholder Apr 22 '16 at 14:42
  • First, thanks for the answer. i was just looking for a simple way to do it starting from vertices and faces. –  Apr 22 '16 at 14:46
  • I think I found a solution using " measure.mesh_surface_area(verts, faces)" from skimage module. It compute surface area, given vertices & triangular faces, and the arguments expected by this function are the exact outputs from skimage.measure.marching_cubes. This algorithm works properly only if the faces provided are all triangles. –  Apr 22 '16 at 15:04

0 Answers0