52 #ifndef CGAL_HALFEDGE_DATA_STRUCTURE_DECORATOR_H
53 #define CGAL_HALFEDGE_DATA_STRUCTURE_DECORATOR_H 1
56 #include <CGAL/basic.h>
58 #ifndef CGAL_PROTECT_VECTOR
60 #define CGAL_PROTECT_VECTOR
62 #ifndef CGAL_IO_VERBOSE_OSTREAM_H
64 #endif // CGAL_IO_VERBOSE_OSTREAM_H
68 template <
class _HDS >
85 typedef typename _HDS::Vertex
Vertex;
87 typedef typename _HDS::Facet
Facet;
90 typedef typename _HDS::Point
Point;
95 typedef typename _HDS::Supports_vertex_point
97 typedef typename _HDS::Supports_vertex_halfedge
99 typedef typename _HDS::Supports_halfedge_prev
101 typedef typename _HDS::Supports_halfedge_vertex
103 typedef typename _HDS::Supports_halfedge_facet
105 typedef typename _HDS::Supports_facet_halfedge
312 h->set_next( v->
next());
330 h->set_next( f->
next());
424 while ( h != gprev) {
470 while ( h != gprev) {
478 if ( ! gprev->is_border())
511 if ( h->
next() !=
i) {
518 while ( g->
next() !=
i) {
527 if ( i->
next() !=
j) {
534 while ( g->
next() !=
j) {
543 if ( j->
next() != h) {
550 while ( g->
next() != h) {
613 while ( gii->next()->opposite()->next() != gi) {
615 gii = gii->next()->opposite();
627 hds.delete_edge( gii);
641 hds.delete_facet( h->facet());
704 set_facet( hprev->next(), hprev->facet());
706 hprev = hprev->next();
707 gprev = gprev->
next();
725 hds.delete_facet( h->facet());
779 if ( h->vertex() != NULL) {
780 hds.delete_vertex( h->vertex());
842 while ( ! stack.empty()) {
909 return v->halfedge();
923 while ( g->
next() != h)
933 while ( g->
next() != h)
945 return f->halfedge();
955 return v->halfedge();
973 while ( g->
next() != h)
985 while ( g->
next() != h)
1001 return f->halfedge();
1009 return hds.new_vertex();
1016 return hds.new_vertex(p);
1023 return hds.new_vertex(v);
1028 return hds.new_facet();
1035 return hds.new_facet(f);
1044 hds.delete_vertex( v);
1049 hds.delete_facet( f);
1103 bool is_valid(
const _HDS& hds,
bool verb =
false,
int level = 0)
1117 template <
class _HDS >
1122 typedef typename _HDS::Halfedge_const_iterator Halfedge_const_iterator;
1123 typedef typename _HDS::Size Size;
1126 verr <<
"begin Halfedge_data_structure_decorator<HDS>::"
1127 "normalized_border_is_valid( verb=true):" << std::endl;
1129 Halfedge_const_iterator e = hds.halfedges_begin();
1131 while( e != hds.halfedges_end() && ! e->is_border() && !
1132 e->opposite()->is_border()) {
1137 verr <<
" non-border edges: " << count << std::endl;
1138 if ( e != hds.border_halfedges_begin()) {
1139 verr <<
" first border edge does not start at "
1140 "border_halfedges_begin()" << std::endl;
1144 while( valid && e != hds.halfedges_end() &&
1145 e->opposite()->is_border()) {
1150 verr <<
" border edges: " << count << std::endl;
1151 verr <<
" total edges: " << hds.size_of_halfedges()/2
1153 if ( e != hds.halfedges_end()) {
1154 if ( e->is_border()) {
1155 verr <<
" border edge " << count
1156 <<
": wrong orientation." << std::endl;
1158 verr <<
" the sum of full + border equals not total edges."
1163 verr <<
"end of Halfedge_data_structure_decorator<HDS>::"
1164 "normalized_border_is_valid(): structure is "
1165 << ( valid ?
"valid." :
"NOT VALID.") << std::endl;
1169 template <
class _HDS >
1172 is_valid(
const _HDS& hds,
bool verb,
int level)
const {
1174 typedef typename _HDS::Halfedge_const_iterator Halfedge_const_iterator;
1175 typedef typename _HDS::Vertex_const_iterator Vertex_const_iterator;
1176 typedef typename _HDS::Facet_const_iterator Facet_const_iterator;
1177 typedef typename _HDS::Size Size;
1179 typedef typename _HDS::Supports_halfedge_vertex
1181 typedef typename _HDS::Supports_vertex_halfedge
1183 typedef typename _HDS::Supports_halfedge_facet
1185 typedef typename _HDS::Supports_facet_halfedge
1189 verr <<
"begin Halfedge_data_structure_decorator<HDS>::is_valid("
1190 " verb=true, level = " << level <<
"):" << std::endl;
1192 bool valid = ( 1 != (hds.size_of_halfedges() & 1));
1194 verr <<
"number of halfedges is odd." << std::endl;
1197 Halfedge_const_iterator begin = hds.halfedges_begin();
1198 Halfedge_const_iterator end = hds.halfedges_end();
1201 for( ; valid && (begin != end); begin++) {
1202 verr <<
"halfedge " << n << std::endl;
1203 if ( begin->is_border())
1204 verr <<
" is border halfedge" << std::endl;
1206 valid = valid && ( begin->next() != NULL);
1207 valid = valid && ( begin->opposite() != NULL);
1209 verr <<
" pointer integrity corrupted (ptr==NULL)."
1214 valid = valid && ( begin->opposite() != &*begin);
1215 valid = valid && ( begin->opposite()->opposite() == &*begin);
1217 verr <<
" opposite pointer integrity corrupted."
1222 valid = valid && ( !
check_tag( Supports_halfedge_prev()) ||
1223 get_prev(begin->next()) == &*begin);
1225 verr <<
" previous pointer integrity corrupted."
1231 valid = valid && ( !
check_tag( Supports_halfedge_vertex())
1232 || get_vertex( &*begin) != NULL);
1233 valid = valid && ( get_vertex( &*begin) ==
1234 get_vertex( begin->next()->opposite()));
1236 verr <<
" vertex pointer integrity corrupted."
1241 valid = valid && ( !
check_tag( Supports_halfedge_facet())
1242 || begin->is_border() || get_facet( &*begin) != NULL);
1243 valid = valid && ( get_facet( &*begin) ==
1244 get_facet( begin->next()));
1246 verr <<
" facet pointer integrity corrupted."
1252 if ( begin->is_border())
1255 verr <<
"summe border halfedges (2*nb) = " << 2 * nb << std::endl;
1256 if ( valid && n != hds.size_of_halfedges())
1257 verr <<
"counting halfedges failed." << std::endl;
1258 if ( valid && level >= 4 && (nb != hds.size_of_border_halfedges()))
1259 verr <<
"counting border halfedges failed." << std::endl;
1260 valid = valid && ( n == hds.size_of_halfedges());
1261 valid = valid && ( level < 4 ||
1262 (nb == hds.size_of_border_halfedges()));
1265 Vertex_const_iterator vbegin = hds.vertices_begin();
1266 Vertex_const_iterator vend = hds.vertices_end();
1269 for( ; valid && (vbegin != vend); ++vbegin) {
1270 verr <<
"vertex " << v << std::endl;
1272 if ( get_vertex_halfedge( &*vbegin) != NULL)
1274 Supports_halfedge_vertex()) ||
1275 get_vertex( get_vertex_halfedge( &*vbegin)) == &*vbegin);
1278 Supports_vertex_halfedge()));
1280 verr <<
" halfedge pointer in vertex corrupted."
1285 const Halfedge* h = get_vertex_halfedge( &*vbegin);
1289 verr <<
" halfedge " << n << std::endl;
1292 valid = valid && ( n <= hds.size_of_halfedges() && n != 0);
1293 }
while ( valid && (h != g));
1297 if ( valid && v != hds.size_of_vertices())
1298 verr <<
"counting vertices failed." << std::endl;
1299 if ( valid && level >= 2 && (
check_tag( Supports_vertex_halfedge())
1300 && n != hds.size_of_halfedges()))
1301 verr <<
"counting halfedges via vertices failed." << std::endl;
1302 valid = valid && ( v == hds.size_of_vertices());
1303 valid = valid && ( level < 2 ||
1304 !
check_tag( Supports_vertex_halfedge()) ||
1305 n == hds.size_of_halfedges());
1308 Facet_const_iterator fbegin = hds.facets_begin();
1309 Facet_const_iterator fend = hds.facets_end();
1312 for( ; valid && (fbegin != fend); ++fbegin) {
1313 verr <<
"facet " << f << std::endl;
1315 if ( get_facet_halfedge( &*fbegin) != NULL)
1317 Supports_halfedge_facet()) ||
1318 get_facet( get_facet_halfedge( &*fbegin)) == &*fbegin);
1321 Supports_facet_halfedge()) || begin->is_border());
1323 verr <<
" halfedge pointer in facet corrupted."
1328 const Halfedge* h = get_facet_halfedge( &*fbegin);
1332 verr <<
" halfedge " << n << std::endl;
1335 valid = valid && ( n <= hds.size_of_halfedges() && n != 0);
1336 }
while ( valid && (h != g));
1340 if ( valid && f != hds.size_of_facets())
1341 verr <<
"counting facets failed." << std::endl;
1342 if ( valid && level >= 3 &&
check_tag( Supports_facet_halfedge()) &&
1343 n + nb != hds.size_of_halfedges())
1344 verr <<
"counting halfedges via facets failed." << std::endl;
1345 valid = valid && ( f == hds.size_of_facets());
1346 valid = valid && ( level < 3 ||
1347 !
check_tag( Supports_facet_halfedge()) ||
1348 n + nb == hds.size_of_halfedges());
1351 verr <<
"level 4: normalized_border_is_valid( verbose = true)"
1353 valid = valid && ( normalized_border_is_valid( hds, verb));
1355 verr <<
"end of Halfedge_data_structure_decorator<HDS>::"
1356 "is_valid(): structure is " << ( valid ?
"valid." :
1357 "NOT VALID.") << std::endl;
1372 first = first->
next();
1374 while (first != last) {
1380 first->set_next( prev);
1388 start->set_next( prev);
1392 template <
class _HDS >
1396 typedef typename _HDS::Halfedge_iterator Halfedge_iterator;
1397 Halfedge_iterator begin = hds.halfedges_begin();
1398 Halfedge_iterator end = hds.halfedges_end();
1399 for( ; begin != end; ++begin) {
1411 }
while ( c != d && is_min);
1417 template <
class _HDS >
1421 typedef typename _HDS::Halfedge_iterator Halfedge_iterator;
1422 typedef typename _HDS::Facet_iterator Facet_iterator;
1423 Facet_iterator begin = hds.facets_begin();
1424 Facet_iterator end = hds.facets_end();
1425 for( ; begin != end; ++begin)
1426 reorient_facet( begin->halfedge());
1432 Halfedge_iterator first = hds.halfedges_begin();
1433 Halfedge_iterator last = hds.halfedges_end();
1434 for( ; first != last; ++first) {
1435 if ( first->is_border() &&
1436 first->vertex() == first->opposite()->vertex())
1437 reorient_facet( &*first);
1442 #endif // CGAL_HALFEDGE_DATA_STRUCTURE_DECORATOR_H //
Halfedge * fill_hole(HDS &hds, Halfedge *h)
const Halfedge * get_prev(const Halfedge *h) const
void remove_tip(Halfedge *h) const
const Facet * get_facet(const Halfedge *h, Tag_true) const
void close_tip(Halfedge *h) const
void erase_connected_component_vertex(HDS &hds, Halfedge *h, Tag_false)
void fill_hole(HDS &hds, Halfedge *h, Tag_true)
#define CGAL_assertion(EX)
Halfedge * flip_edge(Halfedge *h)
void set_vertex_halfedge(Halfedge *h, Halfedge *g, Tag_true) const
Halfedge * find_prev_around_vertex(Halfedge *h, Tag_true) const
const Facet * get_facet(const Halfedge *, Tag_false) const
Facet * new_facet(HDS &hds) const
_HDS::Supports_halfedge_facet Supports_halfedge_facet
Halfedge * join_facet(HDS &hds, Halfedge *h)
void erase_connected_component_face_cycle(HDS &hds, Halfedge *h, HVector &stack)
Facet * new_facet(HDS &, Tag_false) const
Vertex * new_vertex(HDS &hds, const Vertex *v, Tag_true) const
const Halfedge * get_facet_halfedge(const Facet *f) const
void delete_vertex(HDS &, Vertex *, Tag_false)
_HDS::Supports_vertex_halfedge Supports_vertex_halfedge
Facet * new_facet(HDS &hds, const Facet *f) const
void set_vertex_halfedge(Halfedge *, Halfedge *, Tag_false) const
Halfedge * create_segment(HDS &hds)
Halfedge * join_loop(HDS &hds, Halfedge *h, Halfedge *g)
void erase_connected_component_vertex(HDS &hds, Halfedge *h, Tag_true)
void set_facet_halfedge(Halfedge *, Halfedge *, Tag_false) const
void set_facet(Halfedge *h, Facet *f, Tag_true) const
Halfedge opposite() const
Get the ID of the opposite edge of a given edge.
void set_point(Vertex *, const Point &, Tag_false) const
const Vertex * get_vertex(const Halfedge *h, Tag_true) const
const Halfedge * find_prev(const Halfedge *h) const
void delete_vertex(HDS &hds, Vertex *v, Tag_true)
Halfedge prev() const
Get the previous halfedge of its owner element.
This class encapsulate a halfedge over a window manifold.
Halfedge * split_vertex(HDS &hds, Halfedge *h, Halfedge *g)
void set_point(Halfedge *h, const Point &p, Tag_true) const
void set_facet_halfedge(Facet *f, Halfedge *g) const
Halfedge next() const
Get the next halfedge of its owner element.
void delete_facet(HDS &hds, Facet *f)
Halfedge * make_hole(HDS &hds, Halfedge *h)
const Halfedge * get_facet_halfedge(const Facet *, Tag_false) const
void set_vertex(Halfedge *, Vertex *, Tag_false) const
void set_vertex_in_vertex_loop(Halfedge *, Vertex *, Tag_false)
bool is_valid(const _HDS &hds, bool verb=false, int level=0) const
void erase_facet(HDS &hds, Halfedge *h, Tag_true)
void delete_facet(HDS &, Facet *, Tag_false)
void make_hole(HDS &, Halfedge *, Tag_false)
Vertex * new_vertex(HDS &hds, Tag_true) const
#define CGAL_MEDIUM_INLINE
Halfedge * find_prev(Halfedge *h, Tag_false) const
void erase_connected_component(HDS &hds, Halfedge *h)
Vertex * get_vertex(Halfedge *h) const
void set_facet_in_facet_loop(Halfedge *, Facet *, Tag_false)
void set_point(Halfedge *, const Point &, Tag_false) const
#define CGAL_assertion_code(CODE)
Halfedge * find_prev_around_vertex(Halfedge *h, Tag_false) const
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
void reorient_facet(Halfedge *first)
void set_point(Vertex *v, const Point &p) const
void set_facet_halfedge(Halfedge *h) const
Facet * new_facet(HDS &hds, const Facet *f, Tag_true) const
Halfedge * get_vertex_halfedge(Vertex *, Tag_false) const
const Halfedge * find_prev_around_vertex(const Halfedge *h, Tag_false) const
void set_prev(Halfedge *h, Halfedge *g, Tag_true) const
Facet * get_facet(Halfedge *h, Tag_true) const
Halfedge * get_prev(Halfedge *h, Tag_true) const
void set_point(Halfedge *h, const Point &p) const
const Halfedge * find_prev_around_vertex(const Halfedge *h) const
const Halfedge * get_vertex_halfedge(const Vertex *v, Tag_true) const
#define CGAL_precondition(EX)
void set_vertex_halfedge(Vertex *, Halfedge *, Tag_false) const
const Vertex * get_vertex(const Halfedge *, Tag_false) const
_HDS::Supports_facet_halfedge Supports_facet_halfedge
void set_vertex_in_vertex_loop(Halfedge *h, Vertex *v, Tag_true)
void set_prev(Halfedge *, Halfedge *, Tag_false) const
const Halfedge * find_prev_around_vertex(const Halfedge *h, Tag_true) const
void erase_connected_component_vertex(HDS &hds, Halfedge *h)
Facet * get_facet(Halfedge *h) const
Halfedge * get_facet_halfedge(Facet *f) const
void set_facet_in_facet_loop(Halfedge *h, Facet *f, Tag_true)
void inside_out(_HDS &hds)
Halfedge * get_facet_halfedge(Facet *, Tag_false) const
Halfedge * find_prev(Halfedge *h, Tag_true) const
Halfedge * get_vertex_halfedge(Vertex *v) const
void insert_tip(Halfedge *h, Halfedge *v) const
Vertex * new_vertex(HDS &, const Point &, Tag_false) const
Halfedge * get_prev(Halfedge *, Tag_false) const
const Halfedge * get_vertex_halfedge(const Vertex *v) const
Vertex * new_vertex(HDS &, const Vertex *, Tag_false) const
Facet * get_facet(Halfedge *, Tag_false) const
Halfedge * find_prev(Halfedge *h) const
void set_vertex_halfedge(Vertex *v, Halfedge *g, Tag_true) const
void close_tip(Halfedge *h, Vertex *v) const
void set_facet_halfedge(Facet *f, Halfedge *g, Tag_true) const
Facet * new_facet(HDS &, const Facet *, Tag_false) const
void set_facet_halfedge(Facet *, Halfedge *, Tag_false) const
const Halfedge * find_prev(const Halfedge *h, Tag_false) const
Halfedge * get_vertex_halfedge(Vertex *v, Tag_true) const
void set_vertex_halfedge(Halfedge *h) const
Halfedge * add_facet_to_border(HDS &hds, Halfedge *h, Halfedge *g)
Halfedge * split_facet(HDS &hds, Halfedge *h, Halfedge *g)
void fill_hole(HDS &, Halfedge *, Tag_false)
Vertex * new_vertex(HDS &hds) const
bool is_border() const
Is the edge a border edge?
void Assert_compile_time_tag(const Tag &, const Derived &b)
const Vertex * get_vertex(const Halfedge *h) const
void make_hole(HDS &hds, Halfedge *h, Tag_true)
Vertex * get_vertex(Halfedge *h, Tag_true) const
Vertex * new_vertex(HDS &hds, const Point &p, Tag_true) const
void set_facet(Halfedge *h, Facet *f) const
void set_facet_halfedge(Halfedge *h, Halfedge *g, Tag_true) const
void remove_halfedge(Halfedge *h) const
Halfedge * create_loop(HDS &hds)
void erase_facet(HDS &hds, Halfedge *h)
void set_facet_in_facet_loop(Halfedge *h, Facet *f)
void set_facet(Halfedge *, Facet *, Tag_false) const
Vertex * new_vertex(HDS &hds, const Vertex *v) const
const Halfedge * get_prev(const Halfedge *, Tag_false) const
void set_vertex_halfedge(Vertex *v, Halfedge *g) const
Vertex * get_vertex(Halfedge *, Tag_false) const
void delete_vertex(HDS &hds, Vertex *v)
const Halfedge * find_prev(const Halfedge *h, Tag_true) const
_HDS::Supports_halfedge_vertex Supports_halfedge_vertex
#define CGAL_BEGIN_NAMESPACE
void set_vertex(Halfedge *h, Vertex *v) const
#define CGAL_postcondition(EX)
const Halfedge * get_vertex_halfedge(const Vertex *, Tag_false) const
_HDS::Supports_removal Supports_removal
Vertex * new_vertex(HDS &, Tag_false) const
bool normalized_border_is_valid(const _HDS &hds, bool verb=false) const
void set_point(Vertex *v, const Point &p, Tag_true) const
Facet * new_facet(HDS &hds, Tag_true) const
Halfedge * split_loop(HDS &hds, Halfedge *h, Halfedge *i, Halfedge *j)
const Halfedge * get_facet_halfedge(const Facet *f, Tag_true) const
Vertex * new_vertex(HDS &hds, const Point &p) const
Halfedge * get_prev(Halfedge *h) const
void set_prev(Halfedge *h, Halfedge *g) const
Halfedge * get_facet_halfedge(Facet *f, Tag_true) const
#define CGAL_END_NAMESPACE
void erase_facet(HDS &, Halfedge *, Tag_false)
void insert_halfedge(Halfedge *h, Halfedge *f) const
const Facet * get_facet(const Halfedge *h) const
void delete_facet(HDS &hds, Facet *f, Tag_true)
const Halfedge * get_prev(const Halfedge *h, Tag_true) const
Halfedge * join_vertex(HDS &hds, Halfedge *h)
std::vector< Halfedge * > HVector
void set_vertex(Halfedge *h, Vertex *v, Tag_true) const
Halfedge * find_prev_around_vertex(Halfedge *h) const
_HDS::Supports_halfedge_prev Supports_halfedge_prev
_HDS Halfedge_data_structure
_HDS::Supports_vertex_point Supports_vertex_point
void inside_out(_HDS &hds, Tag_false)
void set_vertex_in_vertex_loop(Halfedge *h, Vertex *v)