Skip to content

Commit 747e507

Browse files
committed
Merge branch 'main' of github.com:CadQuery/assembly-mesh-plugin
2 parents 798e2eb + 7ef04e5 commit 747e507

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

.github/workflows/tests.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Tests
33
on: [push, pull_request]
44

55
jobs:
6-
tests:
6+
tests-with-conda-install:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
@@ -18,12 +18,27 @@ jobs:
1818
- shell: bash -el {0}
1919
run: |
2020
mamba info
21-
mamba install -y -c conda-forge -c cadquery cadquery=master
22-
mamba install -y -c conda-forge gmsh
23-
mamba install -y pytest
2421
python -m pytest -v
2522
- name: Upload output meshes as artifacts for inspection
2623
uses: actions/upload-artifact@v3
2724
with:
2825
name: exported-meshes
2926
path: "*.msh"
27+
28+
tests-with-pip-install:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v3
32+
- name: Set up Python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: 3.11
36+
- name: Install system dependencies
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y libglu1-mesa
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install .[dev]
43+
- name: Run tests
44+
run: python -m pytest -v

assembly_mesh_plugin/plugin.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import tempfile
2+
13
from OCP.TopoDS import TopoDS_Shape
24
import cadquery as cq
35
import gmsh
@@ -44,7 +46,19 @@ def assembly_to_gmsh(self, mesh_path="tagged_mesh.msh"):
4446
# All the solids in the current part should be added to the mesh
4547
for s in obj.moved(loc).Solids():
4648
# Add the current solid to the mesh
47-
gmsh.model.occ.importShapesNativePointer(s.wrapped._address())
49+
50+
with tempfile.NamedTemporaryFile(suffix=".brep") as temp_file:
51+
s.exportBrep(temp_file.name)
52+
gmsh.model.occ.importShapes(temp_file.name)
53+
54+
# TODO find a way to check if the OCC in gmsh is compatible with the
55+
# OCC in CadQuery. When pip installed they tend to be incompatible
56+
# and this importShapesNativePointer will seg fault. When both
57+
# packages are conda installed the importShapesNativePointer works.
58+
# Work around that works in both cases is to write a brep and import
59+
# it into gmsh. This is slower but works in all cases.
60+
# gmsh.model.occ.importShapesNativePointer(s.wrapped._address())
61+
4862
gmsh.model.occ.synchronize()
4963

5064
# All the faces in the current part should be added to the mesh

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ name = "assembly_mesh_plugin"
77
version = "0.1.0"
88
dependencies = [
99
"cadquery",
10+
"gmsh",
1011
]
1112
requires-python = ">=3.9"
1213
authors = [

0 commit comments

Comments
 (0)