Geometry Generation¶

Geometry builder¶

class meshpy.geometry.GeometryBuilder[source]¶
add_geometry(points, facets, facet_hole_starts=None, facet_markers=None, point_markers=None)[source]¶
set(mesh_info)[source]¶

Transfer the built geometry into a meshpy.triangle.MeshInfo or a meshpy.tet.MeshInfo.

wrap_in_box(distance, subdivisions=None)[source]¶
Parameters:

subdivisions – is a tuple of integers specifying the number of subdivisions along each axis.

bounding_box()[source]¶
center()[source]¶
apply_transform(f)[source]¶

Geometries¶

These functions are designed so that their output can be splat-passed to GeometryBuilder.add_geometry():

builder = GeometryBuilder()
builder.add_geometry(*make_ball(10))
class meshpy.geometry.Marker[source]¶
FIRST_USER_MARKER = 1000¶
MINUS_X = 1¶
MINUS_Y = 3¶
MINUS_Z = 5¶
PLUS_X = 2¶
PLUS_Y = 4¶
PLUS_Z = 6¶
SHELL = 100¶
meshpy.geometry.make_box(a, b, subdivisions=None)[source]¶
Parameters:

subdivisions – is a tuple of integers specifying the number of subdivisions along each axis.

meshpy.geometry.make_circle(r, center=(0, 0), subdivisions=40, marker=100)[source]¶
meshpy.geometry.make_ball(r, subdivisions=10)[source]¶
meshpy.geometry.make_cylinder(radius, height, radial_subdivisions=10, height_subdivisions=1)[source]¶

Extrusions and surfaces of revolution¶

meshpy.geometry.EXT_OPEN¶
meshpy.geometry.EXT_CLOSED_IN_RZ¶
meshpy.geometry.generate_extrusion(rz_points, base_shape, closure=0, point_idx_offset=0, ring_point_indices=None, ring_markers=None, rz_closure_marker=0)[source]¶

Extrude a given connected base_shape (a list of (x,y) points) along the z axis. For each step in the extrusion, the base shape is multiplied by a radius and shifted in the z direction. Radius and z offset are given by rz_points, which is a list of (r, z) tuples.

Returns (points, facets, facet_holestarts, markers), where points is a list of (3D) points and facets is a list of polygons. Each polygon is, in turn, represented by a tuple of indices into points. If point_idx_offset is not zero, these indices start at that number. markers is a list equal in length to facets, each specifying the facet marker of that facet. facet_holestarts is also equal in length to facets, each element is a list of hole starting points for the corresponding facet.

Use set_facets_ex() to add the extrusion to a MeshInfo structure.

The extrusion proceeds by generating quadrilaterals connecting each ring. If any given radius in rz_points is 0, triangle fans are produced instead of quads to provide non-degenerate closure.

If closure is EXT_OPEN, no efforts are made to put end caps on the extrusion.

If closure is EXT_CLOSED_IN_RZ, then a torus-like structure is assumed and the last ring is just connected to the first.

If ring_markers is not None, it is an list of markers added to each ring. There should be len(rz_points)-1 entries in this list. If rings are added because of closure options, they receive the corresponding XXX_closure_marker. If facet_markers is given, this function returns (points, facets, markers), where markers is is a list containing a marker for each generated facet. Unspecified markers generally default to 0.

If ring_point_indices is given, it must be a list of the same length as rz_points. Each entry in the list may either be None, or a list of point indices. This list must contain the same number of points as the base_shape; it is taken as the indices of pre-existing points that are to be used for the given ring, instead of generating new points.

meshpy.geometry.generate_surface_of_revolution(rz_points, closure=0, radial_subdiv=16, point_idx_offset=0, ring_point_indices=None, ring_markers=None, rz_closure_marker=0)[source]¶