Merge branch 'v0.6.0' into v0.7.0

# Conflicts:
#	cmake/CMakeLists.txt
#	src/ifcconvert/IfcConvert.cpp
#	src/ifcgeom/IfcGeomRepresentation.h
#	src/ifcgeom/IfcRepresentationShapeItem.h
#	src/ifcgeom/kernels/opencascade/IfcGeomFunctions.cpp
#	src/ifcgeom/schema_agnostic/IfcGeomRepresentation.cpp
#	src/ifcgeom/schema_agnostic/Kernel.cpp
#	src/ifcgeom/schema_agnostic/Kernel.h
#	src/ifcgeomserver/IfcGeomServer.cpp
#	src/serializers/schema_dependent/XmlSerializer.cpp
This commit is contained in:
Thomas Krijnen
2019-04-26 15:07:50 +02:00
51 changed files with 10815 additions and 7568 deletions
+11 -17
View File
@@ -78,23 +78,17 @@ IF(PYTHONINTERP_FOUND AND NOT "${PYTHON_EXECUTABLE}" STREQUAL "")
IF("${python_package_dir}" STREQUAL "")
MESSAGE(WARNING "Unable to locate Python site-package directory, unable to install the Python wrapper")
ELSE()
INSTALL(FILES
"${CMAKE_BINARY_DIR}/ifcwrap/ifcopenshell_wrapper.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/entity_instance.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/file.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/guid.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/main.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/template.py"
DESTINATION "${python_package_dir}/ifcopenshell")
INSTALL(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/geom/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/geom/app.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/geom/code_editor_pane.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/geom/main.py"
"${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/geom/occ_utils.py"
DESTINATION "${python_package_dir}/ifcopenshell/geom")
INSTALL(TARGETS _ifcopenshell_wrapper DESTINATION "${python_package_dir}/ifcopenshell")
FILE(GLOB_RECURSE sourcefiles "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/*.py")
FOREACH(file ${sourcefiles})
FILE(RELATIVE_PATH relative "${CMAKE_CURRENT_SOURCE_DIR}/../ifcopenshell-python/ifcopenshell/" "${file}")
GET_FILENAME_COMPONENT(dir "${relative}" DIRECTORY)
INSTALL(FILES "${file}"
DESTINATION "${python_package_dir}/ifcopenshell/${dir}")
ENDFOREACH()
INSTALL(FILES "${CMAKE_BINARY_DIR}/ifcwrap/ifcopenshell_wrapper.py"
DESTINATION "${python_package_dir}/ifcopenshell")
INSTALL(TARGETS _ifcopenshell_wrapper
DESTINATION "${python_package_dir}/ifcopenshell")
ENDIF()
ELSE()
MESSAGE(WARNING "No Python interpreter found, unable to install the Python wrapper")
+102 -10
View File
@@ -136,8 +136,8 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
}
{
const std::vector<const IfcParse::entity::attribute*> attrs = $self->declaration().as_entity()->all_attributes();
std::vector<const IfcParse::entity::attribute*>::const_iterator it = attrs.begin();
const std::vector<const IfcParse::attribute*> attrs = $self->declaration().as_entity()->all_attributes();
std::vector<const IfcParse::attribute*>::const_iterator it = attrs.begin();
for (; it != attrs.end(); ++it) {
if ((*it)->name() == name) {
return 1;
@@ -146,8 +146,8 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
}
{
const std::vector<const IfcParse::entity::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
std::vector<const IfcParse::entity::inverse_attribute*>::const_iterator it = attrs.begin();
const std::vector<const IfcParse::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
for (; it != attrs.end(); ++it) {
if ((*it)->name() == name) {
return 2;
@@ -178,12 +178,12 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
return std::vector<std::string>(1, "wrappedValue");
}
const std::vector<const IfcParse::entity::attribute*> attrs = $self->declaration().as_entity()->all_attributes();
const std::vector<const IfcParse::attribute*> attrs = $self->declaration().as_entity()->all_attributes();
std::vector<std::string> attr_names;
attr_names.reserve(attrs.size());
std::vector<const IfcParse::entity::attribute*>::const_iterator it = attrs.begin();
std::vector<const IfcParse::attribute*>::const_iterator it = attrs.begin();
for (; it != attrs.end(); ++it) {
attr_names.push_back((*it)->name());
}
@@ -196,12 +196,12 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
return std::vector<std::string>(0);
}
const std::vector<const IfcParse::entity::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
const std::vector<const IfcParse::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
std::vector<std::string> attr_names;
attr_names.reserve(attrs.size());
std::vector<const IfcParse::entity::inverse_attribute*>::const_iterator it = attrs.begin();
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
for (; it != attrs.end(); ++it) {
attr_names.push_back((*it)->name());
}
@@ -260,8 +260,8 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
}
IfcEntityList::ptr get_inverse(const std::string& a) {
const std::vector<const IfcParse::entity::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
std::vector<const IfcParse::entity::inverse_attribute*>::const_iterator it = attrs.begin();
const std::vector<const IfcParse::inverse_attribute*> attrs = $self->declaration().as_entity()->all_inverse_attributes();
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
for (; it != attrs.end(); ++it) {
if ((*it)->name() == a) {
return self->data().getInverse(
@@ -586,6 +586,98 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
}
%}
%extend IfcParse::named_type {
%pythoncode %{
def __repr__(self):
return repr(self.declared_type())
%}
}
%extend IfcParse::simple_type {
%pythoncode %{
def __repr__(self):
return "<%s>" % self.declared_type()
%}
}
%extend IfcParse::aggregation_type {
std::string type_of_aggregation_string() const {
static const char* const aggr_strings[] = {"array", "bag", "list", "set"};
return aggr_strings[(int) $self->type_of_aggregation()];
}
%pythoncode %{
def __repr__(self):
format_bound = lambda i: "?" if i == -1 else str(i)
return "<%s [%s:%s] of %r>" % (
self.type_of_aggregation_string(),
format_bound(self.bound1()),
format_bound(self.bound2()),
self.type_of_element()
)
%}
}
%extend IfcParse::type_declaration {
%pythoncode %{
def __repr__(self):
return "<type %s: %r>" % (self.name(), self.declared_type())
%}
}
%extend IfcParse::select_type {
%pythoncode %{
def __repr__(self):
return "<select %s: (%s)>" % (self.name(), " | ".join(map(repr, self.select_list())))
%}
}
%extend IfcParse::enumeration_type {
%pythoncode %{
def __repr__(self):
return "<enumeration %s: (%s)>" % (self.name(), ", ".join(self.enumeration_items()))
%}
}
%extend IfcParse::attribute {
%pythoncode %{
def __repr__(self):
return "<attribute %s%s: %s>" % (self.name(), "?" if self.optional() else "", self.type_of_attribute())
%}
}
%extend IfcParse::inverse_attribute {
std::string type_of_aggregation_string() const {
static const char* const aggr_strings[] = {"bag", "set", ""};
return aggr_strings[(int) $self->type_of_aggregation()];
}
%pythoncode %{
def __repr__(self):
format_bound = lambda i: "?" if i == -1 else str(i)
return "<inverse %s: %s [%s:%s] of %r for %r>" % (
self.name(),
self.type_of_aggregation_string(),
format_bound(self.bound1()),
format_bound(self.bound2()),
self.entity_reference(),
self.attribute_reference()
)
%}
}
%extend IfcParse::entity {
%pythoncode %{
def __repr__(self):
return "<entity %s>" % (self.name())
%}
}
%extend IfcParse::schema_definition {
%pythoncode %{
def __repr__(self):
return "<schema %s>" % (self.name())
%}
}
%{
static std::stringstream ifcopenshell_log_stream;
%}
+17 -1
View File
@@ -106,12 +106,28 @@
// Conversion functions to convert STL vectors into Python objects
%{
swig_type_info* declaration_type_to_swig(const IfcParse::declaration* t) {
if (t->as_entity()) {
return SWIGTYPE_p_IfcParse__entity;
} else if (t->as_type_declaration()) {
return SWIGTYPE_p_IfcParse__type_declaration;
} else if (t->as_select_type()) {
return SWIGTYPE_p_IfcParse__select_type;
} else if (t->as_enumeration_type()) {
return SWIGTYPE_p_IfcParse__enumeration_type;
}
}
PyObject* pythonize(const int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
PyObject* pythonize(const std::string& t) { return PyUnicode_FromString(t.c_str()); }
PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcUtil__IfcBaseClass, 0); }
PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcUtil__IfcBaseClass, 0); }
PyObject* pythonize(const IfcParse::attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__attribute, 0); }
PyObject* pythonize(const IfcParse::inverse_attribute* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__inverse_attribute, 0); }
PyObject* pythonize(const IfcParse::entity* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__entity, 0); }
PyObject* pythonize(const IfcParse::declaration* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), declaration_type_to_swig(t), 0); }
// NB: This cannot be temporary as a Python object is constructed from a pointer to the address of this object
PyObject* pythonize(const IfcGeom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_IfcGeom__Material, 0); }
+27
View File
@@ -10,6 +10,25 @@
$result = SWIG_Python_str_FromChar(IfcUtil::ArgumentTypeToString($1));
}
%typemap(out) IfcParse::declaration* {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), declaration_type_to_swig($1), 0);
}
%typemap(out) IfcParse::parameter_type* {
if ($1->as_named_type()) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_named_type()), SWIGTYPE_p_IfcParse__named_type, 0);
} else if ($1->as_simple_type()) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_simple_type()), SWIGTYPE_p_IfcParse__simple_type, 0);
} else if ($1->as_aggregation_type()) {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1->as_aggregation_type()), SWIGTYPE_p_IfcParse__aggregation_type, 0);
}
}
%typemap(out) IfcParse::simple_type::data_type {
static const char* const data_type_strings[] = {"binary", "boolean", "integer", "logical", "number", "real", "string"};
$result = SWIG_Python_str_FromChar(data_type_strings[(int)$1]);
}
%typemap(out) std::pair<IfcUtil::ArgumentType, Argument*> {
// The SWIG %exception directive does not take care
// of our typemap. So the attribute conversion block
@@ -79,6 +98,9 @@
IfcEntityListList::ptr v = arg;
$result = pythonize(v);
break; }
case IfcUtil::Argument_EMPTY_AGGREGATE: {
$result = PyTuple_New(0);
break; }
case IfcUtil::Argument_UNKNOWN:
default:
SWIG_exception(SWIG_RuntimeError,"Unknown attribute type");
@@ -101,8 +123,13 @@
}
%enddef
CREATE_VECTOR_TYPEMAP_OUT(bool)
CREATE_VECTOR_TYPEMAP_OUT(int)
CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
CREATE_VECTOR_TYPEMAP_OUT(double)
CREATE_VECTOR_TYPEMAP_OUT(std::string)
CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::Material)
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::attribute const *)
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::inverse_attribute const *)
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::entity const *)
CREATE_VECTOR_TYPEMAP_OUT(IfcParse::declaration const *)