Skip to content

Commit 4d5d749

Browse files
committed
Merge developments from the python_wrapper branch into master
1 parent 8872aff commit 4d5d749

61 files changed

Lines changed: 37157 additions & 21166 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/CMakeLists.txt

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,18 @@ ENDIF(MSVC)
123123

124124
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} /usr/inc /usr/local/inc /usr/local/include/oce ${ICU_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
125125

126-
ADD_LIBRARY(IfcParse STATIC
126+
ADD_LIBRARY(IfcParse STATIC
127+
../src/ifcparse/Ifc2x3-latebound.cpp
127128
../src/ifcparse/Ifc2x3.cpp
129+
../src/ifcparse/Ifc4-latebound.cpp
128130
../src/ifcparse/Ifc4.cpp
129-
../src/ifcparse/IfcUtil.cpp
130-
../src/ifcparse/IfcParse.cpp
131131
../src/ifcparse/IfcCharacterDecoder.cpp
132-
133-
../src/ifcparse/IfcWrite.cpp
134132
../src/ifcparse/IfcGuidHelper.cpp
135-
136-
../src/ifcparse/IfcHierarchyHelper.cpp
133+
../src/ifcparse/IfcHierarchyHelper.cpp
134+
../src/ifcparse/IfcLateBoundEntity.cpp
135+
../src/ifcparse/IfcParse.cpp
136+
../src/ifcparse/IfcUtil.cpp
137+
../src/ifcparse/IfcWrite.cpp
137138
)
138139

139140
ADD_LIBRARY(IfcGeom STATIC
@@ -206,18 +207,24 @@ SET(include_files_geom
206207
../src/ifcgeom/IfcRepresentationShapeItem.h
207208
)
208209
SET(include_files_parse
210+
../src/ifcparse/Ifc2x3-latebound.h
209211
../src/ifcparse/Ifc2x3.h
210212
../src/ifcparse/Ifc2x3enum.h
213+
../src/ifcparse/Ifc4-latebound.h
214+
../src/ifcparse/Ifc4.h
215+
../src/ifcparse/Ifc4enum.h
211216
../src/ifcparse/IfcCharacterDecoder.h
217+
../src/ifcparse/IfcEntityDescriptor.h
212218
../src/ifcparse/IfcException.h
213219
../src/ifcparse/IfcFile.h
214220
../src/ifcparse/IfcHierarchyHelper.h
221+
../src/ifcparse/IfcLateBoundEntity.h
215222
../src/ifcparse/IfcParse.h
223+
../src/ifcparse/IfcSpfStream.h
216224
../src/ifcparse/IfcUtil.h
217-
../src/ifcparse/SharedPointer.h
218-
219-
../src/ifcparse/IfcWrite.h
220225
../src/ifcparse/IfcWritableEntity.h
226+
../src/ifcparse/IfcWrite.h
227+
../src/ifcparse/SharedPointer.h
221228
)
222229
INSTALL(FILES ${include_files_geom} DESTINATION include/ifcgeom)
223230
INSTALL(FILES ${include_files_parse} DESTINATION include/ifcparse)

src/ifcblender/io_import_scene_ifc/__init__.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,21 @@
6262
description="The STEP Datatype keyword")
6363

6464

65-
def import_ifc(filename, use_names, process_relations):
65+
def import_ifc(filename, use_names, process_relations, blender_booleans):
6666
from . import ifcopenshell
67+
from .ifcopenshell import geom as ifcopenshell_geom
6768
print("Reading %s..."%bpy.path.basename(filename))
68-
settings = ifcopenshell.IteratorSettings()
69-
iterator = ifcopenshell.Iterator(settings, filename)
69+
settings = ifcopenshell_geom.settings()
70+
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS, blender_booleans)
71+
iterator = ifcopenshell_geom.iterator(settings, filename)
7072
valid_file = iterator.findContext()
7173
if not valid_file:
7274
return False
7375
print("Done reading file")
7476
id_to_object = {}
7577
id_to_parent = {}
7678
id_to_matrix = {}
79+
openings = []
7780
old_progress = -1
7881
print("Creating geometry...")
7982
while True:
@@ -139,15 +142,20 @@ def add_material(mname, props):
139142
bob.ifc_id, bob.ifc_guid, bob.ifc_name, bob.ifc_type = \
140143
ob.id, ob.guid, ob.name, ob.type
141144

142-
bob.hide = ob.type == 'IfcSpace' or ob.type == 'IfcOpeningElement'
143-
bob.hide_render = bob.hide
145+
if ob.type == 'IfcSpace' or ob.type == 'IfcOpeningElement':
146+
if not (ob.type == 'IfcOpeningElement' and blender_booleans):
147+
bob.hide = bob.hide_render = True
148+
bob.draw_type = 'WIRE'
144149

145150
if ob.id not in id_to_object: id_to_object[ob.id] = []
146151
id_to_object[ob.id].append(bob)
147152

148153
if ob.parent_id > 0:
149154
id_to_parent[ob.id] = ob.parent_id
150155

156+
if blender_booleans and ob.type == 'IfcOpeningElement':
157+
openings.append(ob.id)
158+
151159
faces = me.polygons if hasattr(me, 'polygons') else me.faces
152160
if len(faces) == len(matids):
153161
for face, matid in zip(faces, matids):
@@ -173,11 +181,11 @@ def add_material(mname, props):
173181
if parent_id in id_to_object:
174182
bob = id_to_object[parent_id][0]
175183
else:
176-
parent_ob = iterator.GetObject(parent_id)
184+
parent_ob = iterator.getObject(parent_id)
177185
if parent_ob.id == -1:
178186
bob = None
179187
else:
180-
m = parent_ob.matrix
188+
m = parent_ob.transformation.matrix.data
181189
nm = parent_ob.name if len(parent_ob.name) and use_names \
182190
else parent_ob.guid
183191
bob = bpy.data.objects.new(nm, None)
@@ -219,7 +227,16 @@ def add_material(mname, props):
219227

220228
if process_relations:
221229
print("Done processing relations")
222-
230+
231+
for opening_id in openings:
232+
parent_id = id_to_parent[opening_id]
233+
if parent_id in id_to_object:
234+
parent_ob = id_to_object[parent_id][0]
235+
for opening_ob in id_to_object[opening_id]:
236+
mod = parent_ob.modifiers.new("opening", "BOOLEAN")
237+
mod.operation = "DIFFERENCE"
238+
mod.object = opening_ob
239+
223240
txt = bpy.data.texts.new("%s.log"%bpy.path.basename(filename))
224241
txt.from_string(iterator.getLog())
225242

@@ -241,9 +258,13 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
241258
" relations to parenting" \
242259
" (warning: may be slow on large files)",
243260
default=False)
261+
blender_booleans = BoolProperty(name="Use Blender booleans",
262+
description="Use Blender boolean modifiers for opening" \
263+
" elements",
264+
default=False)
244265

245266
def execute(self, context):
246-
if not import_ifc(self.filepath, self.use_names, self.process_relations):
267+
if not import_ifc(self.filepath, self.use_names, self.process_relations, self.blender_booleans):
247268
self.report({'ERROR'},
248269
'Unable to parse .ifc file or no geometrical entities found'
249270
)

src/ifcconvert/ColladaSerializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class ColladaSerializer : public GeometrySerializer
150150
bool ready();
151151
void writeHeader();
152152
void write(const IfcGeom::TriangulationElement<double>* o);
153-
void write(const IfcGeom::ShapeModelElement<double>* o) {}
153+
void write(const IfcGeom::BRepElement<double>* o) {}
154154
void finalize();
155155
bool isTesselated() const { return true; }
156156
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {

src/ifcconvert/GeometrySerializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class GeometrySerializer {
3030
virtual bool isTesselated() const = 0;
3131
virtual ~GeometrySerializer() {}
3232
virtual void write(const IfcGeom::TriangulationElement<double>* o) = 0;
33-
virtual void write(const IfcGeom::ShapeModelElement<double>* o) = 0;
33+
virtual void write(const IfcGeom::BRepElement<double>* o) = 0;
3434
virtual void setUnitNameAndMagnitude(const std::string& name, float magnitude) = 0;
3535
};
3636

src/ifcconvert/IfcConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ int main(int argc, char** argv) {
247247
}
248248

249249
if (convert_back_units) {
250-
serializer->setUnitNameAndMagnitude(context_iterator.getUnitName(), context_iterator.getUnitMagnitude());
250+
serializer->setUnitNameAndMagnitude(context_iterator.getUnitName(), static_cast<const float>(context_iterator.getUnitMagnitude()));
251251
} else {
252252
serializer->setUnitNameAndMagnitude("METER", 1.0f);
253253
}
@@ -274,7 +274,7 @@ int main(int argc, char** argv) {
274274
if (serializer->isTesselated()) {
275275
serializer->write(static_cast<const IfcGeom::TriangulationElement<double>*>(geom_object));
276276
} else {
277-
serializer->write(static_cast<const IfcGeom::ShapeModelElement<double>*>(geom_object));
277+
serializer->write(static_cast<const IfcGeom::BRepElement<double>*>(geom_object));
278278
}
279279

280280
const int progress = context_iterator.progress() / 2;

src/ifcconvert/OpenCascadeBasedSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool OpenCascadeBasedSerializer::ready() {
3434
return succeeded;
3535
}
3636

37-
void OpenCascadeBasedSerializer::write(const IfcGeom::ShapeModelElement<double>* o) {
37+
void OpenCascadeBasedSerializer::write(const IfcGeom::BRepElement<double>* o) {
3838
for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = o->geometry().begin(); it != o->geometry().end(); ++ it) {
3939
gp_GTrsf gtrsf = it->Placement();
4040

src/ifcconvert/OpenCascadeBasedSerializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class OpenCascadeBasedSerializer : public GeometrySerializer {
3939
bool ready();
4040
virtual void writeShape(const TopoDS_Shape& shape) = 0;
4141
void write(const IfcGeom::TriangulationElement<double>* o) {}
42-
void write(const IfcGeom::ShapeModelElement<double>* o);
42+
void write(const IfcGeom::BRepElement<double>* o);
4343
bool isTesselated() const { return false; }
4444
};
4545

src/ifcconvert/WavefrontObjSerializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class WaveFrontOBJSerializer : public GeometrySerializer {
4646
void writeHeader();
4747
void writeMaterial(const IfcGeom::Material& style);
4848
void write(const IfcGeom::TriangulationElement<double>* o);
49-
void write(const IfcGeom::ShapeModelElement<double>* o) {}
49+
void write(const IfcGeom::BRepElement<double>* o) {}
5050
void finalize() {}
5151
bool isTesselated() const { return true; }
5252
void setUnitNameAndMagnitude(const std::string& name, float magnitude) {}

src/ifcexpressparser/bootstrap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ def find_keywords(expr, li = None):
170170
import header
171171
import enum_header
172172
import implementation
173+
import latebound_header
174+
import latebound_implementation
173175
174176
syntax.ignore(Regex(r"\((?:\*(?:[^*]*\*+)+?\))"))
175177
ast = syntax.parseFile(sys.argv[1])
@@ -179,4 +181,6 @@ def find_keywords(expr, li = None):
179181
header.Header(mapping).emit()
180182
enum_header.EnumHeader(mapping).emit()
181183
implementation.Implementation(mapping).emit()
184+
latebound_header.LateBoundHeader(mapping).emit()
185+
latebound_implementation.LateBoundImplementation(mapping).emit()
182186
"""%('\n'.join(statements)))

src/ifcexpressparser/enum_header.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121

2222
class EnumHeader:
2323
def __init__(self, mapping):
24-
selectable_simple_types = sorted(set(sum([b.values for a,b in mapping.schema.selects.items()], [])) & set(mapping.schema.types.keys()))
25-
enumerable_types = selectable_simple_types + [name for name, type in mapping.schema.entities.items()]
24+
enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]))
2625

2726
self.str = templates.enum_header % {
2827
'schema_name_upper' : mapping.schema.name.upper(),

0 commit comments

Comments
 (0)