Skip to main content

A fast triangular implementation

Project description

tmesh

Fast operators for triangular meshes.

Getting Started

tmesh is available on PyPI:

pip install tmesh

See the examples directory to see how to use the package.

The following script demonstrates how to use the package to generate an STL or OBJ file from a simple mesh:

import math

from tmesh import regular_polygon_mesh, Affine2D, linear_extrude

# Create a cuboid.
a = regular_polygon_mesh(1.0, n=4)
b = regular_polygon_mesh(1.0, n=4)

# Move the second cuboid around.
rot = Affine2D(rot=math.pi / 4)
trans = Affine2D(trans=(0.0, 0.5))
b <<= rot @ trans

# Gets the union of A and B.
c = a | b

# Extrudes the 2D mesh to a 3D mesh with height 1.0.
mesh = linear_extrude(c, 1.0)

# Save the resulting mesh.
from tmesh import save_stl, save_stl_text, save_obj, save_ply

save_stl_text("simple_example_ascii.stl", mesh)
save_stl("simple_example.stl", mesh)
save_obj("simple_example.obj", mesh)
save_ply("simple_example.ply", mesh)

Motivation

At various times I have wished there were something like OpenSCAD for Python. Packages like trimesh exist, but they come with a number of clunky dependencies (including, interestingly enough, OpenSCAD itself). This package is a standalone implementation of the core functionality of OpenSCAD, but with a Pythonic API, making it easy to integrate into existing Python code. It is also written in pure C++, so it's hopefully relatively fast.

Project details


Download files

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

Source Distribution

tmesh-0.0.14.tar.gz (63.0 kB view hashes)

Uploaded Source

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