mirror of https://github.com/CGAL/cgal
Use a border edge
This commit is contained in:
parent
7b9bcb8dc3
commit
ded672a308
|
|
@ -548,35 +548,49 @@ private:
|
||||||
.visitor(boost::make_bfs_visitor(boost::write_property(
|
.visitor(boost::make_bfs_visitor(boost::write_property(
|
||||||
boost::typed_identity_property_map<CDT_2_face_handle>(),
|
boost::typed_identity_property_map<CDT_2_face_handle>(),
|
||||||
std::back_inserter(fh_region), boost::on_finish_vertex()))));
|
std::back_inserter(fh_region), boost::on_finish_vertex()))));
|
||||||
|
CGAL_assertion(!fh_region.empty());
|
||||||
|
CGAL_assertion(fh == fh_region[0]);
|
||||||
return fh_region;
|
return fh_region;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto brute_force_border_3_of_region(const std::vector<CDT_2_face_handle>& fh_region) {
|
auto brute_force_border_3_of_region(const std::vector<CDT_2_face_handle>& fh_region) {
|
||||||
std::set<std::pair<Vertex_handle, Vertex_handle>> border_edges;
|
std::set<std::pair<Vertex_handle, Vertex_handle>> border_edges_set;
|
||||||
for(const auto fh: fh_region) {
|
for(const auto fh: fh_region) {
|
||||||
for(int i = 0; i < 3; ++i) {
|
for(int i = 0; i < 3; ++i) {
|
||||||
const auto va = fh->vertex(CDT_2::cw(i))->info().vertex_handle_3d;
|
const auto va = fh->vertex(CDT_2::cw(i))->info().vertex_handle_3d;
|
||||||
const auto vb = fh->vertex(CDT_2::ccw(i))->info().vertex_handle_3d;
|
const auto vb = fh->vertex(CDT_2::ccw(i))->info().vertex_handle_3d;
|
||||||
if(this->tds().is_edge(va, vb)) {
|
if(this->tds().is_edge(va, vb)) {
|
||||||
border_edges.insert(CGAL::make_sorted_pair(va, vb));
|
CGAL_assertion_code(const auto result =)
|
||||||
|
border_edges_set.insert(CGAL::make_sorted_pair(va, vb));
|
||||||
|
CGAL_assertion(result.second == true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::vector<Edge> border_edges;
|
||||||
|
border_edges.reserve(border_edges_set.size());
|
||||||
|
for(const auto& [va, vb]: border_edges_set) {
|
||||||
|
Cell_handle c;
|
||||||
|
int i, j;
|
||||||
|
CGAL_assume(this->tds().is_edge(va, vb, c, i, j));
|
||||||
|
border_edges.emplace_back(c, i, j);
|
||||||
|
}
|
||||||
|
#if CGAL_DEBUG_CDT_3
|
||||||
|
std::cerr << "region size is: " << fh_region.size() << "\n";
|
||||||
|
std::cerr << "region border size is: " << border_edges.size() << "\n";
|
||||||
|
if(border_edges.size() < 3) {
|
||||||
|
std::ofstream dump_region("dump_region_with_size_2.polylines.txt");
|
||||||
|
dump_region.precision(17);
|
||||||
|
write_region(dump_region, fh_region);
|
||||||
|
}
|
||||||
|
#endif // CGAL_DEBUG_CDT_3
|
||||||
return border_edges;
|
return border_edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Edge> search_first_intersection(const CDT_2& cdt_2, const auto& fh_region) {
|
std::optional<Edge>
|
||||||
for(const auto fh_2d : fh_region) {
|
search_first_intersection(const CDT_2& cdt_2, const auto& fh_region, const Edge border_edge) {
|
||||||
CGAL_assertion(true == fh_2d->info().missing_subface);
|
const auto [c, i, j] = border_edge;
|
||||||
CGAL_assertion(false == fh_2d->info().is_outside_the_face);
|
const Vertex_handle va_3d = c->vertex(i);
|
||||||
for(int index = 0; index < 3; ++index) {
|
const Vertex_handle vb_3d = c->vertex(j);
|
||||||
const auto va_3d = fh_2d->vertex(cdt_2.cw(index))->info().vertex_handle_3d;
|
|
||||||
const auto vb_3d = fh_2d->vertex(cdt_2.ccw(index))->info().vertex_handle_3d;
|
|
||||||
Cell_handle c;
|
|
||||||
int i, j;
|
|
||||||
const bool is_3d = this->tds().is_edge(va_3d, vb_3d, c, i, j);
|
|
||||||
CGAL_assertion(fh_2d->info().is_edge_also_in_3d_triangulation[unsigned(index)] == is_3d);
|
|
||||||
if(is_3d) {
|
|
||||||
auto cell_circ = this->incident_cells(c, i, j), end = cell_circ;
|
auto cell_circ = this->incident_cells(c, i, j), end = cell_circ;
|
||||||
CGAL_assertion(cell_circ != nullptr);
|
CGAL_assertion(cell_circ != nullptr);
|
||||||
do {
|
do {
|
||||||
|
|
@ -602,27 +616,14 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(++cell_circ != end);
|
} while(++cell_circ != end);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void restore_subface_region(const CDT_2& cdt_2, CDT_2_face_handle fh) {
|
void restore_subface_region(const CDT_2& cdt_2, CDT_2_face_handle fh) {
|
||||||
const auto fh_region = region(cdt_2, fh);
|
const auto fh_region = region(cdt_2, fh);
|
||||||
assert(!fh_region.empty());
|
|
||||||
assert(fh == fh_region[0]);
|
|
||||||
const auto border_edges = brute_force_border_3_of_region(fh_region);
|
const auto border_edges = brute_force_border_3_of_region(fh_region);
|
||||||
#if CGAL_DEBUG_CDT_3
|
const Edge first_border_edge = border_edges[0];
|
||||||
std::cerr << "region size is: " << fh_region.size() << "\n";
|
const auto found_seg = search_first_intersection(cdt_2, fh_region, first_border_edge);
|
||||||
std::cerr << "region border size is: " << border_edges.size() << "\n";
|
|
||||||
if(border_edges.size() < 3) {
|
|
||||||
std::ofstream dump_region("dump_region_with_size_2.polylines.txt");
|
|
||||||
dump_region.precision(17);
|
|
||||||
write_region(dump_region, fh_region);
|
|
||||||
}
|
|
||||||
#endif // CGAL_DEBUG_CDT_3
|
|
||||||
const auto found_seg = search_first_intersection(cdt_2, fh_region);
|
|
||||||
if(!found_seg) {
|
if(!found_seg) {
|
||||||
std::cerr << "No segment found\n";
|
std::cerr << "No segment found\n";
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue