mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-06 07:51:47 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user