Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting unoriented polygon soup to polygon mesh #7655

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <CGAL/Polygonal_surface_reconstruction/internal/hypothesis.h>
#include <CGAL/Polygonal_surface_reconstruction/internal/compute_confidences.h>
#include <CGAL/Polygonal_surface_reconstruction/internal/point_set_with_planes.h>
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
#include <CGAL/Polygon_mesh_processing/polygon_mesh_to_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/repair_polygon_soup.h>

#include <unordered_map>

Expand Down Expand Up @@ -455,7 +459,12 @@ namespace CGAL {

// Converts from internal data structure to the required `PolygonMesh`.
output_mesh.clear(); // make sure it is empty.
CGAL::copy_face_graph(target_mesh, output_mesh);
std::vector<Point> points;
std::vector<std::vector<std::size_t> > polygons;
CGAL::Polygon_mesh_processing::polygon_mesh_to_polygon_soup(target_mesh, points, polygons);
CGAL::Polygon_mesh_processing::merge_duplicate_points_in_polygon_soup(points, polygons);
CGAL::Polygon_mesh_processing::orient_polygon_soup(points, polygons);
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(points, polygons, output_mesh);
}
else {
error_message_ = "solving the binary program failed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ namespace CGAL {
delete supporting_plane_;
supporting_plane_ = new Plane;
CGAL::linear_least_squares_fitting_3(pts.begin(), pts.end(), *supporting_plane_, CGAL::Dimension_tag<0>());

// Check orientation
int vote_for_opposite = 0;
for (std::size_t i = 0; i < size(); i++)
if (supporting_plane_->orthogonal_vector() * point_set_->normal_map()[at(i)] < 0)
vote_for_opposite++;
else
vote_for_opposite--;

if (vote_for_opposite > 0)
*supporting_plane_ = supporting_plane_->opposite();

return supporting_plane_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Point_set_3
Point_set_processing_3
Polygon
Polygonal_surface_reconstruction
Polygon_mesh_processing
Principal_component_analysis
Principal_component_analysis_LGPL
Profiling_tools
Expand Down