From 7b17c2dccdaf49d72ad7612568d32d3ce2be1ad0 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 16 Jan 2015 16:26:40 +0000 Subject: [PATCH] Make header values writable --- src/examples/IfcOpenHouse.cpp | 2 +- src/ifcparse/IfcFile.h | 26 +++---- src/ifcparse/IfcParse.cpp | 126 ++++++++++++++++++-------------- src/ifcparse/IfcParse.h | 10 ++- src/ifcparse/IfcSpfHeader.cpp | 54 ++++++++++++-- src/ifcparse/IfcSpfHeader.h | 130 ++++++++++++++++++++++++++++------ src/ifcparse/IfcWrite.cpp | 44 +++++++++--- src/ifcwrap/IfcGeomWrapper.i | 28 ++++---- src/ifcwrap/IfcParseWrapper.i | 87 ++++++++++++++++------- src/ifcwrap/IfcPython.i | 28 ++++---- 10 files changed, 370 insertions(+), 165 deletions(-) diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 797c29a202..7046df5511 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -55,7 +55,7 @@ int main(int argc, char** argv) { // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several // convenience functions for working with geometry in IFC files. IfcHierarchyHelper file; - file.filename("IfcOpenHouse.ifc"); + file.header().file_name().name("IfcOpenHouse.ifc"); // Start by adding a wall to the file, initially leaving most attributes blank. IfcSchema::IfcWallStandardCase* south_wall = new IfcSchema::IfcWallStandardCase( diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index 5a46d041db..effeb63642 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -51,13 +51,7 @@ private: IfcSpfHeader _header; - std::string _filename; - std::string _timestamp; - std::string _author; - std::string _author_email; - std::string _author_organisation; - - void initTimestamp(); + void setDefaultHeaderValues(); public: IfcParse::IfcSpfLexer* tokens; IfcParse::IfcSpfStream* stream; @@ -76,7 +70,11 @@ public: template typename T::list::ptr EntitiesByType() { IfcEntityList::ptr untyped_list = EntitiesByType(T::Class()); - return untyped_list->as(); + if (untyped_list) { + return untyped_list->as(); + } else { + return typename T::list::ptr(new typename T::list); + } } /// Returns all entities in the file that match the positional argument. @@ -110,16 +108,10 @@ public: void AddEntity(IfcUtil::IfcBaseClass* entity); void AddEntities(IfcEntityList::ptr es); - void filename(const std::string& s); - std::string filename() const; - void timestamp(const std::string& s); - std::string timestamp() const; - void author(const std::string& name, const std::string& email, const std::string& organisation); - std::string authorName() const; - std::string authorEmail() const; - std::string authorOrganisation() const; - const IfcSpfHeader& header() const { return _header; } + IfcSpfHeader& header() { return _header; } + + std::string createTimestamp() const; bool create_latebound_entities() const { return _create_latebound_entities; } }; diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 3075a49d07..3c035637ba 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -420,25 +420,31 @@ EntityArgument::EntityArgument(const Token& t) { // Reads the arguments from a list of token // Aditionally, stores the ids (i.e. #[\d]+) in a vector // -ArgumentList::ArgumentList(IfcSpfLexer* t, std::vector& ids) { +void ArgumentList::read(IfcSpfLexer* t, std::vector& ids) { IfcParse::IfcFile* file = t->file; Token next = t->Next(); while( next.second || next.first ) { - if ( TokenFunc::isOperator(next,',') ) {} - else if ( TokenFunc::isOperator(next,')') ) break; - else if ( TokenFunc::isOperator(next,'(') ) Push( new ArgumentList(t,ids) ); - else { - if ( TokenFunc::isIdentifier(next) ) ids.push_back(TokenFunc::asInt(next)); - if ( TokenFunc::isKeyword(next) ) { + if ( TokenFunc::isOperator(next,',') ) { + // do nothing + } else if ( TokenFunc::isOperator(next,')') ) { + break; + } else if ( TokenFunc::isOperator(next,'(') ) { + ArgumentList* list = new ArgumentList(); + list->read(t, ids); + push(list); + } else { + if ( TokenFunc::isIdentifier(next) ) { + ids.push_back(TokenFunc::asInt(next)); + } if ( TokenFunc::isKeyword(next) ) { t->Next(); try { - Push ( new EntityArgument(next) ); + push ( new EntityArgument(next) ); } catch ( IfcException& e ) { Logger::Message(Logger::LOG_ERROR,e.what()); } } else { - Push ( new TokenArgument(next) ); + push ( new TokenArgument(next) ); } } next = t->Next(); @@ -461,7 +467,7 @@ IfcUtil::ArgumentType ArgumentList::type() const { } } -void ArgumentList::Push(Argument* l) { +void ArgumentList::push(Argument* l) { list.push_back(l); } @@ -523,10 +529,22 @@ ArgumentList::operator IfcEntityListList::ptr() const { } unsigned int ArgumentList::size() const { return (unsigned int) list.size(); } Argument* ArgumentList::operator [] (unsigned int i) const { - if ( i >= list.size() ) + if ( i >= list.size() ) { throw IfcException("Argument index out of range"); + } return list[i]; } +void ArgumentList::set(unsigned int i, Argument* argument) { + while (size() < i) { + push(new TokenArgument(Token(static_cast(0), '$'))); + } + if (i < size()) { + delete list[i]; + list[i] = argument; + } else { + list.push_back(argument); + } +} std::string ArgumentList::toString(bool upper) const { std::stringstream ss; ss << "("; @@ -666,7 +684,8 @@ void Entity::Load(std::vector& ids, bool seek) const { _type = IfcSchema::Type::FromString(TokenFunc::asString(datatype)); } Token open = file->tokens->Next(); - args = new ArgumentList(file->tokens, ids); + args = new ArgumentList(); + args->read(file->tokens, ids); unsigned int old_offset = file->tokens->stream->Tell(); Token semilocon = file->tokens->Next(); if ( ! TokenFunc::isOperator(semilocon,';') ) file->tokens->stream->Seek(old_offset); @@ -697,7 +716,10 @@ std::string Entity::toString(bool upper) const { if ( upper ) { for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p); } - ss << "#" << _id << "=" << dt << args->toString(upper); + if (!IfcSchema::Type::IsSimple(type()) || _id != 0) { + ss << "#" << _id << "="; + } + ss << dt << args->toString(upper); return ss.str(); } @@ -721,12 +743,12 @@ IfcWrite::IfcWritableEntity* Entity::isWritable() { IfcFile::IfcFile(bool create_latebound_entities) : _create_latebound_entities(create_latebound_entities) + , stream(0) + , lastId(0) + , tokens(0) + , MaxId(0) { - stream = 0; - lastId = 0; - tokens = 0; - MaxId = 0; - initTimestamp(); + setDefaultHeaderValues(); } // @@ -998,25 +1020,7 @@ IfcFile::entity_by_id_t::const_iterator IfcFile::end() const { } std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) { - os << "ISO-10303-21;" << std::endl; - os << "HEADER;" << std::endl; - os << "FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');" << std::endl; - os << "FILE_NAME(" - << static_cast(IfcWrite::IfcCharacterEncoder(f.filename())) << "," - << static_cast(IfcWrite::IfcCharacterEncoder(f.timestamp())) << ",(" - << static_cast(IfcWrite::IfcCharacterEncoder(f.authorOrganisation())) << "),(" - << static_cast(IfcWrite::IfcCharacterEncoder(f.authorName())) << "," - << static_cast(IfcWrite::IfcCharacterEncoder(f.authorEmail())) - << "),'IfcOpenShell " << IFCOPENSHELL_VERSION - << "','IfcOpenShell " << IFCOPENSHELL_VERSION - << "','');" << std::endl; -#ifdef USE_IFC4 - os << "FILE_SCHEMA(('IFC4'));" << std::endl; -#else - os << "FILE_SCHEMA(('IFC2X3'));" << std::endl; -#endif - os << "ENDSEC;" << std::endl; - os << "DATA;" << std::endl; + f.header().write(os); for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) { const IfcUtil::IfcBaseClass* e = it->second; @@ -1029,26 +1033,20 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) { return os; } -void IfcFile::filename(const std::string& s) { _filename = s; } -std::string IfcFile::filename() const { return _filename; } -void IfcFile::timestamp(const std::string& s) { _timestamp = s; } -std::string IfcFile::timestamp() const { return _timestamp; } -void IfcFile::author(const std::string& name, const std::string& email, const std::string& organisation) { - _author = name; - _author_email = email; - _author_organisation = organisation; -} -std::string IfcFile::authorName() const { return _author; } -std::string IfcFile::authorEmail() const { return _author_email; } -std::string IfcFile::authorOrganisation() const { return _author_organisation; } -void IfcFile::initTimestamp() { +std::string IfcFile::createTimestamp() const { char buf[255]; + time_t t; time(&t); - struct tm * ti = localtime (&t); + + struct tm* ti = localtime (&t); + + std::string result = ""; if (strftime(buf,255,"%Y-%m-%dT%H:%M:%S",ti)) { - _timestamp = std::string(buf); + result = std::string(buf); } + + return result; } IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) { @@ -1078,4 +1076,26 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum ty } return l; -} \ No newline at end of file +} + +void IfcFile::setDefaultHeaderValues() { + const std::string empty_string = ""; + std::vector file_description, schema_identifiers, empty_vector; + + file_description.push_back("ViewDefinition [CoordinationView]"); + schema_identifiers.push_back(IfcSchema::Identifier); + + header().file_description().description(file_description); + header().file_description().implementation_level("2;1"); + + header().file_name().name(empty_string); + header().file_name().time_stamp(createTimestamp()); + header().file_name().author(empty_vector); + header().file_name().organization(empty_vector); + header().file_name().preprocessor_version("IfcOpenShell " IFCOPENSHELL_VERSION); + header().file_name().originating_system("IfcOpenShell " IFCOPENSHELL_VERSION); + header().file_name().authorization(empty_string); + + header().file_schema().schema_identifiers(schema_identifiers); +} + diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index ce0634991c..935c2e56b7 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -122,11 +122,12 @@ namespace IfcParse { class ArgumentList: public Argument { private: std::vector list; - void Push(Argument* l); + void push(Argument* l); public: - ArgumentList(IfcSpfLexer* t, std::vector& ids); ~ArgumentList(); + void read(IfcSpfLexer* t, std::vector& ids); + IfcUtil::ArgumentType type() const; operator int() const; @@ -140,7 +141,10 @@ namespace IfcParse { operator IfcEntityList::ptr() const; operator IfcEntityListList::ptr() const; unsigned int size() const; + Argument* operator [] (unsigned int i) const; + void set(unsigned int i, Argument*); + std::string toString(bool upper=false) const; bool isNull() const; }; @@ -206,7 +210,7 @@ namespace IfcParse { /// ============================ class Entity : public IfcAbstractEntity { private: - mutable Argument* args; + mutable ArgumentList* args; mutable IfcSchema::Type::Enum _type; public: /// The EXPRESS ENTITY_INSTANCE_NAME diff --git a/src/ifcparse/IfcSpfHeader.cpp b/src/ifcparse/IfcSpfHeader.cpp index c75d7cc108..d2445c5922 100644 --- a/src/ifcparse/IfcSpfHeader.cpp +++ b/src/ifcparse/IfcSpfHeader.cpp @@ -62,14 +62,17 @@ void IfcSpfHeader::read() { readTerminal(HEADER, TRAILING_SEMICOLON); readTerminal(FILE_DESCRIPTION, TRAILING_PAREN); + delete _file_description; _file_description = new FileDescription(_lexer); readSemicolon(); readTerminal(FILE_NAME, TRAILING_PAREN); + delete _file_name; _file_name = new FileName(_lexer); readSemicolon(); readTerminal(FILE_SCHEMA, TRAILING_PAREN); + delete _file_schema; _file_schema = new FileSchema(_lexer); readSemicolon(); } @@ -83,26 +86,65 @@ bool IfcSpfHeader::tryRead() { } } -const FileDescription& IfcSpfHeader::file_description() { +void IfcSpfHeader::write(std::ostream& os) const { + os << ISO_10303_21 << ";" << "\n"; + os << HEADER << ";" << "\n"; + os << file_description().toString(true) << "\n"; + os << file_name().toString(true) << "\n"; + os << file_schema().toString(true) << "\n"; + os << ENDSEC << ";" << "\n"; + os << DATA << ";" << "\n"; +} + + +const FileDescription& IfcSpfHeader::file_description() const { if (_file_description) { return *_file_description; } else { - throw IfcException("File description not read"); + throw IfcException("File description not set"); } } -const FileName& IfcSpfHeader::file_name() { +const FileName& IfcSpfHeader::file_name() const { if (_file_name) { return *_file_name; } else { - throw IfcException("File name not read"); + throw IfcException("File name not set"); } } -const FileSchema& IfcSpfHeader::file_schema() { +const FileSchema& IfcSpfHeader::file_schema() const { if (_file_schema) { return *_file_schema; } else { - throw IfcException("File schema not read"); + throw IfcException("File schema not set"); } } + +FileDescription& IfcSpfHeader::file_description() { + if (_file_description) { + return *_file_description; + } else { + throw IfcException("File description not set"); + } +} + +FileName& IfcSpfHeader::file_name() { + if (_file_name) { + return *_file_name; + } else { + throw IfcException("File name not set"); + } +} + +FileSchema& IfcSpfHeader::file_schema() { + if (_file_schema) { + return *_file_schema; + } else { + throw IfcException("File schema not set"); + } +} + +FileDescription::FileDescription(IfcSpfLexer* lexer) : HeaderEntity(FILE_DESCRIPTION, lexer) {} +FileName::FileName(IfcSpfLexer* lexer) : HeaderEntity(FILE_NAME, lexer) {} +FileSchema::FileSchema(IfcSpfLexer* lexer) : HeaderEntity(FILE_SCHEMA, lexer) {} \ No newline at end of file diff --git a/src/ifcparse/IfcSpfHeader.h b/src/ifcparse/IfcSpfHeader.h index 101f262fb2..9edce30ea9 100644 --- a/src/ifcparse/IfcSpfHeader.h +++ b/src/ifcparse/IfcSpfHeader.h @@ -21,45 +21,124 @@ #define IFCSPFHEADER_H #include "../ifcparse/IfcSpfStream.h" +#include "../ifcparse/IfcWrite.h" namespace IfcParse { -class HeaderEntity { +class HeaderEntity : public IfcAbstractEntity { private: - ArgumentList* list; + ArgumentList* _list; + const char * const _datatype; protected: - HeaderEntity(IfcSpfLexer* lexer) { + HeaderEntity(const char * const datatype, IfcSpfLexer* lexer) + : _datatype(datatype), _list(0) + { std::vector ids; - list = new ArgumentList(lexer, ids); - }; + _list = new ArgumentList(); + if (lexer) { + _list->read(lexer, ids); + } + } + + ~HeaderEntity() { + delete _list; + } + + void setArgument(unsigned int i, const std::string& s) { + IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument(this); + argument->set(s); + _list->set(i, argument); + } + + void setArgument(unsigned int i, const std::vector& s) { + IfcWrite::IfcWriteArgument* argument = new IfcWrite::IfcWriteArgument(this); + argument->set(s); + _list->set(i, argument); + } + +public: Argument* getArgument(unsigned int i) const { - return (*list)[i]; + return (*_list)[i]; + } + + Argument* getArgument(unsigned int i) { + return (*_list)[i]; + } + + IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index) { + return IfcEntityList::ptr(new IfcEntityList); + } + + std::string datatype() const { + return _datatype; + } + + unsigned int getArgumentCount() const { + return _list->size(); + } + + IfcSchema::Type::Enum type() const { + return (IfcSchema::Type::Enum) -1; + } + + bool is(IfcSchema::Type::Enum v) const { + return false; + } + + std::string toString(bool upper=false) const { + std::stringstream ss; + ss << _datatype << _list->toString(upper) << ";"; + return ss.str(); + } + + unsigned int id() { + return 0; + } + + IfcWrite::IfcWritableEntity* isWritable() { + return 0; } }; -class FileDescription : private HeaderEntity { +class FileDescription : public HeaderEntity { public: - FileDescription(IfcSpfLexer* lexer) : HeaderEntity(lexer) {} + explicit FileDescription(IfcSpfLexer* = 0); + std::vector description() const { return *getArgument(0); } std::string implementation_level() const { return *getArgument(1); } + + void description(const std::vector& value) { setArgument(0, value); } + void implementation_level(const std::string& value) { setArgument(1, value); } }; -class FileName : private HeaderEntity { +class FileName : public HeaderEntity { public: - FileName(IfcSpfLexer* lexer) : HeaderEntity(lexer) {} + explicit FileName(IfcSpfLexer* = 0); + std::string name() const { return *getArgument(0); } std::string time_stamp() const { return *getArgument(1); } std::vector author() const { return *getArgument(2); } std::vector organization() const { return *getArgument(3); } std::string preprocessor_version() const { return *getArgument(4); } std::string originating_system() const { return *getArgument(5); } - std::string authorization()const { return *getArgument(6); } + std::string authorization() const { return *getArgument(6); } + + void name(const std::string& value) { setArgument(0, value); } + void time_stamp(const std::string& value) { setArgument(1, value); } + void author(const std::vector& value) { setArgument(2, value); } + void organization(const std::vector& value) { setArgument(3, value); } + void preprocessor_version(const std::string& value) { setArgument(4, value); } + void originating_system(const std::string& value) { setArgument(5, value); } + void authorization(const std::string& value) { setArgument(6, value); } }; -class FileSchema : private HeaderEntity { +class FileSchema : public HeaderEntity { public: - FileSchema(IfcSpfLexer* lexer) : HeaderEntity(lexer) {} + explicit FileSchema(IfcSpfLexer* = 0); + std::vector schema_identifiers() const { return *getArgument(0); } + + void schema_identifiers(const std::vector& value) { setArgument(0, value); } }; class IfcSpfHeader { @@ -69,7 +148,7 @@ private: FileName* _file_name; FileSchema* _file_schema; void readParen(); - void readSemicolon();\ + void readSemicolon(); enum Trail { TRAILING_SEMICOLON, TRAILING_PAREN, @@ -77,18 +156,29 @@ private: }; void readTerminal(const std::string& term, Trail trail); public: - IfcSpfHeader() : _lexer(0), _file_description(0), _file_name(0), _file_schema(0) {} - explicit IfcSpfHeader(IfcSpfLexer* lexer) : _lexer(lexer) {} + explicit IfcSpfHeader(IfcSpfLexer* lexer = 0) + : _lexer(lexer), _file_description(0), _file_name(0), _file_schema(0) + { + _file_description = new FileDescription(); + _file_name = new FileName(); + _file_schema = new FileSchema(); + } IfcSpfLexer* lexer() { return _lexer; } void lexer(IfcSpfLexer* l) { _lexer = l; } - + void read(); bool tryRead(); + + void write(std::ostream& os) const; - const FileDescription& file_description(); - const FileName& file_name(); - const FileSchema& file_schema(); + const FileDescription& file_description() const; + const FileName& file_name() const; + const FileSchema& file_schema() const; + + FileDescription& file_description(); + FileName& file_name(); + FileSchema& file_schema(); }; } diff --git a/src/ifcparse/IfcWrite.cpp b/src/ifcparse/IfcWrite.cpp index a77685e694..b91facf1a5 100644 --- a/src/ifcparse/IfcWrite.cpp +++ b/src/ifcparse/IfcWrite.cpp @@ -217,14 +217,6 @@ private: } return oss.str(); } - void serialize_double(const std::vector& i) { - data << "("; - for (std::vector::const_iterator it = i.begin(); it != i.end(); ++it) { - if (it != i.begin()) data << ","; - data << format_double(*it); - } - data << ")"; - } bool upper; public: StringBuilderVisitor(std::ostringstream& stream, bool upper = false) @@ -239,9 +231,9 @@ public: if (upper) s = IfcCharacterEncoder(s); data << s; } - void operator()(const std::vector& i) { serialize(i); } - void operator()(const std::vector& i) { serialize_double(i); } - void operator()(const std::vector& i) { serialize(i); } + void operator()(const std::vector& i); + void operator()(const std::vector& i); + void operator()(const std::vector& i); void operator()(const IfcWriteArgument::EnumerationReference& i) { data << "." << i.enumeration_value << "."; } @@ -277,6 +269,36 @@ public: operator std::string() { return data.str(); } }; +template <> +void StringBuilderVisitor::serialize(const std::vector& i) { + data << "("; + for (std::vector::const_iterator it = i.begin(); it != i.end(); ++it) { + if (it != i.begin()) data << ","; + if (upper) { + std::string s = IfcCharacterEncoder(*it); + data << s; + } else { + data << *it; + } + } + data << ")"; +} + +template <> +void StringBuilderVisitor::serialize(const std::vector& i) { + data << "("; + for (std::vector::const_iterator it = i.begin(); it != i.end(); ++it) { + if (it != i.begin()) data << ","; + data << format_double(*it); + } + data << ")"; +} + +void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } +void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } +void StringBuilderVisitor::operator()(const std::vector& i) { serialize(i); } + + IfcWriteArgument::operator int() const { return as(); } IfcWriteArgument::operator bool() const { return as(); } IfcWriteArgument::operator double() const { return as(); } diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 211b35e41c..a10a6cb51f 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -1,20 +1,20 @@ /******************************************************************************** - * * - * This file is part of IfcOpenShell. * - * * - * IfcOpenShell is free software: you can redistribute it and/or modify * + * * + * This file is part of IfcOpenShell. * + * * + * IfcOpenShell is free software: you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as published by * - * the Free Software Foundation, either version 3.0 of the License, or * - * (at your option) any later version. * - * * - * IfcOpenShell is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * Lesser GNU General Public License for more details. * - * * + * the Free Software Foundation, either version 3.0 of the License, or * + * (at your option) any later version. * + * * + * IfcOpenShell is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * Lesser GNU General Public License for more details. * + * * * You should have received a copy of the Lesser GNU General Public License * - * along with this program. If not, see . * - * * + * along with this program. If not, see . * + * * ********************************************************************************/ %rename("settings") IteratorSettings; diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 10405e6c65..ef32983915 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -1,22 +1,35 @@ /******************************************************************************** - * * - * This file is part of IfcOpenShell. * - * * - * IfcOpenShell is free software: you can redistribute it and/or modify * + * * + * This file is part of IfcOpenShell. * + * * + * IfcOpenShell is free software: you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as published by * - * the Free Software Foundation, either version 3.0 of the License, or * - * (at your option) any later version. * - * * - * IfcOpenShell is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * Lesser GNU General Public License for more details. * - * * + * the Free Software Foundation, either version 3.0 of the License, or * + * (at your option) any later version. * + * * + * IfcOpenShell is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * Lesser GNU General Public License for more details. * + * * * You should have received a copy of the Lesser GNU General Public License * - * along with this program. If not, see . * - * * + * along with this program. If not, see . * + * * ********************************************************************************/ +// Two class declarations to silence SWIG warning about base classes being +// undefined, the constructors are private so that SWIG does not wrap them +class IfcAbstractEntity { +private: + IfcAbstractEntity(); +}; +namespace IfcUtil { + class IfcBaseEntity { + private: + IfcBaseEntity(); + }; +} + %ignore IfcParse::IfcLateBoundEntity::is; %ignore IfcParse::IfcLateBoundEntity::type; %ignore IfcParse::IfcLateBoundEntity::getArgument; @@ -32,9 +45,11 @@ %ignore IfcParse::FileName::FileName; %ignore IfcParse::FileSchema::FileSchema; %ignore IfcParse::IfcFile::tokens; + %ignore IfcParse::IfcSpfHeader::IfcSpfHeader(IfcSpfLexer*); %ignore IfcParse::IfcSpfHeader::lexer; %ignore IfcParse::IfcSpfHeader::stream; +%ignore IfcParse::HeaderEntity::is; %rename("by_type") EntitiesByType; %rename("__len__") getArgumentCount; @@ -190,23 +205,41 @@ %extend IfcParse::FileDescription { %pythoncode %{ if _newclass: - # Hide the getters with read-only property implementations - description = property(description) - implementation_level = property(implementation_level) + # Hide the getters with read-write property implementations + __swig_getmethods__["description"] = description + __swig_setmethods__["description"] = description + description = property(description, description) + __swig_getmethods__["implementation_level"] = implementation_level + __swig_setmethods__["implementation_level"] = implementation_level + implementation_level = property(implementation_level, implementation_level) %} }; %extend IfcParse::FileName { %pythoncode %{ if _newclass: - # Hide the getters with read-only property implementations - name = property(name) - time_stamp = property(time_stamp) - author = property(author) - organization = property(organization) - preprocessor_version = property(preprocessor_version) - originating_system = property(originating_system) - authorization = property(authorization) + # Hide the getters with read-write property implementations + __swig_getmethods__["name"] = name + __swig_setmethods__["name"] = name + name = property(name, name) + __swig_getmethods__["time_stamp"] = time_stamp + __swig_setmethods__["time_stamp"] = time_stamp + timestamp = property(time_stamp, time_stamp) + __swig_getmethods__["author"] = author + __swig_setmethods__["author"] = author + author = property(author, author) + __swig_getmethods__["organization"] = organization + __swig_setmethods__["organization"] = organization + organization = property(organization, organization) + __swig_getmethods__["preprocessor_version"] = preprocessor_version + __swig_setmethods__["preprocessor_version"] = preprocessor_version + preprocessor_version = property(preprocessor_version, preprocessor_version) + __swig_getmethods__["originating_system"] = originating_system + __swig_setmethods__["originating_system"] = originating_system + originating_system = property(originating_system, originating_system) + __swig_getmethods__["authorization"] = authorization + __swig_setmethods__["authorization"] = authorization + authorization = property(authorization, authorization) %} }; @@ -214,7 +247,9 @@ %pythoncode %{ if _newclass: # Hide the getters with read-only property implementations - schema_identifiers = property(schema_identifiers) + __swig_getmethods__["schema_identifiers"] = schema_identifiers + __swig_setmethods__["schema_identifiers"] = schema_identifiers + schema_identifiers = property(schema_identifiers, schema_identifiers) %} }; diff --git a/src/ifcwrap/IfcPython.i b/src/ifcwrap/IfcPython.i index b0414862b3..76b9d072bc 100644 --- a/src/ifcwrap/IfcPython.i +++ b/src/ifcwrap/IfcPython.i @@ -1,20 +1,20 @@ /******************************************************************************** - * * - * This file is part of IfcOpenShell. * - * * - * IfcOpenShell is free software: you can redistribute it and/or modify * + * * + * This file is part of IfcOpenShell. * + * * + * IfcOpenShell is free software: you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as published by * - * the Free Software Foundation, either version 3.0 of the License, or * - * (at your option) any later version. * - * * - * IfcOpenShell is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * Lesser GNU General Public License for more details. * - * * + * the Free Software Foundation, either version 3.0 of the License, or * + * (at your option) any later version. * + * * + * IfcOpenShell is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * Lesser GNU General Public License for more details. * + * * * You should have received a copy of the Lesser GNU General Public License * - * along with this program. If not, see . * - * * + * along with this program. If not, see . * + * * ********************************************************************************/ %include "std_vector.i"