Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Surface Mesh Shortest Path: Assertion error with custom .off file

Subject: CGAL users discussion list

List archive

[cgal-discuss] Surface Mesh Shortest Path: Assertion error with custom .off file


Chronological Thread 
  • From: sindhu r <>
  • To:
  • Subject: [cgal-discuss] Surface Mesh Shortest Path: Assertion error with custom .off file
  • Date: Mon, 31 Aug 2020 16:32:23 -0400
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:H7bHkRIlnd5/KnoCbtmcpTZWNBhigK39O0sv0rFitYgeL/XxwZ3uMQTl6Ol3ixeRBMOHsqwC0rCK+PC5EUU7or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQviPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCe8bL9oMRm6swrcusYVjId/N6081gbHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VDi+86tmTgLjhSEaPDA77W7XkNR9g61brhyvpBJx3pDab52OOfp7Yq/QZ8kXSXZdUstTUSFKH4Oyb5EID+oEJetYtIj9p10Tohu+GAmnGfnvwSJPi3/t3K061f4tHh3c0ww6G9IBrmjUrNLzNKoJXuC1ybPHzTTHb/9MxTj9743IfwknrPqRUr1+bdDfxlMzFwPZkFqQs4rlMiua2+gRvGaW7+ltWf6vhWI7qgx9vjiiy9kth4XXhI8YyV/K+CF9zYopOdG2R0F2bN6kHZVfuC+XNoR4TMwiTm9mvisx17MIuZm+fCcQyZQnwQbSa/OGc4iU4hLjSf2eLS1ki3JifbKznxi//Eqgx+HmUcm03lhKoyxYmdfPrnAAzwLf5tSDR/dn/Uqs2SyD2x3S5+xFO0w4iKjWJp8nz7UtjJQcq17DETXzmEjujK+ZaEEk+u+w5uTieLrmp5ucO5Z1igH6L6gig8K/Dfk6PwUPRWSb9uO81Lrs/U39XrpGlOE5kq7csJzCJMQboLC2AxNN34o99xqyCy2q3dcYkHUdMV5IeROKg5L0N1zMIf30FfK/jE6tkDdvyfDGJLrhApDVI3jYkbfhe6xx5FJGxwopydBQ+Y5UCrYHIP/oVU/xscbXDh49MwCu3+nnD9B92psEWW2TGq+ZLL/SsViQ6+0zLOmDfosVtC/gJPgk/P7hkWI5mUQGfaSyxpsWaHW4Hux8LEmDYHrshM0BEWYQsQYkQuzqkg7KbTkGbHm7W+cw5yowFZm9JYbFXIGkxrKbjwmhGZgDfWFABlCRWW2gI56FXbEHYTiWL9NmlBQLULGgT8kq0hT451yy8KZuMueBon5QjpnkztUgv7SPxyF3ziR9CoGm60/IV3t9xzpaSDo/3aQ5qkt4mA/agPpIxsdAHNkW3MtnFwIzNJrS1et/UomgVQfIf9PPQ1GjEIz/XGMBC+kpytpLWH5TXtWviheZgXivCr4R0r2PXdk6q/2CmXf2IMl5xjDN06xz11Q=

Hello,
I'm very new to the vastness of CGAL and have a question about the Surface Mesh Shortest Path (SMSP) package. I am also new to a discussion forum, so please let me know if I'm not following any convention on posting questions/code etc.

What I want to do: Using an .off file of the desired shape, find the shortest path on the shape. I provide the coordinates of the source and target locations and use the "locate" function to determine the face locations (face descriptor and barycentric coordinates). These are then fed to the "shortest_path_points_to_source_points" function. The final output path is written to a file.

What I have done: All of the above (minimal working code is provided here). I have tested my code with success on .off files from the web (elephant.off at https://github.com/CGAL/cgal/blob/master/Mesh_3/examples/Mesh_3/data/elephant.off, kitten_poisson-20-30-0.375.off (attached)). But I'm unable to get it to work on my custom .off file (generated using Polyhedron and Poisson reconstruction, also attached). The following error is what I get with my custom .off file:

terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
Expr: _idx < data_.size()
File: /home/sin/lib/libigl/external/cgal/install/include/CGAL/Surface_mesh/Properties.h
Line: 195

I don't understand what the difference is between my .off file and the ones that are used as part of examples. Any help is dearly appreciated!

Regards,
Sindhu R
#include <stdio.h>
#include <iostream>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/poisson_surface_reconstruction.h>

#include <CGAL/Surface_mesh_shortest_path.h>
#include <boost/lexical_cast.hpp>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_tree.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Surface_mesh<Kernel::Point_3> Triangle_mesh;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Triangle_mesh> TSMSP_Traits;
typedef CGAL::Surface_mesh_shortest_path<TSMSP_Traits> Surface_mesh_shortest_path;
typedef boost::graph_traits<Triangle_mesh> Graph_traits;
typedef Graph_traits::face_descriptor face_descriptor;
typedef TSMSP_Traits::Barycentric_coordinates Barycentric_coordinates;
typedef CGAL::AABB_face_graph_triangle_primitive<Triangle_mesh> AABB_face_graph_primitive;
typedef CGAL::AABB_traits<Kernel, AABB_face_graph_primitive> AABB_face_graph_traits;

int main()
{
	Triangle_mesh my_triangle_mesh;

	// TEST ONLY; DELETE LATER
	const char* poisson_fname = "/home/sin/cpp_eclipsew/CGAL_test_1/data/elephant.off";
//	const char* poisson_fname = "/home/sin/Desktop/cgal_discrete_geodesics_minimal_example/mesh.off";
//	const char* poisson_fname = "/home/sin/cpp_eclipsew/CGAL_test_1/all_points_with_normals_poisson.off";
	std::filebuf fb;
	fb.open(poisson_fname, std::ios::in);
	std::istream is(&fb);
	CGAL::read_off(is, my_triangle_mesh);
	Surface_mesh_shortest_path my_surface_mesh_shortest_path(my_triangle_mesh);

	const char* shortest_path_fname =
	"/home/sin/cpp_eclipsew/CGAL_test_1/data/case_1_static_obstacle_test_0.xyz";

	const CGAL::Surface_mesh_shortest_path<TSMSP_Traits>::Point_3 source_laser_xyz(0.1,0.1,0.1), target_laser_xyz(0.1,0.1,0.1);
	CGAL::Surface_mesh_shortest_path<TSMSP_Traits>::Face_location source_face_location, target_face_location;
	source_face_location = my_surface_mesh_shortest_path.locate<AABB_face_graph_traits>(source_laser_xyz);
	target_face_location = my_surface_mesh_shortest_path.locate<AABB_face_graph_traits>(target_laser_xyz);
	const face_descriptor source_face_descriptor = source_face_location.first;
	const face_descriptor target_face_descriptor = target_face_location.first;
	const Barycentric_coordinates source_barycen = source_face_location.second;
	const Barycentric_coordinates target_barycen = target_face_location.second;

	my_surface_mesh_shortest_path.add_source_point(source_face_descriptor, source_barycen);

	std::ofstream output_stream(shortest_path_fname);
	output_stream << "Today is a good day!\n";
	output_stream << "The source is at face descriptor: " << source_face_descriptor << "\n";
	output_stream << "The target is at face descriptor: " << target_face_descriptor <<"\n";
	std::vector<TSMSP_Traits::Point_3> path_from_desired_source_to_desired_target;
	my_surface_mesh_shortest_path.shortest_path_points_to_source_points(target_face_descriptor,
			target_barycen,
			std::back_inserter(path_from_desired_source_to_desired_target));
	output_stream << "The number of points in the path is: "<<
			path_from_desired_source_to_desired_target.size() << std::endl;
	for (std::size_t i = 0; i <path_from_desired_source_to_desired_target.size(); ++i)
	{
		output_stream << "Point number " << i << "is : [";
		output_stream << " " << path_from_desired_source_to_desired_target[i] << "]\n";

	}

	return 1;

}

Attachment: kitten_poisson-20-30-0.375.off
Description: Binary data

Attachment: cgal_discuss_custom_off_file.off
Description: Binary data



  • [cgal-discuss] Surface Mesh Shortest Path: Assertion error with custom .off file, sindhu r, 08/31/2020

Archive powered by MHonArc 2.6.19+.

Top of Page