mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Python wrapper geometry handling
This commit is contained in:
+3
-4
@@ -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
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace {
|
||||
|
||||
IfcSchema::IfcGeometricRepresentationContext::list::it it;
|
||||
IfcSchema::IfcGeometricRepresentationContext::list::ptr contexts =
|
||||
file->instances_by_type<IfcSchema::IfcGeometricRepresentationContext>();
|
||||
file->instances_by_type_excl_subtypes<IfcSchema::IfcGeometricRepresentationContext>();
|
||||
|
||||
for (it = contexts->begin(); it != contexts->end(); ++it) {
|
||||
IfcSchema::IfcGeometricRepresentationContext* context = *it;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -129,6 +129,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
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<T>();
|
||||
} 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
|
||||
|
||||
@@ -167,14 +167,6 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
|
||||
$result = boost::apply_visitor(ShapeRTTI(), $1);
|
||||
}
|
||||
|
||||
// This does not seem to work:
|
||||
%ignore IfcGeom::Iterator<float>::Iterator(const IfcGeom::IteratorSettings&, IfcParse::IfcFile*);
|
||||
%ignore IfcGeom::Iterator<float>::Iterator(const IfcGeom::IteratorSettings&, void*, int);
|
||||
%ignore IfcGeom::Iterator<float>::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int);
|
||||
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, IfcParse::IfcFile*);
|
||||
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, void*, int);
|
||||
%ignore IfcGeom::Iterator<double>::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<PyObject*>
|
||||
};
|
||||
|
||||
%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<PyObject*>
|
||||
context = property(context)
|
||||
unique_id = property(unique_id)
|
||||
transformation = property(transformation)
|
||||
product = property(product_)
|
||||
%}
|
||||
|
||||
};
|
||||
|
||||
%extend IfcGeom::TriangulationElement {
|
||||
|
||||
Reference in New Issue
Block a user