-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[Small Feature] Arrangement Caching Polyline Traits #5594
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
Open
sgiraudot
wants to merge
45
commits into
CGAL:main
Choose a base branch
from
sgiraudot:Arrangement-Lightweight_polyline_traits-GF
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 4445460
First version of lightweight polyline traits + example
sgiraudot 7237ec8
Create Construct_curve_2 functor and use it in example
sgiraudot 31a2c9b
Handle polygon conversion with lightweight traits
sgiraudot e35aea8
Rebase
sgiraudot 2aaa0cd
First functional version of line cache
sgiraudot bfbd08f
Clean up lightweight polyline class
sgiraudot e90da1f
Use indices and separated containers instead of zip iterator
sgiraudot 721d065
Some clean up
sgiraudot b9141a4
Do not use sweep to insert PWH
sgiraudot 41246df
Use unsigned indices
sgiraudot 65d08f8
Document and clean up
sgiraudot 7caf6b3
Add missing return statements
sgiraudot 0fcb807
Use lightweight traits as default in free BSO functions
sgiraudot 15dbc92
Fix overlap orientation
sgiraudot 83a7235
Allow chosing sweep or not for interting PWH in GPS
sgiraudot 0329f82
Fix std::function type using const ref and no value
sgiraudot 46f7e55
Replace lightweight by caching
sgiraudot 182b566
Distinguish types of Curve_2 / X_monotone_curve_2 and directly insert…
sgiraudot 09fc6cb
Use traits reference and do not construct kernel from scratch + minor…
sgiraudot 5f2448b
Fix Single const iterator
sgiraudot f8df8cd
Never store refs to traits in polylines
sgiraudot 7ad01c0
Fix style + cleaning
sgiraudot 1fbcaaa
Cleaned up Arr_polyline_traits_2 doc; Introduced Arr_caching_polyline…
efifogel 00dc92c
Added polylines_caching.cpp
efifogel 5875155
Enhanced
efifogel 1e902e4
Added support for testing the caching polyline traits
efifogel f5313a5
Use consistent naming
sgiraudot 72b164f
Define constrcut x monotone curve 2 in caching traits
sgiraudot 9763ddf
Fix concepts Construct_curve_2/x_monotone_curve_2
sgiraudot e6b86cd
Add Approximate_2 functor to caching polyline subtraits
sgiraudot 85fd419
Add comment about hacky optimization
sgiraudot b0d08a4
Added a constructore of an x-monotone polyline from a range of points
efifogel 17a5f91
Fixed the test of the caching-polyline traits to retain the points th…
efifogel 5f021fe
Small textual fixes related to "comprise"
efifogel 5823911
Added precondintion
efifogel 5fdadbc
Added missing documentation
efifogel 84d42b8
Fixed types of Curve_2 and X_monotone_curve_2
efifogel 13a5109
Small fixes
efifogel fa36a32
Fixed testing of caching polyline traits
efifogel 1afc180
Fix default value of duplicate_first
sgiraudot a7d0a4f
Fix Split_2
sgiraudot de43b6f
Disable some tests and clean error messages
sgiraudot b7412a9
Fix merge category + add missing precondition in Split_2
sgiraudot e7728dc
Disable assertions test for caching polylines
sgiraudot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
163 changes: 163 additions & 0 deletions
163
Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_caching_polyline_traits_2.h
This file contains hidden or 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,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; | ||
|
|
||
| /// @} /* 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 */ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
truein 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).