Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] [2D Arrangement] Remove edge with degree one vertex

Subject: CGAL users discussion list

List archive

[cgal-discuss] [2D Arrangement] Remove edge with degree one vertex


Chronological Thread 
  • From: Trần Anh <>
  • To:
  • Subject: [cgal-discuss] [2D Arrangement] Remove edge with degree one vertex
  • Date: Sat, 4 Jul 2020 13:01:44 +0930
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:FO7DnhW55pOYVBT/i0czMO8341LV8LGtZVwlr6E/grcLSJyIuqrYbBCFt8tkgFKBZ4jH8fUM07OQ7/m+HzRfqsvZ+DBaKdoQDkJD0Z1X1yUbQ+e9QXXhK/DrayFoVO9jb3RCu0+BDE5OBczlbEfTqHDhpRQbGxH4KBYnbr+tQt2agMu4zf299IPOaAtUmjW9falyLBKrpgnNq8Uam4RvJrswxxfTvndFeetayGN0KVmOmxrw+tq88IRs/ihNu/8t7dJMXbn/c68lUbFWETMqPnwv6sb2rxfDVwyP5nUdUmUSjBVFBhXO4Q/5UJnsrCb0r/Jx1yaGM8L4S7A0Qimi4LxwSBD0kicHNiU2/3/Rh8dtka9UuhOhpxh4w47JfIGYMed1c63Bcd8GQ2dKQ8BcXDFDDIyhdYsCF+UOM+ZWoYf+ulUAswexCBK2C+/z0DJFnGP60bE43uknDArI3BYgH9ULsHnMstv1LqQVUeaox6TUyzXDb+5d1DDh6IjSaB8hp/WMXa9tccrPyEkgCR/FgU+WqYzlJD6V2eENvHKa7+pkT+6gl2knqwRorzWp28wjhZXHiJgPxVDY6SV23pw1JdugRUN0fNOqH4Vcuz2GO4ZoXM4sQ3xktSU6x7EYpJK3YCcHxIo5yhDfdfGKd4aG7wzjWeuRPzp1i29odK6iihux7UStzPD3WMqs0FtSsCZJjt3BumoO2hHT8MSLV+Vx80S71TuA0w3e7PxPL1oumqrBMZEhx6Y9lpoNvkTHGS/7gED2g7WXdkUg4+Sp5eHnbqj/qp+SOIJ5jhvyMqspmsy4DuQ4NhYBU3KH9uS70b3v5Uz5QLNUgf0qiqTVrozWKMABqqO6AwJZyJsv5wi8Aju839kVmWELLFdfdxKGi4jpNUvOIPf9Dfqnn1Ssii1kx/bCPr38H5XNMHnDn6n9fbln7U5cyBE+zd9a551OC7EBJOj/VVP2tNzdFhM5KRC7w/77CNVh0YMTQX6AAqCDP6PWqFOH++MvI/KQa48Iozb9MOMo5+XujH88gV8SZ7Ol3ZoRaHCiH/RpOV+VYXT2goRJLWBftQU3SKnmiUaJTCVIT3e0RaM1oD8hW6y8CoKWeponhvSo2ifzSoFMb2ZCF02SEHr0foOEc/gJYSOWZMRml2pXBvCaV4Y92ET250fBwL19I7+Mo3xKhdfYzNFwotbru1Q3/D1wAd6a1jjUHW5xl2IMATQx2fIm+BEv+hK4yaF9xsdgO5lT6vdOCFpoMJfdy6llDom3VF6QONiOT1miT5OtBjRjFottke9LWF50HpCZtj6GxzCjWuZHmLmCBZhy+aXZjSD8

Hi all,
I hope I can get a bit of advice on this. I have a soup of edges and I would like to remove all edge that have a vertex degree one. I end up choosing 2D Arrangement package to do so (see below). 
My first attempt is to iterate through all the edge and delete the ones that meet the condition. I soon realised that when I delete one edge, I make another edge that previously does not meet the condition now meet it. 
So I decided to create a std::vector<Halfedge_handle> to store all the edge (iterator) and later delete them from the arrangement all at once. Apparently converting between  Halfedge_handle and Edge_iterator is not possible.
Is there any solution to this? Or is there any better solution than using Arrangement? Thanks :).
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>

#include <iostream>

typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::X_monotone_curve_2 Curve_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
int main()
{
	Point_2 p0(0, 0), p1(0, 1), p2(1, 1), p3(1, 2), p4(2, 2);
	Curve_2 c0(p0, p1), c1(p1, p2), c2(p2, p3), c3(p2, p4);

	std::vector<Curve_2> curves;
	curves.push_back(c0);
	curves.push_back(c1);
	curves.push_back(c2);
	curves.push_back(c3);

	Arrangement_2 arr;
	Arrangement_2::Edge_iterator eit;
	CGAL::insert(arr, curves.begin(), curves.end());

	for (eit = arr.edges_begin(); eit != arr.edges_end(); ++eit)
	{
		if ((eit->source()->degree() == 1) || (eit->target()->degree()))
		{
			arr.remove_edge(eit);
		}
	}
	std::cout << arr.number_of_edges() << std::endl;
	return 1;

}



Archive powered by MHonArc 2.6.19+.

Top of Page