Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] More problems filling holes...

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] More problems filling holes...


Chronological Thread 
  • From: Keith Ealanta <>
  • To:
  • Subject: Re: [cgal-discuss] More problems filling holes...
  • Date: Mon, 12 Feb 2007 01:13:33 +1100

Efraim Fogel wrote:
You need to implement yourself the function that removes a hole using the remove_edge() method of the Arrangement_2 class. The function that you tried to use is private and internal, and does do what you may think it does.

Thanks for that. It took me a fair way further. I've even managed to remove a hole from an arrangement. Unfortunately I can only seem to remove the edge from a copy of the arrangement, not from the original.

The problem seems to be that any attempt to access the arrangement seems only able to get me the const version or a duplicate version.

const Arrangement_2 *arr=&(polyset_2.arrangement());
gets me an arrangement object, but then I have to work with consts and functions like remove_edge(arr,e) don't accept consts.

Arrangement_2 arr = polyset_2.arrangement();
just gets me a duplicate of the arrangement, so my changes don't stick around after I drop out of my function.

I strongly suspect I'm not understanding something in the way the iterators function or in the principles of CGAL.
Is there any way to directly access and modify the arrangement contained in a CGAL::Polygon_set_2<Kernel> object?

I've tried using CGAL::Arr_accessor<Arrangement_2> as well, but again I have issues with const/non-const versions for object.

I've attached copies of the .h and .cpp files relevant in the hope someone can explain my errors when they see what I'm doing.
Oh, and yes, the code in delete_hole only deletes the first edge of the hole, but as it gets called repeatedly so long as there is a hole, the hole eventually gets deleted. If anyone can explain the correct way to terminate the while loop that ends on line 110 I'd really appreciate that too.

Please feel free to pick my whole code set apart if you feel like it. i'll learn more that way. ;)
Oh, and for reference the stuff about gcnew is to use the memory-manager attached to the .net environment. I'm writing this as a generic area object I can use from C# and VB

I'm sorry for constantly coming back to the group with this, but it's driving me mad.

Many thanks for putting up with me.

Keith Ealanta


Another option is to compute the union of the Polygon_set object with the holes you are trying to remove, not that efficient though....

This threw an exception each time I tried it. I'm not sure why though.


Or, you can simply ignore the holes. Start with the unbounded face, and traverse its holes.

Ah, I have further plans for the object once I've removed the holes. I just need to be able to strip them out under some circumstances.



Keith Ealanta wrote:

I'm trying to fill all the holes in a Polygon_set_2
After initial struggles I'm now at least finding the faces that describe the holes, but I can't seem to remove the holes from them.

My code is as follows... (sorry for the weird indenting, I've set it up to try to make it more readable in email)

My typedefs are...
typedef CGAL::Cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef CGAL::Polygon_set_2<Kernel> Polygon_set_2;
typedef CGAL::Polygon_2<Kernel>::Vertex_const_iterator VertexIterator;
typedef CGAL::Polygon_set_2<Kernel>::Arrangement_2 Arrangement_2;

And here's the code at issue.

bool Area::FillHollows()
{
bool result = false;
Arrangement_2 arr=data->total_area.arrangement();
Arrangement_2::Face_iterator fi;
std::cout << "Arrangement --------- ";
std::cout << arr.number_of_faces() << " faces." << std::endl;

for (fi=arr.faces_begin();fi!= arr.faces_end();fi++)
{
if (fi->is_unbounded())
{
continue; // ignore the outer border
}

std::cout << "### Face ###" << std::endl;

std::cout << "Border : " ;
print_ccb(fi->outer_ccb());
std::cout << std::endl;


std::cout << "Hole count : " << fi->number_of_holes() << std::endl;
std::cout << "---------" << std::endl;

Arrangement_2::Hole_iterator hi;
int cnter = 0;
for (hi = fi->holes_begin();hi!=fi->holes_end();hi++)
{
std::cout << "hole - " << ++cnter << " : ";
print_ccb(*hi);

// ################# Here's where I hit problems ##################
arr.non_const_handle(fi)->erase_hole(hi);
// ################# Just that one line really. ###################
result = true;
}
std::cout << std::endl;
}
return result;
}

This gets the following compile error...

.\CGAL_Access.cpp(132) : error C2664:
'CGAL::Arrangement_2<Traits_,Dcel_>::Face::erase_hole' :
cannot convert parameter 1 from
'CGAL::I_HalfedgeDS_iterator<I,Val,Dist,Ctg>' to
'CGAL::I_HalfedgeDS_iterator<I,Val,Dist,Ctg>'
with
[ Traits_=CGAL::Gps_segment_traits_2<Kernel,std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>,
Dcel_=CGAL::Gps_dcel<CGAL::Gps_segment_traits_2<Kernel,std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>>
]
and
[
I=CGAL::I_HalfedgeDS_iterator<CGAL::Arr_face_base::Hole_iterator,CGAL::Arr_halfedge<CGAL::Arr_vertex_base<CGAL::Point_2<CGAL::Cartesian<double>>>,CGAL::Arr_halfedge_base<CGAL::Arr_segment_2<Kernel>>,CGAL::Gps_face>
*,__w64 int,std::list<void *>::_Iterator<false>::iterator_category>,
Val=CGAL::_HalfedgeDS_facet_circ<CGAL::Arrangement_2<CGAL::Gps_segment_traits_2<Kernel,std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>,CGAL::Gps_dcel<CGAL::Gps_segment_traits_2<Kernel,std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>>>::Halfedge,CGAL::I_HalfedgeDS_iterator<CGAL::CGALi::In_place_list_iterator<CGAL::Arr_halfedge<CGAL::Arr_vertex_base<CGAL::Point_2<CGAL::Cartesian<double>>>,CGAL::Arr_halfedge_base<CGAL::Arr_segment_2<Kernel>>,CGAL::Gps_face>,std::allocator<CGAL::Arr_halfedge<CGAL::Arr_vertex_base<CGAL::Point_2<CGAL::Cartesian<double>>>,CGAL::Arr_halfedge_base<CGAL::Arr_segment_2<Kernel>>,CGAL::Gps_face>>>,CGAL::Arrangement_2<CGAL::Gps_segment_traits_2<Kernel,std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>,CGAL::Gps_dcel<CGAL::Gps_segment_traits_2<Kernel,std::vector<CGAL::Point_2<CGAL::Cartesian<double>>>>>>::Halfedge,__w64
int,std::bidirectional_iterator_tag>,CGAL::Bidirectional_circulator_tag>,
Dist=__w64 int,
Ctg=std::bidirectional_iterator_tag
]
and
[
I=CGAL::Arr_face_base::Hole_iterator,

Val=CGAL::Arr_halfedge<CGAL::Arr_vertex_base<CGAL::Point_2<CGAL::Cartesian<double>>>,CGAL::Arr_halfedge_base<CGAL::Arr_segment_2<Kernel>>,CGAL::Gps_face>
*,
Dist=__w64 int,
Ctg=std::list<void *>::_Iterator<false>::iterator_category
]
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called.

It looks to me as though erase_hole can't accept the hole_iterator it is defined as using?

Can anyone see what is wrong?
Am I still doing something stupid?

I've left all the cout statements in so I can show the sample data being processed.
The print_ccb is as per the pdf doco, but has had the curves output part removed.
The dataset is a triangle with a triangle missing from the middle of it, and a separate freestanding triangle.

Arrangement --------- 4 faces.
### Face ###
Border : Is_on_hole = 0 : (300 250)(100 400)(100 100)(300 250)
Hole count : 0
---------

### Face ###
Border : Is_on_hole = 0 : (600 400)(500 350)(600 300)(600 400)
Hole count : 0
---------

### Face ###
Border : Is_on_hole = 0 : (900 350)(400 600)(400 100)(900 350)
Hole count : 1
---------
hole - 1 : Is_on_hole = 1 : (500 350)(600 400)(600 300)(500 350)








Archive powered by MHonArc 2.6.16.

Top of Page