mirror of https://github.com/CGAL/cgal
Fixes and apply to multipolygon
This commit is contained in:
parent
9a330fd140
commit
6c35826afd
|
|
@ -44,7 +44,7 @@ namespace internal {
|
||||||
template <typename K>
|
template <typename K>
|
||||||
void pop_back_if_equal_to_front(CGAL::Polygon_2<K>& poly)
|
void pop_back_if_equal_to_front(CGAL::Polygon_2<K>& poly)
|
||||||
{
|
{
|
||||||
CGAL::Polygon_2<K>::iterator it = poly.end();
|
typename CGAL::Polygon_2<K>::iterator it = poly.end();
|
||||||
--it;
|
--it;
|
||||||
if( (*poly.begin()) == *it){
|
if( (*poly.begin()) == *it){
|
||||||
poly.erase(it);
|
poly.erase(it);
|
||||||
|
|
@ -233,7 +233,16 @@ read_multi_polygon_WKT( std::istream& in,
|
||||||
|
|
||||||
if(type.substr(0, 12).compare("MULTIPOLYGON")==0)
|
if(type.substr(0, 12).compare("MULTIPOLYGON")==0)
|
||||||
{
|
{
|
||||||
boost::geometry::read_wkt(line, gc);
|
try {
|
||||||
|
boost::geometry::read_wkt(line, gc);
|
||||||
|
} catch( ...){
|
||||||
|
in.setstate(std::ios::failbit);
|
||||||
|
return in;
|
||||||
|
};
|
||||||
|
for( typename
|
||||||
|
internal::Geometry_container<MultiPolygon, boost::geometry::multi_polygon_tag>::iterator it
|
||||||
|
= gc.begin(); it != gc.end(); ++it)
|
||||||
|
pop_back_if_equal_to_front(*it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,17 +60,14 @@ Polygon generate_polygon()
|
||||||
border.push_back(bl);
|
border.push_back(bl);
|
||||||
border.push_back(t);
|
border.push_back(t);
|
||||||
border.push_back(br);
|
border.push_back(br);
|
||||||
border.push_back(bl);
|
|
||||||
Polygon::Polygon_2 hole1;
|
Polygon::Polygon_2 hole1;
|
||||||
hole1.push_back(Point((xt+xmax)/2, (ymin+ymid)/2));
|
hole1.push_back(Point((xt+xmax)/2, (ymin+ymid)/2));
|
||||||
hole1.push_back(Point(((xt+xmax)/2), ymid));
|
hole1.push_back(Point(((xt+xmax)/2), ymid));
|
||||||
hole1.push_back(Point(xt+(xmax-xt)/4, (ymin+ymid)/2));
|
hole1.push_back(Point(xt+(xmax-xt)/4, (ymin+ymid)/2));
|
||||||
hole1.push_back(Point((xt+xmax)/2, (ymin+ymid)/2));
|
|
||||||
Polygon::Polygon_2 hole2;
|
Polygon::Polygon_2 hole2;
|
||||||
hole2.push_back(Point((xt+xmin)/2, (ymin+ymid)/2));
|
hole2.push_back(Point((xt+xmin)/2, (ymin+ymid)/2));
|
||||||
hole2.push_back(Point(((xt+xmin)/2), ymid));
|
hole2.push_back(Point(((xt+xmin)/2), ymid));
|
||||||
hole2.push_back(Point(xmin+(xt-xmin)/4, (ymin+ymid)/2));
|
hole2.push_back(Point(xmin+(xt-xmin)/4, (ymin+ymid)/2));
|
||||||
hole2.push_back(Point((xt+xmin)/2, (ymin+ymid)/2));
|
|
||||||
Polygon::Holes_container holes;
|
Polygon::Holes_container holes;
|
||||||
holes.push_back(hole1);
|
holes.push_back(hole1);
|
||||||
holes.push_back(hole2);
|
holes.push_back(hole2);
|
||||||
|
|
@ -150,6 +147,7 @@ int main()
|
||||||
CGAL::read_polygon_WKT(is, test_poly);
|
CGAL::read_polygon_WKT(is, test_poly);
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_assertion(poly == test_poly);
|
CGAL_assertion(poly == test_poly);
|
||||||
|
|
||||||
MultiPoint pees = generate_multipoint();
|
MultiPoint pees = generate_multipoint();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue