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
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ jobs:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist
- name: pytest
if: ${{ !startsWith(matrix.platform.target, 'x86') }}
if: ${{ matrix.platform.target == 'x86_64' }}
uses: uraimo/run-on-arch-action@v2
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: 1
with:
arch: ${{ matrix.platform.target }}
arch: x86_64
distro: alpine_latest
githubToken: ${{ github.token }}
install: |
Expand Down
268 changes: 268 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ name = "e57"
crate-type = ["cdylib"]

[dependencies]
pyo3 = "0.21.2"
e57 = { version = "0.11.7",features =["crc32c"]}
numpy = "0.21.0"
ndarray = "0.15.6"
pyo3 = "0.28.3"
e57 = { version = "0.11.12", features = ["crc32c"] }
numpy = "0.28.0"
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[build-system]
requires = ["maturin>=1.0,<2.0"]
requires = ["maturin>=1.13,<2.0"]
build-backend = "maturin"

[project]
name = "e57"
version = "0.2.1a1"
dependencies = [
'pytest',
'numpy',
'numpy>=2,<3',
]
Comment on lines 8 to 10
description = "Read e57 files to Python. E57 is a compact, non-proprietary point cloud format that's defined by the ASTM E2807 standard. This format is widely adopted by 3D design applications."
authors = [
Expand All @@ -23,6 +23,11 @@ classifiers = [
"Topic :: File Formats",
]

[project.optional-dependencies]
test = [
'pytest>=9,<10',
]

[project.urls]
repository = "https://github.com/dancergraham/e57-python"

Expand Down
41 changes: 19 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ use std::fs::File;
use std::io::BufReader;

use ::e57::{CartesianCoordinate, E57Reader};
use ndarray::Ix2;
use numpy::{PyArray, PyArrayMethods};
use numpy::ndarray::Array2;
use numpy::{IntoPyArray, PyArray2};
use pyo3::prelude::*;

#[pyclass]
pub struct E57 {
#[pyo3(get)]
pub points: Py<PyArray<f64, Ix2>>,
pub points: Py<PyArray2<f64>>,
#[pyo3(get)]
pub color: Py<PyArray<f32, Ix2>>,
pub color: Py<PyArray2<f32>>,
#[pyo3(get)]
pub intensity: Py<PyArray<f32, Ix2>>,
pub intensity: Py<PyArray2<f32>>,
}

/// Extracts the xml contents from an e57 file.
Expand Down Expand Up @@ -80,27 +80,24 @@ unsafe fn read_points(py: Python<'_>, filepath: &str) -> PyResult<E57> {
let n_colors = color_vec.len() / 3;
let n_intensities = intensity_vec.len();
let mut e57 = E57 {
points: Py::from(
PyArray::from_vec_bound(py, point_vec)
.reshape([nrows, 3])
.unwrap(),
),
color: Py::from(PyArray::new_bound(py, (0, 3), false)),
intensity: Py::from(PyArray::new_bound(py, (0, 1), false)),
points: Array2::from_shape_vec((nrows, 3), point_vec)
.unwrap()
.into_pyarray(py)
.unbind(),
color: Array2::<f32>::zeros((0, 3)).into_pyarray(py).unbind(),
intensity: Array2::<f32>::zeros((0, 1)).into_pyarray(py).unbind(),
};
if n_colors == n_points {
e57.color = Py::from(
PyArray::from_vec_bound(py, color_vec)
.reshape([nrows, 3])
.unwrap(),
)
e57.color = Array2::from_shape_vec((nrows, 3), color_vec)
.unwrap()
.into_pyarray(py)
.unbind();
}
if n_intensities == n_points {
e57.intensity = Py::from(
PyArray::from_vec_bound(py, intensity_vec)
.reshape([nrows, 1])
.unwrap(),
)
e57.intensity = Array2::from_shape_vec((nrows, 1), intensity_vec)
.unwrap()
.into_pyarray(py)
.unbind();
}
Ok(e57)
}
Expand Down
Loading