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
|
// Copyright (c) 2003-2007 INRIA Sophia-Antipolis (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
// See the file LICENSE.QPL distributed with CGAL.
//
// 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: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Surface_mesher/include/CGAL/Surface_mesh_cell_base_3.h $
// $Id: Surface_mesh_cell_base_3.h 46262 2008-10-14 08:27:53Z afabri $
//
// Author(s) : Steve Oudot, David Rey, Mariette Yvinec, Laurent Rineau, Andreas Fabri
#ifndef CGAL_SURFACE_MESH_CELL_BASE_3_H
#define CGAL_SURFACE_MESH_CELL_BASE_3_H
#include <CGAL/Complex_2_in_triangulation_cell_base_3.h>
#ifdef CGAL_MESH_3_IO_H
#include <string>
#endif
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
#include <bitset>
#endif // CGAL_SURFACE_MESHER_TAG_BAD
namespace CGAL {
template < class GT, class Cb=Triangulation_cell_base_3<GT> >
class Surface_mesh_cell_base_3 :
public Complex_2_in_triangulation_cell_base_3<GT, Cb>
{
typedef Complex_2_in_triangulation_cell_base_3<GT, Cb> Base;
public:
typedef Surface_mesh_cell_base_3 <GT, Cb> Self;
template < class TDS3 >
struct Rebind_TDS {
typedef typename Cb::template Rebind_TDS<TDS3>::Other Cb3;
typedef Surface_mesh_cell_base_3 <GT, Cb3> Other;
};
typedef typename GT::Point_3 Point;
typedef typename Base::Triangulation_data_structure Tds;
typedef typename Tds::Vertex_handle Vertex_handle;
typedef typename Tds::Cell_handle Cell_handle;
private:
// -- fields added to this class --
Point tab_surface_center_facets [4];
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
std::bitset<12> bits;
#else
char bits; // the lower 4 bits for 'facet_visited',
// the higher 4 bits for 'visits'
#endif
public:
// Constructors
Surface_mesh_cell_base_3()
: Base(), bits()// c_visited(0)
{}
Surface_mesh_cell_base_3 (Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2,
Vertex_handle v3)
: Base (v0, v1, v2, v3), bits()// c_visited(0)
{}
Surface_mesh_cell_base_3 (Vertex_handle v0,
Vertex_handle v1,
Vertex_handle v2,
Vertex_handle v3,
Cell_handle n0,
Cell_handle n1,
Cell_handle n2,
Cell_handle n3)
: Base (v0, v1, v2, v3, n0, n1, n2, n3), bits()// c_visited(0)
{}
// Access functions
// Facets
bool is_facet_visited (const int facet) const {
CGAL_assertion (facet>=0 && facet <4);
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
return bits[facet];
#else
return (bits & (1 << facet)) != 0;
#endif
}
bool visited (const int facet) const {
CGAL_assertion (facet>=0 && facet <4);
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
return bits[facet+4];
#else
return (bits & (1 << (facet+4)) != 0);
#endif
}
const Point& get_facet_surface_center(const int facet) const {
CGAL_assertion (facet>=0 && facet <4);
return(tab_surface_center_facets[facet]);
}
// Setting functions
// Facets
void set_facet_visited (const int facet) {
CGAL_assertion (facet>=0 && facet <4);
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
bits[facet] = true;
#else
bits |= (1 << facet);
#endif
}
void set_visited (const int facet) {
CGAL_assertion (facet>=0 && facet <4);
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
bits[facet+4] = true;
#else
bits |= (1 << (4+facet));
#endif
}
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
void set_bad(const int facet) {
bits[facet+8] = true;
}
bool is_bad(const int facet) const {
return bits[facet+8];
}
#endif
void reset_visited (const int facet) {
CGAL_assertion (facet>=0 && facet <4);
#ifdef CGAL_SURFACE_MESHER_TAG_BAD
bits &= ~((1 | (1 << 4) | (1 << 8)) << facet);
// bits[facet+8] = false;
// bits[facet+4] = false;
// bits[facet] = false;
#else
bits &= (15 & ~(1 << facet));
bits &= ((15 | (15<<4)) & ~(1 << (4+facet)));
#endif
}
void set_facet_surface_center(const int facet,
const Point& p) {
CGAL_assertion (facet>=0 && facet <4);
tab_surface_center_facets[facet]=p;
}
#ifdef CGAL_MESH_3_IO_H
static
std::string io_signature()
{
return
Get_io_signature<Complex_2_in_triangulation_cell_base_3<GT, Cb> >()();
}
#endif
}; // end Surface_mesh_cell_base_3
template < class GT, class Cb >
std::istream&
operator>>(std::istream &is,
Surface_mesh_cell_base_3<GT, Cb> &v)
{
return is >>
static_cast<Complex_2_in_triangulation_cell_base_3<GT, Cb>&>(v);
}
template < class GT, class Cb >
std::ostream&
operator<<(std::ostream &os,
const Surface_mesh_cell_base_3<GT, Cb> &v)
{
return os <<
static_cast<const Complex_2_in_triangulation_cell_base_3<GT, Cb>&>(v);
}
} // namespace CGAL
#endif // CGAL_SURFACE_MESH_CELL_BASE_3_H
|