-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7608 from kenohori/gsoc2023-polygon_repair-kenohori
Polygon repair
- Loading branch information
Showing
123 changed files
with
3,081 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2016 GeometryFactory SARL (France). | ||
// All rights reserved. | ||
// | ||
// This file is part of CGAL (www.cgal.org) | ||
// | ||
// $URL$ | ||
// $Id$ | ||
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial | ||
// | ||
// Author(s) : Andreas Fabri | ||
// | ||
// Warning: this file is generated, see include/CGAL/license/README.md | ||
|
||
#ifndef CGAL_LICENSE_POLYGON_REPAIR_H | ||
#define CGAL_LICENSE_POLYGON_REPAIR_H | ||
|
||
#include <CGAL/config.h> | ||
#include <CGAL/license.h> | ||
|
||
#ifdef CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE | ||
|
||
# if CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE | ||
|
||
# if defined(CGAL_LICENSE_WARNING) | ||
|
||
CGAL_pragma_warning("Your commercial license for CGAL does not cover " | ||
"this release of the 2D Polygon Repair package.") | ||
# endif | ||
|
||
# ifdef CGAL_LICENSE_ERROR | ||
# error "Your commercial license for CGAL does not cover this release \ | ||
of the 2D Polygon Repair package. \ | ||
You get this error, as you defined CGAL_LICENSE_ERROR." | ||
# endif // CGAL_LICENSE_ERROR | ||
# endif // CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE | ||
#else // no CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE | ||
# if defined(CGAL_LICENSE_WARNING) | ||
CGAL_pragma_warning("\nThe macro CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE is not defined." | ||
"\nYou use the CGAL 2D Polygon Repair package under " | ||
"the terms of the GPLv3+.") | ||
# endif // CGAL_LICENSE_WARNING | ||
# ifdef CGAL_LICENSE_ERROR | ||
# error "The macro CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE is not defined.\ | ||
You use the CGAL 2D Polygon Repair package under the terms of \ | ||
the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." | ||
# endif // CGAL_LICENSE_ERROR | ||
#endif // no CGAL_POLYGON_REPAIR_COMMERCIAL_LICENSE | ||
#endif // CGAL_LICENSE_POLYGON_REPAIR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/*! \ingroup PkgPolygon2Concepts | ||
* \cgalConcept | ||
* | ||
* \cgalRefines{CopyConstructible,Assignable,DefaultConstructible} | ||
* | ||
* A model of this concept represents a multipolygon with holes. | ||
* | ||
* \cgalHasModelsBegin | ||
* \cgalHasModels{CGAL::Multipolygon_with_holes_2<Polygon>} | ||
* \cgalHasModelsEnd | ||
*/ | ||
|
||
class MultipolygonWithHoles_2 { | ||
public: | ||
|
||
/// \name Types | ||
/// @{ | ||
|
||
//! the polygon type used to represent each polygon with holes of the multipolygon. | ||
typedef unspecified_type Polygon_with_holes_2; | ||
|
||
/*! a bidirectional iterator over the polygons with holes. | ||
* Its value type is `Polygon_with_holes_2`. | ||
*/ | ||
typedef unspecified_type Polygon_with_holes_iterator; | ||
|
||
/*! a bidirectional const iterator over the polygons with holes. | ||
* Its value type is `Polygon_with_holes_2`. | ||
*/ | ||
typedef unspecified_type Polygon_with_holes_const_iterator; | ||
|
||
//! range type for iterating over polygons with holes. | ||
typedef unspecified_type Polygon_with_holes_container; | ||
|
||
//! size type | ||
typedef unsigned int Size; | ||
|
||
/// @} | ||
|
||
/// \name Creation | ||
/// @{ | ||
|
||
/*! constructs a multipolygon using a range of polygons with holes. | ||
*/ | ||
template <typename InputIterator> | ||
MultipolygonWithHoles_2(InputIterator begin, InputIterator end); | ||
|
||
/// @} | ||
|
||
/// \name Predicates | ||
/// @{ | ||
|
||
/*! returns the number of polygons with holes. | ||
*/ | ||
Size number_of_polygons_wih_holes(); | ||
|
||
/// @} | ||
|
||
/// \name Access Functions | ||
/// @{ | ||
|
||
/*! returns the begin iterator of the polygons with holes. | ||
*/ | ||
Polygon_with_holes_iterator polygons_with_holes_begin(); | ||
|
||
/*! returns the past-the-end iterator of the polygons with holes. | ||
*/ | ||
Polygon_with_holes_iterator polygons_with_holes_end(); | ||
|
||
/*! returns the begin iterator of the polygons with holes. | ||
*/ | ||
Polygon_with_holes_const_iterator polygons_with_holes_begin() const; | ||
|
||
/*! returns the past-the-end iterator of the polygons with holes. | ||
*/ | ||
Polygon_with_holes_const_iterator polygons_with_holes_end() const; | ||
|
||
/*! returns the range of polygons with holes. | ||
*/ | ||
const Polygon_with_holes_container& polygons_with_holes() const; | ||
|
||
/// @} | ||
|
||
/// \name Modifiers | ||
/// @{ | ||
|
||
/*! adds a given polygon with holes to the multipolygon. | ||
*/ | ||
void add_polygon_with_holes(const Polygon_with_holes_2& polygon); | ||
|
||
/*! erases the specified polygon. | ||
*/ | ||
void erase_polygon_with_holes(Polygon_with_holes_const_iterator pit); | ||
|
||
/*! removes all the polygons with holes. | ||
*/ | ||
void clear(); | ||
|
||
/// @} | ||
|
||
}; /* end MultipolygonWithHoles_2 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
#include <sstream> | ||
|
||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
#include <CGAL/Multipolygon_with_holes_2.h> | ||
#include <CGAL/draw_multipolygon_with_holes_2.h> | ||
#include <CGAL/IO/WKT.h> | ||
|
||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; | ||
using Multipolygon_with_holes_2 = CGAL::Multipolygon_with_holes_2<Kernel>; | ||
|
||
int main() { | ||
std::string wkt = "MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0),(0.1 0.1,0.1 0.9,0.9 0.9,0.9 0.1,0.1 0.1)),((0.2 0.2,0.8 0.2,0.8 0.8,0.2 0.8,0.2 0.2),(0.3 0.3,0.3 0.7,0.7 0.7,0.7 0.3,0.3 0.3)))"; | ||
std::istringstream iss(wkt); | ||
Multipolygon_with_holes_2 mp; | ||
CGAL::IO::read_multi_polygon_WKT(iss, mp); | ||
CGAL::draw(mp); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
#include <CGAL/Multipolygon_with_holes_2.h> | ||
|
||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; | ||
using Point_2 = Kernel::Point_2; | ||
using Polygon_2 = CGAL::Polygon_2<Kernel>; | ||
using Polygon_with_holes_2 = CGAL::Polygon_with_holes_2<Kernel>; | ||
using Multipolygon_with_holes_2 = CGAL::Multipolygon_with_holes_2<Kernel>; | ||
|
||
int main() { | ||
|
||
Point_2 p1_outer[] = {Point_2(0,0), Point_2(1,0), Point_2(1,1), Point_2(0,1)}; | ||
Point_2 p1_inner[] = {Point_2(0.2,0.2), Point_2(0.8,0.2), Point_2(0.8,0.8), Point_2(0.2,0.8)}; | ||
|
||
Polygon_with_holes_2 p1(Polygon_2(p1_outer, p1_outer+4)); | ||
Polygon_2 h(p1_inner, p1_inner+4); | ||
p1.add_hole(h); | ||
|
||
Point_2 p2_outer[] = {Point_2(0.4,0.4), Point_2(0.6,0.4), Point_2(0.6,0.6), Point_2(0.4,0.6)}; | ||
Polygon_with_holes_2 p2(Polygon_2(p2_outer, p2_outer+4)); | ||
|
||
Multipolygon_with_holes_2 mp; | ||
mp.add_polygon_with_holes(p1); | ||
mp.add_polygon_with_holes(p2); | ||
|
||
for (auto const& p: mp.polygons_with_holes()) { | ||
std::cout << p << std::endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.