Skip to content

Commit a5684f0

Browse files
committed
Correctly take inline entity instances for select types into account in the Python wrapper
1 parent 509c34d commit a5684f0

7 files changed

Lines changed: 698 additions & 38 deletions

File tree

src/ifcexpressparser/IfcExpressParser.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def __str__(self):
543543
namespace %(schema)s {
544544
"""%{'schema_upper':schema_version.upper(),'schema':schema_version}
545545

546-
simple_enumerations = sorted(selectable_simple_types)
546+
simple_enumerations = sorted(simple_types)
547547
entity_enumerations = sorted(entity_names)
548548
all_enumerations = simple_enumerations + entity_enumerations
549549

@@ -613,11 +613,6 @@ def __str__(self):
613613
print >>h_file, c
614614

615615
print >>h_file, "void InitStringMap();"
616-
print >>h_file, "void InitAttributeCountMap();"
617-
print >>h_file, "void InitAttributeIndexMap();"
618-
print >>h_file, "void InitAttributeTypeMap();"
619-
print >>h_file, "void InitAttributeNameMap();"
620-
print >>h_file, "void InitAttributeOptionalMap();"
621616
print >>h_file, "IfcSchemaEntity SchemaEntity(IfcAbstractEntityPtr e = 0);"
622617

623618
print >>h_file, "}\n\n#endif"
@@ -666,6 +661,10 @@ def __str__(self):
666661
string_map,attribute_count_map,attribute_index_map,attribute_name_map,attribute_optional_map,attribute_type_map = [""]*6
667662
print >>cpp2_file, "void InitDescriptorMap() {"
668663
print >>cpp2_file, " IfcEntityDescriptor* current;"
664+
for k,v in simple_types.items():
665+
if k in enumerations or k in selections: continue
666+
print >>cpp2_file, " current = entity_descriptor_map[Type::%s] = new IfcEntityDescriptor(Type::%s,0);"%(k,k)
667+
print >>cpp2_file, " current->add(\"wrappedValue\",false,%s);"%(v.type_enum())
669668
rt_entities = set()
670669
while True:
671670
todo = [e for e in entities if e.class_name not in rt_entities]

src/ifcparse/Ifc2x3-rt.cpp

Lines changed: 234 additions & 7 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc2x3.cpp

Lines changed: 448 additions & 4 deletions
Large diffs are not rendered by default.

src/ifcparse/Ifc2x3enum.h

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/ifcparse/IfcParse.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ TokenArgument::TokenArgument(const Token& t) {
353353
}
354354

355355
EntityArgument::EntityArgument(Ifc2x3::Type::Enum ty, const Token& t) {
356-
entity = new IfcUtil::IfcArgumentSelect(ty,new TokenArgument(t));
356+
entity = new Ifc::IfcUntypedEntity(new Entity(0,t.first->file,t.second));
357357
}
358358

359359
//
@@ -371,7 +371,7 @@ ArgumentList::ArgumentList(Tokens* t, std::vector<unsigned int>& ids) {
371371
if ( TokenFunc::isDatatype(next) ) {
372372
t->Next();
373373
try {
374-
Push ( new EntityArgument(Ifc2x3::Type::FromString(TokenFunc::asString(next)),t->Next()) );
374+
Push ( new EntityArgument(Ifc2x3::Type::ALL,next) ); //Ifc2x3::Type::FromString(TokenFunc::asString(next)),t->Next()) );
375375
} catch ( IfcException& e ) {
376376
Logger::Message(Logger::LOG_ERROR,e.what());
377377
}
@@ -493,22 +493,7 @@ EntityArgument::operator IfcEntities() const { throw IfcException("Argument is n
493493
unsigned int EntityArgument::Size() const { return 1; }
494494
ArgumentPtr EntityArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
495495
std::string EntityArgument::toString(bool upper) const {
496-
ArgumentPtr arg = entity->wrappedValue();
497-
IfcParse::TokenArgument* token_arg = dynamic_cast<IfcParse::TokenArgument*>(arg);
498-
const bool is_string = TokenFunc::isString(token_arg->token);
499-
std::string token_string = token_arg ? (is_string
500-
? TokenFunc::asString(token_arg->token)
501-
: TokenFunc::toString(token_arg->token))
502-
: std::string();
503-
std::string dt = Ifc2x3::Type::ToString(entity->type());
504-
if ( upper ) {
505-
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
506-
if (is_string) token_string = IfcWrite::IfcCharacterEncoder(token_string);
507-
} else {
508-
token_string.insert(token_string.begin(),'\'');
509-
token_string.push_back('\'');
510-
}
511-
return dt + "(" + token_string + ")";
496+
return entity->entity->toString(upper);
512497
}
513498
//return entity->entity->toString(); }
514499
bool EntityArgument::isNull() const { return false; }
@@ -599,7 +584,10 @@ std::string Entity::toString(bool upper) {
599584
if ( upper ) {
600585
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
601586
}
602-
ss << "#" << _id << "=" << dt << args->toString(upper);
587+
if (_id) {
588+
ss << "#" << _id << "=";
589+
}
590+
ss << dt << args->toString(upper);
603591
return ss.str();
604592
}
605593

src/ifcparse/IfcParse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace IfcParse {
162162
/// ===================== =====================
163163
class EntityArgument : public Argument {
164164
private:
165-
IfcUtil::IfcArgumentSelect* entity;
165+
Ifc::IfcUntypedEntity* entity;
166166
public:
167167
EntityArgument(Ifc2x3::Type::Enum ty, const Token& t);
168168
~EntityArgument();

src/ifcwrap/Interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <map>
44
#include <fstream>
55

6+
namespace Ifc { class IfcUntypedEntity; }
7+
68
#include "../ifcparse/IfcUtil.h"
79
#include "../ifcparse/Ifc2x3.h"
810

0 commit comments

Comments
 (0)