Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
887da91
Make x monotone curve 2 a template parameter of polycurve basic traits
sgiraudot Mar 17, 2021
4445460
First version of lightweight polyline traits + example
sgiraudot Mar 17, 2021
7237ec8
Create Construct_curve_2 functor and use it in example
sgiraudot Mar 17, 2021
31a2c9b
Handle polygon conversion with lightweight traits
sgiraudot Mar 18, 2021
e35aea8
Rebase
sgiraudot Mar 18, 2021
2aaa0cd
First functional version of line cache
sgiraudot Mar 29, 2021
bfbd08f
Clean up lightweight polyline class
sgiraudot Mar 30, 2021
e90da1f
Use indices and separated containers instead of zip iterator
sgiraudot Mar 30, 2021
721d065
Some clean up
sgiraudot Mar 31, 2021
b9141a4
Do not use sweep to insert PWH
sgiraudot Mar 31, 2021
41246df
Use unsigned indices
sgiraudot Mar 31, 2021
65d08f8
Document and clean up
sgiraudot Mar 31, 2021
7caf6b3
Add missing return statements
sgiraudot Apr 1, 2021
0fcb807
Use lightweight traits as default in free BSO functions
sgiraudot Apr 1, 2021
15dbc92
Fix overlap orientation
sgiraudot Apr 8, 2021
83a7235
Allow chosing sweep or not for interting PWH in GPS
sgiraudot Apr 8, 2021
0329f82
Fix std::function type using const ref and no value
sgiraudot Apr 8, 2021
46f7e55
Replace lightweight by caching
sgiraudot Apr 14, 2021
182b566
Distinguish types of Curve_2 / X_monotone_curve_2 and directly insert…
sgiraudot Apr 14, 2021
09fc6cb
Use traits reference and do not construct kernel from scratch + minor…
sgiraudot Apr 14, 2021
5f2448b
Fix Single const iterator
sgiraudot Apr 20, 2021
f8df8cd
Never store refs to traits in polylines
sgiraudot Apr 20, 2021
7ad01c0
Fix style + cleaning
sgiraudot Apr 20, 2021
1fbcaaa
Cleaned up Arr_polyline_traits_2 doc; Introduced Arr_caching_polyline…
efifogel Apr 28, 2021
00dc92c
Added polylines_caching.cpp
efifogel Apr 28, 2021
5875155
Enhanced
efifogel Apr 28, 2021
1e902e4
Added support for testing the caching polyline traits
efifogel Apr 29, 2021
f5313a5
Use consistent naming
sgiraudot Apr 29, 2021
72b164f
Define constrcut x monotone curve 2 in caching traits
sgiraudot Apr 29, 2021
9763ddf
Fix concepts Construct_curve_2/x_monotone_curve_2
sgiraudot Apr 29, 2021
e6b86cd
Add Approximate_2 functor to caching polyline subtraits
sgiraudot Apr 29, 2021
85fd419
Add comment about hacky optimization
sgiraudot Apr 29, 2021
b0d08a4
Added a constructore of an x-monotone polyline from a range of points
efifogel May 3, 2021
17a5f91
Fixed the test of the caching-polyline traits to retain the points th…
efifogel May 3, 2021
5f021fe
Small textual fixes related to "comprise"
efifogel May 3, 2021
5823911
Added precondintion
efifogel May 3, 2021
5fdadbc
Added missing documentation
efifogel May 3, 2021
84d42b8
Fixed types of Curve_2 and X_monotone_curve_2
efifogel May 3, 2021
13a5109
Small fixes
efifogel May 3, 2021
fa36a32
Fixed testing of caching polyline traits
efifogel May 11, 2021
1afc180
Fix default value of duplicate_first
sgiraudot May 11, 2021
a7d0a4f
Fix Split_2
sgiraudot May 11, 2021
de43b6f
Disable some tests and clean error messages
sgiraudot May 17, 2021
b7412a9
Fix merge category + add missing precondition in Split_2
sgiraudot May 17, 2021
e7728dc
Disable assertions test for caching polylines
sgiraudot May 17, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/// \ingroup PkgArrangementOnSurface2Macros
/// @{
/*!
* If the macro is set to one, then \f$x\f$-monotone curves are always
* directed from left-to-right.
*/
#define CGAL_ALWAYS_LEFT_TO_RIGHT
/// @}

namespace CGAL {

/*! \ingroup PkgArrangementOnSurface2TraitsClasses
*
* The traits class `Arr_caching_polyline_traits_2` handles piecewise linear
* curves, commonly referred to as polylines. Each polyline is a chain of
* segments, where each two neighboring segments in the chain share a common
* endpoint; that is, the polyline is continuous. Furthermore, the target of the
* \f$i\f$th segement of a polyline has to coincide with the source of the
* \f$i+1\f$st segment; that is, the polyline has to be \a well-oriented.
*
* This traits class template serves as an alternative to the more general
* traits class template `Arr_polyline_traits_2<SubcurveTraits_2>`, which
* handles polylines as well. Use this alternative when you need to construct
* many polylines and every polyline comprises many points. Typically
* (depending on the substituted Kernel) the geometric objects that compose the
* polylines (e.g., points) are reference counted, which implies that a copy of
* a single point amounts to copying a small piece of data (a handle). However,
* when a polyline is constructed, split, or subdivided into \f$x\f$-monotone
* pieces, a large number of points might be copied, which yields with a costly
* operation. This traits class template uses an internal type to represent
* polylines, which in turn uses an internal type to represent lines and points
* that compose polylines. Polylines in the internal representation share the
* geometric data; thus, only one copy of the geometric objects that compose
* several polylines reside in memory. Only a shallow copy is performed to
* carry out each one of the operations above.
*
* CAUTION: If you construct polylines using this traits class template and
* then insert the polylines into an arrangement, for instance, you must retain
* the polyline in memory as long as the arrangement is in memory.
*
* \tparam Kernel a type that represents a geometric kernel. The number type
* used by the substituted kernel should support exact rational arithmetic (that
* is, the number type should support the arithmetic operations \f$ +\f$, \f$
* -\f$, \f$ \times\f$ and \f$ \div\f$ carried out without loss of precision),
* in order to avoid robustness problems, although other inexact number types
* could be used at the user's own risk.
*
* \tparam Range a type that represents a valid range of points.
*
* A polyline that comprises \f$n > 0\f$ segments has \f$ n+1 \f$ points, and
* they are represented as objects of type `Kernel::Point_2`. Since the
* notion of a \a vertex is reserved to 0-dimensional elements of an
* arrangement, we use, in this context, the notion of \a points in order to
* refer to the vertices of a polyline. For example, an arrangement induced by a
* single non-self intersecting polyline has exactly two vertices regardless of
* the number of points.
*
* \cgalModels `ArrangementTraits_2`
* \cgalModels `ArrangementDirectionalXMonotoneTraits_2`
* \cgalModels `ArrangementConstructXMonotoneCurveTraits_2`
* \cgalModels `ArrangementApproximateTraits_2`
*
* \sa `Arr_polyline_traits_2<SubcurveTraits_2>`
*/

template <typename Kernel, typename Range>
class Arr_caching_polyline_traits_2 :
public Arr_polycurve_traits_2<SegmentTraits_2> {
public:

/// \name Types
/// @{
/*!
*/
typedef typename Kernel::Point_2 Point_2;

/*!
*/
typedef unspecified_type X_monotone_curve_2;

/*!
*/
typedef unspecified_type Curve_2;
/// @}

/*! Construction functor of a polyline. Its `operator()` is oveloaded to
* support various input types.
*/
class Construct_curve_2 {
public:
/// \name Operations
/// @{

/*! Obtain a polyline connecting the two given endpoints.
* \param p the first point.
* \param q the second point.
* \pre `p` and `q` are distinct.
* \return a polyline that comprises a single segment connecting `p` and
* `q`.
*/
Curve_2 operator()(const Point_2& p, const Point_2& q) const;

/*! Construct a well-oriented polyline from a range of points.
*
* \param range a range of points
* \param duplicate_first indicates whether the first point should be
* duplicated to construct a closed polyline.
* \pre contains no duplicated points.
* \return a polyline that comprises the given range of points.
*/
template <typename Range>
Curve_2 operator()(const Range& range, bool duplicate_first = false) const;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the default value to true in my latest commits (to match the use cases).

By the way, is there a reason why the documentation is separated in fake headers? I guess it's historical reasons. Having the documentation in the real headers would avoid this kind of problem (although it's probably an overly large amount of work for a package as big as Arrangement_2).

Until now I was convinced the documentation was in the real headers, considering real headers do have a doxygen-like documentation (which is thus only internal and never compiled).


/// @} /* end of operations */
}; /* end of Arr_caching_polyline_traits_2::Construct_curve_2 */

/*! Construction functor of a \f$x\f$-monotone polyline. Its `operator()` is
* oveloaded to support various input types.
*/
class Construct_x_monotone_curve_2 {
public:
/// \name Operations
/// @{

/*! Obtain a polyline connecting the two given endpoints.
* \param p the first point.
* \param q the second point.
* \pre `p` and `q` are distinct.
* \return an (\f$x\f$-monotone) polyline that comprises a single segment
* connecting `p` and `q`.
*/
X_monotone_curve_2 operator()(const Point_2& p, const Point_2& q) const;

/*! Construct a well-oriented polyline from a range of points.
*
* \param range a range of points.
* \pre contains no duplicated points.
* \pre `range` define an x-monotone polyline.
* \return an \f$x\f$-monotone polyline that comprises the given range of
* points.
*/
template <typename Range>
X_monotone_curve_2 operator()(const Range& range) const;

/// @} /* end of operations */
};

/// \name Accessing Functor Objects
/// @{

/*!
*/
Construct_curve_2 construct_curve_2_object() const;

/*!
*/
Construct_x_monotone_curve_2 construct_x_monotone_curve_2_object() const;

/// @} /* End Accessing Functor Objects */

}; /* end Arr_caching_polyline_traits_2 */

} /* end namespace CGAL */
Loading