Skip to main content

Python package for building isosurfaces from 3D scalar fields

Project description

PyTessel

C/C++ CI Anaconda-Server Badge PyPI License: GPL v3

Purpose

Python package for building isosurfaces from 3D scalar fields

Installation

Anaconda

Anaconda version Anaconda last release Anaconda platforms Anaconda downloads

conda install -c ifilot pyqint

PyPi

PyPI PyPI - Downloads PyPI - Python Version

pip install pytessel

Usage

from pytessel import PyTessel
import numpy as np

def main():
    pytessel = PyTessel()

    # generate some data
    x = np.linspace(0, 10, 50)
    # the grid is organized with z the slowest moving index and x the fastest moving index
    grid = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T

    R = [5,5,5]
    scalarfield = np.reshape(np.array([gaussian(r,R) for r in grid]), (len(x),len(x),len(x)))
    unitcell = np.diag(np.ones(3) * 10.0)

    vertices, normals, indices = pytessel.marching_cubes(scalarfield.flatten(), scalarfield.shape, unitcell.flatten(), 0.1)

    pytessel.write_ply('test.ply', vertices, normals, indices)

def gaussian(r, R):
    return np.exp(-(r-R).dot((r-R)))

if __name__ == '__main__':
    main()

The isosurface is written to test.ply and can, for example, be opened using ctmviewer.

Isosurface of Gaussian

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pytessel-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (490.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pytessel-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (476.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pytessel-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (480.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pytessel-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pytessel-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (465.8 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page