mirror of https://github.com/CGAL/cgal
changed the output from unoriented polygon soup to oriented polygon mesh
This commit is contained in:
parent
b534d12620
commit
9eda4485d2
|
|
@ -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>
|
||||
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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_;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue