Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMP: Non-rigid mesh registration #8329

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4c41bda
Non-rigid mesh registration
soesau Jul 2, 2024
97ce59f
added a preliminary license header
soesau Jul 2, 2024
d1de633
fixes for CI
soesau Jul 2, 2024
2f2551b
revert Point_set_3 dependency
soesau Jul 2, 2024
b73ce3e
working on registration and doc
soesau Aug 5, 2024
db8ffbe
doc fix
soesau Aug 5, 2024
d981129
pass on doc
soesau Aug 6, 2024
ba01e61
update on doc
soesau Aug 8, 2024
2fdfb80
update on doc
soesau Aug 8, 2024
06a3187
updated changes.md
soesau Aug 8, 2024
29d1fd1
typo; whitespace
afabri Aug 13, 2024
eb79dfe
proper license; internal::registration; move in CMakeLists
afabri Aug 20, 2024
eebeff2
No 'should' after discussion with @robertod
afabri Aug 20, 2024
c013d13
calculate -> compute https://langeek.co/en/grammar/course/1822
afabri Aug 21, 2024
8667d66
pass on doc
soesau Aug 21, 2024
fb1bb51
Merge branch 'master' into PMP-Non_rigid_registration-GF
soesau Aug 21, 2024
3a274b3
doc of CorrespondenceRange
soesau Aug 21, 2024
3e08965
moving correspondences into named parameters
soesau Aug 21, 2024
5a4fae7
added std::cref to doc of correspondences
soesau Aug 21, 2024
b0e5301
added apply_non_rigid_transformation to CHANGES.md
soesau Oct 2, 2024
4b14289
Merge branch 'master' into PMP-Non_rigid_registration-GF
soesau Oct 2, 2024
357d345
bug fixes
soesau Oct 2, 2024
ab51f73
removed unused variable
soesau Oct 2, 2024
7e0022c
fix warning
soesau Oct 4, 2024
36f59c3
compatibility with Eigen3.3
soesau Oct 8, 2024
d328aac
fix warnings
soesau Oct 9, 2024
09ca6d5
making it easy to switch between both arap terms
soesau Oct 9, 2024
a093496
changes following review
soesau Oct 16, 2024
a948e53
Merge remote-tracking branch 'cgal/master' into PMP-Non_rigid_registr…
soesau Oct 16, 2024
6b363ec
adapt CHANGES.md
soesau Oct 16, 2024
7a10001
another pass for review
soesau Oct 17, 2024
b8937ab
adding proper edge weights for new arap weight as suggested by Roberto
soesau Oct 30, 2024
47b7f67
switching licenses from LGPL to GPL
soesau Nov 18, 2024
688f4a1
moving ARAP visitor into Weights package
soesau Nov 18, 2024
2159bee
vertex normals are estimated if not provided
soesau Nov 18, 2024
37d66b7
documentation of Deformation_algorithm_tag
soesau Nov 20, 2024
d1059ac
doc fix
soesau Nov 21, 2024
608de95
fixing vertex normal rotation after registration
soesau Nov 21, 2024
ff97fb9
doc updates
soesau Nov 21, 2024
09bbae9
doc of geom_traits
soesau Nov 21, 2024
1f897b8
fixed warning
soesau Nov 22, 2024
0a03248
Update Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_me…
soesau Dec 3, 2024
fe9e8d9
renaming maximum_matching_distance to maximal_matching_distance
soesau Dec 10, 2024
b2399b9
Merge branch 'master' into PMP-Non_rigid_registration-GF
soesau Dec 10, 2024
c8bb801
CI fix
soesau Dec 10, 2024
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
Next Next commit
Non-rigid mesh registration
soesau committed Jul 2, 2024
commit 4c41bda1beb1f9d7cd67419a0ea05c9e82f827fc
Original file line number Diff line number Diff line change
@@ -48,6 +48,10 @@
/// Functions to compute the distance between meshes, between a mesh and a point set and between a point set and a mesh.
/// \ingroup PkgPolygonMeshProcessingRef

/// \defgroup PMP_registration_grp Registration Functions
/// Functions to compute the transformation for mapping one mesh onto another or onto a set of points.
/// \ingroup PkgPolygonMeshProcessingRef

soesau marked this conversation as resolved.
Show resolved Hide resolved
/// \defgroup PMP_corefinement_grp Corefinement and Boolean Operations
/// Functions to corefine triangulated surface meshes and compute triangulated
/// surface meshes of the union, difference and intersection
Original file line number Diff line number Diff line change
@@ -57,6 +57,7 @@ create_single_source_cgal_program("hausdorff_bounded_error_distance_example.cpp"
create_single_source_cgal_program("isotropic_remeshing_with_custom_sizing_example.cpp")
create_single_source_cgal_program("triangle_mesh_autorefinement.cpp")
create_single_source_cgal_program("soup_autorefinement.cpp")
create_single_source_cgal_program("non_rigid_mesh_registration_example.cpp")

find_package(Eigen3 3.2.0 QUIET) #(requires 3.2.0 or greater)
include(CGAL_Eigen3_support)
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
soesau marked this conversation as resolved.
Show resolved Hide resolved
#include <CGAL/Surface_mesh.h>

#include <CGAL/Polygon_mesh_processing/non_rigid_mesh_registration.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>

#include <CGAL/Point_set_3.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_exact_constructions_kernel K2;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
using Point = K::Point_3;
using Vector = K::Vector_3;

namespace PMP = CGAL::Polygon_mesh_processing;

int main(int argc, char** argv) {
if (argc == 2)
std::cout << "wrong number of arguments! 0, 2 or 3 arguments possible" << std::endl;
const std::string source_fn = argc > 1 ? argv[1] : "data/wolf0.off";
const std::string target_fn = argc > 2 ? argv[2] : "data/wolf1.off";
const std::string corr_fn = argc > 3 ? argv[3] : "data/wolf0_wolf1.corr";

Mesh source, target;
if (!PMP::IO::read_polygon_mesh(source_fn, source))
{
std::cerr << "Invalid input " << source_fn << std::endl;
return 1;
}

if (!PMP::IO::read_polygon_mesh(target_fn, target))
{
std::cerr << "Invalid input " << target_fn << std::endl;
return 1;
}

std::vector<std::pair<Mesh::Vertex_index, Mesh::Vertex_index>> correspondences_mesh;
std::ifstream corr(corr_fn);
if (corr.is_open()) {
std::string line;
while (std::getline(corr, line)) {
soesau marked this conversation as resolved.
Show resolved Hide resolved
if (line.size() == 0) continue;
std::istringstream iss(line);

std::size_t v0, v1;
if (iss >> v0 >> v1)
Mesh source, target;
correspondences_mesh.push_back(std::make_pair(*(source.vertices_begin() + v0), *(target.vertices_begin() + v1)));
}
}

Mesh mapped_source;
CGAL::Point_set_3<K::Point_3> points;
points.reserve(target.num_vertices());

//typename Mesh::Property_map<Mesh::Vertex_index, K::Vector_3>;
auto vnm = target.add_property_map<Mesh::Vertex_index, K::Vector_3>("v:normal");
if (vnm.second)
PMP::compute_vertex_normals(target, vnm.first);

for (auto v : target.vertices())
points.insert(target.point(v), get(vnm.first, v));

std::vector<std::pair<Mesh::Vertex_index, std::size_t>> correspondences_pts;
correspondences_pts.reserve(correspondences_mesh.size());
for (auto p : correspondences_mesh)
correspondences_pts.push_back(std::make_pair(p.first, static_cast<std::size_t>(p.second)));

typename Mesh::Property_map<Mesh::Vertex_index, CGAL::Aff_transformation_3<K>> vrm = target.add_property_map<Mesh::Vertex_index, CGAL::Aff_transformation_3<K>>("v:rotation").first;
typename Mesh::Property_map<Mesh::Vertex_index, K::Vector_3> vtm = target.add_property_map<Mesh::Vertex_index, K::Vector_3>("v:transformations").first;

Mesh source2 = source;

/*
PMP::non_rigid_mesh_to_points_registration(source, points, vtm, vrm, correspondences_pts, CGAL::parameters::point_to_plane_energy(2.0).point_to_point_energy(0.1).as_rigid_as_possible_energy(10));
PMP::apply_non_rigid_transformation(source, vtm, vrm);
CGAL::IO::write_polygon_mesh("mapped.off", source);*/

PMP::non_rigid_mesh_to_mesh_registration(source, target, vtm, vrm, correspondences_mesh, CGAL::parameters::point_to_plane_energy(2.0).point_to_point_energy(0.1).as_rigid_as_possible_energy(30));
PMP::apply_non_rigid_transformation(source, vtm, vrm);
CGAL::IO::write_polygon_mesh("mapped.off", source);

return EXIT_SUCCESS;
}
Loading