Skip to content

Commit

Permalink
Allowed missing outer or inner ccbs in case not present
Browse files Browse the repository at this point in the history
  • Loading branch information
efifogel committed Aug 11, 2023
1 parent de4bf46 commit 9c6c7ff
Showing 1 changed file with 62 additions and 70 deletions.
132 changes: 62 additions & 70 deletions Arrangement_on_surface_2/demo/globus/globus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,82 +366,74 @@ bool read_arrangement(const std::string& filename, Arrangement_& arr,

// Read the outer CCBs of the face.
auto oit = js_face.find("outer_ccbs");
if (oit == js_face.end()) {
std::cerr << "The outer_ccbs item is missing " << " (" << filename
<< ")\n";
return false;
}

const auto& js_outer_ccbs = *oit;
for (const auto& js_ccb : js_outer_ccbs) {
std::cout << "Outer CCB\n";
// Allocate a new outer CCB record and set its incident face.
auto* new_occb = arr_access.new_outer_ccb();
new_occb->set_face(new_f);

// Read the current outer CCB.
auto bit = js_ccb.find("halfedges");
if (bit == js_ccb.end()) {
std::cerr << "The halfedges item is missing " << " (" << filename
<< ")\n";
return false;
}

const auto& js_halfedges = *bit;
auto hit = js_halfedges.begin();
std::size_t first_idx = *hit;
DHalfedge* first_he = halfedges[first_idx];
first_he->set_outer_ccb(new_occb);
DHalfedge* prev_he = first_he;
for (++hit; hit != js_halfedges.end(); ++hit) {
std::size_t curr_idx = *hit;
auto curr_he = halfedges[curr_idx];
prev_he->set_next(curr_he); // connect
curr_he->set_outer_ccb(new_occb); // set the CCB
prev_he = curr_he;
if (oit != js_face.end()) {
const auto& js_outer_ccbs = *oit;
for (const auto& js_ccb : js_outer_ccbs) {
std::cout << "Outer CCB\n";
// Allocate a new outer CCB record and set its incident face.
auto* new_occb = arr_access.new_outer_ccb();
new_occb->set_face(new_f);

// Read the current outer CCB.
auto bit = js_ccb.find("halfedges");
if (bit == js_ccb.end()) {
std::cerr << "The halfedges item is missing " << " (" << filename
<< ")\n";
return false;
}

const auto& js_halfedges = *bit;
auto hit = js_halfedges.begin();
std::size_t first_idx = *hit;
DHalfedge* first_he = halfedges[first_idx];
first_he->set_outer_ccb(new_occb);
DHalfedge* prev_he = first_he;
for (++hit; hit != js_halfedges.end(); ++hit) {
std::size_t curr_idx = *hit;
auto curr_he = halfedges[curr_idx];
prev_he->set_next(curr_he); // connect
curr_he->set_outer_ccb(new_occb); // set the CCB
prev_he = curr_he;
}
prev_he->set_next(first_he); // close the loop
new_f->add_outer_ccb(new_occb, first_he);
}
prev_he->set_next(first_he); // close the loop
new_f->add_outer_ccb(new_occb, first_he);
}

// Read the inner CCBs of the face.
auto iit = js_face.find("inner_ccbs");
if (iit == js_face.end()) {
std::cerr << "The inner_ccbs item is missing " << " (" << filename
<< ")\n";
return false;
}

const auto& js_inner_ccbs = *iit;
for (const auto& js_ccb : js_inner_ccbs) {
std::cout << "Inner CCB\n";
// Allocate a new inner CCB record and set its incident face.
auto* new_iccb = arr_access.new_inner_ccb();
new_iccb->set_face(new_f);

// Read the current inner CCB.
auto bit = js_ccb.find("halfedges");
if (bit == js_ccb.end()) {
std::cerr << "The halfedges item is missing " << " (" << filename
<< ")\n";
return false;
}

const auto& js_halfedges = *bit;
auto hit = js_halfedges.begin();
std::size_t first_idx = *hit;
DHalfedge* first_he = halfedges[first_idx];
first_he->set_inner_ccb(new_iccb);
DHalfedge* prev_he = first_he;
for (++hit; hit != js_halfedges.end(); ++hit) {
std::size_t curr_idx = *hit;
auto curr_he = halfedges[curr_idx];
prev_he->set_next(curr_he); // connect
curr_he->set_inner_ccb(new_iccb); // set the CCB
prev_he = curr_he;
if (iit != js_face.end()) {
const auto& js_inner_ccbs = *iit;
for (const auto& js_ccb : js_inner_ccbs) {
std::cout << "Inner CCB\n";
// Allocate a new inner CCB record and set its incident face.
auto* new_iccb = arr_access.new_inner_ccb();
new_iccb->set_face(new_f);

// Read the current inner CCB.
auto bit = js_ccb.find("halfedges");
if (bit == js_ccb.end()) {
std::cerr << "The halfedges item is missing " << " (" << filename
<< ")\n";
return false;
}

const auto& js_halfedges = *bit;
auto hit = js_halfedges.begin();
std::size_t first_idx = *hit;
DHalfedge* first_he = halfedges[first_idx];
first_he->set_inner_ccb(new_iccb);
DHalfedge* prev_he = first_he;
for (++hit; hit != js_halfedges.end(); ++hit) {
std::size_t curr_idx = *hit;
auto curr_he = halfedges[curr_idx];
prev_he->set_next(curr_he); // connect
curr_he->set_inner_ccb(new_iccb); // set the CCB
prev_he = curr_he;
}
prev_he->set_next(first_he); // close the loop
new_f->add_inner_ccb(new_iccb, first_he);
}
prev_he->set_next(first_he); // close the loop
new_f->add_inner_ccb(new_iccb, first_he);
}

// // Read the isolated vertices inside the face.
Expand Down

0 comments on commit 9c6c7ff

Please sign in to comment.