From 712a7ee779da81c3331071af918a841f72ee450d Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Wed, 3 Jan 2018 16:14:20 +0100 Subject: [PATCH] Fixed bug in IFC where SweptDiskSolid tessellation would fail for polylines with only 2 points. Indeed, the EstimateSampleCount is not always accurate in this case, as the number of generated curvature pointer is greater by one. Moreover, it is redundant to call EstimateSampleCount, as the SampleDiscrete method will provide the (correct) number of points anyway. This commit fix the described bug, but also increase the efficiency of the ProcessSweptDiskSolid method, as EstimateSampleCount is only called once now, instead of two times. --- code/IFCGeometry.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/IFCGeometry.cpp b/code/IFCGeometry.cpp index 908f5e065..332b2af56 100644 --- a/code/IFCGeometry.cpp +++ b/code/IFCGeometry.cpp @@ -330,7 +330,11 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv const unsigned int cnt_segments = conv.settings.cylindricalTessellation; const IfcFloat deltaAngle = AI_MATH_TWO_PI/cnt_segments; - const size_t samples = curve->EstimateSampleCount(solid.StartParam,solid.EndParam); + TempMesh temp; + curve->SampleDiscrete(temp, solid.StartParam, solid.EndParam); + const std::vector& curve_points = temp.verts; + + const size_t samples = curve_points.size(); result.verts.reserve(cnt_segments * samples * 4); result.vertcnt.reserve((cnt_segments - 1) * samples); @@ -338,10 +342,6 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv std::vector points; points.reserve(cnt_segments * samples); - TempMesh temp; - curve->SampleDiscrete(temp,solid.StartParam,solid.EndParam); - const std::vector& curve_points = temp.verts; - if(curve_points.empty()) { IFCImporter::LogWarn("curve evaluation yielded no points (IfcSweptDiskSolid)"); return;