mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Don't estimate normal from collinear edges in TTL serializer
This commit is contained in:
@@ -265,14 +265,25 @@ void TtlWktSerializer::write(const IfcGeom::TriangulationElement* o)
|
|||||||
double lowest_z = std::numeric_limits<double>::infinity();
|
double lowest_z = std::numeric_limits<double>::infinity();
|
||||||
|
|
||||||
for (const auto& f : o->geometry().polyhedral_faces_with_holes()) {
|
for (const auto& f : o->geometry().polyhedral_faces_with_holes()) {
|
||||||
auto v0 = vertex_map.transpose().row(f[0][0]);
|
Eigen::Vector3d v0, v1, v2, v1_v0, v2_v0;
|
||||||
auto v1 = vertex_map.transpose().row(f[0][1]);
|
for (size_t i = 0; i < f[0].size(); ++i) {
|
||||||
auto v2 = vertex_map.transpose().row(f[0][2]);
|
v0 = vertex_map.transpose().row(f[0][0 + i]);
|
||||||
auto v1_v0 = v1 - v0;
|
v1 = vertex_map.transpose().row(f[0][1 + i]);
|
||||||
auto v2_v0 = v2 - v0;
|
v2 = vertex_map.transpose().row(f[0][2 + i]);
|
||||||
|
v1_v0 = v1 - v0;
|
||||||
|
v2_v0 = v2 - v0;
|
||||||
|
v1_v0.normalize();
|
||||||
|
v2_v0.normalize();
|
||||||
|
if ((std::abs(v1_v0.dot(v2_v0)) + 1.e-9) >= 1.0) {
|
||||||
|
// Don't derive normal from collinear edges
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Eigen::Vector3d cross_product = v1_v0.cross(v2_v0);
|
Eigen::Vector3d cross_product = v1_v0.cross(v2_v0);
|
||||||
cross_product.normalize();
|
cross_product.normalize();
|
||||||
|
|
||||||
// @nb we take abs because so that we can ignore face orientation and potential convatities rquire
|
// @nb we take abs because so that we can ignore face orientation and potential convatities rquire
|
||||||
if ((std::abs(cross_product.z()) + 1.e-9) >= 1.0 && v0.z() < lowest_z) {
|
if ((std::abs(cross_product.z()) + 1.e-9) >= 1.0 && v0.z() < lowest_z) {
|
||||||
lowest_face = f.begin();
|
lowest_face = f.begin();
|
||||||
|
|||||||
Reference in New Issue
Block a user