Fix --no-normals ignored by CGAL kernel for OBJ output (#8861)

CgalShape::Triangulate() unconditionally computed and emitted vertex
normals via t->addNormal(), never checking the DontEmitNormals
("--no-normals") setting. The OpenCascade kernel already gates its
equivalent addNormal() call on this setting, so the CGAL kernel is
brought in line with it: normals are only added when
settings::DontEmitNormals is not set, matching the OCC behavior and
the documented CLI flag.

Generated with the assistance of an AI coding tool.
This commit is contained in:
Petru Conduraru
2026-07-22 12:46:38 +03:00
parent 4ceadd8f10
commit 17011c7bcc
@@ -382,6 +382,7 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
}
const bool setting_use_original_edges = settings.get<ifcopenshell::geometry::settings::CgalEmitOriginalEdges>().get();
const bool calculate_normals = !settings.get<ifcopenshell::geometry::settings::DontEmitNormals>().get();
std::set<std::set<Kernel_::Point_3>> original_edges;
if (setting_use_original_edges) {
@@ -541,11 +542,13 @@ void ifcopenshell::geometry::CgalShape::Triangulate(ifcopenshell::geometry::Sett
);
welds.insert({ pn, vidx });
auto nx = CGAL::to_double(face_normals_map[face].cartesian(0));
auto ny = CGAL::to_double(face_normals_map[face].cartesian(1));
auto nz = CGAL::to_double(face_normals_map[face].cartesian(2));
if (calculate_normals) {
auto nx = CGAL::to_double(face_normals_map[face].cartesian(0));
auto ny = CGAL::to_double(face_normals_map[face].cartesian(1));
auto nz = CGAL::to_double(face_normals_map[face].cartesian(2));
t->addNormal(nx, ny, nz);
t->addNormal(nx, ny, nz);
}
} else {
vidx = it->second;
}