- 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
pull/8/head
aramis_acg 2012-07-12 00:20:28 +00:00
parent d7fe61c255
commit 56bf755c4b
3 changed files with 16 additions and 11 deletions

View File

@ -85,14 +85,18 @@ public:
size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const { size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
ai_assert(InRange(a) && InRange(b)); ai_assert(InRange(a) && InRange(b));
a = fmod(a,static_cast<IfcFloat>( 360. )); a *= conv.angle_scale;
b = fmod(b,static_cast<IfcFloat>( 360. )); b *= conv.angle_scale;
return static_cast<size_t>( abs(ceil(( b-a)) / conv.settings.conicSamplingAngle) );
a = fmod(a,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
b = fmod(b,static_cast<IfcFloat>( AI_MATH_TWO_PI ));
const IfcFloat setting = static_cast<IfcFloat>( AI_MATH_PI * conv.settings.conicSamplingAngle / 180.0 );
return static_cast<size_t>( ceil(abs( b-a)) / setting);
} }
// -------------------------------------------------- // --------------------------------------------------
ParamRange GetParametricRange() const { ParamRange GetParametricRange() const {
return std::make_pair(static_cast<IfcFloat>( 0. ), static_cast<IfcFloat>( 360. )); return std::make_pair(static_cast<IfcFloat>( 0. ), static_cast<IfcFloat>( AI_MATH_TWO_PI / conv.angle_scale ));
} }
protected: protected:
@ -272,7 +276,7 @@ public:
IfcFloat acc = 0; IfcFloat acc = 0;
BOOST_FOREACH(const CurveEntry& entry, curves) { BOOST_FOREACH(const CurveEntry& entry, curves) {
const ParamRange& range = entry.first->GetParametricRange(); 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) { if (u < acc+delta) {
return entry.first->Eval( entry.second ? (u-acc) + range.first : range.second-(u-acc)); return entry.first->Eval( entry.second ? (u-acc) + range.first : range.second-(u-acc));
} }
@ -291,7 +295,7 @@ public:
IfcFloat acc = 0; IfcFloat acc = 0;
BOOST_FOREACH(const CurveEntry& entry, curves) { BOOST_FOREACH(const CurveEntry& entry, curves) {
const ParamRange& range = entry.first->GetParametricRange(); 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) { if (a <= acc+delta && b >= acc) {
const IfcFloat at = std::max(static_cast<IfcFloat>( 0. ),a-acc), bt = std::min(delta,b-acc); const IfcFloat at = std::max(static_cast<IfcFloat>( 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 ); 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(); const ParamRange range = GetParametricRange();
if (IsClosed()) { if (IsClosed()) {
ai_assert(range.first != std::numeric_limits<IfcFloat>::infinity() && range.second != std::numeric_limits<IfcFloat>::infinity()); return true;
u = range.first + fmod(u-range.first,range.second-range.first); //ai_assert(range.first != std::numeric_limits<IfcFloat>::infinity() && range.second != std::numeric_limits<IfcFloat>::infinity());
//u = range.first + fmod(u-range.first,range.second-range.first);
} }
const IfcFloat epsilon = 1e-5; const IfcFloat epsilon = 1e-5;
return u - range.first > -epsilon && range.second - u > -epsilon; return u - range.first > -epsilon && range.second - u > -epsilon;
@ -564,7 +569,7 @@ bool Curve :: InRange(IfcFloat u) const
IfcFloat Curve :: GetParametricRangeDelta() const IfcFloat Curve :: GetParametricRangeDelta() const
{ {
const ParamRange& range = GetParametricRange(); const ParamRange& range = GetParametricRange();
return range.second - range.first; return abs(range.second - range.first);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -154,7 +154,7 @@ void IFCImporter::SetupProperties(const Importer* pImp)
settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true); settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true);
settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true);
settings.conicSamplingAngle = 5.f; settings.conicSamplingAngle = 10.f;
settings.skipAnnotations = true; settings.skipAnnotations = true;
} }

View File

@ -100,7 +100,7 @@ struct ConversionData
{ {
ConversionData(const STEP::DB& db, const IFC::IfcProject& proj, aiScene* out,const IFCImporter::Settings& settings) ConversionData(const STEP::DB& db, const IFC::IfcProject& proj, aiScene* out,const IFCImporter::Settings& settings)
: len_scale(1.0) : len_scale(1.0)
, angle_scale(1.0) , angle_scale(-1.0)
, db(db) , db(db)
, proj(proj) , proj(proj)
, out(out) , out(out)