Skip to content

Commit

Permalink
Merge pull request #42 from OmooLab/feature/dev
Browse files Browse the repository at this point in the history
Feature/dev
  • Loading branch information
icrdr authored Sep 11, 2024
2 parents 7c71417 + b865d9d commit 48700b3
Show file tree
Hide file tree
Showing 89 changed files with 425 additions and 732 deletions.
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[中文文档](https://uj6xfhbzp0.feishu.cn/wiki/Qx3VwHuNPimeI8kr6nDcvl1DnHf?from=from_copylink)
[中文文档](https://uj6xfhbzp0.feishu.cn/wiki/LPKEwjooSivxjskWHlCcQznjnNf?from=from_copylink)

# Bioxel Nodes

Expand Down Expand Up @@ -26,18 +26,18 @@ Welcome to our [discord server](https://discord.gg/pYkNyq2TjE), if you have any

## Support Multiple Formats

| Format | EXT | Test |
| ------ | ---------------------------------------- | ------- |
| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | ✅ pass |
| BMP | .bmp, .BMP | ✅ pass |
| JPEG | .jpg, .JPG, .jpeg, .JPEG | ✅ pass |
| PNG | .png, .PNG | ✅ pass |
| TIFF | .tif, .TIF, .tiff, .TIFF | ✅ pass |
| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | ✅ pass |
| Nrrd | .nrrd, .nhdr | ✅ pass |
| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | ✅ pass |
| OME | .ome.tiff, .ome.tif | ✅ pass |
| MRC | .mrc, .mrc.gz, .map, .map.gz | ✅ pass |
| Format | EXT |
| ------ | ---------------------------------------- |
| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA |
| BMP | .bmp, .BMP |
| JPEG | .jpg, .JPG, .jpeg, .JPEG |
| PNG | .png, .PNG |
| TIFF | .tif, .TIF, .tiff, .TIFF |
| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz |
| Nrrd | .nrrd, .nhdr |
| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 |
| OME | .ome.tiff, .ome.tif |
| MRC | .mrc, .mrc.gz, .map, .map.gz |

## Support 4D volumetric data

Expand All @@ -59,16 +59,6 @@ Welcome to our [discord server](https://discord.gg/pYkNyq2TjE), if you have any
- Only works with Cycles CPU , Cycles GPU (OptiX), EEVEE
- Section surface cannot be generated when convert to mesh (will be supported soon)

## Compatible to Newer Version

**v0.3.x is not compatible to v0.2.x, Updating this addon may break old files. Read the following carefully before upgradation**

Before upgradation, you need to ask yourself whether this project file will be modified again or not, if it's an archived project file, I would recommend that you run **Bioxel Nodes > Save Staged Data** to make the addon nodes permanent. In this way, there will be no potential problem with the nodes not functioning due to the addon update.

After the addon update, your old project files may not work either, this may be because you had executed **Save Staged Data**. If so, you need to execute **Bioxel Nodes > Relink Nodes to Addon** to relink them to make sure that the addon's new functionality and the addon nodes are synchronized.

Also, the older shaders are not based on OSL, so if you find that you can't render volumes, you need to turn on **Open Shading Language (OSL)** in the Render Settings.

## Roadmap

- Better multi-format import experience
Expand Down
3 changes: 0 additions & 3 deletions bioxelnodes/assets/Nodes/BioxelNodes_v0.1.x.blend

This file was deleted.

3 changes: 3 additions & 0 deletions bioxelnodes/assets/Nodes/BioxelNodes_v1.0.0.blend
Git LFS file not shown
3 changes: 0 additions & 3 deletions bioxelnodes/assets/Nodes/BioxelNodes_v1.0.x.blend

This file was deleted.

43 changes: 29 additions & 14 deletions bioxelnodes/bioxelutils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path
import bpy

from ..constants import NODE_LIB_FILEPATH, VERSION
from ..constants import NODE_LIB_DIRPATH, VERSIONS
from ..utils import get_cache_dir


Expand Down Expand Up @@ -215,31 +215,46 @@ def get_file_prop(prop):
return props.get(prop)


def get_node_version():
node_version = get_file_prop("node_version")
return literal_eval(node_version) if node_version else None


def is_incompatible():
if get_file_prop("addon_version") is None:
node_version = get_node_version()
if node_version is None:
for node_group in bpy.data.node_groups:
if node_group.name.startswith("BioxelNodes"):
return True
else:
addon_version = literal_eval(get_file_prop("addon_version"))
if addon_version[0] != VERSION[0]\
or addon_version[1] != VERSION[1]:
addon_version = VERSIONS[0]["node_version"]
if node_version[0] != addon_version[0]\
or node_version[1] != addon_version[1]:
return True

return False


def get_node_lib_path(node_version):
version_str = "v"+".".join([str(i) for i in list(node_version)])
lib_filename = f"BioxelNodes_{version_str}.blend"
return Path(NODE_LIB_DIRPATH,
lib_filename).resolve()


def local_lib_not_updated():
addon_version = VERSIONS[0]["node_version"]
addon_lib_path = get_node_lib_path(addon_version)

use_local = False
for node_group in bpy.data.node_groups:
if node_group.name.startswith("BioxelNodes"):
node_group_lib = node_group.library
if node_group_lib:
abs_filepath = bpy.path.abspath(node_group_lib.filepath)
_local_lib_file = Path(abs_filepath).resolve().as_posix()
if _local_lib_file != NODE_LIB_FILEPATH.as_posix():
lib = node_group.library
if lib:
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
if lib_path != addon_lib_path:
use_local = True
break

addon_version = literal_eval(get_file_prop("addon_version"))
not_update = addon_version != VERSION
return use_local and not_update

not_update = get_node_version() != addon_version
return use_local and not_update
2 changes: 1 addition & 1 deletion bioxelnodes/bioxelutils/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def add_layers(layers: list[Layer],
layer_obj = layer_to_obj(layer, container_obj, cache_dir)
fetch_node = add_node_to_graph("FetchLayer",
node_group,
get_use_link())
use_link=get_use_link())
fetch_node.label = get_layer_prop_value(layer_obj, "name")
fetch_node.inputs[0].default_value = layer_obj

Expand Down
4 changes: 3 additions & 1 deletion bioxelnodes/bioxelutils/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def layer_to_obj(layer: Layer,
socket_type="NodeSocketGeometry")
modifier.node_group = node_group

layer_node = add_node_to_graph("_Layer", node_group, get_use_link())
layer_node = add_node_to_graph("_Layer",
node_group,
use_link=get_use_link())

layer_node.inputs['name'].default_value = layer.name
layer_node.inputs['shape'].default_value = layer.shape
Expand Down
34 changes: 18 additions & 16 deletions bioxelnodes/bioxelutils/node.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
from pathlib import Path
import shutil
import bpy

from .common import get_file_prop, set_file_prop
from .common import get_file_prop, get_node_lib_path, set_file_prop
from ..exceptions import Incompatible, NoFound

from ..constants import NODE_LIB_FILEPATH, VERSION
from ..constants import VERSIONS


def get_node_group(node_type: str, use_link=True):
# unannotate below for local debug in node lib file.
# node_group = bpy.data.node_groups[node_type]
# return node_group

if get_file_prop("addon_version") is None:
set_file_prop("addon_version", VERSION)
# added node is always from latest node version
addon_version = VERSIONS[0]["node_version"]
addon_lib_path = get_node_lib_path(addon_version)

local_lib_file = None
addon_lib_file = NODE_LIB_FILEPATH.as_posix()
if get_file_prop("node_version") is None:
set_file_prop("node_version", addon_version)

local_lib_path = None
for node_group in bpy.data.node_groups:
if node_group.name.startswith("BioxelNodes"):
node_group_lib = node_group.library
if node_group_lib:
abs_filepath = bpy.path.abspath(node_group_lib.filepath)
_local_lib_file = Path(abs_filepath).resolve().as_posix()
if _local_lib_file != addon_lib_file:
local_lib_file = _local_lib_file
lib = node_group.library
if lib:
lib_path = Path(bpy.path.abspath(lib.filepath)).resolve()
if lib_path != addon_lib_path:
local_lib_path = lib_path
break

# local lib first
lib_file = local_lib_file or addon_lib_file
lib_path = local_lib_path or addon_lib_path
bpy.ops.wm.append('EXEC_DEFAULT',
directory=f"{lib_file}/NodeTree",
directory=f"{lib_path.as_posix()}/NodeTree",
filename=node_type,
link=use_link,
use_recursive=True,
Expand All @@ -52,8 +52,9 @@ def assign_node_group(node, node_type: str):
return node


def add_node_to_graph(node_name: str, node_group, use_link=True):
def add_node_to_graph(node_name: str, node_group, node_label=None, use_link=True):
node_type = f"BioxelNodes_{node_name}"
node_label = node_label or node_name

# Deselect all nodes first
for node in node_group.nodes:
Expand All @@ -64,5 +65,6 @@ def add_node_to_graph(node_name: str, node_group, use_link=True):
node = node_group.nodes.new("GeometryNodeGroup")
assign_node_group(node, node_type)

node.label = node_label
node.show_options = False
return node
10 changes: 5 additions & 5 deletions bioxelnodes/blender_manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ wheels = [
"./wheels/SimpleITK-2.3.1-cp311-cp311-macosx_10_9_x86_64.whl",
"./wheels/SimpleITK-2.3.1-cp311-cp311-macosx_11_0_arm64.whl",
"./wheels/SimpleITK-2.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"./wheels/lxml-5.2.2-cp311-cp311-win_amd64.whl",
"./wheels/lxml-5.2.2-cp311-cp311-macosx_10_9_arm64.whl",
"./wheels/lxml-5.2.2-cp311-cp311-macosx_10_9_x86_64.whl",
"./wheels/lxml-5.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"./wheels/lxml-5.3.0-cp311-cp311-win_amd64.whl",
"./wheels/lxml-5.3.0-cp311-cp311-macosx_10_9_arm64.whl",
"./wheels/lxml-5.3.0-cp311-cp311-macosx_10_9_x86_64.whl",
"./wheels/lxml-5.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"./wheels/h5py-3.11.0-cp311-cp311-win_amd64.whl",
"./wheels/h5py-3.11.0-cp311-cp311-macosx_11_0_arm64.whl",
"./wheels/h5py-3.11.0-cp311-cp311-macosx_10_9_x86_64.whl",
Expand All @@ -34,4 +34,4 @@ wheels = [
]

[permissions]
files = "Import/export volume data from/to disk"
files = "Import/export volume data from/to disk"
36 changes: 19 additions & 17 deletions bioxelnodes/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from pathlib import Path

VERSION = (1, 0, 0)
NODE_LIB_FILENAME = "BioxelNodes_v1.0.x"
NODE_LIB_FILEPATH = Path(Path(__file__).parent,
f"assets/Nodes/{NODE_LIB_FILENAME}.blend").resolve()
VERSIONS = [{"label": "Current", "node_version": (1, 0, 0)},
{"label": "v0.3.x", "node_version": (0, 3, 3)},
{"label": "v0.2.x", "node_version": (0, 2, 9)}]

NODE_LIB_DIRPATH = Path(Path(__file__).parent,
"assets/Nodes").resolve()

MENU_ITEMS = [
{
Expand All @@ -23,9 +25,9 @@
'description': ''
},
{
'label': 'Cutout by Color',
'label': 'Cutout by Hue',
'icon': 'COLOR',
'name': 'CutoutByColor',
'name': 'CutoutByHue',
'description': ''
},
"separator",
Expand All @@ -50,7 +52,7 @@
]
},
{
'label': 'Properties',
'label': 'Property',
'icon': 'PROPERTIES',
'items': [
{
Expand Down Expand Up @@ -148,7 +150,7 @@
]
},
{
'label': 'Cutters',
'label': 'Cut',
'icon': 'MOD_BEVEL',
'items': [
{
Expand All @@ -173,31 +175,31 @@
]
},
{
'label': 'Utils',
'label': 'Extra',
'icon': 'MODIFIER',
'items': [
{
'label': 'Pick Surface',
'label': 'Fetch Surface',
'icon': 'OUTLINER_OB_MESH',
'name': 'PickSurface',
'name': 'FetchSurface',
'description': ''
},
{
'label': 'Pick Volume',
'label': 'Fetch Volume',
'icon': 'OUTLINER_OB_VOLUME',
'name': 'PickVolume',
'name': 'FetchVolume',
'description': ''
},
{
'label': 'Pick Shape Wire',
'label': 'Fetch Shape Wire',
'icon': 'FILE_VOLUME',
'name': 'PickShapeWire',
'name': 'FetchShapeWire',
'description': ''
},
{
'label': 'Pick Bbox Wire',
'label': 'Fetch Bbox Wire',
'icon': 'MESH_CUBE',
'name': 'PickBboxWire',
'name': 'FetchBboxWire',
'description': ''
},
"separator",
Expand Down
Loading

0 comments on commit 48700b3

Please sign in to comment.