Subject: CGAL users discussion list
List archive
[cgal-discuss] Overlaying Arrangement_with_history destroys edge-to-curve mapping
Chronological Thread
- From: gp <>
- To:
- Subject: [cgal-discuss] Overlaying Arrangement_with_history destroys edge-to-curve mapping
- Date: Thu, 10 Oct 2019 19:46:56 -0500 (CDT)
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
- Ironport-phdr: 9a23:R9ctQhSEY71+nGIe9VsXOAbBe9psv+yvbD5Q0YIujvd0So/mwa69ZRWN2/xhgRfzUJnB7Loc0qyK6vumBzBLusnJmUtBWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6OPn+FJLMgMSrzeCy/IDYbxlViDanbr5+MRu7oR/Qu8QZjodvJKQ8wQbVr3VVfOhb2XlmLk+JkRbm4cew8p9j8yBOtP8k6sVNT6b0cbkmQLJBFDgpPHw768PttRnYUAuA/WAcXXkMkhpJGAfK8hf3VYrsvyTgt+p93C6aPdDqTb0xRD+v4btnRAPuhSwaMTMy7WPZhdFqjK9DrhyvpwJxzY3Jbo6aKPVwcbjQfc8YSGZdQspdSzBNDp26YoASD+QBJ+FYr4zlqlsBtRu1GA6hBOz3yj9Ih3/22bY10/4gEQ7a3wwtBM8OsXrOo9XpKqgSS+S1zK7PzTnZc/xZwy7w5Y7VeR4vpvGMWKh/ccvXyUQ3EQPKlE6fppfhPzyLzOgCr2+b7+9mWOmyiGAnsxl8riWry8ookIXEiIEYxkrH+Ch42oo4JNy1RUhmatC+CpRQrTuVN45uT8MiXW5ovCE6x6UAuZO0ZiQKzo4oyAXEZPyDbYeE+A7sVOGUITtghXJlfqywhwqq/ES9zuDxUtO43VhJoyZfkdTBt2oB2h3S58SfT/ty5Eah2TKB1wDJ7eFEJFg5laXDK54hw74wkoEcsV7CHiDqm0X7l7KWd0s+9ei09evneLHmppibN4Nulg7xKLwimtajDuQgLggOQ2+b9Pyg273s50L5RKxGgeA3kqnCrJ/aON8bprWiDg9O0ocj7g6/AC283NQZm3kHNlNFdwidg4jnIVGdaMz/WPywilDpnDZwzO3dJZXgBI/MJz7NiuTPZ7F4vkFEgF481dBe45hOC7oCCO/sU1P8rtjfCVkyOlrnkK7cFNxh29ZGCiq0CaiDPfaK6APa1qcUO+CJIbQtlnPlMfF8u6zzknYllEUZeq7v1pJFMCnlTMQjGF2QZD/XuvlEEWoOuVNjHuq2zluLWzRXajC5WKduv2hqWrLjNp/KQ8WWuJLE2S66GpNMYWUfVgKRDn70ep+AXPBKYyvAecI=
Normally, when I CGAL::insert a curve into an arrangement-with-history, I get
back curve handles such that each halfedge in the arrangement corresponds to
one or more of those curve handles. However, if I make two
arrangements-with-history A and B, store their corresponding curve handles
in two sets, and then make an overlay arrangement, the halfedges in the
overlay arrangement do not correspond to any of the handles in those two
sets. It looks like all the curves are recreated from scratch in the new
arrangement so that my externally stored curve handles become obsolete.
Is this meant to happen? It's not quite clear from the documentation on
overlaying arrangements-with-history: "...the resulting arrangement will
store a consolidated container of input curves, and automatically preserve
the cross-mapping between the arrangement edges and the consolidated curve
set."
The following demonstrates my problem.
main.cpp:
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Arr_default_overlay_traits.h>
#include <CGAL/Arr_overlay_2.h>
#include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_with_history_2.h>
using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
using SegmentTraits = CGAL::Arr_segment_traits_2< Kernel >;
using ArrangementTraits = CGAL::Arr_polyline_traits_2< SegmentTraits >;
using Point_2 = ArrangementTraits::Point_2;
using Curve_2 = ArrangementTraits::Curve_2;
using Arrangement = CGAL::Arrangement_with_history_2< ArrangementTraits >;
using OverlayTraits = CGAL::Arr_default_overlay_traits< Arrangement >;
using Curve_handle = Arrangement::Curve_handle;
using Curve_const_handle = Arrangement::Curve_handle;
Curve_2 curve2( const std::vector< Point_2 >& points );
int main ()
{
// Arrangement A, containing a square-shaped face.
std::set< Curve_const_handle > arrAHandles;
Arrangement arrA;
Curve_2 c1 = curve2( { Point_2(2, 2), Point_2(6, 2) } );
Curve_2 c2 = curve2( { Point_2(6, 2), Point_2(6, 6) } );
Curve_2 c3 = curve2( { Point_2(6, 6), Point_2(2, 6) } );
Curve_2 c4 = curve2( { Point_2(2, 6), Point_2(2, 2) } );
arrAHandles.emplace( CGAL::insert (arrA, c1) );
arrAHandles.emplace( CGAL::insert (arrA, c2) );
arrAHandles.emplace( CGAL::insert (arrA, c3) );
arrAHandles.emplace( CGAL::insert (arrA, c4) );
// Arrangement B, containing a rhombus-shaped face.
std::set< Curve_const_handle > arrBHandles;
Arrangement arrB;
Curve_2 t1 = curve2( { Point_2(4, 1), Point_2(7, 4) } );
Curve_2 t2 = curve2( { Point_2(7, 4), Point_2(4, 7) } );
Curve_2 t3 = curve2( { Point_2(4, 7), Point_2(1, 4) } );
Curve_2 t4 = curve2( { Point_2(1, 4), Point_2(4, 1) } );
arrBHandles.emplace( CGAL::insert(arrB, t1) );
arrBHandles.emplace( CGAL::insert(arrB, t2) );
arrBHandles.emplace( CGAL::insert(arrB, t3) );
arrBHandles.emplace( CGAL::insert(arrB, t4) );
// Compute the overlay of the two arrangements.
Arrangement overlay_arr;
OverlayTraits overlay_traits;
overlay (arrA, arrB, overlay_arr, overlay_traits);
// Look at every halfedge in the overlay result and see if its originating
Curve matches one of the handles
// in arrAHandles or arrBHandles.
auto halfEdgeIt = overlay_arr.halfedges_begin();
while( halfEdgeIt != overlay_arr.halfedges_end() ) {
bool matchesOneOfTheHandles = false;
auto originIt = overlay_arr.originating_curves_begin( halfEdgeIt );
while( originIt != overlay_arr.originating_curves_end( halfEdgeIt )
) {
const Curve_handle curveHandle = originIt;
const bool foundInOldAHandles = arrAHandles.find( curveHandle )
!= arrAHandles.cend();
const bool foundInOldBHandles = arrBHandles.find( curveHandle )
!= arrBHandles.cend();
if( foundInOldAHandles || foundInOldBHandles ) {
matchesOneOfTheHandles = true;
}
originIt++;
}
if( !matchesOneOfTheHandles ) {
std::cout << "Halfedge in overlay does not correspond with any
of the original curve handles.\n";
}
halfEdgeIt++;
}
return 0;
}
Curve_2 curve2( const std::vector< Point_2 >& points )
{
ArrangementTraits traits;
auto constructor = traits.construct_curve_2_object();
return constructor( points.begin(), points.end() );
}
--
Sent from: http://cgal-discuss.949826.n4.nabble.com/
- [cgal-discuss] Overlaying Arrangement_with_history destroys edge-to-curve mapping, gp, 10/11/2019
- Re: [cgal-discuss] Overlaying Arrangement_with_history destroys edge-to-curve mapping, Efi Fogel, 10/11/2019
Archive powered by MHonArc 2.6.18.