Skip to content

Commit 8767f6e

Browse files
committed
IfcBlender: updated to Blender 2.58 (Patch by Yorik van Havre)
IfcParse: lazy loading of entities IfcGeom: caching of binary entities
1 parent dd32f3a commit 8767f6e

File tree

14 files changed

+1049
-643
lines changed

14 files changed

+1049
-643
lines changed

src/ifcblender/IfcBlender.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
"description": "Import files in the "\
2424
"Industry Foundation Classes (.ifc) file format",
2525
"author": "Thomas Krijnen, IfcOpenShell",
26-
"blender": (2, 5, 6),
27-
"api": 32738,
26+
"blender": (2, 5, 8),
27+
"api": 37702,
2828
"location": "File > Import",
29-
"warning": "This addon requires several "\
30-
"Open CASCADE libraries to be installed",
29+
"warning": "",
3130
"wiki_url": "http://sourceforge.net/apps/"\
3231
"mediawiki/ifcopenshell/index.php",
3332
"tracker_url": "http://sourceforge.net/tracker/?group_id=543113",
@@ -37,8 +36,7 @@
3736
import bpy
3837
import mathutils
3938
from bpy.props import *
40-
from io_utils import ImportHelper
41-
39+
from bpy_extras.io_utils import ImportHelper
4240

4341
class ImportIFC(bpy.types.Operator, ImportHelper):
4442
bl_idname = "import_scene.ifc"
@@ -54,7 +52,7 @@ def execute(self, context):
5452
ids = {}
5553
while True:
5654
ob = IfcImport.Get()
57-
if not ob.type in ['IFCSPACE', 'IFCOPENINGELEMENT']:
55+
if not ob.type in ['IfcSpace', 'IfcOpeningElement']:
5856
f = ob.mesh.faces
5957
v = ob.mesh.verts
6058
m = ob.matrix

src/ifcobj/IfcObj.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <fstream>
2929
#include <set>
30+
#include <time.h>
3031

3132
#include "../ifcparse/IfcGeomObjects.h"
3233
#include "../ifcobj/ObjMaterials.h"
@@ -56,12 +57,15 @@ int main ( int argc, char** argv ) {
5657
fObj << "mtllib " << fnMtl << std::endl;
5758
std::set<std::string> materials;
5859

60+
time_t start,end;
61+
time(&start);
62+
5963
// The functions IfcGeomObjects::Get() and IfcGeomObjects::Next() wrap an iterator of all geometrical entities in the Ifc file.
6064
// IfcGeomObjects::Get() returns an IfcGeomObjects::IfcGeomObject (see IfcObjects.h for definition)
6165
// IfcGeomObjects::Next() is used to poll whether more geometrical entities are available
6266
do {
6367
const IfcGeomObjects::IfcGeomObject* o = IfcGeomObjects::Get();
64-
if ( o->type == "IFCSPACE" || o->type == "IFCOPENINGELEMENT" ) continue;
68+
if ( o->type == "IfcSpace" || o->type == "IfcOpeningElement" ) continue;
6569
fObj << "o " << o->name << std::endl;
6670
fObj << "usemtl " << o->type << std::endl;
6771
materials.insert(o->type);
@@ -85,4 +89,8 @@ int main ( int argc, char** argv ) {
8589
for( std::set<std::string>::iterator it = materials.begin(); it != materials.end(); ++ it ) {
8690
fMtl << GetMaterial(*it);
8791
}
92+
93+
time(&end);
94+
int dif = (int) difftime (end,start);
95+
printf ("Conversion took %d seconds\n", dif );
8896
}

src/ifcobj/ObjMaterials.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ class ObjMaterial {
5050
};
5151

5252
ObjMaterial GetMaterial(const std::string& s) {
53-
if ( s == "IFCSITE" ) { return ObjMaterial("IFCSITE",0.75f,0.8f,0.65f); }
54-
if ( s == "IFCSLAB" ) { return ObjMaterial("IFCSLAB",0.4f,0.4f,0.4f); }
55-
if ( s == "IFCWALLSTANDARDCASE" ) { return ObjMaterial("IFCWALLSTANDARDCASE",0.9f,0.9f,0.9f); }
56-
if ( s == "IFCWALL" ) { return ObjMaterial("IFCWALL",0.9f,0.9f,0.9f); }
57-
if ( s == "IFCWINDOW" ) { return ObjMaterial("IFCWINDOW",0.75f,0.8f,0.75f,1.0f,1.0f,1.0f,0.0f,0.0f,0.0f,500.0f,0.3f); }
58-
if ( s == "IFCDOOR" ) { return ObjMaterial("IFCDOOR",0.55f,0.3f,0.15f); }
59-
if ( s == "IFCBEAM" ) { return ObjMaterial("IFCBEAM",0.75f,0.7f,0.7f); }
60-
if ( s == "IFCRAILING" ) { return ObjMaterial("IFCRAILING",0.75f,0.7f,0.7f); }
61-
if ( s == "IFCMEMBER" ) { return ObjMaterial("IFCRAILING",0.75f,0.7f,0.7f); }
53+
if ( s == "IfcSite" ) { return ObjMaterial("IfcSite",0.75f,0.8f,0.65f); }
54+
if ( s == "IfcSlab" ) { return ObjMaterial("IfcSlab",0.4f,0.4f,0.4f); }
55+
if ( s == "IfcWallStandardCase" ) { return ObjMaterial("IfcWallStandardCase",0.9f,0.9f,0.9f); }
56+
if ( s == "IfcWall" ) { return ObjMaterial("IfcWall",0.9f,0.9f,0.9f); }
57+
if ( s == "IfcWindow" ) { return ObjMaterial("IfcWindow",0.75f,0.8f,0.75f,1.0f,1.0f,1.0f,0.0f,0.0f,0.0f,500.0f,0.3f); }
58+
if ( s == "IfcDoor" ) { return ObjMaterial("IfcDoor",0.55f,0.3f,0.15f); }
59+
if ( s == "IfcBeam" ) { return ObjMaterial("IfcBeam",0.75f,0.7f,0.7f); }
60+
if ( s == "IfcRailing" ) { return ObjMaterial("IfcRailing",0.65f,0.6f,0.6f); }
61+
if ( s == "IfcMember" ) { return ObjMaterial("IfcMember",0.65f,0.6f,0.6f); }
62+
if ( s == "IfcPlate" ) { return ObjMaterial("IfcPlate",0.8f,0.8f,0.8f); }
6263
return ObjMaterial(s);
6364
}

src/ifcparse/IfcEnum.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,13 @@ std::string IfcSchema::Enum::ToString(IfcTypes t) {
3838
#include "../ifcparse/IfcSchema.h"
3939
#undef IFC_PARSE_ENUM_STR
4040

41-
return "";
41+
return "IfcUnknown";
42+
}
43+
44+
bool IfcSchema::Enum::ShouldRender(IfcTypes t) {
45+
if ( t == IfcUnknown ) return false;
46+
#define IFC_PARSE_RENDER
47+
#include "../ifcparse/IfcSchema.h"
48+
#undef IFC_PARSE_RENDER
49+
else return false;
4250
}

src/ifcparse/IfcEnum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ namespace IfcSchema {
4242
};
4343
IfcTypes FromString(const std::string& a);
4444
std::string ToString(IfcTypes t);
45+
bool ShouldRender(IfcTypes t);
4546
}
4647
}
4748
#endif

0 commit comments

Comments
 (0)