differt-core 0.9.0__tar.gz → 0.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {differt_core-0.9.0 → differt_core-0.10.0}/Cargo.lock +1 -1
- {differt_core-0.9.0 → differt_core-0.10.0}/PKG-INFO +1 -1
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/Cargo.toml +1 -1
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/benches/benchmarks/graph_iterators.rs +1 -1
- differt_core-0.9.0/differt-core/src/geometry/triangle_mesh.rs → differt_core-0.10.0/differt-core/src/geometry/mesh.rs +13 -13
- differt_core-0.10.0/differt-core/src/geometry/mod.rs +16 -0
- differt_core-0.9.0/differt-core/src/scene/triangle_scene.rs → differt_core-0.10.0/differt-core/src/geometry/scene.rs +14 -14
- {differt_core-0.9.0/src/scene → differt_core-0.10.0/differt-core/src/geometry}/sionna.rs +3 -3
- {differt_core-0.9.0 → differt_core-0.10.0/differt-core}/src/lib.rs +0 -4
- differt_core-0.10.0/differt-core/tests/geometry/test_core_mesh.py +11 -0
- differt_core-0.10.0/differt-core/tests/geometry/test_core_scene.py +11 -0
- {differt_core-0.9.0/differt-core/tests/rt → differt_core-0.10.0/differt-core/tests/geometry}/test_graph.py +3 -3
- differt_core-0.9.0/python/differt_core/_differt_core/geometry/triangle_mesh.pyi → differt_core-0.10.0/python/differt_core/_differt_core/geometry/mesh.pyi +4 -4
- differt_core-0.9.0/python/differt_core/_differt_core/scene/triangle_scene.pyi → differt_core-0.10.0/python/differt_core/_differt_core/geometry/scene.pyi +2 -2
- {differt_core-0.9.0/python/differt_core/rt → differt_core-0.10.0/python/differt_core/geometry}/__init__.py +11 -1
- differt_core-0.10.0/python/differt_core/geometry/_graph.py +23 -0
- differt_core-0.10.0/python/differt_core/geometry/_mesh.py +28 -0
- differt_core-0.10.0/python/differt_core/geometry/_scene.py +27 -0
- differt_core-0.10.0/python/differt_core/geometry/_sionna.py +7 -0
- differt_core-0.9.0/src/geometry/triangle_mesh.rs → differt_core-0.10.0/src/geometry/mesh.rs +13 -13
- differt_core-0.10.0/src/geometry/mod.rs +16 -0
- differt_core-0.9.0/src/scene/triangle_scene.rs → differt_core-0.10.0/src/geometry/scene.rs +14 -14
- {differt_core-0.9.0/differt-core/src/scene → differt_core-0.10.0/src/geometry}/sionna.rs +3 -3
- {differt_core-0.9.0/differt-core → differt_core-0.10.0}/src/lib.rs +0 -4
- differt_core-0.9.0/differt-core/src/geometry/mod.rs +0 -10
- differt_core-0.9.0/differt-core/src/rt/mod.rs +0 -10
- differt_core-0.9.0/differt-core/src/scene/mod.rs +0 -12
- differt_core-0.9.0/python/differt_core/_differt_core/rt/__init__.pyi +0 -0
- differt_core-0.9.0/python/differt_core/geometry/__init__.py +0 -5
- differt_core-0.9.0/python/differt_core/geometry/_triangle_mesh.py +0 -5
- differt_core-0.9.0/python/differt_core/rt/_graph.py +0 -19
- differt_core-0.9.0/python/differt_core/scene/__init__.py +0 -6
- differt_core-0.9.0/python/differt_core/scene/_sionna.py +0 -7
- differt_core-0.9.0/python/differt_core/scene/_triangle_scene.py +0 -5
- differt_core-0.9.0/src/geometry/mod.rs +0 -10
- differt_core-0.9.0/src/rt/mod.rs +0 -10
- differt_core-0.9.0/src/scene/mod.rs +0 -12
- {differt_core-0.9.0 → differt_core-0.10.0}/Cargo.toml +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/LICENSE.md +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/README.md +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/LICENSE.md +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/README.md +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/benches/bench_main.rs +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/benches/benchmarks/mod.rs +0 -0
- {differt_core-0.9.0/differt-core/src/rt → differt_core-0.10.0/differt-core/src/geometry}/graph.rs +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/tests/__init__.py +0 -0
- {differt_core-0.9.0/differt-core/tests/rt → differt_core-0.10.0/differt-core/tests/geometry}/__init__.py +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/differt-core/tests/test_version.py +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/pyproject.toml +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/python/differt_core/__init__.py +2 -2
- {differt_core-0.9.0 → differt_core-0.10.0}/python/differt_core/_differt_core/__init__.pyi +0 -0
- {differt_core-0.9.0/python/differt_core/_differt_core/rt → differt_core-0.10.0/python/differt_core/_differt_core/geometry}/graph.pyi +0 -0
- {differt_core-0.9.0/python/differt_core/_differt_core/scene → differt_core-0.10.0/python/differt_core/_differt_core/geometry}/sionna.pyi +0 -0
- {differt_core-0.9.0 → differt_core-0.10.0}/python/differt_core/py.typed +0 -0
- {differt_core-0.9.0/src/rt → differt_core-0.10.0/src/geometry}/graph.rs +0 -0
{differt_core-0.9.0 → differt_core-0.10.0}/differt-core/benches/benchmarks/graph_iterators.rs
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use criterion::{Criterion, Throughput, black_box, criterion_group};
|
|
2
|
-
use differt_core::
|
|
2
|
+
use differt_core::geometry::graph::{complete::CompleteGraph, directed::DiGraph};
|
|
3
3
|
|
|
4
4
|
const NUM_NODES: usize = 1000;
|
|
5
5
|
const DIRECT_PATH: bool = true;
|
|
@@ -9,10 +9,10 @@ use pyo3::{exceptions::PyValueError, prelude::*, types::PyType};
|
|
|
9
9
|
/// A lower-level mesh made of triangles.
|
|
10
10
|
///
|
|
11
11
|
/// This class should not be used directly, prefer its higher-level version
|
|
12
|
-
/// :class:`differt.geometry.
|
|
12
|
+
/// :class:`differt.geometry.Mesh` instead.
|
|
13
13
|
#[derive(Clone, Debug, Default)]
|
|
14
|
-
#[pyclass]
|
|
15
|
-
pub(crate) struct
|
|
14
|
+
#[pyclass(subclass)]
|
|
15
|
+
pub(crate) struct Mesh {
|
|
16
16
|
vertices: Vec<[f32; 3]>,
|
|
17
17
|
triangles: Vec<[usize; 3]>,
|
|
18
18
|
face_colors: Option<Vec<[f32; 3]>>,
|
|
@@ -77,7 +77,7 @@ impl ply::PropertyAccess for PlyFace {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
impl
|
|
80
|
+
impl Mesh {
|
|
81
81
|
pub fn get_material_index(&mut self, material_name: Option<String>) -> isize {
|
|
82
82
|
if let Some(material_name) = material_name {
|
|
83
83
|
return self
|
|
@@ -122,7 +122,7 @@ impl TriangleMesh {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
#[pymethods]
|
|
125
|
-
impl
|
|
125
|
+
impl Mesh {
|
|
126
126
|
/// :class:`Float[np.ndarray, 'num_vertices 3']<jaxtyping.Float>`: The array of triangle vertices.
|
|
127
127
|
#[getter]
|
|
128
128
|
fn vertices<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2<f32>> {
|
|
@@ -184,7 +184,7 @@ impl TriangleMesh {
|
|
|
184
184
|
/// After calling this method, ``other`` will be empty.
|
|
185
185
|
///
|
|
186
186
|
/// Args:
|
|
187
|
-
/// other(
|
|
187
|
+
/// other(Mesh): The mesh to be appended to ``self``.
|
|
188
188
|
pub(crate) fn append(&mut self, other: &mut Self) {
|
|
189
189
|
match (&self.face_colors, &other.face_colors) {
|
|
190
190
|
(None, None) => {},
|
|
@@ -268,7 +268,7 @@ impl TriangleMesh {
|
|
|
268
268
|
///
|
|
269
269
|
/// Currently, only vertices and triangles are loaded. Triangle normals
|
|
270
270
|
/// are ignored because they are computed with
|
|
271
|
-
/// :attr:`differt.geometry.
|
|
271
|
+
/// :attr:`differt.geometry.Mesh.normals` using
|
|
272
272
|
/// JAX so that they can be differentiated with respect to triangle
|
|
273
273
|
/// vertices.
|
|
274
274
|
///
|
|
@@ -276,7 +276,7 @@ impl TriangleMesh {
|
|
|
276
276
|
/// file (str): The path to the Wavefront .obj file.
|
|
277
277
|
///
|
|
278
278
|
/// Returns:
|
|
279
|
-
///
|
|
279
|
+
/// Mesh: The corresponding mesh containing only triangles.
|
|
280
280
|
#[classmethod]
|
|
281
281
|
pub(crate) fn load_obj(_: &Bound<'_, PyType>, filename: &str) -> PyResult<Self> {
|
|
282
282
|
let input = BufReader::new(File::open(filename)?);
|
|
@@ -302,7 +302,7 @@ impl TriangleMesh {
|
|
|
302
302
|
///
|
|
303
303
|
/// Currently, only vertices and triangles are loaded. Triangle normals
|
|
304
304
|
/// are ignored because they are computed with
|
|
305
|
-
/// :attr:`differt.geometry.
|
|
305
|
+
/// :attr:`differt.geometry.Mesh.normals` using
|
|
306
306
|
/// JAX so that they can be differentiated with respect to triangle
|
|
307
307
|
/// vertices.
|
|
308
308
|
///
|
|
@@ -310,7 +310,7 @@ impl TriangleMesh {
|
|
|
310
310
|
/// file (str): The path to the Stanford PLY .ply file.
|
|
311
311
|
///
|
|
312
312
|
/// Returns:
|
|
313
|
-
///
|
|
313
|
+
/// Mesh: The corresponding mesh containing only triangles.
|
|
314
314
|
#[classmethod]
|
|
315
315
|
pub(crate) fn load_ply(_: &Bound<'_, PyType>, filename: &str) -> PyResult<Self> {
|
|
316
316
|
let mut input = BufReader::new(File::open(filename)?);
|
|
@@ -380,7 +380,7 @@ impl TriangleMesh {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
impl From<RawObj> for
|
|
383
|
+
impl From<RawObj> for Mesh {
|
|
384
384
|
fn from(mut raw_obj: RawObj) -> Self {
|
|
385
385
|
use obj::raw::object::Polygon::*;
|
|
386
386
|
|
|
@@ -503,7 +503,7 @@ impl From<RawObj> for TriangleMesh {
|
|
|
503
503
|
|
|
504
504
|
#[cfg(not(tarpaulin_include))]
|
|
505
505
|
#[pymodule(gil_used = false)]
|
|
506
|
-
pub(crate) fn
|
|
507
|
-
m.add_class::<
|
|
506
|
+
pub(crate) fn mesh(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
507
|
+
m.add_class::<Mesh>()?;
|
|
508
508
|
Ok(())
|
|
509
509
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
|
+
|
|
3
|
+
pub mod graph;
|
|
4
|
+
pub mod mesh;
|
|
5
|
+
pub mod scene;
|
|
6
|
+
pub mod sionna;
|
|
7
|
+
|
|
8
|
+
#[cfg(not(tarpaulin_include))]
|
|
9
|
+
#[pymodule(gil_used = false)]
|
|
10
|
+
pub(crate) fn geometry(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
11
|
+
m.add_wrapped(wrap_pymodule!(graph::graph))?;
|
|
12
|
+
m.add_wrapped(wrap_pymodule!(mesh::mesh))?;
|
|
13
|
+
m.add_wrapped(wrap_pymodule!(scene::scene))?;
|
|
14
|
+
m.add_wrapped(wrap_pymodule!(sionna::sionna))?;
|
|
15
|
+
Ok(())
|
|
16
|
+
}
|
|
@@ -3,29 +3,29 @@ use std::path::PathBuf;
|
|
|
3
3
|
use pyo3::{exceptions::PyValueError, prelude::*, types::PyType};
|
|
4
4
|
|
|
5
5
|
use super::sionna::SionnaScene;
|
|
6
|
-
use crate::geometry::
|
|
6
|
+
use crate::geometry::mesh::Mesh;
|
|
7
7
|
|
|
8
|
-
/// A scene that contains one mesh, usually being the results of multiple call to :meth:`
|
|
8
|
+
/// A scene that contains one mesh, usually being the results of multiple call to :meth:`Mesh.append<differt_core.geometry.Mesh.append>`.
|
|
9
9
|
///
|
|
10
10
|
/// This class is only useful to provide a fast constructor for scenes
|
|
11
11
|
/// created using the Sionna file format.
|
|
12
12
|
#[derive(Clone)]
|
|
13
|
-
#[pyclass]
|
|
14
|
-
struct
|
|
15
|
-
/// differt_core.geometry.
|
|
13
|
+
#[pyclass(subclass)]
|
|
14
|
+
struct Scene {
|
|
15
|
+
/// differt_core.geometry.Mesh: The scene mesh.
|
|
16
16
|
#[pyo3(get)]
|
|
17
|
-
mesh:
|
|
17
|
+
mesh: Mesh,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
#[pymethods]
|
|
21
|
-
impl
|
|
21
|
+
impl Scene {
|
|
22
22
|
/// Load a scene from a Sionna-compatible XML file.
|
|
23
23
|
///
|
|
24
24
|
/// Args:
|
|
25
25
|
/// file (str): The path to the XML file.
|
|
26
26
|
///
|
|
27
27
|
/// Returns:
|
|
28
|
-
///
|
|
28
|
+
/// Scene: The corresponding scene.
|
|
29
29
|
#[classmethod]
|
|
30
30
|
fn load_xml(cls: &Bound<'_, PyType>, file: &str) -> PyResult<Self> {
|
|
31
31
|
// TODO: create a Rust variant without PyType?
|
|
@@ -40,9 +40,9 @@ impl TriangleScene {
|
|
|
40
40
|
))
|
|
41
41
|
})?;
|
|
42
42
|
|
|
43
|
-
let mut mesh =
|
|
43
|
+
let mut mesh = Mesh::default();
|
|
44
44
|
|
|
45
|
-
let
|
|
45
|
+
let mesh_py_type = PyType::new::<Mesh>(cls.py());
|
|
46
46
|
|
|
47
47
|
for (_, shape) in sionna.shapes.into_iter() {
|
|
48
48
|
let mesh_file_path = folder.join(shape.file);
|
|
@@ -52,8 +52,8 @@ impl TriangleScene {
|
|
|
52
52
|
))
|
|
53
53
|
})?;
|
|
54
54
|
let mut other_mesh = match shape.r#type.as_str() {
|
|
55
|
-
"obj" =>
|
|
56
|
-
"ply" =>
|
|
55
|
+
"obj" => Mesh::load_obj(&mesh_py_type, mesh_file)?,
|
|
56
|
+
"ply" => Mesh::load_ply(&mesh_py_type, mesh_file)?,
|
|
57
57
|
ty => {
|
|
58
58
|
log::warn!("Unsupported shape type {ty}, skipping.");
|
|
59
59
|
continue;
|
|
@@ -77,7 +77,7 @@ impl TriangleScene {
|
|
|
77
77
|
|
|
78
78
|
#[cfg(not(tarpaulin_include))]
|
|
79
79
|
#[pymodule(gil_used = false)]
|
|
80
|
-
pub(crate) fn
|
|
81
|
-
m.add_class::<
|
|
80
|
+
pub(crate) fn scene(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
81
|
+
m.add_class::<Scene>()?;
|
|
82
82
|
Ok(())
|
|
83
83
|
}
|
|
@@ -8,9 +8,9 @@ use serde::{Deserialize, de};
|
|
|
8
8
|
///
|
|
9
9
|
/// Only a subset of the XML file is actually used.
|
|
10
10
|
///
|
|
11
|
-
/// This
|
|
12
|
-
/// to
|
|
13
|
-
/// :class:`
|
|
11
|
+
/// This scene acts as a bridge between Sionna and DiffeRT,
|
|
12
|
+
/// and is essentially used to quickly load scenes from Sionna
|
|
13
|
+
/// and export them as a :class:`Scene<differt.geometry.Scene>`.
|
|
14
14
|
///
|
|
15
15
|
/// Warning:
|
|
16
16
|
/// We are still open to better ways to parse those XML files,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
2
|
|
|
3
3
|
pub mod geometry;
|
|
4
|
-
pub mod rt;
|
|
5
|
-
pub mod scene;
|
|
6
4
|
|
|
7
5
|
/// Core of DiffeRT module, implemented in Rust.
|
|
8
6
|
#[cfg(not(tarpaulin_include))]
|
|
@@ -20,7 +18,5 @@ fn _differt_core(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
20
18
|
);
|
|
21
19
|
m.add("__version_info__", version_info)?;
|
|
22
20
|
m.add_wrapped(wrap_pymodule!(geometry::geometry))?;
|
|
23
|
-
m.add_wrapped(wrap_pymodule!(rt::rt))?;
|
|
24
|
-
m.add_wrapped(wrap_pymodule!(scene::scene))?;
|
|
25
21
|
Ok(())
|
|
26
22
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_triangle_mesh_deprecated() -> None:
|
|
5
|
+
from differt_core.geometry import ( # ruff:ignore[import-outside-top-level]
|
|
6
|
+
TriangleMesh,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
with pytest.warns(DeprecationWarning, match="TriangleMesh is deprecated"):
|
|
10
|
+
with pytest.raises(TypeError):
|
|
11
|
+
TriangleMesh()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_triangle_scene_deprecated() -> None:
|
|
5
|
+
from differt_core.geometry import ( # ruff:ignore[import-outside-top-level]
|
|
6
|
+
TriangleScene,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
with pytest.warns(DeprecationWarning, match="TriangleScene is deprecated"):
|
|
10
|
+
with pytest.raises(TypeError):
|
|
11
|
+
TriangleScene()
|
|
@@ -4,7 +4,7 @@ import re
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
import pytest
|
|
6
6
|
|
|
7
|
-
from differt_core.
|
|
7
|
+
from differt_core.geometry._graph import (
|
|
8
8
|
CompleteGraph,
|
|
9
9
|
DiGraph,
|
|
10
10
|
)
|
|
@@ -27,7 +27,7 @@ class TestDiGraph:
|
|
|
27
27
|
TypeError,
|
|
28
28
|
match="takes 0 positional arguments but 1 was given",
|
|
29
29
|
):
|
|
30
|
-
_ = graph.insert_from_and_to_nodes(True) #
|
|
30
|
+
_ = graph.insert_from_and_to_nodes(True) # ruff:ignore[boolean-positional-value-in-call]
|
|
31
31
|
|
|
32
32
|
@pytest.mark.parametrize("fast_mode", [True, False])
|
|
33
33
|
def test_disconnect_nodes(self, fast_mode: bool) -> None:
|
|
@@ -154,7 +154,7 @@ class TestDiGraph:
|
|
|
154
154
|
TypeError,
|
|
155
155
|
match="takes 3 positional arguments but 4 were given",
|
|
156
156
|
):
|
|
157
|
-
_ = graph.all_paths(0, 1, 0, True) #
|
|
157
|
+
_ = graph.all_paths(0, 1, 0, True) # ruff:ignore[boolean-positional-value-in-call]
|
|
158
158
|
|
|
159
159
|
@pytest.mark.parametrize(
|
|
160
160
|
("num_nodes", "depth"),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import numpy as np
|
|
3
3
|
from jaxtyping import Float, Int, UInt
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class Mesh:
|
|
6
6
|
vertices: Float[np.ndarray, "num_vertices 3"]
|
|
7
7
|
triangles: UInt[np.ndarray, "num_triangles 3"]
|
|
8
8
|
face_colors: Float[np.ndarray, "num_triangles 3"] | None
|
|
@@ -10,8 +10,8 @@ class TriangleMesh:
|
|
|
10
10
|
material_names: list[str]
|
|
11
11
|
object_bounds: UInt[np.ndarray, "num_objects 2"] | None
|
|
12
12
|
|
|
13
|
-
def append(self, other:
|
|
13
|
+
def append(self, other: Mesh) -> None: ...
|
|
14
14
|
@classmethod
|
|
15
|
-
def load_obj(cls, file: str) ->
|
|
15
|
+
def load_obj(cls, file: str) -> Mesh: ...
|
|
16
16
|
@classmethod
|
|
17
|
-
def load_ply(cls, file: str) ->
|
|
17
|
+
def load_ply(cls, file: str) -> Mesh: ...
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Geometry utilities used by :mod:`differt.geometry`."""
|
|
2
2
|
|
|
3
3
|
__all__ = (
|
|
4
4
|
"AllPathsFromCompleteGraphChunksIter",
|
|
@@ -7,6 +7,13 @@ __all__ = (
|
|
|
7
7
|
"AllPathsFromDiGraphIter",
|
|
8
8
|
"CompleteGraph",
|
|
9
9
|
"DiGraph",
|
|
10
|
+
"Material",
|
|
11
|
+
"Mesh",
|
|
12
|
+
"Scene",
|
|
13
|
+
"Shape",
|
|
14
|
+
"SionnaScene",
|
|
15
|
+
"TriangleMesh",
|
|
16
|
+
"TriangleScene",
|
|
10
17
|
)
|
|
11
18
|
|
|
12
19
|
from ._graph import (
|
|
@@ -17,3 +24,6 @@ from ._graph import (
|
|
|
17
24
|
CompleteGraph,
|
|
18
25
|
DiGraph,
|
|
19
26
|
)
|
|
27
|
+
from ._mesh import Mesh, TriangleMesh
|
|
28
|
+
from ._scene import Scene, TriangleScene
|
|
29
|
+
from ._sionna import Material, Shape, SionnaScene
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
__all__ = (
|
|
2
|
+
"AllPathsFromCompleteGraphChunksIter",
|
|
3
|
+
"AllPathsFromCompleteGraphIter",
|
|
4
|
+
"AllPathsFromDiGraphChunksIter",
|
|
5
|
+
"AllPathsFromDiGraphIter",
|
|
6
|
+
"CompleteGraph",
|
|
7
|
+
"DiGraph",
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
from differt_core import _differt_core
|
|
11
|
+
|
|
12
|
+
AllPathsFromCompleteGraphChunksIter = (
|
|
13
|
+
_differt_core.geometry.graph.AllPathsFromCompleteGraphChunksIter
|
|
14
|
+
)
|
|
15
|
+
AllPathsFromCompleteGraphIter = (
|
|
16
|
+
_differt_core.geometry.graph.AllPathsFromCompleteGraphIter
|
|
17
|
+
)
|
|
18
|
+
AllPathsFromDiGraphChunksIter = (
|
|
19
|
+
_differt_core.geometry.graph.AllPathsFromDiGraphChunksIter
|
|
20
|
+
)
|
|
21
|
+
AllPathsFromDiGraphIter = _differt_core.geometry.graph.AllPathsFromDiGraphIter
|
|
22
|
+
CompleteGraph = _differt_core.geometry.graph.CompleteGraph
|
|
23
|
+
DiGraph = _differt_core.geometry.graph.DiGraph
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
__all__ = ("Mesh", "TriangleMesh")
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import warnings
|
|
5
|
+
from typing import Any, Self
|
|
6
|
+
|
|
7
|
+
from differt_core import _differt_core
|
|
8
|
+
|
|
9
|
+
Mesh = _differt_core.geometry.mesh.Mesh
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Deprecated alias
|
|
13
|
+
class TriangleMesh(Mesh):
|
|
14
|
+
"""
|
|
15
|
+
Deprecated alias for :class:`Mesh`.
|
|
16
|
+
|
|
17
|
+
.. deprecated:: 0.10
|
|
18
|
+
Use :class:`Mesh` instead.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
|
|
22
|
+
"""Deprecated constructor."""
|
|
23
|
+
warnings.warn(
|
|
24
|
+
"TriangleMesh is deprecated, use Mesh instead.",
|
|
25
|
+
DeprecationWarning,
|
|
26
|
+
stacklevel=2,
|
|
27
|
+
)
|
|
28
|
+
return super().__new__(cls, *args, **kwargs)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
__all__ = ("Scene", "TriangleScene")
|
|
2
|
+
|
|
3
|
+
import warnings
|
|
4
|
+
from typing import Any, Self
|
|
5
|
+
|
|
6
|
+
from differt_core import _differt_core
|
|
7
|
+
|
|
8
|
+
Scene = _differt_core.geometry.scene.Scene
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Deprecated alias
|
|
12
|
+
class TriangleScene(Scene):
|
|
13
|
+
"""
|
|
14
|
+
Deprecated alias for :class:`Scene`.
|
|
15
|
+
|
|
16
|
+
.. deprecated:: 0.10
|
|
17
|
+
Use :class:`Scene` instead.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
|
|
21
|
+
"""Deprecated constructor."""
|
|
22
|
+
warnings.warn(
|
|
23
|
+
"TriangleScene is deprecated, use Scene instead.",
|
|
24
|
+
DeprecationWarning,
|
|
25
|
+
stacklevel=2,
|
|
26
|
+
)
|
|
27
|
+
return super().__new__(cls, *args, **kwargs)
|
|
@@ -9,10 +9,10 @@ use pyo3::{exceptions::PyValueError, prelude::*, types::PyType};
|
|
|
9
9
|
/// A lower-level mesh made of triangles.
|
|
10
10
|
///
|
|
11
11
|
/// This class should not be used directly, prefer its higher-level version
|
|
12
|
-
/// :class:`differt.geometry.
|
|
12
|
+
/// :class:`differt.geometry.Mesh` instead.
|
|
13
13
|
#[derive(Clone, Debug, Default)]
|
|
14
|
-
#[pyclass]
|
|
15
|
-
pub(crate) struct
|
|
14
|
+
#[pyclass(subclass)]
|
|
15
|
+
pub(crate) struct Mesh {
|
|
16
16
|
vertices: Vec<[f32; 3]>,
|
|
17
17
|
triangles: Vec<[usize; 3]>,
|
|
18
18
|
face_colors: Option<Vec<[f32; 3]>>,
|
|
@@ -77,7 +77,7 @@ impl ply::PropertyAccess for PlyFace {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
impl
|
|
80
|
+
impl Mesh {
|
|
81
81
|
pub fn get_material_index(&mut self, material_name: Option<String>) -> isize {
|
|
82
82
|
if let Some(material_name) = material_name {
|
|
83
83
|
return self
|
|
@@ -122,7 +122,7 @@ impl TriangleMesh {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
#[pymethods]
|
|
125
|
-
impl
|
|
125
|
+
impl Mesh {
|
|
126
126
|
/// :class:`Float[np.ndarray, 'num_vertices 3']<jaxtyping.Float>`: The array of triangle vertices.
|
|
127
127
|
#[getter]
|
|
128
128
|
fn vertices<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2<f32>> {
|
|
@@ -184,7 +184,7 @@ impl TriangleMesh {
|
|
|
184
184
|
/// After calling this method, ``other`` will be empty.
|
|
185
185
|
///
|
|
186
186
|
/// Args:
|
|
187
|
-
/// other(
|
|
187
|
+
/// other(Mesh): The mesh to be appended to ``self``.
|
|
188
188
|
pub(crate) fn append(&mut self, other: &mut Self) {
|
|
189
189
|
match (&self.face_colors, &other.face_colors) {
|
|
190
190
|
(None, None) => {},
|
|
@@ -268,7 +268,7 @@ impl TriangleMesh {
|
|
|
268
268
|
///
|
|
269
269
|
/// Currently, only vertices and triangles are loaded. Triangle normals
|
|
270
270
|
/// are ignored because they are computed with
|
|
271
|
-
/// :attr:`differt.geometry.
|
|
271
|
+
/// :attr:`differt.geometry.Mesh.normals` using
|
|
272
272
|
/// JAX so that they can be differentiated with respect to triangle
|
|
273
273
|
/// vertices.
|
|
274
274
|
///
|
|
@@ -276,7 +276,7 @@ impl TriangleMesh {
|
|
|
276
276
|
/// file (str): The path to the Wavefront .obj file.
|
|
277
277
|
///
|
|
278
278
|
/// Returns:
|
|
279
|
-
///
|
|
279
|
+
/// Mesh: The corresponding mesh containing only triangles.
|
|
280
280
|
#[classmethod]
|
|
281
281
|
pub(crate) fn load_obj(_: &Bound<'_, PyType>, filename: &str) -> PyResult<Self> {
|
|
282
282
|
let input = BufReader::new(File::open(filename)?);
|
|
@@ -302,7 +302,7 @@ impl TriangleMesh {
|
|
|
302
302
|
///
|
|
303
303
|
/// Currently, only vertices and triangles are loaded. Triangle normals
|
|
304
304
|
/// are ignored because they are computed with
|
|
305
|
-
/// :attr:`differt.geometry.
|
|
305
|
+
/// :attr:`differt.geometry.Mesh.normals` using
|
|
306
306
|
/// JAX so that they can be differentiated with respect to triangle
|
|
307
307
|
/// vertices.
|
|
308
308
|
///
|
|
@@ -310,7 +310,7 @@ impl TriangleMesh {
|
|
|
310
310
|
/// file (str): The path to the Stanford PLY .ply file.
|
|
311
311
|
///
|
|
312
312
|
/// Returns:
|
|
313
|
-
///
|
|
313
|
+
/// Mesh: The corresponding mesh containing only triangles.
|
|
314
314
|
#[classmethod]
|
|
315
315
|
pub(crate) fn load_ply(_: &Bound<'_, PyType>, filename: &str) -> PyResult<Self> {
|
|
316
316
|
let mut input = BufReader::new(File::open(filename)?);
|
|
@@ -380,7 +380,7 @@ impl TriangleMesh {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
impl From<RawObj> for
|
|
383
|
+
impl From<RawObj> for Mesh {
|
|
384
384
|
fn from(mut raw_obj: RawObj) -> Self {
|
|
385
385
|
use obj::raw::object::Polygon::*;
|
|
386
386
|
|
|
@@ -503,7 +503,7 @@ impl From<RawObj> for TriangleMesh {
|
|
|
503
503
|
|
|
504
504
|
#[cfg(not(tarpaulin_include))]
|
|
505
505
|
#[pymodule(gil_used = false)]
|
|
506
|
-
pub(crate) fn
|
|
507
|
-
m.add_class::<
|
|
506
|
+
pub(crate) fn mesh(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
507
|
+
m.add_class::<Mesh>()?;
|
|
508
508
|
Ok(())
|
|
509
509
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
|
+
|
|
3
|
+
pub mod graph;
|
|
4
|
+
pub mod mesh;
|
|
5
|
+
pub mod scene;
|
|
6
|
+
pub mod sionna;
|
|
7
|
+
|
|
8
|
+
#[cfg(not(tarpaulin_include))]
|
|
9
|
+
#[pymodule(gil_used = false)]
|
|
10
|
+
pub(crate) fn geometry(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
11
|
+
m.add_wrapped(wrap_pymodule!(graph::graph))?;
|
|
12
|
+
m.add_wrapped(wrap_pymodule!(mesh::mesh))?;
|
|
13
|
+
m.add_wrapped(wrap_pymodule!(scene::scene))?;
|
|
14
|
+
m.add_wrapped(wrap_pymodule!(sionna::sionna))?;
|
|
15
|
+
Ok(())
|
|
16
|
+
}
|
|
@@ -3,29 +3,29 @@ use std::path::PathBuf;
|
|
|
3
3
|
use pyo3::{exceptions::PyValueError, prelude::*, types::PyType};
|
|
4
4
|
|
|
5
5
|
use super::sionna::SionnaScene;
|
|
6
|
-
use crate::geometry::
|
|
6
|
+
use crate::geometry::mesh::Mesh;
|
|
7
7
|
|
|
8
|
-
/// A scene that contains one mesh, usually being the results of multiple call to :meth:`
|
|
8
|
+
/// A scene that contains one mesh, usually being the results of multiple call to :meth:`Mesh.append<differt_core.geometry.Mesh.append>`.
|
|
9
9
|
///
|
|
10
10
|
/// This class is only useful to provide a fast constructor for scenes
|
|
11
11
|
/// created using the Sionna file format.
|
|
12
12
|
#[derive(Clone)]
|
|
13
|
-
#[pyclass]
|
|
14
|
-
struct
|
|
15
|
-
/// differt_core.geometry.
|
|
13
|
+
#[pyclass(subclass)]
|
|
14
|
+
struct Scene {
|
|
15
|
+
/// differt_core.geometry.Mesh: The scene mesh.
|
|
16
16
|
#[pyo3(get)]
|
|
17
|
-
mesh:
|
|
17
|
+
mesh: Mesh,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
#[pymethods]
|
|
21
|
-
impl
|
|
21
|
+
impl Scene {
|
|
22
22
|
/// Load a scene from a Sionna-compatible XML file.
|
|
23
23
|
///
|
|
24
24
|
/// Args:
|
|
25
25
|
/// file (str): The path to the XML file.
|
|
26
26
|
///
|
|
27
27
|
/// Returns:
|
|
28
|
-
///
|
|
28
|
+
/// Scene: The corresponding scene.
|
|
29
29
|
#[classmethod]
|
|
30
30
|
fn load_xml(cls: &Bound<'_, PyType>, file: &str) -> PyResult<Self> {
|
|
31
31
|
// TODO: create a Rust variant without PyType?
|
|
@@ -40,9 +40,9 @@ impl TriangleScene {
|
|
|
40
40
|
))
|
|
41
41
|
})?;
|
|
42
42
|
|
|
43
|
-
let mut mesh =
|
|
43
|
+
let mut mesh = Mesh::default();
|
|
44
44
|
|
|
45
|
-
let
|
|
45
|
+
let mesh_py_type = PyType::new::<Mesh>(cls.py());
|
|
46
46
|
|
|
47
47
|
for (_, shape) in sionna.shapes.into_iter() {
|
|
48
48
|
let mesh_file_path = folder.join(shape.file);
|
|
@@ -52,8 +52,8 @@ impl TriangleScene {
|
|
|
52
52
|
))
|
|
53
53
|
})?;
|
|
54
54
|
let mut other_mesh = match shape.r#type.as_str() {
|
|
55
|
-
"obj" =>
|
|
56
|
-
"ply" =>
|
|
55
|
+
"obj" => Mesh::load_obj(&mesh_py_type, mesh_file)?,
|
|
56
|
+
"ply" => Mesh::load_ply(&mesh_py_type, mesh_file)?,
|
|
57
57
|
ty => {
|
|
58
58
|
log::warn!("Unsupported shape type {ty}, skipping.");
|
|
59
59
|
continue;
|
|
@@ -77,7 +77,7 @@ impl TriangleScene {
|
|
|
77
77
|
|
|
78
78
|
#[cfg(not(tarpaulin_include))]
|
|
79
79
|
#[pymodule(gil_used = false)]
|
|
80
|
-
pub(crate) fn
|
|
81
|
-
m.add_class::<
|
|
80
|
+
pub(crate) fn scene(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
81
|
+
m.add_class::<Scene>()?;
|
|
82
82
|
Ok(())
|
|
83
83
|
}
|
|
@@ -8,9 +8,9 @@ use serde::{Deserialize, de};
|
|
|
8
8
|
///
|
|
9
9
|
/// Only a subset of the XML file is actually used.
|
|
10
10
|
///
|
|
11
|
-
/// This
|
|
12
|
-
/// to
|
|
13
|
-
/// :class:`
|
|
11
|
+
/// This scene acts as a bridge between Sionna and DiffeRT,
|
|
12
|
+
/// and is essentially used to quickly load scenes from Sionna
|
|
13
|
+
/// and export them as a :class:`Scene<differt.geometry.Scene>`.
|
|
14
14
|
///
|
|
15
15
|
/// Warning:
|
|
16
16
|
/// We are still open to better ways to parse those XML files,
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
2
|
|
|
3
3
|
pub mod geometry;
|
|
4
|
-
pub mod rt;
|
|
5
|
-
pub mod scene;
|
|
6
4
|
|
|
7
5
|
/// Core of DiffeRT module, implemented in Rust.
|
|
8
6
|
#[cfg(not(tarpaulin_include))]
|
|
@@ -20,7 +18,5 @@ fn _differt_core(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
|
20
18
|
);
|
|
21
19
|
m.add("__version_info__", version_info)?;
|
|
22
20
|
m.add_wrapped(wrap_pymodule!(geometry::geometry))?;
|
|
23
|
-
m.add_wrapped(wrap_pymodule!(rt::rt))?;
|
|
24
|
-
m.add_wrapped(wrap_pymodule!(scene::scene))?;
|
|
25
21
|
Ok(())
|
|
26
22
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
|
-
|
|
3
|
-
pub mod triangle_mesh;
|
|
4
|
-
|
|
5
|
-
#[cfg(not(tarpaulin_include))]
|
|
6
|
-
#[pymodule(gil_used = false)]
|
|
7
|
-
pub(crate) fn geometry(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
8
|
-
m.add_wrapped(wrap_pymodule!(triangle_mesh::triangle_mesh))?;
|
|
9
|
-
Ok(())
|
|
10
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
|
-
|
|
3
|
-
pub mod sionna;
|
|
4
|
-
pub mod triangle_scene;
|
|
5
|
-
|
|
6
|
-
#[cfg(not(tarpaulin_include))]
|
|
7
|
-
#[pymodule(gil_used = false)]
|
|
8
|
-
pub(crate) fn scene(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
9
|
-
m.add_wrapped(wrap_pymodule!(sionna::sionna))?;
|
|
10
|
-
m.add_wrapped(wrap_pymodule!(triangle_scene::triangle_scene))?;
|
|
11
|
-
Ok(())
|
|
12
|
-
}
|
|
File without changes
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
__all__ = (
|
|
2
|
-
"AllPathsFromCompleteGraphChunksIter",
|
|
3
|
-
"AllPathsFromCompleteGraphIter",
|
|
4
|
-
"AllPathsFromDiGraphChunksIter",
|
|
5
|
-
"AllPathsFromDiGraphIter",
|
|
6
|
-
"CompleteGraph",
|
|
7
|
-
"DiGraph",
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
from differt_core import _differt_core
|
|
11
|
-
|
|
12
|
-
AllPathsFromCompleteGraphChunksIter = (
|
|
13
|
-
_differt_core.rt.graph.AllPathsFromCompleteGraphChunksIter
|
|
14
|
-
)
|
|
15
|
-
AllPathsFromCompleteGraphIter = _differt_core.rt.graph.AllPathsFromCompleteGraphIter
|
|
16
|
-
AllPathsFromDiGraphChunksIter = _differt_core.rt.graph.AllPathsFromDiGraphChunksIter
|
|
17
|
-
AllPathsFromDiGraphIter = _differt_core.rt.graph.AllPathsFromDiGraphIter
|
|
18
|
-
CompleteGraph = _differt_core.rt.graph.CompleteGraph
|
|
19
|
-
DiGraph = _differt_core.rt.graph.DiGraph
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
|
-
|
|
3
|
-
pub mod triangle_mesh;
|
|
4
|
-
|
|
5
|
-
#[cfg(not(tarpaulin_include))]
|
|
6
|
-
#[pymodule(gil_used = false)]
|
|
7
|
-
pub(crate) fn geometry(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
8
|
-
m.add_wrapped(wrap_pymodule!(triangle_mesh::triangle_mesh))?;
|
|
9
|
-
Ok(())
|
|
10
|
-
}
|
differt_core-0.9.0/src/rt/mod.rs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
use pyo3::{prelude::*, wrap_pymodule};
|
|
2
|
-
|
|
3
|
-
pub mod sionna;
|
|
4
|
-
pub mod triangle_scene;
|
|
5
|
-
|
|
6
|
-
#[cfg(not(tarpaulin_include))]
|
|
7
|
-
#[pymodule(gil_used = false)]
|
|
8
|
-
pub(crate) fn scene(m: Bound<'_, PyModule>) -> PyResult<()> {
|
|
9
|
-
m.add_wrapped(wrap_pymodule!(sionna::sionna))?;
|
|
10
|
-
m.add_wrapped(wrap_pymodule!(triangle_scene::triangle_scene))?;
|
|
11
|
-
Ok(())
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{differt_core-0.9.0/differt-core/src/rt → differt_core-0.10.0/differt-core/src/geometry}/graph.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,11 +13,11 @@ so that one can use :mod:`differt_core` and still be able to differentiate
|
|
|
13
13
|
its code. We welcome any contribution on that topic!
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
+
__all__ = ("__version__", "__version_info__")
|
|
17
|
+
|
|
16
18
|
from differt_core._differt_core import __version__ as _version
|
|
17
19
|
from differt_core._differt_core import __version_info__ as _version_info
|
|
18
20
|
|
|
19
|
-
__all__ = ("__version__", "__version_info__")
|
|
20
|
-
|
|
21
21
|
__version__ = _version
|
|
22
22
|
"""The current full version of this module."""
|
|
23
23
|
__version_info__ = _version_info
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|