mirror of https://github.com/CGAL/cgal
Merge pull request #7339 from efifogel/Ms_2-Hole_filter-efif
Minkowski_sum_2: fix hole filter
This commit is contained in:
commit
5690c51f50
|
|
@ -121,6 +121,7 @@ extracted from labeled images.
|
||||||
|
|
||||||
### [2D Minkowski Sums](https://doc.cgal.org/5.6/Manual/packages.html#PkgMinkowskiSum2)
|
### [2D Minkowski Sums](https://doc.cgal.org/5.6/Manual/packages.html#PkgMinkowskiSum2)
|
||||||
- Fixed a bug that made holes in the Minkowski sum disappear
|
- Fixed a bug that made holes in the Minkowski sum disappear
|
||||||
|
- Fixed hole filtering. The code used to erroneously remove holes from the container of holes of polygons with holes that did not affect the minkowsi sum. Now it simply adds those that do affect it.
|
||||||
|
|
||||||
[Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5)
|
[Release 5.5](https://github.com/CGAL/cgal/releases/tag/v5.5)
|
||||||
-----------
|
-----------
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,12 @@ namespace CGAL {
|
||||||
* to the Minkowski sum boundary.
|
* to the Minkowski sum boundary.
|
||||||
*/
|
*/
|
||||||
template <typename Kernel_, typename Container_>
|
template <typename Kernel_, typename Container_>
|
||||||
class Hole_filter_2
|
class Hole_filter_2 {
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
typedef Kernel_ Kernel;
|
using Kernel = Kernel_;
|
||||||
typedef Container_ Container;
|
using Container = Container_;
|
||||||
|
using Polygon_2 = CGAL::Polygon_2<Kernel, Container>;
|
||||||
typedef CGAL::Polygon_2<Kernel, Container> Polygon_2;
|
using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2<Kernel, Container>;
|
||||||
typedef CGAL::Polygon_with_holes_2<Kernel, Container> Polygon_with_holes_2;
|
|
||||||
typedef typename Polygon_with_holes_2::Hole_iterator Hole_iterator;
|
|
||||||
typedef std::vector<Hole_iterator> Hole_iterator_vector;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! Filter out holes of a polygon with holes.
|
/*! Filter out holes of a polygon with holes.
|
||||||
|
|
@ -45,29 +41,17 @@ public:
|
||||||
*/
|
*/
|
||||||
void operator()(const Polygon_with_holes_2& pgn1,
|
void operator()(const Polygon_with_holes_2& pgn1,
|
||||||
const Polygon_2& pgn2,
|
const Polygon_2& pgn2,
|
||||||
Polygon_with_holes_2& filtered_pgn1) const
|
Polygon_with_holes_2& filtered_pgn1) const {
|
||||||
{
|
|
||||||
filtered_pgn1 = pgn1;
|
|
||||||
|
|
||||||
Hole_iterator_vector to_erase;
|
|
||||||
Bbox_2 boundary_bbox = pgn2.bbox();
|
Bbox_2 boundary_bbox = pgn2.bbox();
|
||||||
|
filtered_pgn1 = Polygon_with_holes_2(pgn1.outer_boundary());
|
||||||
Hole_iterator it = filtered_pgn1.holes_begin();
|
for (const auto& h : pgn1.holes()) {
|
||||||
while (it != filtered_pgn1.holes_end()) {
|
Bbox_2 hole_bbox = h.bbox();
|
||||||
Bbox_2 hole_bbox = (*it).bbox();
|
if ((hole_bbox.ymax()-hole_bbox.ymin() >=
|
||||||
|
boundary_bbox.ymax()-boundary_bbox.ymin()) &&
|
||||||
if ((hole_bbox.ymax()-hole_bbox.ymin() <
|
(hole_bbox.xmax()-hole_bbox.xmin() >=
|
||||||
boundary_bbox.ymax()-boundary_bbox.ymin()) ||
|
|
||||||
(hole_bbox.xmax()-hole_bbox.xmin() <
|
|
||||||
boundary_bbox.xmax()-boundary_bbox.xmin()))
|
boundary_bbox.xmax()-boundary_bbox.xmin()))
|
||||||
{
|
filtered_pgn1.add_hole(h);
|
||||||
to_erase.push_back(it);
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typename Hole_iterator_vector::iterator it2 = to_erase.begin();
|
|
||||||
while (it2 != to_erase.end()) filtered_pgn1.erase_hole(*it2++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Filter out holes of a polygon with holes.
|
/*! Filter out holes of a polygon with holes.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue