Skip to content

Commit 2bbfc74

Browse files
authored
Merge pull request #1246 from thewtex/point-set-io
point set io
2 parents 007e79a + c41eea9 commit 2bbfc74

File tree

352 files changed

+10210
-1673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

352 files changed

+10210
-1673
lines changed

include/itkWasmMeshIO.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <fstream>
2424

2525
#include "itkMeshJSON.h"
26+
#include "itkPointSetJSON.h"
2627
#include "cbor.h"
2728

2829
namespace itk
@@ -72,6 +73,9 @@ class WebAssemblyInterface_EXPORT WasmMeshIO: public MeshIOBase
7273
/** Set the JSON representation of the image information. */
7374
void SetJSON(const MeshJSON & json);
7475

76+
/** Set the JSON representation of the image information. */
77+
void SetJSON(const PointSetJSON & json);
78+
7579
/*-------- This part of the interfaces deals with writing data ----- */
7680

7781
/** Writes the data to disk from the memory buffer provided. Make sure
@@ -93,6 +97,9 @@ class WebAssemblyInterface_EXPORT WasmMeshIO: public MeshIOBase
9397
#if !defined(ITK_WRAPPING_PARSER)
9498
/** Get the JSON representation of the mesh information. */
9599
auto GetJSON() -> MeshJSON;
100+
101+
/** Get the JSON representation of the point set information. */
102+
auto GetPointSetJSON() -> PointSetJSON;
96103
#endif
97104

98105
protected:

packages/compare-images/python/itkwasm-compare-images-emscripten/itkwasm_compare_images_emscripten/js_package.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/compress-stringify/python/itkwasm-compress-stringify-emscripten/itkwasm_compress_stringify_emscripten/js_package.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/core/python/itkwasm/itkwasm/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""itkwasm: Python interface to itk-wasm WebAssembly modules."""
22

3-
__version__ = "1.0b178"
3+
__version__ = "1.0b179"
44

55
from .interface_types import InterfaceTypes
66
from .image import Image, ImageType, ImageRegion
7-
from .pointset import PointSet, PointSetType
7+
from .point_set import PointSet, PointSetType
88
from .mesh import Mesh, MeshType
99
from .transform import Transform, TransformType, TransformParameterizations
1010
from .polydata import PolyData, PolyDataType

packages/core/python/itkwasm/itkwasm/interface_types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class InterfaceTypes(str, Enum):
77
BinaryStream = "BinaryStream"
88
Image = "Image"
99
Mesh = "Mesh"
10+
PointSet = "PointSet"
1011
PolyData = "PolyData"
1112
Transform = "Transform"
1213
JsonCompatible = "JsonCompatible"

packages/core/python/itkwasm/itkwasm/pipeline.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .binary_file import BinaryFile
2323
from .image import Image
2424
from .mesh import Mesh
25+
from .point_set import PointSet
2526
from .polydata import PolyData
2627
from .json_compatible import JsonCompatible
2728
from .int_types import IntTypes
@@ -277,6 +278,27 @@ def run(
277278
"cellData": f"data:application/vnd.itk.address,0:{cell_data_ptr}",
278279
}
279280
ri.set_input_json(mesh_json, index)
281+
elif input_.type == InterfaceTypes.PointSet:
282+
point_set = input_.data
283+
if point_set.numberOfPoints:
284+
pv = array_like_to_bytes(point_set.points)
285+
else:
286+
pv = bytes([])
287+
points_ptr = ri.set_input_array(pv, index, 0)
288+
if point_set.numberOfPointPixels:
289+
pdv = array_like_to_bytes(point_set.pointData)
290+
else:
291+
pdv = bytes([])
292+
point_data_ptr = ri.set_input_array(pdv, index, 1)
293+
point_set_json = {
294+
"pointSetType": asdict(point_set.pointSetType),
295+
"name": point_set.name,
296+
"numberOfPoints": point_set.numberOfPoints,
297+
"points": f"data:application/vnd.itk.address,0:{points_ptr}",
298+
"numberOfPointPixels": point_set.numberOfPointPixels,
299+
"pointData": f"data:application/vnd.itk.address,0:{point_data_ptr}",
300+
}
301+
ri.set_input_json(point_set_json, index)
280302
elif input_.type == InterfaceTypes.PolyData:
281303
polydata = input_.data
282304
if polydata.numberOfPoints:
@@ -442,6 +464,31 @@ def run(
442464
mesh.cellData = buffer_to_numpy_array(mesh.meshType.cellPixelComponentType, bytes([]))
443465

444466
output_data = PipelineOutput(InterfaceTypes.Mesh, mesh)
467+
elif output.type == InterfaceTypes.PointSet:
468+
point_set_json = ri.get_output_json(index)
469+
point_set = PointSet(**point_set_json)
470+
471+
if point_set.numberOfPoints > 0:
472+
data_ptr = ri.get_output_array_address(0, index, 0)
473+
data_size = ri.get_output_array_size(0, index, 0)
474+
point_set.points = buffer_to_numpy_array(
475+
point_set.pointSetType.pointComponentType,
476+
ri.wasmtime_lift(data_ptr, data_size),
477+
)
478+
else:
479+
point_set.points = buffer_to_numpy_array(point_set.pointSetType.pointComponentType, bytes([]))
480+
481+
if point_set.numberOfPointPixels > 0:
482+
data_ptr = ri.get_output_array_address(0, index, 1)
483+
data_size = ri.get_output_array_size(0, index, 1)
484+
point_set.pointData = buffer_to_numpy_array(
485+
point_set.pointSetType.pointPixelComponentType,
486+
ri.wasmtime_lift(data_ptr, data_size),
487+
)
488+
else:
489+
point_set.pointData = buffer_to_numpy_array(point_set.pointSetType.pointPixelComponentType, bytes([]))
490+
491+
output_data = PipelineOutput(InterfaceTypes.PointSet, point_set)
445492
elif output.type == InterfaceTypes.PolyData:
446493
polydata_json = ri.get_output_json(index)
447494
polydata = PolyData(**polydata_json)

packages/core/python/itkwasm/itkwasm/pyodide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Optional
33

44
from .image import Image, ImageType
5-
from .pointset import PointSet, PointSetType
5+
from .point_set import PointSet, PointSetType
66
from .mesh import Mesh, MeshType
77
from .polydata import PolyData, PolyDataType
88
from .binary_file import BinaryFile

packages/core/python/itkwasm/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies = [
4747
"itk>=5.4.0",
4848
"pytest >=2.7.3",
4949
"pytest-pyodide",
50+
"pyodide-py",
5051
"dask[array]",
5152
"test_accelerator @ {root:uri}/test/test-accelerator",
5253
]
@@ -57,7 +58,7 @@ test = [
5758
"pytest --dist-dir=./dist --rt=chrome",
5859
]
5960
download-pyodide = [
60-
"curl -L https://github.com/pyodide/pyodide/releases/download/0.25.1/pyodide-0.25.1.tar.bz2 -o pyodide.tar.bz2",
61+
"curl -L https://github.com/pyodide/pyodide/releases/download/0.26.2/pyodide-0.26.2.tar.bz2 -o pyodide.tar.bz2",
6162
"tar xjf pyodide.tar.bz2",
6263
"rm -rf dist pyodide.tar.bz2",
6364
"mv pyodide dist",

packages/core/typescript/itk-wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "itk-wasm",
3-
"version": "1.0.0-b.178",
3+
"version": "1.0.0-b.179",
44
"packageManager": "[email protected]",
55
"description": "High-performance spatial analysis in a web browser, Node.js, and reproducible execution across programming languages and hardware architectures.",
66
"type": "module",

0 commit comments

Comments
 (0)