mirror of https://github.com/CGAL/cgal
incorporate final comments during developer meeting
changed tags to categories shorter history section
This commit is contained in:
parent
99a9367396
commit
bbfa235f08
|
|
@ -16,19 +16,19 @@ a query point, which is one of the essential steps to achive linear query time.
|
|||
|
||||
\tparam Arrangement_2 is the type of input polygonal environment and output visibility polygon.
|
||||
|
||||
\tparam RegularizationTag indicates whether the output should be regularized. It can be
|
||||
\tparam RegularizationCategory indicates whether the output should be regularized. It can be
|
||||
specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false is the default value.
|
||||
|
||||
|
||||
\cgalModels `Visibility_2`
|
||||
|
||||
\sa `CGAL::Simple_polygon_visibility_2<Arrangement_2, RegularizationTag>`
|
||||
\sa `CGAL::Rotational_sweep_visibility_2<Arrangement_2, RegularizationTag>`
|
||||
\sa `CGAL::Triangular_expansion_visibility_2<Arrangement_2, RegularizationTag>`
|
||||
\sa `CGAL::Simple_polygon_visibility_2<Arrangement_2, RegularizationCategory>`
|
||||
\sa `CGAL::Rotational_sweep_visibility_2<Arrangement_2, RegularizationCategory>`
|
||||
\sa `CGAL::Triangular_expansion_visibility_2<Arrangement_2, RegularizationCategory>`
|
||||
|
||||
|
||||
*/
|
||||
template <typename Arrangement_2, typename RegularizationTag = Tag_false>
|
||||
template <typename Arrangement_2, typename RegularizationCategory = Tag_false>
|
||||
class Preprocessed_rotational_sweep_visibility_2 {
|
||||
public:
|
||||
|
||||
|
|
@ -68,19 +68,19 @@ public:
|
|||
/// \name Tags
|
||||
/// @{
|
||||
/*!
|
||||
Tag identifying whether the regularized visibility area is computed.
|
||||
identifies whether the regularized visibility area is computed.
|
||||
*/
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
|
||||
/*!
|
||||
Tag identifying that the class supports general polygons (i.e.\ with holes).
|
||||
identifies that the class supports general polygons (i.e.\ with holes).
|
||||
*/
|
||||
typedef ::Tag_true Supports_general_polygon_tag;
|
||||
typedef ::Tag_true Supports_general_polygon_category;
|
||||
|
||||
/*!
|
||||
Tag identifying that the class supports general simple polygons.
|
||||
identifies that the class supports general simple polygons.
|
||||
*/
|
||||
typedef ::Tag_true Supports_simple_polygon_tag;
|
||||
typedef ::Tag_true Supports_simple_polygon_category;
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace CGAL {
|
|||
It must be an instance of CGAL::Arrangement_2, where its CGAL::Arrangement_2::Traits_2 must be an instance of
|
||||
CGAL::Arr_segment_traits_2, or of CGAL::Arr_non_caching_segment_traits_2.
|
||||
|
||||
\tparam RegularizationTag indicates whether the output should be regularized. It can be
|
||||
\tparam RegularizationCategory indicates whether the output should be regularized. It can be
|
||||
specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false is the default value.
|
||||
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false
|
|||
\sa `CGAL::Triangular_expansion_visibility_2`
|
||||
|
||||
*/
|
||||
template <typename Arrangement_2_, typename RegularizationTag = Tag_true>
|
||||
template <typename Arrangement_2_, typename RegularizationCategory = Tag_true>
|
||||
class Rotational_sweep_visibility_2 {
|
||||
public:
|
||||
|
||||
|
|
@ -40,19 +40,19 @@ public:
|
|||
/// \name Tags
|
||||
/// @{
|
||||
/*!
|
||||
\copydoc ::Visibility_2::Regularization_tag
|
||||
\copydoc ::Visibility_2::Regularization_category
|
||||
*/
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
|
||||
/*!
|
||||
See \ref Visibility_2::Supports_general_polygon_tag.
|
||||
See \ref Visibility_2::Supports_general_polygon_category.
|
||||
*/
|
||||
typedef ::Tag_true Supports_general_polygon_tag;
|
||||
typedef ::Tag_true Supports_general_polygon_category;
|
||||
|
||||
/*!
|
||||
See \ref Visibility_2::Supports_simple_polygon_tag.
|
||||
See \ref Visibility_2::Supports_simple_polygon_category.
|
||||
*/
|
||||
typedef ::Tag_true Supports_simple_polygon_tag;
|
||||
typedef ::Tag_true Supports_simple_polygon_category;
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ is the number of the vertices of the polygon.
|
|||
It must be an instance of CGAL::Arrangement_2, where its CGAL::Arrangement_2::Traits_2 must be an instance of
|
||||
CGAL::Arr_segment_traits_2, or of CGAL::Arr_non_caching_segment_traits_2.
|
||||
|
||||
\tparam RegularizationTag indicates whether the output should be regularized. It can be
|
||||
\tparam RegularizationCategory indicates whether the output should be regularized. It can be
|
||||
specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false is the default value.
|
||||
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false
|
|||
\sa `CGAL::Rotational_sweep_visibility_2`
|
||||
\sa `CGAL::Triangular_expansion_visibility_2`
|
||||
*/
|
||||
template <typename Arrangement_2_, typename RegularizationTag = Tag_true>
|
||||
template <typename Arrangement_2_, typename RegularizationCategory = Tag_true>
|
||||
class Simple_polygon_visibility_2 {
|
||||
public:
|
||||
|
||||
|
|
@ -45,19 +45,19 @@ public:
|
|||
/// \name Tags
|
||||
/// @{
|
||||
/*!
|
||||
\copydoc ::Visibility_2::Regularization_tag
|
||||
\copydoc ::Visibility_2::Regularization_category
|
||||
*/
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
|
||||
/*!
|
||||
See \ref Visibility_2::Supports_general_polygon_tag.
|
||||
See \ref Visibility_2::Supports_general_polygon_category.
|
||||
*/
|
||||
typedef ::Tag_false Supports_general_polygon_tag;
|
||||
typedef ::Tag_false Supports_general_polygon_category;
|
||||
|
||||
/*!
|
||||
See \ref Visibility_2::Supports_simple_polygon_tag.
|
||||
See \ref Visibility_2::Supports_simple_polygon_category.
|
||||
*/
|
||||
typedef ::Tag_true Supports_simple_polygon_tag;
|
||||
typedef ::Tag_true Supports_simple_polygon_category;
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ The query time is \f$ O(nh)\f$, where \f$ h \f$ is the number of holes+1 of inpu
|
|||
It must be an instance of CGAL::Arrangement_2, where its CGAL::Arrangement_2::Traits_2 must be an instance of
|
||||
CGAL::Arr_segment_traits_2, or of CGAL::Arr_non_caching_segment_traits_2.
|
||||
|
||||
\tparam RegularizationTag indicates whether the output should be regularized. It can be
|
||||
\tparam RegularizationCategory indicates whether the output should be regularized. It can be
|
||||
specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false is the default value.
|
||||
|
||||
\cgalModels `Visibility_2`
|
||||
|
|
@ -24,7 +24,7 @@ specified by one of the following: ::Tag_true or ::Tag_false, where ::Tag_false
|
|||
|
||||
|
||||
*/
|
||||
template <typename Arrangement_2_, typename RegularizationTag = Tag_true>
|
||||
template <typename Arrangement_2_, typename RegularizationCategory = Tag_true>
|
||||
class Triangular_expansion_visibility_2 {
|
||||
public:
|
||||
|
||||
|
|
@ -42,19 +42,19 @@ public:
|
|||
/// \name Tags
|
||||
/// @{
|
||||
/*!
|
||||
\copydoc ::Visibility_2::Regularization_tag
|
||||
\copydoc ::Visibility_2::Regularization_category
|
||||
*/
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
|
||||
/*!
|
||||
See \ref Visibility_2::Supports_general_polygon_tag.
|
||||
See \ref Visibility_2::Supports_general_polygon_category.
|
||||
*/
|
||||
typedef ::Tag_true Supports_general_polygon_tag;
|
||||
typedef ::Tag_true Supports_general_polygon_category;
|
||||
|
||||
/*!
|
||||
See \ref Visibility_2::Supports_simple_polygon_tag.
|
||||
See \ref Visibility_2::Supports_simple_polygon_category.
|
||||
*/
|
||||
typedef ::Tag_true Supports_simple_polygon_tag;
|
||||
typedef ::Tag_true Supports_simple_polygon_category;
|
||||
/// @}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,26 +42,26 @@ public:
|
|||
/// \name Tags
|
||||
/// @{
|
||||
/*!
|
||||
Tag identifying whether the regularized visibility area is computed (either \ref CGAL::Tag_true or \ref CGAL::Tag_false).
|
||||
identifies whether the regularized visibility area is computed (either \ref CGAL::Tag_true or \ref CGAL::Tag_false).
|
||||
*/
|
||||
typedef unspecified_type Regularization_tag;
|
||||
typedef unspecified_type Regularization_category;
|
||||
|
||||
/*!
|
||||
Tag identifying whether general polygons (with holes) are supported (either \ref CGAL::Tag_true or \ref CGAL::Tag_false).
|
||||
identifies whether general polygons (with holes) are supported (either \ref CGAL::Tag_true or \ref CGAL::Tag_false).
|
||||
A general polygon is represented by a face \f$ f \f$ with no
|
||||
isolated vertex and any edge of \f$ f \f$ separates \f$ f \f$ from another face.
|
||||
Note that this allows \f$ f \f$ to touch a vertex from several sides.
|
||||
*/
|
||||
typedef unspecified_type Supports_general_polygon_tag;
|
||||
typedef unspecified_type Supports_general_polygon_category;
|
||||
|
||||
/*!
|
||||
Tag identifying whether simple polygons are supported (either \ref CGAL::Tag_true or \ref CGAL::Tag_false).
|
||||
identifies whether simple polygons are supported (either \ref CGAL::Tag_true or \ref CGAL::Tag_false).
|
||||
|
||||
A simple polygon is represented by a face \f$ f \f$ with no holes,
|
||||
no isolated vertex and any edge of \f$ f \f$ separates \f$ f \f$ from another face.
|
||||
Note that this allows \f$ f \f$ to touch a vertex from several sides.
|
||||
*/
|
||||
typedef unspecified_type Supports_simple_polygon_tag;
|
||||
typedef unspecified_type Supports_simple_polygon_category;
|
||||
/// @}
|
||||
|
||||
/// \name Constructors
|
||||
|
|
|
|||
|
|
@ -7,25 +7,23 @@ namespace CGAL {
|
|||
|
||||
\authors Michael Hemmer, Kan Huang, Francisc Bungiu, Ning Xu
|
||||
|
||||
\cgalFigureBegin{example_figure,visibility-teaser.png}
|
||||
\cgalFigureEnd
|
||||
<!-- \cgalFigureBegin{example_figure,visibility-teaser.png}\cgalFigureEnd -->
|
||||
|
||||
\section visibility_2_introduction Introduction
|
||||
|
||||
This package provides functionality to compute the visibility region within polygonal regions in two dimensions.
|
||||
Using the terminology of the package \ref PkgBooleanSetOperations2Summary, we expect the input polygon
|
||||
\f$ P \f$ to be a valid polygon or a valid polygon with holes (the definition is given below).
|
||||
This package provides functionality to compute the visibility region within polygons in two dimensions.
|
||||
The package is based on the package \ref PkgArrangement2Summary and uses CGAL::Arrangement_2
|
||||
as the fundamental class to specify the input as well as the output.
|
||||
Hence, a polygon \f$ P \f$ is represented by an bounded arrangement face \f$ f \f$
|
||||
that does not have any isolated vertices and any edge that is adjacent to \f$ f \f$ separates \f$ f \f$ from another face.
|
||||
Note that \f$ f \f$ may contain holes.
|
||||
Similarly, a simple polygon is represented by a face without holes.
|
||||
|
||||
Given two points \f$ p \f$ and \f$ q \f$ in \f$ P \f$, they are said to be
|
||||
visible to each other iff the segment \f$ pq \subset P \f$, note that \f$\partial P \subset P\f$.
|
||||
For a query point \f$ q \in P \f$, the set of points that are visible from \f$ q \f$ is defined as the visibility
|
||||
region of \f$ q \f$, denoted by \f$ V_q \f$
|
||||
|
||||
|
||||
Definition [Valid Polygon]:
|
||||
A polygon \f$ P \f$ is valid if \f$ P \f$ is closed (\f$\partial P \subset P\f$) and each boundary loop is simple. Namely, \f$ P \f$ has exactly one outer boundary (it may have some inner boundaires), and the edges in each boundary loop are only allowed to intersect at vertices. Note that a vertex may appear multiple times in one boundary loop. See \ref PkgBooleanSetOperations2Summary for the complete definition.
|
||||
|
||||
Definition [Simple Polygon]
|
||||
A valid polygon is simple if has no holes, i.e., it has exactly one boundary which is an outer boundary.
|
||||
visible to each other iff the segment \f$ pq \subset P \f$, where \f$ P \f$ is
|
||||
considered to be closed, that is, \f$\partial P \subset P\f$.
|
||||
For a query point \f$ q \in P \f$, the set of points that are visible from
|
||||
\f$ q \f$ is defined as the visibility region of \f$ q \f$, denoted by \f$ V_q \f$
|
||||
|
||||
\subsection visibility_2_degeneracies Degeneracies and Regularization
|
||||
|
||||
|
|
@ -34,119 +32,131 @@ Non-regularized visibility and regularized visibility.
|
|||
\cgalFigureEnd
|
||||
|
||||
|
||||
As illustrated in \cgalFigureRef{definition-fig} (1) the visibility region \f$ V_q \f$ of a query point \f$ q \f$ may not be
|
||||
a valid polygon. In the figure, all labeled points are collinear, which implies that the point \f$ c \f$ is visible to \f$ q \f$, that is,
|
||||
the segment \f$ bc \f$ is part of the visibility area \f$ V_q \f$.
|
||||
As illustrated in \cgalFigureRef{definition-fig} (1) the visibility
|
||||
region \f$ V_q \f$ of a query point \f$ q \f$ may not be a polygon.
|
||||
In the figure, all labeled points are collinear, which implies that the
|
||||
point \f$ c \f$ is visible to \f$ q \f$, that is,
|
||||
the segment \f$ bc \f$ is part of \f$ V_q \f$.
|
||||
We call such low dimensional features that are caused by degeneracies `needles`.
|
||||
However, for many applications these needles are actually irrelevant.
|
||||
Moreover, for some algorithms it is actually easier (and more efficient) to ignore needles
|
||||
Moreover, for some algorithms it is even more efficient to ignore needles
|
||||
in the first place.
|
||||
Therefore, this package offers also
|
||||
functionality to compute the regularized visibility area
|
||||
\f$ \overline{V_q} = closure(interior(V_q)) = (V_q\setminus\partial V_q) \cup \partial (V_q\setminus\partial V_q)\f$,
|
||||
as it is shown in \cgalFigureRef{definition-fig} (2). For more information about regularization, refer to Chapter
|
||||
\ref PkgBooleanSetOperations2Summary.
|
||||
|
||||
In summary, this package provides two kinds of visibility region of point \f$ q \f$:
|
||||
- Non-regularized visibility area \f$ V_q \f$.
|
||||
- Regularized visibility area \f$ \overline{V_q} \f$.
|
||||
|
||||
as shown in \cgalFigureRef{definition-fig} (2).
|
||||
For more information about regularization, refer to Chapter \ref PkgBooleanSetOperations2Summary.
|
||||
|
||||
\section visibility_2_classes Classes and Algorithms
|
||||
|
||||
This package is based on the \ref PkgArrangement2Summary package and exploits several of its features.
|
||||
In particular, the output is represented by an `Arrangement_2`, which enables
|
||||
the representation of needles. All provided class templates follow the `Visibility_2` concept.
|
||||
|
||||
Answering visibility queries is, in many ways, similar to answering point-location queries. Thus, we use the same design used
|
||||
to implement point location. Each of the various visibility class templates employs a different algorithm or \em strategy for answering queries
|
||||
\cgalFootnote{The term \em strategy is borrowed from the design-pattern taxonomy~\cite ghjv-dpero-95. A \em strategy provides
|
||||
the means to define a family of algorithms, each implemented by a separate class. All classes that implement the various
|
||||
Answering visibility queries is, in many ways, similar to answering point-location queries.
|
||||
Thus, we use the same design used to implement point location.
|
||||
Each of the various visibility class templates employs a different
|
||||
algorithm or \em strategy for answering
|
||||
queries\cgalFootnote{The term \em strategy is borrowed from the
|
||||
design-pattern taxonomy~\cite ghjv-dpero-95.
|
||||
A \em strategy provides the means to define a family of algorithms,
|
||||
each implemented by a separate class. All classes that implement the various
|
||||
algorithms are made interchangeable, letting the algorithm in use vary according to the user choice.}.
|
||||
Similar to the point-location case, some of the strategies require preprocessing. Thus, before a visibility object is used
|
||||
to answer visibility queries, it must be attached to an arrangement object (subsequently also referred to as the environment).
|
||||
Afterwards the visibility object observers changes to the attached arrangement.
|
||||
Clearly, it is possible to modify the arrangement after attaching the visibility object.
|
||||
However, this should be avoided as this also requires an update of the auxiliary
|
||||
data structures in the attached object.
|
||||
An actual query is then performed by giving the view point \f$ p \f$ and its containing face \f$ f \f$,
|
||||
which must represent a valid \cgalFootnote{See the package \ref PkgBooleanSetOperations2Summary for the precise definition}
|
||||
polygon. Namely, in the face \f$ f \f$, there is no isolated vertex, and any edge of \f$ f \f$ separates \f$ f \f$ from another face.
|
||||
For this purpose every model of the Visibility_2 concept provides two overloaded member functions, called `Visibility_2::compute_visibility()`
|
||||
, that compute the visibility region of \f$ p \f$ in a bounded polygonal face \f$ f \f$: one is for the case where
|
||||
\f$ p \f$ is in the interior of \f$ f \f$; the other one is for the case where \f$ p \f$ is on the boundary of \f$ f \f$.
|
||||
to answer visibility queries, it must be attached to an arrangement object.
|
||||
Afterwards, the visibility object observes changes to the attached arrangement.
|
||||
Hence, it is possible to modify the arrangement after attaching the visibility object.
|
||||
However, this feature should be used with caution as each change to the arrangement also
|
||||
requires an update of the auxiliary data structures in the attached object.
|
||||
|
||||
An actual query is performed by giving the view point \f$ p \f$ and its containing face \f$ f \f$
|
||||
(which must represent a valid polygon) to a visibility object.
|
||||
For more details see the documentation of the overloaded member function `Visibility_2::compute_visibility()`.
|
||||
|
||||
The following models of the `Visibility_2` concept are provided:
|
||||
|
||||
The package provides the following models of the `Visibility_2` concept:
|
||||
|
||||
<CENTER>
|
||||
Class | Function | Preprocessing | Query |Algorithm
|
||||
-------------------------------|-----------------------------------------------------|-------------------------------|-----------------------------------|-------------------------------
|
||||
`Simple_polygon_visibility_2` | simple valid polygons | No |\f$ O(n) \f$ time and \f$ O(n) \f$ space | B. Joe and R. B. Simpson \cite bjrb-clvpa-87
|
||||
`Rotational_sweep_visibility_2` | valid polygons with holes | No | \f$ O(n\log n) \f$ time and \f$ O(n) \f$ space | T. Asano \cite ta-aeafvpprh-85
|
||||
`Triangular_expansion_visibility_2` | valid polygons with holes | \f$ O(n) \f$ time and \f$ O(n) \f$ space | \f$ O(nh) \f$ time and \f$ O(n) \f$ space. | new
|
||||
`Simple_polygon_visibility_2` | simple polygons | No |\f$ O(n) \f$ time and \f$ O(n) \f$ space | B. Joe and R. B. Simpson \cite bjrb-clvpa-87
|
||||
`Rotational_sweep_visibility_2` | polygons with holes | No | \f$ O(n\log n) \f$ time and \f$ O(n) \f$ space | T. Asano \cite ta-aeafvpprh-85
|
||||
`Triangular_expansion_visibility_2` | polygons with holes | \f$ O(n) \f$ time and \f$ O(n) \f$ space | \f$ O(nh) \f$ time and \f$ O(n) \f$ space. | Bungiu et al. \cite ecvp-bhhhk-14
|
||||
</CENTER>
|
||||
|
||||
Where \f$ n \f$ denotes the number of vertices of \f$ f \f$ and \f$ h \f$ the number of holes+1.
|
||||
|
||||
\f$ n \f$ is the number of vertices of \f$ f \f$ and \f$ h \f$ is the number of holes+1.
|
||||
|
||||
\section benchmarks Runtime in Practice
|
||||
\section benchmarks Running Time in Practice
|
||||
|
||||
\cgalFigureBegin{cathedral-fig, cathedral_2.png}
|
||||
Example environment representing a cathedral.
|
||||
Example representing a cathedral.
|
||||
\cgalFigureEnd
|
||||
|
||||
The left hand side of Figure \cgalFigureRef{cathedral-fig} depicts the outer boundary of a cathedral,
|
||||
which is a simple polygon with 565 vertices. The right hand side shows the cathedral also with its inner
|
||||
pillars, which is a polygon (with holes) with 1153 vertices. The following table shows the total runtime consumption of the computation of
|
||||
which is a simple polygon with 565 vertices.
|
||||
The right hand side shows the cathedral also with its inner pillars, which is a polygon (with holes)
|
||||
with 1153 vertices.
|
||||
The following table shows the total runtime consumption of the computation of
|
||||
all visibility polygons for all vertices of the cathedral.
|
||||
|
||||
|
||||
<CENTER>
|
||||
Boundary Cathedral | total preprocessing time | total query time |
|
||||
-------------------------------|-----------------------------------------------------|-------------------------------|
|
||||
`Simple_polygon_visibility_2` | - | 0.38 |
|
||||
`Rotational_sweep_visibility_2` | - | 1.01 |
|
||||
`Triangular_expansion_visibility_2` | 0.01 | 0.06 |
|
||||
</CENTER>
|
||||
|
||||
The second table shows the same for the complete cathedral. The table does not report the time for `Simple_polygon_visibility_2`
|
||||
The second table shows the same for the complete cathedral.
|
||||
The table does not report the time for `Simple_polygon_visibility_2`
|
||||
as this algorithm can only handle simple polygons.
|
||||
|
||||
<CENTER>
|
||||
Complete Cathedral | total preprocessing time | total query time |
|
||||
-------------------------------|-----------------------------------------------------|-------------------------------|
|
||||
`Rotational_sweep_visibility_2` | - | 1.91 |
|
||||
`Triangular_expansion_visibility_2` | 0.01 | 0.04 |
|
||||
</CENTER>
|
||||
|
||||
Thus, in general we recommend to use `Triangular_expansion_visibility_2` even if the polygon is simple. The main advantage
|
||||
of the algorithm is its locality. After the triangle that contains the query point is located in the triangulation,
|
||||
the algorithm explores neighboring triangles, but only those that are actually seen.In this sense the algorithm can be considered as output sensitive.
|
||||
Note that the `Triangular_expansion_visibility_2` algorithm performs better on the full cathedral since the additional pillars block the view early in many cases.
|
||||
Thus, in general we recommend to use `Triangular_expansion_visibility_2` even if the polygon is simple.
|
||||
The main advantage of the algorithm is its locality.
|
||||
After the triangle that contains the query point is located in the triangulation,
|
||||
the algorithm explores neighboring triangles, but only those that are actually seen.
|
||||
In this sense the algorithm can be considered as output sensitive.
|
||||
Note that the `Triangular_expansion_visibility_2` algorithm performs better on the full
|
||||
cathedral since the additional pillars block the view early in many cases.
|
||||
However, if the simple polygon is rather convex (i.e., nearly all boundary is seen) or
|
||||
if only one (or very little) queries are required, using one of the algorithms that does not require preprocessing is advantageous.
|
||||
if only one (or very little) queries are required, using one of the algorithms that
|
||||
does not require preprocessing is advantageous.
|
||||
|
||||
|
||||
\section simple_polygon_visibility_example Example of Visibility in a Simple Polygon
|
||||
The following example shows how to obtain the regularized and non-regularized visibility regions.
|
||||
|
||||
\cgalFigureBegin{simple_example, simple_example.png}
|
||||
|
||||
The visibility region of \f$ q \f$ in a simple polygon: (1) non-regularized visibility; and (2) regularized visibility.
|
||||
\cgalFigureEnd
|
||||
\cgalExample{Visibility_2/simple_polygon_visibility_2.cpp}
|
||||
|
||||
\section general_polygon_example Example of Visibility in a Polygon with Holes
|
||||
The following example shows how to obtain the regularized visibility region using the model `Triangular_expansion_visibility_2`, see \cgalFigureRef{general_polygon}. The arrangement has six bounded faces and an unbounded face. The query point \f$ q \f$ is on a vertex. The red arrow denotes the halfedge \f$ \overrightarrow{pq} \f$, which also identifies the face in which the visibility region is computed.
|
||||
The following example shows how to obtain the regularized visibility region using the model
|
||||
`Triangular_expansion_visibility_2`, see \cgalFigureRef{general_polygon}.
|
||||
The arrangement has six bounded faces and an unbounded face. T
|
||||
he query point \f$ q \f$ is on a vertex.
|
||||
The red arrow denotes the halfedge \f$ \overrightarrow{pq} \f$,
|
||||
which also identifies the face in which the visibility region is computed.
|
||||
\cgalFigureBegin{general_polygon, general_polygon_example.png}
|
||||
The visibility region of \f$ q \f$ in a polygon with two holes.
|
||||
\cgalFigureEnd
|
||||
\cgalExample{Visibility_2/general_polygon_example.cpp}
|
||||
|
||||
\section implentation_history Implementation History
|
||||
\section implementation_history Implementation History
|
||||
|
||||
This package was first developed during Google Summer of Code 2013. Fancisc Bungju developed the Simple_polygon_visibility_2 class; Kan Huang developed the Rotational_sweep_visibility_2 class; and Michael Hemmer developed the Triangular_expansion_visibility_2 class.
|
||||
The former class, Simple_polygon_visibility_2, implements the algorithm presented by B. Joe and R.B. Simpson in 1987 \cite js-clvpa87. This algorithm is a linear time algorithm for simple polygons, fixing the errors in a previous algorithm presented by D.T. Lee in 1983.
|
||||
The second class, Rotational_sweep_visibility_2, implements the algorithm presented by T. Asano in 1985. This algorithm can be applied to polygons with holes with time complexity \f$ O(n\log n) \f$.
|
||||
The third class, Triangular_expansion_visibility_2, implements the algorithm presented by F. Bungju, et al.. This algorithm can be applied to polygons with holes with worst case running time \f$ O(n^2) \f$, but is extremely fast in practice.
|
||||
This package was first developed during Google Summer of Code 2013:
|
||||
Francisc Bungiu developed the `CGAL::Simple_polygon_visibility_2`,
|
||||
Kan Huang developed the `CGAL::Rotational_sweep_visibility_2`,
|
||||
and Michael Hemmer developed the `CGAL::Triangular_expansion_visibility_2`.
|
||||
|
||||
In Google Summer of Code 2014, Ning Xu became a developer for this package. He fixed bugs in the algorithm for simple polygons.
|
||||
During Google Summer of Code 2014 Ning Xu fixed a bug in `CGAL::Simple_polygon_visibility_2` and improved the testsuite.
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// `Preprocessed_rotational_sweep_visibility_2` | valid polygons with holes | \f$ O(n^2) \f$ time and \f$ O(n^2) \f$ space | \f$ O(n) \f$ time and \f$ O(n) \f$ space | Takao Asano, Tetsuo Asano etc \cite aaghi-vpsesp-85
|
||||
// `Preprocessed_rotational_sweep_visibility_2` | polygons with holes | \f$ O(n^2) \f$ time and \f$ O(n^2) \f$ space | \f$ O(n) \f$ time and \f$ O(n) \f$ space | Takao Asano, Tetsuo Asano etc \cite aaghi-vpsesp-85
|
||||
|
|
|
|||
|
|
@ -1,55 +1,66 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Triangular_expansion_visibility_2.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Triangular_expansion_visibility_2.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
// Define the used kernel and arrangement
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef Kernel::Segment_2 Segment_2;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
typedef Arrangement_2::Vertex_const_handle Vertex_const_handle;
|
||||
typedef Arrangement_2::Halfedge_const_handle Halfedge_const_handle;
|
||||
typedef Arrangement_2::Face_handle Face_handle;
|
||||
typedef CGAL::Triangular_expansion_visibility_2<Arrangement_2> TEV;
|
||||
int main() {
|
||||
Point_2 p1(1, 2), p2(12, 3), p3(19, -2), p4(12, 6), p5(14, 14), p6(9, 5);
|
||||
Point_2 h1(8,3), h2(10, 3), h3(8, 4), h4(10, 6), h5(11, 6), h6(11, 7);
|
||||
Segment_2 s[12];
|
||||
s[0] = Segment_2(p1, p2);
|
||||
s[1] = Segment_2(p2, p3);
|
||||
s[2] = Segment_2(p3, p4);
|
||||
s[3] = Segment_2(p4, p5);
|
||||
s[4] = Segment_2(p5, p6);
|
||||
s[5] = Segment_2(p6, p1);
|
||||
|
||||
s[6] = Segment_2(h1, h2);
|
||||
s[7] = Segment_2(h2, h3);
|
||||
s[8] = Segment_2(h3, h1);
|
||||
s[9] = Segment_2(h4, h5);
|
||||
s[10] = Segment_2(h5, h6);
|
||||
s[11] = Segment_2(h6, h4);
|
||||
// Define the used visibility class
|
||||
typedef CGAL::Triangular_expansion_visibility_2<Arrangement_2> TEV;
|
||||
|
||||
int main() {
|
||||
// Defining the input geometry
|
||||
Point_2 p1(1,2), p2(12, 3), p3(19,-2), p4(12,6), p5(14,14), p6( 9,5);
|
||||
Point_2 h1(8,3), h2(10, 3), h3( 8, 4), h4(10,6), h5(11, 6), h6(11,7);
|
||||
std::vector<Segment_2> segments;
|
||||
segments.push_back(Segment_2(p1,p2));
|
||||
segments.push_back(Segment_2(p2,p3));
|
||||
segments.push_back(Segment_2(p3,p4));
|
||||
segments.push_back(Segment_2(p4,p5));
|
||||
segments.push_back(Segment_2(p5,p6));
|
||||
segments.push_back(Segment_2(p6,p1));
|
||||
|
||||
segments.push_back(Segment_2(h1,h2));
|
||||
segments.push_back(Segment_2(h2,h3));
|
||||
segments.push_back(Segment_2(h3,h1));
|
||||
segments.push_back(Segment_2(h4,h5));
|
||||
segments.push_back(Segment_2(h5,h6));
|
||||
segments.push_back(Segment_2(h6,h4));
|
||||
|
||||
// insert geometry into the arrangement
|
||||
Arrangement_2 env;
|
||||
CGAL::insert_non_intersecting_curves(env, &s[0], &s[12]);
|
||||
//find the halfedge whose target is the query point.
|
||||
CGAL::insert_non_intersecting_curves(env,segments.begin(),segments.end());
|
||||
|
||||
//Find the halfedge whose target is the query point.
|
||||
//(usually you may know that already by other means)
|
||||
Point_2 query_point = p4;
|
||||
Halfedge_const_handle he = env.halfedges_begin();
|
||||
while (he->source()->point() != p3 || he->target()->point() != p4)
|
||||
he++;
|
||||
|
||||
//visibility query
|
||||
Arrangement_2 output_arr;
|
||||
TEV tev(env);
|
||||
Face_handle fh = tev.compute_visibility(query_point, he, output_arr);
|
||||
|
||||
//print out the visibility region.
|
||||
std::cout << "Regularized visibility region of q has "
|
||||
<< output_arr.number_of_edges()
|
||||
<< " edges." << std::endl;
|
||||
|
||||
std::cout << "Boundary edges of the visibility region:" << std::endl;
|
||||
Arrangement_2::Ccb_halfedge_circulator curr = fh->outer_ccb();
|
||||
std::cout << "Traverse the face of the visibility region." << std::endl;
|
||||
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]"<< std::endl;
|
||||
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]" << std::endl;
|
||||
while (++curr != fh->outer_ccb())
|
||||
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]"<< std::endl;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,43 +1,48 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Simple_polygon_visibility_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Simple_polygon_visibility_2.h>
|
||||
#include <CGAL/Arr_naive_point_location.h>
|
||||
#include <istream>
|
||||
#include <vector>
|
||||
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef Kernel::Segment_2 Segment_2;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
typedef Arrangement_2::Edge_const_iterator Edge_const_iterator;
|
||||
typedef Arrangement_2::Face_handle Face_handle;
|
||||
typedef Arrangement_2::Edge_const_iterator Edge_const_iterator;
|
||||
typedef Arrangement_2::Ccb_halfedge_circulator Ccb_halfedge_circulator;
|
||||
typedef CGAL::Simple_polygon_visibility_2<Arrangement_2, CGAL::Tag_false>
|
||||
NSPV;
|
||||
typedef CGAL::Simple_polygon_visibility_2<Arrangement_2, CGAL::Tag_true>
|
||||
RSPV;
|
||||
|
||||
|
||||
int main() {
|
||||
//create environment
|
||||
Point_2 p1(0, 4), p2(0, 0), p3(3, 2), p4(4, 0), p5(4, 4), p6(1, 2);
|
||||
Segment_2 s[6];
|
||||
s[0] = Segment_2(p1, p2);
|
||||
s[1] = Segment_2(p2, p3);
|
||||
s[2] = Segment_2(p3, p4);
|
||||
s[3] = Segment_2(p4, p5);
|
||||
s[4] = Segment_2(p5, p6);
|
||||
s[5] = Segment_2(p6, p1);
|
||||
Point_2 p1(0,4), p2(0,0), p3(3,2), p4(4,0), p5(4,4), p6(1,2);
|
||||
std::vector<Segment_2> segments;
|
||||
segments.push_back(Segment_2(p1, p2));
|
||||
segments.push_back(Segment_2(p2, p3));
|
||||
segments.push_back(Segment_2(p3, p4));
|
||||
segments.push_back(Segment_2(p4, p5));
|
||||
segments.push_back(Segment_2(p5, p6));
|
||||
segments.push_back(Segment_2(p6, p1));
|
||||
|
||||
Arrangement_2 env;
|
||||
CGAL::insert_non_intersecting_curves(env, &s[0], &s[6]);
|
||||
//locate the query point in the arrangement
|
||||
CGAL::insert_non_intersecting_curves(env,segments.begin(),segments.end());
|
||||
|
||||
// find the face of the query point
|
||||
// (usually you may know that by other means)
|
||||
Point_2 q(0.5, 2);
|
||||
Arrangement_2::Face_const_handle * face;
|
||||
CGAL::Arr_naive_point_location<Arrangement_2> pl(env);
|
||||
typename CGAL::Arr_point_location_result<Arrangement_2>::Type obj = pl.locate(q);
|
||||
// The query point locates in the interior of a face
|
||||
face = boost::get<Arrangement_2::Face_const_handle> (&obj);
|
||||
//visibility query
|
||||
|
||||
// compute non regularized visibility area
|
||||
// Define visibiliy object type that computes non-regularized visibility area
|
||||
typedef CGAL::Simple_polygon_visibility_2<Arrangement_2, CGAL::Tag_false> NSPV;
|
||||
Arrangement_2 non_regular_output;
|
||||
NSPV non_regular_visibility(env);
|
||||
Face_handle non_regular_fh = non_regular_visibility.compute_visibility(q, *face, non_regular_output);
|
||||
|
|
@ -46,6 +51,10 @@ int main() {
|
|||
<< " edges:" << std::endl;
|
||||
for (Edge_const_iterator eit = non_regular_output.edges_begin(); eit != non_regular_output.edges_end(); ++eit)
|
||||
std::cout << "[" << eit->source()->point() << " -> " << eit->target()->point() << "]" << std::endl;
|
||||
|
||||
// compute non regularized visibility area
|
||||
// Define visibiliy object type that computes regularized visibility area
|
||||
typedef CGAL::Simple_polygon_visibility_2<Arrangement_2, CGAL::Tag_true> RSPV;
|
||||
Arrangement_2 regular_output;
|
||||
RSPV regular_visibility(env);
|
||||
Face_handle regular_fh = regular_visibility.compute_visibility(q, *face, regular_output);
|
||||
|
|
@ -55,12 +64,7 @@ int main() {
|
|||
<< " edges:" << std::endl;
|
||||
for (Edge_const_iterator eit = regular_output.edges_begin(); eit != regular_output.edges_end(); ++eit)
|
||||
std::cout << "[" << eit->source()->point() << " -> " << eit->target()->point() << "]" << std::endl;
|
||||
|
||||
//For a regular face, we can also get its whole boundary by traversing its outer CCB.
|
||||
std::cout << "Traverse the face of the regularized visibility region:" << std::endl;
|
||||
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]" << std::endl;
|
||||
while (++curr != regular_fh->outer_ccb())
|
||||
std::cout << "[" << curr->source()->point() << " -> " << curr->target()->point() << "]" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ using namespace std;
|
|||
namespace CGAL {
|
||||
|
||||
template < class Arrangement_2_,
|
||||
class RegularizationTag = CGAL::Tag_true,
|
||||
class ConcurrencyTag = CGAL::Parallel_tag >
|
||||
class RegularizationCategory = CGAL::Tag_true,
|
||||
class ConcurrencyCategory = CGAL::Parallel_tag >
|
||||
class Parallel_rotational_sweep_visibility_2
|
||||
{
|
||||
|
||||
|
|
@ -76,9 +76,9 @@ public:
|
|||
typedef typename Geometry_traits_2::FT Number_type;
|
||||
typedef typename Geometry_traits_2::Object_2 Object_2;
|
||||
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef CGAL::Tag_true Supports_general_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
typedef CGAL::Tag_true Supports_general_polygon_category;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
||||
|
||||
//private data types declaration
|
||||
typedef Ccb_halfedge_const_circulator Circulator;
|
||||
|
|
@ -835,7 +835,7 @@ private:
|
|||
incident.push_back( std::make_pair( vs[es[i].source_index()].alias_index(), i ) );
|
||||
incident.push_back( std::make_pair( vs[es[i].target_index()].alias_index(), i ) );
|
||||
}
|
||||
sort_incident( ConcurrencyTag() );
|
||||
sort_incident( ConcurrencyCategory() );
|
||||
|
||||
int i = 0;
|
||||
while ( i < incident.size() ) {
|
||||
|
|
@ -1042,9 +1042,9 @@ private:
|
|||
if ( query_type != FACE_QUERY )
|
||||
add_box();
|
||||
|
||||
init_quadrant_parallel( ConcurrencyTag() );
|
||||
init_quadrant_parallel( ConcurrencyCategory() );
|
||||
|
||||
init_orientation_parallel( ConcurrencyTag() );
|
||||
init_orientation_parallel( ConcurrencyCategory() );
|
||||
|
||||
good_vdx.reserve( vs.size() );
|
||||
for ( int i = 0; i < vs.size(); i++ )
|
||||
|
|
@ -1052,7 +1052,7 @@ private:
|
|||
|
||||
// sort vertices by their polar angle
|
||||
compute_shifted_source();
|
||||
sort_vertices( ConcurrencyTag() );
|
||||
sort_vertices( ConcurrencyCategory() );
|
||||
|
||||
// Build the reverse indexes
|
||||
for ( int i = 0; i < good_vdx.size(); i++ ) {
|
||||
|
|
@ -1139,7 +1139,7 @@ private:
|
|||
* There is a bug here. When I verified the intersection parallelly,
|
||||
* the program crashed. Thus, I use the Sequential_tag here.
|
||||
* I will solve this one later.
|
||||
do_intersect_parallel( dp, is, ConcurrencyTag() );
|
||||
do_intersect_parallel( dp, is, ConcurrencyCategory() );
|
||||
*/
|
||||
do_intersect_parallel( dp, is, CGAL::Sequential_tag() );
|
||||
for ( int i = 0; i < es.size(); i++ ) {
|
||||
|
|
@ -1148,7 +1148,7 @@ private:
|
|||
}
|
||||
|
||||
// initialize the first cone
|
||||
int step = default_cone_size( ConcurrencyTag() );
|
||||
int step = default_cone_size( ConcurrencyCategory() );
|
||||
int cone_base = 0;
|
||||
int cone_next = cone_base + step;
|
||||
if ( cone_next + 16 >= vs.size() )
|
||||
|
|
@ -1357,7 +1357,7 @@ private:
|
|||
sub_regions.push_back( Sub_region( pts_num ) );
|
||||
}
|
||||
|
||||
compute_visibility_parallel( ConcurrencyTag() );
|
||||
compute_visibility_parallel( ConcurrencyCategory() );
|
||||
|
||||
merge_result();
|
||||
|
||||
|
|
@ -1544,7 +1544,7 @@ public:
|
|||
< Parallel_rotational_sweep_visibility_2 >
|
||||
( geom_traits, query_pt, polygon_out, arr_out );
|
||||
|
||||
conditional_regularize( arr_out, Regularization_tag() );
|
||||
conditional_regularize( arr_out, Regularization_category() );
|
||||
|
||||
if ( arr_out.faces_begin()->is_unbounded() )
|
||||
return ++arr_out.faces_begin();
|
||||
|
|
@ -1569,7 +1569,7 @@ public:
|
|||
< Parallel_rotational_sweep_visibility_2 >
|
||||
( geom_traits, query_pt, polygon, arr_out );
|
||||
|
||||
conditional_regularize( arr_out, Regularization_tag() );
|
||||
conditional_regularize( arr_out, Regularization_category() );
|
||||
|
||||
if ( arr_out.faces_begin()->is_unbounded() )
|
||||
return ++arr_out.faces_begin();
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@
|
|||
namespace CGAL {
|
||||
|
||||
template < class Arrangement_2_,
|
||||
class RegularizationTag = CGAL::Tag_true,
|
||||
class ConcurrencyTag = CGAL::Parallel_tag >
|
||||
class RegularizationCategory = CGAL::Tag_true,
|
||||
class ConcurrencyCategory = CGAL::Parallel_tag >
|
||||
class Parallel_triangular_expansion_visibility_2
|
||||
{
|
||||
typedef typename Arrangement_2_::Geometry_traits_2 Geometry_traits_2;
|
||||
|
|
@ -65,10 +65,10 @@ public:
|
|||
typedef typename Geometry_traits_2::Object_2 Object_2;
|
||||
|
||||
// TODO
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
|
||||
typedef CGAL::Tag_true Supports_general_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_general_polygon_category;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
||||
|
||||
private:
|
||||
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
|
||||
|
|
@ -450,7 +450,7 @@ private:
|
|||
|
||||
Result_container results;
|
||||
|
||||
compute_visibility_parallel( edges, results, ConcurrencyTag() );
|
||||
compute_visibility_parallel( edges, results, ConcurrencyCategory() );
|
||||
|
||||
// Generate results
|
||||
std::vector<Segment_2> segs;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
Preprocessed_visibility_2() : p_arr(NULL) {};
|
||||
|
||||
/*! Constructor given an arrangement and the Regularization tag. */
|
||||
Preprocessed_visibility_2(Input_Arrangement_2& arr/*, Regularization_tag r_t*/): p_arr(&arr) {};
|
||||
Preprocessed_visibility_2(Input_Arrangement_2& arr/*, Regularization_category r_t*/): p_arr(&arr) {};
|
||||
|
||||
bool is_attached() {
|
||||
return (p_arr != NULL);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template<class Arrangement_2_ , class RegularizationTag = CGAL::Tag_true >
|
||||
template<class Arrangement_2_ , class RegularizationCategory = CGAL::Tag_true >
|
||||
class Rotational_sweep_visibility_2 {
|
||||
public:
|
||||
typedef Arrangement_2_ Arrangement_2;
|
||||
|
|
@ -55,9 +55,9 @@ public:
|
|||
typedef typename Geometry_traits_2::FT Number_type;
|
||||
typedef typename Geometry_traits_2::Object_2 Object_2;
|
||||
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef CGAL::Tag_true Supports_general_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
typedef CGAL::Tag_true Supports_general_polygon_category;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
||||
|
||||
private:
|
||||
typedef std::vector<Point_2> Points;
|
||||
|
|
@ -357,7 +357,7 @@ public:
|
|||
(geom_traits, q, polygon_out, arr_out);
|
||||
}
|
||||
|
||||
conditional_regularize(arr_out, Regularization_tag());
|
||||
conditional_regularize(arr_out, Regularization_category());
|
||||
|
||||
if (arr_out.faces_begin()->is_unbounded())
|
||||
return ++arr_out.faces_begin();
|
||||
|
|
@ -376,7 +376,7 @@ public:
|
|||
|
||||
visibility_region_impl(f, q);
|
||||
Visibility_2::report_while_handling_needles<Rotational_sweep_visibility_2>(geom_traits, q, polygon, arr_out);
|
||||
conditional_regularize(arr_out, Regularization_tag());
|
||||
conditional_regularize(arr_out, Regularization_category());
|
||||
if (arr_out.faces_begin()->is_unbounded())
|
||||
return ++arr_out.faces_begin();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template<class Arrangement_2_, class RegularizationTag = CGAL::Tag_true>
|
||||
template<class Arrangement_2_, class RegularizationCategory = CGAL::Tag_true>
|
||||
class Simple_polygon_visibility_2 {
|
||||
|
||||
public:
|
||||
|
|
@ -62,9 +62,9 @@ public:
|
|||
typedef typename Geometry_traits_2::FT Number_type;
|
||||
typedef typename Geometry_traits_2::Object_2 Object_2;
|
||||
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef CGAL::Tag_false Supports_general_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
typedef CGAL::Tag_false Supports_general_polygon_category;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
||||
|
||||
Simple_polygon_visibility_2() : p_arr(NULL), geom_traits(NULL) {};
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ public:
|
|||
|
||||
CGAL_precondition(out_arr.number_of_isolated_vertices() == 0);
|
||||
CGAL_precondition(s.size() == 0);
|
||||
conditional_regularize(out_arr, Regularization_tag());
|
||||
conditional_regularize(out_arr, Regularization_category());
|
||||
vertices.clear();
|
||||
if (out_arr.faces_begin()->is_unbounded()) {
|
||||
return ++out_arr.faces_begin();
|
||||
|
|
@ -237,7 +237,7 @@ public:
|
|||
out_arr);
|
||||
CGAL_precondition(out_arr.number_of_isolated_vertices() == 0);
|
||||
CGAL_precondition(s.size() == 0);
|
||||
conditional_regularize(out_arr, Regularization_tag());
|
||||
conditional_regularize(out_arr, Regularization_category());
|
||||
vertices.clear();
|
||||
if (out_arr.faces_begin()->is_unbounded()) {
|
||||
return ++out_arr.faces_begin();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
template<class Arrangement_2_ , class RegularizationTag = CGAL::Tag_true >
|
||||
template<class Arrangement_2_ , class RegularizationCategory = CGAL::Tag_true >
|
||||
class Triangular_expansion_visibility_2 {
|
||||
typedef typename Arrangement_2_::Geometry_traits_2 Geometry_traits_2;
|
||||
typedef typename Geometry_traits_2::Kernel K;
|
||||
|
|
@ -55,10 +55,10 @@ public:
|
|||
typedef typename Geometry_traits_2::Object_2 Object_2;
|
||||
|
||||
// TODO
|
||||
typedef RegularizationTag Regularization_tag;
|
||||
typedef RegularizationCategory Regularization_category;
|
||||
|
||||
typedef CGAL::Tag_true Supports_general_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_tag;
|
||||
typedef CGAL::Tag_true Supports_general_polygon_category;
|
||||
typedef CGAL::Tag_true Supports_simple_polygon_category;
|
||||
|
||||
private:
|
||||
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
|
||||
|
|
@ -303,7 +303,7 @@ public:
|
|||
if(ro != CGAL::CLOCKWISE && lo != CGAL::COUNTERCLOCKWISE){
|
||||
*oit++ = nvh->point();
|
||||
}
|
||||
if(!Regularization_tag::value){
|
||||
if(!Regularization_category::value){
|
||||
assert(!(ro == CGAL::COLLINEAR && lo == CGAL::COLLINEAR));
|
||||
// we have to check whether a needle starts here.
|
||||
if(p_cdt->is_constrained(le) && !p_cdt->is_constrained(re) && ro == CGAL::COLLINEAR)
|
||||
|
|
|
|||
|
|
@ -145,11 +145,11 @@ void test_model_methods() {
|
|||
typedef typename Arrangement_2::Point_2 Point_2;
|
||||
typedef typename Arrangement_2::Face_handle Face_handle;
|
||||
typedef typename Arrangement_2::Halfedge_handle Halfedge_handle;
|
||||
typedef typename Visibility_2::Regularization_tag Regularization_tag;
|
||||
typedef typename Visibility_2::Supports_general_polygon_tag
|
||||
Supports_general_polygon_tag;
|
||||
typedef typename Visibility_2::Supports_simple_polygon_tag
|
||||
Supports_simple_polygon_tag;
|
||||
typedef typename Visibility_2::Regularization_category Regularization_category;
|
||||
typedef typename Visibility_2::Supports_general_polygon_category
|
||||
Supports_general_polygon_category;
|
||||
typedef typename Visibility_2::Supports_simple_polygon_category
|
||||
Supports_simple_polygon_category;
|
||||
typedef typename Arrangement_2::Geometry_traits_2::Segment_2
|
||||
Segment_2;
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ bool run_test_case_from_file(Visibility_2 visibility, std::ifstream &input) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(Visibility_2::Regularization_tag::value){
|
||||
if(Visibility_2::Regularization_category::value){
|
||||
regularize(arr_correct_out);
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ void run_tests(int case_number_simple, int case_number_non_simple) {
|
|||
|
||||
Visibility_2 visibility;
|
||||
bool one_failed = false;
|
||||
if (Visibility_2::Supports_simple_polygon_tag::value
|
||||
if (Visibility_2::Supports_simple_polygon_category::value
|
||||
&& case_number_simple >= 1) {
|
||||
int cnt = 0;
|
||||
int cnt_passed = 0;
|
||||
|
|
@ -462,7 +462,7 @@ void run_tests(int case_number_simple, int case_number_non_simple) {
|
|||
}
|
||||
std::cout << ")" << std::endl;
|
||||
}
|
||||
if (Visibility_2::Supports_general_polygon_tag::value
|
||||
if (Visibility_2::Supports_general_polygon_category::value
|
||||
&& case_number_non_simple >= 1) {
|
||||
|
||||
int cnt = 0;
|
||||
|
|
@ -953,16 +953,16 @@ void simple_benchmark(Visibility_2_fst &visibility_fst,
|
|||
typedef typename Geometry_traits_2::Point_2 Point_2;
|
||||
typedef typename Geometry_traits_2::Segment_2 Segment_2;
|
||||
|
||||
assert(Visibility_2_fst::Regularization_tag::value
|
||||
== Visibility_2_snd::Regularization_tag::value);
|
||||
assert(Visibility_2_fst::Regularization_category::value
|
||||
== Visibility_2_snd::Regularization_category::value);
|
||||
|
||||
Arrangement_2 arr;
|
||||
create_arrangement_from_env_file<Arrangement_2>(arr, input);
|
||||
|
||||
int query_cnt(0);
|
||||
double qtime1(0), qtime2(0), ptime1(0), ptime2(0);
|
||||
if (Visibility_2_fst::Supports_general_polygon_tag::value
|
||||
&& Visibility_2_snd::Supports_general_polygon_tag::value) {
|
||||
if (Visibility_2_fst::Supports_general_polygon_category::value
|
||||
&& Visibility_2_snd::Supports_general_polygon_category::value) {
|
||||
|
||||
Face_const_iterator fit;
|
||||
Timer timer;
|
||||
|
|
@ -1136,7 +1136,7 @@ void pure_benchmark( Visibility_2 &visibility,
|
|||
|
||||
int query_cnt(0);
|
||||
double qtime(0), ptime(0);
|
||||
if (Visibility_2::Supports_general_polygon_tag::value) {
|
||||
if (Visibility_2::Supports_general_polygon_category::value) {
|
||||
|
||||
Face_const_iterator fit;
|
||||
Timer timer;
|
||||
|
|
@ -1179,7 +1179,7 @@ void pure_benchmark( Visibility_2 &visibility,
|
|||
|
||||
// std::cout << "NAME TAG PreProTime NQueries TimeQueries TotalTime QAVE TAVE" << std::endl;
|
||||
std::cout << " " << visibility.name()
|
||||
<< " " << Visibility_2::Regularization_tag::value
|
||||
<< " " << Visibility_2::Regularization_category::value
|
||||
<< " " << ptime
|
||||
<< " " << query_cnt
|
||||
<< " " << qtime
|
||||
|
|
@ -1312,7 +1312,7 @@ void test_star_shape(Visibility_2 &visibility,
|
|||
std::cout << "Input arrangement has: "
|
||||
<< GREEN << arr.number_of_faces()-1 << RESET
|
||||
<< " faces." << std::endl;
|
||||
if (Visibility_2::Supports_general_polygon_tag::value) {
|
||||
if (Visibility_2::Supports_general_polygon_category::value) {
|
||||
int cnt(1);
|
||||
Face_const_iterator fit;
|
||||
for (fit = arr.faces_begin() ; fit != arr.faces_end() ; fit++) {
|
||||
|
|
|
|||
|
|
@ -51,17 +51,17 @@ void deploy_pure_benchmark(const CGAL::Query_choice& qchoice, std::ifstream& inp
|
|||
}
|
||||
|
||||
|
||||
template <class Regularization_tag>
|
||||
template <class Regularization_category>
|
||||
void benchmark_one_class(std::string name, const CGAL::Query_choice& qchoice, std::string input_arr_file) {
|
||||
std::ifstream input(input_arr_file.c_str());
|
||||
if (name == "S")
|
||||
deploy_pure_benchmark<CGAL::Simple_polygon_visibility_2<Arrangement_2, Regularization_tag> > (qchoice, input);
|
||||
deploy_pure_benchmark<CGAL::Simple_polygon_visibility_2<Arrangement_2, Regularization_category> > (qchoice, input);
|
||||
if (name == "T")
|
||||
deploy_pure_benchmark<CGAL::Triangular_expansion_visibility_2<Arrangement_2, Regularization_tag> > (qchoice, input);
|
||||
deploy_pure_benchmark<CGAL::Triangular_expansion_visibility_2<Arrangement_2, Regularization_category> > (qchoice, input);
|
||||
if (name == "R")
|
||||
deploy_pure_benchmark<CGAL::Rotational_sweep_visibility_2<Arrangement_2, Regularization_tag> > (qchoice, input);
|
||||
deploy_pure_benchmark<CGAL::Rotational_sweep_visibility_2<Arrangement_2, Regularization_category> > (qchoice, input);
|
||||
if (name == "PR")
|
||||
deploy_pure_benchmark<CGAL::Parallel_rotational_sweep_visibility_2<Arrangement_2, Regularization_tag, CGAL::Parallel_tag> > (qchoice, input);
|
||||
deploy_pure_benchmark<CGAL::Parallel_rotational_sweep_visibility_2<Arrangement_2, Regularization_category, CGAL::Parallel_tag> > (qchoice, input);
|
||||
}
|
||||
|
||||
void print_usage() {
|
||||
|
|
|
|||
|
|
@ -52,32 +52,32 @@ void deploy_benchmark(CGAL::Query_choice& qchoice, std::ifstream& input) {
|
|||
(v1, v2, qchoice, input);
|
||||
}
|
||||
|
||||
template <class Visibility_fst, class Regularization_tag>
|
||||
template <class Visibility_fst, class Regularization_category>
|
||||
void define_snd_class(std::string name2, CGAL::Query_choice& qchoice, std::ifstream& input){
|
||||
if (name2 == "S")
|
||||
deploy_benchmark<Visibility_fst, CGAL::Simple_polygon_visibility_2<Arrangement_2, Regularization_tag> >
|
||||
deploy_benchmark<Visibility_fst, CGAL::Simple_polygon_visibility_2<Arrangement_2, Regularization_category> >
|
||||
(qchoice, input);
|
||||
if (name2 == "T")
|
||||
deploy_benchmark<Visibility_fst, CGAL::Triangular_expansion_visibility_2<Arrangement_2, Regularization_tag> >
|
||||
deploy_benchmark<Visibility_fst, CGAL::Triangular_expansion_visibility_2<Arrangement_2, Regularization_category> >
|
||||
(qchoice, input);
|
||||
if (name2 == "R")
|
||||
deploy_benchmark<Visibility_fst, CGAL::Rotational_sweep_visibility_2<Arrangement_2, Regularization_tag> >
|
||||
deploy_benchmark<Visibility_fst, CGAL::Rotational_sweep_visibility_2<Arrangement_2, Regularization_category> >
|
||||
(qchoice, input);
|
||||
if (name2 == "PR")
|
||||
deploy_benchmark<Visibility_fst, CGAL::Parallel_rotational_sweep_visibility_2<Arrangement_2, Regularization_tag, CGAL::Parallel_tag> >
|
||||
deploy_benchmark<Visibility_fst, CGAL::Parallel_rotational_sweep_visibility_2<Arrangement_2, Regularization_category, CGAL::Parallel_tag> >
|
||||
(qchoice, input);
|
||||
}
|
||||
|
||||
template <class Regularization_tag>
|
||||
template <class Regularization_category>
|
||||
void benchmark_two_classes(std::string name1, std::string name2, CGAL::Query_choice& qchoice, std::ifstream& input) {
|
||||
if (name1 == "S")
|
||||
define_snd_class<CGAL::Simple_polygon_visibility_2<Arrangement_2, Regularization_tag>, Regularization_tag> (name2, qchoice, input);
|
||||
define_snd_class<CGAL::Simple_polygon_visibility_2<Arrangement_2, Regularization_category>, Regularization_category> (name2, qchoice, input);
|
||||
if (name1 == "T")
|
||||
define_snd_class<CGAL::Triangular_expansion_visibility_2<Arrangement_2, Regularization_tag>, Regularization_tag> (name2, qchoice, input);
|
||||
define_snd_class<CGAL::Triangular_expansion_visibility_2<Arrangement_2, Regularization_category>, Regularization_category> (name2, qchoice, input);
|
||||
if (name1 == "R")
|
||||
define_snd_class<CGAL::Rotational_sweep_visibility_2<Arrangement_2, Regularization_tag>, Regularization_tag> (name2, qchoice, input);
|
||||
define_snd_class<CGAL::Rotational_sweep_visibility_2<Arrangement_2, Regularization_category>, Regularization_category> (name2, qchoice, input);
|
||||
if (name1 == "PR")
|
||||
define_snd_class<CGAL::Parallel_rotational_sweep_visibility_2<Arrangement_2, Regularization_tag, CGAL::Parallel_tag>, Regularization_tag> (name2, qchoice, input);
|
||||
define_snd_class<CGAL::Parallel_rotational_sweep_visibility_2<Arrangement_2, Regularization_category, CGAL::Parallel_tag>, Regularization_category> (name2, qchoice, input);
|
||||
}
|
||||
|
||||
void print_usage() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue