Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on: [push, pull_request]

jobs:
tests:
tests-with-conda-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -27,3 +27,21 @@ jobs:
with:
name: exported-meshes
path: "*.msh"

tests-with-pip-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libglu1-mesa
- name: Install dependencies
run: |
python -m pip install .[dev]
- name: Run tests
run: python -m pytest -v
16 changes: 15 additions & 1 deletion assembly_mesh_plugin/plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import tempfile

from OCP.TopoDS import TopoDS_Shape
import cadquery as cq
import gmsh
Expand Down Expand Up @@ -44,7 +46,19 @@ def assembly_to_gmsh(self, mesh_path="tagged_mesh.msh"):
# All the solids in the current part should be added to the mesh
for s in obj.moved(loc).Solids():
# Add the current solid to the mesh
gmsh.model.occ.importShapesNativePointer(s.wrapped._address())

with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
s.exportBrep(temp_file.name)
gmsh.model.occ.importShapes(temp_file.name)

# TODO find a way to check if the OCC in gmsh is compatible with the
# OCC in CadQuery. When pip installed they tend to be incompatible
# and this importShapesNativePointer will seg fault. When both
# packages are conda installed the importShapesNativePointer works.
# Work around that works in both cases is to write a brep and import
# it into gmsh. This is slower but works in all cases.
# gmsh.model.occ.importShapesNativePointer(s.wrapped._address())

gmsh.model.occ.synchronize()

# All the faces in the current part should be added to the mesh
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "assembly_mesh_plugin"
version = "0.1.0"
dependencies = [
"cadquery",
"gmsh",
]
requires-python = ">=3.9"
authors = [
Expand Down
Loading