Made all members of the cell-extension records unique (e.g., added 'env_'); this enables the simultaneous extensions required by other packages; for example, having a lower envelope diagram with history.

This commit is contained in:
Efi Fogel 2024-01-30 14:48:59 +02:00
parent 09761aa0c3
commit b6fb9a5aa1
8 changed files with 823 additions and 888 deletions

View File

@ -166,21 +166,21 @@ public:
// get a face with 2 surfaces defined over it, and compute the arrangement
// of the/ envelope of these surfaces over the face
void resolve(Face_handle face, Minimization_diagram_2& result) {
CGAL_assertion(face->get_aux_is_set(0));
CGAL_assertion(face->get_aux_is_set(1));
CGAL_assertion(face->aux_is_set(0));
CGAL_assertion(face->aux_is_set(1));
// we are interested with the envelope's shape over the current face,
// so we only need to check the first surface from each group, since
// all the surfaces in a group overlap over the current face.
const Xy_monotone_surface_3& surf1 = get_aux_surface(face, 0);
const Xy_monotone_surface_3& surf2 = get_aux_surface(face, 1);
const Xy_monotone_surface_3& surf1 = aux_surface(face, 0);
const Xy_monotone_surface_3& surf2 = aux_surface(face, 1);
// find the projected intersections of the surfaces. if none - we have
// a simple case:
// need only resolve non-intersecting and return
std::list<std::variant<Intersection_curve, Point_2>> inter_objs;
get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs));
projected_intersections(surf1, surf2, std::back_inserter(inter_objs));
if (inter_objs.size() == 0) {
// here for resolve we can compare the surfaces over the edges only
@ -234,7 +234,7 @@ public:
// projected intersection that created it.
Halfedges_w_type_list result_new_edges;
// 3. the collection of faces that form the face before any insertion
Faces_list result_face_parts;
Faces_list result_face_parts;
// 4. the collection of special vertices, which contains:
// - new vertices that were created inside the original face
// (both isolated and not isolated)
@ -289,8 +289,7 @@ public:
// in order to use resolve_minimal_face with intersection halfedge, we
// go over the new edges, and set data over their faces
typename Halfedges_w_type_list::iterator new_edge_it;
for (new_edge_it = result_new_edges.begin();
for (auto new_edge_it = result_new_edges.begin();
new_edge_it != result_new_edges.end(); ++new_edge_it) {
Halfedge_handle new_he = (*new_edge_it).first;
Halfedge_handle new_he_twin = new_he->twin();
@ -298,10 +297,10 @@ public:
Multiplicity itype = (*new_edge_it).second;
#endif
// set sources of the new edge
new_he->set_aux_source(0, face->get_aux_source(0));
new_he->set_aux_source(1, face->get_aux_source(1));
new_he_twin->set_aux_source(0, face->get_aux_source(0));
new_he_twin->set_aux_source(1, face->get_aux_source(1));
new_he->set_aux_source(0, face->aux_source(0));
new_he->set_aux_source(1, face->aux_source(1));
new_he_twin->set_aux_source(0, face->aux_source(0));
new_he_twin->set_aux_source(1, face->aux_source(1));
// set data on new edges
new_he->set_decision(EQUAL);
@ -312,7 +311,7 @@ public:
// to f1, not only the opposite
Face_handle f1 = new_he->face(), f2 = new_he_twin->face();
Comparison_result res;
if (! f1->is_decision_set() && !f2->is_decision_set()) {
if (! f1->is_decision_set() && ! f2->is_decision_set()) {
res = resolve_minimal_face(f1, &new_he);
copy_data_by_comparison_result(face, f1, res);
}
@ -324,7 +323,7 @@ public:
if (! f2->is_decision_set()) {
#ifdef CGAL_ENVELOPE_SAVE_COMPARISONS
if (itype != 0) {
res = convert_decision_to_comparison_result(f1->get_decision());
res = convert_decision_to_comparison_result(f1->decision());
res = resolve_by_intersection_type(res, itype);
CGAL_expensive_assertion_code
(Comparison_result tmp_res =
@ -340,7 +339,7 @@ public:
if (! f1->is_decision_set()) {
#ifdef CGAL_ENVELOPE_SAVE_COMPARISONS
if (itype != 0) {
res = convert_decision_to_comparison_result(f2->get_decision());
res = convert_decision_to_comparison_result(f2->decision());
res = resolve_by_intersection_type(res, itype);
CGAL_expensive_assertion_code
(Comparison_result tmp_res = resolve_minimal_face(f1, &new_he));
@ -357,8 +356,7 @@ public:
// we also need to check the faces incident to the halfedges in
// special_edges since the envelope data over them should be computed
// using compare_left/right versions
Halfedges_list_iterator special_edge_it;
for (special_edge_it = result_special_edges.begin();
for (auto special_edge_it = result_special_edges.begin();
special_edge_it != result_special_edges.end(); ++special_edge_it) {
// we assume that the halfedge given points to the correct face
// (which is inside the original face)
@ -372,17 +370,17 @@ public:
// take care for the edge, if necessary
if (! special_he->is_decision_set() &&
can_copy_decision_from_face_to_edge(special_he)) {
// if (!special_he->get_aux_is_set(0) || !special_he->get_aux_is_set(1))
// if (!special_he->aux_is_set(0) || !special_he->aux_is_set(1))
// {
// // this can only happen when the edge is fake, since the edge is on
//// the face's boundary
// CGAL_assertion(special_he->get_is_fake());
// special_he->set_aux_source(0, face->get_aux_source(0));
// special_he->set_aux_source(1, face->get_aux_source(1));
// special_he->twin()->set_aux_source(0, face->get_aux_source(0));
// special_he->twin()->set_aux_source(1, face->get_aux_source(1));
// CGAL_assertion(special_he->is_fake());
// special_he->set_aux_source(0, face->aux_source(0));
// special_he->set_aux_source(1, face->aux_source(1));
// special_he->twin()->set_aux_source(0, face->aux_source(0));
// special_he->twin()->set_aux_source(1, face->aux_source(1));
// }
//if (special_he->get_is_fake())
//if (special_he->is_fake())
//{
// // this edge is not fake anymore, as it coincides with a projected
// // intersection
@ -400,22 +398,19 @@ public:
++special_vertex_it) {
Vertex_handle special_v = *special_vertex_it;
if (! special_v->is_decision_set()) {
if (special_v->get_aux_is_set(0) && special_v->get_aux_is_set(1))
if (special_v->aux_is_set(0) && special_v->aux_is_set(1))
set_data_by_comparison_result(special_v, EQUAL);
else
// this is a new vertex inside the face, so we need to update its
// aux source information from face also (done in method)
copy_all_data_to_vertex(face, special_v);
}
else
CGAL_assertion(special_v->get_aux_is_set(0) && \
special_v->get_aux_is_set(1));
else CGAL_assertion(special_v->aux_is_set(0) && special_v->aux_is_set(1));
}
// assert all new faces got data set, if not, then maybe no curve cuts
// the face, and should use regular resolve_minimal_face
typename std::list<Face_handle>::iterator new_face_it;
for (new_face_it = result_face_parts.begin();
for (auto new_face_it = result_face_parts.begin();
new_face_it != result_face_parts.end(); ++new_face_it) {
Face_handle new_face = *new_face_it;
if (! new_face->is_decision_set()) {
@ -433,12 +428,12 @@ public:
// get an edge with 2 surfaces defined over it, and split it to get the shape
// of the envelope of these surfaces over the edge
void resolve(Halfedge_handle edge, Minimization_diagram_2& result) {
const Xy_monotone_surface_3& surf1 = get_aux_surface(edge, 0);
const Xy_monotone_surface_3& surf2 = get_aux_surface(edge, 1);
const Xy_monotone_surface_3& surf1 = aux_surface(edge, 0);
const Xy_monotone_surface_3& surf2 = aux_surface(edge, 1);
// find the projected intersections
std::list<std::variant<Intersection_curve, Point_2>> inter_objs;
get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs));
projected_intersections(surf1, surf2, std::back_inserter(inter_objs));
if (inter_objs.size() == 0) {
resolve_minimal_edge(edge, edge);
@ -560,8 +555,7 @@ public:
(original_src->is_at_open_boundary() && is_min_end_at_inf))
{
source_is_special = true;
if (split_points.front().third == true)
overlaps++;
if (split_points.front().third == true) ++overlaps;
}
// check if target is a special vertex, by checking the last point in
@ -687,8 +681,8 @@ public:
void resolve(Vertex_handle vertex) {
// it is enough to compare only one surface from each group (because they
// all overlap over the vertex), but set all the group
const Xy_monotone_surface_3& surf1 = get_aux_surface(vertex, 0);
const Xy_monotone_surface_3& surf2 = get_aux_surface(vertex, 1);
const Xy_monotone_surface_3& surf1 = aux_surface(vertex, 0);
const Xy_monotone_surface_3& surf2 = aux_surface(vertex, 1);
const Point_2& point_2 = vertex->point();
Comparison_result cur_res =
compare_distance_to_envelope(point_2, surf1, surf2);
@ -754,8 +748,8 @@ protected:
if (success) return res;
const Xy_monotone_surface_3& surf1 = get_aux_surface(face, 0);
const Xy_monotone_surface_3& surf2 = get_aux_surface(face, 1);
const Xy_monotone_surface_3& surf1 = aux_surface(face, 0);
const Xy_monotone_surface_3& surf2 = aux_surface(face, 1);
Ccb_halfedge_circulator hec;
if (he == nullptr) {
@ -767,7 +761,7 @@ protected:
Ccb_halfedge_circulator curr = hec;
do {
Halfedge_handle he = hec;
if(he->is_fictitious()) ++hec;
if (he->is_fictitious()) ++hec;
else {
found_edge = true;
const X_monotone_curve_2& cv = hec->curve();
@ -775,7 +769,7 @@ protected:
break;
}
}
while(curr != hec);
while (curr != hec);
}
if (! found_edge) {
@ -801,7 +795,7 @@ protected:
CGAL_assertion_code(Ccb_halfedge_circulator hec_begin = hec;
++hec;
while (hec != hec_begin) {
if(hec->is_fictitious()) {
if (hec->is_fictitious()) {
++hec;
continue;
}
@ -857,9 +851,9 @@ protected:
// find intersections between 2 xy-monotone surfaces
// use caching for repeating questions of same pair of surfaces
template <typename OutputIterator>
OutputIterator get_projected_intersections(const Xy_monotone_surface_3& s1,
const Xy_monotone_surface_3& s2,
OutputIterator o) {
OutputIterator projected_intersections(const Xy_monotone_surface_3& s1,
const Xy_monotone_surface_3& s2,
OutputIterator o) {
return m_traits->construct_projected_intersections_2_object()(s1, s2, o);
}
@ -893,9 +887,8 @@ protected:
// helper method to get the surfaces we need to work on
template <typename FeatureHandle>
const Xy_monotone_surface_3& get_aux_surface(FeatureHandle fh,
unsigned int id) {
const Object& o = fh->get_aux_source(id);
const Xy_monotone_surface_3& aux_surface(FeatureHandle fh, unsigned int id) {
const Object& o = fh->aux_source(id);
CGAL_assertion(!o.is_empty());
// aux source of a face must be a face!
@ -904,30 +897,30 @@ protected:
// this is why we start with a check for a face, then halfedge
// and last vertex
Face_handle f;
if (assign(f, o)) return f->get_env_data();
if (assign(f, o)) return f->env_data_front();
Halfedge_handle h;
if (assign(h, o)) return h->get_env_data();
if (assign(h, o)) return h->env_data_front();
Vertex_handle v;
CGAL_assertion_code(bool b =)
assign(v, o);
CGAL_assertion(b);
return v->get_env_data();
return v->env_data_front();
}
bool can_copy_decision_from_face_to_edge(Halfedge_handle h) {
// can copy decision from face to its incident edge if the aux
// envelopes are continuous over the face and edge
return (h->get_has_equal_aux_data_in_face(0) &&
h->get_has_equal_aux_data_in_face(1));
return (h->has_equal_aux_data_in_face(0) &&
h->has_equal_aux_data_in_face(1));
}
bool can_copy_decision_from_edge_to_vertex(Halfedge_handle h) {
// can copy decision from face to its incident edge if the aux
// envelopes are continuous over the face and edge
return (h->get_has_equal_aux_data_in_target(0) &&
h->get_has_equal_aux_data_in_target(1));
return (h->has_equal_aux_data_in_target(0) &&
h->has_equal_aux_data_in_target(1));
}
@ -957,7 +950,7 @@ protected:
if (! vh->is_decision_set() && has_equal_aux_data_with_face(vh))
// can copy the data from the face, since we already took care of
// the vertices of projected intersections
vh->set_decision(face->get_decision());
vh->set_decision(face->decision());
}
}
@ -966,21 +959,18 @@ protected:
Ccb_halfedge_circulator hec_begin = hec;
do {
Halfedge_handle hh = hec;
if (hh->is_fictitious()) {
++hec;
continue;
}
if (hh->is_fictitious()) continue;
CGAL_assertion(face == hh->face());
// if it is a vertical decomposition edge, copy data from face
/*if (!hh->is_decision_set() && hh->get_is_fake())
{
hh->set_decision(face->get_decision());
hh->twin()->set_decision(face->get_decision());
}*/
/* if (!hh->is_decision_set() && hh->is_fake()) {
* hh->set_decision(face->decision());
* hh->twin()->set_decision(face->decision());
* }
*/
if (! hh->is_decision_set() && can_copy_decision_from_face_to_edge(hh)) {
// copy the decision from face to the edge
hh->set_decision(face->get_decision());
hh->twin()->set_decision(hh->get_decision());
hh->set_decision(face->decision());
hh->twin()->set_decision(hh->decision());
}
// TODO: is this correct? shouldn't we split the edge first?
// I think it is correct, because there is no intersection (of
@ -992,19 +982,18 @@ protected:
// from the face to the edge, the envelope goes closer), then if the
// second map wins on the face, it wins on the edge also
else if (! hh->is_decision_set() &&
face->get_decision() == DAC_DECISION_SECOND &&
hh->get_has_equal_aux_data_in_face(0) &&
! hh->get_has_equal_aux_data_in_face(1)) {
face->decision() == DAC_DECISION_SECOND &&
hh->has_equal_aux_data_in_face(0) &&
! hh->has_equal_aux_data_in_face(1)) {
hh->set_decision(DAC_DECISION_SECOND);
hh->twin()->set_decision(DAC_DECISION_SECOND);
}
// if the second map is continuous, but the first isn't, then if the
// first map wins on the face, it wins on the edge also
else if (! hh->is_decision_set() &&
face->get_decision() == DAC_DECISION_FIRST &&
! hh->get_has_equal_aux_data_in_face(0) &&
hh->get_has_equal_aux_data_in_face(1)) {
face->decision() == DAC_DECISION_FIRST &&
! hh->has_equal_aux_data_in_face(0) &&
hh->has_equal_aux_data_in_face(1)) {
hh->set_decision(DAC_DECISION_FIRST);
hh->twin()->set_decision(DAC_DECISION_FIRST);
}
@ -1014,9 +1003,7 @@ protected:
// conclude from one edge, bt can conclude from the other
conclude_decision_to_vertex(hh->source(), hh->twin(), face, false);
conclude_decision_to_vertex(hh->target(), hh, face, true);
hec++;
} while(hec != hec_begin);
} while (++hec != hec_begin);
}
// try to conclude the decision from the halfedge or the face to the vertex
@ -1028,23 +1015,23 @@ protected:
Face_handle fh, bool try_vertex_face) {
if (vh->is_decision_set()) return;
// first, we try to copy decision from edge, then from face
// first, we try to copy decision from edge, then from face
if (hh->is_decision_set() && can_copy_decision_from_edge_to_vertex(hh))
vh->set_decision(hh->get_decision());
vh->set_decision(hh->decision());
// if the first map is continuous, but the second isn't (i.e. when we move
// from the edge to the vertex, the envelope goes closer), then if the
// second map wins on the edge, it wins on the vertex also
else if (hh->get_decision() == DAC_DECISION_SECOND &&
hh->get_has_equal_aux_data_in_target(0) &&
! hh->get_has_equal_aux_data_in_target(1))
else if (hh->decision() == DAC_DECISION_SECOND &&
hh->has_equal_aux_data_in_target(0) &&
! hh->has_equal_aux_data_in_target(1))
vh->set_decision(DAC_DECISION_SECOND);
// if the second map is continuous, but the first isn't, then if the
// first map wins on the edge, it wins on the vertex also
else if (hh->get_decision() == DAC_DECISION_FIRST &&
! hh->get_has_equal_aux_data_in_target(0) &&
hh->get_has_equal_aux_data_in_target(1))
else if (hh->decision() == DAC_DECISION_FIRST &&
! hh->has_equal_aux_data_in_target(0) &&
hh->has_equal_aux_data_in_target(1))
vh->set_decision(DAC_DECISION_FIRST);
// check if we can copy from the face
@ -1056,15 +1043,17 @@ protected:
if (has_equal_aux_data_in_target_and_face(hh)) {
// can copy the data from the face, since we already took care of
// the vertices of projected intersections
vh->set_decision(fh->get_decision());
vh->set_decision(fh->decision());
}
}
}
// todo: this is for checking
template <typename InputIterator>
bool has_equal_data(const InputIterator& begin1, const InputIterator& end1,
const InputIterator& begin2, const InputIterator& end2) {
bool has_equal_env_data(const InputIterator& begin1,
const InputIterator& end1,
const InputIterator& begin2,
const InputIterator& end2) {
// insert the input data objects into a set
std::set<Xy_monotone_surface_3> first(begin1, end1);
std::set<Xy_monotone_surface_3> second(begin2, end2);
@ -1078,29 +1067,29 @@ protected:
// todo: this is for checking
template <typename FeatureHandle>
void get_aux_data_iterators(unsigned int id, FeatureHandle fh,
Envelope_data_iterator& begin,
Envelope_data_iterator& end) {
void aux_data_iterators(unsigned int id, FeatureHandle fh,
Envelope_data_iterator& begin,
Envelope_data_iterator& end) {
Halfedge_handle h;
Vertex_handle v;
Face_handle f;
const Object& o = fh->get_aux_source(id);
const Object& o = fh->aux_source(id);
CGAL_assertion(!o.is_empty());
if (assign(v, o)) {
begin = v->begin_data();
end = v->end_data();
begin = v->begin_env_data();
end = v->end_env_data();
}
else if (assign(h, o)) {
begin = h->begin_data();
end = h->end_data();
begin = h->begin_env_data();
end = h->end_env_data();
}
else {
CGAL_assertion(assign(f, o));
assign(f, o);
begin = f->begin_data();
end = f->end_data();
begin = f->begin_env_data();
end = f->end_env_data();
}
}
@ -1109,9 +1098,9 @@ protected:
bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1,
FeatureHandle2 fh2) {
Envelope_data_iterator begin1, end1, begin2, end2;
get_aux_data_iterators(id, fh1, begin1, end1);
get_aux_data_iterators(id, fh2, begin2, end2);
bool has_eq = has_equal_data(begin1, end1, begin2, end2);
aux_data_iterators(id, fh1, begin1, end1);
aux_data_iterators(id, fh2, begin2, end2);
bool has_eq = has_equal_env_data(begin1, end1, begin2, end2);
return has_eq;
}
@ -1122,7 +1111,6 @@ protected:
has_equal_aux_data(1, fh1, fh2));
}
// check if we can copy the decision made on a boundary edge to the face
// if so, res will contain this decision's comparison result
bool can_copy_decision_from_boundary_edge(Face_handle face,
@ -1138,37 +1126,33 @@ protected:
hec_begin = hec;
do {
Halfedge_handle hh = hec;
if(hh->is_fictitious()) {
++hec;
continue;
}
if (hh->is_fictitious()) continue;
if (can_copy_decision_from_face_to_edge(hh) &&
hh->is_decision_set() &&
hh->get_decision() != DAC_DECISION_BOTH) {
res = convert_decision_to_comparison_result(hh->get_decision());
hh->decision() != DAC_DECISION_BOTH) {
res = convert_decision_to_comparison_result(hh->decision());
result = true;
}
// if the first map is continuous, but the second isn't (i.e. when we
// move from the edge to the face, the envelope goes farther), then
// if the first map wins on the edge, it wins on the face also
else if (hh->is_decision_set() &&
hh->get_decision() == DAC_DECISION_FIRST &&
hh->get_has_equal_aux_data_in_face(0) &&
! hh->get_has_equal_aux_data_in_face(1)) {
hh->decision() == DAC_DECISION_FIRST &&
hh->has_equal_aux_data_in_face(0) &&
! hh->has_equal_aux_data_in_face(1)) {
res = convert_decision_to_comparison_result(DAC_DECISION_FIRST);
result = true;
}
// if the second map is continuous, but the first isn't, then if the
// second map wins on the edge, it wins on the face also
else if (hh->is_decision_set() &&
hh->get_decision() == DAC_DECISION_SECOND &&
!hh->get_has_equal_aux_data_in_face(0) &&
hh->get_has_equal_aux_data_in_face(1)) {
hh->decision() == DAC_DECISION_SECOND &&
!hh->has_equal_aux_data_in_face(0) &&
hh->has_equal_aux_data_in_face(1)) {
res = convert_decision_to_comparison_result(DAC_DECISION_SECOND);
result = true;
}
hec++;
} while(hec != hec_begin && !result);
} while ((++hec != hec_begin) && ! result);
if (result) return true;
}
@ -1182,33 +1166,30 @@ protected:
Halfedge_handle hh = hec;
if (can_copy_decision_from_face_to_edge(hh) &&
hh->is_decision_set() &&
hh->get_decision() != DAC_DECISION_BOTH) {
res = convert_decision_to_comparison_result(hh->get_decision());
hh->decision() != DAC_DECISION_BOTH) {
res = convert_decision_to_comparison_result(hh->decision());
result = true;
}
// if the first map is continuous, but the second isn't (i.e. when we
// move from the edge to the face, the envelope goes farther), then
// if the first map wins on the edge, it wins on the face also
else if (hh->is_decision_set() &&
hh->get_decision() == DAC_DECISION_FIRST &&
hh->get_has_equal_aux_data_in_face(0) &&
! hh->get_has_equal_aux_data_in_face(1)) {
hh->decision() == DAC_DECISION_FIRST &&
hh->has_equal_aux_data_in_face(0) &&
! hh->has_equal_aux_data_in_face(1)) {
res = convert_decision_to_comparison_result(DAC_DECISION_FIRST);
result = true;
}
// if the second map is continuous, but the first isn't, then if the
// second map wins on the edge, it wins on the face also
else if (hh->is_decision_set() &&
hh->get_decision() == DAC_DECISION_SECOND &&
! hh->get_has_equal_aux_data_in_face(0) &&
hh->get_has_equal_aux_data_in_face(1)) {
hh->decision() == DAC_DECISION_SECOND &&
! hh->has_equal_aux_data_in_face(0) &&
hh->has_equal_aux_data_in_face(1)) {
res = convert_decision_to_comparison_result(DAC_DECISION_SECOND);
result = true;
}
hec++;
} while(hec != hec_begin && !result);
} while ((++hec != hec_begin) && ! result);
if (result) return true;
}
@ -1228,13 +1209,13 @@ protected:
bool has_equal_aux_data_with_face(Vertex_handle v) {
CGAL_assertion(v->is_isolated());
return (v->get_has_equal_aux_data_in_face(0) &&
v->get_has_equal_aux_data_in_face(1));
return (v->has_equal_aux_data_in_face(0) &&
v->has_equal_aux_data_in_face(1));
}
bool has_equal_aux_data_in_target_and_face(Halfedge_handle h) {
return (h->get_has_equal_aux_data_in_target_and_face(0) &&
h->get_has_equal_aux_data_in_target_and_face(1));
return (h->has_equal_aux_data_in_target_and_face(0) &&
h->has_equal_aux_data_in_target_and_face(1));
}
// check the aux data on the endpoint vertices of the edge
@ -1246,20 +1227,20 @@ protected:
can_copy_decision_from_edge_to_vertex(edge->twin()))
// can copy the data from the edge, since we already took care of
// the vertices of projected intersections
edge->source()->set_decision(edge->get_decision());
edge->source()->set_decision(edge->decision());
// if the first map is continuous, but the second isn't (i.e. when we move
// from the edge to the vertex, the envelope goes closer), then if the
// second map wins on the edge, it wins on the vertex also
else if (edge->get_decision() == DAC_DECISION_SECOND &&
edge->twin()->get_has_equal_aux_data_in_target(0) &&
!edge->twin()->get_has_equal_aux_data_in_target(1)) {
else if (edge->decision() == DAC_DECISION_SECOND &&
edge->twin()->has_equal_aux_data_in_target(0) &&
!edge->twin()->has_equal_aux_data_in_target(1)) {
edge->source()->set_decision(DAC_DECISION_SECOND);
}
// if the second map is continuous, but the first isn't, then if the
// first map wins on the edge, it wins on the vertex also
else if (edge->get_decision() == DAC_DECISION_FIRST &&
!edge->twin()->get_has_equal_aux_data_in_target(0) &&
edge->twin()->get_has_equal_aux_data_in_target(1)) {
else if (edge->decision() == DAC_DECISION_FIRST &&
!edge->twin()->has_equal_aux_data_in_target(0) &&
edge->twin()->has_equal_aux_data_in_target(1)) {
edge->source()->set_decision(DAC_DECISION_FIRST);
}
@ -1268,20 +1249,20 @@ protected:
can_copy_decision_from_edge_to_vertex(edge))
// can copy the data from the edge, since we already took care of
// the vertices of projected intersections
edge->target()->set_decision(edge->get_decision());
edge->target()->set_decision(edge->decision());
// if the first map is continuous, but the second isn't (i.e. when we move
// from the edge to the vertex, the envelope goes closer), then if the
// second map wins on the edge, it wins on the vertex also
else if (edge->get_decision() == DAC_DECISION_SECOND &&
edge->get_has_equal_aux_data_in_target(0) &&
!edge->get_has_equal_aux_data_in_target(1)) {
else if (edge->decision() == DAC_DECISION_SECOND &&
edge->has_equal_aux_data_in_target(0) &&
!edge->has_equal_aux_data_in_target(1)) {
edge->target()->set_decision(DAC_DECISION_SECOND);
}
// if the second map is continuous, but the first isn't, then if the
// first map wins on the edge, it wins on the vertex also
else if (edge->get_decision() == DAC_DECISION_FIRST &&
!edge->get_has_equal_aux_data_in_target(0) &&
edge->get_has_equal_aux_data_in_target(1)) {
else if (edge->decision() == DAC_DECISION_FIRST &&
!edge->has_equal_aux_data_in_target(0) &&
edge->has_equal_aux_data_in_target(1)) {
edge->target()->set_decision(DAC_DECISION_FIRST);
}
}
@ -1454,8 +1435,7 @@ protected:
CGAL_assertion(tmp == copied_prev_v2);
bool new_face;
if (is_outer_ccb)
{
if (is_outer_ccb) {
// if it is the first face created, and the last halfedge to
// insert, this is a regular outer ccb, with no special
// degeneracies (around the current vertices, at least)
@ -1469,8 +1449,8 @@ protected:
copied_prev_v2->next(),
new_face,
dummy_swapped_predecessors);
// TODO EBEB 2012-08-06 do we have to care if order has been swapped,
// or do we have to disallow swapping?
// TODO EBEB 2012-08-06 do we have to care if order has been
// swapped, or do we have to disallow swapping?
CGAL_assertion(new_face);
}
@ -1503,8 +1483,8 @@ protected:
copied_prev_he->next(),
new_face,
dummy_swapped_predecessors);
// TODO EBEB 2012-08-06 do we have to care if order has been swapped,
// or do we have to disallow swapping?
// TODO EBEB 2012-08-06 do we have to care if order has been
// swapped, or do we have to disallow swapping?
CGAL_assertion(new_face);
copied_new_he = copied_new_he->twin();
@ -1522,9 +1502,7 @@ protected:
copied_prev_he = copied_new_he;
}
}
hec++;
} while(hec != hec_begin);
} while (++hec != hec_begin);
}
void copy_ccb_unbounded(Ccb_halfedge_circulator hec,
@ -1543,8 +1521,7 @@ protected:
non_fict = hec;
break;
}
++hec;
} while(hec != hec_end);
} while (++hec != hec_end);
// Find an anchor halfedge he_from along the original CCB and locate
// its image he_to in the target CCB.
@ -1712,26 +1689,26 @@ protected:
// aux data of face "from"
void copy_data_by_comparison_result(Face_handle from, Face_handle to,
Comparison_result res) {
CGAL_assertion_msg(from->get_aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(from->get_aux_is_set(1), "aux_data(1) is not set");
to->set_aux_source(0, from->get_aux_source(0));
to->set_aux_source(1, from->get_aux_source(1));
CGAL_assertion_msg(from->aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(from->aux_is_set(1), "aux_data(1) is not set");
to->set_aux_source(0, from->aux_source(0));
to->set_aux_source(1, from->aux_source(1));
to->set_decision(res);
}
// set envelope data in vertex "v" according to the comparison result of the
// aux data of "v"
void set_data_by_comparison_result(Vertex_handle v, Comparison_result res) {
CGAL_assertion_msg(v->get_aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(v->get_aux_is_set(1), "aux_data(1) is not set");
CGAL_assertion_msg(v->aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(v->aux_is_set(1), "aux_data(1) is not set");
v->set_decision(res);
}
// set envelope data in halfedge "h" according to the comparison result of
// the aux data of "h"
void set_data_by_comparison_result(Halfedge_handle h, Comparison_result res) {
CGAL_assertion_msg(h->get_aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(h->get_aux_is_set(1), "aux_data(1) is not set");
CGAL_assertion_msg(h->aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(h->aux_is_set(1), "aux_data(1) is not set");
h->set_decision(res);
}
@ -1741,38 +1718,38 @@ protected:
// Vertex_handle
template <typename FeatureHabdle>
void copy_all_data_to_vertex(FeatureHabdle from, Vertex_handle to) {
CGAL_assertion_msg(from->get_aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(from->get_aux_is_set(1), "aux_data(1) is not set");
CGAL_assertion_msg(from->aux_is_set(0), "aux_data(0) is not set");
CGAL_assertion_msg(from->aux_is_set(1), "aux_data(1) is not set");
CGAL_assertion_msg(!to->is_decision_set(), "data is set in new vertex");
to->set_aux_source(0, from->get_aux_source(0));
to->set_aux_source(1, from->get_aux_source(1));
to->set_aux_source(0, from->aux_source(0));
to->set_aux_source(1, from->aux_source(1));
to->set_decision(EQUAL);
}
// void deal_with_new_vertex(Halfedge_handle orig_he, Vertex_handle new_v)
// {
// const Xy_monotone_surface_3& surf1 = get_aux_surface(orig_he, 0);
// const Xy_monotone_surface_3& surf2 = get_aux_surface(orig_he, 1);
// const Xy_monotone_surface_3& surf1 = aux_surface(orig_he, 0);
// const Xy_monotone_surface_3& surf2 = aux_surface(orig_he, 1);
// const Point_2& p = new_v->point();
// Comparison_result res = compare_distance_to_envelope(p, surf1, surf2);
// new_v->set_aux_source(0, orig_he->get_aux_source(0));
// new_v->set_aux_source(1, orig_he->get_aux_source(1));
// new_v->set_aux_source(0, orig_he->aux_source(0));
// new_v->set_aux_source(1, orig_he->aux_source(1));
// new_v->set_decision(res);
// }
Comparison_result resolve_minimal_edge(Halfedge_handle orig_he,
Halfedge_handle new_he) {
// find and set the envelope data on the new edge
const Xy_monotone_surface_3& surf1 = get_aux_surface(orig_he, 0);
const Xy_monotone_surface_3& surf2 = get_aux_surface(orig_he, 1);
const Xy_monotone_surface_3& surf1 = aux_surface(orig_he, 0);
const Xy_monotone_surface_3& surf2 = aux_surface(orig_he, 1);
Comparison_result res =
compare_distance_to_envelope(new_he->curve(), surf1, surf2);
// the observer keeps this information when splitting an edge
CGAL_assertion(new_he->get_aux_is_set(0) && new_he->get_aux_is_set(1));
CGAL_assertion(new_he->twin()->get_aux_is_set(0) && \
new_he->twin()->get_aux_is_set(1));
CGAL_assertion(new_he->aux_is_set(0) && new_he->aux_is_set(1));
CGAL_assertion(new_he->twin()->aux_is_set(0) && \
new_he->twin()->aux_is_set(1));
new_he->set_decision(res);
new_he->twin()->set_decision(res);
@ -1856,8 +1833,8 @@ protected:
CGAL_assertion(map_halfedges.is_defined(org_he));
CGAL_assertion(org_he->target() == new_he->source());
if ((map_halfedges[org_he])->get_has_equal_aux_data_in_face(0) &&
(map_halfedges[org_he])->get_has_equal_aux_data_in_face(1))
if ((map_halfedges[org_he])->has_equal_aux_data_in_face(0) &&
(map_halfedges[org_he])->has_equal_aux_data_in_face(1))
(*special_vertices)[org_he->target()] =
special_vertices->default_value();
@ -1882,8 +1859,9 @@ protected:
(*vertices_to_halfedges)[org_he->target()] = correct_side_he;
//BZBZ
/* CGAL_assertion(vertices_to_halfedges->is_defined(correct_side_he->source()) &&
vertices_to_halfedges->is_defined(correct_side_he->next()->target()));*/
// CGAL_assertion
// (vertices_to_halfedges->is_defined(correct_side_he->source()) &&
// vertices_to_halfedges->is_defined(correct_side_he->next()->target()));
(*vertices_to_halfedges)[correct_side_he->next()->target()] =
correct_side_he->next();
@ -2435,8 +2413,7 @@ protected:
Vertex_handle left_v, Halfedge_handle left_he,
Vertex_handle right_v, Halfedge_handle right_he) {
// insert the curve only if the face is ok
if (is_face_ok(face))
{
if (is_face_ok(face)) {
CGAL_assertion(copied_arr.is_valid());
Result base_result = insert_visitor.found_subcurve(cv, face,
left_v, left_he,
@ -2486,17 +2463,17 @@ protected:
// since we have in the new edge aux sources as in the face,
// we can copy the vertex-face flags from the vertex
result_new_he->set_is_equal_aux_data_in_target
(0, cur_t->get_is_equal_aux_data_in_face(0));
(0, cur_t->is_equal_aux_data_in_face(0));
result_new_he->set_is_equal_aux_data_in_target
(1, cur_t->get_is_equal_aux_data_in_face(1));
(1, cur_t->is_equal_aux_data_in_face(1));
result_new_he->set_has_equal_aux_data_in_target
(0, cur_t->get_has_equal_aux_data_in_face(0));
(0, cur_t->has_equal_aux_data_in_face(0));
result_new_he->set_has_equal_aux_data_in_target
(1, cur_t->get_has_equal_aux_data_in_face(1));
(1, cur_t->has_equal_aux_data_in_face(1));
result_new_he->set_has_equal_aux_data_in_target_and_face
(0, cur_t->get_has_equal_aux_data_in_face(0));
(0, cur_t->has_equal_aux_data_in_face(0));
result_new_he->set_has_equal_aux_data_in_target_and_face
(1, cur_t->get_has_equal_aux_data_in_face(1));
(1, cur_t->has_equal_aux_data_in_face(1));
}
else {
CGAL_assertion(copied_b_he->target() == cur_t);
@ -2505,20 +2482,20 @@ protected:
bool flag;
flag = (b_he->get_is_equal_aux_data_in_face(0) &&
b_he->get_is_equal_aux_data_in_target(0));
flag = (b_he->is_equal_aux_data_in_face(0) &&
b_he->is_equal_aux_data_in_target(0));
result_new_he->set_is_equal_aux_data_in_target(0, flag);
flag = (b_he->get_is_equal_aux_data_in_face(1) &&
b_he->get_is_equal_aux_data_in_target(1));
flag = (b_he->is_equal_aux_data_in_face(1) &&
b_he->is_equal_aux_data_in_target(1));
result_new_he->set_is_equal_aux_data_in_target(1, flag);
flag = b_he->get_has_equal_aux_data_in_target_and_face(0);
flag = b_he->has_equal_aux_data_in_target_and_face(0);
//CGAL_assertion(flag == parent->has_equal_aux_data(0, b_he->face(), b_he->target()));
result_new_he->set_has_equal_aux_data_in_target(0, flag);
result_new_he->set_has_equal_aux_data_in_target_and_face(0, flag);
flag = b_he->get_has_equal_aux_data_in_target_and_face(1);
flag = b_he->has_equal_aux_data_in_target_and_face(1);
//CGAL_assertion(flag == parent->has_equal_aux_data(1, b_he->face(), b_he->target()));
result_new_he->set_has_equal_aux_data_in_target(1, flag);
result_new_he->set_has_equal_aux_data_in_target_and_face(1, flag);
@ -2544,17 +2521,17 @@ protected:
// since we have in the new edge aux sources as in the face,
// we can copy the vertex-face flags from the vertex
result_new_he->twin()->set_is_equal_aux_data_in_target
(0, cur_t->get_is_equal_aux_data_in_face(0));
(0, cur_t->is_equal_aux_data_in_face(0));
result_new_he->twin()->set_is_equal_aux_data_in_target
(1, cur_t->get_is_equal_aux_data_in_face(1));
(1, cur_t->is_equal_aux_data_in_face(1));
result_new_he->twin()->set_has_equal_aux_data_in_target
(0, cur_t->get_has_equal_aux_data_in_face(0));
(0, cur_t->has_equal_aux_data_in_face(0));
result_new_he->twin()->set_has_equal_aux_data_in_target
(1, cur_t->get_has_equal_aux_data_in_face(1));
(1, cur_t->has_equal_aux_data_in_face(1));
result_new_he->twin()->set_has_equal_aux_data_in_target_and_face
(0, cur_t->get_has_equal_aux_data_in_face(0));
(0, cur_t->has_equal_aux_data_in_face(0));
result_new_he->twin()->set_has_equal_aux_data_in_target_and_face
(1, cur_t->get_has_equal_aux_data_in_face(1));
(1, cur_t->has_equal_aux_data_in_face(1));
}
else {
CGAL_assertion(copied_b_he->target() == cur_t);
@ -2562,20 +2539,20 @@ protected:
Halfedge_handle b_he = map_halfedges[copied_b_he];
bool flag;
flag = (b_he->get_is_equal_aux_data_in_face(0) &&
b_he->get_is_equal_aux_data_in_target(0));
flag = (b_he->is_equal_aux_data_in_face(0) &&
b_he->is_equal_aux_data_in_target(0));
result_new_he->twin()->set_is_equal_aux_data_in_target(0, flag);
flag = (b_he->get_is_equal_aux_data_in_face(1) &&
b_he->get_is_equal_aux_data_in_target(1));
flag = (b_he->is_equal_aux_data_in_face(1) &&
b_he->is_equal_aux_data_in_target(1));
result_new_he->twin()->set_is_equal_aux_data_in_target(1, flag);
flag = b_he->get_has_equal_aux_data_in_target_and_face(0);
//CGAL_assertion(flag == parent->has_equal_aux_data(0, b_he->face(), b_he->target()));
flag = b_he->has_equal_aux_data_in_target_and_face(0);
// CGAL_assertion(flag == parent->has_equal_aux_data(0, b_he->face(), b_he->target()));
result_new_he->twin()->set_has_equal_aux_data_in_target(0, flag);
result_new_he->twin()->set_has_equal_aux_data_in_target_and_face(0, flag);
flag = b_he->get_has_equal_aux_data_in_target_and_face(1);
flag = b_he->has_equal_aux_data_in_target_and_face(1);
//CGAL_assertion(flag == parent->has_equal_aux_data(1, b_he->face(), b_he->target()));
result_new_he->twin()->set_has_equal_aux_data_in_target(1, flag);
result_new_he->twin()->set_has_equal_aux_data_in_target_and_face(1, flag);
@ -2898,10 +2875,10 @@ protected:
virtual void after_split_face(Face_handle org_f, Face_handle new_f, bool)
override {
// update the new face's aux_data from original face
if (org_f->get_aux_is_set(0))
new_f->set_aux_source(0, org_f->get_aux_source(0));
if (org_f->get_aux_is_set(1))
new_f->set_aux_source(1, org_f->get_aux_source(1));
if (org_f->aux_is_set(0))
new_f->set_aux_source(0, org_f->aux_source(0));
if (org_f->aux_is_set(1))
new_f->set_aux_source(1, org_f->aux_source(1));
}
};

View File

@ -60,135 +60,117 @@ public:
}
public:
/*
void print_face(Face_handle fh)
{
std::cout << (fh->is_unbounded() ? "unbounded" : "bounded");
if (fh->get_is_set())
{
std::cout << " #data= " << fh->number_of_data_objects();
if (fh->number_of_data_objects() > 0)
std::cout << " data= " << fh->get_env_data();
}
if (fh->get_aux_is_set(0))
{
std::cout << " #data1= " << get_number_of_aux_data_objects(fh, 0);
if (get_number_of_aux_data_objects(fh, 0)>0)
std::cout << " data#1= " << get_aux_data(fh, 0);
}
if (fh->get_aux_is_set(1))
{
std::cout << " #data2= " << get_number_of_aux_data_objects(fh, 1);
if (get_number_of_aux_data_objects(fh, 1)>0)
std::cout << " data#2= " << get_aux_data(fh, 1);
}
std::cout << std::endl;
}
// print the aux data in the faces of md
void print_faces(Minimization_diagram_2& md)
{
Face_iterator fit = md.faces_begin();
for(; fit != md.faces_end(); ++fit)
{
Face_handle fh = fit;
print_face(fh);
}
std::cout << std::endl;
}
void print_vertices(Minimization_diagram_2& md)
{
Vertex_iterator vit = md.vertices_begin();
for(; vit != md.vertices_end(); ++vit)
{
Vertex_handle vh = vit;
std::cout << vh->point();
if (vh->get_is_set())
{
std::cout << " #data= " << vh->number_of_data_objects();
if (vh->number_of_data_objects() > 0)
std::cout << " data= " << vh->get_env_data();
}
if (vh->get_aux_is_set(0))
{
std::cout << " #data1= " << get_number_of_aux_data_objects(vh, 0);
if (get_number_of_aux_data_objects(vh, 0)>0)
std::cout << " data#1= " << get_aux_data(vh, 0);
}
if (vh->get_aux_is_set(1))
{
std::cout << " #data2= " << get_number_of_aux_data_objects(vh, 1);
if (get_number_of_aux_data_objects(vh, 1)>0)
std::cout << " data#2= " << get_aux_data(vh, 1);
}
std::cout << std::endl;
}
std::cout << std::endl;
}
void print_edges(Minimization_diagram_2& md)
{
Halfedge_iterator hit = md.halfedges_begin();
for(; hit != md.halfedges_end(); ++hit, ++hit)
{
Halfedge_handle hh = hit;
std::cout << hh->curve();
if (hh->get_is_set())
{
std::cout << " #data= " << hh->number_of_data_objects();
if (hh->number_of_data_objects() > 0)
std::cout << " data= " << hh->get_env_data();
}
if (hh->get_aux_is_set(0))
{
std::cout << " #data1= " << get_number_of_aux_data_objects(hh, 0);
if (get_number_of_aux_data_objects(hh, 0)>0)
std::cout << " data#1= " << get_aux_data(hh, 0);
}
if (hh->get_aux_is_set(1))
{
std::cout << " #data2= " << get_number_of_aux_data_objects(hh, 1);
if (get_number_of_aux_data_objects(hh, 1)>0)
std::cout << " data#2= " << get_aux_data(hh, 1);
}
std::cout << std::endl;
}
std::cout << std::endl;
}
*/
/* void print_face(Face_handle fh) {
* std::cout << (fh->is_unbounded() ? "unbounded" : "bounded");
*
* if (fh->env_is_set()) {
* std::cout << " #data= " << fh->env_data_size();
* if (fh->env_data_size() > 0)
* std::cout << " data= " << fh->env_data_front();
* }
*
* if (fh->aux_is_set(0)) {
* std::cout << " #data1= " << number_of_aux_data_objects(fh, 0);
* if (number_of_aux_data_objects(fh, 0)>0)
* std::cout << " data#1= " << aux_data(fh, 0);
* }
* if (fh->aux_is_set(1)) {
* std::cout << " #data2= " << number_of_aux_data_objects(fh, 1);
* if (number_of_aux_data_objects(fh, 1)>0)
* std::cout << " data#2= " << aux_data(fh, 1);
* }
* std::cout << std::endl;
* }
*
* // print the aux data in the faces of md
* void print_faces(Minimization_diagram_2& md) {
* Face_iterator fit = md.faces_begin();
* for(; fit != md.faces_end(); ++fit) {
* Face_handle fh = fit;
* print_face(fh);
* }
* std::cout << std::endl;
* }
*
* void print_vertices(Minimization_diagram_2& md) {
* Vertex_iterator vit = md.vertices_begin();
* for(; vit != md.vertices_end(); ++vit) {
* Vertex_handle vh = vit;
* std::cout << vh->point();
*
* if (vh->env_is_set()) {
* std::cout << " #data= " << vh->env_data_size();
* if (vh->env_data_size() > 0)
* std::cout << " data= " << vh->env_data_front();
* }
*
* if (vh->aux_is_set(0)) {
* std::cout << " #data1= " << number_of_aux_data_objects(vh, 0);
* if (number_of_aux_data_objects(vh, 0)>0)
* std::cout << " data#1= " << aux_data(vh, 0);
* }
* if (vh->aux_is_set(1)) {
* std::cout << " #data2= " << number_of_aux_data_objects(vh, 1);
* if (number_of_aux_data_objects(vh, 1)>0)
* std::cout << " data#2= " << aux_data(vh, 1);
* }
* std::cout << std::endl;
* }
* std::cout << std::endl;
* }
*
* void print_edges(Minimization_diagram_2& md) {
* Halfedge_iterator hit = md.halfedges_begin();
* for(; hit != md.halfedges_end(); ++hit, ++hit) {
* Halfedge_handle hh = hit;
* std::cout << hh->curve();
*
* if (hh->env_is_set()) {
* std::cout << " #data= " << hh->env_data_size();
* if (hh->env_data_size() > 0)
* std::cout << " data= " << hh->env_data_front();
* }
*
* if (hh->aux_is_set(0)) {
* std::cout << " #data1= " << number_of_aux_data_objects(hh, 0);
* if (number_of_aux_data_objects(hh, 0)>0)
* std::cout << " data#1= " << aux_data(hh, 0);
* }
* if (hh->aux_is_set(1)) {
* std::cout << " #data2= " << number_of_aux_data_objects(hh, 1);
*
* if (number_of_aux_data_objects(hh, 1)>0)
* std::cout << " data#2= " << aux_data(hh, 1);
* }
* std::cout << std::endl;
* }
* std::cout << std::endl;
* }
*/
void post_test_assertions(Minimization_diagram_2& md) {
// check that all data is filled in result
for (auto fi = md.faces_begin(); fi != md.faces_end(); ++fi) {
Face_handle fh = fi;
CGAL_assertion_msg(fh->get_aux_is_set(0),
CGAL_assertion_msg(fh->aux_is_set(0),
"data from md1 on face is not set");
CGAL_assertion_msg(fh->get_aux_is_set(1),
CGAL_assertion_msg(fh->aux_is_set(1),
"data from md2 on face is not set");
}
for (auto hi = md.halfedges_begin(); hi != md.halfedges_end(); ++hi) {
Halfedge_handle hh = hi;
CGAL_assertion_msg(hh->get_aux_is_set(0),
CGAL_assertion_msg(hh->aux_is_set(0),
"data from md1 on halfedge is not set");
CGAL_assertion_msg(hh->get_aux_is_set(1),
CGAL_assertion_msg(hh->aux_is_set(1),
"data from md2 on halfedge is not set");
}
for (auto vi = md.vertices_begin(); vi != md.vertices_end(); ++vi) {
Vertex_handle vh = vi;
CGAL_assertion_msg(vh->get_aux_is_set(0),
CGAL_assertion_msg(vh->aux_is_set(0),
"data from md1 on vertex is not set");
CGAL_assertion_msg(vh->get_aux_is_set(1),
CGAL_assertion_msg(vh->aux_is_set(1),
"data from md2 on vertex is not set");
}
}
@ -196,37 +178,37 @@ public:
protected:
// helper methods
template <typename FeatureHandle>
Xy_monotone_surface_3 get_aux_data(FeatureHandle fh, unsigned int id) {
const Object& o = fh->get_aux_source(id);
Xy_monotone_surface_3 aux_data(FeatureHandle fh, unsigned int id) {
const Object& o = fh->aux_source(id);
Xy_monotone_surface_3 data;
Halfedge_handle h;
Vertex_handle v;
Face_handle f;
if (assign(v, o)) data = v->get_env_data();
else if (assign(h, o)) data = h->get_env_data();
if (assign(v, o)) data = v->env_data_front();
else if (assign(h, o)) data = h->env_data_front();
else {
CGAL_assertion(assign(f, o));
assign(f, o);
data = f->get_env_data();
data = f->env_data_front();
}
return data;
}
template <typename FeatureHandle>
int get_number_of_aux_data_objects(FeatureHandle fh, unsigned int id) {
const Object& o = fh->get_aux_source(id);
int number_of_aux_data_objects(FeatureHandle fh, unsigned int id) {
const Object& o = fh->aux_source(id);
int data;
Halfedge_handle h;
Vertex_handle v;
Face_handle f;
if (assign(v, o)) data = v->number_of_data_objects();
else if (assign(h, o)) data = h->number_of_data_objects();
if (assign(v, o)) data = v->env_data_size();
else if (assign(h, o)) data = h->env_data_size();
else {
CGAL_assertion(assign(f, o));
assign(f, o);
data = f->number_of_data_objects();
data = f->env_data_size();
}
return data;
}

View File

@ -92,10 +92,10 @@ public:
//res_v->set_is_intersection(false);
if (v1->is_isolated() && v2->is_isolated()) {
res_v->set_is_equal_aux_data_in_face(0, v1->get_is_equal_data_in_face());
res_v->set_is_equal_aux_data_in_face(1, v2->get_is_equal_data_in_face());
res_v->set_has_equal_aux_data_in_face(0, v1->get_has_equal_data_in_face());
res_v->set_has_equal_aux_data_in_face(1, v2->get_has_equal_data_in_face());
res_v->set_is_equal_aux_data_in_face(0, v1->is_equal_env_data_in_face());
res_v->set_is_equal_aux_data_in_face(1, v2->is_equal_env_data_in_face());
res_v->set_has_equal_aux_data_in_face(0, v1->has_equal_env_data_in_face());
res_v->set_has_equal_aux_data_in_face(1, v2->has_equal_env_data_in_face());
}
}
@ -125,9 +125,9 @@ public:
// the res_v is also isolated, and we should update the is_equal/has_equal
// data in face information
res_v->set_is_equal_aux_data_in_face(0, true);
res_v->set_is_equal_aux_data_in_face(1, v2->get_is_equal_data_in_face());
res_v->set_has_equal_aux_data_in_face(0, !f1->has_no_data());
res_v->set_has_equal_aux_data_in_face(1, v2->get_has_equal_data_in_face());
res_v->set_is_equal_aux_data_in_face(1, v2->is_equal_env_data_in_face());
res_v->set_has_equal_aux_data_in_face(0, ! f1->has_no_env_data());
res_v->set_has_equal_aux_data_in_face(1, v2->has_equal_env_data_in_face());
}
}
@ -140,10 +140,10 @@ public:
if (v1->is_isolated()) {
// the res_v is also isolated, and we should update the is_equal/has_equal
// data in face information
res_v->set_is_equal_aux_data_in_face(0, v1->get_is_equal_data_in_face());
res_v->set_is_equal_aux_data_in_face(0, v1->is_equal_env_data_in_face());
res_v->set_is_equal_aux_data_in_face(1, true);
res_v->set_has_equal_aux_data_in_face(0, v1->get_has_equal_data_in_face());
res_v->set_has_equal_aux_data_in_face(1, !f2->has_no_data());
res_v->set_has_equal_aux_data_in_face(0, v1->has_equal_env_data_in_face());
res_v->set_has_equal_aux_data_in_face(1, ! f2->has_no_env_data());
}
}
@ -157,19 +157,19 @@ public:
res_h->twin()->set_aux_source(1, m_2.non_const_handle(h2->twin()));
// update is_equal/has_equal data in face
res_h->set_is_equal_aux_data_in_face(0, h1->get_is_equal_data_in_face());
res_h->set_is_equal_aux_data_in_face(1, h2->get_is_equal_data_in_face());
res_h->set_has_equal_aux_data_in_face(0, h1->get_has_equal_data_in_face());
res_h->set_has_equal_aux_data_in_face(1, h2->get_has_equal_data_in_face());
res_h->set_is_equal_aux_data_in_face(0, h1->is_equal_env_data_in_face());
res_h->set_is_equal_aux_data_in_face(1, h2->is_equal_env_data_in_face());
res_h->set_has_equal_aux_data_in_face(0, h1->has_equal_env_data_in_face());
res_h->set_has_equal_aux_data_in_face(1, h2->has_equal_env_data_in_face());
res_h->twin()->set_is_equal_aux_data_in_face(0, h1->twin()->
get_is_equal_data_in_face());
is_equal_env_data_in_face());
res_h->twin()->set_is_equal_aux_data_in_face(1, h2->twin()->
get_is_equal_data_in_face());
is_equal_env_data_in_face());
res_h->twin()->set_has_equal_aux_data_in_face(0, h1->twin()->
get_has_equal_data_in_face());
has_equal_env_data_in_face());
res_h->twin()->set_has_equal_aux_data_in_face(1, h2->twin()->
get_has_equal_data_in_face());
has_equal_env_data_in_face());
// update is_equal/has_equal data in target
update_halfedge_flags_on_edge(res_h, m_1.non_const_handle(h1), 0);
@ -197,17 +197,17 @@ public:
res_h->twin()->set_aux_source(1, m_2.non_const_handle(f2));
// update is_equal/has_equal data in face
res_h->set_is_equal_aux_data_in_face(0, h1->get_is_equal_data_in_face());
res_h->set_is_equal_aux_data_in_face(0, h1->is_equal_env_data_in_face());
res_h->set_is_equal_aux_data_in_face(1, true);
res_h->set_has_equal_aux_data_in_face(0, h1->get_has_equal_data_in_face());
res_h->set_has_equal_aux_data_in_face(1, !f2->has_no_data());
res_h->set_has_equal_aux_data_in_face(0, h1->has_equal_env_data_in_face());
res_h->set_has_equal_aux_data_in_face(1, ! f2->has_no_env_data());
res_h->twin()->set_is_equal_aux_data_in_face(0, h1->twin()->
get_is_equal_data_in_face());
is_equal_env_data_in_face());
res_h->twin()->set_is_equal_aux_data_in_face(1, true);
res_h->twin()->set_has_equal_aux_data_in_face(0, h1->twin()->
get_has_equal_data_in_face());
res_h->twin()->set_has_equal_aux_data_in_face(1, !f2->has_no_data());
has_equal_env_data_in_face());
res_h->twin()->set_has_equal_aux_data_in_face(1, ! f2->has_no_env_data());
// update is_equal/has_equal data in target for the first source map
update_halfedge_flags_on_edge(res_h, m_1.non_const_handle(h1), 0);
@ -234,14 +234,16 @@ public:
// update halfedge-face flags of the new halfedge
res_h->set_is_equal_aux_data_in_face(0, true);
res_h->set_is_equal_aux_data_in_face(1, h2->get_is_equal_data_in_face());
res_h->set_has_equal_aux_data_in_face(0, !f1->has_no_data());
res_h->set_has_equal_aux_data_in_face(1, h2->get_has_equal_data_in_face());
res_h->set_is_equal_aux_data_in_face(1, h2->is_equal_env_data_in_face());
res_h->set_has_equal_aux_data_in_face(0, ! f1->has_no_env_data());
res_h->set_has_equal_aux_data_in_face(1, h2->has_equal_env_data_in_face());
res_h->twin()->set_is_equal_aux_data_in_face(0, true);
res_h->twin()->set_is_equal_aux_data_in_face(1, h2->twin()->get_is_equal_data_in_face());
res_h->twin()->set_has_equal_aux_data_in_face(0, !f1->has_no_data());
res_h->twin()->set_has_equal_aux_data_in_face(1, h2->twin()->get_has_equal_data_in_face());
res_h->twin()->set_is_equal_aux_data_in_face
(1, h2->twin()->is_equal_env_data_in_face());
res_h->twin()->set_has_equal_aux_data_in_face(0, ! f1->has_no_env_data());
res_h->twin()->set_has_equal_aux_data_in_face
(1, h2->twin()->has_equal_env_data_in_face());
// update is_equal/has_equal data in target for the second source map
update_halfedge_flags_on_edge(res_h, m_2.non_const_handle(h2), 1);
@ -261,8 +263,9 @@ protected:
template <typename Halfedge_handle_t>
void copy_halfedge_target_info(Halfedge_handle_t from,
Res_halfedge_handle to, unsigned int id) {
to->set_is_equal_aux_data_in_target(id, from->get_is_equal_data_in_target());
to->set_has_equal_aux_data_in_target(id, from->get_has_equal_data_in_target());
to->set_is_equal_aux_data_in_target(id, from->is_equal_env_data_in_target());
to->set_has_equal_aux_data_in_target
(id, from->has_equal_env_data_in_target());
}
void set_halfedge_target_info(Res_halfedge_handle to, unsigned int id,
bool info) {
@ -274,16 +277,17 @@ protected:
void copy_halfedge_target_info_from_halfedge_face_info(Halfedge_handle_t from,
Res_halfedge_handle to,
unsigned int id) {
to->set_is_equal_aux_data_in_target(id, from->get_is_equal_data_in_face());
to->set_has_equal_aux_data_in_target(id, from->get_has_equal_data_in_face());
to->set_has_equal_aux_data_in_target_and_face(id, from->get_has_equal_data_in_face());
to->set_is_equal_aux_data_in_target(id, from->is_equal_env_data_in_face());
to->set_has_equal_aux_data_in_target(id, from->has_equal_env_data_in_face());
to->set_has_equal_aux_data_in_target_and_face
(id, from->has_equal_env_data_in_face());
}
template <typename Vertex_handle_t>
void copy_halfedge_target_info_from_vertex_face_info(Vertex_handle_t from,
Res_halfedge_handle to,
unsigned int id) {
to->set_is_equal_aux_data_in_target(id, from->get_is_equal_data_in_face());
to->set_has_equal_aux_data_in_target(id, from->get_has_equal_data_in_face());
to->set_is_equal_aux_data_in_target(id, from->is_equal_env_data_in_face());
to->set_has_equal_aux_data_in_target(id, from->has_equal_env_data_in_face());
}
// find a halfedge that v is its target and f is its face
@ -309,8 +313,7 @@ protected:
traversed_vertices[Vertex_face_pair(v, hh->face())] = hh;
// check for reult
if (hh->face() == f) result = hh;
++vc;
} while (vc != vc_begin);
} while (++vc != vc_begin);
}
else {
// take it from the map
@ -329,21 +332,21 @@ protected:
if(new_h->target()->is_at_open_boundary()) return;
Vertex_handle vh;
Halfedge_handle hh;
const Object& trg_src = new_h->target()->get_aux_source(id);
const Object& trg_src = new_h->target()->aux_source(id);
if (assign(vh, trg_src)) {
// vh is the target of on_edge, and we can copy the halfedge-target information
// from on_edge
// vh is the target of on_edge, and we can copy the halfedge-target
// information from on_edge
copy_halfedge_target_info(on_edge, new_h, id);
new_h->set_has_equal_aux_data_in_target_and_face
(id, on_edge->get_has_equal_data_in_target_and_face());
(id, on_edge->has_equal_env_data_in_target_and_face());
}
else if (assign(hh, trg_src)) {
// hh is the "HEMSHECH" of on_edge, so we need to set halfedge_target
// information to true
set_halfedge_target_info(new_h, id, true);
// and target-face information using the original halfedge-face information
// and target-face information using the original halfedge-face information
new_h->set_has_equal_aux_data_in_target_and_face
(id, on_edge->get_has_equal_data_in_face());
(id, on_edge->has_equal_env_data_in_face());
}
else
// this cannot happen, since we need to touch an edge
@ -361,34 +364,38 @@ protected:
Halfedge_handle hh;
Face_handle fh;
// update target
const Object& trg_src = new_h->target()->get_aux_source(id);
const Object& trg_src = new_h->target()->aux_source(id);
if (assign(vh, trg_src)) {
if (vh->is_isolated()) {
copy_halfedge_target_info_from_vertex_face_info(vh, new_h, id);
// the target-face information is taken from vertex-face information too
new_h->set_has_equal_aux_data_in_target_and_face
(id, vh->get_has_equal_data_in_face());
(id, vh->has_equal_env_data_in_face());
}
else {
// we have a vertex vh on the boundary of the face in_face
// todo: get rid of this calculations: (using unknown value for
// has_equal flag)
/*CGAL_assertion_code(
bool calc_is_equal = vh->is_equal_data(in_face->begin_data(), in_face->end_data());
)*/
//bool calc_has_equal = vh->has_equal_data(in_face->begin_data(), in_face->end_data());
// CGAL_assertion_code(
// bool calc_is_equal = vh->is_equal_env_data(in_face->begin_env_data(),
// in_face->end_env_data());
// )
//
// bool calc_has_equal = vh->has_equal_env_data(in_face->begin_env_data(),
// in_face->end_env_data());
// find the halfedge with target vh on the boundary of in_face
Halfedge_handle h_of_vh_and_in_face =
find_halfedge_by_vertex_and_face(vh, in_face);
// is_equal relationship is easy:
bool is_equal = h_of_vh_and_in_face->get_is_equal_data_in_face() &&
h_of_vh_and_in_face->get_is_equal_data_in_target();
bool is_equal = h_of_vh_and_in_face->is_equal_env_data_in_face() &&
h_of_vh_and_in_face->is_equal_env_data_in_target();
//CGAL_assertion(is_equal == calc_is_equal);
// has_equal relationship is problematic in one case:
bool has_equal =
h_of_vh_and_in_face->get_has_equal_data_in_target_and_face();
h_of_vh_and_in_face->has_equal_env_data_in_target_and_face();
/*CGAL_assertion(has_equal == calc_has_equal);
if(has_equal != calc_has_equal)
@ -419,8 +426,8 @@ protected:
// the face data
CGAL_assertion(fh == in_face);
new_h->set_is_equal_aux_data_in_target(id, true);
new_h->set_has_equal_aux_data_in_target(id, !fh->has_no_data());
new_h->set_has_equal_aux_data_in_target_and_face(id, !fh->has_no_data());
new_h->set_has_equal_aux_data_in_target(id, ! fh->has_no_env_data());
new_h->set_has_equal_aux_data_in_target_and_face(id, ! fh->has_no_env_data());
}
}

View File

@ -36,7 +36,7 @@ public:
protected:
/*! data container */
Data_container m_data;
Data_container m_env_data;
/*! Indicates that the data (surfaces) have been set already */
bool m_is_set;
@ -48,14 +48,14 @@ public:
Dcel_info() : m_is_set(false), m_decision(DAC_DECISION_NOT_SET) {}
/*! \brief returns true iff data has been set already */
bool get_is_set() const { return m_is_set; }
bool env_is_set() const { return m_is_set; }
/*! \brief resets the flag */
void set_is_set(bool flag) { m_is_set = flag; }
bool is_decision_set() { return (m_decision != DAC_DECISION_NOT_SET); }
Dac_decision get_decision() const { return m_decision; }
Dac_decision decision() const { return m_decision; }
void set_decision(Comparison_result comp)
{ m_decision = enum_cast<Dac_decision>(comp); }
@ -63,55 +63,56 @@ public:
void set_decision(Dac_decision dec) { m_decision = dec; }
/*! User-friendly interface: */
size_t number_of_surfaces() const { return m_data.size(); }
size_t number_of_surfaces() const { return m_env_data.size(); }
Data_const_iterator surfaces_begin() const { return m_data.begin(); }
Data_const_iterator surfaces_begin() const { return m_env_data.begin(); }
Data_const_iterator surfaces_end() const { return m_data.end(); }
Data_const_iterator surfaces_end() const { return m_env_data.end(); }
/*! Obtain the first Xy-monotone surface associated with the face.
* \pre number_of_surfaces() is not 0.
*/
const Data& surface() const {
CGAL_precondition(m_data.size() > 0);
return m_data.front();
CGAL_precondition(m_env_data.size() > 0);
return m_env_data.front();
}
/*! Obtain the number of data objects associated with the face.
/*! Obtain the number of data objects associated with the cell.
*/
int number_of_data_objects() const { return static_cast<int>(m_data.size()); }
int env_data_size() const
{ return static_cast<int>(m_env_data.size()); }
/*! Check whether the data is set to be empty
*/
bool has_no_data() const
{ return (m_is_set && (number_of_data_objects() == 0)); }
bool has_no_env_data() const
{ return (m_is_set && (env_data_size() == 0)); }
/*! Obtain the first data object associated with the face.
* \pre number_of_data_objects() is not 0.
/*! Obtain the first data object associated with the cell.
* \pre m_env_data.size() is not 0.
*/
const Data& get_env_data() const {
CGAL_precondition(m_data.size() > 0);
return m_data.front();
const Data& env_data_front() const {
CGAL_precondition(m_env_data.size() > 0);
return m_env_data.front();
}
/*! Obtain the data iterators (const version).
*/
Data_const_iterator begin_data() const { return m_data.begin(); }
Data_const_iterator begin_env_data() const { return m_env_data.begin(); }
Data_const_iterator end_data() const { return m_data.end(); }
Data_const_iterator end_env_data() const { return m_env_data.end(); }
/*! Obtain the data iterators (non-const version).
*/
Data_iterator begin_data() { return m_data.begin(); }
Data_iterator begin_env_data() { return m_env_data.begin(); }
Data_iterator end_data() { return m_data.end(); }
Data_iterator end_env_data() { return m_env_data.end(); }
/*! Set a data object to the face.
* \param data The data object to set.
*/
void set_env_data(const Data& data) {
clear_data();
add_data(data);
clear_env_data();
add_env_data(data);
}
/*! Set a range of data objects to the face.
@ -120,22 +121,22 @@ public:
*/
template <typename InputIterator>
void set_env_data(InputIterator begin, InputIterator end) {
clear_data();
add_data(begin, end);
clear_env_data();
add_env_data(begin, end);
}
/*! set the data to be empty.
*/
void set_no_data() {
clear_data();
void set_no_env_data() {
clear_env_data();
m_is_set = true;
}
/*! Add a data object to the face.
* \param data The additional data object.
*/
void add_data(const Data& data) {
m_data.push_back(data);
void add_env_data(const Data& data) {
m_env_data.push_back(data);
m_is_set = true;
}
@ -144,15 +145,15 @@ public:
* \param end A past-the-end iterator for the data range.
*/
template <typename InputIterator>
void add_data(InputIterator begin, InputIterator end) {
for (auto it = begin; it != end; it++) m_data.push_back(*it);
void add_env_data(InputIterator begin, InputIterator end) {
for (auto it = begin; it != end; ++it) m_env_data.push_back(*it);
m_is_set = true;
}
/*! Clear the data objects.
*/
void clear_data() {
m_data.clear();
void clear_env_data() {
m_env_data.clear();
m_is_set = false;
}
@ -160,23 +161,23 @@ public:
* set of data objects
*/
template <typename InputIterator>
bool is_equal_data(InputIterator begin, InputIterator end) const {
if (! get_is_set()) return false;
bool is_equal_env_data(InputIterator begin, InputIterator end) const {
if (! env_is_set()) return false;
// insert the input data objects into a set
std::set<Data> input_data(begin, end);
std::set<Data> my_data(begin_data(), end_data());
std::set<Data> my_data(begin_env_data(), end_env_data());
if (input_data.size() != my_data.size()) return false;
return (my_data == input_data);
}
template <typename InputIterator>
bool has_equal_data(InputIterator begin, InputIterator end) const {
if (! get_is_set()) return false;
bool has_equal_env_data(InputIterator begin, InputIterator end) const {
if (! env_is_set()) return false;
// insert the input data objects into a set
std::set<Data> input_data(begin, end);
std::set<Data> my_data(begin_data(), end_data());
std::set<Data> my_data(begin_env_data(), end_env_data());
std::list<Data> intersection;
std::set_intersection(my_data.begin(), my_data.end(),
input_data.begin(), input_data.end(),
@ -185,7 +186,6 @@ public:
}
protected:
/*! Place holder for the source of the overlay data */
Object m_aux_source[2];
@ -202,14 +202,14 @@ public:
m_aux_source[id] = o;
}
const Object& get_aux_source(unsigned int id) {
const Object& aux_source(unsigned int id) {
CGAL_precondition(id < 2);
CGAL_precondition (!m_aux_source[id].is_empty());
return m_aux_source[id];
}
/*! \brief returns true iff the point has been set already */
bool get_aux_is_set(unsigned int id) const {
bool aux_is_set(unsigned int id) const {
CGAL_precondition(id < 2);
return (! m_aux_source[id].is_empty());
}
@ -251,35 +251,25 @@ public:
/*! Constructor */
Envelope_pm_vertex() : Dcel_info<Vertex_data>(), flags(0) {}
/*void set_is_fake(bool b)
{
set_bit(IS_FAKE, b);
}
bool get_is_fake() const
{
return get_bit(IS_FAKE);
}*/
/* void set_is_fake(bool b) { set_bit(IS_FAKE, b); }
* bool is_fake() const { return get_bit(IS_FAKE); }
*/
/* void set_is_intersection(bool b)
{
set_bit(IS_INTERSECTION, b);
}*/
/*bool get_is_intersection() const
{
return get_bit(IS_FAKE);
}*/
/* void set_is_intersection(bool b) { set_bit(IS_INTERSECTION, b); }
* bool is_intersection() const { return get_bit(IS_FAKE); }
*/
void set_is_equal_data_in_face(bool b) { set_bit(IS_EQUAL, b); }
bool get_is_equal_data_in_face() const { return get_bit(IS_EQUAL); }
void set_is_equal_env_data_in_face(bool b) { set_bit(IS_EQUAL, b); }
bool is_equal_env_data_in_face() const { return get_bit(IS_EQUAL); }
void set_has_equal_data_in_face(bool b) { set_bit(HAS_EQUAL, b); }
bool get_has_equal_data_in_face() const { return get_bit(HAS_EQUAL); }
void set_has_equal_env_data_in_face(bool b) { set_bit(HAS_EQUAL, b); }
bool has_equal_env_data_in_face() const { return get_bit(HAS_EQUAL); }
void set_is_equal_aux_data_in_face(unsigned int id, bool b) {
CGAL_assertion(id < 2);
set_bit(IS_EQUAL_AUX+id, b);
}
bool get_is_equal_aux_data_in_face(unsigned int id) const {
bool is_equal_aux_data_in_face(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(IS_EQUAL_AUX+id);
}
@ -288,7 +278,7 @@ public:
CGAL_assertion(id < 2);
set_bit(HAS_EQUAL_AUX+id, b);
}
bool get_has_equal_aux_data_in_face(unsigned int id) const {
bool has_equal_aux_data_in_face(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(HAS_EQUAL_AUX+id);
}
@ -359,26 +349,21 @@ public:
Envelope_pm_halfedge() : Dcel_info<Halfedge_data>(), flags(0) {}
/* void set_is_fake(bool b)
{
set_bit(IS_FAKE, b);
}
bool get_is_fake() const
{
return get_bit(IS_FAKE);
}*/
/* void set_is_fake(bool b) { set_bit(IS_FAKE, b); }
* bool is_fake() const { return get_bit(IS_FAKE); }
*/
void set_is_equal_data_in_face(bool b) { set_bit(IS_EQUAL_FACE, b); }
bool get_is_equal_data_in_face() const { return get_bit(IS_EQUAL_FACE); }
void set_is_equal_env_data_in_face(bool b) { set_bit(IS_EQUAL_FACE, b); }
bool is_equal_env_data_in_face() const { return get_bit(IS_EQUAL_FACE); }
void set_has_equal_data_in_face(bool b) { set_bit(HAS_EQUAL_FACE, b); }
bool get_has_equal_data_in_face() const { return get_bit(HAS_EQUAL_FACE); }
void set_has_equal_env_data_in_face(bool b) { set_bit(HAS_EQUAL_FACE, b); }
bool has_equal_env_data_in_face() const { return get_bit(HAS_EQUAL_FACE); }
void set_is_equal_aux_data_in_face(unsigned int id, bool b) {
CGAL_assertion(id < 2);
set_bit(IS_EQUAL_AUX_FACE+id, b);
}
bool get_is_equal_aux_data_in_face(unsigned int id) const {
bool is_equal_aux_data_in_face(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(IS_EQUAL_AUX_FACE+id);
}
@ -387,22 +372,22 @@ public:
CGAL_assertion(id < 2);
set_bit(HAS_EQUAL_AUX_FACE+id, b);
}
bool get_has_equal_aux_data_in_face(unsigned int id) const {
bool has_equal_aux_data_in_face(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(HAS_EQUAL_AUX_FACE+id);
}
void set_is_equal_data_in_target(bool b) { set_bit(IS_EQUAL_TARGET, b); }
bool get_is_equal_data_in_target() const { return get_bit(IS_EQUAL_TARGET); }
void set_is_equal_env_data_in_target(bool b) { set_bit(IS_EQUAL_TARGET, b); }
bool is_equal_env_data_in_target() const { return get_bit(IS_EQUAL_TARGET); }
void set_has_equal_data_in_target(bool b) { set_bit(HAS_EQUAL_TARGET, b); }
bool get_has_equal_data_in_target() const { return get_bit(HAS_EQUAL_TARGET); }
void set_has_equal_env_data_in_target(bool b) { set_bit(HAS_EQUAL_TARGET, b); }
bool has_equal_env_data_in_target() const { return get_bit(HAS_EQUAL_TARGET); }
void set_is_equal_aux_data_in_target(unsigned int id, bool b) {
CGAL_assertion(id < 2);
set_bit(IS_EQUAL_AUX_TARGET+id, b);
}
bool get_is_equal_aux_data_in_target(unsigned int id) const {
bool is_equal_aux_data_in_target(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(IS_EQUAL_AUX_TARGET+id);
}
@ -411,21 +396,21 @@ public:
CGAL_assertion(id < 2);
set_bit(HAS_EQUAL_AUX_TARGET+id, b);
}
bool get_has_equal_aux_data_in_target(unsigned int id) const {
bool has_equal_aux_data_in_target(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(HAS_EQUAL_AUX_TARGET+id);
}
// access to flags that contain relation between target and face
void set_has_equal_data_in_target_and_face(bool b)
void set_has_equal_env_data_in_target_and_face(bool b)
{ set_bit(HAS_EQUAL_F_T, b); }
bool get_has_equal_data_in_target_and_face() const
bool has_equal_env_data_in_target_and_face() const
{ return get_bit(HAS_EQUAL_F_T); }
void set_has_equal_aux_data_in_target_and_face(unsigned int id, bool b) {
CGAL_assertion(id < 2);
set_bit(HAS_EQUAL_AUX_F_T+id, b);
}
bool get_has_equal_aux_data_in_target_and_face(unsigned int id) const {
bool has_equal_aux_data_in_target_and_face(unsigned int id) const {
CGAL_assertion(id < 2);
return get_bit(HAS_EQUAL_AUX_F_T+id);
}

View File

@ -124,34 +124,37 @@ public:
Xy_monotone_surface_3& prev_surface = surfaces[j];
std::vector<std::variant<Intersection_curve,Point_2>> inter_objs;
traits.construct_projected_intersections_2_object()(cur_surface, prev_surface, std::back_inserter(inter_objs));
traits.construct_projected_intersections_2_object()
(cur_surface, prev_surface, std::back_inserter(inter_objs));
// we collect all intersections and use sweep to insert them
for (std::size_t k = 0; k < inter_objs.size(); ++k) {
if (const Point_2* point = std::get_if<Point_2>(&inter_objs[k])) {
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "intersection between surfaces is a point: "
<< point << std::endl;
#endif
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "intersection between surfaces is a point: "
<< point << std::endl;
#endif
//insert_vertex(result, point, pl);
points_col.push_back(*point);
}
else if (const auto* curve =
std::get_if<Intersection_curve>(&inter_objs[k])) {
curves_col.push_back(curve->first);
/*#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "intersection between surfaces is a curve: " << curve.first << std::endl;
#endif
std::list<Object> objs;
traits.make_x_monotone_2_object()(curve.first, std::back_inserter(objs));
std::list<Object>::iterator itr;
for(itr = objs.begin(); itr != objs.end(); ++itr)
{
X_monotone_curve_2 curr_cv;
assert(assign(curr_cv, *itr));
assign(curr_cv, *itr);
curves_col.push_back(curr_cv);
}*/
/* #ifdef CGAL_DEBUG_ENVELOPE_TEST_3
* std::cout << "intersection between surfaces is a curve: "
* << curve.first << std::endl;
* #endif
* std::list<Object> objs;
* traits.make_x_monotone_2_object()(curve.first,
* std::back_inserter(objs));
* std::list<Object>::iterator itr;
* for(itr = objs.begin(); itr != objs.end(); ++itr) {
* X_monotone_curve_2 curr_cv;
* assert(assign(curr_cv, *itr));
* assign(curr_cv, *itr);
* curves_col.push_back(curr_cv);
* }
*/
//insert(result, curve.first, pl);
}
else assert_msg(false, "wrong intersection type");
@ -167,7 +170,8 @@ public:
m_result = &result;
// now, foreach vertex, edge and face, we should determine which surfaces are minimal over it.
// now, foreach vertex, edge and face, we should determine which surfaces
// are minimal over it.
// update vertices' data
for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) {
@ -242,16 +246,16 @@ protected:
template <typename SurfaceIterator>
void set_minimum_over_vertex(const Vertex_handle& v,
SurfaceIterator begin, SurfaceIterator end) {
if (begin == end) v->set_no_data();
if (begin == end) v->set_no_env_data();
else {
auto si = begin;
// we set the first surface as the minimum, and then compare all the others
v->set_env_data(*si);
++si;
for (; si != end; ++si) {
Comparison_result cr =
traits.compare_z_at_xy_3_object()(v->point(), v->get_env_data(), *si);
if (cr == EQUAL) v->add_data(*si);
auto cr = traits.compare_z_at_xy_3_object()(v->point(),
v->env_data_front(), *si);
if (cr == EQUAL) v->add_env_data(*si);
// this erases all surfaces from vertex's list
else if (cr == LARGER) v->set_env_data(*si);
// else - new surface has no affect on the envelope
@ -264,7 +268,7 @@ protected:
template <typename SurfaceIterator>
void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin,
SurfaceIterator end) {
if (begin == end) h->set_no_data();
if (begin == end) h->set_no_env_data();
else {
if (h != current_edge) compute_point_in_current_edge(h);
@ -273,16 +277,15 @@ protected:
h->set_env_data(*si);
++si;
for (; si != end; ++si) {
Comparison_result cr =
traits.compare_z_at_xy_3_object()(current_point_inside_edge,
h->get_env_data(), *si);
if (cr == EQUAL) h->add_data(*si);
auto cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge,
h->env_data_front(), *si);
if (cr == EQUAL) h->add_env_data(*si);
// this erases all surfaces from halfedge's list
else if (cr == LARGER) h->set_env_data(*si);
// else - new surface has no affect on the envelope
}
// set twin's data
h->twin()->set_env_data(h->begin_data(), h->end_data());
h->twin()->set_env_data(h->begin_env_data(), h->end_env_data());
}
}
@ -295,7 +298,7 @@ protected:
if (face->is_unbounded() || begin == end) {
// a special case - no surface over the unbounded face, and when there
// are no surfaces at all
face->set_no_data();
face->set_no_env_data();
}
else {
auto si = begin;
@ -303,9 +306,8 @@ protected:
face->set_env_data(*si);
++si;
for (; si != end; ++si) {
Comparison_result cr =
compare_surfaces_over_face(face, face->get_env_data(), *si);
if (cr == EQUAL) face->add_data(*si);
auto cr = compare_surfaces_over_face(face, face->env_data_front(), *si);
if (cr == EQUAL) face->add_env_data(*si);
// this erases all surfaces from face's list
else if (cr == LARGER) face->set_env_data(*si);
// else - new surface has no affect on the envelope
@ -329,7 +331,8 @@ protected:
cur_res = traits.compare_z_at_xy_3_object()(current_point,surf1,surf2);
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "for comparison inside face, current result = " << cur_res << std::endl;
std::cout << "for comparison inside face, current result = " << cur_res
<< std::endl;
#endif
return cur_res;
@ -366,7 +369,7 @@ protected:
assert(! face->is_unbounded());
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "in compute point inside face" << std::endl;
std::cout << "in compute point inside face" << std::endl;
#endif
// 1. find an edge on the outer ccb of the face that is not vertical
@ -374,12 +377,12 @@ protected:
Ccb_halfedge_circulator hec_begin = hec;
bool found = false;
do {
if (!traits.is_vertical_2_object()(hec->curve())) {
if (! traits.is_vertical_2_object()(hec->curve())) {
found = true;
continue;
}
hec++;
} while(hec != hec_begin && !found);
++hec;
} while ((hec != hec_begin) && ! found);
assert(found);
Halfedge_handle found_hh = hec;
@ -388,10 +391,10 @@ protected:
// (we use the middle of the curve)
Point_2 shoot_source = traits.construct_middle_point(found_hh->curve());
// 3. ray shoot up or down, into the face
// and find the intersection point of the ray. the segment between
// the point from which we shoot, and the intersection point lies
// inside the face. we take its middle point as a point inside the face
// 3. ray shoot up or down, into the face and find the intersection point
// of the ray. the segment between the point from which we shoot,
// and the intersection point lies inside the face.
// we take its middle point as a point inside the face
bool shoot_up = true;
// TODO_NEW_DESIGN - check this
// if (traits.compare_x(found_hh->source()->point(), found_hh->target()->point()) == LARGER)
@ -418,20 +421,19 @@ protected:
Point_2 res_point = traits.construct_middle_point(shoot_source, shoot_target);
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "finished computing point in face" << std::endl;
#ifdef CGAL_DEBUG_ENVELOPE_TEST_3
std::cout << "finished computing point in face" << std::endl;
// just for checking, locate res_point in env to find face
Object test_pl_obj = pl.locate(res_point);
Face_const_handle test_fh;
assert(assign(test_fh, test_pl_obj));
assert(test_fh == face);
#endif
// just for checking, locate res_point in env to find face
Object test_pl_obj = pl.locate(res_point);
Face_const_handle test_fh;
assert(assign(test_fh, test_pl_obj));
assert(test_fh == face);
#endif
return res_point;
}
// compute a point inside the face saved in current_face
// and put the result into current_point
void compute_point_in_current_face(Face_handle face) {

View File

@ -56,7 +56,7 @@ public:
void create_face (Face_handle1 f1, Face_handle2 f2, Res_face_handle res_f) {
res_f->set_aux_source(0, f1);
res_f->set_aux_source(1, f2);
assert_msg(f1->is_equal_data(f2->begin_data(), f2->end_data()),
assert_msg(f1->is_equal_env_data(f2->begin_env_data(), f2->end_env_data()),
"data different over face");
}
@ -64,7 +64,7 @@ public:
Res_vertex_handle res_v) {
res_v->set_aux_source(0, h1);
res_v->set_aux_source(1, h2);
assert_msg(h1->is_equal_data(h2->begin_data(), h2->end_data()),
assert_msg(h1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()),
"data different over vertex");
}
@ -72,40 +72,40 @@ public:
Res_vertex_handle res_v) {
res_v->set_aux_source(0, v1);
res_v->set_aux_source(1, v2);
assert_msg(v1->is_equal_data(v2->begin_data(), v2->end_data()),
"data different over vertex");
assert_msg(v1->is_equal_env_data(v2->begin_env_data(), v2->end_env_data()),
"data different over vertex");
}
void create_vertex(Vertex_handle1 v1, Halfedge_handle2 h2,
Res_vertex_handle res_v) {
res_v->set_aux_source(0, v1);
res_v->set_aux_source(1, h2);
assert_msg(v1->is_equal_data(h2->begin_data(), h2->end_data()),
"data different over vertex");
assert_msg(v1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()),
"data different over vertex");
}
void create_vertex(Halfedge_handle1 h1, Vertex_handle2 v2,
Res_vertex_handle res_v) {
res_v->set_aux_source(0, h1);
res_v->set_aux_source(1, v2);
assert_msg(h1->is_equal_data(v2->begin_data(), v2->end_data()),
"data different over vertex");
assert_msg(h1->is_equal_env_data(v2->begin_env_data(), v2->end_env_data()),
"data different over vertex");
}
void create_vertex(Face_handle1 f1, Vertex_handle2 v2,
Res_vertex_handle res_v) {
res_v->set_aux_source(0, f1);
res_v->set_aux_source(1, v2);
assert_msg(f1->is_equal_data(v2->begin_data(), v2->end_data()),
"data different over vertex");
assert_msg(f1->is_equal_env_data(v2->begin_env_data(), v2->end_env_data()),
"data different over vertex");
}
void create_vertex(Vertex_handle1 v1, Face_handle2 f2,
Res_vertex_handle res_v) {
res_v->set_aux_source(0, v1);
res_v->set_aux_source(1, f2);
assert_msg(v1->is_equal_data(f2->begin_data(), f2->end_data()),
"data different over vertex");
assert_msg(v1->is_equal_env_data(f2->begin_env_data(), f2->end_env_data()),
"data different over vertex");
}
void create_edge(Halfedge_handle1 h1, Halfedge_handle2 h2,
@ -116,8 +116,8 @@ public:
res_h->twin()->set_aux_source(0, h1->twin());
res_h->twin()->set_aux_source(1, h2->twin());
assert_msg(h1->is_equal_data(h2->begin_data(), h2->end_data()),
"data different over edge");
assert_msg(h1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()),
"data different over edge");
}
void create_edge(Halfedge_handle1 h1, Face_handle2 f2,
@ -128,8 +128,8 @@ public:
res_h->twin()->set_aux_source(0, h1->twin());
res_h->twin()->set_aux_source(1, f2);
assert_msg(h1->is_equal_data(f2->begin_data(), f2->end_data()),
"data different over edge");
assert_msg(h1->is_equal_env_data(f2->begin_env_data(), f2->end_env_data()),
"data different over edge");
}
void create_edge(Face_handle1 f1, Halfedge_handle2 h2,
@ -139,11 +139,9 @@ public:
res_h->twin()->set_aux_source(0, f1);
res_h->twin()->set_aux_source(1, h2->twin());
assert_msg(f1->is_equal_data(h2->begin_data(), h2->end_data()),
"data different over edge");
assert_msg(f1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()),
"data different over edge");
}
};
} //namespace CGAL

View File

@ -176,9 +176,8 @@ public:
Vertex_handle vh = vi;
// first we find the surfaces that are defined over the vertex
std::list<Xy_monotone_surface_3> defined_surfaces;
typename Traits::Is_defined_over is_defined_over =
traits.is_defined_over_object();
for(std::size_t i=0; i<number_of_surfaces; ++i)
auto is_defined_over = traits.is_defined_over_object();
for (std::size_t i=0; i<number_of_surfaces; ++i)
if (is_defined_over(vh->point(), surfaces[i]))
defined_surfaces.push_back(surfaces[i]);
@ -229,7 +228,7 @@ public:
// foreach face in the test envelope, compute a point inside the face,
// locate it in the other envelope and compare the surfaces over the 2 faces
Md2_point_location pl(env);
bool eq, result = true;
bool result = true;
for (auto fi = test_env.faces_begin(); fi != test_env.faces_end(); ++fi) {
Face_handle fh = fi;
if (! fh->is_unbounded()) {
@ -237,8 +236,9 @@ public:
auto pl_obj = pl.locate(inside_test);
// faces of env must contain the faces of test
const Face_const_handle* pl_fh = std::get_if<Face_const_handle>(&pl_obj);
assert(pl_fh!=nullptr);
eq = fh->is_equal_data((*pl_fh)->begin_data(), (*pl_fh)->end_data());
assert(pl_fh != nullptr);
auto eq = fh->is_equal_env_data((*pl_fh)->begin_env_data(),
(*pl_fh)->end_env_data());
assert(eq);
result &= eq;
}
@ -265,16 +265,16 @@ protected:
template <typename SurfaceIterator>
void set_minimum_over_vertex(Vertex_handle v, SurfaceIterator begin,
SurfaceIterator end) {
if (begin == end) v->set_no_data();
if (begin == end) v->set_no_env_data();
else {
auto si = begin;
// we set the first surface as the minimum, and then compare all the others
v->set_env_data(*si);
++si;
for (; si != end; ++si) {
Comparison_result cr =
traits.compare_z_at_xy_3_object()(v->point(), v->get_env_data(), *si);
if (cr == EQUAL) v->add_data(*si);
auto cr = traits.compare_z_at_xy_3_object()(v->point(),
v->env_data_front(), *si);
if (cr == EQUAL) v->add_env_data(*si);
// this erases all surfaces from vertex's list
else if (cr == LARGER) v->set_env_data(*si);
// else - new surface has no affect on the envelope
@ -287,7 +287,7 @@ protected:
template <typename SurfaceIterator>
void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin,
SurfaceIterator end) {
if (begin == end) h->set_no_data();
if (begin == end) h->set_no_env_data();
else {
if (h != current_edge) compute_point_in_current_edge(h);
@ -296,16 +296,15 @@ protected:
h->set_env_data(*si);
++si;
for (; si != end; ++si) {
Comparison_result cr =
traits.compare_z_at_xy_3_object()(current_point_inside_edge,
h->get_env_data(), *si);
if (cr == EQUAL) h->add_data(*si);
auto cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge,
h->env_data_front(), *si);
if (cr == EQUAL) h->add_env_data(*si);
// this erases all surfaces from halfedge's list
else if (cr == LARGER) h->set_env_data(*si);
// else - new surface has no affect on the envelope
}
// set twin's data
h->twin()->set_env_data(h->begin_data(), h->end_data());
h->twin()->set_env_data(h->begin_env_data(), h->end_env_data());
}
}
// fill the face with the surface on the envelope
@ -317,7 +316,7 @@ protected:
if (face->is_unbounded() || begin == end) {
// a special case - no surface over the unbounded face, and when there
// are no surfaces at all
face->set_no_data();
face->set_no_env_data();
}
else {
auto si = begin;
@ -326,9 +325,8 @@ protected:
face->set_env_data(*si);
++si;
for (; si != end; ++si) {
Comparison_result cr =
compare_surfaces_over_face(face, face->get_env_data(), *si);
if (cr == EQUAL) face->add_data(*si);
auto cr = compare_surfaces_over_face(face, face->env_data_front(), *si);
if (cr == EQUAL) face->add_env_data(*si);
// this erases all surfaces from face's list
else if (cr == LARGER) face->set_env_data(*si);
// else - new surface has no affect on the envelope
@ -392,10 +390,9 @@ protected:
<< cur_res << std::endl;
#endif
if (cur_res != EQUAL)
found_not_equal = true;
hec++;
} while(hec != hec_begin && !found_not_equal);
if (cur_res != EQUAL) found_not_equal = true;
++hec;
} while ((hec != hec_begin) && ! found_not_equal);
// std::cout << "for comparison on vertices, result = " << cur_res
// << std::endl;
@ -482,11 +479,11 @@ protected:
#endif
result &= tmp_result;
hec++;
} while(hec != hec_begin && result);
++hec;
} while ((hec != hec_begin) && result);
}
if (result == false) return result;
if (! result) return result;
// check vertices on holes boundary
Hole_iterator hi;
@ -502,9 +499,9 @@ protected:
#endif
result &= tmp_result;
hec++;
} while(hec != hec_begin && result);
if (result == false) return result;
++hec;
} while ((hec != hec_begin) && result);
if (! result) return result;
}
return result;
@ -540,8 +537,8 @@ protected:
found = true;
continue;
}
hec++;
} while (hec != hec_begin && !found);
++hec;
} while ((hec != hec_begin) && !found);
assert(found);
Halfedge_handle found_hh = hec;