Skip to content

Commit 397ba98

Browse files
authored
Merge pull request #61 from jf---/jf/standardize-cpp-params
Jf/standardize cpp params
2 parents 193cd06 + 040eb63 commit 397ba98

File tree

9 files changed

+76
-71
lines changed

9 files changed

+76
-71
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
### Changed
2222
* Added optional surface meshing parameters (`sm_angle`, `sm_radius`, `sm_distance`) to `compas_cgal.reconstruction.poisson_surface_reconstruction` for controlling mesh quality and density.
2323

24+
- `subdivision`: pass-by-value → Eigen::Ref<const> (3 functions)
25+
- `straight_skeleton_2`: const& → Eigen::Ref<const> (8 functions)
26+
- `triangulation`: added const to all Eigen::Ref params (3 functions)
27+
- `meshing`: removed extra & and added const (7 functions)
28+
2429
### Removed
2530

2631

src/meshing.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ typedef boost::graph_traits<Dual>::edge_descriptor edge_descriptor;
3939

4040
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
4141
pmp_trimesh_remesh(
42-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
43-
Eigen::Ref<compas::RowMatrixXi> faces_a,
42+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
43+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
4444
double target_edge_length,
4545
unsigned int number_of_iterations,
4646
bool do_project)
@@ -132,13 +132,13 @@ std::vector<double> get_vertex_areas(compas::Mesh mesh, std::vector<double> face
132132
}
133133

134134
std::tuple<
135-
compas::RowMatrixXd,
135+
compas::RowMatrixXd,
136136
compas::RowMatrixXi,
137-
compas::RowMatrixXd,
137+
compas::RowMatrixXd,
138138
std::vector<std::vector<int>>>
139139
pmp_trimesh_remesh_dual(
140-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
141-
Eigen::Ref<compas::RowMatrixXi> faces_a,
140+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
141+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
142142
const std::vector<int>& fixed_vertices,
143143
double length_factor,
144144
unsigned int number_of_iterations,
@@ -693,8 +693,8 @@ pmp_trimesh_remesh_dual(
693693
}
694694

695695
void pmp_pull(
696-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
697-
Eigen::Ref<compas::RowMatrixXi> faces_a,
696+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
697+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
698698
Eigen::Ref<compas::RowMatrixXd> vertices_b,
699699
Eigen::Ref<compas::RowMatrixXd> normals_b)
700700
{
@@ -823,8 +823,8 @@ void pmp_pull(
823823

824824

825825
void pmp_project(
826-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
827-
Eigen::Ref<compas::RowMatrixXi> faces_a,
826+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
827+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
828828
Eigen::Ref<compas::RowMatrixXd> vertices_b)
829829
{
830830
/////////////////////////////////////////////////////////////////////////////////

src/meshing.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ namespace compas {
2020
* @return Surface area of the mesh
2121
*/
2222
double pmp_area(
23-
Eigen::Ref<const RowMatrixXd>& vertices,
24-
Eigen::Ref<const RowMatrixXi>& faces);
23+
Eigen::Ref<const RowMatrixXd> vertices,
24+
Eigen::Ref<const RowMatrixXi> faces);
2525

2626
/**
2727
* @brief Calculate the volume enclosed by a mesh
@@ -30,8 +30,8 @@ namespace compas {
3030
* @return Volume enclosed by the mesh
3131
*/
3232
double pmp_volume(
33-
Eigen::Ref<const RowMatrixXd>& vertices,
34-
Eigen::Ref<const RowMatrixXi>& faces);
33+
Eigen::Ref<const RowMatrixXd> vertices,
34+
Eigen::Ref<const RowMatrixXi> faces);
3535

3636
/**
3737
* @brief Calculate the centroid of a mesh
@@ -40,8 +40,8 @@ namespace compas {
4040
* @return Coordinates of the mesh centroid
4141
*/
4242
std::vector<double> pmp_centroid(
43-
Eigen::Ref<const RowMatrixXd>& vertices,
44-
Eigen::Ref<const RowMatrixXi>& faces);
43+
Eigen::Ref<const RowMatrixXd> vertices,
44+
Eigen::Ref<const RowMatrixXi> faces);
4545

4646
} // namespace compas
4747

@@ -59,8 +59,8 @@ namespace compas {
5959
*/
6060
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
6161
pmp_trimesh_remesh(
62-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
63-
Eigen::Ref<compas::RowMatrixXi> faces_a,
62+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
63+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
6464
double target_edge_length,
6565
unsigned int number_of_iterations = 10,
6666
bool do_project = true);
@@ -79,13 +79,13 @@ pmp_trimesh_remesh(
7979
*/
8080

8181
std::tuple<
82-
compas::RowMatrixXd,
82+
compas::RowMatrixXd,
8383
compas::RowMatrixXi,
84-
compas::RowMatrixXd,
85-
std::vector<std::vector<int>>>
84+
compas::RowMatrixXd,
85+
std::vector<std::vector<int>>>
8686
pmp_trimesh_remesh_dual(
87-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
88-
Eigen::Ref<compas::RowMatrixXi> faces_a,
87+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
88+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
8989
const std::vector<int>& fixed_vertices,
9090
double length_factor=1.0,
9191
unsigned int number_of_iterations=10,
@@ -103,8 +103,8 @@ pmp_trimesh_remesh_dual(
103103
*/
104104

105105
void pmp_pull(
106-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
107-
Eigen::Ref<compas::RowMatrixXi> faces_a,
106+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
107+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
108108
Eigen::Ref<compas::RowMatrixXd> vertices_b,
109109
Eigen::Ref<compas::RowMatrixXd> normals_b);
110110

@@ -116,6 +116,6 @@ void pmp_pull(
116116
* @param vertices_b Matrix of vertex positions as Nx3 matrix in row-major order (float64)
117117
*/
118118
void pmp_project(
119-
Eigen::Ref<compas::RowMatrixXd> vertices_a,
120-
Eigen::Ref<compas::RowMatrixXi> faces_a,
119+
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
120+
Eigen::Ref<const compas::RowMatrixXi> faces_a,
121121
Eigen::Ref<compas::RowMatrixXd> vertices_b);

src/straight_skeleton_2.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ data_to_polygon_with_holes(
126126

127127
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
128128
pmp_create_interior_straight_skeleton(
129-
const compas::RowMatrixXd& vertices)
129+
Eigen::Ref<const compas::RowMatrixXd> vertices)
130130
{
131131
Polygon_2 polygon = data_to_polygon(vertices);
132132
SsPtr skeleton = CGAL::create_interior_straight_skeleton_2(polygon.vertices_begin(), polygon.vertices_end());
@@ -135,7 +135,7 @@ pmp_create_interior_straight_skeleton(
135135

136136
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
137137
pmp_create_interior_straight_skeleton_with_holes(
138-
const compas::RowMatrixXd& boundary_vertices,
138+
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
139139
const std::vector<compas::RowMatrixXd>& hole_vertices)
140140
{
141141
Polygon_with_holes polygon = data_to_polygon_with_holes(boundary_vertices, hole_vertices);
@@ -145,7 +145,7 @@ pmp_create_interior_straight_skeleton_with_holes(
145145

146146
std::vector<compas::RowMatrixXd>
147147
pmp_create_offset_polygons_2_inner(
148-
const compas::RowMatrixXd& vertices,
148+
Eigen::Ref<const compas::RowMatrixXd> vertices,
149149
double& offset_distance)
150150
{
151151
Polygon_2 polygon = data_to_polygon(vertices);
@@ -161,7 +161,7 @@ pmp_create_offset_polygons_2_inner(
161161

162162
std::vector<std::vector<compas::RowMatrixXd>>
163163
pmp_create_offset_polygons_2_inner_with_holes(
164-
const compas::RowMatrixXd& boundary_vertices,
164+
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
165165
const std::vector<compas::RowMatrixXd>& hole_vertices,
166166
double& offset_distance)
167167
{
@@ -188,7 +188,7 @@ pmp_create_offset_polygons_2_inner_with_holes(
188188

189189
std::vector<compas::RowMatrixXd>
190190
pmp_create_offset_polygons_2_outer(
191-
const compas::RowMatrixXd& vertices,
191+
Eigen::Ref<const compas::RowMatrixXd> vertices,
192192
double& offset_distance)
193193
{
194194
Polygon_2 polygon = data_to_polygon(vertices);
@@ -204,7 +204,7 @@ pmp_create_offset_polygons_2_outer(
204204

205205
std::vector<std::vector<compas::RowMatrixXd>>
206206
pmp_create_offset_polygons_2_outer_with_holes(
207-
const compas::RowMatrixXd& boundary_vertices,
207+
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
208208
const std::vector<compas::RowMatrixXd>& hole_vertices,
209209
double& offset_distance)
210210
{
@@ -226,9 +226,9 @@ pmp_create_offset_polygons_2_outer_with_holes(
226226

227227
std::vector<compas::RowMatrixXd>
228228
pmp_create_weighted_offset_polygons_2_inner(
229-
const compas::RowMatrixXd& vertices,
229+
Eigen::Ref<const compas::RowMatrixXd> vertices,
230230
double offset_distance,
231-
const compas::RowMatrixXd& edge_weights)
231+
Eigen::Ref<const compas::RowMatrixXd> edge_weights)
232232
{
233233
if (edge_weights.rows() != vertices.rows()) {
234234
throw std::invalid_argument("Number of weights must match number of polygon vertices");
@@ -264,9 +264,9 @@ pmp_create_weighted_offset_polygons_2_inner(
264264

265265
std::vector<compas::RowMatrixXd>
266266
pmp_create_weighted_offset_polygons_2_outer(
267-
const compas::RowMatrixXd& vertices,
267+
Eigen::Ref<const compas::RowMatrixXd> vertices,
268268
double offset_distance,
269-
const compas::RowMatrixXd& edge_weights)
269+
Eigen::Ref<const compas::RowMatrixXd> edge_weights)
270270
{
271271
if (edge_weights.rows() != vertices.rows()) {
272272
throw std::invalid_argument("Number of weights must match number of polygon vertices");

src/straight_skeleton_2.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
* - Matrix of skeleton edges as vertex pairs (Kx2, int32)
2323
* - Vector of source edge indices from input polygon for each skeleton edge
2424
*/
25-
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
25+
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
2626
pmp_create_interior_straight_skeleton(
27-
const compas::RowMatrixXd& vertices
27+
Eigen::Ref<const compas::RowMatrixXd> vertices
2828
);
2929

3030
/**
@@ -38,9 +38,9 @@ pmp_create_interior_straight_skeleton(
3838
* - Matrix of skeleton edges as vertex pairs (Qx2, int32)
3939
* - Vector of source edge indices from input polygon for each skeleton edge
4040
*/
41-
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
41+
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
4242
pmp_create_interior_straight_skeleton_with_holes(
43-
const compas::RowMatrixXd& boundary_vertices,
43+
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
4444
const std::vector<compas::RowMatrixXd>& hole_vertices
4545
);
4646

@@ -53,7 +53,7 @@ pmp_create_interior_straight_skeleton_with_holes(
5353
*/
5454
std::vector<compas::RowMatrixXd>
5555
pmp_create_offset_polygons_2_inner(
56-
const compas::RowMatrixXd& vertices,
56+
Eigen::Ref<const compas::RowMatrixXd> vertices,
5757
double& offset_distance
5858
);
5959

@@ -68,7 +68,7 @@ pmp_create_offset_polygons_2_inner(
6868
*/
6969
std::vector<std::vector<compas::RowMatrixXd>>
7070
pmp_create_offset_polygons_2_inner_with_holes(
71-
const compas::RowMatrixXd& boundary_vertices,
71+
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
7272
const std::vector<compas::RowMatrixXd>& hole_vertices,
7373
double& offset_distance
7474
);
@@ -88,7 +88,7 @@ pmp_create_offset_polygons_2_inner_with_holes(
8888
*/
8989
std::vector<compas::RowMatrixXd>
9090
pmp_create_offset_polygons_2_outer(
91-
const compas::RowMatrixXd& vertices,
91+
Eigen::Ref<const compas::RowMatrixXd> vertices,
9292
double& offset_distance
9393
);
9494

@@ -103,7 +103,7 @@ pmp_create_offset_polygons_2_outer(
103103
*/
104104
std::vector<std::vector<compas::RowMatrixXd>>
105105
pmp_create_offset_polygons_2_outer_with_holes(
106-
const compas::RowMatrixXd& boundary_vertices,
106+
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
107107
const std::vector<compas::RowMatrixXd>& hole_vertices,
108108
double& offset_distance
109109
);
@@ -120,9 +120,9 @@ pmp_create_offset_polygons_2_outer_with_holes(
120120
*/
121121
std::vector<compas::RowMatrixXd>
122122
pmp_create_weighted_offset_polygons_2_inner(
123-
const compas::RowMatrixXd& vertices,
123+
Eigen::Ref<const compas::RowMatrixXd> vertices,
124124
double offset_distance,
125-
const compas::RowMatrixXd& edge_weights
125+
Eigen::Ref<const compas::RowMatrixXd> edge_weights
126126
);
127127

128128
/**
@@ -137,9 +137,9 @@ pmp_create_weighted_offset_polygons_2_inner(
137137
*/
138138
std::vector<compas::RowMatrixXd>
139139
pmp_create_weighted_offset_polygons_2_outer(
140-
const compas::RowMatrixXd& vertices,
140+
Eigen::Ref<const compas::RowMatrixXd> vertices,
141141
double offset_distance,
142-
const compas::RowMatrixXd& edge_weights
142+
Eigen::Ref<const compas::RowMatrixXd> edge_weights
143143
);
144144

145145
void init_straight_skeleton_2(nb::module_& m);

src/subdivision.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
44
subd_catmullclark(
5-
compas::RowMatrixXd vertices,
6-
std::vector<std::vector<int>> faces,
5+
Eigen::Ref<const compas::RowMatrixXd> vertices,
6+
const std::vector<std::vector<int>>& faces,
77
unsigned int num_iterations)
88
{
99
compas::Mesh mesh = compas::ngon_from_vertices_and_faces(vertices, faces);
@@ -14,8 +14,8 @@ subd_catmullclark(
1414

1515
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
1616
subd_loop(
17-
compas::RowMatrixXd vertices,
18-
compas::RowMatrixXi faces,
17+
Eigen::Ref<const compas::RowMatrixXd> vertices,
18+
Eigen::Ref<const compas::RowMatrixXi> faces,
1919
unsigned int num_iterations)
2020
{
2121
compas::Mesh mesh = compas::mesh_from_vertices_and_faces(vertices, faces);
@@ -26,8 +26,8 @@ subd_loop(
2626

2727
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
2828
subd_sqrt3(
29-
compas::RowMatrixXd vertices,
30-
compas::RowMatrixXi faces,
29+
Eigen::Ref<const compas::RowMatrixXd> vertices,
30+
Eigen::Ref<const compas::RowMatrixXi> faces,
3131
unsigned int num_iterations)
3232
{
3333
compas::Mesh mesh = compas::mesh_from_vertices_and_faces(vertices, faces);

src/subdivision.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
2020
subd_catmullclark(
21-
compas::RowMatrixXd vertices,
22-
std::vector<std::vector<int>> faces,
21+
Eigen::Ref<const compas::RowMatrixXd> vertices,
22+
const std::vector<std::vector<int>>& faces,
2323
unsigned int num_iterations);
2424

2525
/**
@@ -35,8 +35,8 @@ subd_catmullclark(
3535
*/
3636
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
3737
subd_loop(
38-
compas::RowMatrixXd vertices,
39-
compas::RowMatrixXi faces,
38+
Eigen::Ref<const compas::RowMatrixXd> vertices,
39+
Eigen::Ref<const compas::RowMatrixXi> faces,
4040
unsigned int num_iterations);
4141

4242
/**
@@ -52,6 +52,6 @@ subd_loop(
5252
*/
5353
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
5454
subd_sqrt3(
55-
compas::RowMatrixXd vertices,
56-
compas::RowMatrixXi faces,
55+
Eigen::Ref<const compas::RowMatrixXd> vertices,
56+
Eigen::Ref<const compas::RowMatrixXi> faces,
5757
unsigned int num_iterations);

0 commit comments

Comments
 (0)