Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wrapper #2

Merged
merged 70 commits into from
Mar 4, 2024
Merged

Create wrapper #2

merged 70 commits into from
Mar 4, 2024

Conversation

akaszynski
Copy link
Member

@akaszynski akaszynski commented Feb 28, 2024

Create a basic wrapper of ftetwild.

Resolves #1.

  • Incorporate the same options as in main.cpp
  • Incorporate pre-commit
  • Add trusted provider to PyPi
  • Upload beta to pypi
  • Test installing from sdist
  • Incorporate cibuildwheel

@akaszynski
Copy link
Member Author

At the moment, works (barely). I can't seem to get the development install working, so you'll have to build the wheel and then install it for local testing. Here's the install command (run from pytetwild repo root directory)

pip install pipx
pipx run build --wheel
pip install dist/*

Right now it's just a raw wrapper. Work with it with:

import pyvista as pv
import numpy as np
from pytetwild import PyfTetWildWrapper

mesh = pv.Icosphere(nsub=0)
print(mesh)
# Extract vertices and faces from the bunny mesh
vertices = np.array(mesh.points, dtype=np.float64)  # Ensure correct data type
faces = np.array(mesh.faces.reshape((-1, 4))[:, 1:4], dtype=np.int32)

# Tetrahedralize the mesh using PyfTetWildWrapper
tetrahedral_mesh_vertices, tetrahedral_mesh_tetrahedra = PyfTetWildWrapper.tetrahedralize_mesh(vertices, faces)

# Convert tetrahedral mesh data back to PyVista mesh for visualization
# Note: PyVista's UnstructuredGrid expects cells to be defined by the number of points in the cell followed by the indices of the points in the cell
cells = np.hstack([np.full((tetrahedral_mesh_tetrahedra.shape[0], 1), 4, dtype=np.int32), tetrahedral_mesh_tetrahedra])

# Define cell types for the UnstructuredGrid, 10 represents tetrahedra
cell_types = np.full(tetrahedral_mesh_tetrahedra.shape[0], 10, dtype=np.uint8)

# Create a PyVista unstructured grid
tetrahedral_mesh = pv.UnstructuredGrid(cells, cell_types, tetrahedral_mesh_vertices)

# Visualize the tetrahedral mesh
tetrahedral_mesh.explode(1).plot(show_edges=True)

@akaszynski akaszynski merged commit e72eeca into main Mar 4, 2024
5 checks passed
@akaszynski akaszynski deleted the feat/wrapper branch March 4, 2024 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement basic wrapper
2 participants