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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- `subdivision`: pass-by-value → Eigen::Ref<const> (3 functions)
- `straight_skeleton_2`: const& → Eigen::Ref<const> (8 functions)
- `triangulation`: added const to all Eigen::Ref params (3 functions)
- `meshing`: removed extra & and added const (7 functions)

### Removed


Expand Down
20 changes: 10 additions & 10 deletions src/meshing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ typedef boost::graph_traits<Dual>::edge_descriptor edge_descriptor;

std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
pmp_trimesh_remesh(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
double target_edge_length,
unsigned int number_of_iterations,
bool do_project)
Expand Down Expand Up @@ -132,13 +132,13 @@ std::vector<double> get_vertex_areas(compas::Mesh mesh, std::vector<double> face
}

std::tuple<
compas::RowMatrixXd,
compas::RowMatrixXd,
compas::RowMatrixXi,
compas::RowMatrixXd,
compas::RowMatrixXd,
std::vector<std::vector<int>>>
pmp_trimesh_remesh_dual(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
const std::vector<int>& fixed_vertices,
double length_factor,
unsigned int number_of_iterations,
Expand Down Expand Up @@ -693,8 +693,8 @@ pmp_trimesh_remesh_dual(
}

void pmp_pull(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
Eigen::Ref<compas::RowMatrixXd> vertices_b,
Eigen::Ref<compas::RowMatrixXd> normals_b)
{
Expand Down Expand Up @@ -823,8 +823,8 @@ void pmp_pull(


void pmp_project(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
Eigen::Ref<compas::RowMatrixXd> vertices_b)
{
/////////////////////////////////////////////////////////////////////////////////
Expand Down
34 changes: 17 additions & 17 deletions src/meshing.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ namespace compas {
* @return Surface area of the mesh
*/
double pmp_area(
Eigen::Ref<const RowMatrixXd>& vertices,
Eigen::Ref<const RowMatrixXi>& faces);
Eigen::Ref<const RowMatrixXd> vertices,
Eigen::Ref<const RowMatrixXi> faces);

/**
* @brief Calculate the volume enclosed by a mesh
Expand All @@ -30,8 +30,8 @@ namespace compas {
* @return Volume enclosed by the mesh
*/
double pmp_volume(
Eigen::Ref<const RowMatrixXd>& vertices,
Eigen::Ref<const RowMatrixXi>& faces);
Eigen::Ref<const RowMatrixXd> vertices,
Eigen::Ref<const RowMatrixXi> faces);

/**
* @brief Calculate the centroid of a mesh
Expand All @@ -40,8 +40,8 @@ namespace compas {
* @return Coordinates of the mesh centroid
*/
std::vector<double> pmp_centroid(
Eigen::Ref<const RowMatrixXd>& vertices,
Eigen::Ref<const RowMatrixXi>& faces);
Eigen::Ref<const RowMatrixXd> vertices,
Eigen::Ref<const RowMatrixXi> faces);

} // namespace compas

Expand All @@ -59,8 +59,8 @@ namespace compas {
*/
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
pmp_trimesh_remesh(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
double target_edge_length,
unsigned int number_of_iterations = 10,
bool do_project = true);
Expand All @@ -79,13 +79,13 @@ pmp_trimesh_remesh(
*/

std::tuple<
compas::RowMatrixXd,
compas::RowMatrixXd,
compas::RowMatrixXi,
compas::RowMatrixXd,
std::vector<std::vector<int>>>
compas::RowMatrixXd,
std::vector<std::vector<int>>>
pmp_trimesh_remesh_dual(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
const std::vector<int>& fixed_vertices,
double length_factor=1.0,
unsigned int number_of_iterations=10,
Expand All @@ -103,8 +103,8 @@ pmp_trimesh_remesh_dual(
*/

void pmp_pull(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
Eigen::Ref<compas::RowMatrixXd> vertices_b,
Eigen::Ref<compas::RowMatrixXd> normals_b);

Expand All @@ -116,6 +116,6 @@ void pmp_pull(
* @param vertices_b Matrix of vertex positions as Nx3 matrix in row-major order (float64)
*/
void pmp_project(
Eigen::Ref<compas::RowMatrixXd> vertices_a,
Eigen::Ref<compas::RowMatrixXi> faces_a,
Eigen::Ref<const compas::RowMatrixXd> vertices_a,
Eigen::Ref<const compas::RowMatrixXi> faces_a,
Eigen::Ref<compas::RowMatrixXd> vertices_b);
20 changes: 10 additions & 10 deletions src/straight_skeleton_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ data_to_polygon_with_holes(

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

std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
pmp_create_interior_straight_skeleton_with_holes(
const compas::RowMatrixXd& boundary_vertices,
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
const std::vector<compas::RowMatrixXd>& hole_vertices)
{
Polygon_with_holes polygon = data_to_polygon_with_holes(boundary_vertices, hole_vertices);
Expand All @@ -145,7 +145,7 @@ pmp_create_interior_straight_skeleton_with_holes(

std::vector<compas::RowMatrixXd>
pmp_create_offset_polygons_2_inner(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double& offset_distance)
{
Polygon_2 polygon = data_to_polygon(vertices);
Expand All @@ -161,7 +161,7 @@ pmp_create_offset_polygons_2_inner(

std::vector<std::vector<compas::RowMatrixXd>>
pmp_create_offset_polygons_2_inner_with_holes(
const compas::RowMatrixXd& boundary_vertices,
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
const std::vector<compas::RowMatrixXd>& hole_vertices,
double& offset_distance)
{
Expand All @@ -188,7 +188,7 @@ pmp_create_offset_polygons_2_inner_with_holes(

std::vector<compas::RowMatrixXd>
pmp_create_offset_polygons_2_outer(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double& offset_distance)
{
Polygon_2 polygon = data_to_polygon(vertices);
Expand All @@ -204,7 +204,7 @@ pmp_create_offset_polygons_2_outer(

std::vector<std::vector<compas::RowMatrixXd>>
pmp_create_offset_polygons_2_outer_with_holes(
const compas::RowMatrixXd& boundary_vertices,
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
const std::vector<compas::RowMatrixXd>& hole_vertices,
double& offset_distance)
{
Expand All @@ -226,9 +226,9 @@ pmp_create_offset_polygons_2_outer_with_holes(

std::vector<compas::RowMatrixXd>
pmp_create_weighted_offset_polygons_2_inner(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double offset_distance,
const compas::RowMatrixXd& edge_weights)
Eigen::Ref<const compas::RowMatrixXd> edge_weights)
{
if (edge_weights.rows() != vertices.rows()) {
throw std::invalid_argument("Number of weights must match number of polygon vertices");
Expand Down Expand Up @@ -264,9 +264,9 @@ pmp_create_weighted_offset_polygons_2_inner(

std::vector<compas::RowMatrixXd>
pmp_create_weighted_offset_polygons_2_outer(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double offset_distance,
const compas::RowMatrixXd& edge_weights)
Eigen::Ref<const compas::RowMatrixXd> edge_weights)
{
if (edge_weights.rows() != vertices.rows()) {
throw std::invalid_argument("Number of weights must match number of polygon vertices");
Expand Down
24 changes: 12 additions & 12 deletions src/straight_skeleton_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* - Matrix of skeleton edges as vertex pairs (Kx2, int32)
* - Vector of source edge indices from input polygon for each skeleton edge
*/
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
pmp_create_interior_straight_skeleton(
const compas::RowMatrixXd& vertices
Eigen::Ref<const compas::RowMatrixXd> vertices
);

/**
Expand All @@ -38,9 +38,9 @@ pmp_create_interior_straight_skeleton(
* - Matrix of skeleton edges as vertex pairs (Qx2, int32)
* - Vector of source edge indices from input polygon for each skeleton edge
*/
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
std::tuple<compas::RowMatrixXd, std::vector<int>, compas::RowMatrixXi, std::vector<int>>
pmp_create_interior_straight_skeleton_with_holes(
const compas::RowMatrixXd& boundary_vertices,
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
const std::vector<compas::RowMatrixXd>& hole_vertices
);

Expand All @@ -53,7 +53,7 @@ pmp_create_interior_straight_skeleton_with_holes(
*/
std::vector<compas::RowMatrixXd>
pmp_create_offset_polygons_2_inner(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double& offset_distance
);

Expand All @@ -68,7 +68,7 @@ pmp_create_offset_polygons_2_inner(
*/
std::vector<std::vector<compas::RowMatrixXd>>
pmp_create_offset_polygons_2_inner_with_holes(
const compas::RowMatrixXd& boundary_vertices,
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
const std::vector<compas::RowMatrixXd>& hole_vertices,
double& offset_distance
);
Expand All @@ -88,7 +88,7 @@ pmp_create_offset_polygons_2_inner_with_holes(
*/
std::vector<compas::RowMatrixXd>
pmp_create_offset_polygons_2_outer(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double& offset_distance
);

Expand All @@ -103,7 +103,7 @@ pmp_create_offset_polygons_2_outer(
*/
std::vector<std::vector<compas::RowMatrixXd>>
pmp_create_offset_polygons_2_outer_with_holes(
const compas::RowMatrixXd& boundary_vertices,
Eigen::Ref<const compas::RowMatrixXd> boundary_vertices,
const std::vector<compas::RowMatrixXd>& hole_vertices,
double& offset_distance
);
Expand All @@ -120,9 +120,9 @@ pmp_create_offset_polygons_2_outer_with_holes(
*/
std::vector<compas::RowMatrixXd>
pmp_create_weighted_offset_polygons_2_inner(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double offset_distance,
const compas::RowMatrixXd& edge_weights
Eigen::Ref<const compas::RowMatrixXd> edge_weights
);

/**
Expand All @@ -137,9 +137,9 @@ pmp_create_weighted_offset_polygons_2_inner(
*/
std::vector<compas::RowMatrixXd>
pmp_create_weighted_offset_polygons_2_outer(
const compas::RowMatrixXd& vertices,
Eigen::Ref<const compas::RowMatrixXd> vertices,
double offset_distance,
const compas::RowMatrixXd& edge_weights
Eigen::Ref<const compas::RowMatrixXd> edge_weights
);

void init_straight_skeleton_2(nb::module_& m);
12 changes: 6 additions & 6 deletions src/subdivision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
subd_catmullclark(
compas::RowMatrixXd vertices,
std::vector<std::vector<int>> faces,
Eigen::Ref<const compas::RowMatrixXd> vertices,
const std::vector<std::vector<int>>& faces,
unsigned int num_iterations)
{
compas::Mesh mesh = compas::ngon_from_vertices_and_faces(vertices, faces);
Expand All @@ -14,8 +14,8 @@ subd_catmullclark(

std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
subd_loop(
compas::RowMatrixXd vertices,
compas::RowMatrixXi faces,
Eigen::Ref<const compas::RowMatrixXd> vertices,
Eigen::Ref<const compas::RowMatrixXi> faces,
unsigned int num_iterations)
{
compas::Mesh mesh = compas::mesh_from_vertices_and_faces(vertices, faces);
Expand All @@ -26,8 +26,8 @@ subd_loop(

std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
subd_sqrt3(
compas::RowMatrixXd vertices,
compas::RowMatrixXi faces,
Eigen::Ref<const compas::RowMatrixXd> vertices,
Eigen::Ref<const compas::RowMatrixXi> faces,
unsigned int num_iterations)
{
compas::Mesh mesh = compas::mesh_from_vertices_and_faces(vertices, faces);
Expand Down
12 changes: 6 additions & 6 deletions src/subdivision.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
subd_catmullclark(
compas::RowMatrixXd vertices,
std::vector<std::vector<int>> faces,
Eigen::Ref<const compas::RowMatrixXd> vertices,
const std::vector<std::vector<int>>& faces,
unsigned int num_iterations);

/**
Expand All @@ -35,8 +35,8 @@ subd_catmullclark(
*/
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
subd_loop(
compas::RowMatrixXd vertices,
compas::RowMatrixXi faces,
Eigen::Ref<const compas::RowMatrixXd> vertices,
Eigen::Ref<const compas::RowMatrixXi> faces,
unsigned int num_iterations);

/**
Expand All @@ -52,6 +52,6 @@ subd_loop(
*/
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
subd_sqrt3(
compas::RowMatrixXd vertices,
compas::RowMatrixXi faces,
Eigen::Ref<const compas::RowMatrixXd> vertices,
Eigen::Ref<const compas::RowMatrixXi> faces,
unsigned int num_iterations);
Loading
Loading