mirror of https://github.com/CGAL/cgal
fix cheese18 --merge-facets
The explanation of the bug: `split_graph_into_polylines` can reverse the orientation of a polygon
This commit is contained in:
parent
616cdfbc7a
commit
5bc5ec4f46
|
|
@ -534,7 +534,7 @@ public:
|
|||
const auto vb = *circ;
|
||||
const auto c_id = this->constraint_from_extremities(va, vb);
|
||||
if(c_id != Constraint_id{}) {
|
||||
const bool constraint_c_id_is_reversed = true;
|
||||
const bool constraint_c_id_is_reversed = va != (*this->constraint_hierarchy.vertices_in_constraint_begin(c_id));
|
||||
border.push_back(Face_edge{c_id, constraint_c_id_is_reversed});
|
||||
constraint_to_faces.emplace(c_id, polygon_contraint_id);
|
||||
} else {
|
||||
|
|
@ -635,9 +635,7 @@ private:
|
|||
const auto v_end = this->constraint_hierarchy.vertices_in_constraint_end(c_id);
|
||||
CGAL_assertion(std::distance(v_begin, v_end) >= 2);
|
||||
auto va = *v_begin;
|
||||
auto vb_it = v_end;
|
||||
--vb_it;
|
||||
auto vb = *vb_it;
|
||||
auto vb = *std::prev(v_end);
|
||||
if(reversed) {
|
||||
using std::swap;
|
||||
swap(va, vb);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ int main(int argc, char* argv[])
|
|||
try {
|
||||
go(mesh, output_filename);
|
||||
} catch(CGAL::Failure_exception& e) {
|
||||
if(e.expression().find(std::string("orientation(p0, p1, p2, p3) == POSITIVE")) != std::string::npos)
|
||||
if(e.expression().find(std::string("handles.back() == va")) != std::string::npos)
|
||||
{
|
||||
std::cerr << "BAD MESH! " << mesh.number_of_faces() << " faces\n";
|
||||
std::ofstream bad("bad.off");
|
||||
|
|
@ -302,8 +302,28 @@ int go(Mesh mesh, std::string output_filename) {
|
|||
CDT_3_try {
|
||||
if(merge_facets) {
|
||||
for(int i = 0; i < nb_patches; ++i) {
|
||||
const auto& edges = patch_edges[i];
|
||||
auto& edges = patch_edges[i];
|
||||
auto polylines = segment_soup_to_polylines(edges);
|
||||
while(true) {
|
||||
const auto non_closed_polylines_begin =
|
||||
std::partition(polylines.begin(), polylines.end(),
|
||||
[](const auto& polyline) { return polyline.front() == polyline.back(); });
|
||||
if(non_closed_polylines_begin == polylines.end())
|
||||
break;
|
||||
edges.clear();
|
||||
for(auto it = non_closed_polylines_begin; it != polylines.end(); ++it) {
|
||||
auto& polyline = *it;
|
||||
for(auto it = polyline.begin(), end = polyline.end() - 1; it != end; ++it) {
|
||||
edges.emplace_back(*it, *(it + 1));
|
||||
}
|
||||
}
|
||||
polylines.erase(non_closed_polylines_begin, polylines.end());
|
||||
auto other_polylines = segment_soup_to_polylines(edges);
|
||||
polylines.insert(polylines.end(),
|
||||
std::make_move_iterator(other_polylines.begin()),
|
||||
std::make_move_iterator(other_polylines.end()));
|
||||
}
|
||||
|
||||
std::optional<int> face_index;
|
||||
for(auto& polyline: polylines) {
|
||||
assert(polyline.front() == polyline.back());
|
||||
|
|
|
|||
Loading…
Reference in New Issue