From ea71a1f8a76ccfc4c11d0ce77c12c32e1476042a Mon Sep 17 00:00:00 2001 From: Stefan Fink Date: Tue, 14 Jul 2020 12:17:13 +0200 Subject: [PATCH] IfcSiPrefix.cpp changes for MSVC 2013 IfcHierarchyHelper.h:176,185 changes in addRelatedObject about throw exception exception comes from ifcparse/IfcHierarchyHelper.h line 176 get_parent_of_relation(rel) if (get_parent_of_relation(rel) == relating_object) { ifcparse/IfcHierarchyHelper.h line 47 IfcUtil::IfcBaseClass* get_parent_of_relation(IfcUtil::IfcBaseClass* t) ifcparse/IfcSchema.h ptrdiff_t attribute_index(const std::string& attr_name) const { ptrdiff_t index = -1; -1 return but getArgument(..) Parameter is unsigned int in the methode -1 is ca. 42123423423423 and throw IfcParse::IfcAttributeOutOfRangeException we catch this exception and all works as expected and before in 0.5-rc1 --- src/ifcparse/IfcHierarchyHelper.h | 17 ++++++++++------- src/ifcparse/IfcSIPrefix.cpp | 8 ++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ifcparse/IfcHierarchyHelper.h b/src/ifcparse/IfcHierarchyHelper.h index 96da792aa8..b7cb5e1e61 100644 --- a/src/ifcparse/IfcHierarchyHelper.h +++ b/src/ifcparse/IfcHierarchyHelper.h @@ -173,13 +173,16 @@ public: bool found = false; for (typename T::list::it i = li->begin(); i != li->end(); ++i) { T* rel = *i; - if (get_parent_of_relation(rel) == relating_object) { - IfcEntityList::ptr products = get_children_of_relation(rel); - products->push(related_object); - set_children_of_relation(rel, products); - found = true; - break; - } + try { + if (get_parent_of_relation(rel) == relating_object) { + IfcEntityList::ptr products = get_children_of_relation(rel); + products->push(related_object); + set_children_of_relation(rel, products); + found = true; + break; + } + } + catch (...) { /* */ } } if (! found) { if (! owner_hist) { diff --git a/src/ifcparse/IfcSIPrefix.cpp b/src/ifcparse/IfcSIPrefix.cpp index 95bfc51c98..565f525ca8 100644 --- a/src/ifcparse/IfcSIPrefix.cpp +++ b/src/ifcparse/IfcSIPrefix.cpp @@ -73,8 +73,16 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) { return scale; } +#if _MSC_VER < 1900 +template double IfcParse::get_SI_equivalent(Ifc2x3::IfcNamedUnit* named_unit); +template double IfcParse::get_SI_equivalent(Ifc4::IfcNamedUnit* named_unit); +template double IfcParse::get_SI_equivalent(Ifc4x1::IfcNamedUnit* named_unit); +template double IfcParse::get_SI_equivalent(Ifc4x2::IfcNamedUnit* named_unit); +template double IfcParse::get_SI_equivalent(Ifc4x3_rc1::IfcNamedUnit* named_unit); +#else template double IfcParse::get_SI_equivalent(typename Ifc2x3::IfcNamedUnit* named_unit); template double IfcParse::get_SI_equivalent(typename Ifc4::IfcNamedUnit* named_unit); template double IfcParse::get_SI_equivalent(typename Ifc4x1::IfcNamedUnit* named_unit); template double IfcParse::get_SI_equivalent(typename Ifc4x2::IfcNamedUnit* named_unit); template double IfcParse::get_SI_equivalent(typename Ifc4x3_rc1::IfcNamedUnit* named_unit); +#endif