Merge remote-tracking branch 'cgal/cgal' into v0.7.0

This commit is contained in:
Thomas Krijnen
2019-01-23 15:44:19 +01:00
14 changed files with 3211 additions and 424 deletions
@@ -17,24 +17,44 @@ void triangulate_helper(const cgal_shape_t& shape_const, const IfcGeom::Iterator
vertex->point() = vertex->point().transform(trsf);
}
if (!s.is_valid()) {
Logger::Message(Logger::LOG_ERROR, "Invalid Polyhedron_3 in object (before triangulation)");
return;
}
// Triangulate the shape and compute the normals
std::map<cgal_vertex_descriptor_t, Kernel::Vector_3> vertex_normals;
boost::associative_property_map<std::map<cgal_vertex_descriptor_t, Kernel::Vector_3>> vertex_normals_map(vertex_normals);
// std::map<cgal_vertex_descriptor_t, Kernel::Vector_3> vertex_normals;
// boost::associative_property_map<std::map<cgal_vertex_descriptor_t, Kernel::Vector_3>> vertex_normals_map(vertex_normals);
std::map<cgal_face_descriptor_t, Kernel::Vector_3> face_normals;
boost::associative_property_map<std::map<cgal_face_descriptor_t, Kernel::Vector_3>> face_normals_map(face_normals);
if (CGAL::Polygon_mesh_processing::triangulate_faces(s)) {
// std::cout << "Triangulated model: " << s.size_of_facets() << " facets and " << s.size_of_vertices() << " vertices" << std::endl;
} else {
Logger::Message(Logger::LOG_ERROR, "Failed to triangulate shape");
bool success = false;
try {
success = CGAL::Polygon_mesh_processing::triangulate_faces(s);
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "Triangulation crashed");
return;
}
CGAL::Polygon_mesh_processing::compute_normals(s, vertex_normals_map, face_normals_map);
// Iterates over the faces of the shape
int num_faces = 0, num_vertices = 0;
if (!success) {
Logger::Message(Logger::LOG_ERROR, return;
"Triangulation failed");
}
// std::cout << "Triangulated model: " << s.size_of_facets() << " facets and " << s.size_of_vertices() << " vertices" << std::endl;
if (!s.is_valid()) {
Logger::Message(Logger::LOG_ERROR, "Invalid Polyhedron_3 in object (after triangulation)");
return;
}
// CGAL::Polygon_mesh_processing::compute_normals(s, vertex_normals_map, face_normals_map);
CGAL::Polygon_mesh_processing::compute_face_normals(s, face_normals_map);
for (auto &face: faces(s)) {
if (!face->is_triangle()) {
std::cout << "Warning: non-triangular face!" << std::endl;
continue;
}
CGAL::Polyhedron_3<Kernel>::Halfedge_around_facet_const_circulator current_halfedge = face->facet_begin();
do {
t->addVertex(surface_style_id,
@@ -20,6 +20,13 @@
#ifndef CGALCONVERSIONRESULT_H
#define CGALCONVERSIONRESULT_H
#include "../../../ifcgeom/schema_agnostic/Kernel.h"
#include "../../../ifcgeom/schema_agnostic/IfcGeomElement.h"
#include "../../../ifcgeom/schema_agnostic/cgal/CgalConversionResult.h"
// @todo create separate shapetype enum?
#include "../../../ifcgeom/kernels/opencascade/IfcGeomShapeType.h"
#include <boost/property_map/property_map.hpp>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
@@ -28,12 +35,16 @@
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/self_intersections.h>
#include <CGAL/Nef_polyhedron_3.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Aff_transformation_3 cgal_placement_t;
typedef Kernel::Point_3 cgal_point_t;
typedef Kernel::Vector_3 cgal_direction_t;
typedef Kernel::Vector_3 cgal_vector_t;
typedef Kernel::Plane_3 cgal_plane_t;
typedef std::vector<Kernel::Point_3> cgal_curve_t;
typedef std::vector<Kernel::Point_3> cgal_wire_t;
@@ -60,19 +71,15 @@ namespace IfcGeom {
operator const cgal_placement_t& () { return trsf_; }
virtual double Value(int i, int j) const {
// TODO: Check
// std::cout << "Getting CgalPlacement with i = " << i << " and j = " << j << std::endl;
return CGAL::to_double(trsf_.cartesian(i-1, j-1));
return CGAL::to_double(trsf_.cartesian(i-1, j-1));
}
virtual void Multiply(const ConversionResultPlacement* other) {
// TODO: Check
trsf_ = ((CgalPlacement *)other)->trsf_ * trsf_;
trsf_ = trsf_ * ((CgalPlacement *)other)->trsf_;
}
virtual void PreMultiply(const ConversionResultPlacement* other) {
// TODO: Check
trsf_ = trsf_ * ((CgalPlacement *)other)->trsf_;
trsf_ = ((CgalPlacement *)other)->trsf_ * trsf_;
}
virtual ConversionResultPlacement* clone() const {