Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygon repair #7608

Merged
merged 188 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
98ae089
Add package 2D Polygon Repair
afabri May 17, 2023
1f92944
Merge remote-tracking branch 'cgal/master' into HEAD
sloriot May 24, 2023
3d0fc60
fix minimal doc
sloriot May 24, 2023
da558be
initial api proposal
kenohori Jun 7, 2023
5426708
defined rest of API based on meeting today
kenohori Jun 7, 2023
bd3cf86
skeleton with compiling code
kenohori Jun 14, 2023
a2ed96d
added insertion of odd-even constraints and creation from different p…
kenohori Jun 24, 2023
7c60fad
<<operator for Multipolygon_with_holes_2
kenohori Jul 5, 2023
b46e3e8
reconstruction of multipolygon using new face base with repair info
kenohori Jul 5, 2023
868dd54
sketch of new labelling method (untested)
kenohori Jul 6, 2023
173b91b
polygon reconstruction + fixed labelling method
kenohori Jul 12, 2023
aefce52
simplified labelling code + fixed bugs, corrected reconstruction of h…
kenohori Jul 14, 2023
3517005
drawing multipolygon with holes
kenohori Jul 14, 2023
b296459
interior face iterators
kenohori Jul 14, 2023
2f1f793
fixed simple version
kenohori Jul 15, 2023
e1319a9
mostly fixed documentation
kenohori Jul 19, 2023
0cc9b43
fix cmake target name
kenohori Jul 19, 2023
31ad1cb
added licence line
kenohori Jul 19, 2023
5998fc0
trimmed trailing whitespace
kenohori Jul 19, 2023
6d9579a
The word 'Polygon' is reserved by Microsoft
afabri Jul 20, 2023
46bd5dd
Add needed #include of base class
afabri Jul 20, 2023
24ca8b4
Add needed #includes
afabri Jul 20, 2023
879b7ea
Add WKT support for Multipolygon_with_holes
afabri Jul 20, 2023
12d420f
Fix Stream_support/dependencies
afabri Jul 20, 2023
6c85e54
Fix doc typos
afabri Jul 20, 2023
59d3b21
deterministic order from lexicographically smallest vertex, hole and …
kenohori Jul 21, 2023
65ea5a5
random colours for each drawn polygon
kenohori Jul 21, 2023
eeb441f
add Guillaume since he was the author of drawing of polygons with holes
kenohori Jul 21, 2023
5361499
using instead of typedefs
kenohori Jul 24, 2023
d79c53d
less instead of compare, reuse polygon less
kenohori Jul 24, 2023
59433d9
shorter definitions with using
kenohori Jul 25, 2023
0461ded
use wkt reader instead of manually constructed examples
kenohori Jul 25, 2023
8dea133
more examples
kenohori Jul 25, 2023
3df83bc
new code for hole nesting
kenohori Jul 25, 2023
842bd85
Testing using reference files
kenohori Jul 25, 2023
c0135ea
reorganise examples and tests
kenohori Jul 26, 2023
9a28bcb
resize for vectors
kenohori Jul 26, 2023
6286ef8
direct comparison to detect polygon/multipolygon
kenohori Jul 26, 2023
0ff6dcc
comments in American English + fix typo
kenohori Jul 26, 2023
db0cb2a
spread code a bit after }
kenohori Jul 26, 2023
53ae5f8
bugfixes, empty output works now
kenohori Jul 27, 2023
61fe1f4
more unit tests
kenohori Jul 27, 2023
4c3cbc8
unit tests with empty input (breaks wkt reader)
kenohori Jul 27, 2023
7fd3bad
easy check for empty polygons
kenohori Jul 28, 2023
49177f7
new nesting code + reconstruction fix
kenohori Jul 28, 2023
60a7ef6
ref output for nesting unit test
kenohori Jul 28, 2023
9d8309f
code to write labelled triangulation
kenohori Jul 28, 2023
cca727f
c++17
kenohori Jul 28, 2023
4fc0727
consistent polygon vs hole orientation -> no need for nesting
kenohori Jul 29, 2023
eeea56a
cleanup test files
kenohori Jul 29, 2023
372244c
more unit tests
kenohori Jul 29, 2023
1f98ff2
nesting spike reference file
kenohori Jul 29, 2023
cbed7ce
remove trailing whitespaces
sloriot Aug 1, 2023
d33a2b2
fix change of meaning errors
sloriot Aug 1, 2023
45dc0be
add missing dependencies
sloriot Aug 1, 2023
bc858b3
remove vertices in collinear segments
kenohori Aug 2, 2023
a290df2
spikes test
kenohori Aug 2, 2023
c559d6d
preprocessing to get unique edges
kenohori Aug 3, 2023
ffeeb58
trailing whitespaces
kenohori Aug 3, 2023
506d51f
code to repair and generate svgs from the clipart files
kenohori Aug 4, 2023
f1b2adb
start vertex search from face incident to last insertion
kenohori Aug 4, 2023
a688d1a
init bbox
kenohori Aug 4, 2023
26d2517
started with user manual
kenohori Aug 9, 2023
cab7deb
fix citation
kenohori Aug 9, 2023
ff1b359
more manual
kenohori Aug 11, 2023
88a4322
insert all vertices first, then all constrained edges
kenohori Aug 11, 2023
59f2cb0
renamed functions with repair method
kenohori Aug 11, 2023
0083250
simple multipolygon example
kenohori Aug 12, 2023
5a9e002
Update Polygon_repair_2/doc/Polygon_repair_2/Polygon_repair_2.txt
kenohori Aug 20, 2023
634fb06
Update Polygon_repair_2/doc/Polygon_repair_2/Polygon_repair_2.txt
kenohori Aug 20, 2023
4ef71dc
Update Polygon_repair_2/include/CGAL/Polygon_repair_2/Multipolygon_wi…
kenohori Aug 20, 2023
5ee8cda
draw multipolygon doc
kenohori Aug 20, 2023
58f80a2
Merge remote-tracking branch 'kenohori-cgal/gsoc2023-polygon_repair-k…
kenohori Aug 20, 2023
72c38e4
rest of draw_multipolygon example
kenohori Aug 21, 2023
6db7abb
put wkt directly in example
kenohori Aug 21, 2023
c20d01c
Merge branch 'CGAL:master' into gsoc2023-polygon_repair-kenohori
kenohori Aug 21, 2023
55d2fe8
c++17 from master
kenohori Aug 21, 2023
b9ffb31
clipart in test
kenohori Aug 21, 2023
96007f2
data for example
kenohori Aug 21, 2023
28cfa7e
step by step example
kenohori Aug 21, 2023
edfa190
more of the manual
kenohori Aug 22, 2023
f356259
more details about algorithm
kenohori Aug 23, 2023
6c703f7
Polygon_repair_2 -> Polygon_repair
sloriot Aug 24, 2023
1e77a29
add bibtex and fix cite
sloriot Aug 24, 2023
4613aa7
move multipolygon to polygon package
kenohori Aug 24, 2023
9bfe91f
missed draw function for multipolygons
kenohori Aug 24, 2023
3e1537d
move old examples to tests
kenohori Aug 24, 2023
9820595
doc with history and w/o triangulation, mp
kenohori Aug 24, 2023
5c4e48e
fix dependencies
kenohori Aug 24, 2023
8192774
info about multipolygons in polygon manual
kenohori Aug 25, 2023
9ae9f54
remove old figs
kenohori Aug 25, 2023
188188e
svg
kenohori Aug 25, 2023
f4c6021
in/out will be in table
kenohori Aug 25, 2023
ca3ad80
valid and invalid examples
kenohori Aug 25, 2023
fff924b
in/out examples
kenohori Aug 25, 2023
db09bc9
some performance info
kenohori Aug 29, 2023
4231565
detect kernel automatically
kenohori Aug 29, 2023
69a01c7
unique_edges should be in class, clear all variables
kenohori Aug 30, 2023
79edf30
explain counting
kenohori Aug 30, 2023
d174f6a
doc formatting
kenohori Aug 30, 2023
f2cb4ed
draft (multi)polygon validation
kenohori Aug 30, 2023
d5f0f77
missed a part
kenohori Aug 30, 2023
fdc5fa5
trim whitespace
kenohori Aug 30, 2023
6626b52
better approach reusing existing functions + testing more cases
kenohori Aug 30, 2023
448e611
images for doc
kenohori Aug 30, 2023
1b4ce1c
put is_valid outside, bugfixes
kenohori Aug 31, 2023
bc16dda
label region static, bugfixes
kenohori Aug 31, 2023
e331136
polygons can be in any hole, not just exterior
kenohori Aug 31, 2023
2ab6ad8
some more checks
kenohori Aug 31, 2023
c402ba7
wkt validation
kenohori Aug 31, 2023
dc3e195
test for clipart files
kenohori Sep 1, 2023
e9fc58b
get rid of hashes for exact kernels
kenohori Sep 2, 2023
3386efd
test showing exact kernel
kenohori Sep 2, 2023
a5cea61
exact_test needs qt too
kenohori Sep 2, 2023
fbf3e08
test_clipart not needed
kenohori Sep 2, 2023
091511b
test clipart files directly instead
kenohori Sep 2, 2023
23c4e10
remove default kernel
kenohori Sep 2, 2023
0cf0131
update dependencies
kenohori Sep 4, 2023
31ca1f1
package details
kenohori Sep 6, 2023
015e2ba
repair is odd-even
kenohori Sep 6, 2023
12d3505
remove undocumented classes
kenohori Sep 6, 2023
e06422a
logo draft
kenohori Sep 6, 2023
35d56ae
todo for exact kernels
kenohori Sep 6, 2023
6a20390
svg logo for the future
kenohori Sep 6, 2023
d954161
capitalisation
kenohori Sep 6, 2023
c1e1e72
narrower figure
kenohori Sep 6, 2023
6c9bc49
triangulation should be passed by reference
kenohori Sep 7, 2023
467dcf9
Merge remote-tracking branch 'cgal/master' into HEAD
sloriot Oct 6, 2023
52e9196
use new macros
sloriot Oct 6, 2023
be2ccc2
typo
afabri Oct 6, 2023
1416ddf
No <b>
afabri Oct 6, 2023
455c632
labelled -> labeled
afabri Oct 6, 2023
4f9dd85
PolygonContainer -> Container
afabri Oct 6, 2023
55c5645
Move code to internal folder/namespace
afabri Oct 6, 2023
2f9535d
no concepts, export->insert in a stream, capitalize
afabri Oct 6, 2023
be6fa67
120x120 logo
kenohori Oct 11, 2023
cc04b10
remove non-author of one file
afabri Oct 17, 2023
9f5a217
fix ingroup
afabri Oct 17, 2023
4b9544d
Fix doc of the parameters of the multipolygon
afabri Oct 17, 2023
1fb664a
Document Size
afabri Oct 17, 2023
f06f102
holes -> polygons
afabri Oct 17, 2023
950ed67
remove sentence about ability to store
afabri Oct 17, 2023
d760c40
Be precise
afabri Oct 17, 2023
6d51db7
Change filename
afabri Oct 17, 2023
f1c14d5
fix example
afabri Oct 17, 2023
7ed78a0
mark holes with red edges
kenohori Oct 25, 2023
04264b5
Add non const iterator in the doc
afabri Nov 16, 2023
43bf7ed
no concepts in this package
afabri Jan 4, 2024
ef67654
Ken did more than prototyping
afabri Jan 4, 2024
d1f19a7
Add to CHANGES.md
afabri Jan 4, 2024
c3d4d11
Merge remote-tracking branch 'cgal/master' into gsoc2023-polygon_repa…
afabri Jan 5, 2024
be89ad2
Qt5 -> Qt6
afabri Jan 5, 2024
6edfffe
update doc to qt6
sloriot Jan 5, 2024
c5a186b
Add Even_odd_rule
afabri Jan 18, 2024
e890992
Fix clipart.cpp
afabri Jan 18, 2024
ef8d274
Document the rule
afabri Jan 18, 2024
1d8b017
Fix package description
afabri Jan 18, 2024
db6f210
Fix one input path
afabri Jan 18, 2024
c21a988
Add the file
afabri Jan 18, 2024
a0ad182
Fixes after Guillaume's review
afabri Feb 6, 2024
458c52e
Fixes after Guillaume's review
afabri Feb 6, 2024
edc721e
wording
afabri Feb 6, 2024
653bc36
wording
afabri Feb 6, 2024
5e01914
C++ comment doxygen command
afabri Feb 6, 2024
1c31cfd
Fix path
afabri Feb 7, 2024
5333c6f
#define CGAL_NO_CDT_2_WARNING
afabri Feb 7, 2024
aa6ff65
Change #include order to check dependencies
afabri Feb 7, 2024
8007536
Only compile some of the test cases so that we can have it in a tests…
afabri Feb 7, 2024
38c43ce
Fix multipolygon.cpp
afabri Feb 23, 2024
25b084e
Fix operator<< for Multipolygon_with_holes
afabri Feb 23, 2024
2324d61
Rename header file
afabri Mar 4, 2024
263db4f
Merge master
afabri Mar 4, 2024
b0f4e73
Make the Even_odd_rule a default
afabri Mar 4, 2024
7edadee
fix code
afabri Mar 4, 2024
181cec6
conversion warning
afabri Mar 5, 2024
b13b01a
Remove argc, argv
afabri Mar 6, 2024
b9f3e35
Address warning and assert the Rule type
afabri Mar 6, 2024
5e3cf43
flush
afabri Mar 8, 2024
6744cc1
Add operator==() for Multipolygon_wih_holes
afabri Mar 11, 2024
cf0c917
fix unused variables
afabri Mar 12, 2024
a3fab59
fix unused variables
afabri Mar 12, 2024
511cc50
Do not compare strings, and do a write/read back in order to round
afabri Mar 12, 2024
79ec446
Add #includes
afabri Mar 13, 2024
b0ac1d1
Move files from test to benchmark
afabri Mar 13, 2024
fcbf327
workaround absence of <filesystem>
sloriot Mar 13, 2024
5331c7e
move after definition of function used
sloriot Mar 13, 2024
151b343
readd figs
sloriot Mar 21, 2024
30c303f
Update CHANGES.md
lrineau Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Documentation/doc/Documentation/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
\cgalPackageSection{PartPolygons,Polygons}

\package_listing{Polygon}
\package_listing{Polygon_repair}
\package_listing{Boolean_set_operations_2}
\package_listing{Nef_2}
\package_listing{Nef_S2}
Expand Down
10 changes: 10 additions & 0 deletions Documentation/doc/biblio/geom.bib
Original file line number Diff line number Diff line change
Expand Up @@ -152054,3 +152054,13 @@ @inproceedings{tang2009interactive
year={2009},
organization={ACM}
}

@article{ledoux2014triangulation,
title={A triangulation-based approach to automatically repair GIS polygons},
author={Ledoux, Hugo and Ohori, Ken Arroyo and Meijers, Martijn},
journal={Computers \& Geosciences},
volume={66},
pages={121--131},
year={2014},
publisher={Elsevier}
}
4 changes: 4 additions & 0 deletions Installation/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Release date: October 2023
- **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection.
- **Breaking change**: The file CMake file `UseCGAL.cmake` has been removed from CGAL. Usages of the CMake variables `${CGAL_USE_FILE}` and `${CGAL_LIBRARIES}` must be replaced by a link to the imported target `CGAL::CGAL`, for example: `target_link_library(the_target PRIVATE CGAL::CGAL)`.

### [Polygon Repair](https://doc.cgal.org/6.0/Manual/packages.html#PkgPolygonRepair) (new package)

- This package provides functions to repair polygons, polygons with holes, and multipolygons with holes
using the odd-even heuristic.

#### 2D Arrangements

Expand Down
54 changes: 54 additions & 0 deletions Installation/include/CGAL/license/Polygon_repair.h
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
101 changes: 101 additions & 0 deletions Polygon/doc/Polygon/Concepts/MultipolygonWithHoles_2.h
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 */
13 changes: 12 additions & 1 deletion Polygon/doc/Polygon/PackageDescription.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
\cgalInclude{CGAL/draw_polygon_with_holes_2.h}
*/
/// \defgroup PkgDrawPolygonWithHoles2 Draw a 2D Polygon with Holes
/// \ingroup PkgPolygon2Ref

/*!
\code
#include <CGAL/draw_multipolygon_with_holes_2.h>
\endcode
*/
/// \defgroup PkgDrawMultipolygonWithHoles2 Draw a 2D Multipolygon with Holes

/*!
\addtogroup PkgPolygon2Ref
Expand All @@ -42,11 +48,13 @@
\cgalCRPSection{Concepts}
- `PolygonTraits_2`
- `GeneralPolygonWithHoles_2`
- `MultipolygonWithHoles_2`

\cgalCRPSection{Classes}
- `CGAL::Polygon_2<PolygonTraits_2, Container>`
- `CGAL::Polygon_with_holes_2<PolygonTraits_2,Container>`
- `CGAL::General_polygon_with_holes_2<Polygon>`
- `CGAL::Multipolygon_with_holes_2<PolygonTraits_2,Container>`

\cgalCRPSection{Global Functions}
- `CGAL::area_2()`
Expand All @@ -67,4 +75,7 @@
\cgalCRPSection{Draw a Polygon_with_holes_2}
- \link PkgDrawPolygonWithHoles2 CGAL::draw<PH>() \endlink

\cgalCRPSection{Draw a Multipolygon_with_holes_2}
- \link PkgDrawMultipolygonWithHoles2 CGAL::draw<MPH>() \endlink

*/
34 changes: 22 additions & 12 deletions Polygon/doc/Polygon/Polygon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ points, but little more. Especially, computed values are not cached.
That is, when the `Polygon_2::is_simple()` member function is called
twice or more, the result is computed each time anew.

\section secPolygonWithHole Polygons with Holes and Multipolygons with Holes

This package also provides classes to represent polygons with holes and multipolygons with holes.

For polygons with holes, these are `Polygon_with_holes_2` and `General_polygon_with_holes_2`. They can store a polygon that represents
the outer boundary and a sequence of polygons that represent the holes.

For multipolygons with holes, there is `Multipolygon_with_holes_2`.
It stores a sequence of polygons with holes.

These classes do not add any semantic requirements on the simplicity
or orientation of their boundary polygons.

\section secPolygonExamples Examples

\subsection subsecPolygon The Polygon Class
Expand All @@ -46,6 +59,13 @@ some member functions.

\cgalExample{Polygon/Polygon.cpp}

\subsection SubsectionPolygonRepair_Multipolygon The Multipolygon with Holes Class

The following example shows the creation of a multipolygon with holes and the traversal
of the polygons in it.

\cgalExample{Polygon/multipolygon.cpp}

\cgalFigureBegin{polygon2_algo,pgn_algos.png}
A polygon and some points
\cgalFigureEnd
Expand Down Expand Up @@ -82,7 +102,8 @@ vertices. It additionally provides a member function `Polygon_2::vertices()` tha

\subsection subsecPolygonDraw Draw a Polygon

A polygon can be visualized by calling the \link PkgDrawPolygon2 CGAL::draw<P>() \endlink function as shown in the following example. This function opens a new window showing the given polygon. A call to this function is blocking, that is the program continues as soon as the user closes the window (a version exists for polygon with holes, cf. \link PkgDrawPolygonWithHoles2 CGAL::draw<PH>() \endlink).
A polygon can be visualized by calling the \link PkgDrawPolygon2 CGAL::draw<P>() \endlink function as shown in the following example. This function opens a new window showing the given polygon. A call to this function is blocking, that is the program continues as soon as the user closes the window. Versions for polygons with holes and multipolygons with holes also exist, cf. \link PkgDrawPolygonWithHoles2 CGAL::draw<PH>() \endlink and \link PkgDrawMultipolygonWithHoles2
CGAL::draw<MPH>() \endlink.

\cgalExample{Polygon/draw_polygon.cpp}

Expand All @@ -94,15 +115,4 @@ Result of the run of the draw_polygon program. A window shows the polygon and al
\cgalFigureEnd

*/

\section secPolygonWithHole Polygons with Holes

This package also provides two classes to represent polygons with holes,
namely `Polygon_with_holes_2` and `General_polygon_with_holes_2`. They
can store a polygon that represents the outer boundary and a sequence
of polygons that represent the holes.

These classes do not add any semantic requirements on the simplicity
or orientation of their boundary polygons.

}
2 changes: 2 additions & 0 deletions Polygon/doc/Polygon/examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
\example Stream_support/Polygon_WKT.cpp
\example Polygon/draw_polygon.cpp
\example Polygon/draw_polygon_with_holes.cpp
\example Polygon/multipolygon.cpp
\example Polygon/draw_multipolygon_with_holes.cpp
*/
1 change: 1 addition & 0 deletions Polygon/examples/Polygon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ endforeach()
if(CGAL_Qt6_FOUND)
target_link_libraries(draw_polygon PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(draw_polygon_with_holes PUBLIC CGAL::CGAL_Basic_viewer)
target_link_libraries(draw_multipolygon_with_holes PUBLIC CGAL::CGAL_Basic_viewer)
endif()
20 changes: 20 additions & 0 deletions Polygon/examples/Polygon/draw_multipolygon_with_holes.cpp
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;
}
31 changes: 31 additions & 0 deletions Polygon/examples/Polygon/multipolygon.cpp
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;
}
4 changes: 2 additions & 2 deletions Polygon/include/CGAL/General_polygon_with_holes_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace CGAL {
*
* The class `General_polygon_with_holes_2` models the concept
* `GeneralPolygonWithHoles_2`. It represents a general polygon with holes.
* It is parameterized with a type `Polygon` used to define the exposed
* type `Polygon_2`. This type represents the outer boundary of the general
* It is parameterized with a type `Polygon_` used to define the exposed
* type `%Polygon_2`. This type represents the outer boundary of the general
* polygon and each hole.
*
* \tparam Polygon_ must have input and output operators.
Expand Down
Loading