/usr/include/CGAL/boost/graph/helpers.h is in libcgal-dev 4.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | // Copyright (c) 2014 GeometryFactory (France). All rights reserved.
// 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$
//
// Author(s) : Andreas Fabri
#ifndef CGAL_BOOST_GRAPH_HELPERS_H
#define CGAL_BOOST_GRAPH_HELPERS_H
#include <boost/foreach.hpp>
namespace CGAL {
template <typename FaceGraph>
bool is_border(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, const FaceGraph& g)
{
return face(hd,g) == boost::graph_traits<FaceGraph>::null_face();
}
template <typename FaceGraph>
bool is_border_edge(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, const FaceGraph& g)
{
return is_border(hd, g) || is_border(opposite(hd,g), g);
}
template <typename FaceGraph>
bool is_border(typename boost::graph_traits<FaceGraph>::edge_descriptor ed, const FaceGraph& g)
{
return is_border_edge(halfedge(ed,g), g);
}
template <typename Graph>
boost::optional<typename boost::graph_traits<Graph>::halfedge_descriptor>
is_border(typename boost::graph_traits<Graph>::vertex_descriptor v,
const Graph& g)
{
CGAL::Halfedge_around_target_iterator<Graph> havib, havie;
for(boost::tie(havib, havie) = halfedges_around_target(halfedge(v, g), g); havib != havie; ++havib) {
if(is_border(*havib,g)) {
typename boost::graph_traits<Graph>::halfedge_descriptor h = *havib;
return h;
}
}
// empty
return boost::optional<typename boost::graph_traits<Graph>::halfedge_descriptor>();
}
/*!
returns `true` if there are no
border edges.
*/
template <typename FaceGraph>
bool is_closed(const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
BOOST_FOREACH(halfedge_descriptor hd, halfedges(g)){
if(is_border(hd,g)){
return false;
}
}
return true;
}
template <typename FaceGraph>
bool is_bivalent(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, const FaceGraph& g)
{
return hd == opposite(next(opposite(next(hd,g),g),g),g);
}
/*!
returns `true` if all
vertices have exactly two incident edges.
*/
template <typename FaceGraph>
bool is_pure_bivalent(const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
BOOST_FOREACH(vertex_descriptor vd, vertices(g)){
halfedge_descriptor hd = halfedge(vd,g);
if((hd == boost::graph_traits<FaceGraph>::null_halfedge()) ||
(! is_bivalent(hd,g))){
return false;
}
}
return true;
}
template <typename FaceGraph>
bool is_trivalent(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, const FaceGraph& g)
{
return hd == opposite(next(opposite(next(opposite(next(hd,g),g),g),g),g),g);
}
/*!
returns `true` if all
vertices have exactly three incident edges.
*/
template <typename FaceGraph>
bool is_pure_trivalent(const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
BOOST_FOREACH(vertex_descriptor vd, vertices(g)){
halfedge_descriptor hd = halfedge(vd,g);
if((hd == boost::graph_traits<FaceGraph>::null_halfedge()) ||
(! is_trivalent(hd,g))){
return false;
}
}
return true;
}
/*!
returns `true` iff the connected component denoted by `h` is a triangle.
\pre `g` must be valid.
*/
template <typename FaceGraph>
bool is_triangle(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor beg = hd;
if(is_border(hd,g)) return false;
for(int i=0; i<3;i++){
if(! is_border(opposite(hd,g),g)) return false;
hd = next(hd,g);
}
return next(hd,g)== beg;
}
/*!
returns `true` iff the face is a triangle, that is it has three incident halfedges.
*/
template <typename FaceGraph>
bool is_triangle(typename boost::graph_traits<FaceGraph>::face_descriptor fd, const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor hd = halfedge(fd,g);
return hd == next(next(next(hd,g),g),g);
}
/*!
returns `true` if all faces are triangles.
*/
template <typename FaceGraph>
bool is_pure_triangle(const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
BOOST_FOREACH(face_descriptor fd, faces(g)){
if(! is_triangle(fd,g)){
return false;
}
}
return true;
}
/*!
returns `true` iff the connected component denoted by `h` is a quadrilateral.
*/
template <typename FaceGraph>
bool is_quad(typename boost::graph_traits<FaceGraph>::halfedge_descriptor hd, const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor beg = hd;
if(is_border(hd,g)) return false;
for(int i=0; i<4;i++){
if(! is_border(opposite(hd,g),g)) return false;
hd = next(hd,g);
}
return next(hd,g)== beg;
}
/*!
returns `true` iff the face is a quad, that is it has four incident halfedges.
*/
template <typename FaceGraph>
bool is_quad(typename boost::graph_traits<FaceGraph>::face_descriptor fd, const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor hd = halfedge(fd,g);
return hd == next(next(next(next(hd,g),g),g),g);
}
/*!
returns `true` if all faces are quadrilaterals.
*/
template <typename FaceGraph>
bool is_pure_quad(const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
BOOST_FOREACH(face_descriptor fd, faces(g)){
if(! is_quad(fd,g)){
return false;
}
}
return true;
}
/*!
returns `true` iff the connected component denoted by `h` is a tetrahedron.
*/
template <typename FaceGraph>
bool is_tetrahedron( typename boost::graph_traits<FaceGraph>::halfedge_descriptor h1, const FaceGraph& g)
{
typedef typename boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor h2 = next(h1,g);
halfedge_descriptor h3 = next(h2,g);
halfedge_descriptor h4 = next(opposite(h1,g),g );
halfedge_descriptor h5 = next(opposite(h2,g),g );
halfedge_descriptor h6 = next(opposite(h3,g),g );
// check halfedge combinatorics.
// at least three edges at vertices 1, 2, 3.
if ( h4 == opposite(h3,g) ) return false;
if ( h5 == opposite(h1,g) ) return false;
if ( h6 == opposite(h2,g) ) return false;
// exact three edges at vertices 1, 2, 3.
if ( next(opposite(h4,g),g) != opposite(h3,g) ) return false;
if ( next(opposite(h5,g),g) != opposite(h1,g) ) return false;
if ( next(opposite(h6,g),g) != opposite(h2,g) ) return false;
// three edges at v4.
if ( opposite(next(h4,g),g) != h5 ) return false;
if ( opposite(next(h5,g),g) != h6 ) return false;
if ( opposite(next(h6,g),g) != h4 ) return false;
// All facets are triangles.
if ( next(next(next(h1,g),g),g) != h1 ) return false;
if ( next(next(next(h4,g),g),g) != h4 ) return false;
if ( next(next(next(h5,g),g),g) != h5 ) return false;
if ( next(next(next(h6,g),g),g) != h6 ) return false;
// all edges are non-border edges.
if ( is_border(h1,g) ) return false; // implies h2 and h3
if ( is_border(h4,g) ) return false;
if ( is_border(h5,g) ) return false;
if ( is_border(h6,g) ) return false;
return true;
}
} // namespace CGAL
#endif // CGAL_BOOST_GRAPH_HELPERS_H
|