Skip to main content

No project description provided

Project description

gdmesh

gdmesh is a lightweight Python mesh utility library. It provides tools for mesh management, format-agnostic I/O, and remeshing capabilities, built on top of pyvista.

Installation

pip install gd-mesh-utils

Quick Start

1. Creating Meshes

Create meshes from points and cells:

import numpy as np
import gdmesh as gm

# Create a triangle mesh
points = np.array([
    [0, 0, 0],
    [1, 0, 0],
    [0.5, 1, 0],
])
cells = {"triangle": np.array([[0, 1, 2]])}
mesh = gm.Mesh(points=points, cells=cells)

2. Loading and Saving Meshes

Load and save meshes in various formats using meshio:

import gdmesh as gm

# Load mesh from file
mesh = gm.Mesh.load("input.stl")

# Or use convenience function
mesh = gm.load_mesh("input.vtk")

# Save mesh to file
mesh.save("output.obj")

3. Accessing Mesh Data

Access mesh components as numpy arrays:

# Get point coordinates
points = mesh.points  # Shape: (n_points, 3)

# Get cells
cells = mesh.cells  # Dict: {"triangle": array, ...}

# Get point and cell data
point_data = mesh.point_data  # Dict of arrays
cell_data = mesh.cell_data    # Dict of arrays

4. Remeshing

Remesh surfaces and volumes using pymmg (mmgs/mmg3d under the hood):

# Surface remeshing
remeshed = mesh.remesh_surface()

# Volume remeshing
remeshed = mesh.remesh_volume()

# Optional: provide MMG options
from gdmesh.remesh import MmgOptions
opts = MmgOptions(hmax=0.3, hmin=0.05, hausd=0.01, hgrad=1.3)
remeshed = mesh.remesh_surface(mmg_args=opts)

5. PyVista Integration

Access underlying pyvista mesh for advanced operations:

# Direct access to pyvista mesh
pv_mesh = mesh.pv_mesh

# Use any pyvista functionality
pv_mesh.plot()
pv_mesh.compute_normals()

6. Integration with gdutils

Use with gdutils Container for organized mesh management:

import gdutils as gd
import gdmesh as gm

out = gd.fPath(__file__, "out")
with gd.Container(out / "meshes") as ct:
    # Load mesh
    mesh = gm.Mesh.load("input.stl")
    
    # Remesh
    remeshed = mesh.remesh_surface()
    
    # Save to container
    remeshed.save(ct / "remeshed.stl")
    
# Access later
print(ct.remeshed)  # Path to remeshed mesh

Features

  • Mesh Types: Support for points, lines, triangles, and tetrahedra in 3D
  • Format Agnostic: Read/write many formats via meshio (STL, OBJ, VTK, PLY, etc.)
  • Remeshing: Surface and volume remeshing using pymmg
  • PyVista Wrapper: Full access to pyvista functionality
  • Clean API: Simple, intuitive interface similar to gdutils

Supported Mesh Types

  • Points: Point clouds
  • Lines: Line segments
  • Triangles: Triangular surface meshes
  • Tetrahedra: Tetrahedral volume meshes

Supported Formats

All formats supported by meshio, including:

  • STL, OBJ, PLY
  • VTK, VTP, VTU
  • Gmsh (.msh)
  • Abaqus (.inp)
  • And many more...

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

gd_mesh_utils-0.0.1.tar.gz (95.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gd_mesh_utils-0.0.1-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file gd_mesh_utils-0.0.1.tar.gz.

File metadata

  • Download URL: gd_mesh_utils-0.0.1.tar.gz
  • Upload date:
  • Size: 95.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for gd_mesh_utils-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c153688096bdb66db541cdac883337240cefa16c1f76e41c3163de3b6ebb7db2
MD5 ebd43c85aa800e684963b91fe7a1595f
BLAKE2b-256 9d779b8faadf49231b7fb0d5bdbbe7907065331500c32acfc58a0e6629660cc7

See more details on using hashes here.

File details

Details for the file gd_mesh_utils-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gd_mesh_utils-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for gd_mesh_utils-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0da3ee2575461a8c4e31491d252a73d12ab54cc2af097627479533ce9afee9d5
MD5 2e11462c13dec45cdc0e3f9d5262898a
BLAKE2b-256 ad68fd66b149908ff0f228d997d221160772ccaeead7370416104ea8e849f1f1

See more details on using hashes here.

Supported by

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