Skip to content

Commit 6dbf618

Browse files
committed
- Throw and catch IfcExceptions while parsing
- Fix issues with left-handed IfcCartesianTransformationOperator3D [fixes #3405491 Issues with MappingTarget of IfcMappedItem]
1 parent 34efb48 commit 6dbf618

4 files changed

Lines changed: 1005 additions & 994 deletions

File tree

src/ifcexpressparser/IfcExpressParser.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def __str__(self):
168168
return "typedef %s %s;"%(self.type,self.name)
169169
elif generator_mode == 'SOURCE' and isinstance(self.type,EnumType):
170170
generator_mode = 'SOURCE_TO'
171-
s = "std::string %(name)s::ToString(%(name)s v) {\n if ( v < 0 || v >= %(len)d ) throw;\n const char* names[] = %(type)s;\n return names[v];\n}\n"%self.__dict__
171+
s = "std::string %(name)s::ToString(%(name)s v) {\n if ( v < 0 || v >= %(len)d ) throw IfcException(\"Unable to find find keyword in schema\");\n const char* names[] = %(type)s;\n return names[v];\n}\n"%self.__dict__
172172
generator_mode = 'SOURCE_FROM'
173-
s += ("%(name)s::%(name)s %(name)s::FromString(const std::string& s) {\n%(type)s throw;\n}"%self.__dict__)%self.__dict__
173+
s += ("%(name)s::%(name)s %(name)s::FromString(const std::string& s) {\n%(type)s throw IfcException(\"Unable to find find keyword in schema\);\n}"%self.__dict__)%self.__dict__
174174
generator_mode = 'SOURCE'
175175
return s
176176
class Argument(object):
@@ -252,7 +252,7 @@ def __str__(self):
252252
"\nbool %(class_name)s::is(Type::Enum v) const { return v == Type::%(class_name)s || %(parent_class)s::is(v); }")+
253253
"\nType::Enum %(class_name)s::type() const { return Type::%(class_name)s; }"+
254254
"\nType::Enum %(class_name)s::Class() { return Type::%(class_name)s; }"+
255-
"\n%(class_name)s::%(class_name)s(IfcAbstractEntityPtr e) { if (!is(Type::%(class_name)s)) throw; entity = e; }")%self.__dict__)%self.__dict__
255+
"\n%(class_name)s::%(class_name)s(IfcAbstractEntityPtr e) { if (!is(Type::%(class_name)s)) throw IfcException(\"Unable to find find keyword in schema\"); entity = e; }")%self.__dict__)%self.__dict__
256256

257257

258258
from funcparserlib.parser import a, skip, many, maybe, some
@@ -427,8 +427,10 @@ def __str__(self):
427427
generator_mode = 'SOURCE'
428428

429429
print >>cpp_file, """#include "%(schema)s.h"
430+
#include "IfcException.h"
430431
431432
using namespace %(schema)s;
433+
using namespace IfcParse;
432434
433435
IfcSchemaEntity %(schema)s::SchemaEntity(IfcAbstractEntityPtr e) {
434436
switch(e->type()){"""%{'schema':schema_version}
@@ -437,11 +439,11 @@ def __str__(self):
437439
print >>cpp_file, " case Type::%s: return new IfcEntitySelect(e); break;"%e
438440
for e in entity_enumerations:
439441
print >>cpp_file, " case Type::%s: return new %s(e); break;"%(e,e)
440-
print >>cpp_file, " default: throw; break; "
442+
print >>cpp_file, " default: throw IfcException(\"Unable to find find keyword in schema\"); break; "
441443
print >>cpp_file, " }\n}"
442444
print >>cpp_file
443445
print >>cpp_file, "std::string Type::ToString(Enum v) {"
444-
print >>cpp_file, " if (v < 0 || v >= %d) throw;"%len(all_enumerations)
446+
print >>cpp_file, " if (v < 0 || v >= %d) throw IfcException(\"Unable to find find keyword in schema\");"%len(all_enumerations)
445447
print >>cpp_file, ' const char* names[] = { "%s" };'%'","'.join(all_enumerations)
446448
print >>cpp_file, ' return names[v];'
447449
print >>cpp_file, "}"
@@ -461,7 +463,7 @@ def __str__(self):
461463
print >>cpp_file, """}
462464
Type::Enum Type::FromString(const std::string& s) {
463465
std::map<std::string,Type::Enum>::const_iterator it = string_map.find(s);
464-
if ( it == string_map.end() ) throw;
466+
if ( it == string_map.end() ) throw IfcException("Unable to find find keyword in schema");
465467
else return it->second;
466468
}"""
467469

src/ifcgeom/IfcGeomHelpers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ bool IfcGeom::convert(const Ifc2x3::IfcCartesianTransformationOperator3D::ptr l,
139139
if ( l->hasAxis2() ) IfcGeom::convert(l->Axis2(),axis2);
140140
if ( l->hasAxis3() ) IfcGeom::convert(l->Axis3(),axis3);
141141
else axis3 = axis1.Crossed(axis2);
142-
const gp_Ax3 ax3 (origin,axis3,axis1);
142+
gp_Ax3 ax3 (origin,axis3,axis1);
143+
if ( axis2.Dot(ax3.YDirection()) < 0 ) ax3.YReverse();
143144
trsf.SetTransformation(ax3);
144145
trsf.Invert();
145146
if ( l->hasScale() ) trsf.SetScaleFactor(l->Scale());

0 commit comments

Comments
 (0)