diff --git a/.travis.yml b/.travis.yml index ed49144b61..8056b9feec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,16 +41,15 @@ script: - mkdir build - cd build - cmake .. - - make - - sudo make install + - sudo make -j2 install - cd .. - cd .. - pwd - cd IfcOpenShell - pwd - cd cmake - - mkdir build-ifc2x3 build-ifc4 - - cd build-ifc2x3 + - 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 .. - sudo make install - cd ../../test diff --git a/src/ifcgeom/IfcGeomFunctions.cpp b/src/ifcgeom/IfcGeomFunctions.cpp index 82f92fc0e9..1fc1bc18f0 100644 --- a/src/ifcgeom/IfcGeomFunctions.cpp +++ b/src/ifcgeom/IfcGeomFunctions.cpp @@ -173,7 +173,7 @@ namespace { IfcSchema::IfcGeometricRepresentationContext::list::it it; IfcSchema::IfcGeometricRepresentationContext::list::ptr contexts = - file->instances_by_type(); + file->instances_by_type_excl_subtypes(); for (it = contexts->begin(); it != contexts->end(); ++it) { IfcSchema::IfcGeometricRepresentationContext* context = *it; diff --git a/src/ifcgeom_schema_agnostic/Kernel.cpp b/src/ifcgeom_schema_agnostic/Kernel.cpp index 79637f6638..8266586b25 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.cpp +++ b/src/ifcgeom_schema_agnostic/Kernel.cpp @@ -7,7 +7,7 @@ IfcGeom::Kernel::Kernel(IfcParse::IfcFile* file) { } const std::string& schema_name = file->schema()->name(); - impl::kernel_implementations().construct(schema_name, file); + implementation_ = impl::kernel_implementations().construct(schema_name, file); } } diff --git a/src/ifcopenshell-python/ifcopenshell/__init__.py b/src/ifcopenshell-python/ifcopenshell/__init__.py index 2ff399c8da..d573b57ac6 100644 --- a/src/ifcopenshell-python/ifcopenshell/__init__.py +++ b/src/ifcopenshell-python/ifcopenshell/__init__.py @@ -60,8 +60,11 @@ from .entity_instance import entity_instance def open(fn): - return file(ifcopenshell_wrapper.open(os.path.abspath(fn))) - + f = ifcopenshell_wrapper.open(os.path.abspath(fn)) + if f.good(): + return file(f) + else: + raise IOError("Unable to open file for reading") def create_entity(type, *args, **kwargs): e = entity_instance(type) diff --git a/src/ifcopenshell-python/ifcopenshell/geom/main.py b/src/ifcopenshell-python/ifcopenshell/geom/main.py index 92d57f005f..abc2b4dead 100644 --- a/src/ifcopenshell-python/ifcopenshell/geom/main.py +++ b/src/ifcopenshell-python/ifcopenshell/geom/main.py @@ -91,7 +91,12 @@ class iterator(_iterator): if has_occ: def get(self): return wrap_shape_creation(self.settings, _iterator.get(self)) - + + def __iter__(self): + if self.initialize(): + while True: + yield self.get() + if not self.next(): break class tree(ifcopenshell_wrapper.tree): diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index 329c2d156a..e609ef9272 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -129,6 +129,16 @@ public: } } + template + typename T::list::ptr instances_by_type_excl_subtypes() { + IfcEntityList::ptr untyped_list = instances_by_type_excl_subtypes(&T::Class()); + 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. /// NOTE: This also returns subtypes of the requested type, for example: /// IfcWall will also return IfcWallStandardCase entities diff --git a/src/ifcwrap/IfcGeomWrapper.i b/src/ifcwrap/IfcGeomWrapper.i index 0fc8def4b8..0050b40d23 100644 --- a/src/ifcwrap/IfcGeomWrapper.i +++ b/src/ifcwrap/IfcGeomWrapper.i @@ -167,14 +167,6 @@ struct ShapeRTTI : public boost::static_visitor $result = boost::apply_visitor(ShapeRTTI(), $1); } -// This does not seem to work: -%ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, IfcParse::IfcFile*); -%ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, void*, int); -%ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int); -%ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, IfcParse::IfcFile*); -%ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, void*, int); -%ignore IfcGeom::Iterator::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int); - %extend IfcGeom::IteratorSettings { %pythoncode %{ attrs = ("convert_back_units", "deflection_tolerance", "disable_opening_subtractions", "disable_triangulation", "faster_booleans", "sew_shells", "use_brep_data", "use_world_coords", "weld_vertices") @@ -237,6 +229,11 @@ struct ShapeRTTI : public boost::static_visitor }; %extend IfcGeom::Element { + + IfcUtil::IfcBaseClass* product_() const { + return $self->product(); + } + %pythoncode %{ if _newclass: # Hide the getters with read-only property implementations @@ -248,7 +245,9 @@ struct ShapeRTTI : public boost::static_visitor context = property(context) unique_id = property(unique_id) transformation = property(transformation) + product = property(product_) %} + }; %extend IfcGeom::TriangulationElement {