1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
|
// Copyright (c) 2003,2004,2005 INRIA Sophia-Antipolis (France).
// 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
// 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$
//
//
// Author(s) : Menelaos Karavelas <mkaravel@iacm.forth.gr>
#ifndef CGAL_SEGMENT_DELAUNAY_GRAPH_SIMPLE_STORAGE_SITE_H
#define CGAL_SEGMENT_DELAUNAY_GRAPH_SIMPLE_STORAGE_SITE_H
#include <iostream>
#include <CGAL/assertions.h>
#include <CGAL/Segment_Delaunay_graph_2/basic.h>
namespace CGAL {
/** A Site is either a point or a segment or a point defined as the
intersection of two non-parallel segments (if defined)
*/
namespace SegmentDelaunayGraph_2 {
template<class STraits> class Construct_storage_site_2;
} //namespace SegmentDelaunayGraph_2
template <class STraits>
class Segment_Delaunay_graph_simple_storage_site_2
{
friend class
CGAL_SEGMENT_DELAUNAY_GRAPH_2_NS::Construct_storage_site_2<STraits>;
public:
typedef STraits Storage_traits;
typedef typename Storage_traits::Geom_traits Geom_traits;
typedef typename Geom_traits::Site_2 Site_2;
typedef typename Storage_traits::Point_handle Point_handle;
protected:
typedef Point_handle Handle;
typedef
Segment_Delaunay_graph_simple_storage_site_2<Storage_traits>
Self;
protected:
// constructs point site using input point
static Self construct_storage_site_2(const Handle& hp) {
Self t;
t.initialize_site(hp);
return t;
}
// constructs segment site using input segment
static Self construct_storage_site_2(const Handle& hp1,
const Handle& hp2) {
Self t;
t.initialize_site(hp1, hp2);
return t;
}
public:
// DEFAULT CONSTRUCTOR
//--------------------
Segment_Delaunay_graph_simple_storage_site_2() : type_(0) {}
// COPY CONSTRUCTOR
//-----------------
Segment_Delaunay_graph_simple_storage_site_2(const Self& other) {
copy_from(other);
}
// ASSIGNMENT OPERATOR
//--------------------
Self& operator=(const Self& other) {
copy_from(other);
return *this;
}
public:
// PREDICATES
//-----------
bool is_defined() const { return type_ != 0; }
bool is_point() const { return type_ == 1; }
bool is_segment() const { return type_ == 2; }
bool is_input() const { return true; }
bool is_input(unsigned int) const { return true; }
// ACCESS METHODS
//---------------
const Handle& point() const {
CGAL_precondition( is_point() && is_input() );
return h_[0];
}
const Handle& source_of_supporting_site() const {
CGAL_precondition( is_segment() );
return h_[0];
}
const Handle& target_of_supporting_site() const {
CGAL_precondition( is_segment() );
return h_[1];
}
// the following methods should never be called; they have been
// defined in order for this class to be a model of the
// SegmentDelaunayGraphStorageSite_2 concept.
const Handle& source_of_supporting_site(unsigned int) const {
CGAL_precondition( is_point() && !is_input() );
return h_[0];
}
const Handle& target_of_supporting_site(unsigned int) const {
CGAL_precondition( is_point() && !is_input() );
return h_[0];
}
const Handle& source_of_crossing_site(unsigned int i) const {
CGAL_USE(i);
CGAL_precondition( is_segment() && !is_input(i) );
return h_[0];
}
const Handle& target_of_crossing_site(unsigned int i) const {
CGAL_USE(i);
CGAL_precondition( is_segment() && !is_input(i) );
return h_[0];
}
Site_2 site() const {
if ( is_point() ) {
return Site_2::construct_site_2(*h_[0]);
} else {
return Site_2::construct_site_2(*h_[0],*h_[1]);
}
}
Self source_site() const
{
CGAL_precondition( is_segment() );
return construct_storage_site_2(h_[0]);
}
Self target_site() const
{
CGAL_precondition( is_segment() );
return construct_storage_site_2(h_[1]);
}
Self supporting_site() const {
CGAL_precondition( is_segment() );
return construct_storage_site_2(h_[0], h_[1]);
}
Self supporting_site(unsigned int i) const {
CGAL_USE(i);
CGAL_precondition( is_point() && !is_input() && i < 2 );
return construct_storage_site_2(h_[0], h_[0]);
}
Self crossing_site(unsigned int i) const {
CGAL_USE(i);
CGAL_precondition( is_segment() && !is_input() );
CGAL_precondition( i < 2 && !is_input(i) );
return construct_storage_site_2(h_[0], h_[0]);
}
protected:
// INITIALIZATION
//---------------
void initialize_site(const Handle& hp)
{
type_ = 1;
h_[0] = hp;
}
void initialize_site(const Handle& hp1, const Handle& hp2)
{
type_ = 2;
h_[0] = hp1;
h_[1] = hp2;
}
void copy_from(const Self& other) {
type_ = other.type_;
if ( !other.is_defined() ) { return; }
h_[0] = other.h_[0];
if ( other.is_segment() ) {
h_[1] = other.h_[1];
}
}
protected:
Handle h_[2];
char type_;
};
//-------------------------------------------------------------------------
} //namespace CGAL
#endif // CGAL_SEGMENT_DELAUNAY_GRAPH_SIMPLE_STORAGE_SITE_H
|