mirror of https://github.com/CGAL/cgal
Vector_2 and Vector_3 now also provide a Cartesian_const_iterator.
This commit is contained in:
parent
853437f640
commit
11bbf3e2de
|
|
@ -48,7 +48,9 @@ class VectorC2
|
|||
|
||||
public:
|
||||
|
||||
typedef R_ R;
|
||||
typedef typename Rep::const_iterator Cartesian_const_iterator;
|
||||
|
||||
typedef R_ R;
|
||||
|
||||
VectorC2() {}
|
||||
|
||||
|
|
@ -84,6 +86,16 @@ public:
|
|||
return constant<FT, 1>();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_begin() const
|
||||
{
|
||||
return get(base).begin();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_end() const
|
||||
{
|
||||
return get(base).end();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template < class R >
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ class VectorC3
|
|||
|
||||
public:
|
||||
|
||||
typedef R_ R;
|
||||
typedef typename Rep::const_iterator Cartesian_const_iterator;
|
||||
|
||||
typedef R_ R;
|
||||
|
||||
VectorC3() {}
|
||||
|
||||
|
|
@ -103,6 +105,16 @@ public:
|
|||
return constant<FT, 1>();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_begin() const
|
||||
{
|
||||
return get(base).begin();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_end() const
|
||||
{
|
||||
return get(base).end();
|
||||
}
|
||||
|
||||
const FT & cartesian(int i) const;
|
||||
const FT & operator[](int i) const;
|
||||
const FT & homogeneous(int i) const;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/array.h>
|
||||
#include <CGAL/Kernel_d/Cartesian_const_iterator_d.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -54,6 +55,8 @@ public:
|
|||
|
||||
typedef const FT Cartesian_coordinate_type;
|
||||
typedef const RT& Homogeneous_coordinate_type;
|
||||
typedef Cartesian_const_iterator_d<const RT*> Cartesian_const_iterator;
|
||||
|
||||
typedef R_ R;
|
||||
|
||||
VectorH2() {}
|
||||
|
|
@ -99,6 +102,17 @@ public:
|
|||
const RT & homogeneous(int i) const;
|
||||
FT operator[](int i) const;
|
||||
|
||||
Cartesian_const_iterator cartesian_begin() const
|
||||
{
|
||||
return make_cartesian_const_iterator_begin(get(base).begin(),
|
||||
boost::prior(get(base).end()));
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_end() const
|
||||
{
|
||||
return make_cartesian_const_iterator_end(boost::prior(get(base).end()));
|
||||
}
|
||||
|
||||
int dimension() const;
|
||||
Direction_2 direction() const;
|
||||
Vector_2 perpendicular(const Orientation& o ) const;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <CGAL/Origin.h>
|
||||
#include <CGAL/array.h>
|
||||
#include <CGAL/Kernel_d/Cartesian_const_iterator_d.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -50,6 +51,8 @@ class VectorH3
|
|||
|
||||
public:
|
||||
|
||||
typedef Cartesian_const_iterator_d<const RT*> Cartesian_const_iterator;
|
||||
|
||||
typedef R_ R;
|
||||
|
||||
VectorH3() {}
|
||||
|
|
@ -104,6 +107,17 @@ public:
|
|||
FT cartesian(int i) const;
|
||||
FT operator[](int i) const;
|
||||
|
||||
Cartesian_const_iterator cartesian_begin() const
|
||||
{
|
||||
return make_cartesian_const_iterator_begin(get(base).begin(),
|
||||
boost::prior(get(base).end()));
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_end() const
|
||||
{
|
||||
return make_cartesian_const_iterator_end(boost::prior(get(base).end()));
|
||||
}
|
||||
|
||||
int dimension() const { return 3; };
|
||||
|
||||
Direction_3 direction() const;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ A model for this must provide:
|
|||
&p, int);} {returns the past the end iterator of the \ccHtmlNoLinksFrom{Cartesian} coordinates of \ccc{p}.}
|
||||
|
||||
|
||||
\ccMemberFunction{Kernel::Cartesian_const_iterator_2 operator()(const Kernel::Vector_2
|
||||
&v);} {returns an iterator on the 0'th \ccHtmlNoLinksFrom{Cartesian} coordinate of \ccc{v}.}
|
||||
|
||||
\ccMemberFunction{Kernel::Cartesian_const_iterator_2 operator()(const Kernel::Vector_2
|
||||
&v, int);} {returns the past the end iterator of the \ccHtmlNoLinksFrom{Cartesian} coordinates of \ccc{v}.}
|
||||
|
||||
|
||||
|
||||
\ccRefines
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ A model for this must provide:
|
|||
&p, int);} {returns the past the end iterator of the \ccHtmlNoLinksFrom{Cartesian} coordinates of \ccc{p}.}
|
||||
|
||||
|
||||
\ccMemberFunction{Kernel::Cartesian_const_iterator_3 operator()(const Kernel::Vector_3
|
||||
&v);} {returns an iterator on the 0'th \ccHtmlNoLinksFrom{Cartesian} coordinate of \ccc{v}.}
|
||||
|
||||
\ccMemberFunction{Kernel::Cartesian_const_iterator_3 operator()(const Kernel::Vector_3
|
||||
&v, int);} {returns the past the end iterator of the \ccHtmlNoLinksFrom{Cartesian} coordinates of \ccc{v}.}
|
||||
|
||||
|
||||
|
||||
\ccRefines
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ from $p_1$ to $p_2$.
|
|||
will explicitly state where you can pass this constant as an argument
|
||||
instead of a vector initialized with zeros.
|
||||
|
||||
\ccTypes
|
||||
\ccThree{Cartesian_const_iterator}{Facet }{}
|
||||
\ccThreeToTwo
|
||||
|
||||
\ccNestedType{Cartesian_const_iterator}{An iterator for enumerating the
|
||||
\ccHtmlNoLinksFrom{Cartesian} coordinates of a vector.}
|
||||
|
||||
\ccCreation
|
||||
\ccCreationVariable{v}
|
||||
|
|
@ -103,6 +109,14 @@ with higher dimensional vectors. Again they come in a
|
|||
{returns \ccStyle{cartesian(i)}.
|
||||
\ccPrecond $0\leq i \leq 1$.}
|
||||
|
||||
\ccMethod{Cartesian_const_iterator cartesian_begin() const;}
|
||||
{returns an iterator to the \ccHtmlNoLinksFrom{Cartesian} coordinates
|
||||
of \ccVar, starting with the 0th coordinate.}
|
||||
|
||||
\ccMethod{Cartesian_const_iterator cartesian_end() const;}
|
||||
{returns an off the end iterator to the \ccHtmlNoLinksFrom{Cartesian}
|
||||
coordinates of \ccVar.}
|
||||
|
||||
\ccMethod{int dimension() const;}
|
||||
{returns the dimension (the constant 2).}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@ from $p_1$ to $p_2$.
|
|||
will explicitly state where you can pass this constant as an argument
|
||||
instead of a vector initialized with zeros.
|
||||
|
||||
\ccTypes
|
||||
\ccThree{Cartesian_const_iterator}{Facet }{}
|
||||
\ccThreeToTwo
|
||||
|
||||
\ccNestedType{Cartesian_const_iterator}{An iterator for enumerating the
|
||||
\ccHtmlNoLinksFrom{Cartesian} coordinates of a vector.}
|
||||
|
||||
\ccCreation
|
||||
\ccCreationVariable{v}
|
||||
|
|
@ -108,6 +114,14 @@ with higher dimensional vectors. Again they come in a
|
|||
{returns \ccStyle{cartesian(i)}.
|
||||
\ccPrecond $0\leq i \leq 2$.}
|
||||
|
||||
\ccMethod{Cartesian_const_iterator cartesian_begin() const;}
|
||||
{returns an iterator to the \ccHtmlNoLinksFrom{Cartesian} coordinates
|
||||
of \ccVar, starting with the 0th coordinate.}
|
||||
|
||||
\ccMethod{Cartesian_const_iterator cartesian_end() const;}
|
||||
{returns an off the end iterator to the \ccHtmlNoLinksFrom{Cartesian}
|
||||
coordinates of \ccVar.}
|
||||
|
||||
\ccMethod{int dimension() const;}
|
||||
{returns the dimension (the constant 3).}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
|
||||
|
|
@ -26,24 +26,29 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
// This class should go away.
|
||||
// It is now only used by the Filtered_kernel.
|
||||
// It allows to iterate over the coordinates of both a Point_2 and a Vector_2,
|
||||
// using a boost::variant, as the iterator types are the same at the kernel level.
|
||||
|
||||
template <class K>
|
||||
class Cartesian_coordinate_iterator_2
|
||||
class Cartesian_coordinate_iterator_2
|
||||
{
|
||||
|
||||
protected:
|
||||
typedef typename K::Point_2 P;
|
||||
const P* point;
|
||||
typedef typename K::Vector_2 V;
|
||||
boost::variant<const P*, const V*> var;
|
||||
int index;
|
||||
typedef Cartesian_coordinate_iterator_2<K> Self;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef typename K::FT FT;
|
||||
typedef P Point;
|
||||
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef FT value_type;
|
||||
|
|
@ -51,33 +56,43 @@ public:
|
|||
typedef const value_type& reference;
|
||||
typedef const value_type* pointer;
|
||||
|
||||
Cartesian_coordinate_iterator_2(const Point *const p = NULL,
|
||||
int _index = 0)
|
||||
: point(p), index(_index)
|
||||
{}
|
||||
Cartesian_coordinate_iterator_2()
|
||||
: var((const P*) NULL), index(0) {}
|
||||
|
||||
Cartesian_coordinate_iterator_2(const P * const p, int _index = 0)
|
||||
: var(p), index(_index) {}
|
||||
|
||||
Cartesian_coordinate_iterator_2(const V * const v, int _index = 0)
|
||||
: var(v), index(_index) {}
|
||||
|
||||
|
||||
const FT
|
||||
const FT
|
||||
operator*() const {
|
||||
return point->cartesian(index);
|
||||
if (const P* const* p = boost::get<const P*>(&var))
|
||||
return (*p)->cartesian(index);
|
||||
if (const V* const* v = boost::get<const V*>(&var))
|
||||
return (*v)->cartesian(index);
|
||||
// std::cerr << "type of var = " << var.type().name() << std::endl;
|
||||
CGAL_error();
|
||||
std::abort(); // to kill warning
|
||||
}
|
||||
|
||||
|
||||
Self& operator++() {
|
||||
index++;
|
||||
index++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self&
|
||||
Self&
|
||||
operator--() {
|
||||
index--;
|
||||
index--;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self
|
||||
operator++(int) {
|
||||
Self
|
||||
operator++(int) {
|
||||
Self tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Self
|
||||
|
|
@ -86,55 +101,55 @@ public:
|
|||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Self&
|
||||
operator+=(difference_type i) {
|
||||
|
||||
Self&
|
||||
operator+=(difference_type i) {
|
||||
index+=i;
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self&
|
||||
operator-=(difference_type i) {
|
||||
index -= i;
|
||||
return *this;
|
||||
Self&
|
||||
operator-=(difference_type i) {
|
||||
index -= i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self
|
||||
Self
|
||||
operator+(difference_type i) const {
|
||||
Self tmp=*this;
|
||||
return tmp += i;
|
||||
Self tmp=*this;
|
||||
return tmp += i;
|
||||
}
|
||||
|
||||
Self operator-(difference_type i) const {
|
||||
Self tmp=*this;
|
||||
return tmp -= i;
|
||||
Self tmp=*this;
|
||||
return tmp -= i;
|
||||
}
|
||||
|
||||
difference_type
|
||||
difference_type
|
||||
operator-(const Self& x) const {
|
||||
CGAL_kernel_assertion(point == x.point);
|
||||
return index - x.index;
|
||||
CGAL_kernel_assertion(var == x.var);
|
||||
return index - x.index;
|
||||
}
|
||||
|
||||
reference operator[](difference_type i) const {
|
||||
return *(*this + i);
|
||||
reference operator[](difference_type i) const {
|
||||
return *(*this + i);
|
||||
}
|
||||
|
||||
bool operator==(const Self& x) const {
|
||||
return (point == x.point)&& (index == x.index) ;
|
||||
}
|
||||
|
||||
bool operator!=(const Self& x) const {
|
||||
return ! (*this==x);
|
||||
return (var == x.var) && (index == x.index);
|
||||
}
|
||||
|
||||
bool operator<(const Self& x) const
|
||||
{
|
||||
return (x - *this) > 0; }
|
||||
bool operator!=(const Self& x) const {
|
||||
return ! (*this==x);
|
||||
}
|
||||
|
||||
bool operator<(const Self& x) const
|
||||
{
|
||||
return (x - *this) > 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_CARTESIAN_COORDINATE_ITERATOR_2_H
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
//
|
||||
// Author(s) : Andreas Fabri
|
||||
|
||||
|
|
@ -26,23 +26,27 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <boost/variant.hpp>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
// This class should go away.
|
||||
// It is now only used by the Filtered_kernel.
|
||||
// It allows to iterate over the coordinates of both a Point_3 and a Vector_3,
|
||||
// using a boost::variant, as the iterator types are the same at the kernel level.
|
||||
|
||||
template <class K>
|
||||
class Cartesian_coordinate_iterator_3
|
||||
class Cartesian_coordinate_iterator_3
|
||||
{
|
||||
|
||||
typedef typename K::Point_3 P;
|
||||
const P* point;
|
||||
typedef typename K::Vector_3 V;
|
||||
boost::variant<const P*, const V*> var;
|
||||
int index;
|
||||
typedef Cartesian_coordinate_iterator_3<K> Self;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
typedef typename K::FT FT;
|
||||
typedef P Point;
|
||||
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
typedef FT value_type;
|
||||
|
|
@ -50,33 +54,42 @@ public:
|
|||
typedef const value_type& reference;
|
||||
typedef const value_type* pointer;
|
||||
|
||||
Cartesian_coordinate_iterator_3(const Point *const p = NULL,
|
||||
int _index = 0)
|
||||
: point(p), index(_index)
|
||||
{}
|
||||
Cartesian_coordinate_iterator_3()
|
||||
: var((const P*) NULL), index(0) {}
|
||||
|
||||
Cartesian_coordinate_iterator_3(const P *const p, int _index = 0)
|
||||
: var(p), index(_index) {}
|
||||
|
||||
const FT
|
||||
Cartesian_coordinate_iterator_3(const V *const v, int _index = 0)
|
||||
: var(v), index(_index) {}
|
||||
|
||||
const FT
|
||||
operator*() const {
|
||||
return point->cartesian(index);
|
||||
if (const P* const* p = boost::get<const P*>(&var))
|
||||
return (*p)->cartesian(index);
|
||||
if (const V* const* v = boost::get<const V*>(&var))
|
||||
return (*v)->cartesian(index);
|
||||
// std::cerr << "type of var = " << var.type().name() << std::endl;
|
||||
CGAL_error();
|
||||
std::abort(); // to kill warning
|
||||
}
|
||||
|
||||
|
||||
Self& operator++() {
|
||||
index++;
|
||||
index++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self&
|
||||
Self&
|
||||
operator--() {
|
||||
index--;
|
||||
index--;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self
|
||||
operator++(int) {
|
||||
Self
|
||||
operator++(int) {
|
||||
Self tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Self
|
||||
|
|
@ -85,55 +98,55 @@ public:
|
|||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Self&
|
||||
operator+=(difference_type i) {
|
||||
|
||||
Self&
|
||||
operator+=(difference_type i) {
|
||||
index+=i;
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self&
|
||||
operator-=(difference_type i) {
|
||||
index -= i;
|
||||
return *this;
|
||||
Self&
|
||||
operator-=(difference_type i) {
|
||||
index -= i;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Self
|
||||
Self
|
||||
operator+(difference_type i) const {
|
||||
Self tmp=*this;
|
||||
return tmp += i;
|
||||
Self tmp=*this;
|
||||
return tmp += i;
|
||||
}
|
||||
|
||||
Self operator-(difference_type i) const {
|
||||
Self tmp=*this;
|
||||
return tmp -= i;
|
||||
Self tmp=*this;
|
||||
return tmp -= i;
|
||||
}
|
||||
|
||||
difference_type
|
||||
difference_type
|
||||
operator-(const Self& x) const {
|
||||
CGAL_kernel_assertion(point == x.point);
|
||||
return index - x.index;
|
||||
CGAL_kernel_assertion(var == x.var);
|
||||
return index - x.index;
|
||||
}
|
||||
|
||||
reference operator[](difference_type i) const {
|
||||
return *(*this + i);
|
||||
reference operator[](difference_type i) const {
|
||||
return *(*this + i);
|
||||
}
|
||||
|
||||
bool operator==(const Self& x) const {
|
||||
return (point == x.point)&& (index == x.index) ;
|
||||
}
|
||||
|
||||
bool operator!=(const Self& x) const {
|
||||
return ! (*this==x);
|
||||
return (var == x.var) && (index == x.index) ;
|
||||
}
|
||||
|
||||
bool operator<(const Self& x) const
|
||||
{
|
||||
return (x - *this) > 0; }
|
||||
bool operator!=(const Self& x) const {
|
||||
return ! (*this==x);
|
||||
}
|
||||
|
||||
bool operator<(const Self& x) const
|
||||
{
|
||||
return (x - *this) > 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_CARTESIAN_COORDINATE_ITERATOR_3_H
|
||||
|
|
|
|||
|
|
@ -1741,6 +1741,7 @@ namespace CommonKernelFunctors {
|
|||
class Construct_cartesian_const_iterator_2
|
||||
{
|
||||
typedef typename K::Point_2 Point_2;
|
||||
typedef typename K::Vector_2 Vector_2;
|
||||
typedef typename K::Cartesian_const_iterator_2
|
||||
Cartesian_const_iterator_2;
|
||||
|
||||
|
|
@ -1750,21 +1751,34 @@ namespace CommonKernelFunctors {
|
|||
|
||||
Cartesian_const_iterator_2
|
||||
operator()( const Point_2& p) const
|
||||
{
|
||||
return p.rep().cartesian_begin();
|
||||
}
|
||||
{
|
||||
return p.rep().cartesian_begin();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator_2
|
||||
operator()( const Point_2& p, int) const
|
||||
{
|
||||
return p.rep().cartesian_end();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator_2
|
||||
operator()( const Vector_2& v) const
|
||||
{
|
||||
return v.rep().cartesian_begin();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator_2
|
||||
operator()( const Vector_2& v, int) const
|
||||
{
|
||||
return v.rep().cartesian_end();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
class Construct_cartesian_const_iterator_3
|
||||
{
|
||||
typedef typename K::Point_3 Point_3;
|
||||
typedef typename K::Vector_3 Vector_3;
|
||||
typedef typename K::Cartesian_const_iterator_3
|
||||
Cartesian_const_iterator_3;
|
||||
|
||||
|
|
@ -1774,15 +1788,27 @@ namespace CommonKernelFunctors {
|
|||
|
||||
Cartesian_const_iterator_3
|
||||
operator()( const Point_3& p) const
|
||||
{
|
||||
return p.rep().cartesian_begin();
|
||||
}
|
||||
{
|
||||
return p.rep().cartesian_begin();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator_3
|
||||
operator()( const Point_3& p, int) const
|
||||
{
|
||||
return p.rep().cartesian_end();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator_3
|
||||
operator()( const Vector_3& v) const
|
||||
{
|
||||
return v.rep().cartesian_begin();
|
||||
}
|
||||
|
||||
Cartesian_const_iterator_3
|
||||
operator()( const Vector_3& v, int) const
|
||||
{
|
||||
return v.rep().cartesian_end();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K>
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class Vector_2 : public R_::Kernel_base::Vector_2
|
|||
public:
|
||||
|
||||
typedef RVector_2 Rep;
|
||||
typedef typename R_::Cartesian_const_iterator_2 Cartesian_const_iterator;
|
||||
|
||||
const Rep& rep() const
|
||||
{
|
||||
|
|
@ -123,6 +124,16 @@ public:
|
|||
return cartesian(i);
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_begin() const
|
||||
{
|
||||
return typename R::Construct_cartesian_const_iterator_2()(*this);
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_end() const
|
||||
{
|
||||
return typename R::Construct_cartesian_const_iterator_2()(*this,2);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_hx_2,Vector_2>::type
|
||||
hx() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ class Vector_3 : public R_::Kernel_base::Vector_3
|
|||
|
||||
public:
|
||||
|
||||
typedef typename R_::Kernel_base::Vector_3 Rep;
|
||||
typedef typename R_::Cartesian_const_iterator_3 Cartesian_const_iterator;
|
||||
typedef typename R_::Kernel_base::Vector_3 Rep;
|
||||
|
||||
const Rep& rep() const
|
||||
{
|
||||
|
|
@ -203,6 +204,16 @@ public:
|
|||
return cartesian(i);
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_begin() const
|
||||
{
|
||||
return typename R::Construct_cartesian_const_iterator_3()(*this);
|
||||
}
|
||||
|
||||
Cartesian_const_iterator cartesian_end() const
|
||||
{
|
||||
return typename R::Construct_cartesian_const_iterator_3()(*this,3);
|
||||
}
|
||||
|
||||
typename Qualified_result_of<typename R::Compute_squared_length_3, Vector_3>::type
|
||||
squared_length() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ _test_cls_vector_2(const R& )
|
|||
typedef typename R::FT FT;
|
||||
|
||||
typename R::Vector_2 iv;
|
||||
typedef typename R::Vector_2::Cartesian_const_iterator CCI;
|
||||
|
||||
CGAL::Vector_2<R> v1;
|
||||
CGAL::Vector_2<R> v2(iv);
|
||||
CGAL::Vector_2<R> v0(CGAL::NULL_VECTOR);
|
||||
|
|
@ -100,6 +102,63 @@ _test_cls_vector_2(const R& )
|
|||
assert( v10.direction() == v8.direction() );
|
||||
assert( v11.direction() == v8.direction() );
|
||||
|
||||
|
||||
// now we test the Coordinate iterator
|
||||
const CGAL::Vector_2<R> v(1, 2);
|
||||
|
||||
CCI it = v.cartesian_begin();
|
||||
|
||||
// Default constructor
|
||||
CCI itt;
|
||||
|
||||
// Copy constructor
|
||||
CCI itc(it);
|
||||
|
||||
assert(itc == it);
|
||||
|
||||
// Assignment
|
||||
itt = it;
|
||||
|
||||
// Equality
|
||||
assert(itt == it);
|
||||
|
||||
assert(itt - it == 0);
|
||||
|
||||
// Increment
|
||||
itt++;
|
||||
|
||||
// Inequality
|
||||
assert(itt != it);
|
||||
|
||||
assert(it < itt);
|
||||
assert(itt - it == 1);
|
||||
|
||||
// dereference
|
||||
assert(*it == FT(1));
|
||||
|
||||
it++;
|
||||
assert(*it == FT(2));
|
||||
it++;
|
||||
|
||||
CCI it2 = v.cartesian_end();
|
||||
|
||||
assert(it == it2);
|
||||
it--;
|
||||
it--;
|
||||
assert(*it == FT(1));
|
||||
it += 1;
|
||||
assert(*it == FT(2));
|
||||
it -= 1;
|
||||
assert(*it == FT(1));
|
||||
|
||||
it2 = it + 1;
|
||||
it2--;
|
||||
assert(it == it2);
|
||||
it++;
|
||||
it2 = it - 1;
|
||||
it2++;
|
||||
assert(it == it2);
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ _test_cls_vector_3(const R& )
|
|||
typedef typename R::FT FT;
|
||||
|
||||
typename R::Vector_3 iv;
|
||||
typedef typename R::Vector_3::Cartesian_const_iterator CCI;
|
||||
|
||||
CGAL::Vector_3<R> v1;
|
||||
CGAL::Vector_3<R> v2(iv);
|
||||
|
|
@ -91,6 +92,69 @@ _test_cls_vector_3(const R& )
|
|||
|
||||
assert( v0.dimension() == 3 );
|
||||
|
||||
|
||||
// now we test the Coordinate iterator
|
||||
const CGAL::Vector_3<R> v(1, 2, 3);
|
||||
|
||||
CCI it = v.cartesian_begin();
|
||||
|
||||
// Default constructor
|
||||
CCI itt;
|
||||
|
||||
// Copy constructor
|
||||
CCI itc(it);
|
||||
|
||||
assert(itc == it);
|
||||
|
||||
// Assignment
|
||||
itt = it;
|
||||
|
||||
// Equality
|
||||
assert(itt == it);
|
||||
|
||||
assert(itt - it == 0);
|
||||
|
||||
// Increment
|
||||
itt++;
|
||||
|
||||
// Inequality
|
||||
assert(itt != it);
|
||||
|
||||
assert(it < itt);
|
||||
assert(itt - it == 1);
|
||||
|
||||
itt++;
|
||||
assert(itt - it == 2);
|
||||
|
||||
// dereference
|
||||
assert(*it == FT(1));
|
||||
|
||||
it++;
|
||||
assert(*it == FT(2));
|
||||
it++;
|
||||
assert(*it == FT(3));
|
||||
|
||||
it++;
|
||||
CCI it2 = v.cartesian_end();
|
||||
|
||||
assert(it == it2);
|
||||
it--;
|
||||
it--;
|
||||
it--;
|
||||
assert(*it == FT(1));
|
||||
it += 1;
|
||||
assert(*it == FT(2));
|
||||
it -= 1;
|
||||
assert(*it == FT(1));
|
||||
|
||||
it2 = it + 1;
|
||||
it2--;
|
||||
assert(it == it2);
|
||||
it++;
|
||||
it2 = it - 1;
|
||||
it2++;
|
||||
assert(it == it2);
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ test_new_2(const R& rep)
|
|||
|
||||
cccit = construct_cartesian_const_iterator_2(p1);
|
||||
cccit = construct_cartesian_const_iterator_2(p1,0);
|
||||
cccit = construct_cartesian_const_iterator_2(v6);
|
||||
cccit = construct_cartesian_const_iterator_2(v6,0);
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
typename R::Construct_supporting_line_2 construct_supporting_line
|
||||
|
|
|
|||
|
|
@ -299,6 +299,8 @@ test_new_3(const R& rep)
|
|||
|
||||
cccit = construct_cartesian_const_iterator_3(p1);
|
||||
cccit = construct_cartesian_const_iterator_3(p1,0);
|
||||
cccit = construct_cartesian_const_iterator_3(v5);
|
||||
cccit = construct_cartesian_const_iterator_3(v5,0);
|
||||
|
||||
#ifndef CGAL_NO_DEPRECATED_CODE
|
||||
typename R::Construct_supporting_line_3 construct_supporting_line
|
||||
|
|
|
|||
Loading…
Reference in New Issue