fix bug with handling k for k > 1

This commit is contained in:
Dmitry Anisimov 2020-11-04 11:05:32 +01:00
parent 61a0c33478
commit 36bceb0899
2 changed files with 42 additions and 24 deletions

View File

@ -1697,9 +1697,8 @@ public:
const auto pface = pface_of_pvertex(pvertex);
std::cout << "k intersections: " << this->k(pface) << std::endl;
if (bbox_reached) {
this->k(pface) = 1; break;
}
if (is_occupied_edge && this->k(pface) == 1) {
/* this->k(pface) = 1; */ break;
} else if (is_occupied_edge && this->k(pface) == 1) {
break;
}
@ -1877,9 +1876,8 @@ public:
const auto pface = pface_of_pvertex(pvertex);
std::cout << "k intersections: " << this->k(pface) << std::endl;
if (bbox_reached) {
this->k(pface) = 1; break;
}
if (is_occupied_edge && this->k(pface) == 1) {
/* this->k(pface) = 1; */ break;
} else if (is_occupied_edge && this->k(pface) == 1) {
break;
}
@ -2089,7 +2087,7 @@ public:
std::cout << "k intersections: " << this->k(pface) << std::endl;
if (bbox_reached_back || bbox_reached_front) { // stop
this->k(pface) = 1;
/* this->k(pface) = 1; */
} else if ((is_occupied_edge_back && is_occupied_edge_front) && this->k(pface) == 1) { // stop
@ -2107,6 +2105,7 @@ public:
PFace new_pface = add_pface(std::array<PVertex, 3>{new_vertices[i], new_vertices[i + 1], pvertex});
this->k(new_pface) = k;
}
} else if ((!is_occupied_edge_back && !is_occupied_edge_front) && new_vertices.size() >= 2) { // add a triangle face
for (std::size_t i = 0; i < new_vertices.size() - 1; ++i) {
@ -2116,7 +2115,7 @@ public:
}
// CGAL_assertion_msg(false, "TODO: ADD A TRIANGLE FACE!");
} else if((is_occupied_edge_back || is_occupied_edge_front) && this->k(pface) == 1) { // add a triangle face
} else if ((is_occupied_edge_back || is_occupied_edge_front) && this->k(pface) == 1) { // add a triangle face
for (std::size_t i = 0; i < new_vertices.size() - 1; ++i) {
std::cout << "adding a new face" << std::endl;
@ -2132,7 +2131,7 @@ public:
// PFace new_pface = add_pface(std::array<PVertex, 3>{new_vertices[i], new_vertices[i + 1], pvertex});
// this->k(new_pface) = k;
// }
CGAL_assertion_msg(false, "TODO: ADD NEW OPEN CASE!");
CGAL_assertion_msg(false, "TODO: ADD NEW OPEN CASE! DO NOT FORGET TO UPDATE K!");
}
for (std::size_t i = 1; i < crossed.size() - 1; ++i) {

View File

@ -136,6 +136,11 @@ public:
KSR_3::dump (m_data, "intersected");
for (KSR::size_t i = 0; i < m_data.number_of_support_planes(); ++i) {
for (const auto pface : m_data.pfaces(i))
m_data.k(pface) = k;
}
std::size_t iter = 0;
m_min_time = 0;
m_max_time = time_step;
@ -585,7 +590,7 @@ private:
++ iter;
// if (iter == 3) {
// if (iter == 10) {
// exit(0);
// }
@ -687,21 +692,27 @@ private:
bool collision_other, bbox_reached_other;
// collision_other = m_data.collision_occured(pother, iedge).first;
std::tie(collision_other, bbox_reached_other) = m_data.is_occupied(pvertex, iedge);
std::tie(collision_other, bbox_reached_other) = m_data.is_occupied(pother, iedge);
std::cout << "other/bbox: " << collision_other << "/" << bbox_reached_other << std::endl;
if ((collision || collision_other) && m_data.k(pface) > 1)
m_data.k(pface) --;
std::cout << "k intersections: " << m_data.k(pface) << std::endl;
bool stop = false;
if (bbox_reached) {
m_data.k(pface) = 1; stop = true;
}
if ((collision || collision_other) && m_data.k(pface) == 1) {
std::cout << "pv po k bbox" << std::endl;
/* m_data.k(pface) = 1; */ stop = true;
} else if ((collision || collision_other) && m_data.k(pface) == 1) {
std::cout << "pv po k stop" << std::endl;
stop = true;
}
if ((collision || collision_other) && m_data.k(pface) > 1)
} else if ((collision || collision_other) && m_data.k(pface) > 1) {
std::cout << "pv po k continue" << std::endl;
m_data.k(pface)--;
}
CGAL_assertion(m_data.k(pface) >= 1);
if (stop) // polygon stops
@ -732,15 +743,23 @@ private:
std::tie(collision, bbox_reached) = m_data.is_occupied(pvertex, iedge);
std::cout << "collision/bbox: " << collision << "/" << bbox_reached << std::endl;
std::cout << "k intersections: " << m_data.k(pface) << std::endl;
bool stop = false;
if (bbox_reached) {
m_data.k(pface) = 1; stop = true;
}
if (collision && m_data.k(pface) == 1) {
std::cout << "pv k bbox" << std::endl;
/* m_data.k(pface) = 1; */ stop = true;
} else if (collision && m_data.k(pface) == 1) {
std::cout << "pv k stop" << std::endl;
stop = true;
}
if (collision && m_data.k(pface) > 1)
} else if (collision && m_data.k(pface) > 1) {
std::cout << "pv k continue" << std::endl;
m_data.k(pface)--;
}
CGAL_assertion(m_data.k(pface) >= 1);
if (stop) // polygon stops