[Shortest Paths] There are situations where there is no return point set and a large number of duplicate points occur
Maintainers usually reply within 3 days
@sloriot is already working on this.
Since Jul 18, 2025.
Assessment
This issue has not been assessed yet.
Description
Hello, I encountered a series of problems when testing the function of Triangulated Surface Mesh Shortest Paths to find the shortest path of any two points on the model surface using other models. For example, when using the bathtub model, the path point returned by the algorithm was 0. When testing with the hilbert_cube2_pds_100k_surface.obj model provided by your KSR, a large number of duplicate points occurred, and some points drifted off the surface of the model. The following are my running environment, code and model file
Runtime environment
- Operating system:Windows 11
- Compiler:Visual Studio2022
- CGAL version:6.0.1
- Boost version:1.88.0
Code
- The code when using the bathtub model
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Surface_mesh_shortest_path.h>
#include <CGAL/Random.h>
#include <boost/lexical_cast.hpp>
#include <cstdlib>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> Triangle_mesh;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Triangle_mesh> Traits;
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
typedef boost::graph_traits<Triangle_mesh> Graph_traits;
typedef Graph_traits::vertex_iterator vertex_iterator;
typedef Graph_traits::face_iterator face_iterator;
int main(int argc, char** argv)
{
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("bathtub_0001.obj");
Triangle_mesh tmesh;
if (!CGAL::IO::read_polygon_mesh(filename, tmesh))
{
std::cerr << "Invalid input file1." << std::endl;
return EXIT_FAILURE;
}
const int target_face_index = 79;
face_iterator face_it = faces(tmesh).first;
std::advance(face_it, target_face_index);
// ... and define a barycentric coordinates inside the face
Traits::Barycentric_coordinates face_location1 = { {0.04761892557144165,0.5907313227653503,0.36164984107017517} };
Traits::Barycentric_coordinates face_location2 = { {0.3858107328414917, 0.3522464334964752,0.2619428336620331} };
// construct a shortest path query object and add a source point
Surface_mesh_shortest_path shortest_paths(tmesh);
shortest_paths.add_source_point(*face_it, face_location1);
std::cout << *face_it << std::endl;
// For all vertices in the tmesh, compute the points of
// the shortest path to the source point and write them
// into a file readable using CGAL Lab
std::ofstream output("shortest_paths.txt");
face_iterator f_it = faces(tmesh).first;
std::advance(f_it, 750);
std::vector<Traits::Point_3> points;
std::cout << *f_it << std::endl;
shortest_paths.shortest_path_points_to_source_points(*f_it, face_location2, std::back_inserter(points));
// print the points
output << points.size() << " ";
for (std::size_t i = 0; i < points.size(); ++i)
output << " " << points[i];
output << std::endl;
}
- The code when using the cube model
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Surface_mesh_shortest_path.h>
#include <CGAL/Random.h>
#include <boost/lexical_cast.hpp>
#include <cstdlib>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> Triangle_mesh;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Triangle_mesh> Traits;
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
typedef boost::graph_traits<Triangle_mesh> Graph_traits;
typedef Graph_traits::vertex_iterator vertex_iterator;
typedef Graph_traits::face_iterator face_iterator;
int main(int argc, char** argv)
{
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("hilbert_cube2_pds_100k_surface.obj");
Triangle_mesh tmesh;
if (!CGAL::IO::read_polygon_mesh(filename, tmesh))
{
std::cerr << "Invalid input file1." << std::endl;
return EXIT_FAILURE;
}
const int target_face_index = 4880;
face_iterator face_it = faces(tmesh).first;
std::advance(face_it, target_face_index);
// ... and define a barycentric coordinates inside the face
Traits::Barycentric_coordinates face_location1 = { {0.46936893463134766,0.11540794372558594,0.4152231216430664} };
Traits::Barycentric_coordinates face_location2 = { {0.16719023883342743, 0.47327518463134766,0.3595345914363861} };
// construct a shortest path query object and add a source point
Surface_mesh_shortest_path shortest_paths(tmesh);
shortest_paths.add_source_point(*face_it, face_location1);
std::cout << *face_it << std::endl;
// For all vertices in the tmesh, compute the points of
// the shortest path to the source point and write them
// into a file readable using CGAL Lab
std::ofstream output("shortest_paths.txt");
face_iterator f_it = faces(tmesh).first;
std::advance(f_it, 5749);
std::vector<Traits::Point_3> points;
std::cout << *f_it << std::endl;
shortest_paths.shortest_path_points_to_source_points(*f_it, face_location2, std::back_inserter(points));
// print the points
output << points.size() << " ";
for (std::size_t i = 0; i < points.size(); ++i)
output << " " << points[i];
output << std::endl;
}
Files
- Dominant language
- C++
- Stars
- 6.1k
- Forks
- 1.6k
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 55
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CGAL/cgal
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 3 days
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 3 days
-
Allow cancellable CGAL operationsPossibly taken @AbhaySharma2009 claimed this 9 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 3 days
-
Snap_rounding_2: kd-tree query returns mostly false hot-pixel candidates for diagonal segments, and each query is costly with EpeckPossibly taken @LeoValque claimed this 9 days ago. OpenPkg::Snap_rounding_2
Maintainers usually reply within 3 days
-
corefine_and_compute_union() returns true but the output Surface_mesh has a non-manifold vertex (is_valid_polygon_mesh() is false)Possibly taken @sloriot claimed this 5 days ago. OpenDoc Not a bug Pkg::PMP
Difficulty 5/5 Over a week Newbie friendliness 12/100
CGAL/cgal#9892 · 5 comments · 1 assignee ·
Maintainers usually reply within 3 days
Similar issues
-
RTL-SDR: re-enumerating while streaming removes the in-use entry from the device selection dialogPossibly taken @dpc00 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
throneproj/Throne#2227 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
Maintainers usually reply within 1 day
-
bug needs testing platform:windows topic:buildsystem topic:platforms
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#126110 · 1 comment ·
Maintainers usually reply within 1 day