mirror of https://github.com/CGAL/cgal
Merge remote-tracking branch 'cgal/master' into HEAD
This commit is contained in:
commit
5254404517
|
|
@ -9,4 +9,5 @@ PLUGINS_ARRAY=(${LIST_OF_PLUGINS});
|
||||||
NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]}
|
NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]}
|
||||||
DEL=$(($NB_OF_PLUGINS / 4))
|
DEL=$(($NB_OF_PLUGINS / 4))
|
||||||
cd build
|
cd build
|
||||||
make -j2 ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))}
|
NUM_PROCS=$(nproc)
|
||||||
|
make -j${NUM_PROCS} ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))}
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,8 @@ jobs:
|
||||||
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
|
echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
cd build_doc && make -j2 doc
|
cd build_doc && make -j$(nproc) doc
|
||||||
make -j2 doc_with_postprocessing 2>tmp.log
|
make -j$(nproc) doc_with_postprocessing 2>tmp.log
|
||||||
if [ -s tmp.log ]; then
|
if [ -s tmp.log ]; then
|
||||||
content=`cat ./tmp.log`
|
content=`cat ./tmp.log`
|
||||||
delimiter="$(openssl rand -hex 8)"
|
delimiter="$(openssl rand -hex 8)"
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,24 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: REUSE version
|
- name: REUSE version
|
||||||
uses: fsfe/reuse-action@v2
|
uses: fsfe/reuse-action@v3
|
||||||
with:
|
with:
|
||||||
args: --version
|
args: --version
|
||||||
- name: REUSE lint
|
- name: REUSE lint
|
||||||
uses: fsfe/reuse-action@v2
|
uses: fsfe/reuse-action@v3
|
||||||
with:
|
with:
|
||||||
args: --include-submodules lint
|
args: --include-submodules lint
|
||||||
- name: REUSE SPDX SBOM
|
- name: REUSE SPDX SBOM
|
||||||
uses: fsfe/reuse-action@v2
|
uses: fsfe/reuse-action@v3
|
||||||
with:
|
with:
|
||||||
args: spdx
|
args: spdx
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: sudo apt-get install -y cmake
|
run: sudo apt-get update && sudo apt-get install -y cmake
|
||||||
- name: Create CGAL internal release
|
- name: Create CGAL internal release
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./release
|
mkdir -p ./release
|
||||||
cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake
|
cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake
|
||||||
- name: REUSE lint release tarball
|
- name: REUSE lint release tarball
|
||||||
uses: fsfe/reuse-action@v2
|
uses: fsfe/reuse-action@v3
|
||||||
with:
|
with:
|
||||||
args: --root ./release/CGAL-9.9 --include-submodules lint
|
args: --root ./release/CGAL-9.9 --include-submodules lint
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public:
|
||||||
Result;
|
Result;
|
||||||
public:
|
public:
|
||||||
First_intersection_traits(const AABBTraits& traits)
|
First_intersection_traits(const AABBTraits& traits)
|
||||||
: m_result(), m_traits(traits)
|
: m_result(std::nullopt), m_traits(traits)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool go_further() const {
|
bool go_further() const {
|
||||||
|
|
@ -202,7 +202,7 @@ class First_primitive_traits
|
||||||
public:
|
public:
|
||||||
First_primitive_traits(const AABBTraits& traits)
|
First_primitive_traits(const AABBTraits& traits)
|
||||||
: m_is_found(false)
|
: m_is_found(false)
|
||||||
, m_result()
|
, m_result(std::nullopt)
|
||||||
, m_traits(traits) {}
|
, m_traits(traits) {}
|
||||||
|
|
||||||
bool go_further() const { return !m_is_found; }
|
bool go_further() const { return !m_is_found; }
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ Advancing_front_surface_reconstruction
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
BGL
|
BGL
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Distance_2
|
Distance_2
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ struct Rational_traits_base<Rational, true>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef Fraction_traits<Rational> FT;
|
typedef Fraction_traits<Rational> FT;
|
||||||
typedef typename FT::Decompose Decomose;
|
typedef typename FT::Decompose Decompose;
|
||||||
typedef typename FT::Compose Compose;
|
typedef typename FT::Compose Compose;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -61,13 +61,13 @@ public:
|
||||||
|
|
||||||
RT numerator (const Rational& r) const {
|
RT numerator (const Rational& r) const {
|
||||||
RT num,den;
|
RT num,den;
|
||||||
Decomose()(r,num,den);
|
Decompose()(r,num,den);
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
RT denominator (const Rational& r) const {
|
RT denominator (const Rational& r) const {
|
||||||
RT num,den;
|
RT num,den;
|
||||||
Decomose()(r,num,den);
|
Decompose()(r,num,den);
|
||||||
return den;
|
return den;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ public:
|
||||||
Integer alpha_num = Integer(1), int log_denom = 1
|
Integer alpha_num = Integer(1), int log_denom = 1
|
||||||
) : alpha_num_(alpha_num),
|
) : alpha_num_(alpha_num),
|
||||||
beta_num_((Integer(1) << log_denom) - alpha_num),
|
beta_num_((Integer(1) << log_denom) - alpha_num),
|
||||||
half_((log_denom > 0) ? (Integer(1) << log_denom-1) : 0),
|
half_((log_denom > 0) ? Integer(Integer(1) << log_denom-1) : 0),
|
||||||
log_denom_(log_denom)
|
log_denom_(log_denom)
|
||||||
{
|
{
|
||||||
CGAL_precondition(log_denom_ >= 0);
|
CGAL_precondition(log_denom_ >= 0);
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ polynomial_power_to_bernstein_approx(
|
||||||
std::vector<Integer> f(n+1);
|
std::vector<Integer> f(n+1);
|
||||||
polynomial_affine_transform_approx_log_denom(
|
polynomial_affine_transform_approx_log_denom(
|
||||||
first, beyond, f.begin(),
|
first, beyond, f.begin(),
|
||||||
upper_num - lower_num, lower_num, log_denom,
|
Integer(upper_num - lower_num), lower_num, log_denom,
|
||||||
p+q,
|
p+q,
|
||||||
approx, log, logl
|
approx, log, logl
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -27,31 +27,10 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if CGAL_USE_CORE
|
|
||||||
namespace CORE { class BigInt; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
#if CGAL_USE_CORE
|
|
||||||
// bugfix for CORE by Michael Kerber
|
|
||||||
// why is there a specialized function for CORE?
|
|
||||||
inline CORE::BigInt shift_integer_by(CORE::BigInt x, long shift){
|
|
||||||
if( shift > 0 ){
|
|
||||||
while(shift>63) {
|
|
||||||
x = (x >> 63);
|
|
||||||
shift-=63;
|
|
||||||
}
|
|
||||||
x = (x >> shift);
|
|
||||||
}else{
|
|
||||||
// add 0 bits
|
|
||||||
x = (x << -shift);
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class Shiftable>
|
template <class Shiftable>
|
||||||
Shiftable shift_integer_by(Shiftable x, long shift){
|
Shiftable shift_integer_by(Shiftable x, long shift){
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ public:
|
||||||
long operator()( CORE::BigFloat x ) const {
|
long operator()( CORE::BigFloat x ) const {
|
||||||
CGAL_precondition(!CGAL::zero_in(x));
|
CGAL_precondition(!CGAL::zero_in(x));
|
||||||
x = CGAL::abs(x);
|
x = CGAL::abs(x);
|
||||||
return CORE::floorLg(x.m()-x.err())+x.exp()*CORE::CHUNK_BIT;
|
return CORE::floorLg(CORE::BigInt(x.m()-x.err()))+x.exp()*CORE::CHUNK_BIT;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -337,7 +337,7 @@ public:
|
||||||
// (already commented out in EXACUS)...
|
// (already commented out in EXACUS)...
|
||||||
// NiX_precond(!(NiX::in_zero(x) && NiX::singleton(x)));
|
// NiX_precond(!(NiX::in_zero(x) && NiX::singleton(x)));
|
||||||
x = CGAL::abs(x);
|
x = CGAL::abs(x);
|
||||||
return CORE::ceilLg(x.m()+x.err())+x.exp()*CORE::CHUNK_BIT;
|
return CORE::ceilLg(CORE::BigInt(x.m()+x.err()))+x.exp()*CORE::CHUNK_BIT;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ simple_bound_between(const Algebraic_real& a,
|
||||||
final_mantissa = final_mantissa << 1;
|
final_mantissa = final_mantissa << 1;
|
||||||
final_mantissa++;
|
final_mantissa++;
|
||||||
y_log--;
|
y_log--;
|
||||||
x_m = x_m==0 ? 0 : x_m & ((Integer(1) << x_log) - 1); //x_m - CGAL::ipower(Integer(2),x_log);
|
x_m = x_m==0 ? 0 : Integer(x_m & ((Integer(1) << x_log) - 1)); //x_m - CGAL::ipower(Integer(2),x_log);
|
||||||
x_log = x_m==0 ? -1 : CGAL::internal::floor_log2_abs(x_m);
|
x_log = x_m==0 ? -1 : CGAL::internal::floor_log2_abs(x_m);
|
||||||
}
|
}
|
||||||
final_mantissa = final_mantissa << 1;
|
final_mantissa = final_mantissa << 1;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Algebraic_kernel_for_circles
|
Algebraic_kernel_for_circles
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
|
CGAL_Core
|
||||||
Filtered_kernel
|
Filtered_kernel
|
||||||
Installation
|
Installation
|
||||||
Interval_support
|
Interval_support
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Algebraic_kernel_for_spheres
|
Algebraic_kernel_for_spheres
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
|
CGAL_Core
|
||||||
Filtered_kernel
|
Filtered_kernel
|
||||||
Installation
|
Installation
|
||||||
Interval_support
|
Interval_support
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Alpha_shapes_2
|
Alpha_shapes_2
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Hash_map
|
Hash_map
|
||||||
Homogeneous_kernel
|
Homogeneous_kernel
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Alpha_shapes_3
|
Alpha_shapes_3
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Filtered_kernel
|
Filtered_kernel
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ Alpha_wrap_3
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
BGL
|
BGL
|
||||||
Box_intersection_d
|
Box_intersection_d
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Distance_2
|
Distance_2
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
#ifdef CGAL_USE_BOOST_MP
|
#ifdef CGAL_USE_BOOST_MP
|
||||||
|
|
||||||
|
#ifdef CGAL_USE_CORE
|
||||||
|
#include <CGAL/CORE_arithmetic_kernel.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
//Currently already included in boost_mp.h
|
//Currently already included in boost_mp.h
|
||||||
//#include <boost/multiprecision/cpp_int.hpp>
|
//#include <boost/multiprecision/cpp_int.hpp>
|
||||||
//#ifdef CGAL_USE_GMP
|
//#ifdef CGAL_USE_GMP
|
||||||
|
|
@ -26,20 +30,29 @@
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
// FIXME: the could be several kernels based on Boost.Multiprecision.
|
// FIXME: the could be several kernels based on Boost.Multiprecision.
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
/** \ingroup CGAL_Arithmetic_kernel
|
/** \ingroup CGAL_Arithmetic_kernel
|
||||||
* \brief The Boost.Multiprecision set of exact number types
|
* \brief The Boost.Multiprecision set of exact number types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(CGAL_USE_CORE) || defined(CGAL_CORE_USE_GMP_BACKEND)
|
||||||
struct BOOST_cpp_arithmetic_kernel : internal::Arithmetic_kernel_base {
|
struct BOOST_cpp_arithmetic_kernel : internal::Arithmetic_kernel_base {
|
||||||
typedef boost::multiprecision::cpp_int Integer;
|
typedef boost::multiprecision::cpp_int Integer;
|
||||||
typedef boost::multiprecision::cpp_rational Rational;
|
typedef boost::multiprecision::cpp_rational Rational;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
typedef CORE_arithmetic_kernel BOOST_cpp_arithmetic_kernel;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CGAL_USE_GMP
|
#ifdef CGAL_USE_GMP
|
||||||
|
#if !defined(CGAL_USE_CORE) || !defined(CGAL_CORE_USE_GMP_BACKEND)
|
||||||
struct BOOST_gmp_arithmetic_kernel : internal::Arithmetic_kernel_base {
|
struct BOOST_gmp_arithmetic_kernel : internal::Arithmetic_kernel_base {
|
||||||
typedef boost::multiprecision::mpz_int Integer;
|
typedef boost::multiprecision::mpz_int Integer;
|
||||||
typedef boost::multiprecision::mpq_rational Rational;
|
typedef boost::multiprecision::mpq_rational Rational;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
typedef CORE_arithmetic_kernel BOOST_gmp_arithmetic_kernel;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4, class T5>
|
template <class T1, class T2, class T3, class T4, class T5>
|
||||||
|
|
|
||||||
|
|
@ -55,14 +55,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct Get_arithmetic_kernel<CORE::BigInt>{
|
|
||||||
typedef CORE_arithmetic_kernel Arithmetic_kernel;
|
|
||||||
};
|
|
||||||
template <>
|
|
||||||
struct Get_arithmetic_kernel<CORE::BigRat>{
|
|
||||||
typedef CORE_arithmetic_kernel Arithmetic_kernel;
|
|
||||||
};
|
|
||||||
template <>
|
template <>
|
||||||
struct Get_arithmetic_kernel<CORE::Expr>{
|
struct Get_arithmetic_kernel<CORE::Expr>{
|
||||||
typedef CORE_arithmetic_kernel Arithmetic_kernel;
|
typedef CORE_arithmetic_kernel Arithmetic_kernel;
|
||||||
|
|
@ -74,6 +66,8 @@ struct Get_arithmetic_kernel<CORE::BigFloat>{
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#include <CGAL/BOOST_MP_arithmetic_kernel.h>
|
||||||
|
|
||||||
#endif // CGAL_USE_CORE
|
#endif // CGAL_USE_CORE
|
||||||
|
|
||||||
#endif // CGAL_CORE_ARITHMETIC_KERNEL_H
|
#endif // CGAL_CORE_ARITHMETIC_KERNEL_H
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#include <CGAL/Arrangement_with_history_2.h>
|
#include <CGAL/Arrangement_with_history_2.h>
|
||||||
#include <CGAL/Cartesian.h>
|
#include <CGAL/Cartesian.h>
|
||||||
#include <CGAL/Arr_default_dcel.h>
|
|
||||||
#include <CGAL/Arr_segment_traits_2.h>
|
#include <CGAL/Arr_segment_traits_2.h>
|
||||||
#include <CGAL/Arr_linear_traits_2.h>
|
#include <CGAL/Arr_linear_traits_2.h>
|
||||||
#include <CGAL/Arr_polyline_traits_2.h>
|
#include <CGAL/Arr_polyline_traits_2.h>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "IntersectCurves.h"
|
#include "IntersectCurves.h"
|
||||||
#include "ArrangementTypes.h"
|
#include "ArrangementTypes.h"
|
||||||
#include <boost/function_output_iterator.hpp>
|
#include <boost/iterator/function_output_iterator.hpp>
|
||||||
|
|
||||||
|
|
||||||
template <typename Traits_>
|
template <typename Traits_>
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ operator()(const Point_2& p, const X_monotone_curve_2& curve) const {
|
||||||
auto points = painterOstream.getPointsList(curve);
|
auto points = painterOstream.getPointsList(curve);
|
||||||
|
|
||||||
QPoint p_viewport =
|
QPoint p_viewport =
|
||||||
view->mapFromScene(QPointF{p.x().doubleValue(), p.y().doubleValue()});
|
view->mapFromScene(QPointF{CGAL::to_double(p.x()), CGAL::to_double(p.y())});
|
||||||
|
|
||||||
double min_dist = (std::numeric_limits<double>::max)();
|
double min_dist = (std::numeric_limits<double>::max)();
|
||||||
for (auto& vec : points) {
|
for (auto& vec : points) {
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,10 @@ class Arrangement_2 { ... };
|
||||||
|
|
||||||
An instance of this template represents an arrangement embedded in the
|
An instance of this template represents an arrangement embedded in the
|
||||||
plane. When the template is instantiated, the `GeometryTraits`
|
plane. When the template is instantiated, the `GeometryTraits`
|
||||||
parameter must be substituted with a type that defines a set of
|
parameter must be substituted by a type that defines a set of
|
||||||
geometric-object types, such as point and curve, and a set of
|
geometric-object types, such as point and curve, and a set of
|
||||||
operations on objects of these types (see Section \ref
|
operations on objects of these types (see Section \ref
|
||||||
aos_sec-geom_traits); the `Dcel` parameter must be substituted with a
|
aos_sec-geom_traits); the `Dcel` parameter must be substituted by a
|
||||||
type that represents a doubly-connected edge list (\dcel) data
|
type that represents a doubly-connected edge list (\dcel) data
|
||||||
structure. It defines types of topological objects, such as vertices,
|
structure. It defines types of topological objects, such as vertices,
|
||||||
edges, and faces, and the operations required to maintain the
|
edges, and faces, and the operations required to maintain the
|
||||||
|
|
@ -91,7 +91,7 @@ An instance of this template represents a two-dimensional arrangement
|
||||||
embedded in a surface in three dimensional space. When the template is
|
embedded in a surface in three dimensional space. When the template is
|
||||||
instantiated, the `GeometryTraits` parameter must be substituted as
|
instantiated, the `GeometryTraits` parameter must be substituted as
|
||||||
described above; the `TopologyTraits` parameter must be substituted
|
described above; the `TopologyTraits` parameter must be substituted
|
||||||
with a type that deals with the topology of the surface (see Section
|
by a type that deals with the topology of the surface (see Section
|
||||||
\ref aos_sec-topol_traits). In particular, it maintains a
|
\ref aos_sec-topol_traits). In particular, it maintains a
|
||||||
representation of the arrangement graph embedded in the surface using
|
representation of the arrangement graph embedded in the surface using
|
||||||
a doubly-connected edge list (\dcel) data-structure suitable for
|
a doubly-connected edge list (\dcel) data-structure suitable for
|
||||||
|
|
@ -390,7 +390,7 @@ the `Arrangement_2` class template; their description follows.
|
||||||
|
|
||||||
<UL>
|
<UL>
|
||||||
|
|
||||||
<LI>The `Traits` template-parameter should be instantiated with a
|
<LI>The `Traits` template-parameter should be substituted by a
|
||||||
model of the `ArrangementBasicTraits_2` concept and optionally
|
model of the `ArrangementBasicTraits_2` concept and optionally
|
||||||
additional geometry traits concepts. A model of the
|
additional geometry traits concepts. A model of the
|
||||||
`ArrangementBasicTraits_2` concept defines the types of
|
`ArrangementBasicTraits_2` concept defines the types of
|
||||||
|
|
@ -415,14 +415,15 @@ the `Arrangement_2` class template; their description follows.
|
||||||
rational functions. We exemplify the usage of these traits classes
|
rational functions. We exemplify the usage of these traits classes
|
||||||
in Section \ref aos_sec-geom_traits.
|
in Section \ref aos_sec-geom_traits.
|
||||||
|
|
||||||
<LI>The `Dcel` template-parameter should be instantiated with a class
|
<LI>The `Dcel` template-parameter should be substituted by a class
|
||||||
that models the `ArrangementDcel` concept, which is used to represent
|
that models the `ArrangementDcel` concept, which is used to represent
|
||||||
the topological layout of the arrangement. This parameter is
|
the topological layout of the arrangement. This parameter is
|
||||||
substituted with `Arr_default_dcel<Traits>` by default, and
|
substituted by `Arr_default_dcel<Traits>` by default, and
|
||||||
we use this default value in this and in the following three
|
we use this default value in this and in the following three
|
||||||
sections. However, in many applications it is necessary to
|
sections. However, in many applications it is necessary to extend the
|
||||||
extend the \dcel features. This is done by substituting the
|
\dcel features. This is done by substituting the `Dcel` parameter with
|
||||||
`Dcel` parameter with a different type; see Section \ref arr_ssecex_dcel
|
a different type (typically, a different instance of the
|
||||||
|
`Arr_dcel<>` class template); see Section \ref arr_ssecex_dcel
|
||||||
for further explanations and examples.
|
for further explanations and examples.
|
||||||
</UL>
|
</UL>
|
||||||
|
|
||||||
|
|
@ -1001,7 +1002,7 @@ segments common to all examples that do not construct new geometric
|
||||||
objects. They are kept in the header file
|
objects. They are kept in the header file
|
||||||
`arr_inexact_construction_segments.h`. In these examples the `Traits`
|
`arr_inexact_construction_segments.h`. In these examples the `Traits`
|
||||||
parameter of the `Arrangement_2<Traits, Dcel>` class template is
|
parameter of the `Arrangement_2<Traits, Dcel>` class template is
|
||||||
substituted with an instance of the
|
substituted by an instance of the
|
||||||
`Arr_non_caching_segment_traits_2<Kernel>` class template. The
|
`Arr_non_caching_segment_traits_2<Kernel>` class template. The
|
||||||
`Arr_non_caching_segment_traits_2` class template is instantiated with
|
`Arr_non_caching_segment_traits_2` class template is instantiated with
|
||||||
the predefined kernel that evaluates predicates in an exact manner,
|
the predefined kernel that evaluates predicates in an exact manner,
|
||||||
|
|
@ -1438,7 +1439,7 @@ vary according to the user choice.} for answering queries:
|
||||||
|
|
||||||
The landmark strategy requires that the type of the attached
|
The landmark strategy requires that the type of the attached
|
||||||
arrangement be an instance of the `Arrangement_2<Traits,Dcel>` class
|
arrangement be an instance of the `Arrangement_2<Traits,Dcel>` class
|
||||||
template, where the `Traits` parameter is substituted with a
|
template, where the `Traits` parameter is substituted by a
|
||||||
geometry-traits class that models the `ArrangementLandmarkTraits_2`
|
geometry-traits class that models the `ArrangementLandmarkTraits_2`
|
||||||
concept, which refines the basic `ArrangementBasicTraits_2` concept;
|
concept, which refines the basic `ArrangementBasicTraits_2` concept;
|
||||||
see Section \ref aos_sssec-tr_landmarks_concept for details. Most
|
see Section \ref aos_sssec-tr_landmarks_concept for details. Most
|
||||||
|
|
@ -1742,7 +1743,7 @@ query results, and insert \f$c\f$ at its proper
|
||||||
location.\cgalFootnote{The \cgalFootnoteCode{CGAL::insert_non_intersecting_curve<>()}
|
location.\cgalFootnote{The \cgalFootnoteCode{CGAL::insert_non_intersecting_curve<>()}
|
||||||
function template, as all other functions reviewed in this section, is
|
function template, as all other functions reviewed in this section, is
|
||||||
parameterized by an arrangement type and a point-location type (The
|
parameterized by an arrangement type and a point-location type (The
|
||||||
latter must be substituted with a model of the
|
latter must be substituted by a model of the
|
||||||
`ArrangementPointLocation_2` concept).} The insertion operation thus
|
`ArrangementPointLocation_2` concept).} The insertion operation thus
|
||||||
hardly requires any geometric operations on top of the ones needed to
|
hardly requires any geometric operations on top of the ones needed to
|
||||||
answer the point-location queries. Moreover, it is sufficient that the
|
answer the point-location queries. Moreover, it is sufficient that the
|
||||||
|
|
@ -1846,7 +1847,7 @@ condition. Consider the call \link CGAL::insert<>() `insert(arr, c,
|
||||||
pl)`\endlink, where \f$c\f$ is not necessarily \f$x\f$-monotone. In
|
pl)`\endlink, where \f$c\f$ is not necessarily \f$x\f$-monotone. In
|
||||||
this case the type of `arr` must be an instance of the
|
this case the type of `arr` must be an instance of the
|
||||||
`Arrangement_2<Traits, Dcel>` class template, where the `Traits`
|
`Arrangement_2<Traits, Dcel>` class template, where the `Traits`
|
||||||
template parameter is substituted with a traits class that models the
|
template parameter is substituted by a traits class that models the
|
||||||
concept `ArrangementTraits_2`, which refines the
|
concept `ArrangementTraits_2`, which refines the
|
||||||
`ArrangementXMonotoneTraits_2` concept. It has to define an additional
|
`ArrangementXMonotoneTraits_2` concept. It has to define an additional
|
||||||
\link ArrangementTraits_2::Curve_2 `Curve_2`\endlink type, which may
|
\link ArrangementTraits_2::Curve_2 `Curve_2`\endlink type, which may
|
||||||
|
|
@ -2267,7 +2268,7 @@ accepts the name of an input file that contains the plain-text
|
||||||
description of the geometric objects and an output iterator for
|
description of the geometric objects and an output iterator for
|
||||||
storing the newly constructed objects. When the function is
|
storing the newly constructed objects. When the function is
|
||||||
instantiated, the first template parameter, namely `Type`, must be
|
instantiated, the first template parameter, namely `Type`, must be
|
||||||
substituted with the type of objects to read. It is assumed that an
|
substituted by the type of objects to read. It is assumed that an
|
||||||
extractor operator (`>>`) that extracts objects of the given type from
|
extractor operator (`>>`) that extracts objects of the given type from
|
||||||
the input stream is available. The listing of the function template,
|
the input stream is available. The listing of the function template,
|
||||||
which is defined in the file `read_objects.h`, is omitted here
|
which is defined in the file `read_objects.h`, is omitted here
|
||||||
|
|
@ -2704,7 +2705,7 @@ All the free functions that operate on arrangements of bounded curves
|
||||||
of unbounded curves. For example, consider a container of linear
|
of unbounded curves. For example, consider a container of linear
|
||||||
curves that has to be inserted into an arrangement object, the type of
|
curves that has to be inserted into an arrangement object, the type of
|
||||||
which is an instance of the `Arrangement_2<Traits,Dcel>` class
|
which is an instance of the `Arrangement_2<Traits,Dcel>` class
|
||||||
template, where the `Traits` parameter is substituted with the traits
|
template, where the `Traits` parameter is substituted by the traits
|
||||||
class that handles linear curves; see Section \ref
|
class that handles linear curves; see Section \ref
|
||||||
arr_sssectr_linear. You can do it incrementally; namely, insert the
|
arr_sssectr_linear. You can do it incrementally; namely, insert the
|
||||||
curves one by one as follows:
|
curves one by one as follows:
|
||||||
|
|
@ -3485,7 +3486,7 @@ point-location strategy.
|
||||||
The type of an arrangement associated with the landmark point-location
|
The type of an arrangement associated with the landmark point-location
|
||||||
strategy (see Section \ref arr_ssecpl) must be an instance of the
|
strategy (see Section \ref arr_ssecpl) must be an instance of the
|
||||||
`Arrangement_on_surface_2<GeomTraits, TopolTraits>` class template,
|
`Arrangement_on_surface_2<GeomTraits, TopolTraits>` class template,
|
||||||
where the `GeomTraits` parameter is substituted with a model of the
|
where the `GeomTraits` parameter is substituted by a model of the
|
||||||
concept `ArrangementLandmarkTraits_2`. (Naturally, it can also model
|
concept `ArrangementLandmarkTraits_2`. (Naturally, it can also model
|
||||||
either the `ArrangementXMonotoneTraits_2` concept or the
|
either the `ArrangementXMonotoneTraits_2` concept or the
|
||||||
`ArrangementTraits_2` concept.) The `ArrangementLandmarkTraits_2`
|
`ArrangementTraits_2` concept.) The `ArrangementLandmarkTraits_2`
|
||||||
|
|
@ -4541,7 +4542,7 @@ PkgBooleanSetOperations2Ref. Note that it is not a model of the
|
||||||
computations with square root numbers, which makes it attractive for
|
computations with square root numbers, which makes it attractive for
|
||||||
arrangements induced by line segments, circular arcs, and whole
|
arrangements induced by line segments, circular arcs, and whole
|
||||||
circles. When the traits class-template is instantiated, the `Kernel`
|
circles. When the traits class-template is instantiated, the `Kernel`
|
||||||
template parameter must be substituted with a geometric kernel that
|
template parameter must be substituted by a geometric kernel that
|
||||||
models the `Kernel` concept. Always plug in a kernel that uses a
|
models the `Kernel` concept. Always plug in a kernel that uses a
|
||||||
rational number type, such as
|
rational number type, such as
|
||||||
`Exact_predicates_exact_constructions_kernel`. Observe that the nested
|
`Exact_predicates_exact_constructions_kernel`. Observe that the nested
|
||||||
|
|
@ -4722,20 +4723,20 @@ follows:
|
||||||
|
|
||||||
<UL>
|
<UL>
|
||||||
|
|
||||||
<LI>The `RatKernel` template parameter must be substituted with a
|
<LI>The `RatKernel` template parameter must be substituted by a
|
||||||
geometric kernel whose field type is an exact rational type. It is
|
geometric kernel whose field type is an exact rational type. It is
|
||||||
used to define basic geometric entities (e.g., a line segment or a
|
used to define basic geometric entities (e.g., a line segment or a
|
||||||
circle) with rational coefficients. Typically we use one of the
|
circle) with rational coefficients. Typically we use one of the
|
||||||
standard \cgal kernels, instantiated with the number type
|
standard \cgal kernels, instantiated with the number type
|
||||||
`NtTraits::Rational` (see below).
|
`NtTraits::Rational` (see below).
|
||||||
|
|
||||||
<LI>The `AlgKernel` template parameter must be substituted with a
|
<LI>The `AlgKernel` template parameter must be substituted by a
|
||||||
geometric kernel whose field type is an exact algebraic type. It is
|
geometric kernel whose field type is an exact algebraic type. It is
|
||||||
used to define points with algebraic coordinates. Typically, we use
|
used to define points with algebraic coordinates. Typically, we use
|
||||||
one of the standard \cgal kernels, instantiated with the number type
|
one of the standard \cgal kernels, instantiated with the number type
|
||||||
`NtTraits::Algebraic` (see below).
|
`NtTraits::Algebraic` (see below).
|
||||||
|
|
||||||
<LI>The `NtTraits` template parameter must be substituted with a type
|
<LI>The `NtTraits` template parameter must be substituted by a type
|
||||||
that encapsulates all the numeric operations needed for performing
|
that encapsulates all the numeric operations needed for performing
|
||||||
geometric computation carried out by the geometric traits class. It
|
geometric computation carried out by the geometric traits class. It
|
||||||
defines the `Integer`, `Rational`, and `Algebraic` number-types, and
|
defines the `Integer`, `Rational`, and `Algebraic` number-types, and
|
||||||
|
|
@ -4916,7 +4917,7 @@ provided by the traits in form of functors.
|
||||||
|
|
||||||
When the `Arr_rational_function_traits_2<AlgebraicKernel_d_1>` class
|
When the `Arr_rational_function_traits_2<AlgebraicKernel_d_1>` class
|
||||||
template is instantiated, the template parameter must be substituted
|
template is instantiated, the template parameter must be substituted
|
||||||
with a model of the `AlgebraicKernel_d_1` concept. Models of this
|
by a model of the `AlgebraicKernel_d_1` concept. Models of this
|
||||||
concept, such as the `Algebraic_kernel_d_1<Coefficient>` class
|
concept, such as the `Algebraic_kernel_d_1<Coefficient>` class
|
||||||
template provided by the package \ref PkgAlgebraicFoundations are
|
template provided by the package \ref PkgAlgebraicFoundations are
|
||||||
meant to support algebraic functionalities on univariate polynomials
|
meant to support algebraic functionalities on univariate polynomials
|
||||||
|
|
@ -5176,11 +5177,11 @@ polynomial. Currently supported integral number types are `Gmpz`,
|
||||||
statements included in the header file `integer_type.h`, the listings
|
statements included in the header file `integer_type.h`, the listings
|
||||||
of which are omitted here. This header file is used by the two example
|
of which are omitted here. This header file is used by the two example
|
||||||
programs listed in this section. The template parameter `Coefficient`
|
programs listed in this section. The template parameter `Coefficient`
|
||||||
can be substituted in addition with an instance of the
|
can be substituted in addition by an instance of the
|
||||||
`Sqrt_extension<A,B>` class template, where the template parameters
|
`Sqrt_extension<A,B>` class template, where the template parameters
|
||||||
`NT` and `Root` are substituted in turn with one of the integral
|
`NT` and `Root` are substituted in turn by one of the integral
|
||||||
number types above. Finally, the template parameter `Coefficient` can
|
number types above. Finally, the template parameter `Coefficient` can
|
||||||
be substituted also with a rational number type, where the type of the
|
be substituted also by a rational number type, where the type of the
|
||||||
numerator and denominator is one of the types above.
|
numerator and denominator is one of the types above.
|
||||||
|
|
||||||
The type \link Arr_algebraic_segment_traits_2::Curve_2
|
The type \link Arr_algebraic_segment_traits_2::Curve_2
|
||||||
|
|
@ -5487,7 +5488,7 @@ decorator used to attach a data field to curves and to
|
||||||
\f$x\f$-monotone curves. It is a class template named
|
\f$x\f$-monotone curves. It is a class template named
|
||||||
`Arr_curve_data_traits_2<BaseTraits, XMonotoneCurveData, Merge,
|
`Arr_curve_data_traits_2<BaseTraits, XMonotoneCurveData, Merge,
|
||||||
CurveData, Convert>` parameterized by a base-traits class, which must
|
CurveData, Convert>` parameterized by a base-traits class, which must
|
||||||
be substituted with one of the geometric traits models described in
|
be substituted by one of the geometric traits models described in
|
||||||
the previous subsections or with a user-defined traits model, when the
|
the previous subsections or with a user-defined traits model, when the
|
||||||
decorator is instantiated. The curve-data decorator derives from the
|
decorator is instantiated. The curve-data decorator derives from the
|
||||||
base-traits class, and in particular inherits its \link
|
base-traits class, and in particular inherits its \link
|
||||||
|
|
@ -5882,12 +5883,12 @@ applications.
|
||||||
|
|
||||||
All examples presented so far use the default \dcel; namely, they
|
All examples presented so far use the default \dcel; namely, they
|
||||||
employ the `Arr_default_dcel<Traits>` instance. This is done
|
employ the `Arr_default_dcel<Traits>` instance. This is done
|
||||||
implicitly, as an instance of this class template serves as the
|
implicitly, as this instance of the `Arr_default_dcel` class template
|
||||||
default parameter for the `Arrangement_2` class template; see Section
|
serves as the default parameter for the `Arrangement_2` class
|
||||||
\ref aos_ssec-basic-arr_class. The default \dcel class associates
|
template; see Section \ref aos_ssec-basic-arr_class. The default \dcel
|
||||||
points with vertices and \f$x\f$-monotone curves with halfedges, but
|
class associates points with vertices and \f$x\f$-monotone curves with
|
||||||
nothing more. In this section we show how to use alternative
|
halfedges, but nothing more. In this section we show how to use
|
||||||
\dcel types to extend the desired \dcel records.
|
alternative \dcel types to extend the desired \dcel records.
|
||||||
|
|
||||||
<!-- ------------------------------------------------------------------------- -->
|
<!-- ------------------------------------------------------------------------- -->
|
||||||
\subsubsection arr_sssecex_dcel_face Extending the DCEL Faces
|
\subsubsection arr_sssecex_dcel_face Extending the DCEL Faces
|
||||||
|
|
@ -6107,7 +6108,7 @@ ovl_traits)`\endlink constructs the arrangement `arr_o`, which is the
|
||||||
overlay of two input arrangement `arr_r` and `arr_b`. All three
|
overlay of two input arrangement `arr_r` and `arr_b`. All three
|
||||||
arrangements must use the same geometric primitives. In other words,
|
arrangements must use the same geometric primitives. In other words,
|
||||||
their types are instances of the `Arrangement_2<Traits,Dcel>` class
|
their types are instances of the `Arrangement_2<Traits,Dcel>` class
|
||||||
template, where the `Traits` parameter is substituted with three
|
template, where the `Traits` parameter is substituted by three
|
||||||
geometry-traits classes, respectively. The geometry-traits classes of
|
geometry-traits classes, respectively. The geometry-traits classes of
|
||||||
the input arrangements must be convertible to the geometry-traits
|
the input arrangements must be convertible to the geometry-traits
|
||||||
class of the resulting arrangement.\cgalFootnote{It is sufficient that
|
class of the resulting arrangement.\cgalFootnote{It is sufficient that
|
||||||
|
|
@ -6116,17 +6117,17 @@ of arrangements derive from a common ancestor that models the
|
||||||
geometry-traits concept.} Typically, all three arrangements use the
|
geometry-traits concept.} Typically, all three arrangements use the
|
||||||
same geometry-traits class.
|
same geometry-traits class.
|
||||||
|
|
||||||
The `overlay()` function template is suitable for
|
The `overlay()` function template is suitable for arrangements that do
|
||||||
arrangements that do not store any additional data with their
|
not store any additional data with their \dcel records; namely,
|
||||||
\dcel records; namely, arrangements defined using an instance of
|
arrangements defined using the default \dcel, which is the instance
|
||||||
the default \dcel class-template `Arr_default_dcel`. Typically,
|
`Arr_default_dcel<Traits>`. Typically, the overlay arrangement in this
|
||||||
the overlay arrangement in this case does not store extra data with
|
case does not store extra data with its \dcel records as well. (If it
|
||||||
its \dcel records as well (or if it does, the additional
|
does, the additional data-fields cannot be computed by the overlay
|
||||||
data-fields cannot be computed by the overlay operation). The overlay
|
operation in this case.) The overlay arrangement is equivalent to the
|
||||||
arrangement is equivalent to the arrangement induced by all curves of
|
arrangement induced by all curves of `arr_r` and `arr_b`. Indeed, it
|
||||||
`arr_r` and `arr_b`. Indeed, it is possible to obtain the same result
|
is possible to obtain the same result using the standard
|
||||||
using the standard insertion-operations instead, but, as mentioned
|
insertion-operations instead, but, as mentioned above, this is less
|
||||||
above, this is less efficient.
|
efficient.
|
||||||
|
|
||||||
<!-- ------------------------------------------------------------------------- -->
|
<!-- ------------------------------------------------------------------------- -->
|
||||||
\cgalFigureBegin{aos_figex_overlay,overlay.png}
|
\cgalFigureBegin{aos_figex_overlay,overlay.png}
|
||||||
|
|
@ -6168,7 +6169,7 @@ arrangement that results from overlaying two face-extended
|
||||||
arrangements typically also stores additional data-fields with its
|
arrangements typically also stores additional data-fields with its
|
||||||
faces. The types of such arrangements, for example, could be instances
|
faces. The types of such arrangements, for example, could be instances
|
||||||
of the `Arrangement_2<Traits,Dcel>` class template, where the `Dcel`
|
of the `Arrangement_2<Traits,Dcel>` class template, where the `Dcel`
|
||||||
parameters are substituted with instances of the
|
parameters are substituted by instances of the
|
||||||
`Arr_face_extended_dcel` class template (see Section \ref
|
`Arr_face_extended_dcel` class template (see Section \ref
|
||||||
arr_sssecex_dcel_face). The data field that is attached to an overlay
|
arr_sssecex_dcel_face). The data field that is attached to an overlay
|
||||||
face can be computed from the data fields of the two faces (in `arr_r`
|
face can be computed from the data fields of the two faces (in `arr_r`
|
||||||
|
|
@ -6178,7 +6179,7 @@ data fields with all their \dcel records typically also stores
|
||||||
additional data-fields with all its \dcel records. The types of
|
additional data-fields with all its \dcel records. The types of
|
||||||
such arrangements, for example, could be instances of the
|
such arrangements, for example, could be instances of the
|
||||||
`Arrangement_2<Traits,Dcel>` class template, where the `Dcel`
|
`Arrangement_2<Traits,Dcel>` class template, where the `Dcel`
|
||||||
parameters are substituted with instances of the `Arr_extended_dcel`
|
parameters are substituted by instances of the `Arr_extended_dcel`
|
||||||
class template (see Section \ref arr_sssecex_dcel_all). The data field
|
class template (see Section \ref arr_sssecex_dcel_all). The data field
|
||||||
attached to an overlay feature can be computed from the data fields of
|
attached to an overlay feature can be computed from the data fields of
|
||||||
the two features (in `arr_r` and `arr_b`) that induce the overlay
|
the two features (in `arr_r` and `arr_b`) that induce the overlay
|
||||||
|
|
@ -6193,7 +6194,7 @@ of the overlay traits can be an instance of the class template
|
||||||
`Arr_face_overlay_traits<ArrangementR,ArrangementB,ArrangementO,OverlayFaceData>`,
|
`Arr_face_overlay_traits<ArrangementR,ArrangementB,ArrangementO,OverlayFaceData>`,
|
||||||
which models the concept `OverlayTraits`. An object of this type
|
which models the concept `OverlayTraits`. An object of this type
|
||||||
operates on face-extended arrangements. When instantiated, the
|
operates on face-extended arrangements. When instantiated, the
|
||||||
`OverlayFaceData` parameter must be substituted with a functor that is
|
`OverlayFaceData` parameter must be substituted by a functor that is
|
||||||
capable of combining two face-data fields of types
|
capable of combining two face-data fields of types
|
||||||
`ArrangementR::Dcel::Face_data` and `ArrangementB::Dcel::Face_data`
|
`ArrangementR::Dcel::Face_data` and `ArrangementB::Dcel::Face_data`
|
||||||
and computing the output `ArrangementO::Dcel::Face_data` object. The
|
and computing the output `ArrangementO::Dcel::Face_data` object. The
|
||||||
|
|
@ -6208,7 +6209,7 @@ flag. A polygon is represented as a <em>marked</em> arrangement face
|
||||||
(whose flag is set). The example uses an instance of the
|
(whose flag is set). The example uses an instance of the
|
||||||
`Arr_face_overlay_traits<ArrR,ArrB,ArrO,OverlayFaceData>` class
|
`Arr_face_overlay_traits<ArrR,ArrB,ArrO,OverlayFaceData>` class
|
||||||
template as the face-overlay traits class where the `OverlayFaceData`
|
template as the face-overlay traits class where the `OverlayFaceData`
|
||||||
template parameter is substituted with a functor that simply performs
|
template parameter is substituted by a functor that simply performs
|
||||||
a logical <em>and</em> operation on Boolean flags. As a result, a face
|
a logical <em>and</em> operation on Boolean flags. As a result, a face
|
||||||
in the overlay arrangement is marked only when it corresponds to an
|
in the overlay arrangement is marked only when it corresponds to an
|
||||||
overlapping region of two marked faces in the input
|
overlapping region of two marked faces in the input
|
||||||
|
|
@ -6406,12 +6407,12 @@ between these curves and the arrangement edges they induce. Similarly,
|
||||||
the `Arrangement_with_history_2<GeometryTraits,Dcel>` class-template
|
the `Arrangement_with_history_2<GeometryTraits,Dcel>` class-template
|
||||||
extends the `Arrangement_2<GeometryTraits,Dcel>` class template. The
|
extends the `Arrangement_2<GeometryTraits,Dcel>` class template. The
|
||||||
`GeometryTraits` template parameter, of either class templates, must
|
`GeometryTraits` template parameter, of either class templates, must
|
||||||
be substituted with a model of the `ArrangementTraits_2` concept; see
|
be substituted by a model of the `ArrangementTraits_2` concept; see
|
||||||
Section \ref aos_ssec-insert_gen. It should define the \link
|
Section \ref aos_ssec-insert_gen. It should define the \link
|
||||||
ArrangementTraits_2::Curve_2 `Curve_2`\endlink type and support its
|
ArrangementTraits_2::Curve_2 `Curve_2`\endlink type and support its
|
||||||
subdivision into \link ArrangementBasicTraits_2::X_monotone_curve_2
|
subdivision into \link ArrangementBasicTraits_2::X_monotone_curve_2
|
||||||
`X_monotone_curve_2`\endlink objects, among the others. The `Dcel`
|
`X_monotone_curve_2`\endlink objects, among the others. The `Dcel`
|
||||||
parameter must be substituted with a model of the `ArrangementDcel`
|
parameter must be substituted by a model of the `ArrangementDcel`
|
||||||
concept. You can use either the default \dcel class or an extended
|
concept. You can use either the default \dcel class or an extended
|
||||||
\dcel class (see Section \ref arr_ssecex_dcel) based on your needs. An
|
\dcel class (see Section \ref arr_ssecex_dcel) based on your needs. An
|
||||||
arrangement that support the cross-mapping mentioned above is referred
|
arrangement that support the cross-mapping mentioned above is referred
|
||||||
|
|
@ -6488,7 +6489,7 @@ iterators is \link Arrangement_with_history_2::Curve_2
|
||||||
Overlaying two arrangement-with-history objects is possible only if
|
Overlaying two arrangement-with-history objects is possible only if
|
||||||
their types are instances of the
|
their types are instances of the
|
||||||
`Arrangement_with_history_2<Traits,Dcel>` class template, where the
|
`Arrangement_with_history_2<Traits,Dcel>` class template, where the
|
||||||
respective `Traits` parameters are substituted with two traits classes
|
respective `Traits` parameters are substituted by two traits classes
|
||||||
that are convertible to one another. In this case, the resulting
|
that are convertible to one another. In this case, the resulting
|
||||||
arrangement stores a consolidated container of input curves, and
|
arrangement stores a consolidated container of input curves, and
|
||||||
automatically preserves the cross-mapping between the arrangement
|
automatically preserves the cross-mapping between the arrangement
|
||||||
|
|
@ -6668,15 +6669,15 @@ a file.
|
||||||
\subsection arr_ssecarr_io_aux_data Arrangements with Auxiliary Data
|
\subsection arr_ssecarr_io_aux_data Arrangements with Auxiliary Data
|
||||||
<!-- ------------------------------------------------------------------------- -->
|
<!-- ------------------------------------------------------------------------- -->
|
||||||
|
|
||||||
\cgalAdvancedBegin
|
\cgalAdvancedBegin The inserter and extractor both ignore any
|
||||||
The inserter and extractor both ignore any auxiliary data stored with
|
auxiliary data stored with the arrangement features. Thus, they are
|
||||||
the arrangement features. Thus, they are ideal for arrangements
|
ideal for arrangements instantiated using the default \dcel, which is
|
||||||
instantiated using the `Arr_default_dcel` class.
|
the instance `Arr_default_dcel<Traits>`. However, as explained in
|
||||||
However, as explained in Section \ref arr_ssecex_dcel, one can easily
|
Section \ref arr_ssecex_dcel, one can easily extend the arrangement
|
||||||
extend the arrangement faces by using the `Arr_face_extended_dcel`
|
faces by using the `Arr_face_extended_dcel` template, extend all \dcel
|
||||||
template, or extend all \dcel records by using the `Arr_extended_dcel`
|
records by using the `Arr_extended_dcel` template, or use the
|
||||||
template. In such cases, it might be crucial that the auxiliary data fields
|
`Arr_dcel` template. In such cases, it might be crucial that the
|
||||||
are written to the file and read from there.
|
auxiliary data fields are written to the file and read from there.
|
||||||
|
|
||||||
The arrangement package includes the free functions
|
The arrangement package includes the free functions
|
||||||
`write(arr, os, formatter)`, which writes the arrangement `arr`
|
`write(arr, os, formatter)`, which writes the arrangement `arr`
|
||||||
|
|
@ -6973,7 +6974,7 @@ algorithm on a dual arrangement. It uses the functor template
|
||||||
information stored inside the faces. The functor implements a property
|
information stored inside the faces. The functor implements a property
|
||||||
map that utilizes the `data()` and `set_data()` member functions of the
|
map that utilizes the `data()` and `set_data()` member functions of the
|
||||||
extended face to update or obtain the property. When the property map
|
extended face to update or obtain the property. When the property map
|
||||||
is instantiated, the `Type` parameter must be substituted with the
|
is instantiated, the `Type` parameter must be substituted by the
|
||||||
same type that is used to extend the arrangement face; see Section
|
same type that is used to extend the arrangement face; see Section
|
||||||
\ref arr_sssecex_dcel_face. The functor template is defined in the
|
\ref arr_sssecex_dcel_face. The functor template is defined in the
|
||||||
header file `Extended_face_property_map.h` listed below.
|
header file `Extended_face_property_map.h` listed below.
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
* The `Arr_bounded_planar_topology_traits_2` template has two parameters:
|
* The `Arr_bounded_planar_topology_traits_2` template has two parameters:
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI>The `GeometryTraits_2` template-parameter should be instantiated with
|
* <LI>The `GeometryTraits_2` template-parameter should be substituted by
|
||||||
* a model of the `ArrangementBasicTraits_2` concept. The traits
|
* a model of the `ArrangementBasicTraits_2` concept. The traits
|
||||||
* class defines the types of \f$x\f$-monotone curves and two-dimensional
|
* class defines the types of \f$x\f$-monotone curves and two-dimensional
|
||||||
* points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
* points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
||||||
* `ArrangementBasicTraits_2::Point_2`,
|
* `ArrangementBasicTraits_2::Point_2`,
|
||||||
* respectively, and supports basic geometric predicates on them.
|
* respectively, and supports basic geometric predicates on them.
|
||||||
* <LI>The `Dcel` template-parameter should be instantiated with
|
* <LI>The `Dcel` template-parameter should be substituted by
|
||||||
* a class that is a model of the `ArrangementDcel` concept. The
|
* a class that is a model of the `ArrangementDcel` concept. The
|
||||||
* value of this parameter is by default
|
* value of this parameter is by default
|
||||||
* `Arr_default_dcel<Traits>`.
|
* `Arr_default_dcel<Traits>`.
|
||||||
|
|
|
||||||
|
|
@ -57,17 +57,17 @@ namespace CGAL {
|
||||||
* algebraic number of degree \f$d\f$ if there exist a polynomial \f$ p\f$ with
|
* algebraic number of degree \f$d\f$ if there exist a polynomial \f$ p\f$ with
|
||||||
* <I>integer</I> coefficient of degree \f$d\f$ such that \f$p(\alpha) = 0\f$).
|
* <I>integer</I> coefficient of degree \f$d\f$ such that \f$p(\alpha) = 0\f$).
|
||||||
* We therefore require separate representations of the curve
|
* We therefore require separate representations of the curve
|
||||||
* coefficients and the point coordinates. The `NtTraits` should be instantiated
|
* coefficients and the point coordinates. The `NtTraits` should be substituted
|
||||||
* with a class that defines nested `Integer`, `Rational`, and `Algebraic` number
|
* by a class that defines nested `Integer`, `Rational`, and `Algebraic` number
|
||||||
* types and supports various operations on them, yielding certified computation
|
* types and supports various operations on them, yielding certified computation
|
||||||
* results (for example, it can convert rational numbers to algebraic numbers
|
* results (for example, it can convert rational numbers to algebraic numbers
|
||||||
* and can compute roots of polynomials with integer coefficients). The other
|
* and can compute roots of polynomials with integer coefficients). The other
|
||||||
* template parameters, `RatKernel` and `AlgKernel` should be geometric kernels
|
* template parameters, `RatKernel` and `AlgKernel` should be geometric kernels
|
||||||
* instantiated with the `NtTraits::Rational` and `NtTraits::Algebraic` number
|
* instantiated with the `NtTraits::Rational` and `NtTraits::Algebraic` number
|
||||||
* types, respectively. It is recommended instantiating the
|
* types, respectively. It is recommended substituting the
|
||||||
* `CORE_algebraic_number_traits` class as the `NtTraits` parameter, with
|
* `CORE_algebraic_number_traits` class for the `NtTraits` parameter, and
|
||||||
* `Cartesian<NtTraits::Rational>` and `Cartesian<NtTraits::Algebraic>`
|
* the `Cartesian<NtTraits::Rational>` and `Cartesian<NtTraits::Algebraic>`
|
||||||
* instantiating the two kernel types, respectively. The number types in this
|
* instances for two kernel types, respectively. The number types in this
|
||||||
* case are provided by the \core library, with its ability to exactly represent
|
* case are provided by the \core library, with its ability to exactly represent
|
||||||
* simple algebraic numbers.
|
* simple algebraic numbers.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*! \ingroup PkgArrangementOnSurface2DCEL
|
||||||
|
*
|
||||||
|
* The \dcel class used by the `Arrangement_2`,
|
||||||
|
* `Arr_bounded_planar_topology_traits_2`, `Arr_unb_planar_topology_traits_2`
|
||||||
|
* class templates and other templates. It is parameterized by a geometry
|
||||||
|
* traits type and optionaly by a vertex, halfedge, or face types. By default,
|
||||||
|
* the `Arr_dcel` class template uses the \link
|
||||||
|
* ArrangementBasicTraits_2::Point_2 `Point_2`\endlink and \link
|
||||||
|
* ArrangementBasicTraits_2::X_monotone_curve_2 `X_monotone_curve_2`\endlink
|
||||||
|
* types nested in the traits type to instantiate the vertex and base halfedge
|
||||||
|
* types, respectively. Thus, by default the \dcel only stores the topological
|
||||||
|
* incidence relations and the geometric data attached to vertices and
|
||||||
|
* edges. Any one of the vertex, halfedge, or face types can be
|
||||||
|
* overriden. Notice that if the vertex and halfedge types are overriden, the
|
||||||
|
* traits type is ignored.
|
||||||
|
*
|
||||||
|
* \cgalModels{ArrangementDcelWithRebind}
|
||||||
|
*
|
||||||
|
* \tparam Traits a geometry traits type, which is a model of the
|
||||||
|
* `ArrangementBasicTraits_2` concept.
|
||||||
|
* \tparam V the vertex type, which is a model of the `ArrangementDcelVertex`
|
||||||
|
* concept.
|
||||||
|
* \tparam H the halfedge type, which is a model of the
|
||||||
|
* `ArrangementDcelHalfedge` concept.
|
||||||
|
* \tparam F the face type, which is a model of the `ArrangementDcelFace`
|
||||||
|
* concept.
|
||||||
|
*
|
||||||
|
* \sa `Arr_dcel_base<V, H, F>`
|
||||||
|
*/
|
||||||
|
template <typename Traits,
|
||||||
|
typename V = Arr_vertex_base<typename Traits::Point_2>,
|
||||||
|
typename H = Arr_halfedge_base<typename Traits::X_monotone_curve_2>,
|
||||||
|
typename F = Arr_face_base>
|
||||||
|
class Arr_dcel : public Arr_dcel_base<V, H, F> {
|
||||||
|
};
|
||||||
|
|
||||||
|
} /* end namespace CGAL */
|
||||||
|
|
@ -1,26 +1,25 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/*! \ingroup PkgArrangementOnSurface2DCEL
|
||||||
\ingroup PkgArrangementOnSurface2DCEL
|
*
|
||||||
|
* The default \dcel class used by the `Arrangement_2`,
|
||||||
|
* `Arr_bounded_planar_topology_traits_2`, `Arr_unb_planar_topology_traits_2`
|
||||||
|
* class templates and other templates. It is parameterized by a geometry
|
||||||
|
* traits type. It uses the \link ArrangementBasicTraits_2::Point_2
|
||||||
|
* `Point_2`\endlink and \link ArrangementBasicTraits_2::X_monotone_curve_2
|
||||||
|
* `X_monotone_curve_2`\endlink types nested in the traits type to instantiate
|
||||||
|
* the vertex and base halfedge types, respectively. Thus, by default the \dcel
|
||||||
|
* only stores the topological incidence relations and the geometric data
|
||||||
|
* attached to vertices and edges.
|
||||||
|
*
|
||||||
|
* \cgalModels{ArrangementDcelWithRebind}
|
||||||
|
*
|
||||||
|
* \tparam Traits a geometry traits type, which is a model of the
|
||||||
|
* `ArrangementBasicTraits_2` concept.
|
||||||
|
*
|
||||||
|
* \sa `Arr_dcel<Traits, V, H, F>`
|
||||||
|
* \sa `Arr_dcel_base<V, H, F>`
|
||||||
|
*/
|
||||||
|
template <typename Traits> using Arr_default_dcel = Arr_dcel<Traits>;
|
||||||
|
|
||||||
The default \dcel class used by the `Arrangement_2` class-template
|
|
||||||
is parameterized by a traits class, which is a model of the
|
|
||||||
`ArrangementBasicTraits_2` concept. It simply uses the nested
|
|
||||||
`Traits::Point_2` and `Traits::X_monotone_curve_2` to instantiate
|
|
||||||
the base vertex and halfedge types, respectively. Thus, the default
|
|
||||||
\dcel records store no other information, except for the topological
|
|
||||||
incidence relations and the geometric data attached to vertices and edges.
|
|
||||||
|
|
||||||
\cgalModels{ArrangementDcelWithRebind}
|
|
||||||
|
|
||||||
\sa `Arr_dcel_base<V,H,F>`
|
|
||||||
*/
|
|
||||||
template< typename Traits >
|
|
||||||
class Arr_default_dcel :
|
|
||||||
public Arr_dcel_base< Arr_vertex_base<typename Traits_::Point_2>,
|
|
||||||
Arr_halfedge_base<typename Traits_::X_monotone_curve_2>,
|
|
||||||
Arr_face_base>
|
|
||||||
{
|
|
||||||
}; /* end Arr_default_dcel */
|
|
||||||
} /* end namespace CGAL */
|
} /* end namespace CGAL */
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ that are not provided by the kernel. The kernel is parameterized with a
|
||||||
number type, which should support the arithmetic operations \f$ +\f$, \f$ -\f$ and
|
number type, which should support the arithmetic operations \f$ +\f$, \f$ -\f$ and
|
||||||
\f$ \times\f$ in an exact manner in order to avoid robustness problems.
|
\f$ \times\f$ in an exact manner in order to avoid robustness problems.
|
||||||
Using `Cartesian<MP_Float>` or `Cartesian<Gmpz>` are possible
|
Using `Cartesian<MP_Float>` or `Cartesian<Gmpz>` are possible
|
||||||
instantiations for the kernel. Using other (inexact) number types
|
substitutions for the kernel. Using other (inexact) number types
|
||||||
(for example, instantiating the template with
|
(for example, instantiating the template with
|
||||||
`Simple_cartesian<double>`) is also possible, at the user's own
|
`Simple_cartesian<double>`) is also possible, at the user's own
|
||||||
risk.
|
risk.
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
* The traits class `Arr_segment_traits_2` is a model of the
|
* The traits class `Arr_segment_traits_2` is a model of the
|
||||||
* `ArrangementTraits_2` concept, which allows the construction and maintenance
|
* `ArrangementTraits_2` concept, which allows the construction and maintenance
|
||||||
* of arrangements of line segments. It should be parameterized with a
|
* of arrangements of line segments. It is parameterized with a
|
||||||
* \cgal-kernel model that is templated in turn with a number type. To avoid
|
* \cgal-kernel model that is templated in turn with a number type. To avoid
|
||||||
* numerical errors and robustness problems, the number type should support
|
* numerical errors and robustness problems, the number type should support
|
||||||
* exact rational arithmetic - that is, the number type should support the
|
* exact rational arithmetic; that is, the number type should support the
|
||||||
* arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$ and \f$ \div\f$
|
* arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$ and \f$ \div\f$
|
||||||
* carried out without loss of precision.
|
* carried out without loss of precision.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
* The `Arr_spherical_topology_traits_2` template has two parameters:
|
* The `Arr_spherical_topology_traits_2` template has two parameters:
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI>The `GeometryTraits_2` template-parameter should be instantiated with
|
* <LI>The `GeometryTraits_2` template-parameter should be substituted by
|
||||||
* a model of the `ArrangementBasicTraits_2` concept. The traits
|
* a model of the `ArrangementBasicTraits_2` concept. The traits
|
||||||
* class defines the types of \f$x\f$-monotone curves and two-dimensional
|
* class defines the types of \f$x\f$-monotone curves and two-dimensional
|
||||||
* points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
* points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
||||||
* `ArrangementBasicTraits_2::Point_2`,
|
* `ArrangementBasicTraits_2::Point_2`,
|
||||||
* respectively, and supports basic geometric predicates on them.
|
* respectively, and supports basic geometric predicates on them.
|
||||||
* <LI>The `Dcel` template-parameter should be instantiated with
|
* <LI>The `Dcel` template-parameter should be substituted by
|
||||||
* a class that is a model of the `ArrangementDcel` concept. The
|
* a class that is a model of the `ArrangementDcel` concept. The
|
||||||
* value of this parameter is by default
|
* value of this parameter is by default
|
||||||
* `Arr_default_dcel<Traits>`.
|
* `Arr_default_dcel<Traits>`.
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
* The `Arr_unb_planar_topology_traits_2` template has two parameters:
|
* The `Arr_unb_planar_topology_traits_2` template has two parameters:
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI>The `GeometryTraits_2` template-parameter should be instantiated with
|
* <LI>The `GeometryTraits_2` template-parameter should be substituted by
|
||||||
* a model of the `ArrangementBasicTraits_2` concept. The traits
|
* a model of the `ArrangementBasicTraits_2` concept. The traits
|
||||||
* class defines the types of \f$x\f$-monotone curves and two-dimensional
|
* class defines the types of \f$x\f$-monotone curves and two-dimensional
|
||||||
* points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
* points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
||||||
* `ArrangementBasicTraits_2::Point_2`,
|
* `ArrangementBasicTraits_2::Point_2`,
|
||||||
* respectively, and supports basic geometric predicates on them.
|
* respectively, and supports basic geometric predicates on them.
|
||||||
* <LI>The `Dcel` template-parameter should be instantiated with
|
* <LI>The `Dcel` template-parameter should be substituted by
|
||||||
* a class that is a model of the `ArrangementDcel` concept. The
|
* a class that is a model of the `ArrangementDcel` concept. The
|
||||||
* value of this parameter is by default
|
* value of this parameter is by default
|
||||||
* `Arr_default_dcel<Traits>`.
|
* `Arr_default_dcel<Traits>`.
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,14 @@ namespace CGAL {
|
||||||
|
|
||||||
* The `Arrangement_on_surface_2` template has two parameters:
|
* The `Arrangement_on_surface_2` template has two parameters:
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI>The `GeometryTraits` template-parameter should be instantiated with
|
* <LI>The `GeometryTraits` template-parameter should be substituted by
|
||||||
* a model of a geometry traits. The minimal requirements are defined by the
|
* a model of a geometry traits. The minimal requirements are defined by the
|
||||||
* `ArrangementBasicTraits_2` concept. A model of this concept defines
|
* `ArrangementBasicTraits_2` concept. A model of this concept defines
|
||||||
* the types of \f$ x\f$-monotone curves and two-dimensional points, namely
|
* the types of \f$ x\f$-monotone curves and two-dimensional points, namely
|
||||||
* `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
* `ArrangementBasicTraits_2::X_monotone_curve_2` and
|
||||||
* `ArrangementBasicTraits_2::Point_2`, respectively, and supports basic
|
* `ArrangementBasicTraits_2::Point_2`, respectively, and supports basic
|
||||||
* geometric predicates on them.
|
* geometric predicates on them.
|
||||||
* <LI>The `TopologyTraits` template-parameter should be instantiated with a
|
* <LI>The `TopologyTraits` template-parameter should be substituted by a
|
||||||
* class that is a model of the `ArrangementTopologyTraits` concept.
|
* class that is a model of the `ArrangementTopologyTraits` concept.
|
||||||
* </UL>
|
* </UL>
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,15 @@ namespace CGAL {
|
||||||
* The `Arrangement_on_surface_with_history_2` template has two parameters:
|
* The `Arrangement_on_surface_with_history_2` template has two parameters:
|
||||||
*
|
*
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI>The `GeometryTraits` template-parameter should be instantiated with a
|
* <LI>The `GeometryTraits` template-parameter should be substituted by a
|
||||||
* model of the `ArrangementTraits_2` concept. The traits class defines the
|
* model of the `ArrangementTraits_2` concept. The traits class defines the
|
||||||
* `Curve_2` type, which represents an input curve. It also defines the types
|
* `Curve_2` type, which represents an input curve. It also defines the types
|
||||||
* of \f$ x\f$-monotone curves and two-dimensional points, namely
|
* of \f$ x\f$-monotone curves and two-dimensional points, namely
|
||||||
* `ArrangementTraits_2::X_monotone_curve_2` and
|
* `ArrangementTraits_2::X_monotone_curve_2` and
|
||||||
* `ArrangementTraits_2::Point_2`, respectively, and supports basic
|
* `ArrangementTraits_2::Point_2`, respectively, and supports basic
|
||||||
* geometric predicates on them.
|
* geometric predicates on them.
|
||||||
* <LI>The `Dcel` template-parameter should be instantiated with a class that is
|
* <LI>The `TopologyTraits` template-parameter should be substituted by a
|
||||||
* a model of the `ArrangementDcelWithRebind` concept. The value of this
|
* class that is a model of the `ArrangementTopologyTraits` concept.
|
||||||
* parameter is by default `Arr_default_dcel<Traits>`.
|
|
||||||
* </UL>
|
* </UL>
|
||||||
*
|
*
|
||||||
* \sa `Arrangement_with_history_2<GeometryTraits,Dcel>`
|
* \sa `Arrangement_with_history_2<GeometryTraits,Dcel>`
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,13 @@ namespace CGAL {
|
||||||
*
|
*
|
||||||
* The `Arrangement_with_history_2` template has two parameters:
|
* The `Arrangement_with_history_2` template has two parameters:
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI>The `Traits` template-parameter should be instantiated with a model of
|
* <LI>The `Traits` template-parameter should be substituted by a model of
|
||||||
* the `ArrangementTraits_2` concept. The traits class defines the `Curve_2`
|
* the `ArrangementTraits_2` concept. The traits class defines the `Curve_2`
|
||||||
* type, which represents an input curve. It also defines the types of \f$
|
* type, which represents an input curve. It also defines the types of \f$
|
||||||
* x\f$-monotone curves and two-dimensional points, namely
|
* x\f$-monotone curves and two-dimensional points, namely
|
||||||
* `ArrangementTraits_2::X_monotone_curve_2` and `ArrangementTraits_2::Point_2`,
|
* `ArrangementTraits_2::X_monotone_curve_2` and `ArrangementTraits_2::Point_2`,
|
||||||
* respectively, and supports basic geometric predicates on them.
|
* respectively, and supports basic geometric predicates on them.
|
||||||
* <LI>The `Dcel` template-parameter should be instantiated with a class that is
|
* <LI>The `Dcel` template-parameter should be substituted by a class that is
|
||||||
* a model of the `ArrangementDcelWithRebind` concept. The value of this
|
* a model of the `ArrangementDcelWithRebind` concept. The value of this
|
||||||
* parameter is by default `Arr_default_dcel<Traits>`.
|
* parameter is by default `Arr_default_dcel<Traits>`.
|
||||||
* </UL>
|
* </UL>
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ Instantiate a dcel class with many different possible types without ad-hoc limit
|
||||||
|
|
||||||
\cgalHasModelsBegin
|
\cgalHasModelsBegin
|
||||||
\cgalHasModels{CGAL::Arr_default_dcel<Traits>}
|
\cgalHasModels{CGAL::Arr_default_dcel<Traits>}
|
||||||
|
\cgalHasModels{CGAL::Arr_dcel<Traits,V,H,F>}
|
||||||
\cgalHasModels{CGAL::Arr_face_extended_dcel<Traits,FData,V,H,F>}
|
\cgalHasModels{CGAL::Arr_face_extended_dcel<Traits,FData,V,H,F>}
|
||||||
\cgalHasModels{CGAL::Arr_extended_dcel<Traits,VData,HData,FData,V,H,F>}
|
\cgalHasModels{CGAL::Arr_extended_dcel<Traits,VData,HData,FData,V,H,F>}
|
||||||
\cgalHasModelsEnd
|
\cgalHasModelsEnd
|
||||||
|
|
@ -48,4 +49,3 @@ Arr_dcel();
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
}; /* end ArrangementDcelWithRebind */
|
}; /* end ArrangementDcelWithRebind */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* associated with the landmark point-location strategy (see
|
* associated with the landmark point-location strategy (see
|
||||||
* `CGAL::Arr_landmarks_point_location`) must be an instance of the
|
* `CGAL::Arr_landmarks_point_location`) must be an instance of the
|
||||||
* `CGAL::Arrangement_2<Traits,Dcel>` class template, where the Traits parameter
|
* `CGAL::Arrangement_2<Traits,Dcel>` class template, where the Traits parameter
|
||||||
* is substituted with a model of this concept.
|
* is substituted by a model of this concept.
|
||||||
*
|
*
|
||||||
* \cgalRefines{ArrangementApproximateTraits_2,ArrangementConstructXMonotoneCurveTraits_2}
|
* \cgalRefines{ArrangementApproximateTraits_2,ArrangementConstructXMonotoneCurveTraits_2}
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,7 @@ implemented as peripheral classes or as free (global) functions.
|
||||||
- `CGAL::Arrangement_2::Halfedge`
|
- `CGAL::Arrangement_2::Halfedge`
|
||||||
- `CGAL::Arrangement_2::Face`
|
- `CGAL::Arrangement_2::Face`
|
||||||
- `CGAL::Arr_dcel_base<V,H,F>`
|
- `CGAL::Arr_dcel_base<V,H,F>`
|
||||||
|
- `CGAL::Arr_dcel<Traits,V,H,F>`
|
||||||
- `CGAL::Arr_default_dcel<Traits>`
|
- `CGAL::Arr_default_dcel<Traits>`
|
||||||
- `CGAL::Arr_face_extended_dcel<Traits,FData,V,H,F>`
|
- `CGAL::Arr_face_extended_dcel<Traits,FData,V,H,F>`
|
||||||
- `CGAL::Arr_extended_dcel<Traits,VData,HData,FData,V,H,F>`
|
- `CGAL::Arr_extended_dcel<Traits,VData,HData,FData,V,H,F>`
|
||||||
|
|
|
||||||
|
|
@ -2,56 +2,62 @@
|
||||||
\input{header}
|
\input{header}
|
||||||
\pagestyle{empty}
|
\pagestyle{empty}
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\psscalebox{1.8}{\arrset{1}%
|
\begin{tikzpicture}[scale=1]
|
||||||
\pspicture[](-1,-1)(8,7)
|
\myAxes{-1}{-1}{8}{7}
|
||||||
\arraxes(0,0)(-1,-1)(8,7)
|
\coordinate (a) at (0,0);
|
||||||
\arrMainVertex(0,0){1}
|
\coordinate (b) at (0,3);
|
||||||
\arrMainVertex(0,3){2}
|
\coordinate (d) at (2,3);
|
||||||
\arrEmptyVertex(1,3){3}
|
\coordinate (j) at (4,3);
|
||||||
\arrMainVertex(2,3){4}
|
\coordinate (l) at (5,3);
|
||||||
\arrMainVertex(2,6){5}
|
%
|
||||||
\arrMainVertex(3,1){6}
|
\arrMainVertexZ(a){1}
|
||||||
\arrEmptyVertex(3,3){7}
|
\arrMainVertexZ(b){2}
|
||||||
\arrMainVertex(3,4){8}
|
\arrIntersectionVertexZ(1,3){3}
|
||||||
\arrMainVertex(3,5){9}
|
\arrMainVertexZ(d){4}
|
||||||
\arrMainVertex(4,3){10}
|
\arrMainVertexZ(2,6){5}
|
||||||
\arrEmptyVertex(4,4){11}
|
\arrMainVertexZ(3,1){6}
|
||||||
\arrMainVertex(5,3){12}
|
\arrIntersectionVertexZ(3,3){7}
|
||||||
\arrMainVertex(6,4){13}
|
\arrMainVertexZ(3,4){8}
|
||||||
\arrMainVertex(7,1){14}
|
\arrMainVertexZ(3,5){9}
|
||||||
\arrCrossVertex(4,6){x1}\uput[-45]{0}(4,6){$q_1$}
|
\arrMainVertexZ(j){10}
|
||||||
\arrCrossVertex(6,2){x2}\uput[45]{0}(6,2){$q_2$}
|
\arrIntersectionVertexZ(4,4){11}
|
||||||
\arrCrossVertex(2,4){x3}\uput[45]{0}(2,4){$q_3$}
|
\arrMainVertexZ(l){12}
|
||||||
%
|
\arrMainVertexZ(6,4){13}
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{1}{3}
|
\arrMainVertexZ(7,1){14}
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{3}{5}
|
%
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{5}{9}
|
\draw[edge](1)--(3);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{9}{11}
|
\draw[edge](3)--(5);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{11}{12}
|
\draw[edge](5)--(9);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{12}{14}
|
\draw[edge](9)--(11);
|
||||||
%
|
\draw[edge](11)--(12);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{6}{7}
|
\draw[edge](12)--(14);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{7}{8}\Bput[1pt]{\textcolor{blue}{$s_2$}}
|
%
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{8}{9}
|
\draw[edge](6)--node[sloped,below,pos=0.4] {\textcolor{blue}{$s_2$}} (7);
|
||||||
%
|
\draw[edge](7)--(8);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{8}{11}
|
\draw[edge](8)--(9);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{11}{13}
|
%
|
||||||
%
|
\draw[edge](8)--(11);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{4}{7}
|
\draw[edge](11)--(13);
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{7}{10}
|
%
|
||||||
\ncline[linewidth=1pt,linecolor=blue]{10}{12}
|
\draw[edge](4)--(7);
|
||||||
%
|
\draw[edge](7)--(10);
|
||||||
\ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{2}{3}
|
\draw[edge](10)--(12);
|
||||||
\ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{3}{4}
|
%
|
||||||
\ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{4}{7}
|
\draw[edge=red,dashed](2)--(3);
|
||||||
\ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{7}{10}
|
\draw[edge=red,dashed](3)--(4);
|
||||||
%
|
\draw[edge=red,dashed](4)--(7);
|
||||||
\pnode(2,2){a}\uput{2pt}[-90]{0}(2,2){\textcolor{red}{$s_1$}}
|
\draw[edge=red,dashed](7)--(10);
|
||||||
\nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{2}{a}
|
%
|
||||||
\nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{10}{a}
|
\arrQueryLabeledVertexZ[-45](4,6){x1}{$q_1$}
|
||||||
\pnode(3.5,2){b}\uput{2pt}[-90]{0}(3.5,2){\textcolor{blue}{$s_3$}}
|
\arrQueryLabeledVertexZ[45](6,2){x2}{$q_2$}
|
||||||
\nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{4}{b}
|
\arrQueryLabeledVertexZ[45](2,4){x3}{$q_3$}
|
||||||
\nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{12}{b}
|
%
|
||||||
\endpspicture
|
\draw [decoration={calligraphic brace,
|
||||||
}
|
raise=2pt,
|
||||||
|
amplitude=10pt,aspect=0.5},decorate,line width=0.2pt] (j)--(b)
|
||||||
|
node[midway,below=10pt,red]{$s_1$};
|
||||||
|
\draw [decoration={calligraphic brace,raise=2pt,
|
||||||
|
amplitude=10pt,aspect=0.5},decorate,line width=0.2pt] (d)--(l)
|
||||||
|
node[midway,above=10pt,blue]{$s_3$};
|
||||||
|
\end{tikzpicture}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
% ======== Math ===============================================================
|
% ======== Math ===============================================================
|
||||||
\usepackage{amsmath,amscd,amsthm}
|
\usepackage{amsmath,amscd,amsthm}
|
||||||
\usepackage{empheq}
|
\usepackage{empheq}
|
||||||
|
\usepackage{bm}
|
||||||
% ======== pdf, url and hyperlink =============================================
|
% ======== pdf, url and hyperlink =============================================
|
||||||
% \usepackage{url}
|
% \usepackage{url}
|
||||||
\usepackage{hyperref}
|
\usepackage{hyperref}
|
||||||
|
|
@ -42,24 +42,33 @@
|
||||||
% graphicx.
|
% graphicx.
|
||||||
\usepackage{tikz}
|
\usepackage{tikz}
|
||||||
\usepackage{pgfplots}
|
\usepackage{pgfplots}
|
||||||
|
% \pgfplotsset{compat=1.16}
|
||||||
|
\pgfplotsset{compat=newest}
|
||||||
|
\usepgfplotslibrary{fillbetween}
|
||||||
|
\usepackage{tikz-3dplot}
|
||||||
\usepackage{mathptmx}
|
\usepackage{mathptmx}
|
||||||
\usetikzlibrary{calc}
|
\usetikzlibrary{arrows,arrows.meta}
|
||||||
|
\usetikzlibrary{automata}
|
||||||
\usetikzlibrary{backgrounds}
|
\usetikzlibrary{backgrounds}
|
||||||
|
\usetikzlibrary{calligraphy}
|
||||||
|
\usetikzlibrary{calc}
|
||||||
|
\usetikzlibrary{chains}
|
||||||
|
\usetikzlibrary{cd}
|
||||||
\usetikzlibrary{decorations.pathmorphing}
|
\usetikzlibrary{decorations.pathmorphing}
|
||||||
\usetikzlibrary{decorations.markings}
|
\usetikzlibrary{decorations.markings}
|
||||||
\usetikzlibrary{decorations.pathreplacing}
|
\usetikzlibrary{decorations.pathreplacing}
|
||||||
\usetikzlibrary{patterns}
|
|
||||||
\usetikzlibrary{matrix}
|
|
||||||
\usetikzlibrary{fit}
|
\usetikzlibrary{fit}
|
||||||
\usetikzlibrary{arrows,arrows.meta}
|
\usetikzlibrary{intersections}
|
||||||
\usetikzlibrary{automata}
|
\usetikzlibrary{math}
|
||||||
|
\usetikzlibrary{matrix}
|
||||||
|
\usetikzlibrary{patterns}
|
||||||
\usetikzlibrary{positioning}
|
\usetikzlibrary{positioning}
|
||||||
\usetikzlibrary{shapes}
|
\usetikzlibrary{shapes}
|
||||||
\usetikzlibrary{chains}
|
\usetikzlibrary{shapes.geometric}
|
||||||
|
\usetikzlibrary{shapes.misc}
|
||||||
|
\usetikzlibrary{shadows.blur}
|
||||||
\usetikzlibrary{spy}
|
\usetikzlibrary{spy}
|
||||||
\usetikzlibrary{intersections}
|
|
||||||
\usetikzlibrary{through}
|
\usetikzlibrary{through}
|
||||||
\usetikzlibrary{cd}
|
|
||||||
\usepackage{tikz-3dplot}
|
\usepackage{tikz-3dplot}
|
||||||
%\usetikzlibrary{quotes,angles,graph}
|
%\usetikzlibrary{quotes,angles,graph}
|
||||||
\tikzset{%
|
\tikzset{%
|
||||||
|
|
@ -72,6 +81,23 @@
|
||||||
point/.default=red,
|
point/.default=red,
|
||||||
halfedge/.style={-{Stealth[left,scale=1.5]},commutative diagrams/shift left=#1},
|
halfedge/.style={-{Stealth[left,scale=1.5]},commutative diagrams/shift left=#1},
|
||||||
halfedge/.default=3pt
|
halfedge/.default=3pt
|
||||||
|
edge/.style={line width=0.8pt,draw=#1},
|
||||||
|
edge/.default=blue,
|
||||||
|
halfedge/.style={-{Stealth[left,scale=1.5]},
|
||||||
|
commutative diagrams/shift left=#1},
|
||||||
|
halfedge/.default=3pt,
|
||||||
|
cross/.style={#1,cross out,draw,very thick,rotate=0,
|
||||||
|
minimum size=2*(4pt-\pgflinewidth),inner sep=0pt,outer sep=0pt},
|
||||||
|
cross/.default=red
|
||||||
|
}
|
||||||
|
\pgfplotsset{%
|
||||||
|
axisLimits/.style={enlarge x limits={abs value=\axisLimitsAbsValue,auto},
|
||||||
|
enlarge y limits={abs value=\axisLimitsAbsValue,auto}}}
|
||||||
|
\newlength{\axisLimitsAbsValue}\setlength{\axisLimitsAbsValue}{0.08cm}
|
||||||
|
% ------------------------------------------------------------------------------
|
||||||
|
\newcommand{\mySimpleAxes}[4]{%
|
||||||
|
\draw[-{Stealth[scale=1.5]}] (#1,0)--(#3,0) node[right]{$x$};
|
||||||
|
\draw[-{Stealth[scale=1.5]}] (0,#2)--(0,#4) node[above]{$y$};
|
||||||
}
|
}
|
||||||
% ------------------------------------------------------------------------------
|
% ------------------------------------------------------------------------------
|
||||||
% #1 half length of tick
|
% #1 half length of tick
|
||||||
|
|
|
||||||
|
|
@ -2,33 +2,38 @@
|
||||||
\input{header}
|
\input{header}
|
||||||
\pagestyle{empty}
|
\pagestyle{empty}
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\psscalebox{1.8}{\arrset{1}%
|
\begin{tikzpicture}[scale=1.0,smooth]
|
||||||
\pspicture[](-3.1,-0.725)(3.1,1.709)
|
\begin{axis}[ticks=none,axis line style={draw=none},unit vector ratio*=1 1 1,
|
||||||
%
|
enlarge x limits={abs value=0.08,auto},
|
||||||
\pscustom[linecolor=blue,linewidth=0pt,fillstyle=hlines,hatchcolor=orange,hatchsep=2pt,hatchwidth=1pt]{%
|
enlarge y limits={abs value=0.08,auto},
|
||||||
\psplot{-2}{0}{0 x x mul x mul add x x mul add x 4 mul sub 1 add 8 div}
|
% The following miraculously solves the wierd shift in the intersection
|
||||||
\psplot{0}{-2}{0 x x mul x mul sub x x mul add x 4 mul add 1 add 8 div}
|
% computation
|
||||||
}
|
anchor=left of west
|
||||||
%
|
]
|
||||||
\pscustom[linecolor=blue,linewidth=0pt,fillstyle=vlines,hatchcolor=orange,hatchsep=2pt,hatchwidth=1pt]{
|
% x^3+x^2-4x-8y=-1
|
||||||
\psplot{0}{2}{0 x x mul x mul add x x mul add x 4 mul sub 1 add 8 div}
|
% -x^3+x^2+4x-8y=-1
|
||||||
\psplot{2}{0}{0 x x mul x mul sub x x mul add x 4 mul add 1 add 8 div}
|
\addplot [draw=none,name path=f11,domain=-2:0]{(1-x^3+x^2+4*x)*0.125};
|
||||||
}
|
\addplot [draw=none,name path=f12,domain=0:-2]{(1+x^3+x^2-4*x)*0.125};
|
||||||
%
|
\addplot [draw=none,name path=f21,domain=0:2]{(1-x^3+x^2+4*x)/8.0};
|
||||||
\psplot[linecolor=blue]{-2.5}{3}{0 x x mul x mul sub x x mul add x 4 mul add 1 add 8 div}
|
\addplot [draw=none,name path=f22,domain=2:0]{(1+x^3+x^2-4*x)/8.0};
|
||||||
\psplot[linecolor=blue]{-3}{2.5}{0 x x mul x mul add x x mul add x 4 mul sub 1 add 8 div}
|
%
|
||||||
%
|
\addplot [name path global=A,color=blue,thick,domain=-2.5:3]
|
||||||
\arrMainVertex(-3,-0.625){1}
|
{(1-x^3+x^2+4*x)*0.125} coordinate[point,pos=0] coordinate[point];
|
||||||
\arrMainVertex( 3,-0.625){2}
|
\addplot [name path global=B,color=blue,thick,domain=-3:2.5]
|
||||||
\arrMainVertex(-2.5,1.609){3}
|
{(1+x^3+x^2-4*x)*0.125} coordinate[point,pos=0] coordinate[point];
|
||||||
\arrMainVertex( 2.5,1.609){4}
|
\coordinate [name intersections={of=A and B,name=x}];
|
||||||
\arrEmptyVertex(-2,0.625){x1}
|
%
|
||||||
\arrEmptyVertex( 2,0.625){x2}
|
\node[point=white] at (x-1) {};
|
||||||
\arrEmptyVertex(0,0.125){x3}
|
\node[point=white] at (x-2) {};
|
||||||
\rput(-2.5,1){\textcolor{blue}{$c_1$}}
|
\node[point=white] at (x-3) {};
|
||||||
\rput(-2.9,0.15){\textcolor{blue}{$c_2$}}
|
%
|
||||||
\rput(-1,0.3){\boldmath{$f_1$}}
|
\addplot[pattern={north east lines},pattern color=orange] fill between[of=f11 and f12];
|
||||||
\rput(1,0.3){\boldmath{$f_2$}}
|
\addplot[pattern={north west lines},pattern color=orange] fill between[of=f21 and f22];
|
||||||
\endpspicture
|
%
|
||||||
}
|
\node at (-2.5,1){\textcolor{blue}{$c_1$}};
|
||||||
|
\node at (-2.9,0.15){\textcolor{blue}{$c_2$}};
|
||||||
|
\node at (-1,0.3){$\bm{f_1}$};
|
||||||
|
\node at (1,0.3){$\bm{f_2}$};
|
||||||
|
\end{axis}
|
||||||
|
\end{tikzpicture}
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
\input{header}
|
\input{header}
|
||||||
\pagestyle{empty}
|
\pagestyle{empty}
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\psscalebox{1.8}{\arrset{0.9}%
|
\psscalebox{1.0}{\arrset{0.75}%
|
||||||
\begin{pspicture}(-3.5,-3.5)(2.1,2.1)
|
\begin{pspicture}(-3.5,-3.5)(2.1,2.1)
|
||||||
\newpsstyle{SimpleHandle}{fillstyle=solid,fillcolor=white,framearc=0.5}
|
\newpsstyle{SimpleHandle}{fillstyle=solid,fillcolor=white,framearc=0.5}
|
||||||
\psframe[linewidth=0.25pt](-2,-2)(2,2)
|
\psframe[linewidth=0.25pt](-2,-2)(2,2)
|
||||||
|
|
|
||||||
|
|
@ -2,143 +2,134 @@
|
||||||
\input{header}
|
\input{header}
|
||||||
\pagestyle{empty}
|
\pagestyle{empty}
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\psscalebox{1.8}{\arrset{1}%
|
\begin{tikzpicture}[scale=0.93]
|
||||||
\begin{pspicture}(0,0)(10,7)
|
\fill[lightyellow](0,0)rectangle(1,7);
|
||||||
\psframe*[linecolor=lightyellow](0,0)(1,7)
|
\fill[lightyellow](9,0)rectangle(10,7);
|
||||||
\psframe*[linecolor=lightyellow](9,0)(10,7)
|
\fill[lightyellow](1,0)rectangle(9,1);
|
||||||
\psframe*[linecolor=lightyellow](1,0)(9,1)
|
\fill[lightyellow](1,6)rectangle(9,7);
|
||||||
\psframe*[linecolor=lightyellow](1,6)(9,7)
|
\draw[line width=0.25pt](0,0)rectangle(10,7);
|
||||||
\psframe[linewidth=0.25pt](0,0)(10,7)
|
|
||||||
%
|
%
|
||||||
\arrlvertex[225](1,1){bl}{$v_{\mathrm{bl}}$}
|
\arrMainLabeledVertexZ[225](1,1){bl}{$v_{\mathrm{bl}}$}
|
||||||
\arrlvertex[135](1,6){tl}{$v_{\mathrm{tl}}$}
|
\arrMainLabeledVertexZ[135](1,6){tl}{$v_{\mathrm{tl}}$}
|
||||||
\arrlvertex[315](9,1){br}{$v_{\mathrm{br}}$}
|
\arrMainLabeledVertexZ[315](9,1){br}{$v_{\mathrm{br}}$}
|
||||||
\arrlvertex[45](9,6){tr}{$v_{\mathrm{tr}}$}
|
\arrMainLabeledVertexZ[45](9,6){tr}{$v_{\mathrm{tr}}$}
|
||||||
\arrv[180](1,2.5){1}
|
\arrvZ[180](1,2.5){1}
|
||||||
\arrv[180](1,4){2}
|
\arrvZ[180](1,4){2}
|
||||||
\arrv[180](1,5){3}
|
\arrvZ[180](1,5){3}
|
||||||
\arrv[270](5,1){4}
|
\arrvZ[270](5,1){4}
|
||||||
\arrv[90](5,6){5}
|
\arrvZ[90](5,6){5}
|
||||||
\arrv[0](9,1.5){6}
|
\arrvZ[0](9,1.5){6}
|
||||||
\arrv[0](9,4){7}
|
\arrvZ[0](9,4){7}
|
||||||
\arrv[0](9,5.5){8}
|
\arrvZ[0](9,5.5){8}
|
||||||
%
|
%
|
||||||
\arrEmptyIntersectionVertex(1,4)(9,4)(5,1)(5,6){9}
|
\node[point=white] (9) at (intersection of 2--7 and 4--5) {};
|
||||||
\arrEmptyIntersectionVertex(1,4)(9,4)(1,5)(9,1.5){10}
|
\node[point=white] (10) at (intersection of 2--7 and 3--6) {};
|
||||||
\arrEmptyIntersectionVertex(1,5)(9,1.5)(5,1)(5,6){11}
|
\node[point=white] (11) at (intersection of 3--6 and 4--5) {};
|
||||||
\arrEmptyIntersectionVertex(1,5)(9,1.5)(1,2.5)(9,5.5){12}
|
\node[point=white] (12) at (intersection of 3--6 and 1--8) {};
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{bl}{1}
|
\draw[dashed,line width=0.5pt](bl)--(1);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{bl}{1}
|
\draw[halfedge](bl)to(1);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepB=1pt]{->}{1}{bl}
|
\draw[halfedge](1)to(bl);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{1}{2}
|
\draw[dashed,line width=0.5pt](1)--(2);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{1}{2}
|
\draw[halfedge](1)to(2);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=2pt]{->}{2}{1}
|
\draw[halfedge,shorten >=1pt](2)to(1);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{2}{3}
|
\draw[dashed,line width=0.5pt](2)--(3);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{2}{3}
|
\draw[halfedge](2)to(3);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=3pt,nodesepB=1pt]{->}{3}{2}
|
\draw[halfedge,shorten <=2pt](3)to(2);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{3}{tl}
|
\draw[dashed,line width=0.5pt](3)--(tl);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{3}{tl}
|
\draw[halfedge](3)to(tl);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt]{->}{tl}{3}
|
\draw[halfedge](tl)to(3);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{tl}{5}
|
\draw[dashed,line width=0.5pt](tl)--(5);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{tl}{5}
|
\draw[halfedge](tl)to(5);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{5}{tl}
|
\draw[halfedge](5)to(tl);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{5}{tr}
|
\draw[dashed,line width=0.5pt](5)--(tr);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{5}{tr}
|
\draw[halfedge](5)to(tr);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{tr}{5}
|
\draw[halfedge](tr)to(5);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{tr}{8}
|
\draw[dashed,line width=0.5pt](tr)--(8);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{tr}{8}
|
\draw[halfedge](tr)to(8);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepB=1pt]{->}{8}{tr}
|
\draw[halfedge](8)to(tr);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{8}{7}
|
\draw[dashed,line width=0.5pt](8)--(7);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{8}{7}
|
\draw[halfedge](8)to(7);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=2pt]{->}{7}{8}
|
\draw[halfedge,shorten >=1pt](7)to(8);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{7}{6}
|
\draw[dashed,line width=0.5pt](7)--(6);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{7}{6}
|
\draw[halfedge](7)to(6);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=3pt,nodesepB=1pt]{->}{6}{7}
|
\draw[halfedge,shorten <=1.8pt](6)to(7);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{6}{br}
|
\draw[dashed,line width=0.5pt](6)--(br);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{6}{br}
|
\draw[halfedge](6)to(br);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt]{->}{br}{6}
|
\draw[halfedge](br)to(6);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{br}{4}
|
\draw[dashed,line width=0.5pt](br)--(4);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{br}{4}
|
\draw[halfedge](br)to(4);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{4}{br}
|
\draw[halfedge](4)to(br);
|
||||||
%
|
%
|
||||||
\ncline[linestyle=dashed,linewidth=0.5pt]{4}{bl}
|
\draw[dashed,line width=0.5pt](4)--(bl);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt]{->}{4}{bl}
|
\draw[halfedge](4)to(bl);
|
||||||
\ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{bl}{4}
|
\draw[halfedge](bl)to(4);
|
||||||
%
|
%
|
||||||
%\arredge{3}{10}
|
\draw[edge](3)--(10);
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{3}{10}
|
\draw[halfedge](3)to(10);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt]{->}{3}{10}
|
\draw[halfedge,shorten <=11pt,shorten >=1.6pt](10)to(3);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=12pt,nodesepB=2pt]{->}{10}{3}
|
\draw[edge](10)--(12);
|
||||||
%\arredge{10}{12}
|
\draw[halfedge,shorten <=4pt](12)to(10);
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{10}{12}
|
\draw[halfedge,shorten <=10pt,shorten >=-1.8pt](10)to(12);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=6pt]{->}{12}{10}
|
\draw[edge](12)--(11);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=16pt,nodesepB=-2pt]{->}{10}{12}
|
\draw[halfedge](11)to(12);
|
||||||
%\arredge{12}{11}
|
\draw[halfedge,shorten <=4.2pt,shorten >=1.2pt](12)to(11);
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{12}{11}
|
\draw[edge](11)--(6);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt]{->}{11}{12}
|
\draw[halfedge,shorten >=1.6pt](11)to(6);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=6pt,nodesepB=2pt]{->}{12}{11}
|
\draw[halfedge,shorten >=1.6pt](6)to(11);
|
||||||
%\arredge{11}{6}
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{11}{6}
|
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepB=2pt]{->}{11}{6}
|
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepB=2pt]{->}{6}{11}
|
|
||||||
|
|
||||||
%\arredge{1}{12}
|
\draw[edge](1)--(12);
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{1}{12}
|
\draw[halfedge,shorten <=1.4pt,shorten >=4pt](1)to(12);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=5pt]{->}{1}{12}
|
\draw[halfedge](12)to(1);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt]{->}{12}{1}
|
\draw[edge](12)--(9);
|
||||||
%\arredge{12}{9}
|
\draw[halfedge,shorten >=11.6pt](12)to(9);
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{12}{9}
|
\draw[halfedge,shorten <=2pt,shorten >=3.6pt](9)to(12);
|
||||||
\ncline[linewidth=0.25pt,,offset=3pt,nodesepB=12pt]{->}{12}{9}
|
\draw[edge](9)--(8);
|
||||||
\ncline[linewidth=0.25pt,,offset=3pt,nodesepA=2pt,nodesepB=5pt]{->}{9}{12}
|
\draw[halfedge,shorten <=1.4pt](9)to(8);
|
||||||
%\arredge{9}{8}
|
\draw[halfedge,shorten <=1.8pt,shorten >=11.8pt](8)to(9);
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{9}{8}
|
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt]{->}{9}{8}
|
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=12pt]{->}{8}{9}
|
|
||||||
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{2}{10}
|
\draw[edge](2)--(10);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt,nodesepB=10pt]{->}{2}{10}
|
\draw[halfedge,shorten >=10pt](2)to(10);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepB=1pt]{->}{10}{2}
|
\draw[halfedge](10)to(2);
|
||||||
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{10}{9}
|
\draw[edge](10)--(9);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepB=1pt]{->}{10}{9}
|
\draw[halfedge](10)to(9);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=16pt,nodesepB=10pt]{->}{9}{10}
|
\draw[halfedge,shorten <=13pt,shorten >=9.4pt](9)to(10);
|
||||||
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{9}{7}
|
\draw[edge](9)--(7);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=16pt,nodesepB=1pt]{->}{9}{7}
|
\draw[halfedge,shorten <=13pt](9)to(7);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{7}{9}
|
\draw[halfedge](7)to(9);
|
||||||
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{4}{11}
|
\draw[edge](4)--(11);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt]{->}{4}{11}
|
\draw[halfedge](4)to(11);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=1pt]{->}{11}{4}
|
\draw[halfedge,shorten <=2pt](11)to(4);
|
||||||
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{11}{9}
|
\draw[edge](11)--(9);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt]{->}{9}{11}
|
\draw[halfedge](9)to(11);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=2pt]{->}{11}{9}
|
\draw[halfedge,shorten <=2pt,shorten >=1pt](11)to(9);
|
||||||
|
|
||||||
\ncline[linewidth=0.5pt,linecolor=blue]{9}{5}
|
\draw[edge](9)--(5);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{9}{5}
|
\draw[halfedge](9)to(5);
|
||||||
\ncline[linewidth=0.25pt,offset=3pt,,nodesepA=1pt,nodesepB=2pt]{->}{5}{9}
|
\draw[halfedge,shorten >=1.2pt](5)to(9);
|
||||||
%
|
%
|
||||||
\rput(2,6.5){$\tilde{f}$}
|
\node at(2,6.5){$\tilde{f}$};
|
||||||
\rput(6.2,5.2){$f_1$}
|
\node at(6.2,5.2){$f_1$};
|
||||||
\rput(8.5,4.4){$f_2$}
|
\node at(8.5,4.4){$f_2$};
|
||||||
\rput(8.3,3.4){$f_3$}
|
\node at(8.3,3.4){$f_3$};
|
||||||
\rput(6.2,2){$f_4$}
|
\node at(6.2,2){$f_4$};
|
||||||
\rput(3.8,2){$f_5$}
|
\node at(3.8,2){$f_5$};
|
||||||
\rput(1.7,3.4){$f_6$}
|
\node at(1.7,3.4){$f_6$};
|
||||||
\rput(1.5,4.4){$f_7$}
|
\node at(1.5,4.4){$f_7$};
|
||||||
\rput(3.8,5.2){$f_8$}
|
\node at (3.8,5.2){$f_8$};
|
||||||
\end{pspicture}
|
\end{tikzpicture}
|
||||||
}
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/Arr_tags.h>
|
#include <CGAL/Arr_tags.h>
|
||||||
|
#include <CGAL/Arr_default_dcel.h>
|
||||||
#include <CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h>
|
#include <CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h>
|
||||||
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h>
|
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_construction_helper.h>
|
||||||
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h>
|
#include <CGAL/Arr_topology_traits/Arr_bounded_planar_insertion_helper.h>
|
||||||
|
|
|
||||||
|
|
@ -3316,9 +3316,9 @@ public:
|
||||||
// sqrt((r - s)^2 + t^2)
|
// sqrt((r - s)^2 + t^2)
|
||||||
//
|
//
|
||||||
const int or_fact = (cv.orientation() == CLOCKWISE) ? -1 : 1;
|
const int or_fact = (cv.orientation() == CLOCKWISE) ? -1 : 1;
|
||||||
const Algebraic r = m_nt_traits->convert(or_fact * cv.r());
|
const Algebraic r = m_nt_traits->convert(Integer(or_fact * cv.r()));
|
||||||
const Algebraic s = m_nt_traits->convert(or_fact * cv.s());
|
const Algebraic s = m_nt_traits->convert(Integer(or_fact * cv.s()));
|
||||||
const Algebraic t = m_nt_traits->convert(or_fact * cv.t());
|
const Algebraic t = m_nt_traits->convert(Integer(or_fact * cv.t()));
|
||||||
const Algebraic cos_2phi = (r - s) / m_nt_traits->sqrt((r-s)*(r-s) + t*t);
|
const Algebraic cos_2phi = (r - s) / m_nt_traits->sqrt((r-s)*(r-s) + t*t);
|
||||||
const Algebraic zero = 0;
|
const Algebraic zero = 0;
|
||||||
const Algebraic one = 1;
|
const Algebraic one = 1;
|
||||||
|
|
@ -3363,8 +3363,8 @@ public:
|
||||||
// 4*r*s - t^2 4*r*s - t^2
|
// 4*r*s - t^2 4*r*s - t^2
|
||||||
//
|
//
|
||||||
// The denominator (4*r*s - t^2) must be negative for hyperbolas.
|
// The denominator (4*r*s - t^2) must be negative for hyperbolas.
|
||||||
const Algebraic u = m_nt_traits->convert(or_fact * cv.u());
|
const Algebraic u = m_nt_traits->convert(Integer(or_fact * cv.u()));
|
||||||
const Algebraic v = m_nt_traits->convert(or_fact * cv.v());
|
const Algebraic v = m_nt_traits->convert(Integer(or_fact * cv.v()));
|
||||||
const Algebraic det = 4*r*s - t*t;
|
const Algebraic det = 4*r*s - t*t;
|
||||||
Algebraic x0, y0;
|
Algebraic x0, y0;
|
||||||
|
|
||||||
|
|
@ -3803,9 +3803,9 @@ public:
|
||||||
auto u = cv.u();
|
auto u = cv.u();
|
||||||
auto v = cv.v();
|
auto v = cv.v();
|
||||||
auto w = cv.w();
|
auto w = cv.w();
|
||||||
Algebraic* xs_end = m_nt_traits->solve_quadratic_equation(t*t - four*r*s,
|
Algebraic* xs_end = m_nt_traits->solve_quadratic_equation(Integer(t*t - four*r*s),
|
||||||
two*t*v - four*s*u,
|
Integer(two*t*v - four*s*u),
|
||||||
v*v - four*s*w,
|
Integer(v*v - four*s*w),
|
||||||
xs);
|
xs);
|
||||||
auto n_xs = static_cast<int>(xs_end - xs);
|
auto n_xs = static_cast<int>(xs_end - xs);
|
||||||
|
|
||||||
|
|
@ -3816,15 +3816,15 @@ public:
|
||||||
|
|
||||||
if (CGAL::sign(cv.t()) == ZERO) {
|
if (CGAL::sign(cv.t()) == ZERO) {
|
||||||
// The two vertical tangency points have the same y coordinate:
|
// The two vertical tangency points have the same y coordinate:
|
||||||
ys[0] = m_nt_traits->convert(-v) / m_nt_traits->convert(two*s);
|
ys[0] = m_nt_traits->convert(Integer(- v)) / m_nt_traits->convert(Integer(two * s));
|
||||||
n_ys = 1;
|
n_ys = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ys_end = m_nt_traits->solve_quadratic_equation(four*r*s*s - s*t*t,
|
ys_end = m_nt_traits->solve_quadratic_equation(Integer(four*r*s*s - s*t*t),
|
||||||
four*r*s*v - two*s*t*u,
|
Integer(four*r*s*v - two*s*t*u),
|
||||||
r*v*v - t*u*v +
|
Integer((r*v*v - t*u*v) + (t*t*w)),
|
||||||
t*t*w,
|
|
||||||
ys);
|
ys);
|
||||||
|
|
||||||
n_ys = static_cast<int>(ys_end - ys);
|
n_ys = static_cast<int>(ys_end - ys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3837,7 +3837,7 @@ public:
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int j = 0; j < n_ys; ++j) {
|
for (int j = 0; j < n_ys; ++j) {
|
||||||
if (CGAL::compare(m_nt_traits->convert(two*s) * ys[j],
|
if (CGAL::compare(m_nt_traits->convert(Integer(two*s)) * ys[j],
|
||||||
-(m_nt_traits->convert(t) * xs[i] +
|
-(m_nt_traits->convert(t) * xs[i] +
|
||||||
m_nt_traits->convert(v))) == EQUAL)
|
m_nt_traits->convert(v))) == EQUAL)
|
||||||
{
|
{
|
||||||
|
|
@ -3904,10 +3904,11 @@ public:
|
||||||
auto u = cv.u();
|
auto u = cv.u();
|
||||||
auto v = cv.v();
|
auto v = cv.v();
|
||||||
auto w = cv.w();
|
auto w = cv.w();
|
||||||
Algebraic* ys_end = m_nt_traits->solve_quadratic_equation(t*t - four*r*s,
|
Algebraic* ys_end = m_nt_traits->template
|
||||||
two*t*u - four*r*v,
|
solve_quadratic_equation<Integer>(t*t - four*r*s,
|
||||||
u*u - four*r*w,
|
two*t*u - four*r*v,
|
||||||
ys);
|
u*u - four*r*w,
|
||||||
|
ys);
|
||||||
auto n = static_cast<int>(ys_end - ys);
|
auto n = static_cast<int>(ys_end - ys);
|
||||||
|
|
||||||
// Compute the x coordinates and construct the horizontal tangency points.
|
// Compute the x coordinates and construct the horizontal tangency points.
|
||||||
|
|
@ -3915,7 +3916,7 @@ public:
|
||||||
// Having computed y, x is the single solution to the quadratic equation
|
// Having computed y, x is the single solution to the quadratic equation
|
||||||
// above, and since its discriminant is 0, x is simply given by:
|
// above, and since its discriminant is 0, x is simply given by:
|
||||||
Algebraic x = -(m_nt_traits->convert(t)*ys[i] + m_nt_traits->convert(u)) /
|
Algebraic x = -(m_nt_traits->convert(t)*ys[i] + m_nt_traits->convert(u)) /
|
||||||
m_nt_traits->convert(two*r);
|
m_nt_traits->convert(Integer(two*r));
|
||||||
ps[i] = Point_2(x, ys[i]);
|
ps[i] = Point_2(x, ys[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
// Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel).
|
||||||
|
// All rights reserved.
|
||||||
|
//
|
||||||
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
//
|
||||||
|
// $URL$
|
||||||
|
// $Id$
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author(s): Ron Wein <wein@post.tau.ac.il>
|
||||||
|
// Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||||
|
// Efi Fogel <efifogel@gmail.com>
|
||||||
|
|
||||||
|
#ifndef CGAL_ARR_DCEL_H
|
||||||
|
#define CGAL_ARR_DCEL_H
|
||||||
|
|
||||||
|
#include <CGAL/license/Arrangement_on_surface_2.h>
|
||||||
|
|
||||||
|
#include <CGAL/disable_warnings.h>
|
||||||
|
|
||||||
|
/*! \file
|
||||||
|
* The definition of the Arr_dcel<Traits> class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <CGAL/Arr_dcel_base.h>
|
||||||
|
|
||||||
|
namespace CGAL {
|
||||||
|
|
||||||
|
/*! \class
|
||||||
|
* The arrangement DCEL class.
|
||||||
|
* The Traits parameters corresponds to a geometric traits class, which
|
||||||
|
* defines the Point_2 and X_monotone_curve_2 types.
|
||||||
|
*/
|
||||||
|
template <typename Traits,
|
||||||
|
typename V = Arr_vertex_base<typename Traits::Point_2>,
|
||||||
|
typename H = Arr_halfedge_base<typename Traits::X_monotone_curve_2>,
|
||||||
|
typename F = Arr_face_base>
|
||||||
|
class Arr_dcel : public Arr_dcel_base<V, H, F> {
|
||||||
|
public:
|
||||||
|
/*! \struct
|
||||||
|
* An auxiliary structure for rebinding the DCEL with a new traits class.
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
struct rebind {
|
||||||
|
private:
|
||||||
|
using Pnt = typename T::Point_2;
|
||||||
|
using Xcv = typename T::X_monotone_curve_2;
|
||||||
|
using Rebind_v = typename V::template rebind<Pnt>;
|
||||||
|
using V_other = typename Rebind_v::other;
|
||||||
|
using Rebind_h = typename H::template rebind<Xcv>;
|
||||||
|
using H_other = typename Rebind_h::other;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using other = Arr_dcel<T, V_other, H_other, F>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*! Default constructor. */
|
||||||
|
Arr_dcel() {}
|
||||||
|
|
||||||
|
/*! Destructor. */
|
||||||
|
virtual ~Arr_dcel() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace CGAL
|
||||||
|
|
||||||
|
#include <CGAL/enable_warnings.h>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -8,8 +8,9 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Ron Wein <wein@post.tau.ac.il>
|
// Author(s): Ron Wein <wein@post.tau.ac.il>
|
||||||
// (based on old version by: Iddo Hanniel and Oren Nechushtan)
|
// Efi Fogel <efif@post.tau.ac.il>
|
||||||
|
// (based on old version by: Iddo Hanniel and Oren Nechushtan)
|
||||||
|
|
||||||
#ifndef CGAL_ARR_DCEL_BASE_H
|
#ifndef CGAL_ARR_DCEL_BASE_H
|
||||||
#define CGAL_ARR_DCEL_BASE_H
|
#define CGAL_ARR_DCEL_BASE_H
|
||||||
|
|
@ -23,11 +24,12 @@
|
||||||
* peripheral records.
|
* peripheral records.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <CGAL/Arr_enums.h>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <CGAL/N_step_adaptor_derived.h>
|
|
||||||
|
#include <CGAL/basic.h>
|
||||||
|
#include <CGAL/Arr_enums.h>
|
||||||
|
#include <CGAL/iterator.h>
|
||||||
#include <CGAL/In_place_list.h>
|
#include <CGAL/In_place_list.h>
|
||||||
#include <CGAL/function_objects.h>
|
#include <CGAL/function_objects.h>
|
||||||
#include <CGAL/Iterator_project.h>
|
#include <CGAL/Iterator_project.h>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel).
|
// Copyright (c) 2023 Tel-Aviv University (Israel).
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org).
|
// This file is part of CGAL (www.cgal.org).
|
||||||
|
|
@ -8,8 +8,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Ron Wein <wein@post.tau.ac.il>
|
// Author(s): Efi Fogel <efifogel@gmail.com>
|
||||||
// Baruch Zukerman <baruchzu@post.tau.ac.il>
|
|
||||||
|
|
||||||
#ifndef CGAL_ARR_DEFAULT_DCEL_H
|
#ifndef CGAL_ARR_DEFAULT_DCEL_H
|
||||||
#define CGAL_ARR_DEFAULT_DCEL_H
|
#define CGAL_ARR_DEFAULT_DCEL_H
|
||||||
|
|
@ -19,46 +18,19 @@
|
||||||
#include <CGAL/disable_warnings.h>
|
#include <CGAL/disable_warnings.h>
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
* The definition of the Arr_default_dcel<Traits> class.
|
* The definition of the Arr_default_dcel<Traits> type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/Arr_dcel_base.h>
|
#include <CGAL/Arr_dcel.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*! \class
|
/*! The default arrangement DCEL type.
|
||||||
* The default arrangement DCEL class.
|
|
||||||
* The Traits parameters corresponds to a geometric traits class, which
|
* The Traits parameters corresponds to a geometric traits class, which
|
||||||
* defines the Point_2 and X_monotone_curve_2 types.
|
* defines the Point_2 and X_monotone_curve_2 types.
|
||||||
*/
|
*/
|
||||||
template <class Traits_>
|
template <typename Traits> using Arr_default_dcel = Arr_dcel<Traits>;
|
||||||
class Arr_default_dcel :
|
|
||||||
public Arr_dcel_base<Arr_vertex_base<typename Traits_::Point_2>,
|
|
||||||
Arr_halfedge_base<typename Traits_::X_monotone_curve_2>,
|
|
||||||
Arr_face_base>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
/*! \struct
|
|
||||||
* An auxiliary structure for rebinding the DCEL with a new traits class.
|
|
||||||
*/
|
|
||||||
template<typename T>
|
|
||||||
struct rebind
|
|
||||||
{
|
|
||||||
typedef Arr_default_dcel<T> other;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! Default constructor. */
|
|
||||||
Arr_default_dcel()
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*! Destructor. */
|
|
||||||
virtual ~Arr_default_dcel()
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
||||||
#include <CGAL/enable_warnings.h>
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Ron Wein <wein@post.tau.ac.il>
|
// Author(s): Ron Wein <wein@post.tau.ac.il>
|
||||||
// Baruch Zukerman <baruchzu@post.tau.ac.il>
|
// Baruch Zukerman <baruchzu@post.tau.ac.il>
|
||||||
|
// Efi Fogel <efif@post.tau.ac.il>
|
||||||
|
|
||||||
#ifndef CGAL_ARR_DEFAULT_OVERLAY_TRAITS_H
|
#ifndef CGAL_ARR_DEFAULT_OVERLAY_TRAITS_H
|
||||||
#define CGAL_ARR_DEFAULT_OVERLAY_TRAITS_H
|
#define CGAL_ARR_DEFAULT_OVERLAY_TRAITS_H
|
||||||
|
|
@ -23,7 +24,6 @@
|
||||||
* Definition of default overlay-traits classes.
|
* Definition of default overlay-traits classes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/Arr_default_dcel.h>
|
|
||||||
#include <CGAL/Arr_extended_dcel.h>
|
#include <CGAL/Arr_extended_dcel.h>
|
||||||
#include <CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h>
|
#include <CGAL/Surface_sweep_2/Arr_default_overlay_traits_base.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s) : Ron Wein <wein@post.tau.ac.il>
|
// Author(s): Ron Wein <wein@post.tau.ac.il>
|
||||||
// Efi Fogel <efif@post.tau.ac.il>
|
// Efi Fogel <efif@post.tau.ac.il>
|
||||||
|
|
||||||
#ifndef CGAL_ARR_EXTENDED_DCEL_H
|
#ifndef CGAL_ARR_EXTENDED_DCEL_H
|
||||||
#define CGAL_ARR_EXTENDED_DCEL_H
|
#define CGAL_ARR_EXTENDED_DCEL_H
|
||||||
|
|
@ -26,142 +26,115 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
/*!
|
/*! \class
|
||||||
* \class
|
|
||||||
* An extended DCEL vertex with auxiliary data field.
|
* An extended DCEL vertex with auxiliary data field.
|
||||||
*/
|
*/
|
||||||
template <class VertexBase_, typename VertexData_>
|
template <typename VertexBase, typename VertexData>
|
||||||
class Arr_extended_vertex : public VertexBase_
|
class Arr_extended_vertex : public VertexBase {
|
||||||
{
|
using Vertex_base = VertexBase;
|
||||||
typedef Arr_extended_vertex<VertexBase_, VertexData_> Self;
|
using Vertex_data = VertexData;
|
||||||
typedef VertexBase_ Base;
|
|
||||||
|
using Self = Arr_extended_vertex<Vertex_base, Vertex_data>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef VertexData_ Data;
|
typedef Vertex_data Data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Data m_data; // The auxiliary data field.
|
||||||
Data m_data; // The auxiliary data field.
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*! Get the auxiliary data (const version). */
|
/*! Get the auxiliary data (const version). */
|
||||||
const Data& data () const
|
const Data& data() const { return m_data; }
|
||||||
{
|
|
||||||
return (m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get the auxiliary data (non-const version). */
|
/*! Get the auxiliary data (non-const version). */
|
||||||
Data& data ()
|
Data& data() { return m_data; }
|
||||||
{
|
|
||||||
return (m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Set the auxiliary data. */
|
/*! Set the auxiliary data. */
|
||||||
void set_data (const Data& data)
|
void set_data(const Data& data) { m_data = data; }
|
||||||
{
|
|
||||||
m_data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Assign from another vertex. */
|
/*! Assign from another vertex. */
|
||||||
virtual void assign (const Base& v)
|
virtual void assign(const Vertex_base& v) {
|
||||||
{
|
Vertex_base::assign(v);
|
||||||
Base::assign (v);
|
const Self& ex_v = static_cast<const Self&>(v);
|
||||||
|
|
||||||
const Self& ex_v = static_cast<const Self&>(v);
|
|
||||||
m_data = ex_v.m_data;
|
m_data = ex_v.m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Point_>
|
||||||
|
struct rebind {
|
||||||
|
using Point_2 = Point_;
|
||||||
|
using other = typename Vertex_base::template rebind<Point_2>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*! \class
|
||||||
* \class
|
|
||||||
* An extended DCEL halfedge with auxiliary data field.
|
* An extended DCEL halfedge with auxiliary data field.
|
||||||
*/
|
*/
|
||||||
template <class HalfedgeBase_, typename HalfedgeData_>
|
template <typename HalfedgeBase, typename HalfedgeData>
|
||||||
class Arr_extended_halfedge : public HalfedgeBase_
|
class Arr_extended_halfedge : public HalfedgeBase {
|
||||||
{
|
using Halfedge_base = HalfedgeBase;
|
||||||
typedef Arr_extended_halfedge<HalfedgeBase_, HalfedgeData_> Self;
|
using Halfedge_data = HalfedgeData;
|
||||||
typedef HalfedgeBase_ Base;
|
|
||||||
|
using Self = Arr_extended_halfedge<Halfedge_base, Halfedge_data>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef HalfedgeData_ Data;
|
typedef Halfedge_data Data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Data m_data; // The auxiliary data field.
|
||||||
Data m_data; // The auxiliary data field.
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*! Get the auxiliary data (const version). */
|
/*! Get the auxiliary data (const version). */
|
||||||
const Data& data () const
|
const Data& data() const { return m_data; }
|
||||||
{
|
|
||||||
return (m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get the auxiliary data (non-const version). */
|
/*! Get the auxiliary data (non-const version). */
|
||||||
Data& data ()
|
Data& data() { return m_data; }
|
||||||
{
|
|
||||||
return (m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Set the auxiliary data. */
|
/*! Set the auxiliary data. */
|
||||||
void set_data (const Data& data)
|
void set_data(const Data& data) { m_data = data; }
|
||||||
{
|
|
||||||
m_data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Assign from another vertex. */
|
/*! Assign from another halfedge. */
|
||||||
virtual void assign (const Base& he)
|
virtual void assign(const Halfedge_base& he) {
|
||||||
{
|
Halfedge_base::assign(he);
|
||||||
Base::assign (he);
|
const Self& ex_he = static_cast<const Self&>(he);
|
||||||
|
|
||||||
const Self& ex_he = static_cast<const Self&>(he);
|
|
||||||
m_data = ex_he.m_data;
|
m_data = ex_he.m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename XMonotoneCurve>
|
||||||
|
struct rebind {
|
||||||
|
using X_monotonote_curve_2 = XMonotoneCurve;
|
||||||
|
using other = typename Halfedge_base::template rebind<X_monotonote_curve_2>;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*! \class
|
||||||
* \class
|
|
||||||
* An extended DCEL face with auxiliary data field.
|
* An extended DCEL face with auxiliary data field.
|
||||||
*/
|
*/
|
||||||
template <class FaceBase_, typename FaceData_>
|
template <typename FaceBase, typename FaceData>
|
||||||
class Arr_extended_face : public FaceBase_
|
class Arr_extended_face : public FaceBase {
|
||||||
{
|
using Face_base = FaceBase;
|
||||||
typedef Arr_extended_face<FaceBase_, FaceData_> Self;
|
using Face_data = FaceData;
|
||||||
typedef FaceBase_ Base;
|
|
||||||
|
using Self = Arr_extended_face<Face_base, Face_data>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef FaceData_ Data;
|
typedef Face_data Data;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Data m_data; // The auxiliary data field.
|
||||||
Data m_data; // The auxiliary data field.
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/*! Get the auxiliary data (const version). */
|
/*! Get the auxiliary data (const version). */
|
||||||
const Data& data () const
|
const Data& data() const { return m_data; }
|
||||||
{
|
|
||||||
return (m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get the auxiliary data (non-const version). */
|
/*! Get the auxiliary data (non-const version). */
|
||||||
Data& data ()
|
Data& data() { return m_data; }
|
||||||
{
|
|
||||||
return (m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Set the auxiliary data. */
|
/*! Set the auxiliary data. */
|
||||||
void set_data (const Data& data)
|
void set_data(const Data& data) { m_data = data; }
|
||||||
{
|
|
||||||
m_data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Assign from another vertex. */
|
|
||||||
virtual void assign (const Base& f)
|
|
||||||
{
|
|
||||||
Base::assign (f);
|
|
||||||
|
|
||||||
|
/*! Assign from another face. */
|
||||||
|
virtual void assign(const Face_base& f) {
|
||||||
|
Face_base::assign(f);
|
||||||
const Self& ex_f = static_cast<const Self&>(f);
|
const Self& ex_f = static_cast<const Self&>(f);
|
||||||
m_data = ex_f.m_data;
|
m_data = ex_f.m_data;
|
||||||
}
|
}
|
||||||
|
|
@ -173,49 +146,41 @@ public:
|
||||||
* defines the Point_2 and X_monotone_curve_2 types.
|
* defines the Point_2 and X_monotone_curve_2 types.
|
||||||
* The FaceData parameter specifies the object type stored with each face.
|
* The FaceData parameter specifies the object type stored with each face.
|
||||||
*/
|
*/
|
||||||
template <class Traits_, typename FaceData_,
|
template <typename Traits_, typename FaceData,
|
||||||
class VertexBase_ = Arr_vertex_base<typename Traits_::Point_2>,
|
typename VertexBase = Arr_vertex_base<typename Traits_::Point_2>,
|
||||||
class HalfedgeBase_ =
|
typename HalfedgeBase =
|
||||||
Arr_halfedge_base<typename Traits_::X_monotone_curve_2>,
|
Arr_halfedge_base<typename Traits_::X_monotone_curve_2>,
|
||||||
class FaceBase_ = Arr_face_base>
|
typename FaceBase = Arr_face_base>
|
||||||
class Arr_face_extended_dcel :
|
class Arr_face_extended_dcel :
|
||||||
public Arr_dcel_base<VertexBase_,
|
public Arr_dcel_base<VertexBase, HalfedgeBase,
|
||||||
HalfedgeBase_,
|
Arr_extended_face<FaceBase, FaceData>> {
|
||||||
Arr_extended_face<FaceBase_, FaceData_> >
|
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
using Face_base = FaceBase;
|
||||||
typedef FaceData_ Face_data;
|
using Face_data = FaceData;
|
||||||
|
|
||||||
/*! \struct
|
/*! \struct
|
||||||
* An auxiliary structure for rebinding the DCEL with a new traits class.
|
* An auxiliary structure for rebinding the DCEL with a new traits class.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template <typename T>
|
||||||
class rebind
|
class rebind {
|
||||||
{
|
private:
|
||||||
typedef typename VertexBase_::template rebind
|
using Pnt = typename T::Point_2;
|
||||||
<typename T::Point_2> Rebind_vertex;
|
using Xcv = typename T::X_monotone_curve_2;
|
||||||
typedef typename Rebind_vertex::other Vertex_base;
|
using Rebind_vertex = typename VertexBase::template rebind<Pnt>;
|
||||||
typedef typename HalfedgeBase_::template rebind
|
using Vertex_other = typename Rebind_vertex::other;
|
||||||
<typename T::X_monotone_curve_2> Rebind_halfedge;
|
using Rebind_halfedge = typename HalfedgeBase::template rebind<Xcv>;
|
||||||
typedef typename Rebind_halfedge::other Halfedge_base;
|
using Halfedge_other = typename Rebind_halfedge::other;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using other = Arr_face_extended_dcel<T, Face_data, Vertex_other,
|
||||||
typedef Arr_face_extended_dcel<T,
|
Halfedge_other, Face_base>;
|
||||||
Face_data,
|
|
||||||
Vertex_base,
|
|
||||||
Halfedge_base,
|
|
||||||
FaceBase_> other;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Default constructor. */
|
/*! Default constructor. */
|
||||||
Arr_face_extended_dcel ()
|
Arr_face_extended_dcel() {}
|
||||||
{}
|
|
||||||
|
|
||||||
/*! Destructor. */
|
/*! Destructor. */
|
||||||
virtual ~Arr_face_extended_dcel ()
|
virtual ~Arr_face_extended_dcel() {}
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \class
|
/*! \class
|
||||||
|
|
@ -225,54 +190,48 @@ public:
|
||||||
* The VertexData, HalfedgeData and FaceData parameter specify the object types
|
* The VertexData, HalfedgeData and FaceData parameter specify the object types
|
||||||
* stored with each vertex, halfedge and face, respectively.
|
* stored with each vertex, halfedge and face, respectively.
|
||||||
*/
|
*/
|
||||||
template <class Traits_,
|
template <typename Traits_,
|
||||||
typename VertexData_, typename HalfedgeData_, typename FaceData_,
|
typename VertexData, typename HalfedgeData, typename FaceData,
|
||||||
class VertexBase_ = Arr_vertex_base<typename Traits_::Point_2>,
|
typename VertexBase = Arr_vertex_base<typename Traits_::Point_2>,
|
||||||
class HalfedgeBase_ =
|
typename HalfedgeBase =
|
||||||
Arr_halfedge_base<typename Traits_::X_monotone_curve_2>,
|
Arr_halfedge_base<typename Traits_::X_monotone_curve_2>,
|
||||||
class FaceBase_ = Arr_face_base>
|
typename FaceBase = Arr_face_base>
|
||||||
class Arr_extended_dcel :
|
class Arr_extended_dcel :
|
||||||
public Arr_dcel_base<Arr_extended_vertex<VertexBase_, VertexData_>,
|
public Arr_dcel_base<Arr_extended_vertex<VertexBase, VertexData>,
|
||||||
Arr_extended_halfedge<HalfedgeBase_, HalfedgeData_>,
|
Arr_extended_halfedge<HalfedgeBase, HalfedgeData>,
|
||||||
Arr_extended_face<FaceBase_, FaceData_> >
|
Arr_extended_face<FaceBase, FaceData>> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
|
using Vertex_data = VertexData;
|
||||||
typedef VertexData_ Vertex_data;
|
using Halfedge_data = HalfedgeData;
|
||||||
typedef HalfedgeData_ Halfedge_data;
|
using Face_data = FaceData;
|
||||||
typedef FaceData_ Face_data;
|
using Vertex_base = VertexBase;
|
||||||
|
using Halfedge_base = HalfedgeBase;
|
||||||
|
using Face_base = FaceBase;
|
||||||
|
|
||||||
/*! \struct
|
/*! \struct
|
||||||
* An auxiliary structure for rebinding the DCEL with a new traits class.
|
* An auxiliary structure for rebinding the DCEL with a new traits class.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template <typename T>
|
||||||
class rebind
|
struct rebind {
|
||||||
{
|
private:
|
||||||
typedef typename VertexBase_::template rebind
|
using Pnt = typename T::Point_2;
|
||||||
<typename T::Point_2> Rebind_vertex;
|
using Xcv = typename T::X_monotone_curve_2;
|
||||||
typedef typename Rebind_vertex::other Vertex_base;
|
using Rebind_vertex = typename VertexBase::template rebind<Pnt>;
|
||||||
typedef typename HalfedgeBase_::template rebind
|
using Vertex_other = typename Rebind_vertex::other;
|
||||||
<typename T::X_monotone_curve_2> Rebind_halfedge;
|
using Rebind_halfedge = typename HalfedgeBase::template rebind<Xcv>;
|
||||||
typedef typename Rebind_halfedge::other Halfedge_base;
|
using Halfedge_other = typename Rebind_halfedge::other;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using other = Arr_extended_dcel<T,
|
||||||
typedef Arr_extended_dcel<T,
|
Vertex_data, Halfedge_data, Face_data,
|
||||||
Vertex_data,
|
Vertex_other, Halfedge_other, Face_base>;
|
||||||
Halfedge_data,
|
|
||||||
Face_data,
|
|
||||||
Vertex_base,
|
|
||||||
Halfedge_base,
|
|
||||||
FaceBase_> other;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Default constructor. */
|
/*! Default constructor. */
|
||||||
Arr_extended_dcel ()
|
Arr_extended_dcel() {}
|
||||||
{}
|
|
||||||
|
|
||||||
/*! Destructor. */
|
/*! Destructor. */
|
||||||
virtual ~Arr_extended_dcel ()
|
virtual ~Arr_extended_dcel() {}
|
||||||
{}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -1430,8 +1430,8 @@ protected:
|
||||||
{
|
{
|
||||||
// Actually compare the slopes.
|
// Actually compare the slopes.
|
||||||
const bool swap_res = (sign_denom1 != sign_denom2);
|
const bool swap_res = (sign_denom1 != sign_denom2);
|
||||||
const CoordNT A = (cv.y0() - y0())*p.x() + (y0()*cv.x0() - cv.y0()*x0());
|
const CoordNT A = NT(cv.y0() - y0())*p.x() + (y0()*cv.x0() - cv.y0()*x0());
|
||||||
const CoordNT B = (cv.x0() - x0())*p.y();
|
const CoordNT B = NT(cv.x0() - x0())*p.y();
|
||||||
|
|
||||||
slope_res = CGAL::compare (A, B);
|
slope_res = CGAL::compare (A, B);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1110,9 +1110,9 @@ protected:
|
||||||
//
|
//
|
||||||
Nt_traits nt_traits;
|
Nt_traits nt_traits;
|
||||||
const int or_fact = (m_orient == CLOCKWISE) ? -1 : 1;
|
const int or_fact = (m_orient == CLOCKWISE) ? -1 : 1;
|
||||||
const Algebraic r = nt_traits.convert(or_fact * m_r);
|
const Algebraic r = nt_traits.convert(Integer(or_fact * m_r));
|
||||||
const Algebraic s = nt_traits.convert(or_fact * m_s);
|
const Algebraic s = nt_traits.convert(Integer(or_fact * m_s));
|
||||||
const Algebraic t = nt_traits.convert(or_fact * m_t);
|
const Algebraic t = nt_traits.convert(Integer(or_fact * m_t));
|
||||||
const Algebraic cos_2phi = (r - s) / nt_traits.sqrt((r-s)*(r-s) + t*t);
|
const Algebraic cos_2phi = (r - s) / nt_traits.sqrt((r-s)*(r-s) + t*t);
|
||||||
const Algebraic zero = 0;
|
const Algebraic zero = 0;
|
||||||
const Algebraic one = 1;
|
const Algebraic one = 1;
|
||||||
|
|
@ -1158,8 +1158,8 @@ protected:
|
||||||
// 4*r*s - t^2 4*r*s - t^2
|
// 4*r*s - t^2 4*r*s - t^2
|
||||||
//
|
//
|
||||||
// The denominator (4*r*s - t^2) must be negative for hyperbolas.
|
// The denominator (4*r*s - t^2) must be negative for hyperbolas.
|
||||||
const Algebraic u = nt_traits.convert(or_fact * m_u);
|
const Algebraic u = nt_traits.convert(Integer(or_fact * m_u));
|
||||||
const Algebraic v = nt_traits.convert(or_fact * m_v);
|
const Algebraic v = nt_traits.convert(Integer(or_fact * m_v));
|
||||||
const Algebraic det = 4*r*s - t*t;
|
const Algebraic det = 4*r*s - t*t;
|
||||||
Algebraic x0, y0;
|
Algebraic x0, y0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,9 @@ int compute_resultant_roots(const Nt_traits& nt_traits,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Act according to the degree of the first conic curve.
|
// Act according to the degree of the first conic curve.
|
||||||
const typename Nt_traits::Integer two = 2;
|
typedef typename Nt_traits::Integer Integer;
|
||||||
typename Nt_traits::Integer c[5];
|
const Integer two = 2;
|
||||||
|
Integer c[5];
|
||||||
unsigned int degree = 4;
|
unsigned int degree = 4;
|
||||||
typename Nt_traits::Algebraic* xs_end;
|
typename Nt_traits::Algebraic* xs_end;
|
||||||
|
|
||||||
|
|
@ -73,7 +74,7 @@ int compute_resultant_roots(const Nt_traits& nt_traits,
|
||||||
// The first curve has no quadratic coefficients, and represents a line.
|
// The first curve has no quadratic coefficients, and represents a line.
|
||||||
if (CGAL::sign (v1) == ZERO) {
|
if (CGAL::sign (v1) == ZERO) {
|
||||||
// The first line is u1*x + w1 = 0, therefore:
|
// The first line is u1*x + w1 = 0, therefore:
|
||||||
xs[0] = nt_traits.convert(-w1) / nt_traits.convert(u1);
|
xs[0] = nt_traits.convert(Integer(- w1)) / nt_traits.convert(u1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,7 +88,7 @@ int compute_resultant_roots(const Nt_traits& nt_traits,
|
||||||
// Return if the two lines are parallel
|
// Return if the two lines are parallel
|
||||||
if (CGAL::sign (c[1]) == ZERO) return 0;
|
if (CGAL::sign (c[1]) == ZERO) return 0;
|
||||||
|
|
||||||
xs[0] = nt_traits.convert(-c[0]) / nt_traits.convert(c[1]);
|
xs[0] = nt_traits.convert(Integer(- c[0])) / nt_traits.convert(c[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,10 +225,11 @@ public:
|
||||||
if (CGAL::compare(
|
if (CGAL::compare(
|
||||||
CGAL::width(y_bfi),
|
CGAL::width(y_bfi),
|
||||||
CGAL::lower(CGAL::abs(y_bfi)) * eps)
|
CGAL::lower(CGAL::abs(y_bfi)) * eps)
|
||||||
== SMALLER)
|
== SMALLER){
|
||||||
return std::make_pair(
|
return std::make_pair(
|
||||||
Bound(CGAL::lower(y_bfi)),
|
Bound(CGAL::lower(y_bfi)),
|
||||||
Bound(CGAL::upper(y_bfi)));
|
Bound(CGAL::upper(y_bfi)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else precision*=2;
|
else precision*=2;
|
||||||
}
|
}
|
||||||
|
|
@ -287,10 +288,11 @@ private:
|
||||||
if (CGAL::zero_in(y_denom_bfi) == false)
|
if (CGAL::zero_in(y_denom_bfi) == false)
|
||||||
{
|
{
|
||||||
BFI y_bfi(y_numer_bfi/y_denom_bfi);
|
BFI y_bfi(y_numer_bfi/y_denom_bfi);
|
||||||
if (CGAL::width(y_bfi) < eps )
|
if (CGAL::width(y_bfi) < eps ){
|
||||||
return std::make_pair(
|
return std::make_pair(
|
||||||
Bound(CGAL::lower(y_bfi)),
|
Bound(CGAL::lower(y_bfi)),
|
||||||
Bound(CGAL::upper(y_bfi)));
|
Bound(CGAL::upper(y_bfi)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else precision*=2;
|
else precision*=2;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <CGAL/Arr_tags.h>
|
#include <CGAL/Arr_tags.h>
|
||||||
|
#include <CGAL/Arr_default_dcel.h>
|
||||||
#include <CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h>
|
#include <CGAL/Arr_topology_traits/Arr_planar_topology_traits_base_2.h>
|
||||||
#include <CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h>
|
#include <CGAL/Arr_topology_traits/Arr_unb_planar_construction_helper.h>
|
||||||
#include <CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h>
|
#include <CGAL/Arr_topology_traits/Arr_unb_planar_insertion_helper.h>
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include <CGAL/Arr_tags.h>
|
#include <CGAL/Arr_tags.h>
|
||||||
#include <CGAL/Arrangement_on_surface_2.h>
|
#include <CGAL/Arrangement_on_surface_2.h>
|
||||||
#include <CGAL/Arrangement_2/Arr_default_planar_topology.h>
|
#include <CGAL/Arrangement_2/Arr_default_planar_topology.h>
|
||||||
|
#include <CGAL/Arr_default_dcel.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -577,7 +577,7 @@ public:
|
||||||
return (m_self->compare_y_at_x_right_2_object()(xcv1, xcv2, left1));
|
return (m_self->compare_y_at_x_right_2_object()(xcv1, xcv2, left1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We now that the curves do not share a common endpoint, and we can
|
// We know that the curves do not share a common endpoint, and we can
|
||||||
// compare their relative y-position (which does not change to the left
|
// compare their relative y-position (which does not change to the left
|
||||||
// of the given point p).
|
// of the given point p).
|
||||||
return (m_self->compare_y_position_2_object()(xcv1, xcv2));
|
return (m_self->compare_y_position_2_object()(xcv1, xcv2));
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,11 @@
|
||||||
#include <CGAL/HalfedgeDS_iterator.h>
|
#include <CGAL/HalfedgeDS_iterator.h>
|
||||||
#include <CGAL/Arrangement_2/Arrangement_2_iterators.h>
|
#include <CGAL/Arrangement_2/Arrangement_2_iterators.h>
|
||||||
#include <CGAL/In_place_list.h>
|
#include <CGAL/In_place_list.h>
|
||||||
#include <CGAL/Arr_default_dcel.h>
|
|
||||||
#include <CGAL/Aos_observer.h>
|
#include <CGAL/Aos_observer.h>
|
||||||
#include <CGAL/Arr_accessor.h>
|
#include <CGAL/Arr_accessor.h>
|
||||||
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
|
#include <CGAL/Arrangement_2/Arr_traits_adaptor_2.h>
|
||||||
#include <CGAL/function_objects.h>
|
#include <CGAL/function_objects.h>
|
||||||
|
#include <CGAL/iterator.h>
|
||||||
#include <CGAL/Iterator_project.h>
|
#include <CGAL/Iterator_project.h>
|
||||||
#include <CGAL/Iterator_transform.h>
|
#include <CGAL/Iterator_transform.h>
|
||||||
#include <CGAL/Arr_point_location_result.h>
|
#include <CGAL/Arr_point_location_result.h>
|
||||||
|
|
|
||||||
|
|
@ -166,104 +166,75 @@ protected:
|
||||||
// Forward declaration:
|
// Forward declaration:
|
||||||
class Curve_halfedges_observer;
|
class Curve_halfedges_observer;
|
||||||
|
|
||||||
|
public:
|
||||||
/*! \class
|
/*! \class
|
||||||
* Extension of a curve with the set of edges that it induces.
|
* Extension of a curve with the set of edges that it induces.
|
||||||
* Each edge is represented by one of the halfedges.
|
* Each edge is represented by one of the halfedges.
|
||||||
*/
|
*/
|
||||||
class Curve_halfedges : public Curve_2,
|
class Curve_halfedges : public Curve_2,
|
||||||
public In_place_list_base<Curve_halfedges>
|
public In_place_list_base<Curve_halfedges> {
|
||||||
{
|
using Gt = Geometry_traits_2;
|
||||||
|
using Btt = Base_topology_traits;
|
||||||
|
using Aos_wh = Arrangement_on_surface_with_history_2<Gt, Btt>;
|
||||||
|
|
||||||
friend class Curve_halfedges_observer;
|
friend class Curve_halfedges_observer;
|
||||||
friend class Arrangement_on_surface_with_history_2<Geometry_traits_2,
|
friend class Arrangement_on_surface_with_history_2<Gt, Btt>;
|
||||||
Base_topology_traits>;
|
friend class Arr_with_history_accessor<Aos_wh>;
|
||||||
friend class Arr_with_history_accessor<
|
|
||||||
Arrangement_on_surface_with_history_2<Geometry_traits_2,
|
|
||||||
Base_topology_traits> >;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::set<Halfedge_handle, Less_halfedge_handle> Halfedges_set;
|
using Halfedges_set = std::set<Halfedge_handle, Less_halfedge_handle>;
|
||||||
|
|
||||||
// Data members:
|
// Data members:
|
||||||
Halfedges_set m_halfedges;
|
Halfedges_set m_halfedges;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*! Default constructor. */
|
/*! Default constructor. */
|
||||||
Curve_halfedges ()
|
Curve_halfedges() {}
|
||||||
{}
|
|
||||||
|
|
||||||
/*! Constructor from a given curve. */
|
/*! Constructor from a given curve. */
|
||||||
Curve_halfedges (const Curve_2& curve) :
|
Curve_halfedges(const Curve_2& curve) : Curve_2(curve) {}
|
||||||
Curve_2(curve)
|
|
||||||
{}
|
|
||||||
|
|
||||||
typedef typename Halfedges_set::iterator iterator;
|
using iterator = typename Halfedges_set::iterator;
|
||||||
typedef typename Halfedges_set::const_iterator const_iterator;
|
using const_iterator = typename Halfedges_set::const_iterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/*! Get the number of edges induced by the curve. */
|
/*! Get the number of edges induced by the curve. */
|
||||||
Size _size () const
|
Size size() const { return m_halfedges.size(); }
|
||||||
{
|
|
||||||
return (m_halfedges.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get an iterator for the first edge in the set (const version). */
|
/*! Get an iterator for the first edge in the set (const version). */
|
||||||
const_iterator _begin () const
|
const_iterator begin() const { return m_halfedges.begin(); }
|
||||||
{
|
|
||||||
return m_halfedges.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get an iterator for the first edge in the set (non-const version). */
|
/*! Get an iterator for the first edge in the set (non-const version). */
|
||||||
iterator _begin ()
|
iterator begin() { return m_halfedges.begin(); }
|
||||||
{
|
|
||||||
return m_halfedges.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get a past-the-end iterator for the set edges (const version). */
|
/*! Get a past-the-end iterator for the set edges (const version). */
|
||||||
const_iterator _end () const
|
const_iterator end() const { return m_halfedges.end(); }
|
||||||
{
|
|
||||||
return m_halfedges.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Get a past-the-end iterator for the set edges (non-const version). */
|
/*! Get a past-the-end iterator for the set edges (non-const version). */
|
||||||
iterator _end ()
|
iterator end() { return m_halfedges.end(); }
|
||||||
{
|
|
||||||
return m_halfedges.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Insert an edge to the set. */
|
/*! Insert an edge to the set. */
|
||||||
iterator _insert (Halfedge_handle he)
|
iterator _insert(Halfedge_handle he) {
|
||||||
{
|
|
||||||
std::pair<iterator, bool> res = m_halfedges.insert(he);
|
std::pair<iterator, bool> res = m_halfedges.insert(he);
|
||||||
CGAL_assertion(res.second);
|
CGAL_assertion(res.second);
|
||||||
return (res.first);
|
return res.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Erase an edge, given by its position, from the set. */
|
/*! Erase an edge, given by its position, from the set. */
|
||||||
void _erase(iterator pos)
|
void erase(iterator pos) { m_halfedges.erase(pos); }
|
||||||
{
|
|
||||||
m_halfedges.erase(pos);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! Erase an edge from the set. */
|
/*! Erase an edge from the set. */
|
||||||
void _erase (Halfedge_handle he)
|
void _erase(Halfedge_handle he) {
|
||||||
{
|
|
||||||
size_t res = m_halfedges.erase(he);
|
size_t res = m_halfedges.erase(he);
|
||||||
if (res == 0)
|
if (res == 0) res = m_halfedges.erase(he->twin());
|
||||||
res = m_halfedges.erase(he->twin());
|
|
||||||
CGAL_assertion(res != 0);
|
CGAL_assertion(res != 0);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Cleat the edges set. */
|
/*! Cleat the edges set. */
|
||||||
void _clear ()
|
void clear() { m_halfedges.clear(); }
|
||||||
{
|
|
||||||
m_halfedges.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
typedef CGAL_ALLOCATOR(Curve_halfedges) Curves_alloc;
|
typedef CGAL_ALLOCATOR(Curve_halfedges) Curves_alloc;
|
||||||
typedef In_place_list<Curve_halfedges, false> Curve_halfedges_list;
|
typedef In_place_list<Curve_halfedges, false> Curve_halfedges_list;
|
||||||
|
|
||||||
|
|
@ -505,16 +476,13 @@ public:
|
||||||
|
|
||||||
/// \name Traversal of the edges induced by a curve.
|
/// \name Traversal of the edges induced by a curve.
|
||||||
//@{
|
//@{
|
||||||
Size number_of_induced_edges (Curve_const_handle c) const
|
Size number_of_induced_edges (Curve_const_handle c) const { return c->size(); }
|
||||||
{
|
|
||||||
return (c->_size());
|
|
||||||
}
|
|
||||||
|
|
||||||
Induced_edge_iterator
|
Induced_edge_iterator
|
||||||
induced_edges_begin (Curve_const_handle c) const { return (c->_begin()); }
|
induced_edges_begin (Curve_const_handle c) const { return (c->begin()); }
|
||||||
|
|
||||||
Induced_edge_iterator
|
Induced_edge_iterator
|
||||||
induced_edges_end (Curve_const_handle c) const { return (c->_end()); }
|
induced_edges_end (Curve_const_handle c) const { return (c->end()); }
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \name Manipulating edges.
|
/// \name Manipulating edges.
|
||||||
|
|
@ -646,12 +614,12 @@ protected:
|
||||||
Size _remove_curve (Curve_handle ch)
|
Size _remove_curve (Curve_handle ch)
|
||||||
{
|
{
|
||||||
// Go over all edges the given curve induces.
|
// Go over all edges the given curve induces.
|
||||||
Curve_halfedges *p_cv = &(*ch);
|
Curve_halfedges* p_cv = &(*ch);
|
||||||
typename Curve_halfedges::const_iterator it = ch->_begin();
|
Halfedge_handle he;
|
||||||
Halfedge_handle he;
|
Size n_removed = 0;
|
||||||
Size n_removed = 0;
|
|
||||||
|
|
||||||
while (it != ch->_end()) {
|
typename Curve_halfedges::const_iterator it = ch->begin();
|
||||||
|
while (it != ch->end()) {
|
||||||
// Check how many curves have originated the current edge.
|
// Check how many curves have originated the current edge.
|
||||||
// Note we increment the iterator now, as the edge may be removed.
|
// Note we increment the iterator now, as the edge may be removed.
|
||||||
he = *it;
|
he = *it;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Author(s): Ron Wein <wein@post.tau.ac.il>
|
// Author(s): Ron Wein <wein@post.tau.ac.il>
|
||||||
|
// Efi Fogel <efif@post.tau.ac.il>
|
||||||
|
|
||||||
#ifndef CGAL_ARRANGEMENT_WITH_HISTORY_2_H
|
#ifndef CGAL_ARRANGEMENT_WITH_HISTORY_2_H
|
||||||
#define CGAL_ARRANGEMENT_WITH_HISTORY_2_H
|
#define CGAL_ARRANGEMENT_WITH_HISTORY_2_H
|
||||||
|
|
@ -23,6 +24,7 @@
|
||||||
|
|
||||||
#include <CGAL/Arrangement_on_surface_with_history_2.h>
|
#include <CGAL/Arrangement_on_surface_with_history_2.h>
|
||||||
#include <CGAL/Arrangement_2/Arr_default_planar_topology.h>
|
#include <CGAL/Arrangement_2/Arr_default_planar_topology.h>
|
||||||
|
#include <CGAL/Arr_default_dcel.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ public:
|
||||||
ix1 = scaled_x1.BigIntValue();
|
ix1 = scaled_x1.BigIntValue();
|
||||||
ix2 = scaled_x2.BigIntValue();
|
ix2 = scaled_x2.BigIntValue();
|
||||||
|
|
||||||
if (CORE::abs (ix2 - ix1) > one)
|
if (CGAL::abs (ix2 - ix1) > one)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Scale the values by a factor of 2.
|
// Scale the values by a factor of 2.
|
||||||
|
|
@ -179,9 +179,9 @@ public:
|
||||||
temp_gcd = numer_gcd;
|
temp_gcd = numer_gcd;
|
||||||
|
|
||||||
denom_lcm *= denom;
|
denom_lcm *= denom;
|
||||||
denom_lcm /= CORE::gcd (temp_lcm, denom);
|
denom_lcm /= CGAL::gcd (temp_lcm, denom);
|
||||||
|
|
||||||
numer_gcd = CORE::gcd (temp_gcd, numer);
|
numer_gcd = CGAL::gcd (temp_gcd, numer);
|
||||||
}
|
}
|
||||||
|
|
||||||
++q_iter;
|
++q_iter;
|
||||||
|
|
@ -246,8 +246,8 @@ public:
|
||||||
|
|
||||||
if (sign_disc == ZERO)
|
if (sign_disc == ZERO)
|
||||||
{
|
{
|
||||||
// We have one real root with mutliplicity 2.
|
// We have one real root with multiplicity 2.
|
||||||
*oi = -Algebraic (b) / Algebraic (2*a);
|
*oi = -Algebraic (b) / Algebraic (NT(2*a));
|
||||||
++oi;
|
++oi;
|
||||||
}
|
}
|
||||||
else if (sign_disc == POSITIVE)
|
else if (sign_disc == POSITIVE)
|
||||||
|
|
@ -255,7 +255,7 @@ public:
|
||||||
// We have two distinct real roots. We return them in ascending order.
|
// We have two distinct real roots. We return them in ascending order.
|
||||||
const Algebraic sqrt_disc = CGAL::sqrt (Algebraic (disc));
|
const Algebraic sqrt_disc = CGAL::sqrt (Algebraic (disc));
|
||||||
const Algebraic alg_b = b;
|
const Algebraic alg_b = b;
|
||||||
const Algebraic alg_2a = 2*a;
|
const Algebraic alg_2a = NT(2*a);
|
||||||
|
|
||||||
if (sign_a == POSITIVE)
|
if (sign_a == POSITIVE)
|
||||||
{
|
{
|
||||||
|
|
@ -334,7 +334,7 @@ public:
|
||||||
temp_lcm = denom_lcm;
|
temp_lcm = denom_lcm;
|
||||||
|
|
||||||
denom_lcm *= denom;
|
denom_lcm *= denom;
|
||||||
denom_lcm /= CORE::gcd (temp_lcm, denom);
|
denom_lcm /= CGAL::gcd (temp_lcm, denom);
|
||||||
}
|
}
|
||||||
|
|
||||||
index--;
|
index--;
|
||||||
|
|
|
||||||
|
|
@ -865,7 +865,7 @@ void draw(const Arc_2& arc,
|
||||||
get_pixel_coords(l, y_clip, pix_beg);
|
get_pixel_coords(l, y_clip, pix_beg);
|
||||||
get_pixel_coords(ptmp->left, it->second ? engine.y_max_r :
|
get_pixel_coords(ptmp->left, it->second ? engine.y_max_r :
|
||||||
engine.y_min_r, pix_end);
|
engine.y_min_r, pix_end);
|
||||||
if(CGAL_ABS(ptmp->left - l) <= engine.pixel_w_r*2) {
|
if(CGAL_ABS(Rational(ptmp->left - l)) <= engine.pixel_w_r*2) {
|
||||||
|
|
||||||
Coordinate_2 xy(Coordinate_1(pt), *support, arc.arcno());
|
Coordinate_2 xy(Coordinate_1(pt), *support, arc.arcno());
|
||||||
Rational _;
|
Rational _;
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,6 @@ struct Pixel_2_
|
||||||
Integer sub_x, sub_y; // subpixel coordinates relative to pixel's boundary
|
Integer sub_x, sub_y; // subpixel coordinates relative to pixel's boundary
|
||||||
// (always 0 for pixels)
|
// (always 0 for pixels)
|
||||||
|
|
||||||
Pixel_2_& operator =(const Pixel_2_& pix) = default;
|
|
||||||
|
|
||||||
bool operator ==(const Pixel_2_& pix) const {
|
bool operator ==(const Pixel_2_& pix) const {
|
||||||
return (
|
return (
|
||||||
x == pix.x && y == pix.y && level == pix.level &&
|
x == pix.x && y == pix.y && level == pix.level &&
|
||||||
|
|
@ -697,7 +695,7 @@ bool get_range_QF_1(int var, const NT& l_, const NT& r_, const NT& key,
|
||||||
while(der_it != der_begin) {
|
while(der_it != der_begin) {
|
||||||
--der_it;
|
--der_it;
|
||||||
|
|
||||||
e1 = xsum_abs * e1 + CGAL_ABS(x1 * z1);
|
e1 = xsum_abs * e1 + CGAL_ABS(NT(x1 * z1));
|
||||||
z1 = x0*z1 + x1*y1;
|
z1 = x0*z1 + x1*y1;
|
||||||
y1 = y1*x0 + x1*y0;
|
y1 = y1*x0 + x1*y0;
|
||||||
y0 = x0*y0 + extract(*cache_it)*(*der_it);
|
y0 = x0*y0 + extract(*cache_it)*(*der_it);
|
||||||
|
|
@ -728,7 +726,7 @@ bool get_range_QF_1(int var, const NT& l_, const NT& r_, const NT& key,
|
||||||
NT y0 = extract(*cache_it), y1(0), z1(0), e1(0);
|
NT y0 = extract(*cache_it), y1(0), z1(0), e1(0);
|
||||||
while(cache_it != begin) {
|
while(cache_it != begin) {
|
||||||
--cache_it;
|
--cache_it;
|
||||||
e1 = xsum_abs * e1 + CGAL_ABS(x1*z1);
|
e1 = xsum_abs * e1 + CGAL_ABS(NT(x1*z1));
|
||||||
z1 = x0*z1 + x1*y1;
|
z1 = x0*z1 + x1*y1;
|
||||||
y1 = y1*x0 + x1*y0;
|
y1 = y1*x0 + x1*y0;
|
||||||
y0 = x0*y0 + extract(*cache_it);
|
y0 = x0*y0 + extract(*cache_it);
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,7 @@ struct Curve_renderer_traits<CGAL::Interval_nt<true>, CORE::BigRat > :
|
||||||
|
|
||||||
//! Specialization for \c CORE::BigFloat
|
//! Specialization for \c CORE::BigFloat
|
||||||
template <>
|
template <>
|
||||||
struct Curve_renderer_traits<CORE::BigFloat, class CORE::BigRat>
|
struct Curve_renderer_traits<CORE::BigFloat, CORE::BigRat>
|
||||||
: public Curve_renderer_traits_base<CORE::BigFloat, CORE::BigInt,
|
: public Curve_renderer_traits_base<CORE::BigFloat, CORE::BigInt,
|
||||||
CORE::BigRat> {
|
CORE::BigRat> {
|
||||||
|
|
||||||
|
|
@ -347,7 +347,7 @@ struct Curve_renderer_traits<CORE::BigFloat, class CORE::BigRat>
|
||||||
typedef Integer result_type;
|
typedef Integer result_type;
|
||||||
|
|
||||||
Integer operator()(const Rational& x) const {
|
Integer operator()(const Rational& x) const {
|
||||||
return x.BigIntValue();
|
return numerator(x)/denominator(x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -400,7 +400,7 @@ struct Curve_renderer_traits<CORE::BigRat, CORE::BigRat> :
|
||||||
typedef Integer result_type;
|
typedef Integer result_type;
|
||||||
|
|
||||||
Integer operator()(const Rational& x) const {
|
Integer operator()(const Rational& x) const {
|
||||||
return x.BigIntValue();
|
return numerator(x)/denominator(x);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -409,9 +409,7 @@ struct Curve_renderer_traits<CORE::BigRat, CORE::BigRat> :
|
||||||
typedef std::size_t result_type;
|
typedef std::size_t result_type;
|
||||||
|
|
||||||
inline result_type operator()(const Float& key) const {
|
inline result_type operator()(const Float& key) const {
|
||||||
const CORE::BigRatRep& rep = key.getRep();
|
return std::hash<Float>()(key);
|
||||||
std::size_t ret = reinterpret_cast<std::size_t>(&rep);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -877,7 +877,7 @@ endfunction()
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
function(test_polycurve_conic_traits)
|
function(test_polycurve_conic_traits)
|
||||||
# echo polycurve test starting
|
# echo polycurve test starting
|
||||||
if(CGAL_DISABLE_GMP)
|
if(NOT CGAL_Core_FOUND)
|
||||||
MESSAGE(STATUS "test_polycurve_conic_traits requires CORE and will not be executed")
|
MESSAGE(STATUS "test_polycurve_conic_traits requires CORE and will not be executed")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -948,7 +948,7 @@ endfunction()
|
||||||
# polycurve bezier traits
|
# polycurve bezier traits
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
function(test_polycurve_bezier_traits)
|
function(test_polycurve_bezier_traits)
|
||||||
if(CGAL_DISABLE_GMP)
|
if(NOT CGAL_Core_FOUND)
|
||||||
MESSAGE(STATUS "test_polycurve_bezier_traits requires CORE and will not be executed")
|
MESSAGE(STATUS "test_polycurve_bezier_traits requires CORE and will not be executed")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -1057,7 +1057,7 @@ endfunction()
|
||||||
# conic traits
|
# conic traits
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
function(test_conic_traits)
|
function(test_conic_traits)
|
||||||
if(CGAL_DISABLE_GMP)
|
if(NOT CGAL_Core_FOUND)
|
||||||
MESSAGE(STATUS "test_conic_traits requires CORE and will not be executed")
|
MESSAGE(STATUS "test_conic_traits requires CORE and will not be executed")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -1188,7 +1188,7 @@ endfunction()
|
||||||
# bezier traits
|
# bezier traits
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
function(test_bezier_traits)
|
function(test_bezier_traits)
|
||||||
if(CGAL_DISABLE_GMP)
|
if(NOT CGAL_Core_FOUND)
|
||||||
MESSAGE(STATUS "test_bezier_traits requires CORE and will not be executed")
|
MESSAGE(STATUS "test_bezier_traits requires CORE and will not be executed")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -1235,7 +1235,7 @@ endfunction()
|
||||||
# rational arc traits
|
# rational arc traits
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
function(test_rational_arc_traits)
|
function(test_rational_arc_traits)
|
||||||
if(CGAL_DISABLE_GMP)
|
if(NOT CGAL_Core_FOUND)
|
||||||
MESSAGE(STATUS "test_rational_arc_traits requires CORE and will not be executed")
|
MESSAGE(STATUS "test_rational_arc_traits requires CORE and will not be executed")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -1302,7 +1302,7 @@ endfunction()
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
function(test_algebraic_traits_core)
|
function(test_algebraic_traits_core)
|
||||||
#TODO: Adapt
|
#TODO: Adapt
|
||||||
if(CGAL_DISABLE_GMP)
|
if(NOT CGAL_Core_FOUND)
|
||||||
MESSAGE(STATUS "test_algebraic_traits_core requires CORE and will not be executed")
|
MESSAGE(STATUS "test_algebraic_traits_core requires CORE and will not be executed")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,18 @@
|
||||||
# We need the bezier curve (not polycurve) to contruct a bezier point.
|
# We need the bezier curve (not polycurve) to contruct a bezier point.
|
||||||
#
|
#
|
||||||
# Point ID: 0
|
# Point ID: 0
|
||||||
r c 4 0 0 500 200 100 200 900 0 0.5
|
r c 4 0 0 500 200 100 200 900 0 1/2
|
||||||
# Point ID: 1
|
# Point ID: 1
|
||||||
r c 4 900 0 1200 600 1500 400 900 600 0.3
|
r c 4 900 0 1200 600 1500 400 900 600 3/10
|
||||||
# Point id: 2
|
# Point id: 2
|
||||||
r c 4 0 0 100 200 500 200 900 0 0.0
|
r c 4 0 0 100 200 500 200 900 0 0
|
||||||
# Point id: 3
|
# Point id: 3
|
||||||
r c 4 900 0 1200 300 1500 400 2000 450 1.0
|
r c 4 900 0 1200 300 1500 400 2000 450 1
|
||||||
# Point id: 4
|
# Point id: 4
|
||||||
r c 4 2000 450 2100 300 2200 200 2300 450 0.0
|
r c 4 2000 450 2100 300 2200 200 2300 450 0
|
||||||
# Point id: 5
|
# Point id: 5
|
||||||
r c 4 2300 450 2500 500 2800 600 3000 450 1.0
|
r c 4 2300 450 2500 500 2800 600 3000 450 1
|
||||||
# Point id: 6
|
# Point id: 6
|
||||||
r c 4 0 0 100 200 500 200 900 0 0.0
|
r c 4 0 0 100 200 500 200 900 0 0
|
||||||
# Point id: 7
|
# Point id: 7
|
||||||
r c 4 2300 450 2500 500 2800 600 3000 450 1.0
|
r c 4 2300 450 2500 500 2800 600 3000 450 1
|
||||||
|
|
@ -2,6 +2,7 @@ Algebraic_foundations
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
BGL
|
BGL
|
||||||
Barycentric_coordinates_2
|
Barycentric_coordinates_2
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Distance_2
|
Distance_2
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ Algebraic_foundations
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
Arrangement_on_surface_2
|
Arrangement_on_surface_2
|
||||||
Boolean_set_operations_2
|
Boolean_set_operations_2
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circular_kernel_2
|
Circular_kernel_2
|
||||||
Circulator
|
Circulator
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,5 @@ if(NOT CGAL_Core_FOUND)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
create_single_source_cgal_program("zero-one.cpp")
|
||||||
create_single_source_cgal_program("delaunay.cpp")
|
create_single_source_cgal_program("delaunay.cpp")
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
#include <CGAL/CORE_Expr.h>
|
||||||
|
|
||||||
|
typedef CORE::Expr Real;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Real r(3.14);
|
||||||
|
|
||||||
|
CGAL::is_zero(r);
|
||||||
|
|
||||||
|
CGAL::is_one(r);
|
||||||
|
|
||||||
|
r = CGAL::sqrt(r);
|
||||||
|
|
||||||
|
|
||||||
|
CGAL::is_zero(r);
|
||||||
|
|
||||||
|
CGAL::is_one(r);
|
||||||
|
|
||||||
|
r = r * r;
|
||||||
|
|
||||||
|
CGAL::is_zero(r);
|
||||||
|
|
||||||
|
CGAL::is_one(r);
|
||||||
|
|
||||||
|
r = r - r;
|
||||||
|
|
||||||
|
CGAL::is_zero(r);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ public:
|
||||||
/// constructor for <tt>const char* </tt>(default base = 10)
|
/// constructor for <tt>const char* </tt>(default base = 10)
|
||||||
BigFloat(const char* s) : RCBigFloat(new BigFloatRep(s)) {}
|
BigFloat(const char* s) : RCBigFloat(new BigFloatRep(s)) {}
|
||||||
/// constructor for <tt>std::string</tt>(default base = 10)
|
/// constructor for <tt>std::string</tt>(default base = 10)
|
||||||
BigFloat(const std::string& s) : RCBigFloat(new BigFloatRep(s)) {}
|
BigFloat(const std::string& s) : RCBigFloat(new BigFloatRep(s.c_str())) {}
|
||||||
|
|
||||||
/// constructor for <tt>int</tt> and <tt>long</tt>
|
/// constructor for <tt>int</tt> and <tt>long</tt>
|
||||||
// This is a hack because in Sturm, we need to approximate any
|
// This is a hack because in Sturm, we need to approximate any
|
||||||
|
|
@ -106,6 +106,9 @@ public:
|
||||||
explicit BigFloat(BigFloatRep* r, bool) : RCBigFloat(r) {
|
explicit BigFloat(BigFloatRep* r, bool) : RCBigFloat(r) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator BigRat() const {
|
||||||
|
return this->BigRatValue();
|
||||||
|
}
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
|
@ -510,32 +513,6 @@ inline long minStar(long m, long n) {
|
||||||
}
|
}
|
||||||
/// \name Functions for Compatibility with BigInt (needed by Poly, Curves)
|
/// \name Functions for Compatibility with BigInt (needed by Poly, Curves)
|
||||||
//@{
|
//@{
|
||||||
/// isDivisible(a,b) = "is a divisible by b"
|
|
||||||
/** Assuming that a and b are in coanonized forms.
|
|
||||||
Defined to be true if mantissa(b) | mantissa(a) &&
|
|
||||||
exp(b) = min*(exp(b), exp(a)).
|
|
||||||
* This concepts assume a and b are exact BigFloats.
|
|
||||||
*/
|
|
||||||
inline bool isDivisible(const BigFloat& a, const BigFloat& b) {
|
|
||||||
// assert: a and b are exact BigFloats.
|
|
||||||
if (sign(a.m()) == 0) return true;
|
|
||||||
if (sign(b.m()) == 0) return false;
|
|
||||||
unsigned long bin_a = getBinExpo(a.m());
|
|
||||||
unsigned long bin_b = getBinExpo(b.m());
|
|
||||||
|
|
||||||
BigInt m_a = a.m() >> bin_a;
|
|
||||||
BigInt m_b = b.m() >> bin_b;
|
|
||||||
long e_a = bin_a + BigFloatRep::bits(a.exp());
|
|
||||||
long e_b = bin_b + BigFloatRep::bits(b.exp());
|
|
||||||
long dx = minStar(e_a, e_b);
|
|
||||||
|
|
||||||
return isDivisible(m_a, m_b) && (dx == e_b);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool isDivisible(double x, double y) {
|
|
||||||
//Are these exact?
|
|
||||||
return isDivisible(BigFloat(x), BigFloat(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// div_exact(x,y) returns the BigFloat quotient of x divided by y
|
/// div_exact(x,y) returns the BigFloat quotient of x divided by y
|
||||||
/** This is defined only if isDivisible(x,y).
|
/** This is defined only if isDivisible(x,y).
|
||||||
|
|
@ -548,7 +525,6 @@ inline bool isDivisible(double x, double y) {
|
||||||
// normalizing it then we get zero.
|
// normalizing it then we get zero.
|
||||||
inline BigFloat div_exact(const BigFloat& x, const BigFloat& y) {
|
inline BigFloat div_exact(const BigFloat& x, const BigFloat& y) {
|
||||||
BigInt z;
|
BigInt z;
|
||||||
CGAL_assertion (isDivisible(x,y));
|
|
||||||
unsigned long bin_x = getBinExpo(x.m());
|
unsigned long bin_x = getBinExpo(x.m());
|
||||||
unsigned long bin_y = getBinExpo(y.m());
|
unsigned long bin_y = getBinExpo(y.m());
|
||||||
|
|
||||||
|
|
@ -615,15 +591,20 @@ inline BigFloat gcd(const BigFloat& a, const BigFloat& b) {
|
||||||
//}//
|
//}//
|
||||||
|
|
||||||
|
|
||||||
// constructor BigRat from BigFloat
|
inline double doubleValue(const BigFloat& bf)
|
||||||
inline BigRat::BigRat(const BigFloat& f) : RCBigRat(new BigRatRep()){
|
{
|
||||||
*this = f.BigRatValue();
|
return bf.doubleValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline long longValue(const BigFloat& bf)
|
||||||
|
{
|
||||||
|
return bf.longValue();
|
||||||
|
}
|
||||||
|
|
||||||
} //namespace CORE
|
} //namespace CORE
|
||||||
|
|
||||||
#ifdef CGAL_HEADER_ONLY
|
#ifdef CGAL_HEADER_ONLY
|
||||||
#include <CGAL/CORE/BigFloat_impl.h>
|
#include <CGAL/CORE/BigFloat_impl.h>
|
||||||
#include <CGAL/CORE/CoreIO_impl.h>
|
|
||||||
#endif // CGAL_HEADER_ONLY
|
#endif // CGAL_HEADER_ONLY
|
||||||
|
|
||||||
#include <CGAL/enable_warnings.h>
|
#include <CGAL/enable_warnings.h>
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ inline void BigFloatRep::eliminateTrailingZeroes() {
|
||||||
// builtin functions
|
// builtin functions
|
||||||
inline extLong BigFloatRep::lMSB() const {
|
inline extLong BigFloatRep::lMSB() const {
|
||||||
if (!isZeroIn())
|
if (!isZeroIn())
|
||||||
return extLong(floorLg(abs(m) - err)) + bits(exp);
|
return extLong(floorLg(BigInt(abs(m) - err))) + bits(exp);
|
||||||
else
|
else
|
||||||
return extLong(CORE_negInfty);
|
return extLong(CORE_negInfty);
|
||||||
}
|
}
|
||||||
|
|
@ -327,7 +327,7 @@ inline extLong BigFloatRep::lMSB() const {
|
||||||
* Not well-defined if zero is in the interval.
|
* Not well-defined if zero is in the interval.
|
||||||
*/
|
*/
|
||||||
inline extLong BigFloatRep::uMSB() const {
|
inline extLong BigFloatRep::uMSB() const {
|
||||||
return extLong(floorLg(abs(m) + err)) + bits(exp);
|
return extLong(floorLg(BigInt(abs(m) + err))) + bits(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline extLong BigFloatRep::MSB() const {
|
inline extLong BigFloatRep::MSB() const {
|
||||||
|
|
|
||||||
|
|
@ -194,8 +194,7 @@ void BigFloatRep :: truncM(const BigFloatRep& B, const extLong& r, const extLong
|
||||||
err = 2;
|
err = 2;
|
||||||
exp = B.exp + t;
|
exp = B.exp + t;
|
||||||
} else // t < chunkCeil(clLg(B.err))
|
} else // t < chunkCeil(clLg(B.err))
|
||||||
core_error(std::string("BigFloat error: truncM called with stricter")
|
CGAL_error_msg("BigFloat error: truncM called with stricter precision than current error.");
|
||||||
+ "precision than current error.", __FILE__, __LINE__, true);
|
|
||||||
} else {// B.m == 0
|
} else {// B.m == 0
|
||||||
long t = chunkFloor(- a.asLong()) - B.exp;
|
long t = chunkFloor(- a.asLong()) - B.exp;
|
||||||
|
|
||||||
|
|
@ -204,8 +203,7 @@ void BigFloatRep :: truncM(const BigFloatRep& B, const extLong& r, const extLong
|
||||||
err = 1;
|
err = 1;
|
||||||
exp = B.exp + t;
|
exp = B.exp + t;
|
||||||
} else // t < chunkCeil(clLg(B.err))
|
} else // t < chunkCeil(clLg(B.err))
|
||||||
core_error(std::string("BigFloat error: truncM called with stricter")
|
CGAL_error_msg("BigFloat error: truncM called with stricter precision than current error.");
|
||||||
+ "precision than current error.", __FILE__, __LINE__, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +214,7 @@ CGAL_INLINE_FUNCTION
|
||||||
void BigFloatRep::approx(const BigFloatRep& B,
|
void BigFloatRep::approx(const BigFloatRep& B,
|
||||||
const extLong& r, const extLong& a) {
|
const extLong& r, const extLong& a) {
|
||||||
if (B.err) {
|
if (B.err) {
|
||||||
if (1 + clLg(B.err) <= bitLength(B.m))
|
if (static_cast<std::size_t>(1 + clLg(B.err)) <= bitLength(B.m))
|
||||||
truncM(B, r + 1, a);
|
truncM(B, r + 1, a);
|
||||||
else // 1 + clLg(B.err) > lg(B.m)
|
else // 1 + clLg(B.err) > lg(B.m)
|
||||||
truncM(B, CORE_posInfty, a);
|
truncM(B, CORE_posInfty, a);
|
||||||
|
|
@ -258,7 +256,7 @@ void BigFloatRep::div(const BigInt& N, const BigInt& D,
|
||||||
exp = 0;
|
exp = 0;
|
||||||
}
|
}
|
||||||
} else // D == 0
|
} else // D == 0
|
||||||
core_error( "BigFloat error: zero divisor.", __FILE__, __LINE__, true);
|
CGAL_error_msg( "BigFloat error: zero divisor.");
|
||||||
|
|
||||||
// Call normalization globally -- IP 10/9/98
|
// Call normalization globally -- IP 10/9/98
|
||||||
normal();
|
normal();
|
||||||
|
|
@ -455,6 +453,7 @@ void BigFloatRep::centerize(const BigFloatRep& a, const BigFloatRep& b) {
|
||||||
// Zilin & Vikram, 08/24/04
|
// Zilin & Vikram, 08/24/04
|
||||||
// err = 1 + longValue(chunkShift(r.m, r.exp - exp));
|
// err = 1 + longValue(chunkShift(r.m, r.exp - exp));
|
||||||
BigInt E = chunkShift(r.m, r.exp - exp);
|
BigInt E = chunkShift(r.m, r.exp - exp);
|
||||||
|
E = abs(E);
|
||||||
bigNormal(E);
|
bigNormal(E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -538,8 +537,7 @@ void BigFloatRep :: div(const BigFloatRep& x, const BigFloatRep& y,
|
||||||
bigNormal(bigErr);
|
bigNormal(bigErr);
|
||||||
}
|
}
|
||||||
} else {// y.m <= y.err
|
} else {// y.m <= y.err
|
||||||
core_error("BigFloat error: possible zero divisor.",
|
CGAL_error_msg("BigFloat error: possible zero divisor.");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call normalization globally -- IP 10/9/98
|
// Call normalization globally -- IP 10/9/98
|
||||||
|
|
@ -734,8 +732,7 @@ void BigFloatRep::sqrt(const BigFloatRep& x, const extLong& a, const BigFloat& A
|
||||||
} // end of case with error in mantissa
|
} // end of case with error in mantissa
|
||||||
}//else
|
}//else
|
||||||
} else
|
} else
|
||||||
core_error("BigFloat error: squareroot called with negative operand.",
|
CGAL_error_msg("BigFloat error: squareroot called with negative operand.");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
} //sqrt with initial approximation
|
} //sqrt with initial approximation
|
||||||
|
|
||||||
// compareMExp(x)
|
// compareMExp(x)
|
||||||
|
|
@ -822,8 +819,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const {
|
||||||
if (err > 0 && err >= abs(m)) {
|
if (err > 0 && err >= abs(m)) {
|
||||||
// if err is larger than mantissa, sign and significant values
|
// if err is larger than mantissa, sign and significant values
|
||||||
// can not be determined.
|
// can not be determined.
|
||||||
core_error("BigFloat error: Error is too big!",
|
CGAL_CORE_warning_msg(true, "BigFloat error: Error is too big!");
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
decOut.rep = "0.0e0"; // error is too big
|
decOut.rep = "0.0e0"; // error is too big
|
||||||
decOut.isScientific = false;
|
decOut.isScientific = false;
|
||||||
decOut.noSignificant = 0;
|
decOut.noSignificant = 0;
|
||||||
|
|
@ -869,7 +865,7 @@ BigFloatRep::toDecimal(unsigned int width, bool Scientific) const {
|
||||||
M <<= e2; // M = x * 2^(e2)
|
M <<= e2; // M = x * 2^(e2)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string decRep = M.get_str();
|
std::string decRep = M.convert_to<std::string>();
|
||||||
// Determine the "significant part" of this string, i.e. the part which
|
// Determine the "significant part" of this string, i.e. the part which
|
||||||
// is guaranteed to be correct in the presence of error,
|
// is guaranteed to be correct in the presence of error,
|
||||||
// except that the last digit which might be subject to +/- 1.
|
// except that the last digit which might be subject to +/- 1.
|
||||||
|
|
@ -1003,8 +999,7 @@ void BigFloatRep :: fromString(const char *str, extLong prec ) {
|
||||||
// NOTE: prec defaults to get_static_defBigFloatInputDigits() (see BigFloat.h)
|
// NOTE: prec defaults to get_static_defBigFloatInputDigits() (see BigFloat.h)
|
||||||
// check that prec is not INFTY
|
// check that prec is not INFTY
|
||||||
if (prec.isInfty())
|
if (prec.isInfty())
|
||||||
core_error("BigFloat error: infinite precision not allowed",
|
CGAL_error_msg("BigFloat error: infinite precision not allowed");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
|
|
||||||
const char *e = strchr(str, 'e');
|
const char *e = strchr(str, 'e');
|
||||||
int dot = 0;
|
int dot = 0;
|
||||||
|
|
|
||||||
|
|
@ -24,448 +24,113 @@
|
||||||
#ifndef _CORE_BIGINT_H_
|
#ifndef _CORE_BIGINT_H_
|
||||||
#define _CORE_BIGINT_H_
|
#define _CORE_BIGINT_H_
|
||||||
|
|
||||||
#include <CGAL/CORE/Gmp.h>
|
#include <CGAL/boost_mp_type.h>
|
||||||
#include <CGAL/CORE/RefCount.h>
|
#include <CGAL/CORE/RefCount.h>
|
||||||
#include <CGAL/CORE/MemoryPool.h>
|
#include <CGAL/CORE/MemoryPool.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
#if !(defined(CGAL_CORE_USE_BOOST_BACKEND) && BOOST_VERSION > 107900 && defined(CGAL_USE_BOOST_MP)) && !defined(CGAL_DISABLE_GMP)
|
||||||
|
#define CGAL_CORE_USE_GMP_BACKEND 1
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace CORE {
|
namespace CORE {
|
||||||
|
|
||||||
|
#ifdef CGAL_CORE_USE_GMP_BACKEND
|
||||||
|
typedef boost::multiprecision::mpz_int BigInt;
|
||||||
|
#else
|
||||||
|
typedef boost::multiprecision::cpp_int BigInt;
|
||||||
|
#endif
|
||||||
|
|
||||||
class BigIntRep : public RCRepImpl<BigIntRep> {
|
|
||||||
public:
|
|
||||||
BigIntRep() {
|
|
||||||
mpz_init(mp);
|
|
||||||
}
|
|
||||||
// Note : should the copy-ctor be allowed at all ? [Sylvain Pion]
|
|
||||||
BigIntRep(const BigIntRep& z) : RCRepImpl<BigIntRep>() {
|
|
||||||
mpz_init_set(mp, z.mp);
|
|
||||||
}
|
|
||||||
BigIntRep(signed char c) {
|
|
||||||
mpz_init_set_si(mp, c);
|
|
||||||
}
|
|
||||||
BigIntRep(unsigned char c) {
|
|
||||||
mpz_init_set_ui(mp, c);
|
|
||||||
}
|
|
||||||
BigIntRep(signed int i) {
|
|
||||||
mpz_init_set_si(mp, i);
|
|
||||||
}
|
|
||||||
BigIntRep(unsigned int i) {
|
|
||||||
mpz_init_set_ui(mp, i);
|
|
||||||
}
|
|
||||||
BigIntRep(signed short int s) {
|
|
||||||
mpz_init_set_si(mp, s);
|
|
||||||
}
|
|
||||||
BigIntRep(unsigned short int s) {
|
|
||||||
mpz_init_set_ui(mp, s);
|
|
||||||
}
|
|
||||||
BigIntRep(signed long int l) {
|
|
||||||
mpz_init_set_si(mp, l);
|
|
||||||
}
|
|
||||||
BigIntRep(unsigned long int l) {
|
|
||||||
mpz_init_set_ui(mp, l);
|
|
||||||
}
|
|
||||||
BigIntRep(float f) {
|
|
||||||
mpz_init_set_d(mp, f);
|
|
||||||
}
|
|
||||||
BigIntRep(double d) {
|
|
||||||
mpz_init_set_d(mp, d);
|
|
||||||
}
|
|
||||||
BigIntRep(const char* s, int base=0) {
|
|
||||||
mpz_init_set_str(mp, s, base);
|
|
||||||
}
|
|
||||||
BigIntRep(const std::string& s, int base=0) {
|
|
||||||
mpz_init_set_str(mp, s.c_str(), base);
|
|
||||||
}
|
|
||||||
explicit BigIntRep(mpz_srcptr z) {
|
|
||||||
mpz_init_set(mp, z);
|
|
||||||
}
|
|
||||||
~BigIntRep() {
|
|
||||||
mpz_clear(mp);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_CORE_EXPORT CORE_NEW(BigIntRep)
|
|
||||||
CGAL_CORE_EXPORT CORE_DELETE(BigIntRep)
|
|
||||||
|
|
||||||
mpz_srcptr get_mp() const {
|
|
||||||
return mp;
|
|
||||||
}
|
|
||||||
mpz_ptr get_mp() {
|
|
||||||
return mp;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
mpz_t mp;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef RCImpl<BigIntRep> RCBigInt;
|
|
||||||
class CGAL_CORE_EXPORT BigInt : public RCBigInt {
|
|
||||||
public:
|
|
||||||
/// \name Constructors
|
|
||||||
//@{
|
|
||||||
/// default constructor
|
|
||||||
BigInt() : RCBigInt(new BigIntRep()) {}
|
|
||||||
/// constructor for <tt>signed char</tt>
|
|
||||||
BigInt(signed char x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned char</tt>
|
|
||||||
BigInt(unsigned char x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>signed short int</tt>
|
|
||||||
BigInt(signed short int x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned short int</tt>
|
|
||||||
BigInt(unsigned short int x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>signed int</tt>
|
|
||||||
BigInt(signed int x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned int</tt>
|
|
||||||
BigInt(unsigned int x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>signed long int</tt>
|
|
||||||
BigInt(signed long int x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned long int</tt>
|
|
||||||
BigInt(unsigned long int x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>float</tt>
|
|
||||||
BigInt(float x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>double</tt>
|
|
||||||
BigInt(double x) : RCBigInt(new BigIntRep(x)) {}
|
|
||||||
/// constructor for <tt>const char*</tt> with base
|
|
||||||
BigInt(const char* s, int base=0) : RCBigInt(new BigIntRep(s, base)) {}
|
|
||||||
/// constructor for <tt>std::string</tt> with base
|
|
||||||
BigInt(const std::string& s, int base=0) : RCBigInt(new BigIntRep(s, base)) {}
|
|
||||||
/// constructor for <tt>mpz_srcptr</tt>
|
|
||||||
explicit BigInt(mpz_srcptr z) : RCBigInt(new BigIntRep(z)) {}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Copy-Assignment-Destructor
|
|
||||||
//@{
|
|
||||||
/// copy constructor
|
|
||||||
BigInt(const BigInt& rhs) : RCBigInt(rhs) {
|
|
||||||
rep->incRef();
|
|
||||||
}
|
|
||||||
/// assignment operator
|
|
||||||
BigInt& operator=(const BigInt& rhs) {
|
|
||||||
if (this != &rhs) {
|
|
||||||
rep->decRef();
|
|
||||||
rep = rhs.rep;
|
|
||||||
rep->incRef();
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
/// destructor
|
|
||||||
~BigInt() {
|
|
||||||
rep->decRef();
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Overloaded operators
|
|
||||||
//@{
|
|
||||||
BigInt& operator +=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_add(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator -=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_sub(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator *=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_mul(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator /=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_tdiv_q(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator %=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_tdiv_r(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator &=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_and(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator |=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_ior(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator ^=(const BigInt& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_xor(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator <<=(unsigned long ul) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_mul_2exp(get_mp(), get_mp(), ul);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator >>=(unsigned long ul) {
|
|
||||||
makeCopy();
|
|
||||||
mpz_tdiv_q_2exp(get_mp(), get_mp(), ul);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name unary, increment, decrement operators
|
|
||||||
//@{
|
|
||||||
BigInt operator+() const {
|
|
||||||
return BigInt(*this);
|
|
||||||
}
|
|
||||||
BigInt operator-() const {
|
|
||||||
BigInt r;
|
|
||||||
mpz_neg(r.get_mp(), get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
BigInt& operator++() {
|
|
||||||
makeCopy();
|
|
||||||
mpz_add_ui(get_mp(), get_mp(), 1);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt& operator--() {
|
|
||||||
makeCopy();
|
|
||||||
mpz_sub_ui(get_mp(), get_mp(), 1);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigInt operator++(int) {
|
|
||||||
BigInt r(*this);
|
|
||||||
++(*this);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
BigInt operator--(int) {
|
|
||||||
BigInt r(*this);
|
|
||||||
--(*this);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Helper Functions
|
|
||||||
//@{
|
|
||||||
/// Has Exact Division
|
|
||||||
static bool hasExactDivision() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/// get mpz pointer (const)
|
|
||||||
mpz_srcptr get_mp() const {
|
|
||||||
return rep->get_mp();
|
|
||||||
}
|
|
||||||
/// get mpz pointer
|
|
||||||
mpz_ptr get_mp() {
|
|
||||||
return rep->get_mp();
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name String Conversion Functions
|
|
||||||
//@{
|
|
||||||
/// set value from <tt>const char*</tt>
|
|
||||||
int set_str(const char* s, int base = 0) {
|
|
||||||
makeCopy();
|
|
||||||
return mpz_set_str(get_mp(), s, base);
|
|
||||||
}
|
|
||||||
/// convert to <tt>std::string</tt>
|
|
||||||
std::string get_str(int base = 10) const {
|
|
||||||
int n = mpz_sizeinbase (get_mp(), base) + 2;
|
|
||||||
char *buffer = new char[n];
|
|
||||||
mpz_get_str(buffer, base, get_mp());
|
|
||||||
std::string result(buffer);
|
|
||||||
delete [] buffer;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Conversion Functions
|
|
||||||
//@{
|
|
||||||
/// intValue
|
|
||||||
int intValue() const {
|
|
||||||
return static_cast<int>(mpz_get_si(get_mp()));
|
|
||||||
}
|
|
||||||
/// longValue
|
|
||||||
long longValue() const {
|
|
||||||
return mpz_get_si(get_mp());
|
|
||||||
}
|
|
||||||
/// ulongValue
|
|
||||||
unsigned long ulongValue() const {
|
|
||||||
return mpz_get_ui(get_mp());
|
|
||||||
}
|
|
||||||
/// doubleValue
|
|
||||||
double doubleValue() const {
|
|
||||||
return mpz_get_d(get_mp());
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
};
|
|
||||||
|
|
||||||
inline BigInt operator+(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_add(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator-(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_sub(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator*(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_mul(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator/(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_tdiv_q(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator%(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_tdiv_r(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator&(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_and(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator|(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_ior(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator^(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_xor(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator<<(const BigInt& a, unsigned long ul) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_mul_2exp(r.get_mp(), a.get_mp(), ul);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigInt operator>>(const BigInt& a, unsigned long ul) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_tdiv_q_2exp(r.get_mp(), a.get_mp(), ul);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int cmp(const BigInt& x, const BigInt& y) {
|
inline int cmp(const BigInt& x, const BigInt& y) {
|
||||||
return mpz_cmp(x.get_mp(), y.get_mp());
|
return x.compare(y);
|
||||||
}
|
|
||||||
inline bool operator==(const BigInt& a, const BigInt& b) {
|
|
||||||
return cmp(a, b) == 0;
|
|
||||||
}
|
|
||||||
inline bool operator!=(const BigInt& a, const BigInt& b) {
|
|
||||||
return cmp(a, b) != 0;
|
|
||||||
}
|
|
||||||
inline bool operator>=(const BigInt& a, const BigInt& b) {
|
|
||||||
return cmp(a, b) >= 0;
|
|
||||||
}
|
|
||||||
inline bool operator>(const BigInt& a, const BigInt& b) {
|
|
||||||
return cmp(a, b) > 0;
|
|
||||||
}
|
|
||||||
inline bool operator<=(const BigInt& a, const BigInt& b) {
|
|
||||||
return cmp(a, b) <= 0;
|
|
||||||
}
|
|
||||||
inline bool operator<(const BigInt& a, const BigInt& b) {
|
|
||||||
return cmp(a, b) < 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& o, const BigInt& x) {
|
|
||||||
//return CORE::operator<<(o, x.get_mp());
|
|
||||||
return CORE::io_write(o, x.get_mp());
|
|
||||||
}
|
|
||||||
inline std::istream& operator>>(std::istream& i, BigInt& x) {
|
|
||||||
x.makeCopy();
|
|
||||||
//return CORE::operator>>(i, x.get_mp());
|
|
||||||
return CORE::io_read(i, x.get_mp());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// sign
|
inline int set_str(BigInt& a, const char* s) {
|
||||||
inline int sign(const BigInt& a) {
|
a = BigInt(s);
|
||||||
return mpz_sgn(a.get_mp());
|
return 0; // should be -1 if not correct in the base (we ignore)
|
||||||
}
|
}
|
||||||
/// abs
|
|
||||||
inline BigInt abs(const BigInt& a) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_abs(r.get_mp(), a.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
/// neg
|
|
||||||
inline BigInt neg(const BigInt& a) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_neg(r.get_mp(), a.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
/// negate
|
|
||||||
inline void negate(BigInt& a) {
|
|
||||||
a.makeCopy();
|
|
||||||
mpz_neg(a.get_mp(), a.get_mp());
|
|
||||||
}
|
|
||||||
/// cmpabs
|
|
||||||
inline int cmpabs(const BigInt& a, const BigInt& b) {
|
|
||||||
return mpz_cmpabs(a.get_mp(), b.get_mp());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \name Conversion Functions
|
/// longValue
|
||||||
//@{
|
|
||||||
/// longValue
|
|
||||||
inline long longValue(const BigInt& a) {
|
inline long longValue(const BigInt& a) {
|
||||||
return a.longValue();
|
return a.convert_to<long>();
|
||||||
}
|
}
|
||||||
/// ulongValue
|
|
||||||
inline unsigned long ulongValue(const BigInt& a) {
|
/// doubleValue
|
||||||
return a.ulongValue();
|
|
||||||
}
|
|
||||||
/// doubleValue
|
|
||||||
inline double doubleValue(const BigInt& a) {
|
inline double doubleValue(const BigInt& a) {
|
||||||
return a.doubleValue();
|
return a.convert_to<double>();
|
||||||
}
|
}
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name File I/O Functions
|
/// isEven
|
||||||
//@{
|
|
||||||
/// read from file
|
|
||||||
void readFromFile(BigInt& z, std::istream& in, long maxLength = 0);
|
|
||||||
/// write to file
|
|
||||||
void writeToFile(const BigInt& z, std::ostream& in, int base=10, int charsPerLine=80);
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Misc Functions
|
|
||||||
//@{
|
|
||||||
/// isEven
|
|
||||||
inline bool isEven(const BigInt& z) {
|
inline bool isEven(const BigInt& z) {
|
||||||
return mpz_even_p(z.get_mp());
|
return bit_test(z,0) == 0;
|
||||||
}
|
}
|
||||||
/// isOdd
|
/// isOdd
|
||||||
inline bool isOdd(const BigInt& z) {
|
inline bool isOdd(const BigInt& z) {
|
||||||
return mpz_odd_p(z.get_mp());
|
return bit_test(z,0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// get exponent of power 2
|
|
||||||
inline unsigned long getBinExpo(const BigInt& z) {
|
|
||||||
return mpz_scan1(z.get_mp(), 0);
|
|
||||||
}
|
|
||||||
/// get exponent of power k
|
|
||||||
inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long k) {
|
|
||||||
mpz_t f;
|
|
||||||
mpz_init_set_ui(f, k);
|
|
||||||
m.makeCopy();
|
|
||||||
e = mpz_remove(m.get_mp(), z.get_mp(), f);
|
|
||||||
mpz_clear(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// divisible(x,y) = "x | y"
|
|
||||||
inline bool isDivisible(const BigInt& x, const BigInt& y) {
|
inline bool isDivisible(const BigInt& x, const BigInt& y) {
|
||||||
return mpz_divisible_p(x.get_mp(), y.get_mp()) != 0;
|
BigInt q, r;
|
||||||
|
divide_qr(x, y, q, r);
|
||||||
|
return r.is_zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isDivisible(int x, int y) {
|
inline bool isDivisible(int x, int y) {
|
||||||
return x % y == 0;
|
return x % y == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isDivisible(long x, long y) {
|
inline bool isDivisible(long x, long y) {
|
||||||
return x % y == 0;
|
return x % y == 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
/// exact div
|
/// get exponent of power 2
|
||||||
|
inline std::size_t getBinExpo(const BigInt& z) {
|
||||||
|
if (z.is_zero()) {
|
||||||
|
return (std::numeric_limits<std::size_t>::max)();
|
||||||
|
}
|
||||||
|
return lsb(abs(z));
|
||||||
|
}
|
||||||
|
|
||||||
|
// bit length
|
||||||
|
inline std::size_t bitLength(const BigInt& a){
|
||||||
|
if (a.is_zero()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return msb(abs(a))+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// floorLg -- floor of log_2(a)
|
||||||
|
/** Convention: a=0, floorLg(a) returns -1.
|
||||||
|
* This makes sense for integer a.
|
||||||
|
*/
|
||||||
|
inline long floorLg(const BigInt& a) {
|
||||||
|
assert(std::size_t((std::numeric_limits<long>::max)()) > bitLength(a));
|
||||||
|
return (sign(a) == 0) ? (-1) : static_cast<long>(bitLength(a)-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// div_rem
|
||||||
|
inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) {
|
||||||
|
divide_qr(a, b, q, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// ulongValue
|
||||||
|
inline unsigned long ulongValue(const BigInt& a) {
|
||||||
|
assert(a >= BigInt(0));
|
||||||
|
return a.convert_to<unsigned long>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// exact div
|
||||||
inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) {
|
inline void divexact(BigInt& z, const BigInt& x, const BigInt& y) {
|
||||||
z.makeCopy();
|
BigInt r;
|
||||||
mpz_divexact(z.get_mp(), x.get_mp(), y.get_mp());
|
divide_qr(x, y, z, r ); // was void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) Is this faster?
|
||||||
|
assert(r.is_zero());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chee (1/12/2004) The definition of div_exact(x,y) next
|
// Chee (1/12/2004) The definition of div_exact(x,y) next
|
||||||
// ensure that in Polynomials<NT> works with both NT=BigInt and NT=int:
|
// ensure that in Polynomials<NT> works with both NT=BigInt and NT=int:
|
||||||
inline BigInt div_exact(const BigInt& x, const BigInt& y) {
|
inline BigInt div_exact(const BigInt& x, const BigInt& y) {
|
||||||
|
|
@ -473,50 +138,19 @@ inline BigInt div_exact(const BigInt& x, const BigInt& y) {
|
||||||
divexact(z, x, y); // z is set to x/y;
|
divexact(z, x, y); // z is set to x/y;
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int div_exact(int x, int y) {
|
inline int div_exact(int x, int y) {
|
||||||
return x/y; // precondition: isDivisible(x,y)
|
return x/y; // precondition: isDivisible(x,y)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long div_exact(long x, long y) {
|
inline long div_exact(long x, long y) {
|
||||||
return x/y; // precondition: isDivisible(x,y)
|
return x/y; // precondition: isDivisible(x,y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline BigInt gcd(const BigInt& a, const BigInt& b){
|
||||||
/// gcd
|
return boost::multiprecision::gcd(a,b);
|
||||||
inline BigInt gcd(const BigInt& a, const BigInt& b) {
|
|
||||||
BigInt r;
|
|
||||||
mpz_gcd(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
/// div_rem
|
|
||||||
inline void div_rem(BigInt& q, BigInt& r, const BigInt& a, const BigInt& b) {
|
|
||||||
q.makeCopy();
|
|
||||||
r.makeCopy();
|
|
||||||
mpz_tdiv_qr(q.get_mp(), r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
}
|
|
||||||
/// power
|
|
||||||
inline void power(BigInt& c, const BigInt& a, unsigned long ul) {
|
|
||||||
c.makeCopy();
|
|
||||||
mpz_pow_ui(c.get_mp(), a.get_mp(), ul);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pow
|
|
||||||
inline BigInt pow(const BigInt& a, unsigned long ui) {
|
|
||||||
BigInt r;
|
|
||||||
power(r, a, ui);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
// bit length
|
|
||||||
inline int bitLength(const BigInt& a) {
|
|
||||||
return mpz_sizeinbase(a.get_mp(), 2);
|
|
||||||
}
|
|
||||||
/// floorLg -- floor of log_2(a)
|
|
||||||
/** Convention: a=0, floorLg(a) returns -1.
|
|
||||||
* This makes sense for integer a.
|
|
||||||
*/
|
|
||||||
inline long floorLg(const BigInt& a) {
|
|
||||||
return (sign(a) == 0) ? (-1) : (bitLength(a)-1);
|
|
||||||
}
|
|
||||||
/// ceilLg -- ceiling of log_2(a) where a=BigInt, int or long
|
/// ceilLg -- ceiling of log_2(a) where a=BigInt, int or long
|
||||||
/** Convention: a=0, ceilLg(a) returns -1.
|
/** Convention: a=0, ceilLg(a) returns -1.
|
||||||
* This makes sense for integer a.
|
* This makes sense for integer a.
|
||||||
|
|
@ -524,20 +158,45 @@ inline long floorLg(const BigInt& a) {
|
||||||
inline long ceilLg(const BigInt& a) {
|
inline long ceilLg(const BigInt& a) {
|
||||||
if (sign(a) == 0)
|
if (sign(a) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
unsigned long len = bitLength(a);
|
assert(std::size_t((std::numeric_limits<long>::max)()) > bitLength(a));
|
||||||
return (mpz_scan1(a.get_mp(), 0) == len-1) ? (len-1) : len;
|
std::size_t len = static_cast<long>(bitLength(a));
|
||||||
|
|
||||||
|
return (lsb(abs(a)) == len - 1) ? (static_cast<long>(len) - 1) : static_cast<long>(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long ceilLg(long a) { // need this for Polynomial<long>
|
inline long ceilLg(long a) { // need this for Polynomial<long>
|
||||||
return ceilLg(BigInt(a));
|
return ceilLg(BigInt(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long ceilLg(int a) { // need this for Polynomial<int>
|
inline long ceilLg(int a) { // need this for Polynomial<int>
|
||||||
return ceilLg(BigInt(a));
|
return ceilLg(BigInt(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
//@}
|
|
||||||
|
/// negate
|
||||||
|
inline void negate(BigInt& a) {
|
||||||
|
a= - a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get exponent of power k
|
||||||
|
inline void getKaryExpo(const BigInt& z, BigInt& m, int& e, unsigned long uk) {
|
||||||
|
BigInt k(uk), q, r;
|
||||||
|
e = 0;
|
||||||
|
m = z;
|
||||||
|
for(;;) {
|
||||||
|
divide_qr(m, k, q, r);
|
||||||
|
if (!r.is_zero()) break;
|
||||||
|
m = q;
|
||||||
|
++e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void power(BigInt& c, const BigInt& a, unsigned long ul) {
|
||||||
|
c = pow(a, ul);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CORE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} //namespace CORE
|
|
||||||
|
|
||||||
#endif // _CORE_BIGINT_H_
|
#endif // _CORE_BIGINT_H_
|
||||||
|
|
|
||||||
|
|
@ -28,354 +28,35 @@
|
||||||
#include <CGAL/CORE/BigInt.h>
|
#include <CGAL/CORE/BigInt.h>
|
||||||
|
|
||||||
namespace CORE {
|
namespace CORE {
|
||||||
|
#ifdef CGAL_CORE_USE_GMP_BACKEND
|
||||||
|
typedef boost::multiprecision::mpq_rational BigRat;
|
||||||
|
#else
|
||||||
|
typedef boost::multiprecision::cpp_rational BigRat;
|
||||||
|
#endif
|
||||||
|
|
||||||
class BigRatRep : public RCRepImpl<BigRatRep> {
|
|
||||||
public:
|
inline BigInt numerator(const BigRat& q)
|
||||||
BigRatRep() {
|
{
|
||||||
mpq_init(mp);
|
return boost::multiprecision::numerator(q);
|
||||||
}
|
|
||||||
// Note : should the copy-ctor be allowed at all ? [Sylvain Pion]
|
|
||||||
BigRatRep(const BigRatRep& z) : RCRepImpl<BigRatRep>() {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set(mp, z.mp);
|
|
||||||
}
|
|
||||||
BigRatRep(signed char c) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_si(mp, c, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(unsigned char c) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_ui(mp, c, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(signed int i) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_si(mp, i, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(unsigned int i) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_ui(mp, i, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(signed short int s) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_si(mp, s, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(unsigned short int s) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_ui(mp, s, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(signed long int l) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_si(mp, l, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(unsigned long int l) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_ui(mp, l, 1);
|
|
||||||
}
|
|
||||||
BigRatRep(float f) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_d(mp, f);
|
|
||||||
}
|
|
||||||
BigRatRep(double d) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_d(mp, d);
|
|
||||||
}
|
|
||||||
BigRatRep(const char* s) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_str(mp, s, 0);
|
|
||||||
}
|
|
||||||
BigRatRep(const std::string& s) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_str(mp, s.c_str(), 0);
|
|
||||||
}
|
|
||||||
explicit BigRatRep(mpq_srcptr q) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set(mp, q);
|
|
||||||
}
|
|
||||||
BigRatRep(mpz_srcptr z) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpq_set_z(mp, z);
|
|
||||||
}
|
|
||||||
BigRatRep(mpz_srcptr n, mpz_srcptr d) {
|
|
||||||
mpq_init(mp);
|
|
||||||
mpz_set(mpq_numref(mp), n);
|
|
||||||
mpz_set(mpq_denref(mp), d);
|
|
||||||
mpq_canonicalize(mp);
|
|
||||||
}
|
|
||||||
~BigRatRep() {
|
|
||||||
mpq_clear(mp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_CORE_EXPORT CORE_NEW(BigRatRep)
|
inline BigInt denominator(const BigRat& q)
|
||||||
CGAL_CORE_EXPORT CORE_DELETE(BigRatRep)
|
{
|
||||||
|
return boost::multiprecision::denominator(q);
|
||||||
mpq_srcptr get_mp() const {
|
|
||||||
return mp;
|
|
||||||
}
|
|
||||||
mpq_ptr get_mp() {
|
|
||||||
return mp;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
mpq_t mp;
|
|
||||||
}; //BigRatRep
|
|
||||||
|
|
||||||
class BigFloat;
|
|
||||||
|
|
||||||
typedef RCImpl<BigRatRep> RCBigRat;
|
|
||||||
class BigRat : public RCBigRat {
|
|
||||||
public:
|
|
||||||
/// \name Constructors
|
|
||||||
//@{
|
|
||||||
/// default constructor
|
|
||||||
BigRat() : RCBigRat(new BigRatRep()) {}
|
|
||||||
/// constructor for <tt>signed char</tt>
|
|
||||||
BigRat(signed char x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned char</tt>
|
|
||||||
BigRat(unsigned char x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>signed short int</tt>
|
|
||||||
BigRat(signed short int x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned short int</tt>
|
|
||||||
BigRat(unsigned short int x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>signed int</tt>
|
|
||||||
BigRat(signed int x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned int</tt>
|
|
||||||
BigRat(unsigned int x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>signed long int</tt>
|
|
||||||
BigRat(signed long int x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>unsigned long int</tt>
|
|
||||||
BigRat(unsigned long int x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>float</tt>
|
|
||||||
BigRat(float x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>double</tt>
|
|
||||||
BigRat(double x) : RCBigRat(new BigRatRep(x)) {}
|
|
||||||
/// constructor for <tt>const char*</tt> with base
|
|
||||||
BigRat(const char* s) : RCBigRat(new BigRatRep(s)) {}
|
|
||||||
/// constructor for <tt>std::string</tt> with base
|
|
||||||
BigRat(const std::string& s) : RCBigRat(new BigRatRep(s)) {}
|
|
||||||
/// constructor for <tt>mpq_srcptr</tt>
|
|
||||||
explicit BigRat(mpq_srcptr z) : RCBigRat(new BigRatRep(z)) {}
|
|
||||||
/// constructor for <tt>BigInt</tt>
|
|
||||||
BigRat(const BigInt& z) : RCBigRat(new BigRatRep(z.get_mp())) {}
|
|
||||||
/// constructor for two <tt>BigInts</tt>
|
|
||||||
BigRat(const BigInt& n, const BigInt& d)
|
|
||||||
: RCBigRat(new BigRatRep(n.get_mp(), d.get_mp())) {}
|
|
||||||
/// constructor for <tt>BigFloat</tt>
|
|
||||||
BigRat(const BigFloat&);
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Copy-Assignment-Destructor
|
|
||||||
//@{
|
|
||||||
/// copy constructor
|
|
||||||
BigRat(const BigRat& rhs) : RCBigRat(rhs) {
|
|
||||||
rep->incRef();
|
|
||||||
}
|
|
||||||
/// assignment operator
|
|
||||||
BigRat& operator=(const BigRat& rhs) {
|
|
||||||
if (this != &rhs) {
|
|
||||||
rep->decRef();
|
|
||||||
rep = rhs.rep;
|
|
||||||
rep->incRef();
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
/// destructor
|
|
||||||
~BigRat() {
|
|
||||||
rep->decRef();
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Overloaded operators
|
|
||||||
//@{
|
|
||||||
BigRat& operator +=(const BigRat& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpq_add(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat& operator -=(const BigRat& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpq_sub(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat& operator *=(const BigRat& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpq_mul(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat& operator /=(const BigRat& rhs) {
|
|
||||||
makeCopy();
|
|
||||||
mpq_div(get_mp(), get_mp(), rhs.get_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat& operator <<=(unsigned long ul) {
|
|
||||||
makeCopy();
|
|
||||||
mpq_mul_2exp(get_mp(), get_mp(), ul);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat& operator >>=(unsigned long ul) {
|
|
||||||
makeCopy();
|
|
||||||
mpq_div_2exp(get_mp(), get_mp(), ul);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name div2, unary, increment, decrement operators
|
|
||||||
//@{
|
|
||||||
|
|
||||||
/// exact division by 2 (this method is provided for compatibility)
|
|
||||||
BigRat div2() const {
|
|
||||||
BigRat r; BigRat t(2); // probably not most efficient way
|
|
||||||
mpq_div(r.get_mp(), get_mp(), t.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
BigRat operator+() const {
|
|
||||||
return BigRat(*this);
|
|
||||||
}
|
|
||||||
BigRat operator-() const {
|
|
||||||
BigRat r;
|
|
||||||
mpq_neg(r.get_mp(), get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
BigRat& operator++() {
|
|
||||||
makeCopy();
|
|
||||||
mpz_add(get_num_mp(),get_num_mp(),get_den_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat& operator--() {
|
|
||||||
makeCopy();
|
|
||||||
mpz_sub(get_num_mp(),get_num_mp(),get_den_mp());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
BigRat operator++(int) {
|
|
||||||
BigRat r(*this);
|
|
||||||
++(*this);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
BigRat operator--(int) {
|
|
||||||
BigRat r(*this);
|
|
||||||
--(*this);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Helper Functions
|
|
||||||
//@{
|
|
||||||
/// Canonicalize
|
|
||||||
void canonicalize() {
|
|
||||||
makeCopy();
|
|
||||||
mpq_canonicalize(get_mp());
|
|
||||||
}
|
|
||||||
/// Has Exact Division
|
|
||||||
static bool hasExactDivision() {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// return mpz pointer of numerator (const)
|
// Chee (3/19/2004):
|
||||||
mpz_srcptr get_num_mp() const {
|
|
||||||
return mpq_numref(get_mp());
|
|
||||||
}
|
|
||||||
/// return mpz pointer of numerator
|
|
||||||
mpz_ptr get_num_mp() {
|
|
||||||
return mpq_numref(get_mp());
|
|
||||||
}
|
|
||||||
/// return mpz pointer of denominator
|
|
||||||
mpz_srcptr get_den_mp() const {
|
|
||||||
return mpq_denref(get_mp());
|
|
||||||
}
|
|
||||||
/// return mpz pointer of denominator
|
|
||||||
mpz_ptr get_den_mp() {
|
|
||||||
return mpq_denref(get_mp());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// get mpq pointer (const)
|
|
||||||
mpq_srcptr get_mp() const {
|
|
||||||
return rep->get_mp();
|
|
||||||
}
|
|
||||||
/// get mpq pointer
|
|
||||||
mpq_ptr get_mp() {
|
|
||||||
return rep->get_mp();
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name String Conversion Functions
|
|
||||||
//@{
|
|
||||||
/// set value from <tt>const char*</tt>
|
|
||||||
int set_str(const char* s, int base = 0) {
|
|
||||||
makeCopy();
|
|
||||||
return mpq_set_str(get_mp(), s, base);
|
|
||||||
}
|
|
||||||
/// convert to <tt>std::string</tt>
|
|
||||||
std::string get_str(int base = 10) const {
|
|
||||||
int n = mpz_sizeinbase(mpq_numref(get_mp()), base) + mpz_sizeinbase(mpq_denref(get_mp()), base)+ 3;
|
|
||||||
char *buffer = new char[n];
|
|
||||||
mpq_get_str(buffer, base, get_mp());
|
|
||||||
std::string result(buffer);
|
|
||||||
delete [] buffer;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
|
|
||||||
/// \name Conversion Functions
|
|
||||||
//@{
|
|
||||||
/// intValue
|
|
||||||
int intValue() const {
|
|
||||||
return static_cast<int>(doubleValue());
|
|
||||||
}
|
|
||||||
/// longValue
|
|
||||||
long longValue() const {
|
|
||||||
return static_cast<long>(doubleValue());
|
|
||||||
}
|
|
||||||
/// doubleValue
|
|
||||||
double doubleValue() const {
|
|
||||||
return mpq_get_d(get_mp());
|
|
||||||
}
|
|
||||||
/// BigIntValue
|
|
||||||
BigInt BigIntValue() const {
|
|
||||||
BigInt r;
|
|
||||||
mpz_tdiv_q(r.get_mp(), get_num_mp(), get_den_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
//@}
|
|
||||||
}; //BigRat class
|
|
||||||
|
|
||||||
inline BigRat operator+(const BigRat& a, const BigRat& b) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_add(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigRat operator-(const BigRat& a, const BigRat& b) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_sub(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigRat operator*(const BigRat& a, const BigRat& b) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_mul(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigRat operator/(const BigRat& a, const BigRat& b) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_div(r.get_mp(), a.get_mp(), b.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
// Chee (3/19/2004):
|
|
||||||
// The following definitions of div_exact(x,y) and gcd(x,y)
|
// The following definitions of div_exact(x,y) and gcd(x,y)
|
||||||
// ensures that in Polynomial<NT>
|
// ensures that in Polynomial<NT>
|
||||||
/// divisible(x,y) = "x | y"
|
/// divisible(x,y) = "x | y"
|
||||||
inline BigRat div_exact(const BigRat& x, const BigRat& y) {
|
inline BigRat div_exact(const BigRat& x, const BigRat& y) {
|
||||||
BigRat z;
|
BigRat z = x / y;
|
||||||
mpq_div(z.get_mp(), x.get_mp(), y.get_mp());
|
return z;
|
||||||
return z;
|
}
|
||||||
}
|
|
||||||
/// numerator
|
|
||||||
inline BigInt numerator(const BigRat& a) {
|
|
||||||
return BigInt(a.get_num_mp());
|
|
||||||
}
|
|
||||||
/// denominator
|
|
||||||
inline BigInt denominator(const BigRat& a) {
|
|
||||||
return BigInt(a.get_den_mp());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BigRat gcd(const BigRat& x, const BigRat& y) {
|
inline BigRat gcd(const BigRat& x , const BigRat& y)
|
||||||
// return BigRat(1); // Remark: we may want replace this by
|
{
|
||||||
|
// return BigRat(1); // Remark: we may want replace this by
|
||||||
// the definition of gcd of a quotient field
|
// the definition of gcd of a quotient field
|
||||||
// of a UFD [Yap's book, Chap.3]
|
// of a UFD [Yap's book, Chap.3]
|
||||||
//Here is one possible definition: gcd of x and y is just the
|
//Here is one possible definition: gcd of x and y is just the
|
||||||
|
|
@ -384,98 +65,17 @@ inline BigRat gcd(const BigRat& x, const BigRat& y) {
|
||||||
BigInt n = gcd(numerator(x), numerator(y));
|
BigInt n = gcd(numerator(x), numerator(y));
|
||||||
BigInt d = gcd(denominator(x), denominator(y));
|
BigInt d = gcd(denominator(x), denominator(y));
|
||||||
return BigRat(n,d);
|
return BigRat(n,d);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
/// BigIntValue
|
||||||
// Chee: 8/8/2004: need isDivisible to compile Polynomial<BigRat>
|
inline BigInt BigIntValue(const BigRat& br)
|
||||||
// A trivial implementation is to return true always. But this
|
{
|
||||||
// caused tPolyRat to fail.
|
BigInt r, rem;
|
||||||
// So we follow the definition of
|
divide_qr(numerator(br), denominator(br), r, rem);
|
||||||
// Expr::isDivisible(e1, e2) which checks if e1/e2 is an integer.
|
|
||||||
inline bool isInteger(const BigRat& x) {
|
|
||||||
return BigInt(x.get_den_mp()) == 1;
|
|
||||||
}
|
|
||||||
inline bool isDivisible(const BigRat& x, const BigRat& y) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_div(r.get_mp(), x.get_mp(), y.get_mp());
|
|
||||||
return isInteger(r);
|
|
||||||
}
|
|
||||||
inline BigRat operator<<(const BigRat& a, unsigned long ul) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_mul_2exp(r.get_mp(), a.get_mp(), ul);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
inline BigRat operator>>(const BigRat& a, unsigned long ul) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_div_2exp(r.get_mp(), a.get_mp(), ul);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int cmp(const BigRat& x, const BigRat& y) {
|
} // namespace CORE
|
||||||
return mpq_cmp(x.get_mp(), y.get_mp());
|
|
||||||
}
|
|
||||||
inline bool operator==(const BigRat& a, const BigRat& b) {
|
|
||||||
return cmp(a, b) == 0;
|
|
||||||
}
|
|
||||||
inline bool operator!=(const BigRat& a, const BigRat& b) {
|
|
||||||
return cmp(a, b) != 0;
|
|
||||||
}
|
|
||||||
inline bool operator>=(const BigRat& a, const BigRat& b) {
|
|
||||||
return cmp(a, b) >= 0;
|
|
||||||
}
|
|
||||||
inline bool operator>(const BigRat& a, const BigRat& b) {
|
|
||||||
return cmp(a, b) > 0;
|
|
||||||
}
|
|
||||||
inline bool operator<=(const BigRat& a, const BigRat& b) {
|
|
||||||
return cmp(a, b) <= 0;
|
|
||||||
}
|
|
||||||
inline bool operator<(const BigRat& a, const BigRat& b) {
|
|
||||||
return cmp(a, b) < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& o, const BigRat& x) {
|
|
||||||
//return CORE::operator<<(o, x.get_mp());
|
|
||||||
return CORE::io_write(o, x.get_mp());
|
|
||||||
}
|
|
||||||
inline std::istream& operator>>(std::istream& i, BigRat& x) {
|
|
||||||
x.makeCopy();
|
|
||||||
//return CORE::operator>>(i, x.get_mp());
|
|
||||||
return CORE::io_read(i, x.get_mp());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// sign
|
|
||||||
inline int sign(const BigRat& a) {
|
|
||||||
return mpq_sgn(a.get_mp());
|
|
||||||
}
|
|
||||||
/// abs
|
|
||||||
inline BigRat abs(const BigRat& a) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_abs(r.get_mp(), a.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
/// neg
|
|
||||||
inline BigRat neg(const BigRat& a) {
|
|
||||||
BigRat r;
|
|
||||||
mpq_neg(r.get_mp(), a.get_mp());
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
/// div2
|
|
||||||
inline BigRat div2(const BigRat& a) {
|
|
||||||
BigRat r(a);
|
|
||||||
return r.div2();
|
|
||||||
}
|
|
||||||
/// longValue
|
|
||||||
inline long longValue(const BigRat& a) {
|
|
||||||
return a.longValue();
|
|
||||||
}
|
|
||||||
/// doubleValue
|
|
||||||
inline double doubleValue(const BigRat& a) {
|
|
||||||
return a.doubleValue();
|
|
||||||
}
|
|
||||||
/// return BigInt value
|
|
||||||
inline BigInt BigIntValue(const BigRat& a) {
|
|
||||||
return a.BigIntValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} //namespace CORE
|
|
||||||
#endif // _CORE_BIGRAT_H_
|
#endif // _CORE_BIGRAT_H_
|
||||||
|
|
|
||||||
|
|
@ -29,4 +29,13 @@
|
||||||
|
|
||||||
#include <CGAL/export/CORE.h>
|
#include <CGAL/export/CORE.h>
|
||||||
|
|
||||||
|
#ifdef CGAL_TEST_SUITE
|
||||||
|
// disabled for the testsuite to avoid `w`
|
||||||
|
#define CGAL_CORE_warning_msg(X ,Y)
|
||||||
|
// if (!(X)) CGAL_error_msg(Y)
|
||||||
|
#else
|
||||||
|
#define CGAL_CORE_warning_msg(X ,Y) CGAL_warning_msg(X ,Y)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // _CORE_CONFIG_H_
|
#endif // _CORE_CONFIG_H_
|
||||||
|
|
|
||||||
|
|
@ -156,12 +156,6 @@ CGAL_CORE_EXPORT double IntMantissa(double d);
|
||||||
// (See CORE_PATH/progs/ieee/frexp.cpp for details)
|
// (See CORE_PATH/progs/ieee/frexp.cpp for details)
|
||||||
CGAL_CORE_EXPORT int IntExponent(double d);
|
CGAL_CORE_EXPORT int IntExponent(double d);
|
||||||
|
|
||||||
/// Writes out an error or warning message in the local file CORE_DIAGFILE
|
|
||||||
/** If last argument (err) is TRUE, then this is considered an error
|
|
||||||
* (not just warning). In this case, the message is also printed in
|
|
||||||
* std::cerr, using std::perror().
|
|
||||||
* */
|
|
||||||
CGAL_CORE_EXPORT void core_error(std::string msg, std::string file, int lineno, bool err);
|
|
||||||
|
|
||||||
/// This is for debugging messages
|
/// This is for debugging messages
|
||||||
inline void core_debug(std::string msg){
|
inline void core_debug(std::string msg){
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@
|
||||||
|
|
||||||
#include <CGAL/use.h>
|
#include <CGAL/use.h>
|
||||||
#include <CGAL/CORE/CoreAux.h>
|
#include <CGAL/CORE/CoreAux.h>
|
||||||
#include <CGAL/gmp.h>
|
|
||||||
|
|
||||||
namespace CORE {
|
namespace CORE {
|
||||||
|
|
||||||
|
|
@ -157,30 +156,5 @@ int IntExponent(double d) {
|
||||||
return e-53;
|
return e-53;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// core_error is the method to write Core Library warning or error messages
|
|
||||||
/** Both warnings and errors are written to a file called CORE_DIAGFILE.
|
|
||||||
* But errors are also written on std::cerr (similar to std::perror()).
|
|
||||||
* */
|
|
||||||
// Usage: core_error(message, file_with_error, line_number, err_type)
|
|
||||||
// where err_type=0 means WARNING, error_type=0 means ERROR
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void core_error(std::string msg, std::string file, int lineno, bool err) {
|
|
||||||
std::ofstream outFile(CORE_DIAGFILE, std::ios::app); // open to append
|
|
||||||
if (!outFile) {
|
|
||||||
// perror("CORE ERROR: cannot open Core Diagnostics file");
|
|
||||||
std::cerr << "CORE ERROR: can't open Core Diagnostics file"<<std::endl;
|
|
||||||
std::exit(1); //Note: do not call abort()
|
|
||||||
}
|
|
||||||
outFile << "CORE " << (err? "ERROR" : "WARNING")
|
|
||||||
<< " (at " << file << ": " << lineno << "): "
|
|
||||||
<< msg << std::endl;
|
|
||||||
outFile.close();
|
|
||||||
if (err) {
|
|
||||||
std::cerr << (std::string("CORE ERROR") + " (file " + file + ", line "
|
|
||||||
+ std::to_string(lineno) +"):" + msg + "\n").c_str();
|
|
||||||
std::exit(1); //Note: do not call abort()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} //namespace CORE
|
} //namespace CORE
|
||||||
|
|
|
||||||
|
|
@ -1,479 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
*
|
|
||||||
* File: CoreIO.cpp
|
|
||||||
*
|
|
||||||
* Written by
|
|
||||||
* Zilin Du <zilin@cs.nyu.edu>
|
|
||||||
* Chee Yap <yap@cs.nyu.edu>
|
|
||||||
*
|
|
||||||
* WWW URL: https://cs.nyu.edu/exact/
|
|
||||||
* Email: exact@cs.nyu.edu
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _COREIO_IMPL_H_
|
|
||||||
#define _COREIO_IMPL_H_
|
|
||||||
|
|
||||||
#ifdef CGAL_HEADER_ONLY
|
|
||||||
#define CGAL_INLINE_FUNCTION inline
|
|
||||||
#else
|
|
||||||
#define CGAL_INLINE_FUNCTION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <CGAL/CORE/BigFloatRep.h>
|
|
||||||
#include <CGAL/CORE/BigFloat.h>
|
|
||||||
#include <CGAL/CORE/BigInt.h>
|
|
||||||
|
|
||||||
namespace CORE {
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void core_io_error_handler(const char *f, const char *m) {
|
|
||||||
std::cout << "\n error_handler";
|
|
||||||
std::cout << "::" << f << "::" << m << "\n";
|
|
||||||
std::cout.flush();
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void core_io_memory_handler(char *t, const char *f, const char *m) {
|
|
||||||
if (t == nullptr) {
|
|
||||||
std::cout << "\n memory_handler";
|
|
||||||
std::cout << "::" << f << "::" << m;
|
|
||||||
std::cout << "memory exhausted\n";
|
|
||||||
std::cout.flush();
|
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// s has size old_size and will be resized to new_size.
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void allocate (char * &s, int old_size, int new_size) {
|
|
||||||
if (old_size > new_size)
|
|
||||||
old_size = new_size;
|
|
||||||
|
|
||||||
if (s == nullptr)
|
|
||||||
old_size = 0;
|
|
||||||
|
|
||||||
char *t = new char[new_size];
|
|
||||||
core_io_memory_handler(t, "CoreIO", "allocate::out of memory error");
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < old_size; i++)
|
|
||||||
t[i] = s[i];
|
|
||||||
|
|
||||||
delete[] s;
|
|
||||||
s = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
// appends c to s at position pos.
|
|
||||||
// sz is the size of s
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void append_char (char * &s, int & sz, int pos, char c) {
|
|
||||||
if (pos > sz)
|
|
||||||
core_io_error_handler("CoreIO", "append_char::invalid argument");
|
|
||||||
|
|
||||||
if (pos == sz) {
|
|
||||||
allocate(s, sz, 2*sz);
|
|
||||||
sz *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
s[pos] = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// skip blanks, tabs, line breaks and comment lines
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
int skip_comment_line (std::istream & in) {
|
|
||||||
char c;
|
|
||||||
|
|
||||||
do {
|
|
||||||
in.get(c);
|
|
||||||
while ( c == '#' ) {
|
|
||||||
do {
|
|
||||||
in.get(c);
|
|
||||||
} while ( c != '\n' );
|
|
||||||
in.get(c);
|
|
||||||
}
|
|
||||||
} while (c == ' ' || c == '\t' || c == '\n');
|
|
||||||
|
|
||||||
if (in.eof())
|
|
||||||
core_io_error_handler("CoreIO::read_from_file()","unexpected end of file.");
|
|
||||||
|
|
||||||
in.putback(c);
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// skips '\\' followed by '\n'
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
char skip_backslash_new_line (std::istream & in) {
|
|
||||||
char c;
|
|
||||||
in.get(c);
|
|
||||||
|
|
||||||
while (c == '\\') {
|
|
||||||
in.get(c);
|
|
||||||
|
|
||||||
if (c == '\n')
|
|
||||||
in.get(c);
|
|
||||||
else
|
|
||||||
core_io_error_handler("CoreIO::operator>>", "\\ must be immediately followed by new line.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void read_string(std::istream& in, char* &buffer, int sz) {
|
|
||||||
char c;
|
|
||||||
int pos=0;
|
|
||||||
skip_comment_line(in);
|
|
||||||
|
|
||||||
while ( in.get(c) ) {
|
|
||||||
if ( c == ' ' || c == '\t' || c == '\n' || c == '#')
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
append_char(buffer, sz, pos++, c);
|
|
||||||
}
|
|
||||||
append_char(buffer, sz, pos, '\0');
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void read_base_number(std::istream& in, BigInt& m, long length, long maxBits) {
|
|
||||||
char *buffer;
|
|
||||||
int size, offset;
|
|
||||||
int base;
|
|
||||||
bool is_negate;
|
|
||||||
|
|
||||||
char c;
|
|
||||||
int pos = 0;
|
|
||||||
skip_comment_line(in);
|
|
||||||
|
|
||||||
// read sign
|
|
||||||
in.get(c);
|
|
||||||
if (c == '-') {
|
|
||||||
is_negate = true;
|
|
||||||
in.get(c);
|
|
||||||
} else
|
|
||||||
is_negate = false;
|
|
||||||
|
|
||||||
// read base and compute digits
|
|
||||||
if (c == '0') {
|
|
||||||
in.get(c);
|
|
||||||
if (c == 'b') {
|
|
||||||
base = 2;
|
|
||||||
size = (maxBits == 0 || maxBits > length) ? length : maxBits;
|
|
||||||
offset = length - size;
|
|
||||||
} else if (c == 'x') {
|
|
||||||
base = 16;
|
|
||||||
size = (maxBits == 0) ? length : (maxBits+3) >> 2;
|
|
||||||
size = (size > length) ? length : size;
|
|
||||||
offset = (length - size) << 2;
|
|
||||||
} else {
|
|
||||||
base = 8;
|
|
||||||
size = (maxBits == 0) ? length : (maxBits+2) / 3;
|
|
||||||
size = (size > length) ? length : size;
|
|
||||||
offset = (length - size) * 3;
|
|
||||||
in.putback(c);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
base = 10;
|
|
||||||
size = (maxBits == 0) ? length : (int)std::ceil(maxBits*std::log(2.0)/std::log(10.0));
|
|
||||||
size = (size > length) ? length : size;
|
|
||||||
offset = length - size;
|
|
||||||
in.putback(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = new char[size+2];
|
|
||||||
// read digits
|
|
||||||
for (int i=0; i<size; i++) {
|
|
||||||
c=skip_backslash_new_line(in);
|
|
||||||
if(in.eof()){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (c != ' ' && c != '\t' && c != '\n')
|
|
||||||
append_char(buffer, size, pos++, c);
|
|
||||||
}
|
|
||||||
if (base == 10) {
|
|
||||||
for(int j=0; j<offset; j++)
|
|
||||||
append_char(buffer, size, pos++, '0');
|
|
||||||
}
|
|
||||||
append_char(buffer, size, pos, '\0');
|
|
||||||
|
|
||||||
// convert string to bigint.
|
|
||||||
if (m.set_str(buffer, base) < 0)
|
|
||||||
core_io_error_handler("CoreIO::read_from_file()","bad big number format.");
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// shift left if necessary
|
|
||||||
if (offset > 0 && base != 10) {
|
|
||||||
m <<= offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_negate)
|
|
||||||
negate(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void write_base_number(std::ostream& out, char* buffer, std::size_t length, int base, int charsPerLine) {
|
|
||||||
// write big number in a format that gmp's mpz_set_str() can
|
|
||||||
// automatically recognize with argument base = 0.
|
|
||||||
if (base == 2)
|
|
||||||
out << "0b";
|
|
||||||
else if (base == 16)
|
|
||||||
out << "0x";
|
|
||||||
else if (base == 8)
|
|
||||||
out << '0';
|
|
||||||
|
|
||||||
// write big number in charsPerLine.
|
|
||||||
char* start, *end, c;
|
|
||||||
for (std::size_t i=0; i<length; i += charsPerLine) {
|
|
||||||
start = buffer + i;
|
|
||||||
if (i + charsPerLine >= length)
|
|
||||||
out << start;
|
|
||||||
else {
|
|
||||||
end = start + charsPerLine;
|
|
||||||
c = *end;
|
|
||||||
*end = '\0';
|
|
||||||
|
|
||||||
out << start << "\\\n";
|
|
||||||
*end = c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void readFromFile(BigInt& z, std::istream& in, long maxLength) {
|
|
||||||
char *buffer;
|
|
||||||
long length;
|
|
||||||
|
|
||||||
// check type name whether it is Integer or not.
|
|
||||||
buffer = new char[8];
|
|
||||||
read_string(in, buffer, sizeof(buffer));
|
|
||||||
if ( std::strcmp(buffer, "Integer") != 0)
|
|
||||||
core_io_error_handler("BigInt::read_from_file()","type name expected.");
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read the bit length field.
|
|
||||||
buffer = new char[100];
|
|
||||||
read_string(in, buffer, sizeof(buffer));
|
|
||||||
length = std::atol(buffer);
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read bigint
|
|
||||||
read_base_number(in, z, length, maxLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void writeToFile(const BigInt& z, std::ostream& out, int base, int charsPerLine) {
|
|
||||||
BigInt c = abs(z);
|
|
||||||
|
|
||||||
// get the absolute value string
|
|
||||||
char* buffer = new char[mpz_sizeinbase(c.get_mp(), base) + 2];
|
|
||||||
mpz_get_str(buffer, base, c.get_mp());
|
|
||||||
std::size_t length = std::strlen(buffer);
|
|
||||||
|
|
||||||
// write type name of big number and length
|
|
||||||
//out << "# This is an experimental big number format.\n";
|
|
||||||
out << "Integer " << length << "\n";
|
|
||||||
|
|
||||||
// if bigint is negative, then write an sign '-'.
|
|
||||||
if ( sign(z) < 0 )
|
|
||||||
out << '-';
|
|
||||||
|
|
||||||
write_base_number(out, buffer, length, base, charsPerLine);
|
|
||||||
out << "\n";
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void readFromFile(BigFloat& bf, std::istream& in, long maxLength) {
|
|
||||||
char *buffer;
|
|
||||||
long length;
|
|
||||||
long exponent;
|
|
||||||
BigInt mantissa;
|
|
||||||
|
|
||||||
// check type name whether it is Float
|
|
||||||
buffer = new char[6];
|
|
||||||
read_string(in, buffer, sizeof(buffer));
|
|
||||||
if (std::strcmp(buffer, "Float") != 0)
|
|
||||||
core_io_error_handler("BigFloat::read_from_file()", "type name expected");
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read base (default is 16384)
|
|
||||||
buffer = new char[8];
|
|
||||||
read_string(in, buffer, sizeof(buffer));
|
|
||||||
if (std::strcmp(buffer, "(16384)") != 0)
|
|
||||||
core_io_error_handler("BigFloat::read_from_file()", "base expected");
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read the bit length field.
|
|
||||||
buffer = new char[100];
|
|
||||||
read_string(in, buffer, sizeof(buffer));
|
|
||||||
length = std::atol(buffer);
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read exponent
|
|
||||||
buffer = new char[100];
|
|
||||||
read_string(in, buffer, sizeof(buffer));
|
|
||||||
exponent = std::atol(buffer);
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read mantissa
|
|
||||||
read_base_number(in, mantissa, length, maxLength);
|
|
||||||
|
|
||||||
// construct BigFloat
|
|
||||||
bf = BigFloat(mantissa, 0, exponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void writeToFile(const BigFloat& bf, std::ostream& out, int base, int charsPerLine) {
|
|
||||||
BigInt c(CORE::abs(bf.m()));
|
|
||||||
|
|
||||||
// get the absolute value string
|
|
||||||
char* buffer = new char[mpz_sizeinbase(c.get_mp(), base) + 2];
|
|
||||||
mpz_get_str(buffer, base, c.get_mp());
|
|
||||||
std::size_t length = std::strlen(buffer);
|
|
||||||
|
|
||||||
|
|
||||||
// write type name, base, length
|
|
||||||
//out << "# This is an experimental Big Float format." << std::endl;
|
|
||||||
out << "Float (16384) " << length << std::endl;
|
|
||||||
// write exponent
|
|
||||||
out << bf.exp() << std::endl;
|
|
||||||
|
|
||||||
// write mantissa
|
|
||||||
if ( CORE::sign(bf.m()) < 0 )
|
|
||||||
out << '-';
|
|
||||||
|
|
||||||
write_base_number(out, buffer, length, base, charsPerLine);
|
|
||||||
out << '\n';
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Underconstruction ----
|
|
||||||
void BigFloat::read_from_file2(std::istream& in, long maxLength) {
|
|
||||||
long length = 1024;
|
|
||||||
char *buffer;
|
|
||||||
|
|
||||||
// check type name whether it is Float
|
|
||||||
buffer = new char[7];
|
|
||||||
BigInt::read_string(in, buffer, sizeof(buffer));
|
|
||||||
if (strcmp(buffer, "NFloat") != 0)
|
|
||||||
core_io_error_handler("BigFloat::read_from_file2()", "type name expected");
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read base (default is 16)
|
|
||||||
buffer = new char[5];
|
|
||||||
BigInt::read_string(in, buffer, sizeof(buffer));
|
|
||||||
if (strcmp(buffer, "(16)") != 0)
|
|
||||||
core_io_error_handler("BigFloat::read_from_file2()", "base expected");
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read length field
|
|
||||||
buffer = new char[100];
|
|
||||||
BigInt::read_string(in, buffer, sizeof(buffer));
|
|
||||||
|
|
||||||
// get the length field if it is not null.
|
|
||||||
if (buffer[0] != '\0') {
|
|
||||||
length = atol(buffer);
|
|
||||||
if (maxLength > 0 && length >= maxLength)
|
|
||||||
length = maxLength;
|
|
||||||
}
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read exponent
|
|
||||||
buffer = new char[100];
|
|
||||||
BigInt::read_string(in, buffer, sizeof(buffer));
|
|
||||||
long exp16 = atol(buffer);
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// read mantissa
|
|
||||||
buffer = new char[length+2];
|
|
||||||
//BigInt::read_base_number(in, buffer, length);
|
|
||||||
|
|
||||||
BigInt m16(buffer);
|
|
||||||
delete[] buffer;
|
|
||||||
|
|
||||||
// convert to base CHUNK_BIT
|
|
||||||
exp16 = exp16 - length + 1;
|
|
||||||
if ( m16.is_negative() )
|
|
||||||
exp16 ++;
|
|
||||||
|
|
||||||
long tmp_exp = exp16 * 4;
|
|
||||||
long q = tmp_exp / CHUNK_BIT;
|
|
||||||
long r = tmp_exp % CHUNK_BIT;
|
|
||||||
if ( r < 0 ) {
|
|
||||||
r += CHUNK_BIT;
|
|
||||||
q --;
|
|
||||||
}
|
|
||||||
|
|
||||||
BigInt mantissa = m16 << r;
|
|
||||||
long exponent = q;
|
|
||||||
|
|
||||||
// construct BigFloat
|
|
||||||
if (--rep->refCount == 0)
|
|
||||||
delete rep;
|
|
||||||
|
|
||||||
rep = new BigFloatRep(mantissa, 0, exponent);
|
|
||||||
rep->refCount++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// write normal float
|
|
||||||
// now it assumed to write in hex base, i.e. B=2^4=16
|
|
||||||
// (note: our default base B=2^(CHUNK_BIT)=2^14=16384
|
|
||||||
void BigFloat::write_to_file2(std::ostream& out, int base, int charsPerLine) {
|
|
||||||
// convert to base 16.
|
|
||||||
long new_base = 4; // 2^4 = 16
|
|
||||||
long tmp_exp = (rep->exp) * CHUNK_BIT;
|
|
||||||
long q = tmp_exp / new_base;
|
|
||||||
long r = tmp_exp % new_base;
|
|
||||||
std::cout << "CORE_DEBUG: q=" << q << ", r=" << r << std::endl;
|
|
||||||
if ( r < 0 ) {
|
|
||||||
r += new_base;
|
|
||||||
q--;
|
|
||||||
}
|
|
||||||
std::cout << "CORE_DEBUG: q=" << q << ", r=" << r << std::endl;
|
|
||||||
|
|
||||||
BigInt m16 = (rep->m) << r;
|
|
||||||
|
|
||||||
int size = mpz_sizeinbase(m16.I, base) + 2;
|
|
||||||
std::cout << "size=" << size << std::endl;
|
|
||||||
char* buffer = new char[size];
|
|
||||||
|
|
||||||
int length = bigint_to_string(m16, buffer, base);
|
|
||||||
std::cout << "length=" << length << std::endl;
|
|
||||||
|
|
||||||
long exp16 = q + length - 1;
|
|
||||||
if ( m16.is_negative() )
|
|
||||||
exp16 --;
|
|
||||||
|
|
||||||
// write type name, base, length
|
|
||||||
out << "# This is an experimental Big Float format." << std::endl;
|
|
||||||
out << "NFloat (16) " << length << std::endl;
|
|
||||||
|
|
||||||
// write exponent
|
|
||||||
out << exp16 << std::endl;
|
|
||||||
|
|
||||||
// write mantissa
|
|
||||||
if ( m16.is_negative() ) {
|
|
||||||
out << '-';
|
|
||||||
buffer ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
BigInt::write_base_number(out, buffer, length, base, charsPerLine);
|
|
||||||
out << '\n';
|
|
||||||
delete[] buffer;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
} //namespace CORE
|
|
||||||
|
|
||||||
#endif // _COREIO_IMPL_H_
|
|
||||||
|
|
@ -72,9 +72,7 @@ public:
|
||||||
Expr(float f) : RCExpr(nullptr) { // check for valid numbers
|
Expr(float f) : RCExpr(nullptr) { // check for valid numbers
|
||||||
// (i.e., not infinite and not NaN)
|
// (i.e., not infinite and not NaN)
|
||||||
if (! CGAL_CORE_finite(f)) {
|
if (! CGAL_CORE_finite(f)) {
|
||||||
core_error(" ERROR : constructed an invalid float! ", __FILE__, __LINE__, false);
|
CGAL_error_msg("ERROR : constructed an invalid float! ");
|
||||||
if (get_static_AbortFlag())
|
|
||||||
abort();
|
|
||||||
get_static_InvalidFlag() = -1;
|
get_static_InvalidFlag() = -1;
|
||||||
}
|
}
|
||||||
rep = new ConstDoubleRep(f);
|
rep = new ConstDoubleRep(f);
|
||||||
|
|
@ -83,9 +81,7 @@ public:
|
||||||
Expr(double d) : RCExpr(nullptr) { // check for valid numbers
|
Expr(double d) : RCExpr(nullptr) { // check for valid numbers
|
||||||
// (i.e., not infinite and not NaN)
|
// (i.e., not infinite and not NaN)
|
||||||
if (! CGAL_CORE_finite(d)) {
|
if (! CGAL_CORE_finite(d)) {
|
||||||
core_error(" ERROR : constructed an invalid double! ", __FILE__, __LINE__, false);
|
CGAL_error_msg("ERROR : constructed an invalid double! ");
|
||||||
if (get_static_AbortFlag())
|
|
||||||
abort();
|
|
||||||
get_static_InvalidFlag() = -2;
|
get_static_InvalidFlag() = -2;
|
||||||
}
|
}
|
||||||
rep = new ConstDoubleRep(d);
|
rep = new ConstDoubleRep(d);
|
||||||
|
|
@ -95,6 +91,14 @@ public:
|
||||||
Expr(const BigInt& I) : RCExpr(new ConstRealRep(Real(I))) {}
|
Expr(const BigInt& I) : RCExpr(new ConstRealRep(Real(I))) {}
|
||||||
/// constructor for <tt>BigRat</tt>
|
/// constructor for <tt>BigRat</tt>
|
||||||
Expr(const BigRat& R) : RCExpr(new ConstRealRep(Real(R))) {}
|
Expr(const BigRat& R) : RCExpr(new ConstRealRep(Real(R))) {}
|
||||||
|
/// constructor from expression template
|
||||||
|
template <class TmplExpr,
|
||||||
|
class = std::enable_if_t<
|
||||||
|
boost::multiprecision::is_number_expression<TmplExpr>::value> >
|
||||||
|
Expr(const TmplExpr& R)
|
||||||
|
: RCExpr(new ConstRealRep(Real(
|
||||||
|
std::conditional_t<boost::multiprecision::number_category<TmplExpr>::value == boost::multiprecision::number_kind_integer,
|
||||||
|
BigInt, BigRat>(R)))) {}
|
||||||
|
|
||||||
/// constructor for <tt>BigFloat</tt>
|
/// constructor for <tt>BigFloat</tt>
|
||||||
Expr(const BigFloat& F) : RCExpr(new ConstRealRep(Real(F))) {}
|
Expr(const BigFloat& F) : RCExpr(new ConstRealRep(Real(F))) {}
|
||||||
|
|
@ -173,9 +177,7 @@ public:
|
||||||
/// /= operator
|
/// /= operator
|
||||||
Expr& operator/=(const Expr& e) {
|
Expr& operator/=(const Expr& e) {
|
||||||
if ((e.rep)->getSign() == 0) {
|
if ((e.rep)->getSign() == 0) {
|
||||||
core_error(" ERROR : division by zero ! ",__FILE__, __LINE__, false);
|
CGAL_error_msg("ERROR : division by zero ! ");
|
||||||
if (get_static_AbortFlag())
|
|
||||||
abort();
|
|
||||||
get_static_InvalidFlag() = -3;
|
get_static_InvalidFlag() = -3;
|
||||||
}
|
}
|
||||||
*this = new DivRep(rep, e.rep);
|
*this = new DivRep(rep, e.rep);
|
||||||
|
|
@ -376,9 +378,7 @@ inline Expr operator*(const Expr& e1, const Expr& e2) {
|
||||||
/// division
|
/// division
|
||||||
inline Expr operator/(const Expr& e1, const Expr& e2) {
|
inline Expr operator/(const Expr& e1, const Expr& e2) {
|
||||||
if (e2.sign() == 0) {
|
if (e2.sign() == 0) {
|
||||||
core_error(" ERROR : division by zero ! ", __FILE__, __LINE__, false);
|
CGAL_error_msg("ERROR : division by zero ! ");
|
||||||
if (get_static_AbortFlag())
|
|
||||||
abort();
|
|
||||||
get_static_InvalidFlag() = -4;
|
get_static_InvalidFlag() = -4;
|
||||||
}
|
}
|
||||||
return Expr(new DivRep(e1.Rep(), e2.Rep()));
|
return Expr(new DivRep(e1.Rep(), e2.Rep()));
|
||||||
|
|
@ -479,9 +479,7 @@ inline bool isDivisible(const Expr& e1, const Expr& e2) {
|
||||||
/// square root
|
/// square root
|
||||||
inline Expr sqrt(const Expr& e) {
|
inline Expr sqrt(const Expr& e) {
|
||||||
if (e.sign() < 0) {
|
if (e.sign() < 0) {
|
||||||
core_error(" ERROR : sqrt of negative value ! ", __FILE__, __LINE__, false);
|
CGAL_error_msg("ERROR : sqrt of negative value ! ");
|
||||||
if (get_static_AbortFlag())
|
|
||||||
abort();
|
|
||||||
get_static_InvalidFlag() = -5;
|
get_static_InvalidFlag() = -5;
|
||||||
}
|
}
|
||||||
return Expr(new SqrtRep(e.Rep()));
|
return Expr(new SqrtRep(e.Rep()));
|
||||||
|
|
|
||||||
|
|
@ -564,9 +564,7 @@ public:
|
||||||
I = ss.isolateRoot(n);
|
I = ss.isolateRoot(n);
|
||||||
// check whether n-th root exists
|
// check whether n-th root exists
|
||||||
if (I.first == 1 && I.second == 0) {
|
if (I.first == 1 && I.second == 0) {
|
||||||
core_error("CORE ERROR! root index out of bound",
|
CGAL_error_msg("CORE ERROR! root index out of bound");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
// test if the root isolated in I is 0:
|
// test if the root isolated in I is 0:
|
||||||
if ((I.first == 0)&&(I.second == 0))
|
if ((I.first == 0)&&(I.second == 0))
|
||||||
|
|
@ -583,9 +581,7 @@ public:
|
||||||
ss.isolateRoots(I.first, I.second, v);
|
ss.isolateRoots(I.first, I.second, v);
|
||||||
I = v.front();
|
I = v.front();
|
||||||
if (v.size() != 1) {
|
if (v.size() != 1) {
|
||||||
core_error("CORE ERROR! non-isolating interval",
|
CGAL_error_msg("CORE ERROR! non-isolating interval");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
abort();
|
|
||||||
}
|
}
|
||||||
ffVal = computeFilteredValue(); // Chee: this line seems unnecessary
|
ffVal = computeFilteredValue(); // Chee: this line seems unnecessary
|
||||||
}
|
}
|
||||||
|
|
@ -1092,8 +1088,7 @@ void AddSubRep<Operator>::computeExactFlags() {
|
||||||
uMSB() = newValue.uMSB(); // chen: to get tighers value.
|
uMSB() = newValue.uMSB(); // chen: to get tighers value.
|
||||||
sign() = newValue.sign();
|
sign() = newValue.sign();
|
||||||
} else if (lowBound.isInfty()) {//check if rootbound is too big
|
} else if (lowBound.isInfty()) {//check if rootbound is too big
|
||||||
core_error("AddSubRep:root bound has exceeded the maximum size\n \
|
CGAL_CORE_warning_msg(false, "AddSubRep:root bound has exceeded the maximum size but we still cannot decide zero.");
|
||||||
but we still cannot decide zero.\n", __FILE__, __LINE__, false);
|
|
||||||
} else { // Op(first, second) == 0
|
} else { // Op(first, second) == 0
|
||||||
lMSB() = CORE_negInfty;
|
lMSB() = CORE_negInfty;
|
||||||
sign() = 0;
|
sign() = 0;
|
||||||
|
|
@ -1186,8 +1181,7 @@ void AddSubRep<Operator>::computeExactFlags() {
|
||||||
//8/9/01, Chee: implement escape precision here:
|
//8/9/01, Chee: implement escape precision here:
|
||||||
if (i> get_static_EscapePrec()) {
|
if (i> get_static_EscapePrec()) {
|
||||||
get_static_EscapePrecFlag() = -i.asLong();//negative means EscapePrec is used
|
get_static_EscapePrecFlag() = -i.asLong();//negative means EscapePrec is used
|
||||||
core_error("Escape precision triggered at",
|
CGAL_CORE_warning_msg(false, "Escape precision triggered");
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
if (get_static_EscapePrecWarning())
|
if (get_static_EscapePrecWarning())
|
||||||
std::cout<< "Escape Precision triggered at "
|
std::cout<< "Escape Precision triggered at "
|
||||||
<< get_static_EscapePrec() << " bits" << std::endl;
|
<< get_static_EscapePrec() << " bits" << std::endl;
|
||||||
|
|
@ -1204,8 +1198,7 @@ void AddSubRep<Operator>::computeExactFlags() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (sign() == 0 && ua .isInfty()) {
|
if (sign() == 0 && ua .isInfty()) {
|
||||||
core_error("AddSubRep: root bound has exceeded the maximum size\n \
|
CGAL_error_msg("AddSubRep: root bound has exceeded the maximum size but we still cannot decide zero.");
|
||||||
but we still cannot decide zero.\n", __FILE__, __LINE__, true);
|
|
||||||
} // if (sign == 0 && ua .isInfty())
|
} // if (sign == 0 && ua .isInfty())
|
||||||
}// else do progressive
|
}// else do progressive
|
||||||
}
|
}
|
||||||
|
|
@ -1236,8 +1229,7 @@ void AddSubRep<Operator>::computeApproxValue(const extLong& relPrec,
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "CORE WARNING: a huge lMSB in AddSubRep: " << lMSB();
|
oss << "CORE WARNING: a huge lMSB in AddSubRep: " << lMSB();
|
||||||
core_error(oss.str(),
|
CGAL_CORE_warning_msg(false, oss.str().c_str());
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extLong rf = first->uMSB()-lMSB()+relPrec+EXTLONG_FOUR; // 2 better
|
extLong rf = first->uMSB()-lMSB()+relPrec+EXTLONG_FOUR; // 2 better
|
||||||
|
|
|
||||||
|
|
@ -702,7 +702,7 @@ void computeExactFlags_temp(ConstRep* t, const Real &value) {
|
||||||
} else {
|
} else {
|
||||||
t->uMSB() = value.uMSB();
|
t->uMSB() = value.uMSB();
|
||||||
t->lMSB() = value.lMSB();
|
t->lMSB() = value.lMSB();
|
||||||
core_error("Leaves in DAG is not exact!", __FILE__, __LINE__, true);
|
CGAL_error_msg("Leafs in DAG is not exact!");
|
||||||
}
|
}
|
||||||
|
|
||||||
t->sign() = value.sign();
|
t->sign() = value.sign();
|
||||||
|
|
@ -809,8 +809,7 @@ void SqrtRep::computeExactFlags() {
|
||||||
|
|
||||||
sign() = child->sign();
|
sign() = child->sign();
|
||||||
if (sign() < 0)
|
if (sign() < 0)
|
||||||
core_error("squareroot is called with negative operand.",
|
CGAL_error_msg("square root is called with negative operand.");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
|
|
||||||
uMSB() = child->uMSB() / EXTLONG_TWO;
|
uMSB() = child->uMSB() / EXTLONG_TWO;
|
||||||
lMSB() = child->lMSB() / EXTLONG_TWO;
|
lMSB() = child->lMSB() / EXTLONG_TWO;
|
||||||
|
|
@ -928,7 +927,7 @@ void DivRep::computeExactFlags() {
|
||||||
second->computeExactFlags();
|
second->computeExactFlags();
|
||||||
|
|
||||||
if (!second->sign())
|
if (!second->sign())
|
||||||
core_error("zero divisor.", __FILE__, __LINE__, true);
|
CGAL_error_msg("zero divisor.");
|
||||||
|
|
||||||
if (!first->sign()) {// value must be exactly zero.
|
if (!first->sign()) {// value must be exactly zero.
|
||||||
reduceToZero();
|
reduceToZero();
|
||||||
|
|
@ -1025,8 +1024,7 @@ void MultRep::computeApproxValue(const extLong& relPrec,
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB();
|
oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB();
|
||||||
core_error(oss.str(),
|
CGAL_CORE_warning_msg(false, oss.str().c_str());
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extLong r = relPrec + EXTLONG_FOUR;
|
extLong r = relPrec + EXTLONG_FOUR;
|
||||||
|
|
@ -1048,8 +1046,7 @@ void DivRep::computeApproxValue(const extLong& relPrec,
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB();
|
oss << "CORE WARNING: a huge lMSB in AddSubRep " << lMSB();
|
||||||
core_error(oss.str(),
|
CGAL_CORE_warning_msg(false, oss.str().c_str());
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extLong rr = relPrec + EXTLONG_SEVEN; // These rules come from
|
extLong rr = relPrec + EXTLONG_SEVEN; // These rules come from
|
||||||
|
|
@ -1082,7 +1079,9 @@ void Expr::debug(int mode, int level, int depthLimit) const {
|
||||||
else if (mode == Expr::TREE_MODE)
|
else if (mode == Expr::TREE_MODE)
|
||||||
rep->debugTree(level, 0, depthLimit);
|
rep->debugTree(level, 0, depthLimit);
|
||||||
else
|
else
|
||||||
core_error("unknown debugging mode", __FILE__, __LINE__, false);
|
{
|
||||||
|
CGAL_CORE_warning_msg(false, "unknown debugging mode");
|
||||||
|
}
|
||||||
std::cout << "---- End Expr debug(): " << std::endl;
|
std::cout << "---- End Expr debug(): " << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1215,8 +1214,6 @@ void BinOpRep::debugTree(int level, int indent, int depthLimit) const {
|
||||||
second->debugTree(level, indent + 2, depthLimit - 1);
|
second->debugTree(level, indent + 2, depthLimit - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CORE_MEMORY_IMPL(BigIntRep)
|
|
||||||
CORE_MEMORY_IMPL(BigRatRep)
|
|
||||||
CORE_MEMORY_IMPL(ConstDoubleRep)
|
CORE_MEMORY_IMPL(ConstDoubleRep)
|
||||||
CORE_MEMORY_IMPL(ConstRealRep)
|
CORE_MEMORY_IMPL(ConstRealRep)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,8 @@ public:
|
||||||
}
|
}
|
||||||
/// division
|
/// division
|
||||||
filteredFp operator/ (const filteredFp& x) const {
|
filteredFp operator/ (const filteredFp& x) const {
|
||||||
if (x.fpVal == 0.0)
|
CGAL_CORE_warning_msg(x.fpVal != 0.0, "possible zero divisor!");
|
||||||
core_error("possible zero divisor!", __FILE__, __LINE__, false);
|
|
||||||
double xxx = core_abs(x.fpVal) / x.maxAbs - (x.ind+1)*CORE_EPS + DBL_MIN;
|
double xxx = core_abs(x.fpVal) / x.maxAbs - (x.ind+1)*CORE_EPS + DBL_MIN;
|
||||||
if (xxx > 0) {
|
if (xxx > 0) {
|
||||||
double val = fpVal / x.fpVal;
|
double val = fpVal / x.fpVal;
|
||||||
|
|
@ -149,8 +149,8 @@ public:
|
||||||
}
|
}
|
||||||
/// square root
|
/// square root
|
||||||
filteredFp sqrt () const {
|
filteredFp sqrt () const {
|
||||||
if (fpVal < 0.0)
|
|
||||||
core_error("possible negative sqrt!", __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg( !(fpVal < 0.0), "possible negative sqrt!");
|
||||||
if (fpVal > 0.0) {
|
if (fpVal > 0.0) {
|
||||||
double val = std::sqrt(fpVal);
|
double val = std::sqrt(fpVal);
|
||||||
return filteredFp(val, ( maxAbs / fpVal ) * val, 1 + ind);
|
return filteredFp(val, ( maxAbs / fpVal ) * val, 1 + ind);
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of CGAL (www.cgal.org).
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
// CORE LIBRARY FILE
|
|
||||||
#ifndef _CORE_GMP_H_
|
|
||||||
#define _CORE_GMP_H_
|
|
||||||
|
|
||||||
#include <CGAL/CORE/Impl.h>
|
|
||||||
#include <gmp.h>
|
|
||||||
|
|
||||||
namespace CORE {
|
|
||||||
|
|
||||||
CGAL_CORE_EXPORT std::ostream& io_write (std::ostream &, mpz_srcptr);
|
|
||||||
CGAL_CORE_EXPORT std::ostream& io_write (std::ostream &, mpq_srcptr);
|
|
||||||
CGAL_CORE_EXPORT std::istream& io_read (std::istream &, mpz_ptr);
|
|
||||||
CGAL_CORE_EXPORT std::istream& io_read (std::istream &, mpq_ptr);
|
|
||||||
//std::ostream& operator<< (std::ostream &, mpz_srcptr);
|
|
||||||
//std::ostream& operator<< (std::ostream &, mpq_srcptr);
|
|
||||||
//std::istream& operator>> (std::istream &, mpz_ptr);
|
|
||||||
//std::istream& operator>> (std::istream &, mpq_ptr);
|
|
||||||
|
|
||||||
} //namespace CORE
|
|
||||||
|
|
||||||
#ifdef CGAL_HEADER_ONLY
|
|
||||||
#include <CGAL/CORE/Gmp_impl.h>
|
|
||||||
#endif // CGAL_HEADER_ONLY
|
|
||||||
|
|
||||||
#endif // _CORE_GMP_H_
|
|
||||||
|
|
@ -1,265 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
* Core Library Version 1.7, August 2004
|
|
||||||
* Copyright (c) 1995-2004 Exact Computation Project
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* file: GmpIO.cpp
|
|
||||||
* Adapted from multi-files under /cxx in GMP's source distribution
|
|
||||||
*
|
|
||||||
* Zilin Du, 2003
|
|
||||||
*
|
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
* SPDX-License-Identifier: LGPL-3.0-only
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
/* Auxiliary functions for C++-style input of GMP types.
|
|
||||||
|
|
||||||
Copyright 2001 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is part of the GNU MP Library.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CGAL_HEADER_ONLY
|
|
||||||
#define CGAL_INLINE_FUNCTION inline
|
|
||||||
#else
|
|
||||||
#define CGAL_INLINE_FUNCTION
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <CGAL/CORE/Gmp.h>
|
|
||||||
#include <cctype>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
namespace CORE {
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
int
|
|
||||||
__gmp_istream_set_base (std::istream &i, char &c, bool &zero, bool &showbase)
|
|
||||||
{
|
|
||||||
int base;
|
|
||||||
using std::ios;
|
|
||||||
|
|
||||||
zero = showbase = false;
|
|
||||||
switch (i.flags() & ios::basefield)
|
|
||||||
{
|
|
||||||
case ios::dec:
|
|
||||||
base = 10;
|
|
||||||
break;
|
|
||||||
case ios::hex:
|
|
||||||
base = 16;
|
|
||||||
break;
|
|
||||||
case ios::oct:
|
|
||||||
base = 8;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
showbase = true; // look for initial "0" or "0x" or "0X"
|
|
||||||
if (c == '0')
|
|
||||||
{
|
|
||||||
if (! i.get(c))
|
|
||||||
c = 0; // reset or we might loop indefinitely
|
|
||||||
|
|
||||||
if (c == 'x' || c == 'X')
|
|
||||||
{
|
|
||||||
base = 16;
|
|
||||||
i.get(c);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
base = 8;
|
|
||||||
zero = true; // if no other digit is read, the "0" counts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
base = 10;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void
|
|
||||||
__gmp_istream_set_digits (std::string &s, std::istream &i, char &c, bool &ok, int base)
|
|
||||||
{
|
|
||||||
switch (base)
|
|
||||||
{
|
|
||||||
case 10:
|
|
||||||
while (isdigit(c))
|
|
||||||
{
|
|
||||||
ok = true; // at least a valid digit was read
|
|
||||||
s += c;
|
|
||||||
if (! i.get(c))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
while (isdigit(c) && c != '8' && c != '9')
|
|
||||||
{
|
|
||||||
ok = true; // at least a valid digit was read
|
|
||||||
s += c;
|
|
||||||
if (! i.get(c))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
while (isxdigit(c))
|
|
||||||
{
|
|
||||||
ok = true; // at least a valid digit was read
|
|
||||||
s += c;
|
|
||||||
if (! i.get(c))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
std::istream &
|
|
||||||
//operator>> (std::istream &i, mpz_ptr z)
|
|
||||||
io_read (std::istream &i, mpz_ptr z)
|
|
||||||
{
|
|
||||||
using namespace std;
|
|
||||||
int base;
|
|
||||||
char c = 0;
|
|
||||||
std::string s;
|
|
||||||
bool ok = false, zero, showbase;
|
|
||||||
|
|
||||||
i.get(c); // start reading
|
|
||||||
|
|
||||||
if (i.flags() & ios::skipws) // skip initial whitespace
|
|
||||||
while (isspace(c) && i.get(c))
|
|
||||||
;
|
|
||||||
|
|
||||||
if (c == '-' || c == '+') // sign
|
|
||||||
{
|
|
||||||
if (c == '-') // mpz_set_str doesn't accept '+'
|
|
||||||
s = "-";
|
|
||||||
i.get(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (isspace(c) && i.get(c)) // skip whitespace
|
|
||||||
;
|
|
||||||
|
|
||||||
base = __gmp_istream_set_base(i, c, zero, showbase); // select the base
|
|
||||||
__gmp_istream_set_digits(s, i, c, ok, base); // read the number
|
|
||||||
|
|
||||||
if (i.good()) // last character read was non-numeric
|
|
||||||
i.putback(c);
|
|
||||||
else if (i.eof() && (ok || zero)) // stopped just before eof
|
|
||||||
i.clear();
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
mpz_set_str(z, s.c_str(), base); // extract the number
|
|
||||||
else if (zero)
|
|
||||||
mpz_set_ui(z, 0);
|
|
||||||
else
|
|
||||||
i.setstate(ios::failbit); // read failed
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
std::istream &
|
|
||||||
//operator>> (std::istream &i, mpq_ptr q)
|
|
||||||
io_read (std::istream &i, mpq_ptr q)
|
|
||||||
{
|
|
||||||
using namespace std;
|
|
||||||
int base;
|
|
||||||
char c = 0;
|
|
||||||
std::string s;
|
|
||||||
bool ok = false, zero, showbase;
|
|
||||||
|
|
||||||
i.get(c); // start reading
|
|
||||||
|
|
||||||
if (i.flags() & ios::skipws) // skip initial whitespace
|
|
||||||
while (isspace(c) && i.get(c))
|
|
||||||
;
|
|
||||||
|
|
||||||
if (c == '-' || c == '+') // sign
|
|
||||||
{
|
|
||||||
if (c == '-')
|
|
||||||
s = "-";
|
|
||||||
i.get(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (isspace(c) && i.get(c)) // skip whitespace
|
|
||||||
;
|
|
||||||
|
|
||||||
base = __gmp_istream_set_base(i, c, zero, showbase); // select the base
|
|
||||||
__gmp_istream_set_digits(s, i, c, ok, base); // read the numerator
|
|
||||||
|
|
||||||
if (! ok && zero) // the only digit read was "0"
|
|
||||||
{
|
|
||||||
base = 10;
|
|
||||||
s += '0';
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == '/') // there's a denominator
|
|
||||||
{
|
|
||||||
bool zero2 = false;
|
|
||||||
int base2 = base;
|
|
||||||
|
|
||||||
s += '/';
|
|
||||||
ok = false; // denominator is mandatory
|
|
||||||
i.get(c);
|
|
||||||
|
|
||||||
while (isspace(c) && i.get(c)) // skip whitespace
|
|
||||||
;
|
|
||||||
|
|
||||||
if (showbase) // check base of denominator
|
|
||||||
base2 = __gmp_istream_set_base(i, c, zero2, showbase);
|
|
||||||
|
|
||||||
if (base2 == base || base2 == 10) // read the denominator
|
|
||||||
__gmp_istream_set_digits(s, i, c, ok, base);
|
|
||||||
|
|
||||||
if (! ok && zero2) // the only digit read was "0"
|
|
||||||
{ // denominator is 0, but that's your business
|
|
||||||
s += '0';
|
|
||||||
ok = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.good()) // last character read was non-numeric
|
|
||||||
i.putback(c);
|
|
||||||
else if (i.eof() && ok) // stopped just before eof
|
|
||||||
i.clear();
|
|
||||||
|
|
||||||
if (ok)
|
|
||||||
mpq_set_str(q, s.c_str(), base); // extract the number
|
|
||||||
else
|
|
||||||
i.setstate(ios::failbit); // read failed
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
std::ostream&
|
|
||||||
//operator<< (std::ostream &o, mpz_srcptr z)
|
|
||||||
io_write (std::ostream &o, mpz_srcptr z)
|
|
||||||
{
|
|
||||||
char *str = new char [mpz_sizeinbase(z,10) + 2];
|
|
||||||
str = mpz_get_str(str, 10, z);
|
|
||||||
o << str ;
|
|
||||||
delete[] str;
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
std::ostream&
|
|
||||||
//operator<< (std::ostream &o, mpq_srcptr q)
|
|
||||||
io_write (std::ostream &o, mpq_srcptr q)
|
|
||||||
{
|
|
||||||
// size according to GMP documentation
|
|
||||||
char *str = new char [mpz_sizeinbase(mpq_numref(q), 10) +
|
|
||||||
mpz_sizeinbase (mpq_denref(q), 10) + 3];
|
|
||||||
str = mpq_get_str(str, 10, q);
|
|
||||||
o << str ;
|
|
||||||
delete[] str;
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace CORE
|
|
||||||
|
|
@ -57,7 +57,7 @@ public:
|
||||||
t = t->next;
|
t = t->next;
|
||||||
}
|
}
|
||||||
//);
|
//);
|
||||||
//CGAL_warning_msg(count == nObjects * blocks.size(),
|
//CGAL_CORE_warning_msg(count == nObjects * blocks.size(),
|
||||||
// "Cannot delete memory as there are cyclic references");
|
// "Cannot delete memory as there are cyclic references");
|
||||||
|
|
||||||
if(count == nObjects * blocks.size()){
|
if(count == nObjects * blocks.size()){
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,12 @@
|
||||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#ifndef __PROMOTE_H__
|
#ifndef _CORE_PROMOTE_H__
|
||||||
#define __PROMOTE_H__
|
#define _CORE_PROMOTE_H__
|
||||||
|
|
||||||
#include <CGAL/CORE/Impl.h>
|
#include <CGAL/CORE/Impl.h>
|
||||||
|
#include <CGAL/CORE/BigInt.h>
|
||||||
|
#include <CGAL/CORE/BigRat.h>
|
||||||
|
|
||||||
namespace CORE {
|
namespace CORE {
|
||||||
|
|
||||||
|
|
@ -67,10 +69,10 @@ class Promotion<T, T> {
|
||||||
typedef T ResultT;
|
typedef T ResultT;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_TYPE(T1, T2) \
|
#define CORE_MAX_TYPE(T1, T2) \
|
||||||
typename Promotion<T1, T2>::ResultT
|
typename Promotion<T1, T2>::ResultT
|
||||||
|
|
||||||
#define DEFINE_MAX_TYPE(T1, T2, Tr) \
|
#define CORE_DEFINE_MAX_TYPE(T1, T2, Tr) \
|
||||||
template<> class Promotion<T1, T2> { \
|
template<> class Promotion<T1, T2> { \
|
||||||
public: \
|
public: \
|
||||||
typedef Tr ResultT; \
|
typedef Tr ResultT; \
|
||||||
|
|
@ -83,15 +85,15 @@ class Promotion<T, T> {
|
||||||
/*
|
/*
|
||||||
* For example:
|
* For example:
|
||||||
*
|
*
|
||||||
* DEFINE_MAX_TYPE(BigInt, BigRat, BigRat) // define the promotion
|
* CORE_DEFINE_MAX_TYPE(BigInt, BigRat, BigRat) // define the promotion
|
||||||
*
|
*
|
||||||
* template<typename T1, typename T2> // define function f with type templates
|
* template<typename T1, typename T2> // define function f with type templates
|
||||||
* MAX_TYPE(T1, T2) f(T1& , T2& );
|
* CORE_MAX_TYPE(T1, T2) f(T1& , T2& );
|
||||||
*
|
*
|
||||||
* or
|
* or
|
||||||
*
|
*
|
||||||
* template<typename T1, typename T2> // define function f with type templates
|
* template<typename T1, typename T2> // define function f with type templates
|
||||||
* const MAX_TYPE(T1, T2)& f(T1& , T2& );
|
* const CORE_MAX_TYPE(T1, T2)& f(T1& , T2& );
|
||||||
*
|
*
|
||||||
* BigInt a = 1;
|
* BigInt a = 1;
|
||||||
* BigRat b = "1/3";
|
* BigRat b = "1/3";
|
||||||
|
|
@ -119,30 +121,30 @@ class Promotion<T, T> {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class BigInt;
|
//class BigInt;
|
||||||
class BigFloat;
|
class BigFloat;
|
||||||
class BigRat;
|
//class BigRat;
|
||||||
class Expr;
|
class Expr;
|
||||||
|
|
||||||
DEFINE_MAX_TYPE(long, BigInt, BigInt)
|
CORE_DEFINE_MAX_TYPE(long, BigInt, BigInt)
|
||||||
DEFINE_MAX_TYPE(long, BigFloat, BigFloat)
|
CORE_DEFINE_MAX_TYPE(long, BigFloat, BigFloat)
|
||||||
DEFINE_MAX_TYPE(long, BigRat, BigRat)
|
CORE_DEFINE_MAX_TYPE(long, BigRat, BigRat)
|
||||||
DEFINE_MAX_TYPE(long, Expr, Expr)
|
CORE_DEFINE_MAX_TYPE(long, Expr, Expr)
|
||||||
|
|
||||||
DEFINE_MAX_TYPE(int, BigInt, BigInt)
|
CORE_DEFINE_MAX_TYPE(int, BigInt, BigInt)
|
||||||
DEFINE_MAX_TYPE(int, BigFloat, BigFloat)
|
CORE_DEFINE_MAX_TYPE(int, BigFloat, BigFloat)
|
||||||
DEFINE_MAX_TYPE(int, BigRat, BigRat)
|
CORE_DEFINE_MAX_TYPE(int, BigRat, BigRat)
|
||||||
DEFINE_MAX_TYPE(int, Expr, Expr)
|
CORE_DEFINE_MAX_TYPE(int, Expr, Expr)
|
||||||
|
|
||||||
DEFINE_MAX_TYPE(BigInt, BigFloat, BigFloat)
|
CORE_DEFINE_MAX_TYPE(BigInt, BigFloat, BigFloat)
|
||||||
DEFINE_MAX_TYPE(BigInt, BigRat, BigRat)
|
CORE_DEFINE_MAX_TYPE(BigInt, BigRat, BigRat)
|
||||||
DEFINE_MAX_TYPE(BigInt, Expr, Expr)
|
CORE_DEFINE_MAX_TYPE(BigInt, Expr, Expr)
|
||||||
|
|
||||||
DEFINE_MAX_TYPE(BigFloat, BigRat, BigRat)
|
CORE_DEFINE_MAX_TYPE(BigFloat, BigRat, BigRat)
|
||||||
DEFINE_MAX_TYPE(BigFloat, Expr, Expr)
|
CORE_DEFINE_MAX_TYPE(BigFloat, Expr, Expr)
|
||||||
|
|
||||||
DEFINE_MAX_TYPE(BigRat, Expr, Expr)
|
CORE_DEFINE_MAX_TYPE(BigRat, Expr, Expr)
|
||||||
|
|
||||||
} //namespace CORE
|
} //namespace CORE
|
||||||
|
|
||||||
#endif //__PROMOTE_H__
|
#endif //_CORE_PROMOTE_H__
|
||||||
|
|
|
||||||
|
|
@ -277,12 +277,12 @@ const long halfLongMin = LONG_MIN /2;
|
||||||
struct _real_add {
|
struct _real_add {
|
||||||
template <class T>
|
template <class T>
|
||||||
static Real eval(const T& a, const T& b) {
|
static Real eval(const T& a, const T& b) {
|
||||||
return a+b;
|
return T(a+b);
|
||||||
}
|
}
|
||||||
// specialized for two long values
|
// specialized for two long values
|
||||||
static Real eval(long a, long b) {
|
static Real eval(long a, long b) {
|
||||||
if ((a > halfLongMax && b > halfLongMax) || (a < halfLongMin && b < halfLongMin))
|
if ((a > halfLongMax && b > halfLongMax) || (a < halfLongMin && b < halfLongMin))
|
||||||
return BigInt(a)+BigInt(b);
|
return BigInt(BigInt(a)+ BigInt(b));
|
||||||
else
|
else
|
||||||
return a+b;
|
return a+b;
|
||||||
}
|
}
|
||||||
|
|
@ -291,12 +291,12 @@ struct _real_add {
|
||||||
struct _real_sub {
|
struct _real_sub {
|
||||||
template <class T>
|
template <class T>
|
||||||
static Real eval(const T& a, const T& b) {
|
static Real eval(const T& a, const T& b) {
|
||||||
return a-b;
|
return T(a-b);
|
||||||
}
|
}
|
||||||
// specialized for two long values
|
// specialized for two long values
|
||||||
static Real eval(long a, long b) {
|
static Real eval(long a, long b) {
|
||||||
if ((a > halfLongMax && b < halfLongMin) || (a < halfLongMin && b > halfLongMax))
|
if ((a > halfLongMax && b < halfLongMin) || (a < halfLongMin && b > halfLongMax))
|
||||||
return BigInt(a)-BigInt(b);
|
return BigInt(BigInt(a)-BigInt(b));
|
||||||
else
|
else
|
||||||
return a-b;
|
return a-b;
|
||||||
}
|
}
|
||||||
|
|
@ -305,12 +305,12 @@ struct _real_sub {
|
||||||
struct _real_mul {
|
struct _real_mul {
|
||||||
template <class T>
|
template <class T>
|
||||||
static Real eval(const T& a, const T& b) {
|
static Real eval(const T& a, const T& b) {
|
||||||
return a*b;
|
return T(a*b);
|
||||||
}
|
}
|
||||||
// specialized for two long values
|
// specialized for two long values
|
||||||
static Real eval(long a, long b) {
|
static Real eval(long a, long b) {
|
||||||
if (flrLg(a) + flrLg(b) >= static_cast<int>(LONG_BIT-2))
|
if (flrLg(a) + flrLg(b) >= static_cast<int>(LONG_BIT-2))
|
||||||
return BigInt(a)*BigInt(b);
|
return BigInt(BigInt(a)*BigInt(b));
|
||||||
else
|
else
|
||||||
return a*b;
|
return a*b;
|
||||||
}
|
}
|
||||||
|
|
@ -357,7 +357,7 @@ struct real_div {
|
||||||
bf_a.approx(a.BigRatValue(), bf_b.MSB() - bf_b.flrLgErr() + 1, CORE_posInfty);
|
bf_a.approx(a.BigRatValue(), bf_b.MSB() - bf_b.flrLgErr() + 1, CORE_posInfty);
|
||||||
return bf_a.div(bf_b, r);
|
return bf_a.div(bf_b, r);
|
||||||
} else // both are BigRat
|
} else // both are BigRat
|
||||||
return a.BigRatValue()/b.BigRatValue();
|
return BigRat(a.BigRatValue() / b.BigRatValue());
|
||||||
} else if (a.ID() == REAL_BIGFLOAT || b.ID() == REAL_BIGFLOAT
|
} else if (a.ID() == REAL_BIGFLOAT || b.ID() == REAL_BIGFLOAT
|
||||||
|| a.ID() == REAL_DOUBLE || b.ID() == REAL_DOUBLE) {
|
|| a.ID() == REAL_DOUBLE || b.ID() == REAL_DOUBLE) {
|
||||||
return a.BigFloatValue().div(b.BigFloatValue(), r);
|
return a.BigFloatValue().div(b.BigFloatValue(), r);
|
||||||
|
|
@ -478,11 +478,11 @@ inline Real sqrt(const Real& x) {
|
||||||
// unary minus operator
|
// unary minus operator
|
||||||
template <class T>
|
template <class T>
|
||||||
inline Real Realbase_for<T>::operator-() const {
|
inline Real Realbase_for<T>::operator-() const {
|
||||||
return -ker;
|
return T(- T(ker));
|
||||||
}
|
}
|
||||||
template <>
|
template <>
|
||||||
inline Real RealLong::operator-() const {
|
inline Real RealLong::operator-() const {
|
||||||
return ker < -LONG_MAX ? -BigInt(ker) : -ker;
|
return ker < -LONG_MAX ? BigInt(- BigInt(ker)) : -ker;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void init_CORE() {
|
inline void init_CORE() {
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,10 @@ public:
|
||||||
int ID() const;
|
int ID() const;
|
||||||
|
|
||||||
long longValue() const {
|
long longValue() const {
|
||||||
return ker.longValue();
|
return CORE::longValue(ker);
|
||||||
}
|
}
|
||||||
double doubleValue() const {
|
double doubleValue() const {
|
||||||
return ker.doubleValue();
|
return CORE::doubleValue(ker);
|
||||||
}
|
}
|
||||||
BigInt BigIntValue() const {
|
BigInt BigIntValue() const {
|
||||||
return BigInt(ker);
|
return BigInt(ker);
|
||||||
|
|
@ -231,7 +231,7 @@ inline BigInt RealBigInt::BigIntValue() const {
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
inline BigInt RealBigRat::BigIntValue() const {
|
inline BigInt RealBigRat::BigIntValue() const {
|
||||||
return ker.BigIntValue();
|
return CORE::BigIntValue(ker);
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
inline BigInt RealBigFloat::BigIntValue() const {
|
inline BigInt RealBigFloat::BigIntValue() const {
|
||||||
|
|
@ -500,11 +500,11 @@ inline unsigned long RealBigRat::height() const {
|
||||||
// toString()
|
// toString()
|
||||||
template<>
|
template<>
|
||||||
inline std::string RealBigInt::toString(long, bool) const {
|
inline std::string RealBigInt::toString(long, bool) const {
|
||||||
return ker.get_str();
|
return ker.convert_to<std::string>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
inline std::string RealBigRat::toString(long, bool) const {
|
inline std::string RealBigRat::toString(long, bool) const {
|
||||||
return ker.get_str();
|
return ker.convert_to<std::string>();
|
||||||
}
|
}
|
||||||
template<>
|
template<>
|
||||||
inline std::string RealBigFloat::toString(long prec, bool sci) const {
|
inline std::string RealBigFloat::toString(long prec, bool sci) const {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@
|
||||||
#include <CGAL/CORE/Impl.h>
|
#include <CGAL/CORE/Impl.h>
|
||||||
#include <CGAL/CORE/CoreAux.h>
|
#include <CGAL/CORE/CoreAux.h>
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace CORE {
|
namespace CORE {
|
||||||
|
|
||||||
#ifndef LONG_MAX
|
#ifndef LONG_MAX
|
||||||
|
|
@ -77,6 +80,9 @@ public:
|
||||||
extLong(long);
|
extLong(long);
|
||||||
/// constructor for \c unsigned long
|
/// constructor for \c unsigned long
|
||||||
extLong(unsigned long);
|
extLong(unsigned long);
|
||||||
|
/// constructor for \c std::size_t
|
||||||
|
template<typename T, typename = std::enable_if_t<std::is_same_v<T,std::size_t> && !std::is_same_v<unsigned long, std::size_t>>>
|
||||||
|
extLong(T s);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \name Arithmetic and assignment operators
|
/// \name Arithmetic and assignment operators
|
||||||
|
|
@ -149,8 +155,7 @@ const extLong EXTLONG_EIGHT(8);
|
||||||
// private comparison function
|
// private comparison function
|
||||||
inline int extLong::cmp(const extLong& x) const {
|
inline int extLong::cmp(const extLong& x) const {
|
||||||
if (isNaN() || x.isNaN()) {
|
if (isNaN() || x.isNaN()) {
|
||||||
core_error("Two extLong NaN's cannot be compared!",
|
CGAL_CORE_warning_msg(false, "Two extLong NaN's cannot be compared!");
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
}
|
}
|
||||||
return (val == x.val) ? 0 : ((val > x.val) ? 1 : -1);
|
return (val == x.val) ? 0 : ((val > x.val) ? 1 : -1);
|
||||||
}
|
}
|
||||||
|
|
@ -189,6 +194,17 @@ inline extLong::extLong(unsigned long u) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename>
|
||||||
|
inline extLong::extLong(T u) {
|
||||||
|
if (u >= (std::numeric_limits<std::size_t>::max)()) {
|
||||||
|
val = EXTLONG_MAX;
|
||||||
|
flag = 1;
|
||||||
|
} else {
|
||||||
|
val = static_cast<long>(u);
|
||||||
|
flag = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// isNaN defaults to false
|
// isNaN defaults to false
|
||||||
inline extLong::extLong(bool isNaN) : val(0), flag(0) {
|
inline extLong::extLong(bool isNaN) : val(0), flag(0) {
|
||||||
if (isNaN) {
|
if (isNaN) {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ extLong& extLong::operator+= (const extLong& y) {
|
||||||
if (flag == 2 || y.flag == 2 || (flag * y.flag < 0)) {
|
if (flag == 2 || y.flag == 2 || (flag * y.flag < 0)) {
|
||||||
#ifdef CORE_DEBUG
|
#ifdef CORE_DEBUG
|
||||||
if (flag * y.flag < 0) //want a message at the first creation of NaN
|
if (flag * y.flag < 0) //want a message at the first creation of NaN
|
||||||
core_error("extLong NaN Error in addition.", __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg(false, "extLong NaN Error in addition.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*this = CORE_NaNLong;
|
*this = CORE_NaNLong;
|
||||||
|
|
@ -96,7 +96,7 @@ extLong& extLong::operator-= (const extLong& y) {
|
||||||
if (flag == 2 || y.flag == 2 || (flag * y.flag > 0)) {
|
if (flag == 2 || y.flag == 2 || (flag * y.flag > 0)) {
|
||||||
#ifdef CORE_DEBUG
|
#ifdef CORE_DEBUG
|
||||||
if (flag * y.flag > 0) //want a message at the first creation of NaN
|
if (flag * y.flag > 0) //want a message at the first creation of NaN
|
||||||
core_error("extLong NaN Error in subtraction.", __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg(false, "extLong NaN Error in subtraction.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*this = CORE_NaNLong;
|
*this = CORE_NaNLong;
|
||||||
|
|
@ -131,7 +131,7 @@ extLong& extLong::operator*= (const extLong& y) {
|
||||||
*this = CORE_negInfty;
|
*this = CORE_negInfty;
|
||||||
} else {
|
} else {
|
||||||
#ifdef CORE_DEBUG
|
#ifdef CORE_DEBUG
|
||||||
core_error("extLong NaN Error in multiplication.",__FILE__,__LINE__,false);
|
CGAL_CORE_warning_msg(false, "extLong NaN Error in multiplication.");
|
||||||
#endif
|
#endif
|
||||||
*this = CORE_NaNLong;
|
*this = CORE_NaNLong;
|
||||||
}
|
}
|
||||||
|
|
@ -144,9 +144,9 @@ extLong& extLong::operator/= (const extLong& y) {
|
||||||
if (flag==2 || y.flag==2 || ((flag != 0) && (y.flag != 0)) || (y.val == 0)) {
|
if (flag==2 || y.flag==2 || ((flag != 0) && (y.flag != 0)) || (y.val == 0)) {
|
||||||
#ifdef CORE_DEBUG
|
#ifdef CORE_DEBUG
|
||||||
if (y.val == 0)
|
if (y.val == 0)
|
||||||
core_error("extLong NaN Error, Divide by Zero.", __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg(false, "extLong NaN Error, Divide by Zero.");
|
||||||
else if ((flag !=0) && (y.flag !=0))
|
else if ((flag !=0) && (y.flag !=0))
|
||||||
core_error("extLong NaN Error, +/-Inf/Inf.", __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg(false, "extLong NaN Error, +/-Inf/Inf.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*this = CORE_NaNLong;
|
*this = CORE_NaNLong;
|
||||||
|
|
@ -180,8 +180,7 @@ extLong extLong::operator- () const {
|
||||||
// you cannot interpret the returned value!
|
// you cannot interpret the returned value!
|
||||||
CGAL_INLINE_FUNCTION
|
CGAL_INLINE_FUNCTION
|
||||||
int extLong::sign() const {
|
int extLong::sign() const {
|
||||||
if (flag == 2)
|
CGAL_CORE_warning_msg(flag != 2, "NaN Sign can not be determined!");
|
||||||
core_error("NaN Sign can not be determined!", __FILE__, __LINE__, false);
|
|
||||||
return ((val == 0) ? 0 : ((val > 0) ? 1 : -1));
|
return ((val == 0) ? 0 : ((val > 0) ? 1 : -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1336,7 +1336,7 @@ cout <<"Number of roots at " << xCurr << " are " << numRoots<<endl;
|
||||||
if (!xCurr.isExact()){
|
if (!xCurr.isExact()){
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << "xCurr has error! xCurr=" << xCurr;
|
oss << "xCurr has error! xCurr=" << xCurr;
|
||||||
core_error(oss.str(), __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg(false, oss.str());
|
||||||
}
|
}
|
||||||
}//main while loop
|
}//main while loop
|
||||||
|
|
||||||
|
|
@ -1426,4 +1426,3 @@ void showIntervals(char* s, BFVecInterval &vI) {
|
||||||
/*************************************************************************** */
|
/*************************************************************************** */
|
||||||
// END
|
// END
|
||||||
/*************************************************************************** */
|
/*************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@
|
||||||
#define CORE_POLY_H
|
#define CORE_POLY_H
|
||||||
|
|
||||||
#include <CGAL/CORE/BigFloat.h>
|
#include <CGAL/CORE/BigFloat.h>
|
||||||
|
#include <CGAL/CORE/BigRat.h>
|
||||||
#include <CGAL/CORE/Promote.h>
|
#include <CGAL/CORE/Promote.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <CGAL/assertions.h>
|
#include <CGAL/assertions.h>
|
||||||
|
|
@ -196,12 +197,10 @@ public:
|
||||||
/// In particular, if the value is 0, we return 0.
|
/// In particular, if the value is 0, we return 0.
|
||||||
/// @param oldMSB is any estimate of the negative log of the evaluation
|
/// @param oldMSB is any estimate of the negative log of the evaluation
|
||||||
BigFloat evalExactSign(const BigFloat& val, const extLong& oldMSB=54) const;
|
BigFloat evalExactSign(const BigFloat& val, const extLong& oldMSB=54) const;
|
||||||
|
|
||||||
/// Polynomial evaluation that return the same type as its argument
|
/// Polynomial evaluation that return the same type as its argument
|
||||||
/// Caution: The type T must be greater or equal to the type NT
|
|
||||||
/// NOTE: Eventually, we will remove this restriction by
|
|
||||||
/// introduce MaxType(NT,T) for the return type.
|
|
||||||
template <class T>
|
template <class T>
|
||||||
MAX_TYPE(NT, T) eval(const T&) const;
|
CORE_MAX_TYPE(NT, T) eval(const T&) const;
|
||||||
|
|
||||||
// Bounds
|
// Bounds
|
||||||
BigFloat CauchyUpperBound() const; // Cauchy Root Upper Bound
|
BigFloat CauchyUpperBound() const; // Cauchy Root Upper Bound
|
||||||
|
|
|
||||||
|
|
@ -673,7 +673,7 @@ Polynomial<NT> Polynomial<NT>::pseudoRemainder (
|
||||||
int bTrueDegree = tmpB.degree;
|
int bTrueDegree = tmpB.degree;
|
||||||
C = NT(1); // Initialized to C=1.
|
C = NT(1); // Initialized to C=1.
|
||||||
if (bTrueDegree == -1) {
|
if (bTrueDegree == -1) {
|
||||||
core_error("ERROR in Polynomial<NT>::pseudoRemainder :\n -- divide by zero polynomial", __FILE__, __LINE__, false);
|
CGAL_CORE_warning_msg(false, "ERROR in Polynomial<NT>::pseudoRemainder :\n -- divide by zero polynomial");
|
||||||
return Polynomial(0); // Unit Polynomial (arbitrary!)
|
return Polynomial(0); // Unit Polynomial (arbitrary!)
|
||||||
}
|
}
|
||||||
if (bTrueDegree > degree) {
|
if (bTrueDegree > degree) {
|
||||||
|
|
@ -771,8 +771,8 @@ BigFloat Polynomial<NT>::eval(const BigFloat& f) const { // evaluation
|
||||||
|
|
||||||
template <class NT>
|
template <class NT>
|
||||||
template <class T>
|
template <class T>
|
||||||
MAX_TYPE(NT, T) Polynomial<NT>::eval(const T& f) const { // evaluation
|
CORE_MAX_TYPE(NT, T) Polynomial<NT>::eval(const T& f) const { // evaluation
|
||||||
typedef MAX_TYPE(NT, T) ResultT;
|
typedef CORE_MAX_TYPE(NT, T) ResultT;
|
||||||
if (degree == -1)
|
if (degree == -1)
|
||||||
return ResultT(0);
|
return ResultT(0);
|
||||||
if (degree == 0)
|
if (degree == 0)
|
||||||
|
|
@ -892,10 +892,10 @@ BigFloat Polynomial<NT>::CauchyUpperBound() const {
|
||||||
NT mx = 0;
|
NT mx = 0;
|
||||||
int deg = getTrueDegree();
|
int deg = getTrueDegree();
|
||||||
for (int i = 0; i < deg; ++i) {
|
for (int i = 0; i < deg; ++i) {
|
||||||
mx = core_max(mx, abs(coeff[i]));
|
mx = core_max(mx, NT(abs(coeff[i])));
|
||||||
}
|
}
|
||||||
Expr e = mx;
|
Expr e = mx;
|
||||||
e /= Expr(abs(coeff[deg]));
|
e /= Expr(NT(abs(coeff[deg])));
|
||||||
e.approx(CORE_INFTY, 2);
|
e.approx(CORE_INFTY, 2);
|
||||||
// get an absolute approximate value with error < 1/4
|
// get an absolute approximate value with error < 1/4
|
||||||
return (e.BigFloatValue().makeExact() + 2);
|
return (e.BigFloatValue().makeExact() + 2);
|
||||||
|
|
@ -922,7 +922,7 @@ BigInt Polynomial<NT>::CauchyBound() const {
|
||||||
/* compute B^{deg} */
|
/* compute B^{deg} */
|
||||||
if (rhs <= lhs) {
|
if (rhs <= lhs) {
|
||||||
B <<= 1;
|
B <<= 1;
|
||||||
rhs *= (BigInt(1)<<deg);
|
rhs *= BigFloat(BigInt(BigInt(1)<<deg));
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -959,7 +959,7 @@ BigInt Polynomial<NT>::UpperBound() const {
|
||||||
/* compute B^{deg} */
|
/* compute B^{deg} */
|
||||||
if (rhs <= (std::max)(lhsPos,lhsNeg)) {
|
if (rhs <= (std::max)(lhsPos,lhsNeg)) {
|
||||||
B <<= 1;
|
B <<= 1;
|
||||||
rhs *= (BigInt(1)<<deg);
|
rhs *= BigFloat(BigInt(BigInt(1)<<deg));
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -975,9 +975,9 @@ BigFloat Polynomial<NT>::CauchyLowerBound() const {
|
||||||
NT mx = 0;
|
NT mx = 0;
|
||||||
int deg = getTrueDegree();
|
int deg = getTrueDegree();
|
||||||
for (int i = 1; i <= deg; ++i) {
|
for (int i = 1; i <= deg; ++i) {
|
||||||
mx = core_max(mx, abs(coeff[i]));
|
mx = core_max(mx, NT(abs(coeff[i])));
|
||||||
}
|
}
|
||||||
Expr e = Expr(abs(coeff[0]))/ Expr(abs(coeff[0]) + mx);
|
Expr e = Expr(NT(abs(coeff[0])))/ Expr(NT(NT(abs(coeff[0])) + mx));
|
||||||
e.approx(2, CORE_INFTY);
|
e.approx(2, CORE_INFTY);
|
||||||
// get an relative approximate value with error < 1/4
|
// get an relative approximate value with error < 1/4
|
||||||
return (e.BigFloatValue().makeExact().div2());
|
return (e.BigFloatValue().makeExact().div2());
|
||||||
|
|
@ -1018,8 +1018,8 @@ BigFloat Polynomial<NT>::height() const {
|
||||||
int deg = getTrueDegree();
|
int deg = getTrueDegree();
|
||||||
NT ht = 0;
|
NT ht = 0;
|
||||||
for (int i = 0; i< deg; i++)
|
for (int i = 0; i< deg; i++)
|
||||||
if (ht < abs(coeff[i]))
|
if (ht < NT(abs(coeff[i])))
|
||||||
ht = abs(coeff[i]);
|
ht = NT(abs(coeff[i]));
|
||||||
return BigFloat(ht);
|
return BigFloat(ht);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -607,8 +607,7 @@ public:
|
||||||
if (ff == 0) {
|
if (ff == 0) {
|
||||||
NEWTON_DIV_BY_ZERO = true;
|
NEWTON_DIV_BY_ZERO = true;
|
||||||
del = 0;
|
del = 0;
|
||||||
core_error("Zero divisor in Newton Iteration",
|
CGAL_CORE_warning_msg(false, "Zero divisor in Newton Iteration");
|
||||||
__FILE__, __LINE__, false);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -680,8 +679,7 @@ public:
|
||||||
stepsize++; // heuristic
|
stepsize++; // heuristic
|
||||||
} while ((del != 0) && ((del.uMSB() >= -prec) && (count >0))) ;
|
} while ((del != 0) && ((del.uMSB() >= -prec) && (count >0))) ;
|
||||||
|
|
||||||
if (count == 0) core_error("newtonIterE: reached count=0",
|
CGAL_assertion_msg(count != 0, "newtonIterE: reached count=0");
|
||||||
__FILE__, __LINE__, true);
|
|
||||||
del = BigFloat(core_abs(del.m()), err, del.exp() );
|
del = BigFloat(core_abs(del.m()), err, del.exp() );
|
||||||
del.makeCeilExact();
|
del.makeCeilExact();
|
||||||
return val;
|
return val;
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
LGPL (v3)
|
|
||||||
LGPL (v3 or later)
|
LGPL (v3 or later)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Algebraic_kernel_for_circles
|
Algebraic_kernel_for_circles
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circular_kernel_2
|
Circular_kernel_2
|
||||||
Distance_2
|
Distance_2
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Algebraic_kernel_for_spheres
|
Algebraic_kernel_for_spheres
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circular_kernel_3
|
Circular_kernel_3
|
||||||
Distance_2
|
Distance_2
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
BGL
|
BGL
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Combinatorial_map
|
Combinatorial_map
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ Algebraic_foundations
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
BGL
|
BGL
|
||||||
Box_intersection_d
|
Box_intersection_d
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Convex_decomposition_3
|
Convex_decomposition_3
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Algebraic_foundations
|
Algebraic_foundations
|
||||||
Arithmetic_kernel
|
Arithmetic_kernel
|
||||||
BGL
|
BGL
|
||||||
|
CGAL_Core
|
||||||
Cartesian_kernel
|
Cartesian_kernel
|
||||||
Circulator
|
Circulator
|
||||||
Convex_hull_2
|
Convex_hull_2
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
OFF
|
||||||
|
5 4 0
|
||||||
|
|
||||||
|
-1 -1 1
|
||||||
|
-1 1 1
|
||||||
|
1 -1 -1
|
||||||
|
-1 1 -1
|
||||||
|
-1 -1 -1
|
||||||
|
3 0 4 2
|
||||||
|
3 2 4 3
|
||||||
|
3 4 0 1
|
||||||
|
3 1 3 4
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue