diff --git a/.gitattributes b/.gitattributes
index 35a3066ee9c..ccb9bc4d4b5 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -18,7 +18,6 @@
*.js text
*.hmtl text
*.bib text
-*.sh text
*.css text
*.ui text
*.qrc text
@@ -36,6 +35,7 @@
*.pdb text
# Declare files that will always have LF line endings on checkout.
+*.sh text eol=lf
Documentation/Doxyfile text eol=lf
Documentation/pkglist_filter text eol=lf
Installation/update_CHANGES text eol=lf
diff --git a/.travis.yml b/.travis.yml
index 67ef61cbf57..26946424096 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,34 @@ sudo: required
git:
depth: 3
env:
+ matrix:
+ PACKAGES_MATRIX
+
+compiler: clang
+install:
+ - echo "$PWD"
+ - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$PACKAGE" != CHECK ]; then DO_IGNORE=FALSE; for ARG in $(echo "$PACKAGE");do if [ "$ARG" = "Maintenance" ]; then continue; fi; . $PWD/.travis/test_package.sh "$PWD" "$ARG"; echo "DO_IGNORE is $DO_IGNORE"; if [ "$DO_IGNORE" = "FALSE" ]; then break; fi; done; if [ "$DO_IGNORE" = "TRUE" ]; then travis_terminate 0; fi;fi
+ - /usr/bin/time -f 'Spend time of %C -- %E (real)' bash .travis/install.sh
+ - export CXX=clang++ CC=clang;
+before_script:
+ - wget -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen_exe
+ - sudo mv doxygen_exe /usr/bin/doxygen
+ - sudo chmod +x /usr/bin/doxygen
+ - mkdir -p build
+ - cd build
+ - /usr/bin/time -f 'Spend time of %C -- %E (real)' cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON ..
+ - /usr/bin/time -f 'Spend time of %C -- %E (real)' make
+ - /usr/bin/time -f 'Spend time of %C -- %E (real)' sudo make install &>/dev/null
+ - cd ..
+script:
+ - cd ./.travis
+ - /usr/bin/time -f 'Spend time of %C -- %E (real)' bash ./build_package.sh $PACKAGE
+notifications:
+ email:
+ on_success: change
+ # default: always
+ on_failure: always
+ # default: always
matrix:
- PACKAGE='CHECK'
- PACKAGE='AABB_tree Advancing_front_surface_reconstruction Algebraic_foundations '
@@ -49,32 +77,7 @@ env:
- PACKAGE='Surface_mesh_parameterization Surface_mesh_segmentation Surface_mesh_shortest_path '
- PACKAGE='Surface_mesh_simplification Surface_mesh_skeletonization Surface_mesh_topology '
- PACKAGE='Surface_mesher Surface_sweep_2 TDS_2 '
- - PACKAGE='TDS_3 Testsuite Three '
- - PACKAGE='Triangulation Triangulation_2 Triangulation_3 '
- - PACKAGE='Union_find Visibility_2 Voronoi_diagram_2 '
- - PACKAGE='wininst '
-compiler: clang
-install:
- - echo "$PWD"
- - if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] && [ "$PACKAGE" != CHECK ]; then DO_IGNORE=FALSE; for ARG in $(echo "$PACKAGE");do if [ "$ARG" = "Maintenance" ]; then continue; fi; . $PWD/.travis/test_package.sh "$PWD" "$ARG"; echo "DO_IGNORE is $DO_IGNORE"; if [ "$DO_IGNORE" = "FALSE" ]; then break; fi; done; if [ "$DO_IGNORE" = "TRUE" ]; then travis_terminate 0; fi;fi
- - /usr/bin/time -f 'Spend time of %C -- %E (real)' bash .travis/install.sh
- - export CXX=clang++ CC=clang;
-before_script:
- - wget -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen_exe
- - sudo mv doxygen_exe /usr/bin/doxygen
- - sudo chmod +x /usr/bin/doxygen
- - mkdir -p build
- - cd build
- - /usr/bin/time -f 'Spend time of %C -- %E (real)' cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON ..
- - /usr/bin/time -f 'Spend time of %C -- %E (real)' make
- - /usr/bin/time -f 'Spend time of %C -- %E (real)' sudo make install &>/dev/null
- - cd ..
-script:
- - cd ./.travis
- - /usr/bin/time -f 'Spend time of %C -- %E (real)' bash ./build_package.sh $PACKAGE
-notifications:
- email:
- on_success: change
- # default: always
- on_failure: always
- # default: always
+ - PACKAGE='TDS_3 Testsuite Tetrahedral_remeshing '
+ - PACKAGE='Three Triangulation Triangulation_2 '
+ - PACKAGE='Triangulation_3 Union_find Visibility_2 '
+ - PACKAGE='Voronoi_diagram_2 wininst '
diff --git a/.travis/build_package.sh b/.travis/build_package.sh
index 7fbe3c29aa2..cb046d1e29f 100755
--- a/.travis/build_package.sh
+++ b/.travis/build_package.sh
@@ -28,7 +28,7 @@ function build_demo {
EXTRA_CXX_FLAGS="-Werror=inconsistent-missing-override"
;;
esac
- mytime cmake -DCGAL_DIR="/usr/local/lib/cmake/CGAL" -DCGAL_DONT_OVERRIDE_CMAKE_FLAGS:BOOL=ON -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${EXTRA_CXX_FLAGS}" ..
+ mytime cmake -DCGAL_DIR="/usr/local/lib/cmake/CGAL" -DCGAL_DONT_OVERRIDE_CMAKE_FLAGS:BOOL=ON -DCMAKE_CXX_FLAGS="${CXX_FLAGS} ${EXTRA_CXX_FLAGS}" ..
mytime make -j2 VERBOSE=1
}
old_IFS=$IFS
@@ -57,41 +57,41 @@ cd $ROOT
cd ..
IFS=$old_IFS
mytime zsh $ROOT/Scripts/developer_scripts/test_merge_of_branch HEAD
- #test dependencies
+ #test dependencies
cd $ROOT
mytime bash Scripts/developer_scripts/cgal_check_dependencies.sh --check_headers /usr/bin/doxygen
cd .travis
- #parse current matrix and check that no package has been forgotten
+ #parse current matrix and check that no package has been forgotten
- IFS=$'\n'
- COPY=0
- MATRIX=()
- for LINE in $(cat "$PWD/packages.txt")
- do
- MATRIX+="$LINE "
- done
-
- PACKAGES=()
- cd ..
- for f in *
- do
- if [ -d "$f/package_info/$f" ]
- then
- PACKAGES+="$f "
- fi
- done
-
- DIFFERENCE=$(echo ${MATRIX[@]} ${PACKAGES[@]} | tr ' ' '\n' | sort | uniq -u)
- IFS=$' '
- if [ "${DIFFERENCE[0]}" != "" ]
- then
- echo "The matrix and the actual package list differ : ."
- echo ${DIFFERENCE[*]}
+ IFS=$'\n'
+ COPY=0
+ MATRIX=()
+ for LINE in $(cat "$PWD/packages.txt")
+ do
+ MATRIX+="$LINE "
+ done
+
+ PACKAGES=()
+ cd ..
+ for f in *
+ do
+ if [ -d "$f/package_info/$f" ]
+ then
+ PACKAGES+="$f "
+ fi
+ done
+
+ DIFFERENCE=$(echo ${MATRIX[@]} ${PACKAGES[@]} | tr ' ' '\n' | sort | uniq -u)
+ IFS=$' '
+ if [ "${DIFFERENCE[0]}" != "" ]
+ then
+ echo "The matrix and the actual package list differ : ."
+ echo ${DIFFERENCE[*]}
echo "You should run generate_travis.sh."
- exit 1
- fi
- echo "Matrix is up to date."
+ exit 1
+ fi
+ echo "Matrix is up to date."
#check if non standard cgal installation works
cd $ROOT
mkdir build_test
@@ -126,7 +126,7 @@ cd $ROOT
fi
IFS=$' '
EXAMPLES="$ARG/examples/$ARG"
- TEST="$ARG/test/$ARG"
+ TEST="$ARG/test/$ARG"
DEMOS=$ROOT/$ARG/demo/*
if [ -d "$ROOT/$EXAMPLES" ]
@@ -168,17 +168,17 @@ cd $ROOT
for DEMO in $DEMOS; do
DEMO=${DEMO#"$ROOT"}
echo $DEMO
- #If there is no demo subdir, try in GraphicsView
+ #If there is no demo subdir, try in GraphicsView
if [ ! -d "$ROOT/$DEMO" ] || [ ! -f "$ROOT/$DEMO/CMakeLists.txt" ]; then
DEMO="GraphicsView/demo/$ARG"
fi
- if [ "$ARG" != Polyhedron ] && [ -d "$ROOT/$DEMO" ]
- then
+ if [ "$ARG" != Polyhedron ] && [ -d "$ROOT/$DEMO" ]
+ then
cd $ROOT/$DEMO
build_demo
elif [ "$ARG" != Polyhedron_demo ]; then
echo "No demo found for $ARG"
- fi
+ fi
done
if [ "$ARG" = Polyhedron_demo ]; then
DEMO=Polyhedron/demo/Polyhedron
diff --git a/.travis/packages.txt b/.travis/packages.txt
index 69e4f85c73a..6e75cd0ad14 100644
--- a/.travis/packages.txt
+++ b/.travis/packages.txt
@@ -129,6 +129,7 @@ Surface_sweep_2
TDS_2
TDS_3
Testsuite
+Tetrahedral_remeshing
Three
Triangulation
Triangulation_2
diff --git a/.travis/windows.h b/.travis/windows.h
new file mode 100644
index 00000000000..a774a068df3
--- /dev/null
+++ b/.travis/windows.h
@@ -0,0 +1,12 @@
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+
+
+#define FAR #error named reserved in windows.h
+#define far #error named reserved in windows.h
+
+#define Polyline #error named reserved in windows.h
+#define Polygon #error named reserved in windows.h
diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/VerticalRayShootCallback.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/VerticalRayShootCallback.h
index 53cb0fcb76e..00b841f2d6f 100644
--- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/VerticalRayShootCallback.h
+++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/VerticalRayShootCallback.h
@@ -127,7 +127,11 @@ protected:
void highlightPointLocation( QGraphicsSceneMouseEvent *event );
Face_const_handle getFace( const CGAL::Object& o );
CGAL::Object rayShootUp( const Kernel_point_2& point );
+ CGAL::Object rayShootUp( const Kernel_point_2& point, CGAL::Tag_true );
+ CGAL::Object rayShootUp( const Kernel_point_2& point, CGAL::Tag_false );
CGAL::Object rayShootDown( const Kernel_point_2& point );
+ CGAL::Object rayShootDown( const Kernel_point_2& point, CGAL::Tag_true );
+ CGAL::Object rayShootDown( const Kernel_point_2& point, CGAL::Tag_false );
using Superclass::scene;
using Superclass::shootingUp;
@@ -304,6 +308,14 @@ VerticalRayShootCallback< Arr_ >::getFace( const CGAL::Object& obj )
template < typename Arr_ >
CGAL::Object
VerticalRayShootCallback< Arr_ >::rayShootUp( const Kernel_point_2& pt )
+{
+ typename Supports_landmarks< Arrangement >::Tag supportsLandmarks;
+ return this->rayShootUp( pt, supportsLandmarks );
+}
+
+template < typename Arr_ >
+CGAL::Object VerticalRayShootCallback< Arr_ >::rayShootUp( const Kernel_point_2& pt,
+ CGAL::Tag_true )
{
CGAL::Object pointLocationResult;
Walk_pl_strategy* walkStrategy;
@@ -334,9 +346,48 @@ VerticalRayShootCallback< Arr_ >::rayShootUp( const Kernel_point_2& pt )
return pointLocationResult;
}
+template < typename Arr_ >
+CGAL::Object VerticalRayShootCallback< Arr_ >::rayShootUp( const Kernel_point_2& pt,
+ CGAL::Tag_false )
+{
+ CGAL::Object pointLocationResult;
+ Walk_pl_strategy* walkStrategy;
+ TrapezoidPointLocationStrategy* trapezoidStrategy;
+ SimplePointLocationStrategy* simpleStrategy;
+
+ Point_2 point = this->toArrPoint( pt );
+
+ if ( CGAL::assign( walkStrategy, this->pointLocationStrategy ) )
+ {
+ pointLocationResult = walkStrategy->ray_shoot_up( point );
+ }
+ else if ( CGAL::assign( trapezoidStrategy, this->pointLocationStrategy ) )
+ {
+ pointLocationResult = trapezoidStrategy->ray_shoot_up( point );
+ }
+ else if ( CGAL::assign( simpleStrategy, this->pointLocationStrategy ) )
+ {
+ pointLocationResult = simpleStrategy->ray_shoot_up( point );
+ }
+ else
+ {
+ std::cout<<"Didn't find the right strategy\n";
+ }
+
+ return pointLocationResult;
+}
+
template < typename Arr_ >
CGAL::Object
VerticalRayShootCallback< Arr_ >::rayShootDown( const Kernel_point_2& pt )
+{
+ typename Supports_landmarks< Arrangement >::Tag supportsLandmarks;
+ return this->rayShootDown( pt, supportsLandmarks );
+}
+
+template < typename Arr_ >
+CGAL::Object
+VerticalRayShootCallback< Arr_ >::rayShootDown( const Kernel_point_2& pt, CGAL::Tag_true )
{
CGAL::Object pointLocationResult;
Walk_pl_strategy* walkStrategy;
@@ -367,4 +418,30 @@ VerticalRayShootCallback< Arr_ >::rayShootDown( const Kernel_point_2& pt )
return pointLocationResult;
}
+template < typename Arr_ >
+CGAL::Object
+VerticalRayShootCallback< Arr_ >::rayShootDown( const Kernel_point_2& pt, CGAL::Tag_false )
+{
+ CGAL::Object pointLocationResult;
+ Walk_pl_strategy* walkStrategy;
+ TrapezoidPointLocationStrategy* trapezoidStrategy;
+ SimplePointLocationStrategy* simpleStrategy;
+
+ Point_2 point = this->toArrPoint( pt );
+
+ if ( CGAL::assign( walkStrategy, this->pointLocationStrategy ) )
+ {
+ pointLocationResult = walkStrategy->ray_shoot_down( point );
+ }
+ else if ( CGAL::assign( trapezoidStrategy, this->pointLocationStrategy ) )
+ {
+ pointLocationResult = trapezoidStrategy->ray_shoot_down( point );
+ }
+ else if ( CGAL::assign( simpleStrategy, this->pointLocationStrategy ) )
+ {
+ pointLocationResult = simpleStrategy->ray_shoot_down( point );
+ }
+ return pointLocationResult;
+}
+
#endif // VERTICAL_RAY_SHOOT_CALLBACK_H
diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--Intersect_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--Intersect_2.h
index 3af9a106877..146eb151548 100644
--- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--Intersect_2.h
+++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrTraits--Intersect_2.h
@@ -16,21 +16,19 @@ public:
/// A model of this concept must provide:
/// @{
-/*!
-computes the intersections of `xc1` and `xc2` and
-inserts them in an ascending lexicographic \f$ xy\f$-order into the
-output iterator `oi`. The value-type of `Output_iterator` is
-`CGAL::Object`, where each `Object` wraps either a
-`pair` object, which
-represents an intersection point with its multiplicity (in case the
-multiplicity is undefined or unknown, it should be set to \f$ 0\f$) or an
-`ArrTraits::X_monotone_curve_2` object, representing an
-overlapping subcurve of `xc1` and `xc2`. The operator
-returns a past-the-end iterator for the output sequence.
-*/
-Output_iterator operator()(ArrTraits::X_monotone_curve_2 xc1,
-ArrTraits::X_monotone_curve_2 xc2,
-Output_iterator& oi);
+/*! computes the intersections of `xc1` and `xc2` and inserts them in an
+ * ascending lexicographic \f$ xy\f$-order into a range begining at
+ * `oi`. The type `OutputIterator` dereferences a `boost::variant` of either the
+ * type `pair` or the type
+ * `ArrTraits::X_monotone_curve_2`. An object of the former type represents an
+ * intersection point with its multiplicity (in case the multiplicity is
+ * undefined or unknown, it should be set to \f$ 0\f$). An object of the latter
+ * type representing an overlapping subcurve of `xc1` and `xc2`. The operator
+ * returns a past-the-end iterator of the destination range.
+ */
+OutputIterator operator()(ArrTraits::X_monotone_curve_2 xc1,
+ ArrTraits::X_monotone_curve_2 xc2,
+ Output_iterator& oi);
/// @}
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_circle_segment_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_circle_segment_traits_2.h
index dc8dc0d5e78..2b5a25cd5e0 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_circle_segment_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_circle_segment_traits_2.h
@@ -7,9 +7,10 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Ron Wein
-// Baruch Zukerman
-// Waqar Khan
+// Author(s): Ron Wein
+// Baruch Zukerman
+// Waqar Khan
+// Efi Fogel
#ifndef CGAL_ARR_CIRCLE_SEGMENT_TRAITS_2_H
#define CGAL_ARR_CIRCLE_SEGMENT_TRAITS_2_H
@@ -546,21 +547,15 @@ public:
return Split_2();
}
- class Intersect_2
- {
+ class Intersect_2 {
private:
-
- Intersection_map& _inter_map; // The map of intersection points.
+ Intersection_map& _inter_map; // The map of intersection points.
public:
-
/*! Constructor. */
- Intersect_2 (Intersection_map& map) :
- _inter_map (map)
- {}
+ Intersect_2(Intersection_map& map) : _inter_map(map) {}
- /*!
- * Find the intersections of the two given curves and insert them to the
+ /*! Find the intersections of the two given curves and insert them to the
* given output iterator. As two segments may itersect only once, only a
* single will be contained in the iterator.
* \param cv1 The first curve.
@@ -568,20 +563,15 @@ public:
* \param oi The output iterator.
* \return The past-the-end iterator.
*/
- template
- OutputIterator operator() (const X_monotone_curve_2& cv1,
- const X_monotone_curve_2& cv2,
- OutputIterator oi) const
- {
- return (cv1.intersect (cv2, oi, &_inter_map));
- }
+ template
+ OutputIterator operator()(const X_monotone_curve_2& cv1,
+ const X_monotone_curve_2& cv2,
+ OutputIterator oi) const
+ { return (cv1.intersect(cv2, oi, &_inter_map)); }
};
/*! Get an Intersect_2 functor object. */
- Intersect_2 intersect_2_object () const
- {
- return (Intersect_2 (inter_map));
- }
+ Intersect_2 intersect_2_object() const { return (Intersect_2(inter_map)); }
class Are_mergeable_2
{
@@ -706,14 +696,11 @@ public:
friend class Arr_circle_segment_traits_2;
public:
- /*!\brief
- * Returns a trimmed version of an arc
- *
+ /*! Obtain a trimmed version of an arc
* \param xcv The arc
* \param src the new first endpoint
* \param tgt the new second endpoint
* \return The trimmed arc
- *
* \pre src != tgt
* \pre both points must be interior and must lie on \c cv
*/
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h
index 654f86e3e30..eb9acae74a8 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_circular_line_arc_traits_2.h
@@ -22,7 +22,6 @@
#include
-
/*! \file
* This file was developed at Inria, France, and copied over to the
* Arrangement_2 package, which it is now part of. It contains a traits
@@ -30,12 +29,13 @@
* It is based on the circular kernel.
*/
-#include
-#include
-#include
-
#include
+#include
+
+#include
+#include
+
namespace CGAL {
namespace VariantFunctors{
@@ -47,9 +47,9 @@ namespace CGAL {
object_to_object_variant(const std::vector& res1,
OutputIterator res2)
{
- for(std::vector::const_iterator it = res1.begin();
- it != res1.end(); ++it ){
- if(const Arc1 *arc = CGAL::object_cast< Arc1 >(&*it)){
+ for (std::vector::const_iterator it = res1.begin();
+ it != res1.end(); ++it ) {
+ if (const Arc1 *arc = CGAL::object_cast< Arc1 >(&*it)){
boost::variant< Arc1, Arc2 > v = *arc;
*res2++ = make_object(v);
}
@@ -64,29 +64,27 @@ namespace CGAL {
return res2;
}
-
- template
- class In_x_range_2
+ template
+ OutputIterator
+ object_to_object_variant1(const std::vector& res,
+ OutputIterator oi)
{
- public:
- typedef typename CircularKernel::Circular_arc_point_2
- Circular_arc_point_2;
- typedef bool result_type;
+ typedef IntersectionPoint Intersection_point;
+ typedef XMonotoneCurve X_monotone_curve_2;
+ typedef boost::variant
+ Intersection_result;
- result_type
- operator()(const boost::variant< Arc1, Arc2 > &a,
- const Circular_arc_point_2 &p) const
- {
- if ( const Arc1* arc1 = boost::get( &a ) ){
- return CircularKernel().in_x_range_2_object()(*arc1, p);
- }
- else {
- const Arc2* arc2 = boost::get( &a );
- return CircularKernel().in_x_range_2_object()(*arc2, p);
+ for (auto it = res.begin(); it != res.end(); ++it) {
+ if (const Arc* arc = boost::get(&*it)) {
+ X_monotone_curve_2 cv = *arc;
+ *oi++ = Intersection_result(cv);
}
+ else *oi++ = Intersection_result(*it);
}
- };
-
+ return oi;
+ }
template
class Compare_y_to_right_2
@@ -277,7 +275,7 @@ namespace CGAL {
CircularKernel()
.make_x_monotone_2_object()(*arc1,std::back_inserter(container));
return object_to_object_variant
- (container, res);
+ (container, res);
}
else {
const Arc2* arc2 = boost::get( &A );
@@ -285,65 +283,42 @@ namespace CGAL {
CircularKernel()
.make_x_monotone_2_object()(*arc2,std::back_inserter(container));
return object_to_object_variant
- (container, res);
+ (container, res);
}
}
};
-
-
template
class Intersect_2
{
public:
- typedef typename CircularKernel::Circular_arc_point_2
- Circular_arc_point_2;
+ typedef typename CircularKernel::Circular_arc_point_2
+ Circular_arc_point_2;
template < class OutputIterator >
OutputIterator
operator()(const boost::variant< Arc1, Arc2 > &c1,
const boost::variant< Arc1, Arc2 > &c2,
- OutputIterator res) const
+ OutputIterator oi) const
{
if ( const Arc1* arc1 = boost::get( &c1 ) ){
if ( const Arc1* arc2 = boost::get( &c2 ) ){
- std::vector container;
- CircularKernel()
- .intersect_2_object()(*arc1,*arc2,std::back_inserter(container));
- return object_to_object_variant
- (container, res);
- }
- else if ( const Arc2* arc2 = boost::get( &c2 ) ){
- std::vector container;
- CircularKernel()
- .intersect_2_object()(*arc1,*arc2,std::back_inserter(container));
- return object_to_object_variant
- (container, res);
- }
- }
- else {
- const Arc2* arc1e = boost::get( &c1 );
- if ( const Arc1* arc2 = boost::get( &c2 ) ){
- std::vector container;
- CircularKernel()
- .intersect_2_object()(*arc1e,*arc2,std::back_inserter(container));
- return object_to_object_variant
- (container, res);
+ return CircularKernel().intersect_2_object()(*arc1, *arc2, oi);
}
const Arc2* arc2 = boost::get( &c2 );
- std::vector container;
- CircularKernel()
- .intersect_2_object()(*arc1e,*arc2,std::back_inserter(container));
- return object_to_object_variant
- (container, res);
+ return CircularKernel().intersect_2_object()(*arc1, *arc2, oi);
}
- CGAL_error();
- return res;//for no warning
+
+ const Arc2* arc1e = boost::get( &c1 );
+ if ( const Arc1* arc2 = boost::get( &c2 ) ){
+ return CircularKernel().intersect_2_object()(*arc1e, *arc2, oi);
+ }
+ const Arc2* arc2 = boost::get( &c2 );
+ return CircularKernel().intersect_2_object()(*arc1e, *arc2, oi);
}
};
-
template
class Split_2
{
@@ -533,7 +508,7 @@ namespace CGAL {
typedef unsigned int Multiplicity;
typedef CGAL::Tag_false Has_left_category;
- typedef CGAL::Tag_false Has_merge_category;
+ typedef CGAL::Tag_false Has_merge_category;
typedef CGAL::Tag_false Has_do_intersect_category;
typedef Arr_oblivious_side_tag Left_side_category;
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h
index f1640b280b0..cc26c045a84 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_conic_traits_2.h
@@ -8,8 +8,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
-// Author(s) : Ron Wein
-// Waqar Khan
+// Author(s): Ron Wein
+// Waqar Khan
#ifndef CGAL_ARR_CONIC_TRAITS_2_H
#define CGAL_ARR_CONIC_TRAITS_2_H
@@ -22,6 +22,8 @@
* The conic traits-class for the arrangement package.
*/
+#include
+
#include
#include
#include
@@ -29,8 +31,6 @@
#include
#include
-#include
-
namespace CGAL {
/*!
@@ -88,8 +88,7 @@ private:
// Type definition for the intersection points mapping.
typedef typename X_monotone_curve_2::Conic_id Conic_id;
- typedef typename X_monotone_curve_2::Intersection_point_2
- Intersection_point_2;
+ typedef typename X_monotone_curve_2::Intersection_point Intersection_point;
typedef typename X_monotone_curve_2::Intersection_map Intersection_map;
mutable Intersection_map inter_map; // Mapping conic pairs to their
@@ -604,21 +603,15 @@ public:
return Split_2();
}
- class Intersect_2
- {
+ class Intersect_2 {
private:
-
- Intersection_map& _inter_map; // The map of intersection points.
+ Intersection_map& _inter_map; // The map of intersection points.
public:
-
/*! Constructor. */
- Intersect_2 (Intersection_map& map) :
- _inter_map (map)
- {}
+ Intersect_2(Intersection_map& map) : _inter_map(map) {}
- /*!
- * Find the intersections of the two given curves and insert them to the
+ /*! Find the intersections of the two given curves and insert them to the
* given output iterator. As two segments may itersect only once, only a
* single will be contained in the iterator.
* \param cv1 The first curve.
@@ -626,20 +619,15 @@ public:
* \param oi The output iterator.
* \return The past-the-end iterator.
*/
- template
- OutputIterator operator() (const X_monotone_curve_2& cv1,
- const X_monotone_curve_2& cv2,
- OutputIterator oi) const
- {
- return (cv1.intersect (cv2, _inter_map, oi));
- }
+ template
+ OutputIterator operator()(const X_monotone_curve_2& cv1,
+ const X_monotone_curve_2& cv2,
+ OutputIterator oi) const
+ { return (cv1.intersect(cv2, _inter_map, oi)); }
};
/*! Get an Intersect_2 functor object. */
- Intersect_2 intersect_2_object () const
- {
- return (Intersect_2 (inter_map));
- }
+ Intersect_2 intersect_2_object () const { return (Intersect_2(inter_map)); }
class Are_mergeable_2
{
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h
index 877444cb066..7ed8e459334 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h
@@ -7,8 +7,8 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Ron Wein
-// Efi Fogel
+// Author(s): Ron Wein
+// Efi Fogel
#ifndef CGAL_ARR_CURVE_DATA_TRAITS_2_H
#define CGAL_ARR_CURVE_DATA_TRAITS_2_H
@@ -22,6 +22,8 @@
*/
#include
+
+#include
#include
#include
@@ -193,35 +195,40 @@ public:
* \param oi The output iterator.
* \return The past-the-end iterator.
*/
- template
+ template
OutputIterator operator()(const X_monotone_curve_2& cv1,
const X_monotone_curve_2& cv2,
OutputIterator oi) const
{
+ typedef std::pair Intersection_point;
+ typedef boost::variant
+ Intersection_result;
+ typedef boost::variant
+ Intersection_base_result;
+
// Use the base functor to obtain all intersection objects.
- std::list base_objects;
+ std::list base_objects;
m_base.intersect_2_object()(cv1, cv2, std::back_inserter(base_objects));
// Stop if the list is empty:
if (base_objects.empty()) return oi;
// Go over all intersection objects and prepare the output.
- const Base_x_monotone_curve_2* base_cv;
- for (typename std::list::const_iterator it =
- base_objects.begin(); it != base_objects.end(); ++it)
- {
- if ((base_cv = object_cast(&(*it))) != nullptr) {
+ for (const auto& item : base_objects) {
+ const Base_x_monotone_curve_2* base_cv =
+ boost::get(&item);
+ if (base_cv != nullptr) {
// The current intersection object is an overlapping x-monotone
// curve: Merge the data fields of both intersecting curves and
// associate the result with the overlapping curve.
- X_monotone_curve_2 cv(*base_cv, Merge() (cv1.data(), cv2.data()));
- *oi++ = make_object(cv);
- }
- else {
- // The current intersection object is an intersection point:
- // Copy it as is.
- *oi++ = *it;
+ X_monotone_curve_2 cv(*base_cv, Merge()(cv1.data(), cv2.data()));
+ *oi++ = Intersection_result(cv);
+ continue;
}
+ // The current intersection object is an intersection point:
+ // Copy it as is.
+ const Intersection_point* ip = boost::get(&item);
+ *oi++ = Intersection_result(*ip);
}
return oi;
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h
index 3c21ac9026d..6ccd5d249bc 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_geodesic_arc_on_sphere_traits_2.h
@@ -7,7 +7,7 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Efi Fogel
+// Author(s) : Efi Fogel
#ifndef CGAL_ARR_GEODESIC_ARC_ON_SPHERE_TRAITS_2_H
#define CGAL_ARR_GEODESIC_ARC_ON_SPHERE_TRAITS_2_H
@@ -25,6 +25,8 @@
#include
+#include
+
#include
#include
#include
@@ -1646,7 +1648,10 @@ public:
Project project,
OutputIterator oi) const
{
- typedef std::pair Point_2_pair;
+ typedef std::pair Intersection_point;
+ typedef boost::variant
+ Intersection_result;
+
const Kernel* kernel = m_traits;
typename Kernel::Equal_2 equal = kernel->equal_2_object();
@@ -1658,7 +1663,7 @@ public:
if (equal(l1, l2)) {
const Point_2& trg = (in_between(r1, l2, r2)) ? r1_3 : r2_3;
X_monotone_curve_2 xc(l1_3, trg, normal, vertical, true);
- *oi++ = make_object(xc);
+ *oi++ = Intersection_result(xc);
return oi;
}
@@ -1668,29 +1673,29 @@ public:
if (l1_eq_start || (!l2_eq_start && in_between(l1, start, l2))) {
// The following applies only to full circles:
if (l1_eq_start && equal(r2, start))
- *oi++ = make_object(Point_2_pair(r2_3, 1));
+ *oi++ = Intersection_result(Intersection_point(r2_3, 1));
if (in_between(r1, l1, l2)) return oi; // no intersection
if (equal(r1, l2)) {
- *oi++ = make_object(Point_2_pair(r1_3, 1));
+ *oi++ = Intersection_result(Intersection_point(r1_3, 1));
return oi;
}
const Point_2& trg = (in_between(r1, l2, r2)) ? r1_3 : r2_3;
X_monotone_curve_2 xc(l2_3, trg, normal, vertical, true);
- *oi++ = make_object(xc);
+ *oi++ = Intersection_result(xc);
return oi;
}
CGAL_assertion(l2_eq_start || in_between(l2, start, l1));
// The following applies only to full circles:
if (l2_eq_start && equal(r1, start))
- *oi++ = make_object(Point_2_pair(r1_3, 1));
+ *oi++ = Intersection_result(Intersection_point(r1_3, 1));
if (in_between(r2, l2, l1)) return oi; // no intersection
if (equal(r2, l1)) {
- *oi++ = make_object(Point_2_pair(r2_3, 1));
+ *oi++ = Intersection_result(Intersection_point(r2_3, 1));
return oi;
}
const Point_2& trg = (in_between(r1, l2, r2)) ? r1_3 : r2_3;
X_monotone_curve_2 xc(l1_3, trg, normal, vertical, true);
- *oi++ = make_object(xc);
+ *oi++ = Intersection_result(xc);
return oi;
}
@@ -1784,9 +1789,12 @@ public:
typedef Arr_geodesic_arc_on_sphere_traits_2 Traits;
typedef typename Kernel::Counterclockwise_in_between_2
Counterclockwise_in_between_2;
- typedef typename Kernel::Equal_3 Equal_3;
+ typedef typename Kernel::Equal_3 Equal_3;
+
+ typedef std::pair Intersection_point;
+ typedef boost::variant
+ Intersection_result;
- typedef std::pair Point_2_pair;
const Kernel* kernel = m_traits;
Equal_3 equal_3 = kernel->equal_3_object();
@@ -1810,9 +1818,9 @@ public:
(res && (xc1.is_directed_right() != xc2.is_directed_right())))
{
if (xc1.left().is_min_boundary() && xc2.left().is_min_boundary())
- *oi++ = make_object(Point_2_pair(xc1.left(), 1));
+ *oi++ = Intersection_result(Intersection_point(xc1.left(), 1));
if (xc1.right().is_max_boundary() && xc2.right().is_max_boundary())
- *oi++ = make_object(Point_2_pair(xc1.right(), 1));
+ *oi++ = Intersection_result(Intersection_point(xc1.right(), 1));
return oi;
}
@@ -1820,11 +1828,11 @@ public:
* the other arc is completely overlapping.
*/
if (xc1.left().is_min_boundary() && xc1.right().is_max_boundary()) {
- *oi++ = make_object(xc2);
+ *oi++ = Intersection_result(xc2);
return oi;
}
if (xc2.left().is_min_boundary() && xc2.right().is_max_boundary()) {
- *oi++ = make_object(xc1);
+ *oi++ = Intersection_result(xc1);
return oi;
}
/*! Find an endpoint that does not coincide with a pole, and project
@@ -1877,14 +1885,14 @@ public:
// Determine which one of the two directions:
Point_2 ed(v.direction());
if (is_in_between(ed, xc1) && is_in_between(ed, xc2)) {
- *oi++ = make_object(Point_2_pair(ed, 1));
+ *oi++ = Intersection_result(Intersection_point(ed, 1));
return oi;
}
Vector_3 vo(kernel->construct_opposite_vector_3_object()(v));
Point_2 edo(vo.direction());
if (is_in_between(edo, xc1) && is_in_between(edo, xc2)) {
- *oi++ = make_object(Point_2_pair(edo, 1));
+ *oi++ = Intersection_result(Intersection_point(edo, 1));
return oi;
}
return oi;
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_cache.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_cache.h
index 87a104c032f..3910c36249d 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_cache.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_cache.h
@@ -52,11 +52,11 @@ public:
/// \name Type definitions for the intersection-point mapping.
//@{
- /*! \struct Intersection_point_2
+ /*! \struct Intersection_point
* Representation of an intersection point (in both parameter and physical
* spaces).
*/
- struct Intersection_point_2
+ struct Intersection_point
{
Algebraic s; // The parameter for the first curve.
Algebraic t; // The parameter for the second curve.
@@ -64,7 +64,7 @@ public:
Algebraic y; // The y-coordinate.
/*! Constructor. */
- Intersection_point_2 (const Algebraic& _s, const Algebraic& _t,
+ Intersection_point (const Algebraic& _s, const Algebraic& _t,
const Algebraic& _x, const Algebraic& _y) :
s(_s), t(_t),
x(_x), y(_y)
@@ -73,7 +73,7 @@ public:
typedef std::pair Curve_pair;
typedef std::pair Parameter_pair;
- typedef std::list Intersection_list;
+ typedef std::list Intersection_list;
typedef
typename Intersection_list::const_iterator Intersection_iter;
@@ -378,7 +378,7 @@ _Bezier_cache::get_intersections
CGAL::compare (nt_traits.evaluate_at (polyY_1, *t_it),
y) == EQUAL)
{
- info.first.push_back (Intersection_point_2 (*s_it, *t_it,
+ info.first.push_back (Intersection_point (*s_it, *t_it,
x / denX, y / denY));
}
}
@@ -535,10 +535,8 @@ _Bezier_cache::get_intersections
CGAL_assertion(CGAL::sign (s) != NEGATIVE && CGAL::compare (s, one) != LARGER &&
CGAL::sign (t) != NEGATIVE && CGAL::compare (t, one) != LARGER);
- if (!swapt)
- info.first.push_back (Intersection_point_2 (s, t,pit1->x, pit1->y));
- else
- info.first.push_back (Intersection_point_2 (t, s,pit1->x, pit1->y));
+ if (!swapt) info.first.push_back(Intersection_point(s, t,pit1->x, pit1->y));
+ else info.first.push_back(Intersection_point(t, s,pit1->x, pit1->y));
}
info.second = false;
diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_x_monotone_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_x_monotone_2.h
index 25a1c51dbab..5397a42062f 100644
--- a/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_x_monotone_2.h
+++ b/Arrangement_on_surface_2/include/CGAL/Arr_geometry_traits/Bezier_x_monotone_2.h
@@ -7,8 +7,8 @@
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
-// Author(s) : Ron Wein
-// Iddo Hanniel
+// Author(s): Ron Wein
+// Iddo Hanniel
#ifndef CGAL_BEZIER_X_MONOTONE_2_H
#define CGAL_BEZIER_X_MONOTONE_2_H
@@ -85,27 +85,24 @@ private:
typedef typename Bezier_cache::Intersection_iter Intersect_iter;
// Representation of an intersection point with its multiplicity:
- typedef std::pair Intersection_point_2;
+ typedef std::pair Intersection_point;
/*! \class Less_intersection_point
* Comparison functor for intersection points.
*/
- class Less_intersection_point
- {
+ class Less_intersection_point {
private:
- Bezier_cache *p_cache;
+ Bezier_cache* p_cache;
public:
- Less_intersection_point (Bezier_cache& cache) :
- p_cache (&cache)
- {}
+ Less_intersection_point(Bezier_cache& cache) : p_cache(&cache) {}
- bool operator() (const Intersection_point_2& ip1,
- const Intersection_point_2& ip2) const
+ bool operator()(const Intersection_point& ip1,
+ const Intersection_point& ip2) const
{
// Use an xy-lexicographic comparison.
- return (ip1.first.compare_xy (ip2.first, *p_cache) == SMALLER);
+ return (ip1.first.compare_xy(ip2.first, *p_cache) == SMALLER);
}
};
@@ -117,7 +114,7 @@ private:
*/
struct Less_curve_pair
{
- bool operator() (const Curve_pair& cp1, const Curve_pair& cp2) const
+ bool operator()(const Curve_pair& cp1, const Curve_pair& cp2) const
{
// Compare the pairs of IDs lexicographically.
return (cp1.first < cp2.first ||
@@ -128,34 +125,32 @@ private:
/*! \struct Subcurve
* For the usage of the _exact_vertical_position() function.
*/
- struct Subcurve
- {
- std::list control_points;
- Rational t_min;
- Rational t_max;
+ struct Subcurve {
+ std::list control_points;
+ Rational t_min;
+ Rational t_max;
/*! Get the rational bounding box of the subcurve. */
- void bbox (Rational& x_min, Rational& y_min,
- Rational& x_max, Rational& y_max) const
+ void bbox(Rational& x_min, Rational& y_min,
+ Rational& x_max, Rational& y_max) const
{
- typename std::list::const_iterator pit =
+ typename std::list::const_iterator pit =
control_points.begin();
- CGAL_assertion (pit != control_points.end());
+ CGAL_assertion(pit != control_points.end());
x_min = x_max = pit->x();
y_min = y_max = pit->y();
- for (++pit; pit != control_points.end(); ++pit)
- {
- if (CGAL::compare (x_min, pit->x()) == LARGER)
+ for (++pit; pit != control_points.end(); ++pit) {
+ if (CGAL::compare(x_min, pit->x()) == LARGER)
x_min = pit->x();
- else if (CGAL::compare (x_max, pit->x()) == SMALLER)
+ else if (CGAL::compare(x_max, pit->x()) == SMALLER)
x_max = pit->x();
- if (CGAL::compare (y_min, pit->y()) == LARGER)
+ if (CGAL::compare(y_min, pit->y()) == LARGER)
y_min = pit->y();
- else if (CGAL::compare (y_max, pit->y()) == SMALLER)
+ else if (CGAL::compare(y_max, pit->y()) == SMALLER)
y_max = pit->y();
}
@@ -189,10 +184,10 @@ private:
public:
/*! Default constructor. */
- _Bezier_x_monotone_2 () :
+ _Bezier_x_monotone_2() :
_xid(0),
- _dir_right (false),
- _is_vert (false)
+ _dir_right(false),
+ _is_vert(false)
{}
/*!
@@ -209,80 +204,56 @@ public:
* \pre B should be an originator of both ps and pt.
* \pre xid is a non-zero serial number.
*/
- _Bezier_x_monotone_2 (const Curve_2& B, unsigned int xid,
- const Point_2& ps, const Point_2& pt,
- Bezier_cache& cache);
+ _Bezier_x_monotone_2(const Curve_2& B, unsigned int xid,
+ const Point_2& ps, const Point_2& pt,
+ Bezier_cache& cache);
/*!
* Get the supporting Bezier curve.
*/
- const Curve_2& supporting_curve () const
- {
- return (_curve);
- }
+ const Curve_2& supporting_curve() const { return (_curve); }
/*!
* Get the x-monotone ID of the curve.
*/
- unsigned int xid () const
- {
- return (_xid);
- }
+ unsigned int xid() const { return (_xid); }
/*!
* Get the source point.
*/
- const Point_2& source () const
- {
- return (_ps);
- }
+ const Point_2& source() const { return (_ps); }
/*!
* Get the target point.
*/
- const Point_2& target () const
- {
- return (_pt);
- }
+ const Point_2& target() const { return (_pt); }
/*!
* Get the left endpoint (the lexicographically smaller one).
*/
- const Point_2& left () const
- {
- return (_dir_right ? _ps : _pt);
- }
+ const Point_2& left() const { return (_dir_right ? _ps : _pt); }
/*!
* Get the right endpoint (the lexicographically larger one).
*/
- const Point_2& right () const
- {
- return (_dir_right ? _pt : _ps);
- }
+ const Point_2& right() const { return (_dir_right ? _pt : _ps); }
/*!
* Check if the subcurve is a vertical segment.
*/
- bool is_vertical () const
- {
- return (_is_vert);
- }
+ bool is_vertical() const { return (_is_vert); }
/*!
* Check if the subcurve is directed from left to right.
*/
- bool is_directed_right () const
- {
- return (_dir_right);
- }
+ bool is_directed_right() const { return (_dir_right); }
/*!
* Get the approximate parameter range defining the curve.
* \return A pair of t_src and t_trg, where B(t_src) is the source point
* and B(t_trg) is the target point.
*/
- std::pair parameter_range () const;
+ std::pair parameter_range() const;
/*!
* Get the relative position of the query point with respect to the subcurve.
@@ -293,8 +264,8 @@ public:
* LARGER if the point is above the arc;
* EQUAL if p lies on the arc.
*/
- Comparison_result point_position (const Point_2& p,
- Bezier_cache& cache) const;
+ Comparison_result point_position(const Point_2& p,
+ Bezier_cache& cache) const;
/*!
* Compare the relative y-position of two x-monotone subcurve to the right
@@ -307,9 +278,9 @@ public:
* EQUAL in case of an overlap (should not happen);
* LARGER if (*this) lies above cv to the right of p.
*/
- Comparison_result compare_to_right (const Self& cv,
- const Point_2& p,
- Bezier_cache& cache) const;
+ Comparison_result compare_to_right(const Self& cv,
+ const Point_2& p,
+ Bezier_cache& cache) const;
/*!
* Compare the relative y-position of two x-monotone subcurve to the left
@@ -322,106 +293,90 @@ public:
* EQUAL in case of an overlap (should not happen);
* LARGER if (*this) lies above cv to the right of p.
*/
- Comparison_result compare_to_left (const Self& cv,
- const Point_2& p,
- Bezier_cache& cache) const;
+ Comparison_result compare_to_left(const Self& cv,
+ const Point_2& p,
+ Bezier_cache& cache) const;
- /*!
- * Check whether the two subcurves are equal (have the same graph).
+ /*! Check whether the two subcurves are equal (have the same graph).
* \param cv The other subcurve.
* \param cache Caches the vertical tangency points and intersection points.
* \return (true) if the two subcurves have the same graph;
* (false) otherwise.
*/
- bool equals (const Self& cv,
- Bezier_cache& cache) const;
+ bool equals(const Self& cv, Bezier_cache& cache) const;
- /*!
- * Compute the intersections with the given subcurve.
+ /*! Compute the intersections with the given subcurve.
* \param cv The other subcurve.
* \param inter_map Caches the bounded intersection points.
* \param cache Caches the vertical tangency points and intersection points.
* \param oi The output iterator.
* \return The past-the-end iterator.
*/
- template
- OutputIterator intersect (const Self& cv,
- Intersection_map& inter_map,
- Bezier_cache& cache,
- OutputIterator oi) const
+ template
+ OutputIterator intersect(const Self& cv,
+ Intersection_map& inter_map,
+ Bezier_cache& cache,
+ OutputIterator oi) const
{
+ typedef boost::variant Intersection_result;
+
// In case we have two x-monotone subcurves of the same Bezier curve,
// check if they have a common left endpoint.
- if (_curve.is_same (cv._curve))
- {
- if (left().is_same (cv.left()) || left().is_same (cv.right()))
- {
- *oi = CGAL::make_object (Intersection_point_2 (left(), 0));
- ++oi;
- }
+ if (_curve.is_same(cv._curve)) {
+ if (left().is_same(cv.left()) || left().is_same(cv.right()))
+ *oi++ = Intersection_result(Intersection_point(left(), 0));
}
// Compute the intersections of the two sucurves. Note that for caching
// purposes we always apply the _intersect() function on the subcurve whose
// curve ID is smaller.
- std::vector ipts;
- Self ovlp_cv;
- bool do_ovlp;
+ std::vector ipts;
+ Self ovlp_cv;
+ bool do_ovlp;
if (_curve.id() <= cv._curve.id())
- do_ovlp = _intersect (cv, inter_map, cache, ipts, ovlp_cv);
+ do_ovlp = _intersect(cv, inter_map, cache, ipts, ovlp_cv);
else
- do_ovlp = cv._intersect (*this, inter_map, cache, ipts, ovlp_cv);
+ do_ovlp = cv._intersect(*this, inter_map, cache, ipts, ovlp_cv);
// In case of overlap, just report the overlapping subcurve.
- if (do_ovlp)
- {
- *oi = CGAL::make_object (ovlp_cv);
- ++oi;
- return (oi);
+ if (do_ovlp) {
+ *oi++ = Intersection_result(ovlp_cv);
+ return oi;
}
// If we have a set of intersection points, sort them in ascending
// xy-lexicorgraphical order, and insert them to the output iterator.
- typename std::vector::const_iterator ip_it;
-
- std::sort (ipts.begin(), ipts.end(), Less_intersection_point (cache));
- for (ip_it = ipts.begin(); ip_it != ipts.end(); ++ip_it)
- {
- *oi = CGAL::make_object (*ip_it);
- ++oi;
+ std::sort(ipts.begin(), ipts.end(), Less_intersection_point(cache));
+ for (auto ip_it = ipts.begin(); ip_it != ipts.end(); ++ip_it) {
+ *oi++ = Intersection_result(*ip_it);
}
// In case we have two x-monotone subcurves of the same Bezier curve,
// check if they have a common right endpoint.
- if (_curve.is_same (cv._curve))
- {
- if (right().is_same (cv.left()) || right().is_same (cv.right()))
- {
- *oi = CGAL::make_object (Intersection_point_2 (right(), 0));
- ++oi;
+ if (_curve.is_same(cv._curve)) {
+ if (right().is_same(cv.left()) || right().is_same(cv.right())) {
+ *oi++ = Intersection_result(Intersection_point(right(), 0));
}
}
- return (oi);
+ return oi;
}
- /*!
- * Split the subcurve into two at a given split point.
+ /*! Split the subcurve into two at a given split point.
* \param p The split point.
* \param c1 Output: The first resulting arc, lying to the left of p.
* \param c2 Output: The first resulting arc, lying to the right of p.
* \pre p lies in the interior of the subcurve (not one of its endpoints).
*/
- void split (const Point_2& p,
- Self& c1, Self& c2) const;
+ void split(const Point_2& p, Self& c1, Self& c2) const;
/*!
* Check if the two subcurves are mergeable.
* \param cv The other subcurve.
* \return Whether the two subcurves can be merged.
*/
- bool can_merge_with (const Self& cv) const;
+ bool can_merge_with(const Self& cv) const;
/*!
* Merge the current arc with the given arc.
@@ -429,13 +384,13 @@ public:
* \pre The two arcs are mergeable.
* \return The merged arc.
*/
- Self merge (const Self& cv) const;
+ Self merge(const Self& cv) const;
/*!
* Flip the subcurve (swap its source and target points).
* \return The flipped subcurve.
*/
- Self flip () const
+ Self flip() const
{
// Note that we just swap the source and target of the original subcurve
// and do not touch the supporting Beizer curve.
@@ -445,7 +400,7 @@ public:
cv._pt = this->_ps;
cv._dir_right = ! this->_dir_right;
- return (cv);
+ return cv;
}
Self trim(const Point_2& src, const Point_2& tgt) const
@@ -460,26 +415,21 @@ public:
}
private:
-
- /*!
- * Check if the given t-value is in the range of the subcurve.
+ /*! Check if the given t-value is in the range of the subcurve.
* \param t The parameter value.
* \param cache Caches the vertical tangency points and intersection points.
* \return If t in the parameter-range of the subcurve.
*/
- bool _is_in_range (const Algebraic& t,
- Bezier_cache& cache) const;
+ bool _is_in_range(const Algebraic& t, Bezier_cache& cache) const;
- /*!
- * Check if the given point lies in the range of this x-monotone subcurve.
+ /*! Check if the given point lies in the range of this x-monotone subcurve.
* \param p The point, which lies on the supporting Bezier curve.
* \param is_certain Output: Is the answer we provide is certain.
* \return Whether p is on the x-monotone subcurve.
*/
- bool _is_in_range (const Point_2& p, bool& is_certain) const;
+ bool _is_in_range(const Point_2& p, bool& is_certain) const;
- /*!
- * Given a point p that lies on the supporting Bezier curve (X(t), Y(t)),
+ /*! Given a point p that lies on the supporting Bezier curve (X(t), Y(t)),
* determine whether p lies within the t-range of the x-monotone subcurve.
* If so, the value t0 such that p = (X(t0), Y(t0)) is also computed.
* \param p The point, which lies on the supporting Bezier curve.
@@ -488,23 +438,20 @@ private:
* \param is_endpoint Output: Whether p equals on the of the endpoints.
* \return Whether p lies in the t-range of the subcurve.
*/
- bool _is_in_range (const Point_2& p,
- Bezier_cache& cache,
- Algebraic& t0,
- bool& is_endpoint) const;
+ bool _is_in_range(const Point_2& p,
+ Bezier_cache& cache,
+ Algebraic& t0,
+ bool& is_endpoint) const;
- /*!
- * Compute a y-coordinate of a point on the x-monotone subcurve with a
+ /*! Compute a y-coordinate of a point on the x-monotone subcurve with a
* given x-coordinate.
* \param x0 The given x-coodinate.
* \param cache Caches the vertical tangency points and intersection points.
* \return The y-coordinate.
*/
- Algebraic _get_y (const Rational& x0,
- Bezier_cache& cache) const;
+ Algebraic _get_y(const Rational& x0, Bezier_cache& cache) const;
- /*!
- * Compare the slopes of the subcurve with another given Bezier subcurve at
+ /*! Compare the slopes of the subcurve with another given Bezier subcurve at
* their given intersection point.
* \param cv The other subcurve.
* \param p The intersection point.
@@ -515,20 +462,18 @@ private:
* EQUAL if the two slopes are equal;
* LARGER if (*this) slope is greater than cv's.
*/
- Comparison_result _compare_slopes (const Self& cv,
- const Point_2& p,
- Bezier_cache& cache) const;
+ Comparison_result _compare_slopes(const Self& cv,
+ const Point_2& p,
+ Bezier_cache& cache) const;
- /*!
- * Get the range of t-value over which the subcurve is defined.
+ /*! Get the range of t-value over which the subcurve is defined.
* \param cache Caches the vertical tangency points and intersection points.
* \return A pair comprised of the t-value for the source point and the
* t-value for the target point.
*/
- std::pair _t_range (Bezier_cache& cache) const;
+ std::pair _t_range(Bezier_cache& cache) const;
- /*!
- * Compare the relative y-position of two x-monotone subcurve to the right
+ /*! Compare the relative y-position of two x-monotone subcurve to the right
* (or to the left) of their intersection point, whose multiplicity is
* greater than 1.
* \param cv The other subcurve.
@@ -543,25 +488,22 @@ private:
* EQUAL in case of an overlap (should not happen);
* LARGER if (*this) lies above cv next to p.
*/
- Comparison_result _compare_to_side (const Self& cv,
- const Point_2& p,
- bool to_right,
- Bezier_cache& cache) const;
+ Comparison_result _compare_to_side(const Self& cv,
+ const Point_2& p,
+ bool to_right,
+ Bezier_cache& cache) const;
- /*!
- * Clip the control polygon of the supporting Bezier curve such that it
+ /*! Clip the control polygon of the supporting Bezier curve such that it
* fits the current x-monotone subcurve.
* \param ctrl Output: The clipped control polygon.
* \param t_min Output: The minimal t-value of the clipped curve.
* \param t_max Output: The maximal t-value of the clipped curve.
*/
- void _clip_control_polygon
- (typename Bounding_traits::Control_points& ctrl,
- typename Bounding_traits::NT& t_min,
- typename Bounding_traits::NT& t_max) const;
+ void _clip_control_polygon(typename Bounding_traits::Control_points& ctrl,
+ typename Bounding_traits::NT& t_min,
+ typename Bounding_traits::NT& t_max) const;
- /*!
- * Approximate the intersection points between the supporting Bezier curves
+ /*! Approximate the intersection points between the supporting Bezier curves
* of the given x-monotone curves.
* \param cv The x-monotone curve we intersect.
* \param inter_pts Output: An output list of intersection points between
@@ -571,11 +513,10 @@ private:
* between the subcurves are approximated.
* \return Whether all intersection points where successfully approximated.
*/
- bool _approximate_intersection_points (const Self& cv,
- std::list& inter_pts) const;
+ bool _approximate_intersection_points(const Self& cv,
+ std::list& inter_pts) const;
- /*!
- * Compute the intersections with the given subcurve.
+ /*! Compute the intersections with the given subcurve.
* \param cv The other subcurve.
* \param inter_map Caches the bounded intersection points.
* \param cache Caches the vertical tangency points and intersection points.
@@ -583,14 +524,13 @@ private:
* \param ovlp_cv Output: An overlapping subcurve (if exists).
* \return Whether an overlap has occurred.
*/
- bool _intersect (const Self& cv,
- Intersection_map& inter_map,
- Bezier_cache& cache,
- std::vector& ipts,
- Self& ovlp_cv) const;
+ bool _intersect(const Self& cv,
+ Intersection_map& inter_map,
+ Bezier_cache& cache,
+ std::vector& ipts,
+ Self& ovlp_cv) const;
- /*!
- * Compute the exact vertical position of the given point with respect to
+ /*! Compute the exact vertical position of the given point with respect to
* the x-monotone curve.
* \param p The point.
* \param force_exact Sould we force an exact result.
@@ -598,64 +538,63 @@ private:
* LARGER if the point is above the curve;
* EQUAL if p lies on the curve.
*/
- Comparison_result _exact_vertical_position (const Point_2& p,
- bool
+ Comparison_result _exact_vertical_position(const Point_2& p,
+ bool
#if !defined(CGAL_NO_ASSERTIONS)
- force_exact
+ force_exact
#endif
- ) const;
+ ) const;
};
/*!
* Exporter for Bezier curves.
*/
-template
+template
std::ostream&
-operator<< (std::ostream& os,
- const _Bezier_x_monotone_2& cv)
+operator<<(std::ostream& os,
+ const _Bezier_x_monotone_2
+ & cv)
{
os << cv.supporting_curve()
<< " [" << cv.xid()
<< "] | " << cv.source()
<< " --> " << cv.target();
- return (os);
+ return os;
}
// ---------------------------------------------------------------------------
// Constructor given two endpoints.
//
-template
-_Bezier_x_monotone_2::_Bezier_x_monotone_2
- (const Curve_2& B, unsigned int xid,
- const Point_2& ps, const Point_2& pt,
- Bezier_cache& cache) :
- _curve (B),
- _xid (xid),
- _ps (ps),
- _pt (pt),
- _is_vert (false)
+template
+_Bezier_x_monotone_2::
+_Bezier_x_monotone_2(const Curve_2& B, unsigned int xid,
+ const Point_2& ps, const Point_2& pt,
+ Bezier_cache& cache) :
+ _curve(B),
+ _xid(xid),
+ _ps(ps),
+ _pt(pt),
+ _is_vert(false)
{
- CGAL_precondition (xid > 0);
+ CGAL_precondition(xid > 0);
// Get the originators of the point that correspond to the curve B.
- Originator_iterator ps_org = ps.get_originator (B, _xid);
- CGAL_precondition (ps_org != ps.originators_end());
+ Originator_iterator ps_org = ps.get_originator(B, _xid);
+ CGAL_precondition(ps_org != ps.originators_end());
- Originator_iterator pt_org = pt.get_originator (B, _xid);
- CGAL_precondition (pt_org != pt.originators_end());
+ Originator_iterator pt_org = pt.get_originator(B, _xid);
+ CGAL_precondition(pt_org != pt.originators_end());
// Check if the subcurve is directed left or right.
- const Comparison_result res = _ps.compare_x (_pt, cache);
+ const Comparison_result res = _ps.compare_x(_pt, cache);
- if (res == EQUAL)
- {
+ if (res == EQUAL) {
// We have a vertical segment. Check if the source is below the target.
_is_vert = true;
- _dir_right = (CGAL::compare (_ps.y(), _pt.y()) == SMALLER);
+ _dir_right = (CGAL::compare(_ps.y(), _pt.y()) == SMALLER);
}
else
{
@@ -665,89 +604,83 @@ _Bezier_x_monotone_2::_Bezier_x_monotone_2
// Check if the value of the parameter t increases when we traverse the
// curve from left to right: If the curve is directed to the right, we
// check if t_src < t_trg, otherwise we check whether t_src > t_trg.
- Comparison_result t_res;
+ Comparison_result t_res;
- if (CGAL::compare (ps_org->point_bound().t_max,
- pt_org->point_bound().t_min) == SMALLER ||
- CGAL::compare (ps_org->point_bound().t_min,
- pt_org->point_bound().t_max) == LARGER)
+ if (CGAL::compare(ps_org->point_bound().t_max,
+ pt_org->point_bound().t_min) == SMALLER ||
+ CGAL::compare(ps_org->point_bound().t_min,
+ pt_org->point_bound().t_max) == LARGER)
{
// Perform the comparison assuming that the possible parameter
// values do not overlap.
- t_res = CGAL::compare (ps_org->point_bound().t_min,
+ t_res = CGAL::compare(ps_org->point_bound().t_min,
pt_org->point_bound().t_min);
}
- else
- {
+ else {
// In this case both exact parameter values must be known.
// We use them to perform an exact comparison.
- CGAL_assertion (ps_org->has_parameter() && pt_org->has_parameter());
+ CGAL_assertion(ps_org->has_parameter() && pt_org->has_parameter());
- t_res = CGAL::compare (ps_org->parameter(), pt_org->parameter());
+ t_res = CGAL::compare(ps_org->parameter(), pt_org->parameter());
}
- CGAL_precondition (t_res != EQUAL);
+ CGAL_precondition(t_res != EQUAL);
- if (_dir_right)
- _inc_to_right = (t_res == SMALLER);
- else
- _inc_to_right = (t_res == LARGER);
+ if (_dir_right) _inc_to_right = (t_res == SMALLER);
+ else _inc_to_right = (t_res == LARGER);
}
// ---------------------------------------------------------------------------
// Get the approximate parameter range defining the curve.
//
-template
+template
std::pair
-_Bezier_x_monotone_2::parameter_range () const
+_Bezier_x_monotone_2::parameter_range() const
{
// First try to use the approximate representation of the endpoints.
- Originator_iterator s_org = _ps.get_originator (_curve, _xid);
- CGAL_assertion (s_org != _ps.originators_end());
+ Originator_iterator s_org = _ps.get_originator(_curve, _xid);
+ CGAL_assertion(s_org != _ps.originators_end());
- Originator_iterator t_org = _pt.get_originator (_curve, _xid);
- CGAL_assertion (t_org != _pt.originators_end());
+ Originator_iterator t_org = _pt.get_originator(_curve, _xid);
+ CGAL_assertion(t_org != _pt.originators_end());
- double t_src = (CGAL::to_double (s_org->point_bound().t_min) +
- CGAL::to_double (s_org->point_bound().t_max)) / 2;
- double t_trg = (CGAL::to_double (t_org->point_bound().t_min) +
- CGAL::to_double (t_org->point_bound().t_max)) / 2;
+ double t_src = (CGAL::to_double(s_org->point_bound().t_min) +
+ CGAL::to_double(s_org->point_bound().t_max)) / 2;
+ double t_trg = (CGAL::to_double(t_org->point_bound().t_min) +
+ CGAL::to_double(t_org->point_bound().t_max)) / 2;
- return (std::make_pair (t_src, t_trg));
+ return (std::make_pair(t_src, t_trg));
}
// ---------------------------------------------------------------------------
// Get the relative position of the query point with respect to the subcurve.
//
-template
+template
Comparison_result
-_Bezier_x_monotone_2::point_position
- (const Point_2& p,
- Bezier_cache& cache) const
+_Bezier_x_monotone_2::
+point_position(const Point_2& p, Bezier_cache& cache) const
{
Nt_traits nt_traits;
//First check if the bezier is a vertical segment
- if (is_vertical())
- {
- if (! p.is_exact()) p.make_exact (cache);
- if (! _ps.is_exact()) _ps.make_exact (cache);
- if (! _pt.is_exact()) _ps.make_exact (cache);
+ if (is_vertical()) {
+ if (! p.is_exact()) p.make_exact(cache);
+ if (! _ps.is_exact()) _ps.make_exact(cache);
+ if (! _pt.is_exact()) _ps.make_exact(cache);
- if (p.is_rational() && _ps.is_rational() && _pt.is_rational())
- {
+ if (p.is_rational() && _ps.is_rational() && _pt.is_rational()) {
const Rat_point_2& rat_p = (Rat_point_2) p;
const Rat_point_2& rat_ps = (Rat_point_2) _ps;
const Rat_point_2& rat_pt = (Rat_point_2) _pt;
- Comparison_result res1 = (CGAL::compare (rat_p.y(), rat_ps.y()));
- Comparison_result res2 = (CGAL::compare (rat_p.y(), rat_pt.y()));
- return (res1==res2 ? res1:EQUAL);
+ Comparison_result res1 = (CGAL::compare(rat_p.y(), rat_ps.y()));
+ Comparison_result res2 = (CGAL::compare(rat_p.y(), rat_pt.y()));
+ return (res1== res2 ? res1:EQUAL);
}
- Comparison_result res1 = (CGAL::compare (p.y(), _ps.y()));
- Comparison_result res2 = (CGAL::compare (p.y(), _pt.y()));
- return (res1==res2 ? res1:EQUAL);
+ Comparison_result res1 = (CGAL::compare(p.y(), _ps.y()));
+ Comparison_result res2 = (CGAL::compare(p.y(), _pt.y()));
+ return (res1== res2 ? res1:EQUAL);
}
if (p.identical(_ps)) {
@@ -757,106 +690,99 @@ _Bezier_x_monotone_2::point_position
// Then check whether the bezier is an horizontal segment or
// if p has the same x-coordinate as one of the endpoint
- const Comparison_result res1 = p.compare_x (_ps, cache);
+ const Comparison_result res1 = p.compare_x(_ps, cache);
if (res1 == EQUAL || nt_traits.degree(_curve.y_polynomial()) <= 0)
{
- if (! p.is_exact()) p.make_exact (cache);
- if (! _ps.is_exact()) _ps.make_exact (cache);
+ if (! p.is_exact()) p.make_exact(cache);
+ if (! _ps.is_exact()) _ps.make_exact(cache);
// If both point are rational, compare their rational y-coordinates.
if (p.is_rational() && _ps.is_rational())
{
- const Rat_point_2& rat_p = (Rat_point_2) p;
- const Rat_point_2& rat_ps = (Rat_point_2) _ps;
+ const Rat_point_2& rat_p = (Rat_point_2) p;
+ const Rat_point_2& rat_ps = (Rat_point_2) _ps;
- return (CGAL::compare (rat_p.y(), rat_ps.y()));
+ return (CGAL::compare(rat_p.y(), rat_ps.y()));
}
// Compare the algebraic y-coordinates.
- return (CGAL::compare (p.y(), _ps.y()));
+ return (CGAL::compare(p.y(), _ps.y()));
}
- if (p.identical(_pt)) {
- return EQUAL;
- }
+ if (p.identical(_pt)) return EQUAL;
- const Comparison_result res2 = p.compare_x (_pt, cache);
+ const Comparison_result res2 = p.compare_x(_pt, cache);
- if (res2 == EQUAL)
- {
+ if (res2 == EQUAL) {
// In this case both points must be exact.
- CGAL_assertion (p.is_exact() && _pt.is_exact());
+ CGAL_assertion(p.is_exact() && _pt.is_exact());
// If both point are rational, compare their rational y-coordinates.
- if (p.is_rational() && _pt.is_rational())
- {
- const Rat_point_2& rat_p = (Rat_point_2) p;
- const Rat_point_2& rat_pt = (Rat_point_2) _pt;
+ if (p.is_rational() && _pt.is_rational()) {
+ const Rat_point_2& rat_p = (Rat_point_2) p;
+ const Rat_point_2& rat_pt = (Rat_point_2) _pt;
- return (CGAL::compare (rat_p.y(), rat_pt.y()));
+ return (CGAL::compare(rat_p.y(), rat_pt.y()));
}
// Compare the algebraic y-coordinates.
- return (CGAL::compare (p.y(), _pt.y()));
+ return (CGAL::compare(p.y(), _pt.y()));
}
// Make sure that p is in the x-range of our subcurve.
- CGAL_precondition (res1 != res2);
+ CGAL_precondition(res1 != res2);
// Check for the case when curve is an originator of the point.
- Originator_iterator p_org = p.get_originator (_curve, _xid);
+ Originator_iterator p_org = p.get_originator(_curve, _xid);
- if (p_org != p.originators_end())
- {
+ if (p_org != p.originators_end()) {
CGAL_assertion_code
- (Originator_iterator ps_org = _ps.get_originator (_curve, _xid);
+ (Originator_iterator ps_org = _ps.get_originator(_curve, _xid);
CGAL_assertion(ps_org != _ps.originators_end());
- Originator_iterator pt_org = _pt.get_originator (_curve, _xid);
+ Originator_iterator pt_org = _pt.get_originator(_curve, _xid);
CGAL_assertion(pt_org != _pt.originators_end()));
// Check if the point is in the parameter range of this subcurve.
// First try an approximate check of the parameter bounds.
- bool correct_res;
- bool in_range = false;
+ bool correct_res;
+ bool in_range = false;
- in_range = _is_in_range (p, correct_res);
+ in_range = _is_in_range(p, correct_res);
- if (! correct_res)
- {
+ if (! correct_res) {
// Perform the comparsion in an exact manner.
if (! p.is_exact())
- p.make_exact (cache);
+ p.make_exact(cache);
- CGAL_assertion (p_org->has_parameter());
+ CGAL_assertion(p_org->has_parameter());
- in_range = _is_in_range (p_org->parameter(), cache);
+ in_range = _is_in_range(p_org->parameter(), cache);
}
- if (in_range)
- return (EQUAL);
+ if (in_range) return (EQUAL);
}
// Call the vertical-position function that uses the bounding-boxes
// to evaluate the comparsion result.
- typename Bounding_traits::Control_points cp;
+ typename Bounding_traits::Control_points cp;
- std::copy (_curve.control_points_begin(), _curve.control_points_end(),
- std::back_inserter(cp));
+ std::copy(_curve.control_points_begin(), _curve.control_points_end(),
+ std::back_inserter(cp));
- Originator_iterator ps_org = _ps.get_originator (_curve, _xid);
- CGAL_assertion (ps_org != _ps.originators_end());
+ Originator_iterator ps_org = _ps.get_originator(_curve, _xid);
+ CGAL_assertion(ps_org != _ps.originators_end());
- Originator_iterator pt_org = _pt.get_originator (_curve, _xid);
- CGAL_assertion (pt_org != _pt.originators_end());
+ Originator_iterator pt_org = _pt.get_originator(_curve, _xid);
+ CGAL_assertion(pt_org != _pt.originators_end());
- Comparison_result res_bound = EQUAL;
- typename Bounding_traits::NT x_min, y_min, x_max, y_max;
- bool can_refine;
+ Comparison_result res_bound = EQUAL;
+ typename Bounding_traits::NT x_min, y_min, x_max, y_max;
+ bool can_refine;
- p.get_bbox (x_min, y_min, x_max, y_max);
+ p.get_bbox(x_min, y_min, x_max, y_max);
- if (CGAL::compare (ps_org->point_bound().t_max,
+ if (CGAL::compare(ps_org->point_bound().t_max,
pt_org->point_bound().t_min) == SMALLER)
{
// Examine the parameter range of the originator of the source point
@@ -866,14 +792,13 @@ _Bezier_x_monotone_2::point_position
can_refine = ! _ps.is_exact();
do
{
- const Rat_point_2& ps = _curve (ps_org->point_bound().t_max);
+ const Rat_point_2& ps = _curve(ps_org->point_bound().t_max);
- if ((_dir_right && CGAL::compare (ps.x(), x_min) != LARGER) ||
- (! _dir_right && CGAL::compare (ps.x(), x_max) != SMALLER))
+ if ((_dir_right && CGAL::compare(ps.x(), x_min) != LARGER) ||
+ (! _dir_right && CGAL::compare(ps.x(), x_max) != SMALLER))
break;
- if (can_refine)
- can_refine = _ps.refine();
+ if (can_refine) can_refine = _ps.refine();
} while (can_refine);
// Examine the parameter range of the originator of the target point
@@ -883,10 +808,10 @@ _Bezier_x_monotone_2::point_position
can_refine = ! _pt.is_exact();
do
{
- const Rat_point_2& pt = _curve (pt_org->point_bound().t_min);
+ const Rat_point_2& pt = _curve(pt_org->point_bound().t_min);
- if ((_dir_right && CGAL::compare (pt.x(), x_max) != SMALLER) ||
- (! _dir_right && CGAL::compare (pt.x(), x_min) != LARGER))
+ if ((_dir_right && CGAL::compare(pt.x(), x_max) != SMALLER) ||
+ (! _dir_right && CGAL::compare(pt.x(), x_min) != LARGER))
break;
if (can_refine)
@@ -896,11 +821,11 @@ _Bezier_x_monotone_2::point_position
// In this case the parameter value of the source is smaller than the
// target's, so we compare the point with the subcurve of B defined over
// the proper parameter range.
- res_bound = p.vertical_position (cp,
+ res_bound = p.vertical_position(cp,
ps_org->point_bound().t_max,
pt_org->point_bound().t_min);
}
- else if (CGAL::compare (pt_org->point_bound().t_max,
+ else if (CGAL::compare(pt_org->point_bound().t_max,
ps_org->point_bound().t_min) == SMALLER)
{
// Examine the parameter range of the originator of the source point
@@ -908,12 +833,11 @@ _Bezier_x_monotone_2::point_position
// lies to the left of p if the curve is directed from left to right
// (or to the right of p, if the subcurve is directed from right to left).
can_refine = ! _ps.is_exact();
- do
- {
- const Rat_point_2& ps = _curve (ps_org->point_bound().t_min);
+ do {
+ const Rat_point_2& ps = _curve(ps_org->point_bound().t_min);
- if ((_dir_right && CGAL::compare (ps.x(), x_min) != LARGER) ||
- (! _dir_right && CGAL::compare (ps.x(), x_max) != SMALLER))
+ if ((_dir_right && CGAL::compare(ps.x(), x_min) != LARGER) ||
+ (! _dir_right && CGAL::compare(ps.x(), x_max) != SMALLER))
break;
if (can_refine)
@@ -925,12 +849,11 @@ _Bezier_x_monotone_2::point_position
// lies to the right of p if the curve is directed from left to right
// (or to the left of p, if the subcurve is directed from right to left).
can_refine = ! _pt.is_exact();
- do
- {
- const Rat_point_2& pt = _curve (pt_org->point_bound().t_max);
+ do {
+ const Rat_point_2& pt = _curve(pt_org->point_bound().t_max);
- if ((_dir_right && CGAL::compare (pt.x(), x_max) != SMALLER) ||
- (! _dir_right && CGAL::compare (pt.x(), x_min) != LARGER))
+ if ((_dir_right && CGAL::compare(pt.x(), x_max) != SMALLER) ||
+ (! _dir_right && CGAL::compare(pt.x(), x_min) != LARGER))
break;
if (can_refine)
@@ -940,7 +863,7 @@ _Bezier_x_monotone_2::point_position
// In this case the parameter value of the source is large than the
// target's, so we compare the point with the subcurve of B defined over
// the proper parameter range.
- res_bound = p.vertical_position (cp,
+ res_bound = p.vertical_position(cp,
pt_org->point_bound().t_max,
ps_org->point_bound().t_min);
}
@@ -960,13 +883,14 @@ _Bezier_x_monotone_2::point_position
std::vector roots;
std::pair prange = parameter_range();
- nt_traits.compute_polynomial_roots (poly_x,prange.first,prange.second,std::back_inserter(roots));
+ nt_traits.compute_polynomial_roots(poly_x,prange.first,prange.second, std::back_inserter(roots));
- CGAL_assertion(roots.size()==1); //p is in the range and the curve is x-monotone
+ //p is in the range and the curve is x-monotone
+ CGAL_assertion(roots.size() == 1);
return CGAL::compare(
((Rat_point_2) p).y(),
- nt_traits.evaluate_at (_curve.y_polynomial(), *roots.begin())
+ nt_traits.evaluate_at(_curve.y_polynomial(), *roots.begin())
);
}
@@ -974,22 +898,22 @@ _Bezier_x_monotone_2::point_position
// p lies of the given subcurve. We take one of p's originating curves and
// compute its intersections with our x-monotone curve.
if (! p.is_exact())
- p.make_exact (cache);
+ p.make_exact(cache);
- CGAL_assertion (p.originators_begin() != p.originators_end());
+ CGAL_assertion(p.originators_begin() != p.originators_end());
Originator org = *(p.originators_begin());
bool do_ovlp;
bool swap_order = (_curve.id() > org.curve().id());
const Intersect_list& inter_list = (! swap_order ?
- (cache.get_intersections (_curve.id(),
+ (cache.get_intersections(_curve.id(),
_curve.x_polynomial(), _curve.x_norm(),
_curve.y_polynomial(), _curve.y_norm(),
org.curve().id(),
org.curve().x_polynomial(), org.curve().x_norm(),
org.curve().y_polynomial(), org.curve().y_norm(),
do_ovlp)) :
- (cache.get_intersections (org.curve().id(),
+ (cache.get_intersections(org.curve().id(),
org.curve().x_polynomial(), org.curve().x_norm(),
org.curve().y_polynomial(), org.curve().y_norm(),
_curve.id(),
@@ -997,29 +921,24 @@ _Bezier_x_monotone_2::point_position
_curve.y_polynomial(), _curve.y_norm(),
do_ovlp)));
- if (do_ovlp)
- return (EQUAL);
+ if (do_ovlp) return EQUAL;
// Go over the intersection points and look for p there.
- Intersect_iter iit;
-
- for (iit = inter_list.begin(); iit != inter_list.end(); ++iit)
- {
+ for (auto iit = inter_list.begin(); iit != inter_list.end(); ++iit) {
// Get the parameter of the originator and compare it to p's parameter.
- const Algebraic& s = swap_order ? iit->s : iit->t;
+ const Algebraic& s = swap_order ? iit->s : iit->t;
- if (CGAL::compare (s, org.parameter()) == EQUAL)
- {
+ if (CGAL::compare(s, org.parameter()) == EQUAL) {
// Add this curve as an originator for p.
- const Algebraic& t = swap_order ? iit->t : iit->s;
+ const Algebraic& t = swap_order ? iit->t : iit->s;
- CGAL_assertion (_is_in_range (t, cache));
+ CGAL_assertion(_is_in_range(t, cache));
- Point_2& pt = const_cast (p);
+ Point_2& pt = const_cast(p);
pt.add_originator (Originator (_curve, _xid, t));
// The point p lies on the subcurve.
- return (EQUAL);
+ return EQUAL;
}
}
@@ -1028,21 +947,14 @@ _Bezier_x_monotone_2::point_position
// between the curve and the point. (This case should be very rare.)
// Note that we first try to work with inexact endpoint representation, and
// only if we fail we make the endpoints of the x-monotone curves exact.
- if (! p.is_exact())
- p.make_exact (cache);
+ if (! p.is_exact()) p.make_exact (cache);
- Comparison_result exact_res = _exact_vertical_position (p, false);
+ Comparison_result exact_res = _exact_vertical_position(p, false);
+ if (exact_res != EQUAL) return (exact_res);
+ if (! _ps.is_exact()) _ps.make_exact(cache);
+ if (! _pt.is_exact()) _pt.make_exact(cache);
- if (exact_res != EQUAL)
- return (exact_res);
-
- if (! _ps.is_exact())
- _ps.make_exact (cache);
-
- if (! _pt.is_exact())
- _pt.make_exact (cache);
-
- return (_exact_vertical_position (p, true));
+ return (_exact_vertical_position(p, true));
}
// ---------------------------------------------------------------------------
@@ -1051,57 +963,45 @@ _Bezier_x_monotone_2::point_position
//
template
Comparison_result
-_Bezier_x_monotone_2::compare_to_right
- (const Self& cv,
- const Point_2& p,
- Bezier_cache& cache) const
+_Bezier_x_monotone_2::
+compare_to_right(const Self& cv,
+ const Point_2& p,
+ Bezier_cache& cache) const
{
CGAL_precondition (p.compare_xy (right(), cache) != LARGER);
CGAL_precondition (p.compare_xy (cv.right(), cache) != LARGER);
- if (this == &cv)
- return (EQUAL);
+ if (this == &cv) return EQUAL;
// Make sure that p is incident to both curves (either equals the left
// endpoint or lies in the curve interior). Note that this is important to
// carry out these tests, as it assures us the eventually both curves are
// originators of p.
- if (! p.equals (left(), cache))
- {
- if (point_position (p, cache) != EQUAL)
- {
+ if (! p.equals (left(), cache)) {
+ if (point_position (p, cache) != EQUAL) {
CGAL_precondition_msg (false, "p is not on cv1");
}
}
- if (! p.equals (cv.left(), cache))
- {
- if (cv.point_position (p, cache) != EQUAL)
- {
+ if (! p.equals (cv.left(), cache)) {
+ if (cv.point_position (p, cache) != EQUAL) {
CGAL_precondition_msg (false, "p is not on cv2");
}
}
// Check for vertical subcurves. A vertical segment is above any other
// x-monotone subcurve to the right of their common endpoint.
- if (is_vertical())
- {
- if (cv.is_vertical())
- // Both are vertical segments with a common endpoint, so they overlap:
- return (EQUAL);
-
+ if (is_vertical()) {
+ // Both are vertical segments with a common endpoint, so they overlap:
+ if (cv.is_vertical()) return (EQUAL);
return (LARGER);
}
- else if (cv.is_vertical())
- {
- return (SMALLER);
- }
+ else if (cv.is_vertical()) return (SMALLER);
// Check if both subcurves originate from the same Bezier curve.
- Nt_traits nt_traits;
+ Nt_traits nt_traits;
- if (_curve.is_same (cv._curve))
- {
+ if (_curve.is_same (cv._curve)) {
// Get the originator, and check whether p is a vertical tangency
// point of this originator (otherwise it is a self-intersection point,
// and we proceed as if it is a regular intersection point).
@@ -1109,24 +1009,20 @@ _Bezier_x_monotone_2::compare_to_right
CGAL_assertion (org != p.originators_end());
- if (org->point_bound().type == Bez_point_bound::VERTICAL_TANGENCY_PT)
- {
+ if (org->point_bound().type == Bez_point_bound::VERTICAL_TANGENCY_PT) {
CGAL_assertion (_inc_to_right != cv._inc_to_right);
- if (! p.is_exact())
- {
+ if (! p.is_exact()) {
// Comparison based on the control polygon of the bounded vertical
// tangency point, using the fact this polygon is y-monotone.
const typename Bounding_traits::Control_points& cp =
org->point_bound().ctrl;
- if (_inc_to_right)
- {
- return (CGAL::compare (cp.back().y(), cp.front().y()));
+ if (_inc_to_right) {
+ return (CGAL::compare(cp.back().y(), cp.front().y()));
}
- else
- {
- return (CGAL::compare (cp.front().y(), cp.back().y()));
+ else {
+ return (CGAL::compare(cp.front().y(), cp.back().y()));
}
}
@@ -1135,14 +1031,14 @@ _Bezier_x_monotone_2::compare_to_right
// In this case we know that we have a vertical tangency at t0, so
// X'(t0) = 0. We evaluate the sign of Y'(t0) in order to find the
// vertical position of the two subcurves to the right of this point.
- CGAL_assertion (org->has_parameter());
+ CGAL_assertion(org->has_parameter());
- const Algebraic& t0 = org->parameter();
- Polynomial polyY_der = nt_traits.derive (_curve.y_polynomial());
- const CGAL::Sign sign_der =
- CGAL::sign (nt_traits.evaluate_at (polyY_der, t0));
+ const Algebraic& t0 = org->parameter();
+ Polynomial polyY_der = nt_traits.derive(_curve.y_polynomial());
+ const CGAL::Sign sign_der =
+ CGAL::sign(nt_traits.evaluate_at(polyY_der, t0));
- CGAL_assertion (sign_der != CGAL::ZERO);
+ CGAL_assertion(sign_der != CGAL::ZERO);
if (_inc_to_right)
return ((sign_der == CGAL::POSITIVE) ? LARGER : SMALLER);
@@ -1154,28 +1050,27 @@ _Bezier_x_monotone_2::compare_to_right
// Compare the slopes of the two supporting curves at p. In the general
// case, the slopes are not equal and their comparison gives us the
// vertical order to p's right.
- Comparison_result slope_res = _compare_slopes (cv, p, cache);
+ Comparison_result slope_res = _compare_slopes(cv, p, cache);
- if (slope_res != EQUAL)
- return (slope_res);
+ if (slope_res != EQUAL) return (slope_res);
// Compare the two subcurves by choosing some point to the right of p
// and comparing the vertical position there.
Comparison_result right_res;
- if (right().compare_x (cv.right(), cache) != LARGER)
+ if (right().compare_x(cv.right(), cache) != LARGER)
{
- right_res = _compare_to_side (cv, p,
+ right_res = _compare_to_side(cv, p,
true, // Compare to p's right.
cache);
}
else
{
- right_res = cv._compare_to_side (*this, p,
+ right_res = cv._compare_to_side(*this, p,
true, // Compare to p's right.
cache);
- right_res = CGAL::opposite (right_res);
+ right_res = CGAL::opposite(right_res);
}
return (right_res);
@@ -1192,8 +1087,8 @@ _Bezier_x_monotone_2::compare_to_left
const Point_2& p,
Bezier_cache& cache) const
{
- CGAL_precondition (p.compare_xy (left(), cache) != SMALLER);
- CGAL_precondition (p.compare_xy (cv.left(), cache) != SMALLER);
+ CGAL_precondition(p.compare_xy(left(), cache) != SMALLER);
+ CGAL_precondition(p.compare_xy(cv.left(), cache) != SMALLER);
if (this == &cv)
return (EQUAL);
@@ -1202,19 +1097,19 @@ _Bezier_x_monotone_2::compare_to_left
// endpoint or lies in the curve interior). Note that this is important to
// carry out these tests, as it assures us the eventually both curves are
// originators of p.
- if (! p.equals (right(), cache))
+ if (! p.equals(right(), cache))
{
- if (point_position (p, cache) != EQUAL)
+ if (point_position(p, cache) != EQUAL)
{
- CGAL_precondition_msg (false, "p is not on cv1");
+ CGAL_precondition_msg(false, "p is not on cv1");
}
}
- if (! p.equals (cv.right(), cache))
+ if (! p.equals(cv.right(), cache))
{
- if (cv.point_position (p, cache) != EQUAL)
+ if (cv.point_position(p, cache) != EQUAL)
{
- CGAL_precondition_msg (false, "p is not on cv2");
+ CGAL_precondition_msg(false, "p is not on cv2");
}
}
@@ -1236,15 +1131,15 @@ _Bezier_x_monotone_2::compare_to_left
// Check if both subcurves originate from the same Bezier curve.
Nt_traits nt_traits;
- if (_curve.is_same (cv._curve))
+ if (_curve.is_same(cv._curve))
{
// Get the originator, and check whether p is a vertical tangency
// point of this originator (otherwise it is a self-intersection point,
// and we proceed as if it is a regular intersection point).
- Originator_iterator org = p.get_originator (_curve, _xid);
+ Originator_iterator org = p.get_originator(_curve, _xid);
- CGAL_assertion (org != p.originators_end());
- CGAL_assertion (_inc_to_right != cv._inc_to_right);
+ CGAL_assertion(org != p.originators_end());
+ CGAL_assertion(_inc_to_right != cv._inc_to_right);
if (org->point_bound().type == Bez_point_bound::VERTICAL_TANGENCY_PT)
{
@@ -1270,14 +1165,14 @@ _Bezier_x_monotone_2::compare_to_left
// In this case we know that we have a vertical tangency at t0, so
// X'(t0) = 0. We evaluate the sign of Y'(t0) in order to find the
// vertical position of the two subcurves to the right of this point.
- CGAL_assertion (org->has_parameter());
+ CGAL_assertion(org->has_parameter());
const Algebraic& t0 = org->parameter();
- Polynomial polyY_der = nt_traits.derive (_curve.y_polynomial());
+ Polynomial polyY_der = nt_traits.derive(_curve.y_polynomial());
const CGAL::Sign sign_der =
- CGAL::sign (nt_traits.evaluate_at (polyY_der, t0));
+ CGAL::sign(nt_traits.evaluate_at(polyY_der, t0));
- CGAL_assertion (sign_der != CGAL::ZERO);
+ CGAL_assertion(sign_der != CGAL::ZERO);
if (_inc_to_right)
return ((sign_der == CGAL::NEGATIVE) ? LARGER : SMALLER);
@@ -1290,7 +1185,7 @@ _Bezier_x_monotone_2::compare_to_left
// case, the slopes are not equal and their comparison gives us the
// vertical order to p's right; note that we swap the order of the curves
// to obtains their position to the left.
- Comparison_result slope_res = cv._compare_slopes (*this, p, cache);
+ Comparison_result slope_res = cv._compare_slopes(*this, p, cache);
if (slope_res != EQUAL)
return (slope_res);
@@ -1299,18 +1194,18 @@ _Bezier_x_monotone_2::compare_to_left
// and compareing the vertical position there.
Comparison_result left_res;
- if (left().compare_x (cv.left(), cache) != SMALLER)
+ if (left().compare_x(cv.left(), cache) != SMALLER)
{
- left_res = _compare_to_side (cv, p,
+ left_res = _compare_to_side(cv, p,
false, // Compare to p's left.
cache);
}
else
{
- left_res = cv._compare_to_side (*this, p,
+ left_res = cv._compare_to_side(*this, p,
false, // Compare to p's left.
cache);
- left_res = CGAL::opposite (left_res);
+ left_res = CGAL::opposite(left_res);
}
return (left_res);
@@ -1325,7 +1220,7 @@ bool _Bezier_x_monotone_2::equals
Bezier_cache& cache) const
{
// Check if the two subcurves have overlapping supporting curves.
- if (! _curve.is_same (cv._curve))
+ if (! _curve.is_same(cv._curve))
{
//special case when curves are vertical
if (cv.is_vertical()){
@@ -1335,7 +1230,7 @@ bool _Bezier_x_monotone_2::equals
}
// Check whether the two curves have the same support:
- if (! _curve.has_same_support (cv._curve))
+ if (! _curve.has_same_support(cv._curve))
return (false);
// Mark that the two curves overlap in the cache.
@@ -1343,14 +1238,14 @@ bool _Bezier_x_monotone_2::equals
const Curve_id id2 = cv._curve.id();
if (id1 < id2)
- cache.mark_as_overlapping (id1, id2);
+ cache.mark_as_overlapping(id1, id2);
else
- cache.mark_as_overlapping (id2, id1);
+ cache.mark_as_overlapping(id2, id1);
}
// Check for equality of the endpoints.
- return (left().equals (cv.left(), cache) &&
- right().equals (cv.right(), cache));
+ return (left().equals(cv.left(), cache) &&
+ right().equals(cv.right(), cache));
}
// ---------------------------------------------------------------------------
@@ -1406,9 +1301,9 @@ bool _Bezier_x_monotone_2::can_merge_with
{
// Note that we only allow merging subcurves of the same originating
// Bezier curve (overlapping curves will not do in this case).
- return (_curve.is_same (cv._curve) &&
+ return (_curve.is_same(cv._curve) &&
_xid == cv._xid &&
- (right().is_same (cv.left()) || left().is_same (cv.right())));
+ (right().is_same(cv.left()) || left().is_same(cv.right())));
return (false);
}
@@ -1421,28 +1316,22 @@ typename _Bezier_x_monotone_2::Self
_Bezier_x_monotone_2::merge
(const Self& cv) const
{
- CGAL_precondition (_curve.is_same (cv._curve));
- CGAL_precondition (_xid == cv._xid);
+ CGAL_precondition(_curve.is_same(cv._curve));
+ CGAL_precondition(_xid == cv._xid);
- Self res = *this;
+ Self res = *this;
- if (right().is_same (cv.left()))
- {
+ if (right().is_same(cv.left())) {
// Extend the subcurve to the right.
- if (_dir_right)
- res._pt = cv.right();
- else
- res._ps = cv.right();
+ if (_dir_right) res._pt = cv.right();
+ else res._ps = cv.right();
}
- else
- {
- CGAL_precondition (left().is_same (cv.right()));
+ else {
+ CGAL_precondition(left().is_same(cv.right()));
// Extend the subcurve to the left.
- if (_dir_right)
- res._ps = cv.left();
- else
- res._pt = cv.left();
+ if (_dir_right) res._ps = cv.left();
+ else res._pt = cv.left();
}
return (res);
@@ -1451,42 +1340,35 @@ _Bezier_x_monotone_2::merge
// ---------------------------------------------------------------------------
// Check if the given t-value is in the range of the subcurve.
//
-template
-bool _Bezier_x_monotone_2::_is_in_range
- (const Algebraic& t,
- Bezier_cache& cache) const
+template
+bool _Bezier_x_monotone_2::
+_is_in_range(const Algebraic& t, Bezier_cache& cache) const
{
// First try to use the approximate representation of the endpoints.
- Originator_iterator s_org = _ps.get_originator (_curve, _xid);
- CGAL_assertion (s_org != _ps.originators_end());
+ Originator_iterator s_org = _ps.get_originator(_curve, _xid);
+ CGAL_assertion(s_org != _ps.originators_end());
- Originator_iterator t_org = _pt.get_originator (_curve, _xid);
- CGAL_assertion (t_org != _pt.originators_end());
+ Originator_iterator t_org = _pt.get_originator (_curve, _xid);
+ CGAL_assertion(t_org != _pt.originators_end());
- Nt_traits nt_traits;
+ Nt_traits nt_traits;
- bool p_lt_ps =
- (CGAL::compare (t, nt_traits.convert (s_org->point_bound().t_min)) ==
- SMALLER);
- bool p_gt_ps =
- (CGAL::compare (t, nt_traits.convert (s_org->point_bound().t_max)) ==
- LARGER);
- bool p_lt_pt =
- (CGAL::compare (t, nt_traits.convert (t_org->point_bound().t_min)) ==
- SMALLER);
- bool p_gt_pt =
- (CGAL::compare (t, nt_traits.convert (t_org->point_bound().t_max)) ==
- LARGER);
+ bool p_lt_ps =
+ CGAL::compare(t, nt_traits.convert(s_org->point_bound().t_min)) == SMALLER;
+ bool p_gt_ps =
+ CGAL::compare(t, nt_traits.convert(s_org->point_bound().t_max)) == LARGER;
+ bool p_lt_pt =
+ CGAL::compare(t, nt_traits.convert(t_org->point_bound().t_min)) == SMALLER;
+ bool p_gt_pt =
+ CGAL::compare(t, nt_traits.convert(t_org->point_bound().t_max)) == LARGER;
- if ((p_gt_ps && p_lt_pt) || (p_lt_ps && p_gt_pt))
- {
+ if ((p_gt_ps && p_lt_pt) || (p_lt_ps && p_gt_pt)) {
// The point p is definitely in the x-range of the subcurve, as its
// parameter is between the source and target parameters.
- return (true);
+ return true;
}
- if ((p_lt_ps && p_lt_pt) || (p_gt_ps && p_gt_pt))
- {
+ if ((p_lt_ps && p_lt_pt) || (p_gt_ps && p_gt_pt)) {
// The point p is definitely not in the x-range of the subcurve,
// as its parameter is smaller than both source and target parameter
// (or greater than both of them).
@@ -1507,60 +1389,54 @@ bool _Bezier_x_monotone_2::_is_in_range
// ---------------------------------------------------------------------------
// Check if the given point lies in the range of this x-monotone subcurve.
//
-template
-bool _Bezier_x_monotone_2::_is_in_range
- (const Point_2& p,
- bool& is_certain) const
+template
+bool _Bezier_x_monotone_2::
+_is_in_range(const Point_2& p, bool& is_certain) const
{
is_certain = true;
// Check the easy case that p is one of the subcurve endpoints.
- if (p.is_same(_ps) || p.is_same(_pt))
- return true;
+ if (p.is_same(_ps) || p.is_same(_pt)) return true;
// Compare the parameter of p with the parameters of the endpoints.
- Originator_iterator p_org = p.get_originator (_curve, _xid);
+ Originator_iterator p_org = p.get_originator(_curve, _xid);
- if (p_org == p.originators_end())
- {
- CGAL_assertion (p.get_originator (_curve) != p.originators_end());
+ if (p_org == p.originators_end()) {
+ CGAL_assertion(p.get_originator(_curve) != p.originators_end());
// In this case a different x-monotone curve of the supporting Bezier
// curve is an originator of the point, so we know that p does not
// lie in the range of our x-monotone subcurve.
- return (false);
+ return false;
}
- Originator_iterator s_org = _ps.get_originator (_curve, _xid);
- CGAL_assertion (s_org != _ps.originators_end());
+ Originator_iterator s_org = _ps.get_originator(_curve, _xid);
+ CGAL_assertion(s_org != _ps.originators_end());
- Originator_iterator t_org = _pt.get_originator (_curve, _xid);
- CGAL_assertion (t_org != _pt.originators_end());
+ Originator_iterator t_org = _pt.get_originator(_curve, _xid);
+ CGAL_assertion(t_org != _pt.originators_end());
- bool can_refine_p = ! p.is_exact();
- bool can_refine_s = ! _ps.is_exact();
- bool can_refine_t = ! _pt.is_exact();
+ bool can_refine_p = ! p.is_exact();
+ bool can_refine_s = ! _ps.is_exact();
+ bool can_refine_t = ! _pt.is_exact();
- while (can_refine_p || can_refine_s || can_refine_t)
- {
- bool p_lt_ps = (CGAL::compare (p_org->point_bound().t_max,
- s_org->point_bound().t_min) == SMALLER);
- bool p_gt_ps = (CGAL::compare (p_org->point_bound().t_min,
- s_org->point_bound().t_max) == LARGER);
- bool p_lt_pt = (CGAL::compare (p_org->point_bound().t_max,
- t_org->point_bound().t_min) == SMALLER);
- bool p_gt_pt = (CGAL::compare (p_org->point_bound().t_min,
- t_org->point_bound().t_max) == LARGER);
+ while (can_refine_p || can_refine_s || can_refine_t) {
+ bool p_lt_ps = (CGAL::compare(p_org->point_bound().t_max,
+ s_org->point_bound().t_min) == SMALLER);
+ bool p_gt_ps = (CGAL::compare(p_org->point_bound().t_min,
+ s_org->point_bound().t_max) == LARGER);
+ bool p_lt_pt = (CGAL::compare(p_org->point_bound().t_max,
+ t_org->point_bound().t_min) == SMALLER);
+ bool p_gt_pt = (CGAL::compare(p_org->point_bound().t_min,
+ t_org->point_bound().t_max) == LARGER);
- if ((p_gt_ps && p_lt_pt) || (p_lt_ps && p_gt_pt))
- {
+ if ((p_gt_ps && p_lt_pt) || (p_lt_ps && p_gt_pt)) {
// The point p is definitely in the x-range of the subcurve, as its
// parameter is between the source and target parameters.
return (true);
}
- if ((p_lt_ps && p_lt_pt) || (p_gt_ps && p_gt_pt))
- {
+ if ((p_lt_ps && p_lt_pt) || (p_gt_ps && p_gt_pt)) {
// The point p is definitely not in the x-range of the subcurve,
// as its parameter is smaller than both source and target parameter
// (or greater than both of them).
@@ -1568,19 +1444,14 @@ bool _Bezier_x_monotone_2::_is_in_range
}
// Try to refine the points.
- if (can_refine_p)
- can_refine_p = p.refine();
-
- if (can_refine_s)
- can_refine_s = _ps.refine();
-
- if (can_refine_t)
- can_refine_t = _pt.refine();
+ if (can_refine_p) can_refine_p = p.refine();
+ if (can_refine_s) can_refine_s = _ps.refine();
+ if (can_refine_t) can_refine_t = _pt.refine();
}
// If we reached here, we do not have a certain answer.
is_certain = false;
- return (false);
+ return false;
}
// ---------------------------------------------------------------------------
@@ -1588,35 +1459,32 @@ bool _Bezier_x_monotone_2::_is_in_range
// determine whether p lies within the t-range of the x-monotone subcurve.
// If so, the value t0 such that p = (X(t0), Y(t0)) is also computed.
//
-template
-bool _Bezier_x_monotone_2::_is_in_range
- (const Point_2& p,
- Bezier_cache& cache,
- Algebraic& t0,
- bool& is_endpoint) const
+template
+bool _Bezier_x_monotone_2::
+_is_in_range(const Point_2& p,
+ Bezier_cache& cache,
+ Algebraic& t0,
+ bool& is_endpoint) const
{
// The given point p must be rational, otherwise there is no point checking
// whether it lies in the interior of the curve.
- if (! p.is_rational())
- {
+ if (! p.is_rational()) {
is_endpoint = false;
- return (false);
+ return false;
}
- const Rat_point_2& rat_p = (Rat_point_2) p;
+ const Rat_point_2& rat_p = (Rat_point_2) p;
// Determine the parameter range [t_min, t_max] for our x-monotone
// subcurve.
- std::pair t_range = _t_range (cache);
- Algebraic t_min, t_max;
+ std::pair t_range = _t_range (cache);
+ Algebraic t_min, t_max;
- if ((_dir_right && _inc_to_right) || (! _dir_right && ! _inc_to_right))
- {
+ if ((_dir_right && _inc_to_right) || (! _dir_right && ! _inc_to_right)) {
t_min = t_range.first;
t_max = t_range.second;
}
- else
- {
+ else {
t_min = t_range.second;
t_max = t_range.first;
}
@@ -1624,90 +1492,78 @@ bool _Bezier_x_monotone_2::_is_in_range
// The given point p must lie on (X(t), Y(t)) for some t-value. Obtain the
// parameter value t0 for that point. We start by computing all t-values
// such that X(t) equals the x-coordinate of p.
- Nt_traits nt_traits;
- std::list t_vals;
- typename std::list::iterator t_iter;
- Comparison_result res1, res2;
- Algebraic y0;
+ Nt_traits nt_traits;
+ std::list t_vals;
+ typename std::list::iterator t_iter;
+ Comparison_result res1, res2;
+ Algebraic y0;
- if ( is_vertical() ){
- if ( compare(rat_p.x(),left().x())==EQUAL ){
- _curve.get_t_at_y (rat_p.y(), std::back_inserter(t_vals));
+ if (is_vertical()){
+ if ( compare(rat_p.x(),left().x()) == EQUAL) {
+ _curve.get_t_at_y(rat_p.y(), std::back_inserter(t_vals));
- for (t_iter = t_vals.begin(); t_iter != t_vals.end(); ++t_iter)
- {
+ for (t_iter = t_vals.begin(); t_iter != t_vals.end(); ++t_iter) {
// Compare the current t-value with t_min.
- res1 = CGAL::compare (t_min, *t_iter);
+ res1 = CGAL::compare(t_min, *t_iter);
- if (res1 == LARGER)
- continue;
+ if (res1 == LARGER) continue;
-
- if (res1 == EQUAL)
- {
+ if (res1 == EQUAL) {
t0 = t_min;
is_endpoint = true;
return (true);
}
// Compare the current t-value with t_max.
- res2 = CGAL::compare (t_max, *t_iter);
+ res2 = CGAL::compare(t_max, *t_iter);
- if (res2 == EQUAL)
- {
+ if (res2 == EQUAL) {
t0 = t_max;
is_endpoint = true;
- return (true);
+ return true;
}
- if (res2 == LARGER)
- {
+ if (res2 == LARGER) {
t0 = *t_iter;
is_endpoint = false;
- return (true);
+ return true;
}
}
}
is_endpoint = false;
- return (false);
+ return false;
}
- _curve.get_t_at_x (rat_p.x(), std::back_inserter(t_vals));
- CGAL_assertion (! t_vals.empty() );
+ _curve.get_t_at_x(rat_p.x(), std::back_inserter(t_vals));
+ CGAL_assertion(! t_vals.empty() );
- for (t_iter = t_vals.begin(); t_iter != t_vals.end(); ++t_iter)
- {
+ for (t_iter = t_vals.begin(); t_iter != t_vals.end(); ++t_iter) {
// Compare the current t-value with t_min.
res1 = CGAL::compare (t_min, *t_iter);
- if (res1 == LARGER)
- continue;
+ if (res1 == LARGER) continue;
// Make sure the y-coordinates match.
- y0 = nt_traits.evaluate_at (_curve.y_polynomial(), *t_iter) /
- nt_traits.convert (_curve.y_norm());
+ y0 = nt_traits.evaluate_at(_curve.y_polynomial(), *t_iter) /
+ nt_traits.convert(_curve.y_norm());
- if (CGAL::compare (nt_traits.convert (rat_p.y()), y0) == EQUAL)
- {
- if (res1 == EQUAL)
- {
+ if (CGAL::compare(nt_traits.convert(rat_p.y()), y0) == EQUAL) {
+ if (res1 == EQUAL) {
t0 = t_min;
is_endpoint = true;
- return (true);
+ return true;
}
// Compare the current t-value with t_max.
res2 = CGAL::compare (t_max, *t_iter);
- if (res2 == EQUAL)
- {
+ if (res2 == EQUAL) {
t0 = t_max;
is_endpoint = true;
return (true);
}
- if (res2 == LARGER)
- {
+ if (res2 == LARGER) {
t0 = *t_iter;
is_endpoint = false;
return (true);
@@ -1718,53 +1574,48 @@ bool _Bezier_x_monotone_2::_is_in_range
// In this case, we have not found a t-value in the range of our subcurve,
// so p does not lie on the subcurve:
is_endpoint = false;
- return (false);
+ return false;
}
// ---------------------------------------------------------------------------
// Compute a y-coordinate of a point on the x-monotone subcurve with a
// given x-coordinate.
//
-template
+template
typename _Bezier_x_monotone_2::Algebraic
-_Bezier_x_monotone_2::_get_y
- (const Rational& x0,
- Bezier_cache& cache) const
+_Bezier_x_monotone_2::
+_get_y(const Rational& x0, Bezier_cache& cache) const
{
// Obtain the t-values for with the x-coordinates of the supporting
// curve equal x0.
- std::list t_vals;
+ std::list t_vals;
- _curve.get_t_at_x (x0, std::back_inserter(t_vals));
+ _curve.get_t_at_x(x0, std::back_inserter(t_vals));
// Find a t-value that is in the range of the current curve.
- Nt_traits nt_traits;
- typename std::list::iterator t_iter;
- std::pair t_range = _t_range (cache);
- const Algebraic& t_src = t_range.first;
- const Algebraic& t_trg = t_range.second;
- Comparison_result res1, res2;
+ Nt_traits nt_traits;
+ typename std::list::iterator t_iter;
+ std::pair t_range = _t_range (cache);
+ const Algebraic& t_src = t_range.first;
+ const Algebraic& t_trg = t_range.second;
+ Comparison_result res1, res2;
- for (t_iter = t_vals.begin(); t_iter != t_vals.end(); ++t_iter)
- {
+ for (t_iter = t_vals.begin(); t_iter != t_vals.end(); ++t_iter) {
res1 = CGAL::compare (*t_iter, t_src);
- if (res1 == EQUAL)
- {
+ if (res1 == EQUAL) {
// Return the y-coordinate of the source point:
return (_ps.y());
}
res2 = CGAL::compare (*t_iter, t_trg);
- if (res2 == EQUAL)
- {
+ if (res2 == EQUAL) {
// Return the y-coordinate of the source point:
return (_pt.y());
}
- if (res1 != res2)
- {
+ if (res1 != res2) {
// We found a t-value in the range of our x-monotone subcurve.
// Use this value to compute the y-coordinate.
return (nt_traits.evaluate_at (_curve.y_polynomial(), *t_iter) /
@@ -1774,42 +1625,38 @@ _Bezier_x_monotone_2::_get_y
// If we reached here, x0 is not in the x-range of our subcurve.
CGAL_error();
- return (0);
+ return 0;
}
// ---------------------------------------------------------------------------
// Compare the slopes of the subcurve with another given Bezier subcurve at
// their given intersection point.
//
-template
+template
Comparison_result
-_Bezier_x_monotone_2::_compare_slopes
- (const Self& cv,
- const Point_2& p,
- Bezier_cache& cache) const
+_Bezier_x_monotone_2::
+_compare_slopes(const Self& cv, const Point_2& p, Bezier_cache& cache) const
{
// Get the originators of p.
- Originator_iterator org1 = p.get_originator (_curve, _xid);
- const bool valid_org1 = (org1 != p.originators_end());
+ Originator_iterator org1 = p.get_originator(_curve, _xid);
+ const bool valid_org1 = (org1 != p.originators_end());
- Originator_iterator org2 = p.get_originator (cv._curve, cv._xid);
- const bool valid_org2 = (org2 != p.originators_end());
+ Originator_iterator org2 = p.get_originator(cv._curve, cv._xid);
+ const bool valid_org2 = (org2 != p.originators_end());
- CGAL_assertion (valid_org1 || valid_org2);
+ CGAL_assertion(valid_org1 || valid_org2);
// If the point is only approximated, we can carry out a comparison using
// an approximate number type.
- if (valid_org1 && valid_org2 && ! p.is_exact())
- {
+ if (valid_org1 && valid_org2 && ! p.is_exact()) {
// If the point is inexact, we assume it is a bounded intersection
// point of two curves, and therefore the bounding angle these curves
// span do not overlap.
- const Bez_point_bound& bound1 = org1->point_bound();
- const Bez_point_bound& bound2 = org2->point_bound();
- Bounding_traits bound_tr;
+ const Bez_point_bound& bound1 = org1->point_bound();
+ const Bez_point_bound& bound2 = org2->point_bound();
+ Bounding_traits bound_tr;
- return (bound_tr.compare_slopes_at_intersection_point (bound1,
- bound2));
+ return (bound_tr.compare_slopes_at_intersection_point(bound1, bound2));
}
// Obtain the parameter values t1 and t2 that correspond to the point p.
@@ -1818,17 +1665,15 @@ _Bezier_x_monotone_2::_compare_slopes
// it must be a ratioal point!) and lies in its interior. In this
// (degenerate) case we compute the parameter value and set the appropriate
// originator for p.
- Nt_traits nt_traits;
- Algebraic t1;
- Algebraic t2;
+ Nt_traits nt_traits;
+ Algebraic t1;
+ Algebraic t2;
- if (valid_org1)
- {
+ if (valid_org1) {
CGAL_assertion (org1->has_parameter());
t1 = org1->parameter();
}
- else
- {
+ else {
bool is_endpoint1;
CGAL_assertion_code (bool in_range1 =)
_is_in_range (p, cache, t1, is_endpoint1);
@@ -1836,66 +1681,60 @@ _Bezier_x_monotone_2::_compare_slopes
p.add_originator (Originator (_curve, _xid, t1));
}
- if (valid_org2)
- {
+ if (valid_org2) {
CGAL_assertion (org2->has_parameter());
t2 = org2->parameter();
}
- else
- {
- bool is_endpoint2;
- CGAL_assertion_code (bool in_range2 =)
- cv._is_in_range (p, cache, t2, is_endpoint2);
- CGAL_assertion (in_range2);
- p.add_originator (Originator (cv._curve, cv._xid, t2));
+ else {
+ bool is_endpoint2;
+ CGAL_assertion_code(bool in_range2 =)
+ cv._is_in_range(p, cache, t2, is_endpoint2);
+ CGAL_assertion(in_range2);
+ p.add_originator(Originator (cv._curve, cv._xid, t2));
}
// The slope of (X(t), Y(t)) at t0 is given by Y'(t0)/X'(t0).
// Compute the slope of (*this).
// Note that we take special care of the case X'(t0) = 0, when the tangent
// is vertical and its slope is +/- oo.
- Polynomial derivX = nt_traits.derive (_curve.x_polynomial());
- Polynomial derivY = nt_traits.derive (_curve.y_polynomial());
- Algebraic numer1 = nt_traits.evaluate_at (derivY, t1) *
- nt_traits.convert (_curve.x_norm());
- Algebraic denom1 = nt_traits.evaluate_at (derivX, t1) *
- nt_traits.convert (_curve.y_norm());
- CGAL::Sign inf_slope1 = CGAL::ZERO;
- Algebraic slope1;
+ Polynomial derivX = nt_traits.derive(_curve.x_polynomial());
+ Polynomial derivY = nt_traits.derive(_curve.y_polynomial());
+ Algebraic numer1 = nt_traits.evaluate_at(derivY, t1) *
+ nt_traits.convert (_curve.x_norm());
+ Algebraic denom1 = nt_traits.evaluate_at(derivX, t1) *
+ nt_traits.convert (_curve.y_norm());
+ CGAL::Sign inf_slope1 = CGAL::ZERO;
+ Algebraic slope1;
- if (CGAL::sign (denom1) == CGAL::ZERO)
- {
- inf_slope1 = is_directed_right() ? CGAL::sign (numer1) : CGAL::opposite( CGAL::sign (numer1) );
+ if (CGAL::sign (denom1) == CGAL::ZERO) {
+ inf_slope1 = is_directed_right() ?
+ CGAL::sign(numer1) : CGAL::opposite(CGAL::sign(numer1));
// If both derivatives are zero, we cannot perform the comparison:
- if (inf_slope1 == CGAL::ZERO)
- return (EQUAL);
+ if (inf_slope1 == CGAL::ZERO) return EQUAL;
}
- else
- {
+ else {
slope1 = numer1 / denom1;
}
// Compute the slope of the other subcurve.
derivX = nt_traits.derive (cv._curve.x_polynomial());
derivY = nt_traits.derive (cv._curve.y_polynomial());
- Algebraic numer2 = nt_traits.evaluate_at (derivY, t2) *
- nt_traits.convert (cv._curve.x_norm());
- Algebraic denom2 = nt_traits.evaluate_at (derivX, t2) *
- nt_traits.convert (cv._curve.y_norm());
- CGAL::Sign inf_slope2 = CGAL::ZERO;
- Algebraic slope2;
+ Algebraic numer2 = nt_traits.evaluate_at (derivY, t2) *
+ nt_traits.convert (cv._curve.x_norm());
+ Algebraic denom2 = nt_traits.evaluate_at (derivX, t2) *
+ nt_traits.convert (cv._curve.y_norm());
+ CGAL::Sign inf_slope2 = CGAL::ZERO;
+ Algebraic slope2;
- if (CGAL::sign (denom2) == CGAL::ZERO)
- {
- inf_slope2 = cv.is_directed_right() ? CGAL::sign (numer2) : CGAL::opposite( CGAL::sign (numer2) );
+ if (CGAL::sign (denom2) == CGAL::ZERO) {
+ inf_slope2 = cv.is_directed_right() ?
+ CGAL::sign (numer2) : CGAL::opposite( CGAL::sign (numer2) );
// If both derivatives are zero, we cannot perform the comparison:
- if (inf_slope2 == CGAL::ZERO)
- return (EQUAL);
+ if (inf_slope2 == CGAL::ZERO) return (EQUAL);
}
- else
- {
+ else {
slope2 = numer2 / denom2;
}
@@ -1906,11 +1745,9 @@ _Bezier_x_monotone_2::_compare_slopes
if (inf_slope1 == CGAL::NEGATIVE)
return (inf_slope2 == CGAL::NEGATIVE ? EQUAL : SMALLER);
- if (inf_slope2 == CGAL::POSITIVE)
- return (SMALLER);
+ if (inf_slope2 == CGAL::POSITIVE) return (SMALLER);
- if (inf_slope2 == CGAL::NEGATIVE)
- return (LARGER);
+ if (inf_slope2 == CGAL::NEGATIVE) return (LARGER);
// Compare the slopes.
return (CGAL::compare (slope1, slope2));
@@ -1919,29 +1756,25 @@ _Bezier_x_monotone_2::_compare_slopes
// ---------------------------------------------------------------------------
// Get the range of t-value over which the subcurve is defined.
//
-template
+template
std::pair::Algebraic,
typename _Bezier_x_monotone_2::Algebraic>
-_Bezier_x_monotone_2::_t_range
- (Bezier_cache& cache) const
+_Bezier_x_monotone_2::
+_t_range(Bezier_cache& cache) const
{
- Originator_iterator ps_org = _ps.get_originator (_curve, _xid);
+ Originator_iterator ps_org = _ps.get_originator(_curve, _xid);
CGAL_assertion(ps_org != _ps.originators_end());
- Originator_iterator pt_org = _pt.get_originator (_curve, _xid);
+ Originator_iterator pt_org = _pt.get_originator(_curve, _xid);
CGAL_assertion(pt_org != _pt.originators_end());
// Make sure that the two endpoints are exact.
- if (! ps_org->has_parameter())
- _ps.make_exact (cache);
+ if (! ps_org->has_parameter()) _ps.make_exact (cache);
+ if (! pt_org->has_parameter()) _pt.make_exact (cache);
- if (! pt_org->has_parameter())
- _pt.make_exact (cache);
-
- return (std::make_pair (ps_org->parameter(),
- pt_org->parameter()));
+ return (std::make_pair(ps_org->parameter(), pt_org->parameter()));
}
// ---------------------------------------------------------------------------
@@ -1949,18 +1782,18 @@ _Bezier_x_monotone_2::_t_range
// (or to the left) of their intersection point, whose multiplicity is
// greater than 1.
//
-template
+template
Comparison_result
-_Bezier_x_monotone_2::_compare_to_side
- (const Self& cv,
- const Point_2& p,
- bool to_right,
- Bezier_cache& cache) const
+_Bezier_x_monotone_2::
+_compare_to_side(const Self& cv,
+ const Point_2& p,
+ bool to_right,
+ Bezier_cache& cache) const
{
// Get the intersection points of the two curves from the cache. Note that
// we make sure that the ID of this->_curve is smaller than of cv's curve ID.
- const bool no_swap_curves = (_curve.id() <= cv._curve.id());
- bool do_ovlp;
+ const bool no_swap_curves = (_curve.id() <= cv._curve.id());
+ bool do_ovlp;
const Intersect_list& inter_list =
(no_swap_curves ?
(cache.get_intersections (_curve.id(),
@@ -1984,40 +1817,36 @@ _Bezier_x_monotone_2::_compare_to_side
CGAL_assertion (org != p.originators_end());
CGAL_assertion (org->has_parameter());
- const Algebraic& t0 = org->parameter();
+ const Algebraic& t0 = org->parameter();
// Get the parameter range of the curve.
- const std::pair& range = _t_range (cache);
- const Algebraic& t_src = range.first;
- const Algebraic& t_trg = range.second;
+ const std::pair& range = _t_range (cache);
+ const Algebraic& t_src = range.first;
+ const Algebraic& t_trg = range.second;
// Find the next intersection point that lies to the right of p.
- Intersect_iter iit;
- Algebraic next_t;
- Comparison_result res = CGAL::EQUAL;
- bool found = false;
+ Intersect_iter iit;
+ Algebraic next_t;
+ Comparison_result res = CGAL::EQUAL;
+ bool found = false;
- for (iit = inter_list.begin(); iit != inter_list.end(); ++iit)
- {
+ for (iit = inter_list.begin(); iit != inter_list.end(); ++iit) {
// Check if the current point lies to the right (left) of p. We do so by
// considering its originating parameter value s (or t, if we swapped
// the curves).
- const Algebraic& t = (no_swap_curves ? (iit->s) : iit->t);
+ const Algebraic& t = (no_swap_curves ? (iit->s) : iit->t);
- res = CGAL::compare (t, t0);
+ res = CGAL::compare(t, t0);
if ((to_right && ((_inc_to_right && res == LARGER) ||
(! _inc_to_right && res == SMALLER))) ||
(! to_right && ((_inc_to_right && res == SMALLER) ||
(! _inc_to_right && res == LARGER))))
{
- if (! found)
- {
+ if (! found) {
next_t = t;
found = true;
}
- else
- {
+ else {
// If we have already located an intersection point to the right
// (left) of p, choose the leftmost (rightmost) of the two points.
res = CGAL::compare (t, next_t);
@@ -2035,12 +1864,9 @@ _Bezier_x_monotone_2::_compare_to_side
// If the next intersection point occurs before the right (left) endpoint
// of the subcurve, keep it. Otherwise, take the parameter value at
// the endpoint.
- if (found)
- {
- if (to_right == _dir_right)
- res = CGAL::compare (t_trg, next_t);
- else
- res = CGAL::compare (t_src, next_t);
+ if (found) {
+ if (to_right == _dir_right) res = CGAL::compare (t_trg, next_t);
+ else res = CGAL::compare (t_src, next_t);
}
if (! found ||
@@ -2055,10 +1881,10 @@ _Bezier_x_monotone_2::_compare_to_side
// Find a rational value between t0 and t_next. Using this value, we
// a point with rational coordinates on our subcurve. We also locate a point
// on the other curve with the same x-coordinates.
- Nt_traits nt_traits;
- const Rational& mid_t = nt_traits.rational_in_interval (t0, next_t);
- const Rat_point_2& q1 = _curve (mid_t);
- const Algebraic& y2 = cv._get_y (q1.x(), cache);
+ Nt_traits nt_traits;
+ const Rational& mid_t = nt_traits.rational_in_interval(t0, next_t);
+ const Rat_point_2& q1 = _curve(mid_t);
+ const Algebraic& y2 = cv._get_y(q1.x(), cache);
// We now just have to compare the y-coordinates of the two points we have
// computed.
@@ -2069,33 +1895,32 @@ _Bezier_x_monotone_2::_compare_to_side
// Clip the control polygon of the supporting Bezier curve such that it fits
// the current x-monotone subcurve.
//
-template
-void _Bezier_x_monotone_2::_clip_control_polygon
- (typename Bounding_traits::Control_points& ctrl,
- typename Bounding_traits::NT& t_min,
- typename Bounding_traits::NT& t_max) const
+template
+void _Bezier_x_monotone_2::
+_clip_control_polygon(typename Bounding_traits::Control_points& ctrl,
+ typename Bounding_traits::NT& t_min,
+ typename Bounding_traits::NT& t_max) const
{
// Start from the control polygon of the supporting curve.
ctrl.clear();
- std::copy (_curve.control_points_begin(), _curve.control_points_end(),
- std::back_inserter (ctrl));
+ std::copy(_curve.control_points_begin(), _curve.control_points_end(),
+ std::back_inserter(ctrl));
// The x-monotone subcurve is defined over a parameter range
// 0 <= t_min < t_max <= 1. Determine the endpoint with minimal t-value and
// the one with maximal t-value.
- const Point_2& p_min = (_inc_to_right ? left() : right());
- Originator_iterator org_min = p_min.get_originator (_curve, _xid);
- const Point_2& p_max = (_inc_to_right ? right() : left());
- Originator_iterator org_max = p_max.get_originator (_curve, _xid);
- bool clipped_min = false;
+ const Point_2& p_min = (_inc_to_right ? left() : right());
+ Originator_iterator org_min = p_min.get_originator(_curve, _xid);
+ const Point_2& p_max = (_inc_to_right ? right() : left());
+ Originator_iterator org_max = p_max.get_originator(_curve, _xid);
+ bool clipped_min = false;
- CGAL_assertion (org_min != p_min.originators_end());
- CGAL_assertion (org_max != p_max.originators_end());
+ CGAL_assertion(org_min != p_min.originators_end());
+ CGAL_assertion(org_max != p_max.originators_end());
// Check if t_min = 0. If so, there is no need to clip.
if (! (org_min->point_bound().type == Bez_point_bound::RATIONAL_PT &&
- CGAL::sign (org_min->point_bound().t_min) == CGAL::ZERO))
+ CGAL::sign(org_min->point_bound().t_min) == CGAL::ZERO))
{
// It is possible that the paramater range of the originator is too large.
// We therefore make sure it fits the current bounding box of the point
@@ -2104,22 +1929,20 @@ void _Bezier_x_monotone_2point_bound().t_max;
- de_Casteljau_2 (ctrl.begin(), ctrl.end(),
- t_min,
- std::back_inserter(cp_a),
- std::front_inserter(cp_b));
+ de_Casteljau_2(ctrl.begin(), ctrl.end(),
+ t_min,
+ std::back_inserter(cp_a),
+ std::front_inserter(cp_b));
ctrl.clear();
- std::copy (cp_b.begin(), cp_b.end(),
- std::back_inserter (ctrl));
+ std::copy(cp_b.begin(), cp_b.end(), std::back_inserter (ctrl));
clipped_min = true;
}
- else
- {
+ else {
t_min = 0;
}
@@ -2137,27 +1960,21 @@ void _Bezier_x_monotone_2point_bound().t_min - t_min) / (1 - t_min);
}
- else
- {
+ else {
t_max = org_max->point_bound().t_min;
}
- de_Casteljau_2 (ctrl.begin(), ctrl.end(),
- t_max,
- std::back_inserter(cp_a),
- std::front_inserter(cp_b));
+ de_Casteljau_2(ctrl.begin(), ctrl.end(), t_max,
+ std::back_inserter(cp_a), std::front_inserter(cp_b));
ctrl.clear();
- std::copy (cp_a.begin(), cp_a.end(),
- std::back_inserter (ctrl));
+ std::copy(cp_a.begin(), cp_a.end(), std::back_inserter (ctrl));
t_max = org_max->point_bound().t_min;
}
- else
- {
+ else {
t_max = 1;
}
@@ -2167,11 +1984,10 @@ void _Bezier_x_monotone_2
-bool _Bezier_x_monotone_2::_approximate_intersection_points
- (const Self& cv,
- std::list& inter_pts) const
+template
+bool _Bezier_x_monotone_2::
+_approximate_intersection_points(const Self& cv,
+ std::list& inter_pts) const
{
typedef typename Bounding_traits::Intersection_point Intersection_point;
@@ -2179,16 +1995,15 @@ bool _Bezier_x_monotone_2