Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a1016d8
Showing
34 changed files
with
16,844 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
IfcOpenShell | ||
============ | ||
open source (LGPL) software library for working with the IFC file format | ||
|
||
|
||
http://IfcOpenShell.org | ||
|
||
|
||
Compiling on Windows | ||
==================== | ||
Users are advised to use the Visual Studio .sln file in the win/ folder. | ||
For Windows users a prebuilt Open CASCADE version is available from the | ||
http://opencascade.org website. Download and install this version and | ||
provide the paths to the Open CASCADE header and library files to MS | ||
Visual Studio C++. | ||
|
||
For building the Autodesk 3ds Max plugin, the 3ds Max SDK needs to be | ||
installed as well as 3ds Max itself. Please provide the include and | ||
library paths to Visual Studio. | ||
|
||
For building the IfcPython wrapper, SWIG needs to be installed. Please | ||
download the latest swigwin version from http://www.swig.org/download.html. | ||
After extracting the .zip file, please add the extracted folder to the PATH | ||
environment variable. Python needs to be installed, please provide the | ||
include and library paths to Visual Studio. | ||
|
||
|
||
|
||
Compiling on *nix | ||
==================== | ||
Users are advised to build IfcOpenShell using the cmake file provided in | ||
the cmake/ folder. There might be an Open CASCADE package in your operating | ||
system's software repository. If not, you will need to compile Open | ||
CASCADE yourself. See http://opencascade.org. | ||
|
||
For building the IfcPython wrapper, SWIG and Python development are | ||
required. | ||
|
||
To build IfcOpenShell please take the following steps: | ||
$ cd /path/to/IfcOpenShell/cmake | ||
$ mkdir build | ||
$ cd build | ||
Optionally: | ||
$ OCC_INCLUDE_PATH="/path/to/OpenCASCADE/include" | ||
$ OCC_LIBRARY_PATH="/path/to/OpenCASCADE/lib" | ||
$ export OCC_INCLUDE_PATH | ||
$ export OCC_LIBRARY_PATH | ||
$ cmake ../ | ||
$ make | ||
|
||
If all worked out correctly you can now use IfcOpenShell. For example: | ||
$ wget ftp://ftp.dds.no/pub/ifc/Munkerud/Munkerud_hus6_BE.zip | ||
$ unzip Munkerud_hus6_BE.zip | ||
$ ./IfcObj Munkerud_hus6_BE.ifc | ||
$ less Munkerud_hus6_BE.obj | ||
Or: | ||
$ wget ftp://ftp.dds.no/pub/ifc/Munkerud/Munkerud_hus6_BE.zip | ||
$ unzip Munkerud_hus6_BE.zip | ||
$ python | ||
>>> import IfcImport | ||
>>> IfcImport.Init('Munkerud_hus6_BE.ifc') | ||
>>> geom = IfcImport.Get() | ||
>>> geom.name | ||
>>> for v in geom.mesh.verts: v | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
cmake_minimum_required (VERSION 2.6) | ||
project (IfcOpenShell) | ||
|
||
# Find Open CASCADE header files | ||
IF("$ENV{OCC_INCLUDE_DIR}" STREQUAL "") | ||
SET(OCC_INCLUDE_DIR "/usr/include/opencascade/" CACHE FILEPATH "Open CASCADE header files") | ||
MESSAGE(STATUS "Looking for opencascade include files in: ${OCC_INCLUDE_DIR}") | ||
MESSAGE(STATUS "Use OCC_INCLUDE_DIR to specify another directory") | ||
ELSE() | ||
SET(OCC_INCLUDE_DIR $ENV{OCC_INCLUDE_DIR} CACHE FILEPATH "Open CASCADE header files") | ||
MESSAGE(STATUS "Looking for opencascade include files in: ${OCC_INCLUDE_DIR}") | ||
ENDIF() | ||
|
||
FIND_FILE(gp_Pnt_hxx "gp_Pnt.hxx" ${OCC_INCLUDE_DIR}) | ||
IF(gp_Pnt_hxx) | ||
MESSAGE(STATUS "Header files found") | ||
ELSE() | ||
MESSAGE(FATAL_ERROR "Unable to find header files, aborting") | ||
ENDIF() | ||
|
||
|
||
# Find Open CASCADE library files | ||
IF("$ENV{OCC_LIBRARY_DIR}" STREQUAL "") | ||
SET(OCC_LIBRARY_DIR "/usr/lib/" CACHE FILEPATH "Open CASCADE library files") | ||
MESSAGE(STATUS "Looking for opencascade library files in: ${OCC_LIBRARY_DIR}") | ||
MESSAGE(STATUS "Use OCC_LIBRARY_DIR to specify another directory") | ||
ELSE() | ||
SET(OCC_LIBRARY_DIR $ENV{OCC_LIBRARY_DIR} CACHE FILEPATH "Open CASCADE library files") | ||
MESSAGE(STATUS "Looking for opencascade library files in: ${OCC_LIBRARY_DIR}") | ||
ENDIF() | ||
|
||
FIND_LIBRARY(libTKernel "TKernel" ${OCC_LIBRARY_DIR}) | ||
IF(libTKernel) | ||
MESSAGE(STATUS "Library files found") | ||
ELSE() | ||
MESSAGE(FATAL_ERROR "Unable to find library files, aborting") | ||
ENDIF() | ||
|
||
ADD_DEFINITIONS(-DHAVE_LIMITS_H) | ||
ADD_DEFINITIONS(-DHAVE_IOSTREAM) | ||
ADD_DEFINITIONS(-DHAVE_IOMANIP) | ||
ADD_DEFINITIONS(-DHAVE_FSTREAM) | ||
ADD_DEFINITIONS(-O3) | ||
ADD_DEFINITIONS(-fPIC) | ||
|
||
INCLUDE_DIRECTORIES(${OCC_INCLUDE_DIR}) | ||
ADD_LIBRARY(IfcParse STATIC ../src/ifcparse/IfcEnum.cpp ../src/ifcparse/IfcTypes.cpp ../src/ifcparse/IfcParse.cpp ../src/ifcparse/IfcGeom.cpp ../src/ifcparse/IfcGeomObjects.cpp) | ||
|
||
LINK_DIRECTORIES (${IfcOpenShell_BINARY_DIR} /usr/lib) | ||
ADD_EXECUTABLE(IfcObj ../src/ifcobj/IfcObj.cpp) | ||
TARGET_LINK_LIBRARIES (IfcObj IfcParse TKAdvTools TKMath TKernel TKBRep TKGeomBase TKGeomAlgo TKBool TKMesh TKShHealing) | ||
|
||
# Build python wrapper using separate CMakeLists.txt | ||
ADD_SUBDIRECTORY(../src/ifcwrap .) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import bpy, mathutils | ||
from bpy.props import * | ||
from io_utils import ImportHelper | ||
|
||
class ImportIFC(bpy.types.Operator, ImportHelper): | ||
'''Load an IFC File''' | ||
bl_idname = "import_scene.ifc" | ||
bl_label = "Import IFC" | ||
|
||
filename_ext = ".ifc" | ||
filter_glob = StringProperty(default="*.ifc", options={'HIDDEN'}) | ||
|
||
def execute(self, context): | ||
import IFCimport | ||
IFCimport.init_objs(self.filepath) | ||
ids = {} | ||
while True: | ||
ob = IFCimport.current_obj() | ||
print (ob.name) | ||
if not ob.type in ['IFCSPACE','IFCOPENINGELEMENT']: | ||
f = ob.mesh.faces | ||
v = ob.mesh.verts | ||
m = ob.matrix | ||
if ob.mesh.id in ids: me = ids[ob.mesh.id] | ||
else: | ||
verts = [] | ||
faces = [] | ||
for i in range(0,len(f),3): | ||
faces.append([f[i+0],f[i+1],f[i+2]]) | ||
for i in range(0,len(v),3): | ||
verts.append([v[i+0],v[i+1],v[i+2]]) | ||
me = bpy.data.meshes.new('mesh%d'%ob.mesh.id) | ||
me.from_pydata(verts,[],faces) | ||
if ob.type in bpy.data.materials: | ||
mat = bpy.data.materials[ob.type] | ||
mat.use_fake_user = True | ||
else: mat = bpy.data.materials.new(ob.type) | ||
me.materials.append(mat) | ||
ids[ob.mesh.id] = me | ||
bob = bpy.data.objects.new(ob.name,me) | ||
bob.matrix_world = mathutils.Matrix([m[0],m[1],m[2],0],[m[3],m[4],m[5],0],[m[6],m[7],m[8],0],[m[9],m[10],m[11],1]) | ||
bpy.context.scene.objects.link(bob) | ||
me.update() | ||
if not IFCimport.next_obj(): break | ||
return {'FINISHED'} | ||
|
||
def menu_func_import(self, context): | ||
self.layout.operator(ImportIFC.bl_idname, text="Industry Foundation Classes (.ifc)") | ||
def register(): | ||
bpy.types.INFO_MT_file_import.append(menu_func_import) | ||
register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
/******************************************************************************** | ||
* * | ||
* This file is part of IfcOpenShell. * | ||
* * | ||
* IfcOpenShell is free software: you can redistribute it and/or modify * | ||
* it under the terms of the Lesser GNU General Public License as published by * | ||
* the Free Software Foundation, either version 3.0 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
* IfcOpenShell is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* Lesser GNU General Public License for more details. * | ||
* * | ||
* You should have received a copy of the Lesser GNU General Public License * | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. * | ||
* * | ||
********************************************************************************/ | ||
|
||
#include "Max.h" | ||
#include "stdmat.h" | ||
#include "decomp.h" | ||
#include "shape.h" | ||
#include "splshape.h" | ||
#include "dummy.h" | ||
#include "istdplug.h" | ||
|
||
#include "../ifcmax/IfcMax.h" | ||
#include "../ifcmax/MaxMaterials.h" | ||
#include "../ifcparse/IfcGeomObjects.h" | ||
|
||
int controlsInit = false; | ||
|
||
BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { | ||
if (!controlsInit) { | ||
controlsInit = true; | ||
InitCommonControls(); | ||
} | ||
return true; | ||
} | ||
|
||
__declspec( dllexport ) const TCHAR* LibDescription() { | ||
return _T("IfcOpenShell IFC Importer"); | ||
} | ||
|
||
__declspec( dllexport ) int LibNumberClasses() { return 1; } | ||
|
||
static class IFCImpClassDesc:public ClassDesc { | ||
public: | ||
int IsPublic() {return 1;} | ||
void * Create(BOOL loading = FALSE) {return new IFCImp;} | ||
const TCHAR * ClassName() {return _T("IFCImp");} | ||
SClass_ID SuperClassID() {return SCENE_IMPORT_CLASS_ID;} | ||
Class_ID ClassID() {return Class_ID(0x3f230dbf, 0x5b3015c2);} | ||
const TCHAR* Category() {return _T("Chrutilities");} | ||
} IFCImpDesc; | ||
|
||
__declspec( dllexport ) ClassDesc* LibClassDesc(int i) { | ||
return i == 0 ? &IFCImpDesc : 0; | ||
} | ||
|
||
__declspec( dllexport ) ULONG LibVersion() { | ||
return VERSION_3DSMAX; | ||
} | ||
|
||
int IFCImp::ExtCount() { return 1; } | ||
|
||
const TCHAR * IFCImp::Ext(int n) { | ||
return n == 0 ? _T("IFC") : _T(""); | ||
} | ||
|
||
const TCHAR * IFCImp::LongDesc() { | ||
return _T("IfcOpenShell IFC Importer for 3ds Max"); | ||
} | ||
|
||
const TCHAR * IFCImp::ShortDesc() { | ||
return _T("Industry Foundation Classes"); | ||
} | ||
|
||
const TCHAR * IFCImp::AuthorName() { | ||
return _T("Thomas Krijnen"); | ||
} | ||
|
||
const TCHAR * IFCImp::CopyrightMessage() { | ||
return _T("Copyight (c) 2011 IfcOpenShell"); | ||
} | ||
|
||
const TCHAR * IFCImp::OtherMessage1() { | ||
return _T(""); | ||
} | ||
|
||
const TCHAR * IFCImp::OtherMessage2() { | ||
return _T(""); | ||
} | ||
|
||
unsigned int IFCImp::Version() { | ||
return 12; | ||
} | ||
|
||
static BOOL CALLBACK AboutBoxDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { | ||
return TRUE; | ||
} | ||
|
||
void IFCImp::ShowAbout(HWND hWnd) {} | ||
|
||
DWORD WINAPI fn(LPVOID arg) { return 0; } | ||
|
||
int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc, BOOL suppressPrompts) { | ||
|
||
itfc->ProgressStart("Importing file...", TRUE, fn, NULL); | ||
|
||
if ( ! IfcGeomObjects::Init((char*)name) ) return false; | ||
|
||
std::map<int, TriObject*> dict; | ||
MtlBaseLib* mats = itfc->GetSceneMtls(); | ||
int slot = mats->Count(); | ||
|
||
do{ | ||
|
||
const IfcGeomObjects::IfcGeomObject* o = IfcGeomObjects::Get(); | ||
|
||
Mtl *m; | ||
const int matIndex = mats->FindMtlByName(MSTR(o->type.c_str())); | ||
if ( matIndex == -1 ) { | ||
StdMat2* stdm = GetMaterial(o->type); | ||
m = stdm; | ||
m->SetName(o->type.c_str()); | ||
mats->Add(m); | ||
itfc->PutMtlToMtlEditor(m,slot++); | ||
} else { | ||
m = static_cast<Mtl*>((*mats)[matIndex]); | ||
} | ||
|
||
std::map<int, TriObject*>::const_iterator it = dict.find(o->mesh->id); | ||
|
||
TriObject* tri; | ||
if ( it == dict.end() ) { | ||
tri = CreateNewTriObject(); | ||
const int numVerts = o->mesh->verts.size()/3; | ||
tri->mesh.setNumVerts(numVerts); | ||
for( int i = 0; i < numVerts; i ++ ) { | ||
tri->mesh.setVert(i,o->mesh->verts[3*i+0],o->mesh->verts[3*i+1],o->mesh->verts[3*i+2]); | ||
} | ||
const int numFaces = o->mesh->faces.size()/3; | ||
tri->mesh.setNumFaces(numFaces); | ||
for( int i = 0; i < numFaces; i ++ ) { | ||
tri->mesh.faces[i].setVerts(o->mesh->faces[3*i+0],o->mesh->faces[3*i+1],o->mesh->faces[3*i+2]); | ||
tri->mesh.faces[i].setEdgeVisFlags(o->mesh->edges[3*i+0],o->mesh->edges[3*i+1],o->mesh->edges[3*i+2]); | ||
} | ||
tri->mesh.InvalidateTopologyCache(); | ||
tri->mesh.InvalidateGeomCache(); | ||
tri->mesh.buildNormals(); | ||
tri->mesh.BuildStripsAndEdges(); | ||
dict[o->mesh->id] = tri; | ||
} else { | ||
tri = (*it).second; | ||
} | ||
|
||
ImpNode* node = impitfc->CreateNode(); | ||
node->Reference(tri); | ||
node->SetName(o->name.c_str()); | ||
node->GetINode()->SetMtl(m); | ||
node->SetTransform(0,Matrix3 ( Point3(o->matrix[0],o->matrix[1],o->matrix[2]),Point3(o->matrix[3],o->matrix[4],o->matrix[5]), | ||
Point3(o->matrix[6],o->matrix[7],o->matrix[8]),Point3(o->matrix[9],o->matrix[10],o->matrix[11]) )); | ||
impitfc->AddNodeToScene(node); | ||
|
||
itfc->ProgressUpdate(IfcGeomObjects::Progress(),true,""); | ||
|
||
} while ( IfcGeomObjects::Next() ); | ||
|
||
itfc->ProgressEnd(); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
LIBRARY ifcmax.dli | ||
EXPORTS | ||
LibDescription @1 | ||
LibNumberClasses @2 | ||
LibClassDesc @3 | ||
LibVersion @4 | ||
SECTIONS | ||
.data READ WRITE |
Oops, something went wrong.