From 624e296d248818e2e98ae8de9639d0962f9a6647 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sat, 13 Mar 2021 10:05:33 +0100 Subject: [PATCH] #1368 fix layerset folding: check length thichkness ratio --- src/ifcgeom/IfcGeomFunctions.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index e21427076b..b324ff3f22 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -2600,6 +2600,8 @@ bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const IfcRepre } } + const double total_thickness = std::accumulate(thicknesses.begin(), thicknesses.end(), 0.); + gp_Pnt own_axis_start, own_axis_end; find_wall_end_points(wall, own_axis_start, own_axis_end); @@ -2661,6 +2663,16 @@ bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const IfcRepre } */ + const double length_required = endpoint_connections.size() * total_thickness; + // @todo this is not precisely the distance in case of curved walls. Also, it's safer + // to first reproject the body onto the axis to get the precise curve parametrization + // range. It's only a safeguard though, so can probably be approximated. + const double axis_length = own_axis_start.Distance(own_axis_end); + if (length_required > axis_length) { + Logger::Warning("The wall axis is not long enough to accomodate the fold points"); + return false; + } + for (endpoint_connections_t::const_iterator it = endpoint_connections.begin(); it != endpoint_connections.end(); ++it) { IfcSchema::IfcConnectionTypeEnum::Value connection_type = it->first.first; @@ -2746,8 +2758,6 @@ bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const IfcRepre double layer_offset = 0; - const double total_thickness = std::accumulate(thicknesses.begin(), thicknesses.end(), 0.); - std::vector::const_iterator thickness = thicknesses.begin(); result_t::iterator result_vector = result.begin() + 1; @@ -2778,7 +2788,8 @@ bool IfcGeom::Kernel::fold_layers(const IfcSchema::IfcWall* wall, const IfcRepre surface->D1(u, v, Ps, Vs1, Vs2); Vs1.Cross(Vs2); - if (Vs1.IsParallel(Vc, 1.e-5)) { + if (Vs1.IsNormal(Vc, 1.e-5)) { + int a = 1; Logger::Warning("Connected walls are parallel"); parallel = true; } else if (w < axis_u1 || w > axis_u2) {