mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 13:28:19 +00:00
Rework iterator constructor #7291
This commit is contained in:
@@ -22,7 +22,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import operator
|
import operator
|
||||||
|
|
||||||
from .. import ifcopenshell_wrapper
|
from .. import open, ifcopenshell_wrapper
|
||||||
from ..file import file
|
from ..file import file
|
||||||
from ..entity_instance import entity_instance
|
from ..entity_instance import entity_instance
|
||||||
|
|
||||||
@@ -307,10 +307,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
|
|||||||
self.file = file
|
self.file = file
|
||||||
file_or_filename = file_or_filename.wrapped_data
|
file_or_filename = file_or_filename.wrapped_data
|
||||||
else:
|
else:
|
||||||
# @todo?
|
file_or_filename = self.file = open(file_or_filename)
|
||||||
self.file = None
|
|
||||||
# Makes sure people are able to use python's platform agnostic paths
|
|
||||||
file_or_filename = os.path.abspath(file_or_filename)
|
|
||||||
|
|
||||||
if include is not None and exclude is not None:
|
if include is not None and exclude is not None:
|
||||||
raise ValueError("include and exclude cannot be specified simultaneously")
|
raise ValueError("include and exclude cannot be specified simultaneously")
|
||||||
@@ -342,7 +339,7 @@ class iterator(ifcopenshell_wrapper.Iterator):
|
|||||||
geometry_library, self.settings, file_or_filename, include_or_exclude, include is not None, num_threads
|
geometry_library, self.settings, file_or_filename, include_or_exclude, include is not None, num_threads
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
ifcopenshell_wrapper.Iterator.__init__(self, geometry_library, settings, file_or_filename, num_threads)
|
self.this = ifcopenshell_wrapper.construct_iterator(geometry_library, self.settings, file_or_filename, num_threads)
|
||||||
|
|
||||||
if has_occ:
|
if has_occ:
|
||||||
|
|
||||||
|
|||||||
@@ -628,6 +628,7 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
$result = boost::apply_visitor(ShapeRTTI(), (boost::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*>) $1);
|
$result = boost::apply_visitor(ShapeRTTI(), (boost::variant<IfcGeom::Element*, IfcGeom::Representation::Representation*, IfcGeom::Transformation*>) $1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%newobject construct_iterator;
|
||||||
%newobject construct_iterator_with_include_exclude;
|
%newobject construct_iterator_with_include_exclude;
|
||||||
%newobject construct_iterator_with_include_exclude_globalid;
|
%newobject construct_iterator_with_include_exclude_globalid;
|
||||||
%newobject construct_iterator_with_include_exclude_id;
|
%newobject construct_iterator_with_include_exclude_id;
|
||||||
@@ -635,6 +636,10 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
|||||||
// I couldn't get the vector<string> typemap to be applied when %extending Iterator constructor.
|
// I couldn't get the vector<string> typemap to be applied when %extending Iterator constructor.
|
||||||
// anyway it does not matter as SWIG generates C code without actual constructors
|
// anyway it does not matter as SWIG generates C code without actual constructors
|
||||||
%inline %{
|
%inline %{
|
||||||
|
IfcGeom::Iterator* construct_iterator(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, IfcParse::IfcFile* file, int num_threads) {
|
||||||
|
return new IfcGeom::Iterator(ifcopenshell::geometry::kernels::construct(file, geometry_library, settings), settings, file, num_threads);
|
||||||
|
}
|
||||||
|
|
||||||
IfcGeom::Iterator* construct_iterator_with_include_exclude(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, IfcParse::IfcFile* file, std::vector<std::string> elems, bool include, int num_threads) {
|
IfcGeom::Iterator* construct_iterator_with_include_exclude(const std::string& geometry_library, ifcopenshell::geometry::Settings settings, IfcParse::IfcFile* file, std::vector<std::string> elems, bool include, int num_threads) {
|
||||||
std::set<std::string> elems_set(elems.begin(), elems.end());
|
std::set<std::string> elems_set(elems.begin(), elems.end());
|
||||||
IfcGeom::entity_filter ef{ include, false, elems_set };
|
IfcGeom::entity_filter ef{ include, false, elems_set };
|
||||||
|
|||||||
Reference in New Issue
Block a user