Skip to content

Commit 84556dc

Browse files
FIX docstrings optional parameters.
1 parent 47cfeb0 commit 84556dc

File tree

4 files changed

+42
-32
lines changed

4 files changed

+42
-32
lines changed

docs/examples/example_mapping_patterns.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
# ==============================================================================
2828

2929
aabb = mesh.aabb()
30-
fixed_points = []
30+
fixed_vertices = []
3131

3232

3333
for vertex in mesh.vertices():
3434
x, y, z = mesh.vertex_attributes(vertex, "xyz") # type: ignore
3535
if abs(z-aabb.zmin) < 1e-3 or abs(z-aabb.zmax) < 1e-3:
36-
fixed_points.append(vertex)
36+
fixed_vertices.append(vertex)
3737

3838
# ==============================================================================
3939
# Mapping: 3D Mesh, 2D Pattern, UV
4040
# ==============================================================================
4141

42-
mesh_mapped0 = map_pattern_to_mesh("ZigZag", mesh, clip_boundaries=True, tolerance=1e-6, pattern_u=16, pattern_v=16, simplify_borders=True, fixed_points=fixed_points)
42+
mesh_mapped0 = map_pattern_to_mesh("ZigZag", mesh, clip_boundaries=True, tolerance=1e-6, pattern_u=16, pattern_v=16, simplify_borders=True, fixed_vertices=fixed_vertices)
4343
mesh_mapped1 = map_pattern_to_mesh("ZigZag", mesh, clip_boundaries=True, tolerance=1e-6, pattern_u=16, pattern_v=16, simplify_borders=False)
4444
# ==============================================================================
4545
# Viewer
@@ -55,7 +55,7 @@
5555
viewer.scene.add(mesh_mapped0, name="mesh_mapped0", facecolor=Color.red(), show_points=True)
5656
# viewer.scene.add(mesh_mapped1, name="mesh_mapped1", facecolor=Color.blue(), show_points=True, show_faces=False)
5757

58-
for p in fixed_points:
58+
for p in fixed_vertices:
5959
viewer.scene.add(mesh.vertex_point(p), pointcolor=Color.red(), pointsize=10)
6060

6161
viewer.show()

src/compas_libigl/mapping.py

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from compas_libigl._types_std import VectorVectorInt # noqa: F401
2727

2828

29-
def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, simplify_borders=True, fixed_points=None, tolerance=1e-6):
29+
def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, simplify_borders=True, fixed_vertices=None, tolerance=1e-6):
3030
"""
3131
Map a 2D pattern mesh onto a 3D target.
3232
@@ -36,14 +36,18 @@ def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, simplify_borders=T
3636
A tuple of (vertices, faces) representing the target mesh.
3737
pattern_mesh : tuple[list[list[float]], list[list[int]]]
3838
A tuple of (vertices, faces) representing the pattern mesh.
39-
clip_boundaries : bool
39+
clip_boundaries : bool, optional
4040
Whether to clip the pattern mesh to the boundaries of the target mesh.
41-
simplify_borders : bool
41+
Default is True.
42+
simplify_borders : bool, optional
4243
Whether to simplify the border of the pattern mesh.
43-
fixed_points : list[list[float]]
44+
Default is True.
45+
fixed_vertices : list[list[float]], optional
4446
A list of fixed points on the target mesh.
45-
tolerance : float
47+
Default is None.
48+
tolerance : float, optional
4649
The tolerance for point comparison, to remove duplicates.
50+
Default is 1e-6.
4751
4852
Returns
4953
-------
@@ -65,13 +69,13 @@ def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, simplify_borders=T
6569
f_numpy = np.array(f, dtype=np.int32)
6670
pattern_v_numpy = np.array(pv, dtype=np.float64)
6771

68-
# Handle fixed_points - provide empty array if None
72+
# Handle fixed_vertices - provide empty array if None
6973

70-
fixed_points_vectorint = VectorInt()
71-
if fixed_points is None:
72-
fixed_points_vectorint = VectorInt()
74+
fixed_vertices_vectorint = VectorInt()
75+
if fixed_vertices is None:
76+
fixed_vertices_vectorint = VectorInt()
7377
else:
74-
fixed_points_vectorint = VectorInt(fixed_points)
78+
fixed_vertices_vectorint = VectorInt(fixed_vertices)
7579

7680
# Convert pattern_f from Python list to VectorVectorInt which is expected by C++ code
7781

@@ -81,14 +85,14 @@ def map_mesh(target_mesh, pattern_mesh, clip_boundaries=True, simplify_borders=T
8185

8286
# Perform the mapping
8387
pv_numpy_copy, pf_numpy_cleaned, p_normals, pattern_is_boundary, pattern_groups = _mapping.map_mesh_with_automatic_parameterization(
84-
v_numpy, f_numpy, pattern_v_numpy, pattern_f_vec, clip_boundaries, simplify_borders, fixed_points_vectorint, tolerance
88+
v_numpy, f_numpy, pattern_v_numpy, pattern_f_vec, clip_boundaries, simplify_borders, fixed_vertices_vectorint, tolerance
8589
)
8690

8791
# Return the result as a tuple
8892
return pv_numpy_copy, pf_numpy_cleaned, p_normals, pattern_is_boundary, pattern_groups
8993

9094

91-
def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, pattern_u=16, pattern_v=16, simplify_borders=True, fixed_points=None):
95+
def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, pattern_u=16, pattern_v=16, simplify_borders=True, fixed_vertices=None):
9296
"""
9397
Map a 2D pattern mesh onto a 3D target.
9498
@@ -118,18 +122,24 @@ def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, patter
118122
119123
mesh : compas.datastructures.Mesh
120124
The target mesh.
121-
clip_boundaries : bool
125+
clip_boundaries : bool, optional
122126
Whether to clip the pattern mesh to the boundaries of the target mesh.
123-
tolerance : float
127+
Default is True.
128+
tolerance : float, optional
124129
The tolerance for point comparison, to remove duplicates.
125-
pattern_u : int
130+
Default is 1e-6.
131+
pattern_u : int, optional
126132
The number of pattern vertices in the u direction.
127-
pattern_v : int
133+
Default is 16.
134+
pattern_v : int, optional
128135
The number of pattern vertices in the v direction.
129-
simplify_borders : bool
136+
Default is 16.
137+
simplify_borders : bool, optional
130138
Whether to simplify the border of the pattern mesh.
131-
fixed_points : list[list[float]]
139+
Default is True.
140+
fixed_vertices : list[list[float]], optional
132141
A list of fixed points on the target mesh.
142+
Default is None.
133143
134144
Returns
135145
-------
@@ -188,7 +198,7 @@ def map_pattern_to_mesh(name, mesh, clip_boundaries=True, tolerance=1e-6, patter
188198

189199
v, f = mesh.to_vertices_and_faces()
190200
mapped_vertices, mapped_faces, mapped_normals, mapped_is_boundary, mapped_groups = map_mesh(
191-
(v, f), (pv, pf), clip_boundaries=clip_boundaries, simplify_borders=simplify_borders, fixed_points=fixed_points, tolerance=tolerance
201+
(v, f), (pv, pf), clip_boundaries=clip_boundaries, simplify_borders=simplify_borders, fixed_vertices=fixed_vertices, tolerance=tolerance
192202
)
193203

194204
return Mesh.from_vertices_and_faces(mapped_vertices, mapped_faces)

src/mapping.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, std::vector<bool>
172172
const std::vector<std::vector<int>>& pattern_f,
173173
bool clip_boundaries,
174174
bool simplify_borders,
175-
std::vector<int>& fixed_points,
175+
std::vector<int>& fixed_vertices,
176176
double tolerance
177177
)
178178
{
@@ -181,7 +181,7 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, std::vector<bool>
181181
// Fixed points
182182
////////////////////////////////////////////////////////////////////////////////////////
183183
Clipper2Lib::PathD fixed;
184-
for (const auto &point_id : fixed_points){
184+
for (const auto &point_id : fixed_vertices){
185185
fixed.emplace_back(Clipper2Lib::PointD(flattned_target_uv(point_id, 0), flattned_target_uv(point_id, 1)));
186186
}
187187

@@ -449,7 +449,7 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, compas::RowMatrix
449449
const std::vector<std::vector<int>>& pattern_f,
450450
bool clip_boundaries,
451451
bool simplify_borders,
452-
std::vector<int>& fixed_points,
452+
std::vector<int>& fixed_vertices,
453453
double tolerance)
454454
{
455455

@@ -486,7 +486,7 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, compas::RowMatrix
486486

487487

488488
// Clip the pattern
489-
auto [clipped_pattern_v, clipped_pattern_f, clipped_pattern_is_boundary, clipped_pattern_groups] = eigen_to_clipper(target_uv, target_f, pattern_v, pattern_f, clip_boundaries, simplify_borders, fixed_points, tolerance);
489+
auto [clipped_pattern_v, clipped_pattern_f, clipped_pattern_is_boundary, clipped_pattern_groups] = eigen_to_clipper(target_uv, target_f, pattern_v, pattern_f, clip_boundaries, simplify_borders, fixed_vertices, tolerance);
490490

491491
Eigen::MatrixXd clipped_pattern_uv;
492492
clipped_pattern_uv.setZero();
@@ -523,7 +523,7 @@ NB_MODULE(_mapping, m)
523523
"pattern_f"_a,
524524
"clip_boundaries"_a,
525525
"simplify_borders"_a,
526-
"fixed_points"_a,
526+
"fixed_vertices"_a,
527527
"tolerance"_a
528528
);
529529
}

src/mapping.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool paths_intersect(const Clipper2Lib::PathsD& paths1, const Clipper2Lib::Paths
7474
* @param pattern_f The pattern mesh face indices.
7575
* @param clip_boundaries Whether to clip the pattern mesh to the boundaries of the target mesh.
7676
* @param simplify_borders Whether to simplify the border of the pattern mesh.
77-
* @param fixed_points fixed points on the target mesh
77+
* @param fixed_vertices fixed points on the target mesh
7878
* @param tolerance The tolerance for point comparison, to remove duplicates.
7979
* @return A tuple of the clipped pattern mesh vertex coordinates and face indices.
8080
*/
@@ -86,7 +86,7 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, std::vector<bool>
8686
const std::vector<std::vector<int>>& pattern_f,
8787
bool clip_boundaries,
8888
bool simplify_borders,
89-
std::vector<int>& fixed_points,
89+
std::vector<int>& fixed_vertices,
9090
double tolerance = 1e-6
9191
) ;
9292

@@ -101,7 +101,7 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, std::vector<bool>
101101
* @param pattern_f vector of vectors of int of pattern mesh triangle indices
102102
* @param clip_boundaries whether to clip the pattern mesh to the boundaries of the target mesh
103103
* @param simplify_borders whether to simplify the border of the pattern mesh
104-
* @param fixed_points fixed points on the target mesh
104+
* @param fixed_vertices fixed points on the target mesh
105105
* @param tolerance tolerance for point comparison, to remove duplicates
106106
* @return A tuple containing the mapped pattern vertices, faces, and vertex normal vectors.
107107
*/
@@ -112,6 +112,6 @@ std::tuple<compas::RowMatrixXd, std::vector<std::vector<int>>, compas::RowMatrix
112112
const std::vector<std::vector<int>>& pattern_f,
113113
bool clip_boundaries,
114114
bool simplify_borders,
115-
std::vector<int>& fixed_points,
115+
std::vector<int>& fixed_vertices,
116116
double tolerance = 1e-6
117117
);

0 commit comments

Comments
 (0)