From 56bf755c4beadd0a7e14d3723a976feef5e9234a Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Thu, 12 Jul 2012 00:20:28 +0000 Subject: [PATCH] - Ifc: fix handling of curves with RADIAN parameters. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1289 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/IFCCurve.cpp | 23 ++++++++++++++--------- code/IFCLoader.cpp | 2 +- code/IFCUtil.h | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/code/IFCCurve.cpp b/code/IFCCurve.cpp index 4d9f499e0..fab256f6a 100644 --- a/code/IFCCurve.cpp +++ b/code/IFCCurve.cpp @@ -85,14 +85,18 @@ public: size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const { ai_assert(InRange(a) && InRange(b)); - a = fmod(a,static_cast( 360. )); - b = fmod(b,static_cast( 360. )); - return static_cast( abs(ceil(( b-a)) / conv.settings.conicSamplingAngle) ); + a *= conv.angle_scale; + b *= conv.angle_scale; + + a = fmod(a,static_cast( AI_MATH_TWO_PI )); + b = fmod(b,static_cast( AI_MATH_TWO_PI )); + const IfcFloat setting = static_cast( AI_MATH_PI * conv.settings.conicSamplingAngle / 180.0 ); + return static_cast( ceil(abs( b-a)) / setting); } // -------------------------------------------------- ParamRange GetParametricRange() const { - return std::make_pair(static_cast( 0. ), static_cast( 360. )); + return std::make_pair(static_cast( 0. ), static_cast( AI_MATH_TWO_PI / conv.angle_scale )); } protected: @@ -272,7 +276,7 @@ public: IfcFloat acc = 0; BOOST_FOREACH(const CurveEntry& entry, curves) { const ParamRange& range = entry.first->GetParametricRange(); - const IfcFloat delta = range.second-range.first; + const IfcFloat delta = abs(range.second-range.first); if (u < acc+delta) { return entry.first->Eval( entry.second ? (u-acc) + range.first : range.second-(u-acc)); } @@ -291,7 +295,7 @@ public: IfcFloat acc = 0; BOOST_FOREACH(const CurveEntry& entry, curves) { const ParamRange& range = entry.first->GetParametricRange(); - const IfcFloat delta = range.second-range.first; + const IfcFloat delta = abs(range.second-range.first); if (a <= acc+delta && b >= acc) { const IfcFloat at = std::max(static_cast( 0. ),a-acc), bt = std::min(delta,b-acc); cnt += entry.first->EstimateSampleCount( entry.second ? at + range.first : range.second - bt, entry.second ? bt + range.first : range.second - at ); @@ -552,8 +556,9 @@ bool Curve :: InRange(IfcFloat u) const { const ParamRange range = GetParametricRange(); if (IsClosed()) { - ai_assert(range.first != std::numeric_limits::infinity() && range.second != std::numeric_limits::infinity()); - u = range.first + fmod(u-range.first,range.second-range.first); + return true; + //ai_assert(range.first != std::numeric_limits::infinity() && range.second != std::numeric_limits::infinity()); + //u = range.first + fmod(u-range.first,range.second-range.first); } const IfcFloat epsilon = 1e-5; return u - range.first > -epsilon && range.second - u > -epsilon; @@ -564,7 +569,7 @@ bool Curve :: InRange(IfcFloat u) const IfcFloat Curve :: GetParametricRangeDelta() const { const ParamRange& range = GetParametricRange(); - return range.second - range.first; + return abs(range.second - range.first); } // ------------------------------------------------------------------------------------------------ diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index b4ef88aee..add16565a 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -154,7 +154,7 @@ void IFCImporter::SetupProperties(const Importer* pImp) settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); - settings.conicSamplingAngle = 5.f; + settings.conicSamplingAngle = 10.f; settings.skipAnnotations = true; } diff --git a/code/IFCUtil.h b/code/IFCUtil.h index 669befea4..a8fe6f680 100644 --- a/code/IFCUtil.h +++ b/code/IFCUtil.h @@ -100,7 +100,7 @@ struct ConversionData { ConversionData(const STEP::DB& db, const IFC::IfcProject& proj, aiScene* out,const IFCImporter::Settings& settings) : len_scale(1.0) - , angle_scale(1.0) + , angle_scale(-1.0) , db(db) , proj(proj) , out(out)