Skip to content

Commit 1a47898

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 3af7afb + 6cae924 commit 1a47898

26 files changed

+96
-134
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222

2323
### Removed
2424

25+
* Removed all the types_std imports from the code. Instead type casters are used: https://nanobind.readthedocs.io/en/latest/exchanging.html .
26+
2527

2628
## [0.7.1] 2025-06-24
2729

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,14 @@ function(add_nanobind_module module_name source_file)
150150
endfunction()
151151

152152
# === Add your modules ===
153-
add_nanobind_module(_nanobind src/nanobind.cpp)
154-
add_nanobind_module(_types_std src/types_std.cpp)
155153
add_nanobind_module(_boundaries src/boundaries.cpp)
156154
add_nanobind_module(_curvature src/curvature.cpp)
157155
add_nanobind_module(_geodistance src/geodistance.cpp)
158156
add_nanobind_module(_intersections src/intersections.cpp)
159157
add_nanobind_module(_isolines src/isolines.cpp)
160-
add_nanobind_module(_massmatrix src/massmatrix.cpp)
158+
add_nanobind_module(_mapping src/mapping.cpp)
161159
add_nanobind_module(_meshing src/meshing.cpp)
160+
add_nanobind_module(_massmatrix src/massmatrix.cpp)
162161
add_nanobind_module(_parametrisation src/parametrisation.cpp)
163162
add_nanobind_module(_planarize src/planarize.cpp)
164-
add_nanobind_module(_mapping src/mapping.cpp)
163+

mesh_flattened.json

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

src/boundaries.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "boundaries.hpp"
22

3-
std::vector<std::vector<int>> trimesh_boundaries( Eigen::Ref<const compas::RowMatrixXi> F) {
4-
std::vector<std::vector<int>> L;
3+
compas::VectorVectorInt trimesh_boundaries( Eigen::Ref<const compas::RowMatrixXi> F) {
4+
compas::VectorVectorInt L;
55
igl::boundary_loop(F, L);
66
return L;
77
}

src/boundaries.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
*
1212
* @note The input mesh should be manifold for correct results.
1313
*/
14-
std::vector<std::vector<int>> trimesh_boundaries(Eigen::Ref<const compas::RowMatrixXi> F);
14+
compas::VectorVectorInt trimesh_boundaries(Eigen::Ref<const compas::RowMatrixXi> F);

src/compas.hpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,46 @@
1111
#include <cmath>
1212
#include <iostream>
1313
#include <limits>
14-
#include <iostream>
14+
#include <unordered_map>
15+
#include <tuple>
16+
#include <iomanip>
1517

1618
// Nanobind includes
1719
#include <nanobind/nanobind.h>
1820
#include <nanobind/eigen/dense.h>
1921
#include <nanobind/eigen/sparse.h>
2022
#include <nanobind/stl/tuple.h>
21-
#include <nanobind/stl/bind_vector.h>
23+
#include <nanobind/stl/vector.h>
2224
#include <nanobind/stl/string.h>
2325

26+
namespace nb = nanobind;
27+
28+
using namespace nb::literals;
29+
30+
// Nanobind type casters: https://nanobind.readthedocs.io/en/latest/exchanging.html
31+
2432
namespace compas {
33+
// Basic Eigen types with clear naming
2534
using RowMatrixXd = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
2635
using RowMatrixXi = Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
27-
}
28-
29-
namespace nb = nanobind;
30-
31-
using namespace nb::literals;
36+
using VectorXi = Eigen::VectorXi;
37+
using VectorXd = Eigen::VectorXd;
38+
39+
// STL containers with descriptive names
40+
using VectorInt = std::vector<int>;
41+
using VectorFloat = std::vector<float>;
42+
using VectorBool = std::vector<bool>;
43+
using VectorVectorInt = std::vector<VectorInt>;
44+
45+
// Complex types with descriptive names
46+
using TupleIntFloatFloatFloat = std::tuple<int, float, float, float>; // face_id, u, v, t
47+
using VectorTupleIntFloatFloatFloat = std::vector<TupleIntFloatFloatFloat>;
48+
using VectorVectorTupleIntFloatFloatFloat = std::vector<VectorTupleIntFloatFloatFloat>;
49+
50+
// Tuple types with descriptive names
51+
using IsolinesResult = std::tuple<RowMatrixXd, RowMatrixXi, RowMatrixXi>; // vertices, edges, indices
52+
using RemeshIsolineResult = std::tuple<RowMatrixXd, RowMatrixXi, VectorXi>; // vertices, faces, labels
53+
using RemeshIsolinesResult = std::tuple<RowMatrixXd, RowMatrixXi, VectorXd, VectorXi>; // vertices, faces, scalar_values, face_groups
54+
using PrincipalCurvatureResult = std::tuple<RowMatrixXd, RowMatrixXd, VectorXd, VectorXd>; // PD1, PD2, PV1, PV2
55+
using MeshMapResult = std::tuple<RowMatrixXd, VectorVectorInt, RowMatrixXd, VectorBool, VectorInt>; // pattern_vertices, pattern_faces, pattern_normals, is_boundary, groups
56+
}

src/compas_libigl/boundaries.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import numpy as np
22

33
from compas_libigl import _boundaries
4-
from compas_libigl import _types_std # noqa: F401
54

65

76
def trimesh_boundaries(M):
@@ -29,5 +28,5 @@ def trimesh_boundaries(M):
2928
"""
3029
V, F = M
3130
F = np.asarray(F, dtype=np.int32)
32-
result: _types_std.VectorVectorInt = _boundaries.trimesh_boundaries(F)
31+
result = _boundaries.trimesh_boundaries(F)
3332
return [list(loop) for loop in result]

src/compas_libigl/intersections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from compas.plugins import plugin
33

44
from compas_libigl import _intersections
5-
from compas_libigl import _types_std # noqa: F401
65

76

87
@plugin(category="intersections")

src/compas_libigl/mapping.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from tessagon.types.zig_zag_tessagon import ZigZagTessagon
2222

2323
from compas_libigl import _mapping # type: ignore
24-
from compas_libigl import _types_std # noqa: F401
2524

2625
TESSAGON_TYPES = {
2726
"Hex": HexTessagon,
@@ -90,15 +89,15 @@ def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, simplify_borders=T
9089

9190
# Handle fixed_vertices - provide empty array if None
9291

93-
fixed_vertices_vectorint = _types_std.VectorInt()
92+
fixed_vertices_vectorint = []
9493
if fixed_vertices is None:
95-
fixed_vertices_vectorint = _types_std.VectorInt()
94+
fixed_vertices_vectorint = []
9695
else:
97-
fixed_vertices_vectorint = _types_std.VectorInt(fixed_vertices)
96+
fixed_vertices_vectorint = fixed_vertices
9897

9998
# Convert pattern_f from Python list to VectorVectorInt which is expected by C++ code
10099

101-
pattern_f_vec = _types_std.VectorVectorInt()
100+
pattern_f_vec = []
102101
for face in pf:
103102
pattern_f_vec.append(face)
104103

src/compas_libigl/parametrisation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from compas.plugins import plugin
33

44
from compas_libigl import _parametrisation
5-
from compas_libigl import _types_std # noqa: F401
65

76

87
@plugin(category="trimesh")

0 commit comments

Comments
 (0)