Skip to content

Commit d650c2b

Browse files
authored
Merge branch 'navis-org:master' into fix_numpy_doctest
2 parents bd0e2dc + aba1df1 commit d650c2b

File tree

3 files changed

+76
-46
lines changed

3 files changed

+76
-46
lines changed

.github/workflows/test-package.yml

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,47 @@ jobs:
1515
# igraph: ["igraph", "no-igraph"]
1616
steps:
1717
# This cancels any such job that is still runnning
18-
- name: Cancel Previous Runs
19-
uses: styfle/cancel-workflow-action@0.9.1
20-
with:
21-
access_token: ${{ github.token }}
22-
- uses: actions/checkout@v4
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: ${{ matrix.python-version }}
27-
- name: Install Linux libraries
28-
run: |
29-
sudo apt-get update -y -qq
30-
sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \
31-
libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \
32-
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 graphviz graphviz-dev \
33-
mesa-vulkan-drivers
34-
- name: Install dependencies
35-
run: |
36-
pip install --upgrade pip
37-
pip install zstandard==0.16.0
38-
pip install numpy
39-
pip install flybrains --no-deps
40-
pip install git+https://github.com/siavashk/pycpd@master
41-
pip install pyarrow
42-
- name: Install navis
43-
run: pip install -e .[dev,all]
44-
# - run: pip install python-igraph
45-
# if: ${{ matrix.igraph == 'igraph' }}
46-
- name: Report dependency versions
47-
run: pip freeze -r requirements.txt
48-
- name: Test
49-
uses: coactions/setup-xvfb@v1
50-
with:
18+
- name: Cancel Previous Runs
19+
uses: styfle/cancel-workflow-action@0.9.1
20+
with:
21+
access_token: ${{ github.token }}
22+
- uses: actions/checkout@v4
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Set up Blender
5128
run: |
52-
export NAVIS_HEADLESS=TRUE
53-
pytest --verbose
29+
pwd
30+
wget -qO- https://mirrors.iu13.net/blender/release/Blender4.2/blender-4.2.4-linux-x64.tar.xz | tar xJ
31+
mv blender-4.2.4-linux-x64 ../
32+
echo "PATH=../blender-4.2.4-linux-x64/:$PATH" >> $GITHUB_ENV
33+
- name: Install Linux libraries
34+
run: |
35+
sudo apt-get update -y -qq
36+
sudo apt-get install -y libdbus-1-3 libxkbcommon-x11-0 libxcb-icccm4 \
37+
libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 \
38+
libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 graphviz graphviz-dev \
39+
mesa-vulkan-drivers
40+
- name: Install dependencies
41+
run: |
42+
pip install --upgrade pip
43+
pip install zstandard==0.16.0
44+
pip install numpy
45+
pip install flybrains --no-deps
46+
pip install git+https://github.com/siavashk/pycpd@master
47+
pip install pyarrow
48+
- name: Install navis
49+
run: pip install -e .[dev,all]
50+
# - run: pip install python-igraph
51+
# if: ${{ matrix.igraph == 'igraph' }}
52+
- name: Report dependency versions
53+
run: |
54+
which blender
55+
pip freeze -r requirements.txt
56+
- name: Test
57+
uses: coactions/setup-xvfb@v1
58+
with:
59+
run: |
60+
export NAVIS_HEADLESS=TRUE
61+
pytest --verbose

navis/meshes/b3d.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def simplify_mesh_blender(x, F, inplace=False):
3737
simp
3838
Simplified mesh object.
3939
40+
Examples
41+
--------
42+
>>> import navis
43+
>>> n = navis.example_neurons(1, kind="mesh")
44+
>>> n_sm = simplify_mesh_blender(n,
45+
... F=0.2,
46+
... inplace=False)
47+
>>> n.n_vertices > n_sm.n_vertices
48+
True
49+
4050
"""
4151
if not tm.interfaces.blender.exists:
4252
raise ModuleNotFoundError('No Blender 3D unavailable (executable not found).')

navis/meshes/templates/blender_decimate.py.template

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,29 @@ import os
55
if __name__ == '__main__':
66
# clear scene of default box
77
bpy.ops.wm.read_homefile()
8-
try:
9-
bpy.ops.object.mode_set(mode='OBJECT')
10-
except BaseException:
11-
pass
12-
bpy.ops.object.select_all(action='SELECT')
13-
bpy.ops.object.delete(use_global=True)
8+
if bpy.app.version > (3, 2, 0):
9+
objs = [bpy.context.scene.objects['Camera'], bpy.context.scene.objects['Cube'], bpy.context.scene.objects['Light']]
10+
with bpy.context.temp_override(selected_objects=objs):
11+
bpy.ops.object.delete()
12+
else:
13+
try:
14+
bpy.ops.object.mode_set(mode='OBJECT')
15+
except BaseException:
16+
pass
17+
bpy.ops.object.select_all(action='SELECT')
18+
bpy.ops.object.delete(use_global=True)
1419

1520
# get temporary files from templated locations
1621
mesh_pre = $MESH_PRE
1722
mesh_post = os.path.abspath(r'$MESH_POST')
1823

1924
for filename in mesh_pre: # use data.objects instead of context.scene.objects
20-
bpy.ops.import_mesh.stl(filepath=os.path.abspath(filename))
21-
25+
if bpy.app.version > (4, 0, 0):
26+
bpy.ops.wm.stl_import(filepath=os.path.abspath(filename))
27+
else:
28+
bpy.ops.import_mesh.stl(filepath=os.path.abspath(filename))
2229
mesh = bpy.data.objects[0]
30+
2331
# Make sure mesh is the active object
2432
try:
2533
# earlier than blender <2.8
@@ -29,13 +37,17 @@ if __name__ == '__main__':
2937
bpy.context.view_layer.objects.active = mesh
3038

3139
# add decimate modifier
40+
3241
mod = mesh.modifiers.new('decimate', 'DECIMATE')
3342
mod.decimate_type = 'COLLAPSE'
3443
mod.ratio = $RATIO
3544
mod.use_collapse_triangulate = True
3645

3746
bpy.ops.object.modifier_apply(modifier=mod.name)
3847

39-
bpy.ops.export_mesh.stl(
40-
filepath=mesh_post,
41-
use_mesh_modifiers=True)
48+
if bpy.app.version > (4, 0, 0):
49+
bpy.ops.wm.stl_export(filepath=mesh_post, apply_modifiers=True)
50+
else:
51+
bpy.ops.export_mesh.stl(
52+
filepath=mesh_post,
53+
use_mesh_modifiers=True)

0 commit comments

Comments
 (0)