2015-01-05 14:11:42 +00:00
|
|
|
/********************************************************************************
|
2015-01-16 16:26:40 +00:00
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
2015-01-05 14:11:42 +00:00
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
2015-01-16 16:26:40 +00:00
|
|
|
* 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. *
|
|
|
|
|
* *
|
2015-01-05 14:11:42 +00:00
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
2015-01-16 16:26:40 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
2015-01-05 14:11:42 +00:00
|
|
|
********************************************************************************/
|
|
|
|
|
|
2015-01-16 16:26:40 +00:00
|
|
|
// 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();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-05 14:11:42 +00:00
|
|
|
%ignore IfcParse::IfcLateBoundEntity::is;
|
|
|
|
|
%ignore IfcParse::IfcLateBoundEntity::type;
|
|
|
|
|
%ignore IfcParse::IfcLateBoundEntity::getArgument;
|
|
|
|
|
%ignore IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(IfcAbstractEntity*);
|
|
|
|
|
|
|
|
|
|
%ignore IfcParse::IfcFile::Init;
|
2015-02-17 20:07:09 +00:00
|
|
|
%ignore IfcParse::IfcFile::entityById;
|
|
|
|
|
%ignore IfcParse::IfcFile::entityByGuid;
|
2015-02-17 19:55:27 +00:00
|
|
|
%ignore IfcParse::IfcFile::addEntity;
|
2015-02-17 19:48:41 +00:00
|
|
|
%ignore IfcParse::IfcFile::removeEntity;
|
|
|
|
|
%ignore IfcParse::IfcFile::traverse(IfcUtil::IfcBaseClass*, int);
|
|
|
|
|
%ignore IfcParse::IfcFile::traverse(IfcUtil::IfcBaseClass*);
|
2015-01-05 14:11:42 +00:00
|
|
|
%ignore operator<<;
|
|
|
|
|
|
2015-01-05 17:46:23 +00:00
|
|
|
%ignore IfcParse::FileDescription::FileDescription;
|
|
|
|
|
%ignore IfcParse::FileName::FileName;
|
|
|
|
|
%ignore IfcParse::FileSchema::FileSchema;
|
|
|
|
|
%ignore IfcParse::IfcFile::tokens;
|
2015-01-16 16:26:40 +00:00
|
|
|
|
2015-01-05 17:46:23 +00:00
|
|
|
%ignore IfcParse::IfcSpfHeader::IfcSpfHeader(IfcSpfLexer*);
|
|
|
|
|
%ignore IfcParse::IfcSpfHeader::lexer;
|
|
|
|
|
%ignore IfcParse::IfcSpfHeader::stream;
|
2015-01-16 16:26:40 +00:00
|
|
|
%ignore IfcParse::HeaderEntity::is;
|
2015-01-05 17:46:23 +00:00
|
|
|
|
2015-02-17 20:07:09 +00:00
|
|
|
%rename("by_type") entitiesByType;
|
2015-01-05 14:11:42 +00:00
|
|
|
%rename("__len__") getArgumentCount;
|
|
|
|
|
%rename("get_argument_type") getArgumentType;
|
|
|
|
|
%rename("get_argument_name") getArgumentName;
|
|
|
|
|
%rename("get_argument_index") getArgumentIndex;
|
2015-01-21 17:01:22 +00:00
|
|
|
%rename("get_argument_optionality") getArgumentOptionality;
|
2015-02-27 13:41:33 +00:00
|
|
|
%rename("get_attribute_names") getAttributeNames;
|
|
|
|
|
%rename("get_inverse_attribute_names") getInverseAttributeNames;
|
2015-01-05 14:11:42 +00:00
|
|
|
%rename("__repr__") toString;
|
|
|
|
|
%rename("entity_instance") IfcLateBoundEntity;
|
|
|
|
|
%rename("file") IfcFile;
|
|
|
|
|
|
|
|
|
|
%extend IfcParse::IfcFile {
|
|
|
|
|
IfcParse::IfcLateBoundEntity* by_id(unsigned id) {
|
2015-02-17 20:07:09 +00:00
|
|
|
return (IfcParse::IfcLateBoundEntity*) $self->entityById(id);
|
2015-01-05 14:11:42 +00:00
|
|
|
}
|
|
|
|
|
IfcParse::IfcLateBoundEntity* by_guid(const std::string& guid) {
|
2015-02-17 20:07:09 +00:00
|
|
|
return (IfcParse::IfcLateBoundEntity*) $self->entityByGuid(guid);
|
2015-01-05 14:11:42 +00:00
|
|
|
}
|
2015-02-17 19:48:41 +00:00
|
|
|
IfcParse::IfcLateBoundEntity* add(IfcParse::IfcLateBoundEntity* e) {
|
2015-02-17 19:55:27 +00:00
|
|
|
return (IfcParse::IfcLateBoundEntity*) $self->addEntity(e);
|
2015-02-17 19:48:41 +00:00
|
|
|
}
|
|
|
|
|
void remove(IfcParse::IfcLateBoundEntity* e) {
|
|
|
|
|
$self->removeEntity(e);
|
|
|
|
|
}
|
|
|
|
|
IfcEntityList::ptr traverse(IfcParse::IfcLateBoundEntity* e, int max_level=-1) {
|
|
|
|
|
return $self->traverse(e, max_level);
|
2015-01-05 14:11:42 +00:00
|
|
|
}
|
|
|
|
|
void write(const std::string& fn) {
|
|
|
|
|
std::ofstream f(fn.c_str());
|
|
|
|
|
f << (*$self);
|
|
|
|
|
}
|
2015-06-02 13:29:08 +00:00
|
|
|
std::vector<unsigned> entity_names() const {
|
|
|
|
|
std::vector<unsigned> keys;
|
2015-01-21 17:01:22 +00:00
|
|
|
keys.reserve(std::distance($self->begin(), $self->end()));
|
|
|
|
|
for (IfcParse::IfcFile::entity_by_id_t::const_iterator it = $self->begin(); it != $self->end(); ++ it) {
|
|
|
|
|
keys.push_back(it->first);
|
|
|
|
|
}
|
|
|
|
|
return keys;
|
|
|
|
|
}
|
2015-01-05 17:46:23 +00:00
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
header = property(header)
|
2015-06-02 13:29:08 +00:00
|
|
|
%}
|
2015-01-05 14:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
%extend IfcParse::IfcLateBoundEntity {
|
2015-06-02 13:29:08 +00:00
|
|
|
int get_attribute_category(const std::string& name) const {
|
|
|
|
|
const std::vector<std::string> names = $self->getAttributeNames();
|
|
|
|
|
if (std::find(names.begin(), names.end(), name) != names.end()) {
|
|
|
|
|
return 1;
|
|
|
|
|
} else {
|
|
|
|
|
const std::vector<std::string> names = $self->getInverseAttributeNames();
|
|
|
|
|
if (std::find(names.begin(), names.end(), name) != names.end()) {
|
|
|
|
|
return 2;
|
|
|
|
|
} else {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-17 11:27:02 +00:00
|
|
|
|
|
|
|
|
std::pair<IfcUtil::ArgumentType,Argument*> get_argument(unsigned i) {
|
|
|
|
|
return std::pair<IfcUtil::ArgumentType,Argument*>($self->getArgumentType(i), $self->getArgument(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::pair<IfcUtil::ArgumentType,Argument*> get_argument(const std::string& a) {
|
|
|
|
|
unsigned i = IfcSchema::Type::GetAttributeIndex($self->type(), a);
|
|
|
|
|
return std::pair<IfcUtil::ArgumentType,Argument*>($self->getArgumentType(i), $self->getArgument(i));
|
|
|
|
|
}
|
2016-04-09 20:20:08 +02:00
|
|
|
|
|
|
|
|
bool __eq__(IfcParse::IfcLateBoundEntity* other) const {
|
|
|
|
|
if ($self == other) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return $self->id() == other->id() && $self->entity->file == other->entity->file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Just something to have a somewhat sensible value to hash
|
|
|
|
|
size_t file_pointer() const {
|
|
|
|
|
return reinterpret_cast<size_t>($self->entity->file);
|
|
|
|
|
}
|
2015-01-05 14:11:42 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-05 17:46:23 +00:00
|
|
|
%extend IfcParse::IfcSpfHeader {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
|
|
|
|
# Hide the getters with read-only property implementations
|
|
|
|
|
file_description = property(file_description)
|
|
|
|
|
file_name = property(file_name)
|
|
|
|
|
file_schema = property(file_schema)
|
2015-06-02 13:29:08 +00:00
|
|
|
%}
|
2015-01-05 17:46:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcParse::FileDescription {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
2015-01-16 16:26:40 +00:00
|
|
|
# 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)
|
2015-06-02 13:29:08 +00:00
|
|
|
%}
|
2015-01-05 17:46:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcParse::FileName {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
2015-01-16 16:26:40 +00:00
|
|
|
# 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
|
2015-01-20 14:39:52 +00:00
|
|
|
time_stamp = property(time_stamp, time_stamp)
|
2015-01-16 16:26:40 +00:00
|
|
|
__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)
|
2015-06-02 13:29:08 +00:00
|
|
|
%}
|
2015-01-05 17:46:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%extend IfcParse::FileSchema {
|
|
|
|
|
%pythoncode %{
|
|
|
|
|
if _newclass:
|
2015-01-18 15:32:50 +00:00
|
|
|
# Hide the getters with read-write property implementations
|
2015-01-16 16:26:40 +00:00
|
|
|
__swig_getmethods__["schema_identifiers"] = schema_identifiers
|
|
|
|
|
__swig_setmethods__["schema_identifiers"] = schema_identifiers
|
|
|
|
|
schema_identifiers = property(schema_identifiers, schema_identifiers)
|
2015-06-02 13:29:08 +00:00
|
|
|
%}
|
2015-01-05 17:46:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
%include "../ifcparse/IfcSpfHeader.h"
|
2015-01-05 14:11:42 +00:00
|
|
|
%include "../ifcparse/IfcFile.h"
|
|
|
|
|
%include "../ifcparse/IfcLateBoundEntity.h"
|
|
|
|
|
|
|
|
|
|
// The IfcFile* returned by open() is to be freed by SWIG/Python
|
|
|
|
|
%newobject open;
|
|
|
|
|
|
|
|
|
|
%inline %{
|
|
|
|
|
IfcParse::IfcFile* open(const std::string& s) {
|
|
|
|
|
IfcParse::IfcFile* f = new IfcParse::IfcFile(true);
|
|
|
|
|
f->Init(s);
|
|
|
|
|
return f;
|
|
|
|
|
}
|
2015-09-10 15:53:59 +02:00
|
|
|
|
|
|
|
|
const char* const schema_identifier() {
|
|
|
|
|
return IfcSchema::Identifier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* const version() {
|
|
|
|
|
return IFCOPENSHELL_VERSION;
|
|
|
|
|
}
|
2015-01-05 14:11:42 +00:00
|
|
|
%}
|