mirror of https://github.com/CGAL/cgal
Update of offsets during point insertion in the periodic hyperbolic triangulation. Preliminary tests look good.
This commit is contained in:
parent
38d15e7fc8
commit
30ffeb0337
|
|
@ -26,7 +26,7 @@ typedef Triangulation::Vertex_handle Vertex_handle;
|
|||
typedef Triangulation::Locate_type Locate_type;
|
||||
typedef Triangulation::Edge Edge;
|
||||
typedef Traits::FT FT;
|
||||
typedef std::set<Face_handle>::iterator face_iterator;
|
||||
typedef Triangulation::Face_iterator Face_iterator;
|
||||
|
||||
|
||||
using namespace CGAL;
|
||||
|
|
@ -47,20 +47,13 @@ int main(void) {
|
|||
cout << "Point " << query << " is located in face " << fh->get_number();
|
||||
cout << (lt == Triangulation::EDGE ? " [EDGE]" : (lt == Triangulation::VERTEX ? " [VERTEX]" : " [FACE]")) << endl;
|
||||
|
||||
std::set<Face_handle> faces_in_conflict;
|
||||
tr.find_in_conflict(query, fh, faces_in_conflict);
|
||||
cout << "Faces in conflict: ";
|
||||
for (face_iterator it = faces_in_conflict.begin(); it != faces_in_conflict.end(); it++) {
|
||||
cout << (*it)->get_number() << ", ";
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
cout << "Number of faces before: " << tr.number_of_faces() << endl;
|
||||
|
||||
tr.insert(query, fh);
|
||||
|
||||
cout << "Number of faces after: " << tr.number_of_faces() << endl;
|
||||
|
||||
|
||||
/*
|
||||
cout << endl;
|
||||
faces_in_conflict.clear();
|
||||
|
|
|
|||
|
|
@ -277,6 +277,12 @@ public:
|
|||
|
||||
template <class Int, class GT>
|
||||
ostream& operator<<(ostream& s, const Hyperbolic_word_4<Int, GT>& o) {
|
||||
|
||||
if (o.is_identity()) {
|
||||
s << "_";
|
||||
return s;
|
||||
}
|
||||
|
||||
for (Int i = 0; i < 4; i++) {
|
||||
if (o.b(i)) {
|
||||
s << o(i);
|
||||
|
|
|
|||
|
|
@ -175,12 +175,76 @@ insert(const Point &p, Face_handle start)
|
|||
{
|
||||
|
||||
typedef typename Gt::Side_of_fundamental_octagon Side_of_fundamental_octagon;
|
||||
|
||||
|
||||
Side_of_fundamental_octagon check = Side_of_fundamental_octagon();
|
||||
CGAL::Bounded_side side = check(p);
|
||||
|
||||
if (side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
return this->insert_in_face(p, start);
|
||||
|
||||
cout << "Point inserted in face " << start->get_number() << ", vertices: ";
|
||||
for (int i = 0; i < 3; i++)
|
||||
cout << start->vertex(i)->idx() << " with offset " << start->offset(i) << ", ";
|
||||
cout << endl;
|
||||
cout << "Neighbor offsets: " << start->neighbor_offset(0) << ", " << start->neighbor_offset(1) << ", " << start->neighbor_offset(2) << endl;
|
||||
|
||||
int next_number = this->number_of_faces();
|
||||
Vertex_handle ov[] = { start->vertex(0),
|
||||
start->vertex(1),
|
||||
start->vertex(2) };
|
||||
Offset oo[] = { start->offset(0),
|
||||
start->offset(1),
|
||||
start->offset(2) };
|
||||
Offset ono[] = { start->neighbor_offset(0),
|
||||
start->neighbor_offset(1),
|
||||
start->neighbor_offset(2) };
|
||||
|
||||
Vertex_handle new_vertex = this->insert_in_face(p, start);
|
||||
new_vertex->set_point( p );
|
||||
new_vertex->set_idx( this->number_of_vertices() );
|
||||
cout << "New vertex has id " << new_vertex->idx() << endl;
|
||||
|
||||
// Assign offsets
|
||||
Face_circulator iface = _tds.incident_faces(new_vertex), end(iface);
|
||||
if (iface != 0) {
|
||||
do {
|
||||
|
||||
// Null all offsets
|
||||
iface->set_offsets();
|
||||
|
||||
if (iface->get_number() == -1) {
|
||||
iface->set_number(next_number++);
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (iface->vertex(i) == ov[j]) {
|
||||
iface->set_offset(i, oo[j]);
|
||||
if (iface->vertex(Triangulation_cw_ccw_2::cw(i)) == ov[Triangulation_cw_ccw_2::cw(j)]) {
|
||||
iface->set_neighbor_face_offset(Triangulation_cw_ccw_2::ccw(i), ono[Triangulation_cw_ccw_2::ccw(j)]);
|
||||
}
|
||||
else if (iface->vertex(Triangulation_cw_ccw_2::ccw(i)) == ov[Triangulation_cw_ccw_2::ccw(j)]) {
|
||||
iface->set_neighbor_face_offset(Triangulation_cw_ccw_2::cw(i), ono[Triangulation_cw_ccw_2::cw(j)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} while (++iface != end);
|
||||
|
||||
cout << "New faces created: " << endl << "------------------------" << endl;
|
||||
do {
|
||||
cout << "Face " << iface->get_number() << ", vertices: ";
|
||||
for (int i = 0; i < 3; i++) {
|
||||
cout << iface->vertex(i)->idx() << " with offset " << iface->offset(i) << ", ";
|
||||
}
|
||||
cout << endl;
|
||||
cout << "Neighbor offsets: " << iface->neighbor_offset(0) << ", " << iface->neighbor_offset(1) << ", " << iface->neighbor_offset(2) << endl;
|
||||
} while (++iface != end);
|
||||
cout << "--------- end ----------" << endl << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return new_vertex;
|
||||
} else {
|
||||
return Vertex_handle();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,12 @@ public:
|
|||
|
||||
Periodic_4_hyperbolic_triangulation_ds_face_base_2()
|
||||
#ifndef CGAL_CFG_NO_CPP0X_UNIFIED_INITIALIZATION_SYNTAX
|
||||
: o{Offset(), Offset(), Offset()}, no{Offset(), Offset(), Offset()}
|
||||
: o{Offset(), Offset(), Offset()}, no{Offset(), Offset(), Offset()}, face_number(-1)
|
||||
{}
|
||||
#else
|
||||
{
|
||||
set_offsets();
|
||||
face_number = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ public:
|
|||
const Vertex_handle& v2)
|
||||
#ifndef CGAL_CFG_NO_CPP0X_UNIFIED_INITIALIZATION_SYNTAX
|
||||
: V{v0, v1, v2},
|
||||
o{Offset(), Offset(), Offset()}, no{Offset(), Offset(), Offset()}
|
||||
o{Offset(), Offset(), Offset()}, no{Offset(), Offset(), Offset()}, face_number(-1)
|
||||
{
|
||||
set_neighbors();
|
||||
}
|
||||
|
|
@ -79,6 +80,7 @@ public:
|
|||
set_offsets();
|
||||
set_vertices(v0, v1, v2);
|
||||
set_neighbors();
|
||||
face_number = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -91,7 +93,7 @@ public:
|
|||
#ifndef CGAL_CFG_NO_CPP0X_UNIFIED_INITIALIZATION_SYNTAX
|
||||
: V{v0, v1, v2},
|
||||
N{n0, n1, n2},
|
||||
o{Offset(), Offset(), Offset()}, no{Offset(), Offset(), Offset()}
|
||||
o{Offset(), Offset(), Offset()}, no{Offset(), Offset(), Offset()}, face_number(-1)
|
||||
{
|
||||
set_neighbors();
|
||||
}
|
||||
|
|
@ -100,6 +102,7 @@ public:
|
|||
set_offsets();
|
||||
set_vertices(v0, v1, v2);
|
||||
set_neighbors(n0, n1, n2);
|
||||
face_number = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -200,6 +203,10 @@ public:
|
|||
no[2] = no2;
|
||||
}
|
||||
|
||||
void set_neighbor_face_offset(int k, Offset new_o) {
|
||||
no[k] = new_o;
|
||||
}
|
||||
|
||||
void set_offsets(
|
||||
const Offset& o0, const Offset& o1,
|
||||
const Offset& o2, const Offset& no0,
|
||||
|
|
@ -213,6 +220,10 @@ public:
|
|||
no[2] = no2;
|
||||
}
|
||||
|
||||
void set_offset(int k, Offset new_o) {
|
||||
o[k] = new_o;
|
||||
}
|
||||
|
||||
void set_vertices() {
|
||||
V[0] = V[1] = V[2] = Vertex_handle();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue