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: Efraim Fogel <>
  • To:
  • Subject: Re: [cgal-discuss] More problems filling holes...
  • Date: Tue, 06 Feb 2007 16:35:43 +0200

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.

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

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

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)




--
____ _ ____ _
/_____/_) o /__________ __ //
(____ ( ( ( (_/ (_/-(-'_(/
_/




Archive powered by MHonArc 2.6.16.

Top of Page