Skip to content

Commit ed5f879

Browse files
committed
Merge pull request IfcOpenShell#1 from aothms/master
1 parent 3bc3331 commit ed5f879

File tree

10 files changed

+41
-714
lines changed

10 files changed

+41
-714
lines changed

src/ifcexpressparser/IfcExpressParser.py

Lines changed: 6 additions & 5 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(simple_types)
546+
simple_enumerations = sorted(selectable_simple_types)
547547
entity_enumerations = sorted(entity_names)
548548
all_enumerations = simple_enumerations + entity_enumerations
549549

@@ -613,6 +613,11 @@ 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();"
616621
print >>h_file, "IfcSchemaEntity SchemaEntity(IfcAbstractEntityPtr e = 0);"
617622

618623
print >>h_file, "}\n\n#endif"
@@ -661,10 +666,6 @@ def __str__(self):
661666
string_map,attribute_count_map,attribute_index_map,attribute_name_map,attribute_optional_map,attribute_type_map = [""]*6
662667
print >>cpp2_file, "void InitDescriptorMap() {"
663668
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())
668669
rt_entities = set()
669670
while True:
670671
todo = [e for e in entities if e.class_name not in rt_entities]

src/ifcparse/Ifc2x3-rt.cpp

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

src/ifcparse/Ifc2x3.cpp

Lines changed: 4 additions & 448 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: 20 additions & 7 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 Ifc::IfcUntypedEntity(new Entity(0,t.first->file,t.second));
356+
entity = new IfcUtil::IfcArgumentSelect(ty,new TokenArgument(t));
357357
}
358358

359359
//
@@ -371,10 +371,11 @@ 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::ALL,next) ); //Ifc2x3::Type::FromString(TokenFunc::asString(next)),t->Next()) );
374+
Push ( new EntityArgument(Ifc2x3::Type::FromString(TokenFunc::asString(next)),t->Next()) );
375375
} catch ( IfcException& e ) {
376376
Logger::Message(Logger::LOG_ERROR,e.what());
377377
}
378+
t->Next();
378379
} else {
379380
Push ( new TokenArgument(next) );
380381
}
@@ -492,7 +493,22 @@ EntityArgument::operator IfcEntities() const { throw IfcException("Argument is n
492493
unsigned int EntityArgument::Size() const { return 1; }
493494
ArgumentPtr EntityArgument::operator [] (unsigned int i) const { throw IfcException("Argument is not a list of arguments"); }
494495
std::string EntityArgument::toString(bool upper) const {
495-
return entity->entity->toString(upper);
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 + ")";
496512
}
497513
//return entity->entity->toString(); }
498514
bool EntityArgument::isNull() const { return false; }
@@ -583,10 +599,7 @@ std::string Entity::toString(bool upper) {
583599
if ( upper ) {
584600
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
585601
}
586-
if (_id) {
587-
ss << "#" << _id << "=";
588-
}
589-
ss << dt << args->toString(upper);
602+
ss << "#" << _id << "=" << dt << args->toString(upper);
590603
return ss.str();
591604
}
592605

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-
Ifc::IfcUntypedEntity* entity;
165+
IfcUtil::IfcArgumentSelect* entity;
166166
public:
167167
EntityArgument(Ifc2x3::Type::Enum ty, const Token& t);
168168
~EntityArgument();

src/ifcparse/IfcUntypedEntity.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ 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-
}
7064
void Ifc::IfcUntypedEntity::setArgument(unsigned int i, int v) {
7165
IfcUtil::ArgumentType arg_type = Ifc2x3::Type::GetAttributeType(_type,i);
7266
if (arg_type == Argument_INT) {

src/ifcparse/IfcUntypedEntity.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ 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);
3130
void setArgument(unsigned int i, int v);
3231
void setArgument(unsigned int i, bool v);
3332
void setArgument(unsigned int i, double v);

src/ifcwrap/IfcPython.i

Lines changed: 2 additions & 8 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 ? $1->Size() : 0;
45+
const unsigned size = $1->Size();
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);
@@ -54,7 +54,6 @@
5454
const Argument& arg = *($1.second);
5555
const ArgumentType type = $1.first;
5656
if (arg.isNull()) {
57-
Py_INCREF(Py_None);
5857
$result = Py_None;
5958
} else {
6059
switch(type) {
@@ -150,11 +149,6 @@
150149
}
151150
}
152151

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

159153
namespace std {
160154
%template(Ints) vector<int>;

src/ifcwrap/Interface.h

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

6-
namespace Ifc { class IfcUntypedEntity; }
7-
86
#include "../ifcparse/IfcUtil.h"
97
#include "../ifcparse/Ifc2x3.h"
108

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

31-
void setArgument(unsigned int i);
3229
void setArgument(unsigned int i, int v);
3330
void setArgument(unsigned int i, bool v);
3431
void setArgument(unsigned int i, double v);

0 commit comments

Comments
 (0)