Fix IfcOpenHouse

This commit is contained in:
Thomas Krijnen
2018-08-13 11:43:28 +02:00
parent d09abbd260
commit 175387bd88
5 changed files with 24 additions and 9 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ script:
- cd cmake
- mkdir build
- cd build
- cmake -DCOLLADA_SUPPORT=True -DOPENCOLLADA_INCLUDE_DIR=/usr/local/include/opencollada -DOPENCOLLADA_LIBRARY_DIR=/usr/local/lib/opencollada -DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DBUILD_EXAMPLES=Off -DBUILD_IFCPYTHON=True -DUNICODE_SUPPORT=True -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DPYTHON_LIBRARY=/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_EXECUTABLE=/usr/bin/python2.7 ..
- cmake -DCOLLADA_SUPPORT=True -DOPENCOLLADA_INCLUDE_DIR=/usr/local/include/opencollada -DOPENCOLLADA_LIBRARY_DIR=/usr/local/lib/opencollada -DPCRE_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DBUILD_IFCPYTHON=True -DUNICODE_SUPPORT=True -DOCC_LIBRARY_DIR=/usr/lib/x86_64-linux-gnu -DPYTHON_LIBRARY=/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_EXECUTABLE=/usr/bin/python2.7 ..
- sudo make install
- cd ../../test
- /usr/bin/python2.7 tests.py
@@ -12,9 +12,9 @@ namespace IfcGeom {
template <typename Fn, typename T>
IfcUtil::IfcBaseClass* execute_based_on_schema(Fn fn1, Fn fn2, const std::string& schema_name, const TopoDS_Shape& shape, T t) {
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
if (schema_name == "ifc2x3") {
if (schema_name_lower == "ifc2x3") {
return fn1(shape, t);
} else if (schema_name == "ifc4") {
} else if (schema_name_lower == "ifc4") {
return fn2(shape, t);
} else {
throw IfcParse::IfcException("No geometry serialization available for " + schema_name);
+6
View File
@@ -52,6 +52,9 @@ namespace IfcUtil {
template <class T>
T* as() {
if (this == 0) {
return static_cast<T*>(0);
}
return declaration().is(T::Class())
? static_cast<T*>(this)
: static_cast<T*>(0);
@@ -59,6 +62,9 @@ namespace IfcUtil {
template <class T>
const T* as() const {
if (this == 0) {
return static_cast<const T*>(0);
}
return declaration().is(T::Class())
? static_cast<const T*>(this)
: static_cast<const T*>(0);
+11 -6
View File
@@ -39,7 +39,7 @@
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcGlobalId.h"
namespace impl {
namespace {
IfcUtil::IfcBaseClass* get_parent_of_relation(IfcUtil::IfcBaseClass* t) {
return *t->data().getArgument(
t->declaration().as_entity()->attribute_index("RelatingObject")
@@ -132,10 +132,10 @@ public:
bool found = false;
for (typename T::list::it i = li->begin(); i != li->end(); ++i) {
T* rel = *i;
if (impl::get_parent_of_relation(rel) == relating_object) {
IfcEntityList::ptr products = impl::get_children_of_relation(rel);
if (get_parent_of_relation(rel) == relating_object) {
IfcEntityList::ptr products = get_children_of_relation(rel);
products->push(related_object);
impl::set_children_of_relation(rel, products);
set_children_of_relation(rel, products);
found = true;
break;
}
@@ -154,8 +154,13 @@ public:
IfcEntityInstanceData* data = new IfcEntityInstanceData(&T::Class());
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set<std::string>(IfcParse::IfcGlobalId()); data->setArgument(0, attr); }
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(owner_hist); data->setArgument(1, attr); }
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(relating_object); data->setArgument(4, attr); }
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(related_objects); data->setArgument(5, attr); }
int relating_index = 4, related_index = 5;
if (T::Class().name() == "IfcRelContainedInSpatialStructure") {
// IfcRelContainedInSpatialStructure has attributes reversed.
std::swap(relating_index, related_index);
}
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(relating_object); data->setArgument(relating_index, attr); }
{ IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument(); attr->set(related_objects); data->setArgument(related_index, attr); }
T* t = (T*)Schema::get_schema().instantiate(data);
addEntity(t);
+4
View File
@@ -1079,6 +1079,10 @@ private:
template <typename T>
void apply_attribute_(T& t, Argument* attr) const {
if (!attr) {
return;
}
if (attr->type() == IfcUtil::Argument_ENTITY_INSTANCE) {
IfcUtil::IfcBaseClass* inst = *attr;
t(inst);