Skip to content

Commit d8d221d

Browse files
committed
Merge branch 'master' of https://github.com/aothms/IfcOpenShell
1 parent ed5f879 commit d8d221d

10 files changed

Lines changed: 713 additions & 41 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 & 20 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,11 +371,10 @@ 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
}
378-
t->Next();
379378
} else {
380379
Push ( new TokenArgument(next) );
381380
}
@@ -493,22 +492,7 @@ EntityArgument::operator IfcEntities() const { throw IfcException("Argument is n
493492
unsigned int EntityArgument::Size() const { return 1; }
494493
ArgumentPtr EntityArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
495494
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 + ")";
495+
return entity->entity->toString(upper);
512496
}
513497
//return entity->entity->toString(); }
514498
bool EntityArgument::isNull() const { return false; }
@@ -599,7 +583,10 @@ std::string Entity::toString(bool upper) {
599583
if ( upper ) {
600584
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
601585
}
602-
ss << "#" << _id << "=" << dt << args->toString(upper);
586+
if (_id) {
587+
ss << "#" << _id << "=";
588+
}
589+
ss << dt << args->toString(upper);
603590
return ss.str();
604591
}
605592

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/ifcparse/IfcUntypedEntity.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ void Ifc::IfcUntypedEntity::invalid_argument(unsigned int i, const std::string&
6161
const std::string arg_name = Ifc2x3::Type::GetAttributeName(_type,i);
6262
throw IfcException(t + " is not a valid type for '" + arg_name + "'");
6363
}
64+
void Ifc::IfcUntypedEntity::setArgument(unsigned int i) {
65+
bool is_optional = Ifc2x3::Type::GetAttributeOptional(_type, i);
66+
if (is_optional) {
67+
writable_entity()->setArgument(i);
68+
} else invalid_argument(i,"NONE");
69+
}
6470
void Ifc::IfcUntypedEntity::setArgument(unsigned int i, int v) {
6571
IfcUtil::ArgumentType arg_type = Ifc2x3::Type::GetAttributeType(_type,i);
6672
if (arg_type == Argument_INT) {

src/ifcparse/IfcUntypedEntity.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace Ifc {
2727
const char* getArgumentName(unsigned int i) const;
2828
unsigned getArgumentIndex(const std::string& a) const;
2929

30+
void setArgument(unsigned int iz);
3031
void setArgument(unsigned int i, int v);
3132
void setArgument(unsigned int i, bool v);
3233
void setArgument(unsigned int i, double v);

src/ifcwrap/IfcPython.i

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
%rename("get_argument_type") getArgumentType;
3838
%rename("get_argument_name") getArgumentName;
3939
%rename("get_argument_index") getArgumentIndex;
40-
%rename("set_argument") setArgument;
40+
%rename("_set_argument") setArgument;
4141
%rename("__repr__") toString;
4242
%rename("Entity") IfcUntypedEntity;
4343

4444
%typemap(out) IfcEntities {
45-
const unsigned size = $1->Size();
45+
const unsigned size = $1 ? $1->Size() : 0;
4646
$result = PyList_New(size);
4747
for (unsigned i = 0; i < size; ++i) {
4848
PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr((*$1)[i]), SWIGTYPE_p_Ifc__IfcUntypedEntity, 0);
@@ -149,6 +149,11 @@
149149
}
150150
}
151151

152+
%extend Ifc::IfcUntypedEntity {
153+
%pythoncode %{
154+
set_argument = lambda self,x,y: self._set_argument(x) if y is None else self._set_argument(x,y)
155+
%}
156+
}
152157

153158
namespace std {
154159
%template(Ints) vector<int>;

src/ifcwrap/Interface.h

Lines changed: 3 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

@@ -26,6 +28,7 @@ namespace Ifc {
2628
const char* getArgumentName(unsigned int i) const;
2729
unsigned getArgumentIndex(const std::string& a) const;
2830

31+
void setArgument(unsigned int i);
2932
void setArgument(unsigned int i, int v);
3033
void setArgument(unsigned int i, bool v);
3134
void setArgument(unsigned int i, double v);

0 commit comments

Comments
 (0)