// Copyright (c) 2000,2001 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), // Max-Planck-Institute Saarbruecken (Germany), // and Tel-Aviv University (Israel). All rights reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // SPDX-License-Identifier: LGPL-3.0+ // // // Author(s) : Michael Seel #ifndef CGAL_POINTCDXXX_H #define CGAL_POINTCDXXX_H #include #include #include namespace CGAL { #define PointCd PointCd2 template class PointCd; template std::istream& operator>>(std::istream&, PointCd&); template std::ostream& operator<<(std::ostream&, const PointCd&); template class PointCd : public Handle_for< Tuple_d<_FT,_LA> > { typedef Tuple_d<_FT,_LA> Tuple; typedef Handle_for Base; typedef PointCd<_FT,_LA> Self; using Base::ptr; typename _LA::Vector& vector_rep() { return ptr()->v; } const typename _LA::Vector& vector_rep() const { return ptr()->v; } _FT& entry(int i) { return ptr()->v[i]; } const _FT& entry(int i) const { return ptr()->v[i]; } PointCd(const Base& b) : Base(b) {} public: /*{\Mtypes 4}*/ typedef _FT RT; typedef _FT FT; typedef _LA LA; typedef typename Tuple::const_iterator Cartesian_const_iterator; typedef typename Tuple::Homogeneous_const_iterator Homogeneous_const_iterator; friend class VectorCd; friend class HyperplaneCd; /*{\Mcreation 4}*/ PointCd(int d = 0) : Base( Tuple(d) ) {} PointCd(int d, const Origin&) : Base( Tuple(d) ) {} template PointCd(int d, InputIterator first, InputIterator last) : Base( Tuple(d,first,last) ) { if ( first == last ) return; // else first specifies common denominator: CGAL_assertion_msg(FT(*first)!=FT(0), "PointCd::constructor: denominator must be nonzero."); for (int i=0; i PointCd (int d, InputIterator first, InputIterator last, const FT& D) : Base( Tuple(d,first,last) ) { CGAL_assertion_msg(D!=FT(0),"PointCd::constructor: D must be nonzero."); for (int i=0; i& p) : Base(p) {} ~PointCd() {} int dimension() const { return ptr()->size(); } FT cartesian(int i) const { CGAL_assertion_msg((0<=i && ibegin(); } Cartesian_const_iterator cartesian_end() const { return ptr()->end(); } Homogeneous_const_iterator homogeneous_begin() const { return Homogeneous_const_iterator(ptr()->begin(),ptr()->end()); } Homogeneous_const_iterator homogeneous_end() const { return Homogeneous_const_iterator(ptr()->beyondend()); } PointCd transform(const Aff_transformationCd& t) const; inline VectorCd operator-(const Origin& o) const; VectorCd operator-(const PointCd& q) const { VectorCd res(dimension()); res.ptr()->cartesian_sub(ptr(),q.ptr()); return res; } PointCd operator+(const VectorCd& v) const; PointCd operator-(const VectorCd& v) const; PointCd& operator+=(const VectorCd& v); PointCd& operator-=(const VectorCd& v); static Comparison_result cmp( const PointCd& p1, const PointCd& p2) { Compare_componentwise cmpobj; return cmpobj(p1.vector_rep(),p2.vector_rep()); } bool operator==(const PointCd& q) const { if (this->identical(q)) return true; if (dimension()!=q.dimension()) return false; return vector_rep()==q.vector_rep(); } bool operator!=(const PointCd& q) const { return !(*this==q); } bool operator==(const Origin&) const { for (int i = 0; i < dimension(); i++) if (cartesian(i) != FT(0)) return false; return true; } friend std::istream& operator>> <> (std::istream&, PointCd&); friend std::ostream& operator<< <> (std::ostream&, const PointCd&); FT hx() const { return cartesian(0); } FT hy() const { return cartesian(1); } FT hz() const { return cartesian(2); } FT hw() const { return FT(1); } FT x() const { return cartesian(0); } FT y() const { return cartesian(1); } FT z() const { return cartesian(2); } }; // PointCd #undef PointCd } //namespace CGAL #endif // CGAL_POINTCDXXX_H //----------------------- end of file ----------------------------------