| 1 |
/* |
|---|
| 2 |
Clustr. Copyright (c) 2007-2009 Yahoo! Inc. |
|---|
| 3 |
|
|---|
| 4 |
All rights reserved. This code is free software; you can redistribute it |
|---|
| 5 |
and/or modify it under the terms of the GNU General Public License (GPL), |
|---|
| 6 |
version 2 only. This code is distributed WITHOUT ANY WARRANTY, whether |
|---|
| 7 |
express or implied. See the GNU GPL for more details |
|---|
| 8 |
(http://www.gnu.org/licenses/gpl.html) |
|---|
| 9 |
|
|---|
| 10 |
AS A SPECIAL EXCEPTION, YOU HAVE PERMISSION TO LINK THIS PROGRAM WITH THE |
|---|
| 11 |
CGAL LIBRARY AND DISTRIBUTE EXECUTABLES, AS LONG AS YOU FOLLOW THE REQUIREMENTS |
|---|
| 12 |
OF THE GNU GPL VERSION 2 IN REGARD TO ALL OF THE SOFTWARE IN THE EXECUTABLE |
|---|
| 13 |
ASIDE FROM CGAL. |
|---|
| 14 |
*/ |
|---|
| 15 |
|
|---|
| 16 |
#include <iostream> |
|---|
| 17 |
#include "clustr.h" |
|---|
| 18 |
|
|---|
| 19 |
using namespace Clustr; |
|---|
| 20 |
|
|---|
| 21 |
Vertex_handle Mesh::vertex_circulator::target (const Edge &e) { |
|---|
| 22 |
return e.first->vertex(Mesh::ccw(e.second)); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
Vertex_handle Mesh::vertex_circulator::origin (const Edge &e) { |
|---|
| 26 |
return e.first->vertex(Mesh::cw(e.second)); |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
Mesh::vertex_circulator& |
|---|
| 30 |
Mesh::vertex_circulator::operator++(void) |
|---|
| 31 |
{ |
|---|
| 32 |
Mesh *mesh = ring->mesh; |
|---|
| 33 |
Edge_circulator edge = mesh->incident_edges(vertex), edge0 = edge; |
|---|
| 34 |
Edge selected; |
|---|
| 35 |
int min_count = ~0; |
|---|
| 36 |
|
|---|
| 37 |
if (previous.first == NULL) previous = *edge; |
|---|
| 38 |
Direction angle_in(mesh->segment(previous)), angle_out; |
|---|
| 39 |
|
|---|
| 40 |
(*vertex)++; |
|---|
| 41 |
do { |
|---|
| 42 |
if (mesh->classify(*edge) == Mesh::REGULAR) { |
|---|
| 43 |
Vertex_handle next_v = target(*edge); |
|---|
| 44 |
if (next_v == origin(previous)) continue; |
|---|
| 45 |
if (next_v->count() <= min_count) { |
|---|
| 46 |
Direction next_angle = mesh->segment(*edge).direction(); |
|---|
| 47 |
if (next_v->count() == min_count && |
|---|
| 48 |
!next_angle.counterclockwise_in_between(angle_in,angle_out)) |
|---|
| 49 |
continue; |
|---|
| 50 |
selected = *edge; |
|---|
| 51 |
angle_out = mesh->segment(selected).direction(); |
|---|
| 52 |
min_count = next_v->count(); |
|---|
| 53 |
} |
|---|
| 54 |
} |
|---|
| 55 |
} while (++edge != edge0); |
|---|
| 56 |
//std::cerr << mesh->segment(previous) << " -> " << mesh->segment(selected) << std::endl; |
|---|
| 57 |
previous = selected; |
|---|
| 58 |
vertex = target(selected); |
|---|
| 59 |
return *this; |
|---|
| 60 |
} |
|---|