// Copyright (c) 1997-2002 Max-Planck-Institute Saarbruecken (Germany). // All rights reserved. // // This file is part of CGAL (www.cgal.org). // // $URL: https://github.com/CGAL/cgal/blob/v5.1/Nef_S2/include/CGAL/Nef_S2/Sphere_triangle.h $ // $Id: Sphere_triangle.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Seel #ifndef CGAL_SPHERE_TRIANGLE_H #define CGAL_SPHERE_TRIANGLE_H #include #include #include #include namespace CGAL { template class Sphere_triangle_rep { typedef Sphere_point Point; typedef Sphere_circle Circle; typedef Sphere_triangle_rep Rep; std::array points_; std::array circles_; friend class Sphere_triangle; Sphere_triangle_rep(const Point& p1, const Point& p2, const Point& p3, const Circle& c1, const Circle& c2, const Circle& c3) : points_(CGAL::make_array(p1,p2,p3)), circles_(CGAL::make_array(c1,c2,c3)) {} public: Sphere_triangle_rep() {} }; /*{\Manpage{Sphere_triangle}{R}{Triangles on the unit sphere}{t}}*/ template class Sphere_triangle : public Handle_for< Sphere_triangle_rep > { /*{\Mdefinition An object |\Mvar| of type |\Mname| is a triangle on the surface of the unit sphere.}*/ public: /*{\Mtypes 5}*/ typedef R_ R; /*{\Mtypemember representation class.}*/ typedef typename R::RT RT; /*{\Mtypemember ring type.}*/ typedef Sphere_triangle_rep Rep; typedef Handle_for Base; /*{\Mcreation 5}*/ Sphere_triangle() : Base() {} /*{\Mcreate creates some triangle.}*/ Sphere_triangle( const Sphere_point& p0, const Sphere_point& p1, const Sphere_point& p2, const Sphere_circle& c0, const Sphere_circle& c1, const Sphere_circle& c2) : Base(Rep(p0,p1,p2,c0,c1,c2)) /*{\Mcreate creates a triangle spanned by the three points |p0|, |p1|, |p2|, where the triangle is left of the three circles |c0|, |c1|, |c2|. \precond $c_i$ contains $p_i$ and $p_{i+1}$ mod 3.}*/ { CGAL_assertion( c0.has_on(p0) && c0.has_on(p1) ); CGAL_assertion( c1.has_on(p1) && c1.has_on(p2) ); CGAL_assertion( c2.has_on(p2) && c0.has_on(p0) ); } Sphere_triangle(const Sphere_triangle& t) : Base(t) {} /*{\Moperations 4 2}*/ const Sphere_point& point(unsigned i) const /*{\Mop returns the ith point of |\Mvar|.}*/ { return this->ptr()->points_[i%3]; } const Sphere_circle& circle(unsigned i) const /*{\Mop returns the ith circle of |\Mvar|.}*/ { return this->ptr()->circles_[i%3]; } Sphere_triangle opposite() const /*{\Mop returns the opposite of |\Mvar|.}*/ { return Sphere_triangle(point(0), point(1), point(2), circle(0).opposite(), circle(1).opposite(), circle(2).opposite()); } }; // Sphere_triangle template std::ostream& operator<<(std::ostream& os, const CGAL::Sphere_triangle& t) { for (int i=0; i<3; ++i) os << t.point(i); for (int i=0; i<3; ++i) os << t.circle(i); return os; } template std::istream& operator>>(std::istream& is, CGAL::Sphere_triangle& t) { CGAL::Sphere_point p1,p2,p3; CGAL::Sphere_circle c1,c2,c3; if ( !(is >> p1 >> p2 >> p3 >> c1 >> c2 >> c3) ) return is; t = CGAL::Sphere_triangle(p1,p2,p3,c1,c2,c3); return is; } } //namespace CGAL #endif //CGAL_SPHERE_TRIANGLE_H