1 // Copyright (c) 1997-2002  Max-Planck-Institute Saarbruecken (Germany).
2 // All rights reserved.
3 //
4 // This file is part of CGAL (www.cgal.org).
5 //
6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Nef_3/include/CGAL/Nef_3/SHalfloop.h $
7 // $Id: SHalfloop.h 4e519a3 2021-05-05T13:15:37+02:00 Sébastien Loriot
8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 //
11 // Author(s)     : Michael Seel        <seel@mpi-sb.mpg.de>
12 //                 Miguel Granados     <granados@mpi-sb.mpg.de>
13 //                 Susan Hert          <hert@mpi-sb.mpg.de>
14 //                 Lutz Kettner        <kettner@mpi-sb.mpg.de>
15 //                 Peter Hachenberger  <hachenberger@mpi-sb.mpg.de>
16 #ifndef CGAL_NEF_SHALFLOOP_H
17 #define CGAL_NEF_SHALFLOOP_H
18 
19 #include <CGAL/license/Nef_3.h>
20 
21 
22 #include <string>
23 #include <sstream>
24 #include <CGAL/IO/Verbose_ostream.h>
25 #include <CGAL/Nef_3/SNC_iteration.h>
26 
27 #undef CGAL_NEF_DEBUG
28 #define CGAL_NEF_DEBUG 83
29 #include <CGAL/Nef_2/debug.h>
30 
31 namespace CGAL {
32 
33 template <typename Refs>
34 class SHalfloop_base {
35 
36   typedef typename Refs::Mark  Mark;
37   typedef typename Refs::Sphere_circle  Sphere_circle;
38   typedef typename Refs::SHalfloop_handle SHalfloop_handle;
39   typedef typename Refs::SHalfloop_const_handle SHalfloop_const_handle;
40   typedef typename Refs::SFace_handle SFace_handle;
41   typedef typename Refs::SFace_const_handle SFace_const_handle;
42   typedef typename Refs::Halffacet_handle Halffacet_handle;
43   typedef typename Refs::Halffacet_const_handle Halffacet_const_handle;
44 
45   SHalfloop_handle   twin_;
46   SFace_handle       incident_sface_;
47   Halffacet_handle   facet_;
48 
49   // temporary needed:
50   Mark               mark_;
51   Sphere_circle      circle_;
52 
53  public:
54 
SHalfloop_base()55   SHalfloop_base() : twin_(), incident_sface_(), facet_(),
56     mark_(), circle_() {}
57 
~SHalfloop_base()58     ~SHalfloop_base() {
59       CGAL_NEF_TRACEN("  destroying SHalfloop_base item "<<&*this);
60     }
SHalfloop_base(const SHalfloop_base<Refs> & l)61     SHalfloop_base(const SHalfloop_base<Refs>& l)
62       { twin_ = l.twin_;
63         incident_sface_ = l.incident_sface_;
64         facet_ = l.facet_;
65         mark_ = l.mark_;
66         circle_ = l.circle_;
67       }
68 
69     SHalfloop_base<Refs>& operator=(const SHalfloop_base<Refs>& l)
70       { twin_ = l.twin_;
71         incident_sface_ = l.incident_sface_;
72         facet_ = l.facet_;
73         mark_ = l.mark_;
74         circle_ = l.circle_;
75         return *this;
76       }
77 
78     SHalfloop_base<Refs>& operator=(SHalfloop_base<Refs>&& l) noexcept
79       { twin_ = std::move(l.twin_);
80         incident_sface_ = std::move(l.incident_sface_);
81         facet_ = std::move(l.facet_);
82         mark_ = std::move(l.mark_);
83         circle_ = std::move(l.circle_);
84         return *this;
85       }
86 
mark()87     Mark& mark() { return mark_;}
mark()88     const Mark& mark() const { return mark_; }
89 
twin()90     SHalfloop_handle& twin() { return twin_; }
twin()91     SHalfloop_const_handle twin() const { return twin_; }
92 
circle()93     Sphere_circle& circle() { return circle_; }
circle()94     const Sphere_circle& circle() const { return circle_; }
95 
incident_sface()96     SFace_handle& incident_sface() { return incident_sface_; }
incident_sface()97     SFace_const_handle incident_sface() const { return incident_sface_; }
98 
facet()99     Halffacet_handle& facet() { return facet_; }
facet()100     Halffacet_const_handle facet() const { return facet_; }
101 
102  public:
debug()103     std::string debug() const
104       { std::stringstream os;
105         CGAL::IO::set_pretty_mode(os);
106         os<<"sl [ "<<circle_<<" ] ";
107         return os.str();
108       }
109 
is_twin()110     bool is_twin() const { return (&*twin_ < this); }
111 
112     bool is_valid( bool verb = false, int level = 0) const {
113 
114       Verbose_ostream verr(verb);
115       verr << "begin CGAL::SNC_items<...>::SHalfloop_base::is_valid( verb=true, "
116         "level = " << level << "):" << std::endl;
117 
118       bool valid = (twin_  != SHalfloop_handle() && twin_  != nullptr);
119       valid = valid && (incident_sface_ != SFace_handle() &&
120                         incident_sface_ != nullptr);
121       valid = valid && (facet_ != Halffacet_handle() &&
122                         facet_ != nullptr);
123       valid = valid && (circle_.d() == 0);
124       valid = valid && (circle_.a() != 0 || circle_.b() != 0 || circle_.c() !=0);
125 
126       verr << "end of CGAL::SNC_items<...>::SHalfloop_base::is_valid(): structure is "
127            << ( valid ? "valid." : "NOT VALID.") << std::endl;
128 
129       return valid;
130     }
131 
132 }; // SHalfloop_base
133 
134 } //namespace CGAL
135 #endif //CGAL_NEF_SHALFLOOP_H
136