mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
- Throw and catch IfcExceptions while parsing
- Fix issues with left-handed IfcCartesianTransformationOperator3D [fixes #3405491 Issues with MappingTarget of IfcMappedItem]
This commit is contained in:
@@ -168,9 +168,9 @@ class Typedef:
|
|||||||
return "typedef %s %s;"%(self.type,self.name)
|
return "typedef %s %s;"%(self.type,self.name)
|
||||||
elif generator_mode == 'SOURCE' and isinstance(self.type,EnumType):
|
elif generator_mode == 'SOURCE' and isinstance(self.type,EnumType):
|
||||||
generator_mode = 'SOURCE_TO'
|
generator_mode = 'SOURCE_TO'
|
||||||
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__
|
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__
|
||||||
generator_mode = 'SOURCE_FROM'
|
generator_mode = 'SOURCE_FROM'
|
||||||
s += ("%(name)s::%(name)s %(name)s::FromString(const std::string& s) {\n%(type)s throw;\n}"%self.__dict__)%self.__dict__
|
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__
|
||||||
generator_mode = 'SOURCE'
|
generator_mode = 'SOURCE'
|
||||||
return s
|
return s
|
||||||
class Argument(object):
|
class Argument(object):
|
||||||
@@ -252,7 +252,7 @@ class Classdef:
|
|||||||
"\nbool %(class_name)s::is(Type::Enum v) const { return v == Type::%(class_name)s || %(parent_class)s::is(v); }")+
|
"\nbool %(class_name)s::is(Type::Enum v) const { return v == Type::%(class_name)s || %(parent_class)s::is(v); }")+
|
||||||
"\nType::Enum %(class_name)s::type() const { return Type::%(class_name)s; }"+
|
"\nType::Enum %(class_name)s::type() const { return Type::%(class_name)s; }"+
|
||||||
"\nType::Enum %(class_name)s::Class() { return Type::%(class_name)s; }"+
|
"\nType::Enum %(class_name)s::Class() { return Type::%(class_name)s; }"+
|
||||||
"\n%(class_name)s::%(class_name)s(IfcAbstractEntityPtr e) { if (!is(Type::%(class_name)s)) throw; entity = e; }")%self.__dict__)%self.__dict__
|
"\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__
|
||||||
|
|
||||||
|
|
||||||
from funcparserlib.parser import a, skip, many, maybe, some
|
from funcparserlib.parser import a, skip, many, maybe, some
|
||||||
@@ -427,8 +427,10 @@ print >>h_file, "}\n\n#endif"
|
|||||||
generator_mode = 'SOURCE'
|
generator_mode = 'SOURCE'
|
||||||
|
|
||||||
print >>cpp_file, """#include "%(schema)s.h"
|
print >>cpp_file, """#include "%(schema)s.h"
|
||||||
|
#include "IfcException.h"
|
||||||
|
|
||||||
using namespace %(schema)s;
|
using namespace %(schema)s;
|
||||||
|
using namespace IfcParse;
|
||||||
|
|
||||||
IfcSchemaEntity %(schema)s::SchemaEntity(IfcAbstractEntityPtr e) {
|
IfcSchemaEntity %(schema)s::SchemaEntity(IfcAbstractEntityPtr e) {
|
||||||
switch(e->type()){"""%{'schema':schema_version}
|
switch(e->type()){"""%{'schema':schema_version}
|
||||||
@@ -437,11 +439,11 @@ for e in simple_enumerations:
|
|||||||
print >>cpp_file, " case Type::%s: return new IfcEntitySelect(e); break;"%e
|
print >>cpp_file, " case Type::%s: return new IfcEntitySelect(e); break;"%e
|
||||||
for e in entity_enumerations:
|
for e in entity_enumerations:
|
||||||
print >>cpp_file, " case Type::%s: return new %s(e); break;"%(e,e)
|
print >>cpp_file, " case Type::%s: return new %s(e); break;"%(e,e)
|
||||||
print >>cpp_file, " default: throw; break; "
|
print >>cpp_file, " default: throw IfcException(\"Unable to find find keyword in schema\"); break; "
|
||||||
print >>cpp_file, " }\n}"
|
print >>cpp_file, " }\n}"
|
||||||
print >>cpp_file
|
print >>cpp_file
|
||||||
print >>cpp_file, "std::string Type::ToString(Enum v) {"
|
print >>cpp_file, "std::string Type::ToString(Enum v) {"
|
||||||
print >>cpp_file, " if (v < 0 || v >= %d) throw;"%len(all_enumerations)
|
print >>cpp_file, " if (v < 0 || v >= %d) throw IfcException(\"Unable to find find keyword in schema\");"%len(all_enumerations)
|
||||||
print >>cpp_file, ' const char* names[] = { "%s" };'%'","'.join(all_enumerations)
|
print >>cpp_file, ' const char* names[] = { "%s" };'%'","'.join(all_enumerations)
|
||||||
print >>cpp_file, ' return names[v];'
|
print >>cpp_file, ' return names[v];'
|
||||||
print >>cpp_file, "}"
|
print >>cpp_file, "}"
|
||||||
@@ -461,7 +463,7 @@ for e in all_enumerations:
|
|||||||
print >>cpp_file, """}
|
print >>cpp_file, """}
|
||||||
Type::Enum Type::FromString(const std::string& s) {
|
Type::Enum Type::FromString(const std::string& s) {
|
||||||
std::map<std::string,Type::Enum>::const_iterator it = string_map.find(s);
|
std::map<std::string,Type::Enum>::const_iterator it = string_map.find(s);
|
||||||
if ( it == string_map.end() ) throw;
|
if ( it == string_map.end() ) throw IfcException("Unable to find find keyword in schema");
|
||||||
else return it->second;
|
else return it->second;
|
||||||
}"""
|
}"""
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,8 @@ bool IfcGeom::convert(const Ifc2x3::IfcCartesianTransformationOperator3D::ptr l,
|
|||||||
if ( l->hasAxis2() ) IfcGeom::convert(l->Axis2(),axis2);
|
if ( l->hasAxis2() ) IfcGeom::convert(l->Axis2(),axis2);
|
||||||
if ( l->hasAxis3() ) IfcGeom::convert(l->Axis3(),axis3);
|
if ( l->hasAxis3() ) IfcGeom::convert(l->Axis3(),axis3);
|
||||||
else axis3 = axis1.Crossed(axis2);
|
else axis3 = axis1.Crossed(axis2);
|
||||||
const gp_Ax3 ax3 (origin,axis3,axis1);
|
gp_Ax3 ax3 (origin,axis3,axis1);
|
||||||
|
if ( axis2.Dot(ax3.YDirection()) < 0 ) ax3.YReverse();
|
||||||
trsf.SetTransformation(ax3);
|
trsf.SetTransformation(ax3);
|
||||||
trsf.Invert();
|
trsf.Invert();
|
||||||
if ( l->hasScale() ) trsf.SetScaleFactor(l->Scale());
|
if ( l->hasScale() ) trsf.SetScaleFactor(l->Scale());
|
||||||
|
|||||||
+987
-985
File diff suppressed because one or more lines are too long
@@ -568,8 +568,14 @@ bool Ifc::Init(IfcParse::File* f) {
|
|||||||
if ( log1 ) std::cout << "Scanning file..." << std::endl;
|
if ( log1 ) std::cout << "Scanning file..." << std::endl;
|
||||||
while ( true ) {
|
while ( true ) {
|
||||||
if ( currentId ) {
|
if ( currentId ) {
|
||||||
e = new Entity(currentId,tokens);
|
try {
|
||||||
entity = Ifc2x3::SchemaEntity(e);
|
e = new Entity(currentId,tokens);
|
||||||
|
entity = Ifc2x3::SchemaEntity(e);
|
||||||
|
} catch (IfcException ex) {
|
||||||
|
currentId = 0;
|
||||||
|
Ifc::LogMessage("Error",ex.what());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( log1 && !((++x)%1000) ) std::cout << "\r#" << currentId << " " << std::flush;
|
if ( log1 && !((++x)%1000) ) std::cout << "\r#" << currentId << " " << std::flush;
|
||||||
Ifc2x3::Type::Enum ty = entity->type();
|
Ifc2x3::Type::Enum ty = entity->type();
|
||||||
do {
|
do {
|
||||||
|
|||||||
Reference in New Issue
Block a user