CMakeLists.txt for IfcMax. Tested with VS 2015 and 3ds Max + SDK 2016

This commit is contained in:
Stinkfist0
2016-02-19 22:53:09 +02:00
parent 481515f5ae
commit 5ee9bed590
9 changed files with 107 additions and 62 deletions
+2 -1
View File
@@ -24,7 +24,8 @@ Dependencies
* [SWIG](http://www.swig.org/), [Python](https://www.python.org/) libraries - *optional* * [SWIG](http://www.swig.org/), [Python](https://www.python.org/) libraries - *optional*
For building the IfcOpenShell Python interface and the Blender add-on For building the IfcOpenShell Python interface and the Blender add-on
* 3ds Max SDK - *optional* * 3ds Max SDK - *optional*
For building the 3ds Max plug-in For building the 3ds Max plug-in.
All recent versions of 3ds Max (2014 and newer) are 64-bit only, so a 64-bit installation is assumed.
Compiling on Windows Compiling on Windows
+8
View File
@@ -29,6 +29,7 @@ OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when swi
OPTION(BUILD_IFCPYTHON "Build IfcPython." ON) OPTION(BUILD_IFCPYTHON "Build IfcPython." ON)
OPTION(BUILD_EXAMPLES "Build example applications." ON) OPTION(BUILD_EXAMPLES "Build example applications." ON)
OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF)
OPTION(BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." OFF)
# TODO QtViewer is deprecated ATM as it uses the 0.4 API # TODO QtViewer is deprecated ATM as it uses the 0.4 API
# OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF) # OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF)
@@ -48,6 +49,9 @@ UNIFY_ENVVARS_AND_CACHE(OPENCOLLADA_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(OPENCOLLADA_LIBRARY_DIR) UNIFY_ENVVARS_AND_CACHE(OPENCOLLADA_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(PCRE_LIBRARY_DIR) UNIFY_ENVVARS_AND_CACHE(PCRE_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(PYTHON_EXECUTABLE) UNIFY_ENVVARS_AND_CACHE(PYTHON_EXECUTABLE)
IF(WIN32)
UNIFY_ENVVARS_AND_CACHE(THREEDS_MAX_SDK_HOME)
ENDIF()
# Find Boost # Find Boost
IF(MSVC) IF(MSVC)
@@ -419,6 +423,10 @@ IF(BUILD_EXAMPLES)
ADD_SUBDIRECTORY(../src/examples examples) ADD_SUBDIRECTORY(../src/examples examples)
ENDIF() ENDIF()
IF(BUILD_IFCMAX)
ADD_SUBDIRECTORY(../src/ifcmax ifcmax)
ENDIF()
# CMake installation targets # CMake installation targets
INSTALL(FILES ${IFCPARSE_H_FILES} DESTINATION include/ifcparse) INSTALL(FILES ${IFCPARSE_H_FILES} DESTINATION include/ifcparse)
INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION include/ifcgeom) INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION include/ifcgeom)
+39
View File
@@ -0,0 +1,39 @@
################################################################################
# #
# 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_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} ${ICU_INCLUDE_DIR}
${Boost_INCLUDE_DIRS} ${THREEDS_MAX_SDK_HOME}/include
)
# All recent versions of 3ds Max (2014 and newer) are 64-bit only so assume lib/x64 directory
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${IfcOpenShell_BINARY_DIR} ${OCC_LIBRARY_DIR} ${OPENCOLLADA_LIBRARY_DIR}
${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} ${THREEDS_MAX_SDK_HOME}/lib/x64/Release
)
ADD_LIBRARY(IfcMax SHARED IfcMax.h IfcMax.cpp)
TARGET_LINK_LIBRARIES(IfcMax IfcParse IfcGeom Comctl32.lib zlibdll.lib bmm.lib core.lib CustDlg.lib edmodel.lib expr.lib
flt.lib geom.lib gfx.lib gup.lib imageViewers.lib ManipSys.lib maxnet.lib Maxscrpt.lib
maxutil.lib MenuMan.lib menus.lib mesh.lib MNMath.lib Paramblk2.lib particle.lib Poly.lib RenderUtil.lib
tessint.lib viewfile.lib ${OPENCASCADE_LIBRARIES}
)
SET_TARGET_PROPERTIES(IfcMax PROPERTIES SUFFIX ".dli")
INSTALL(TARGETS IfcMax RUNTIME DESTINATION bin)
+53 -43
View File
@@ -20,49 +20,54 @@
#include <map> #include <map>
#include <set> #include <set>
#include <Max.h>
#include <stdmat.h> #include <stdmat.h>
#include <istdplug.h> #include <istdplug.h>
#include "../ifcmax/IfcMax.h" #include "IfcMax.h"
#include "../ifcgeom/IfcGeomIterator.h" #include "../ifcgeom/IfcGeomIterator.h"
static const int NUM_MATERIAL_SLOTS = 24; static const int NUM_MATERIAL_SLOTS = 24;
int controlsInit = false; BOOL WINAPI DllMain(HINSTANCE /*hinstDLL*/, ULONG /*fdwReason*/, LPVOID /*lpvReserved*/) {
static int controlsInit = false;
BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) {
if (!controlsInit) { if (!controlsInit) {
controlsInit = true; controlsInit = true;
InitCommonControls(); InitCommonControls();
} }
return true; return TRUE;
} }
__declspec( dllexport ) const TCHAR* LibDescription() { static class IFCImpClassDesc :public ClassDesc {
return _T("IfcOpenShell IFC Importer");
}
__declspec( dllexport ) int LibNumberClasses() { return 1; }
static class IFCImpClassDesc:public ClassDesc {
public: public:
int IsPublic() {return 1;} int IsPublic() { return 1; }
void * Create(BOOL loading = FALSE) {return new IFCImp;} void * Create(BOOL /*loading = FALSE*/) { return new IFCImp; }
const TCHAR * ClassName() {return _T("IFCImp");} // TODO Delete() function?
SClass_ID SuperClassID() {return SCENE_IMPORT_CLASS_ID;} const TCHAR * ClassName() { return _T("IFCImp"); }
Class_ID ClassID() {return Class_ID(0x3f230dbf, 0x5b3015c2);} SClass_ID SuperClassID() { return SCENE_IMPORT_CLASS_ID; }
const TCHAR* Category() {return _T("Chrutilities");} Class_ID ClassID() { return Class_ID(0x3f230dbf, 0x5b3015c2); }
const TCHAR* Category() { return _T("Chrutilities"); }
} IFCImpDesc; } IFCImpDesc;
__declspec( dllexport ) ClassDesc* LibClassDesc(int i) { #define DLLEXPORT __declspec(dllexport)
return i == 0 ? &IFCImpDesc : 0;
extern "C" {
DLLEXPORT const TCHAR* LibDescription() {
return _T("IfcOpenShell IFC Importer");
} }
__declspec( dllexport ) ULONG LibVersion() { DLLEXPORT int LibNumberClasses() { return 1; }
return VERSION_3DSMAX;
DLLEXPORT ClassDesc* LibClassDesc(int i) {
return i == 0 ? &IFCImpDesc : 0;
} }
DLLEXPORT ULONG LibVersion() {
return VERSION_3DSMAX;
}
} // extern "C"
int IFCImp::ExtCount() { return 1; } int IFCImp::ExtCount() { return 1; }
const TCHAR * IFCImp::Ext(int n) { const TCHAR * IFCImp::Ext(int n) {
@@ -82,7 +87,7 @@ const TCHAR * IFCImp::AuthorName() {
} }
const TCHAR * IFCImp::CopyrightMessage() { const TCHAR * IFCImp::CopyrightMessage() {
return _T("Copyight (c) 2011 IfcOpenShell"); return _T("Copyright (c) 2011-2016 IfcOpenShell");
} }
const TCHAR * IFCImp::OtherMessage1() { const TCHAR * IFCImp::OtherMessage1() {
@@ -97,13 +102,14 @@ unsigned int IFCImp::Version() {
return 12; return 12;
} }
static BOOL CALLBACK AboutBoxDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // TODO Use this in IFCImp::ShowAbout() if/when wanted
return TRUE; //static BOOL CALLBACK AboutBoxDlgProc(HWND /*hWnd*/, UINT /*msg*/, WPARAM /*wParam*/, LPARAM /*lParam*/) {
} // return TRUE;
//}
void IFCImp::ShowAbout(HWND hWnd) {} void IFCImp::ShowAbout(HWND /*hWnd*/) {}
DWORD WINAPI fn(LPVOID arg) { return 0; } DWORD WINAPI fn(LPVOID /*arg*/) { return 0; }
#if MAX_RELEASE > 14000 #if MAX_RELEASE > 14000
# define S(x) (TSTR::FromCStr(x.c_str())) # define S(x) (TSTR::FromCStr(x.c_str()))
@@ -113,8 +119,9 @@ DWORD WINAPI fn(LPVOID arg) { return 0; }
# define S(x) (CStr(x.c_str())) # define S(x) (CStr(x.c_str()))
#endif #endif
Mtl* FindMaterialByName(MtlBaseLib* library, const std::string& material_name) { static Mtl* FindMaterialByName(MtlBaseLib* library, const std::string& material_name) {
const int mat_index = library->FindMtlByName(S(material_name)); TSTR mat_name = S(material_name);
const int mat_index = library->FindMtlByName(mat_name);
Mtl* m = 0; Mtl* m = 0;
if (mat_index != -1) { if (mat_index != -1) {
m = static_cast<Mtl*>((*library)[mat_index]); m = static_cast<Mtl*>((*library)[mat_index]);
@@ -122,7 +129,7 @@ Mtl* FindMaterialByName(MtlBaseLib* library, const std::string& material_name) {
return m; return m;
} }
Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& slot, const IfcGeom::Material& material) { static Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& slot, const IfcGeom::Material& material) {
Mtl* m = FindMaterialByName(library, material.name()); Mtl* m = FindMaterialByName(library, material.name());
if (m == 0) { if (m == 0) {
StdMat2* stdm = NewDefaultStdMat(); StdMat2* stdm = NewDefaultStdMat();
@@ -136,10 +143,10 @@ Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& sl
stdm->SetSpecular(Color(specular[0], specular[1], specular[2]),t); stdm->SetSpecular(Color(specular[0], specular[1], specular[2]),t);
} }
if (material.hasSpecularity()) { if (material.hasSpecularity()) {
stdm->SetShininess(material.specularity(), t); stdm->SetShininess((float)material.specularity(), t);
} }
if (material.hasTransparency()) { if (material.hasTransparency()) {
stdm->SetOpacity(1.0 - material.transparency(), t); stdm->SetOpacity(1.0f - (float)material.transparency(), t);
} }
m = stdm; m = stdm;
m->SetName(S(material.name())); m->SetName(S(material.name()));
@@ -151,7 +158,10 @@ Mtl* FindOrCreateMaterial(MtlBaseLib* library, Interface* max_interface, int& sl
return m; return m;
} }
Mtl* ComposeMultiMaterial(std::map<std::vector<std::string>, Mtl*>& multi_mats, MtlBaseLib* library, Interface* max_interface, int& slot, const std::vector<IfcGeom::Material>& materials, const std::string& object_type, const std::vector<int>& material_ids) { static Mtl* ComposeMultiMaterial(std::map<std::vector<std::string>, Mtl*>& multi_mats, MtlBaseLib* library,
Interface* max_interface, int& slot, const std::vector<IfcGeom::Material>& materials,
const std::string& object_type, const std::vector<int>& material_ids)
{
std::vector<std::string> material_names; std::vector<std::string> material_names;
bool needs_default = std::find(material_ids.begin(), material_ids.end(), -1) != material_ids.end(); bool needs_default = std::find(material_ids.begin(), material_ids.end(), -1) != material_ids.end();
if (needs_default) { if (needs_default) {
@@ -184,7 +194,7 @@ Mtl* ComposeMultiMaterial(std::map<std::vector<std::string>, Mtl*>& multi_mats,
return i->second; return i->second;
} }
MultiMtl* multi_mat = NewDefaultMultiMtl(); MultiMtl* multi_mat = NewDefaultMultiMtl();
multi_mat->SetNumSubMtls(material_names.size()); multi_mat->SetNumSubMtls((int)material_names.size());
int mtl_id = 0; int mtl_id = 0;
if (needs_default) { if (needs_default) {
multi_mat->SetSubMtlAndName(mtl_id ++, default_material, default_material->GetName()); multi_mat->SetSubMtlAndName(mtl_id ++, default_material, default_material->GetName());
@@ -201,7 +211,7 @@ Mtl* ComposeMultiMaterial(std::map<std::vector<std::string>, Mtl*>& multi_mats,
return multi_mat; return multi_mat;
} }
int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc, BOOL suppressPrompts) { int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc, BOOL /*suppressPrompts*/) {
IfcGeom::IteratorSettings settings; IfcGeom::IteratorSettings settings;
settings.use_world_coords() = false; settings.use_world_coords() = false;
@@ -217,7 +227,7 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
#endif #endif
IfcGeom::Iterator<float> iterator(settings, fn_mb); IfcGeom::Iterator<float> iterator(settings, fn_mb);
delete fn_mb;
if (!iterator.initialize()) return false; if (!iterator.initialize()) return false;
itfc->ProgressStart(_T("Importing file..."), TRUE, fn, NULL); itfc->ProgressStart(_T("Importing file..."), TRUE, fn, NULL);
@@ -237,12 +247,12 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
TriObject* tri = CreateNewTriObject(); TriObject* tri = CreateNewTriObject();
const int numVerts = o->geometry().verts().size()/3; const int numVerts = (int)o->geometry().verts().size()/3;
tri->mesh.setNumVerts(numVerts); tri->mesh.setNumVerts(numVerts);
for( int i = 0; i < numVerts; i ++ ) { for( int i = 0; i < numVerts; i ++ ) {
tri->mesh.setVert(i,o->geometry().verts()[3*i+0],o->geometry().verts()[3*i+1],o->geometry().verts()[3*i+2]); tri->mesh.setVert(i,o->geometry().verts()[3*i+0],o->geometry().verts()[3*i+1],o->geometry().verts()[3*i+2]);
} }
const int numFaces = o->geometry().faces().size()/3; const int numFaces = (int)o->geometry().faces().size()/3;
tri->mesh.setNumFaces(numFaces); tri->mesh.setNumFaces(numFaces);
bool needs_default = std::find(o->geometry().material_ids().begin(), o->geometry().material_ids().end(), -1) != o->geometry().material_ids().end(); bool needs_default = std::find(o->geometry().material_ids().begin(), o->geometry().material_ids().end(), -1) != o->geometry().material_ids().end();
@@ -274,7 +284,7 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
tri->mesh.faces[i].setVerts(v1, v2, v3); tri->mesh.faces[i].setVerts(v1, v2, v3);
tri->mesh.faces[i].setEdgeVisFlags(b1, b2, b3); tri->mesh.faces[i].setEdgeVisFlags(b1, b2, b3);
MtlID mtlid = o->geometry().material_ids()[i]; MtlID mtlid = (MtlID)o->geometry().material_ids()[i];
if (needs_default) { if (needs_default) {
mtlid ++; mtlid ++;
} }
@@ -310,4 +320,4 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc,
itfc->ProgressEnd(); itfc->ProgressEnd();
return true; return true;
} }
-8
View File
@@ -1,8 +0,0 @@
LIBRARY ifcmax.dli
EXPORTS
LibDescription @1
LibNumberClasses @2
LibClassDesc @3
LibVersion @4
SECTIONS
.data READ WRITE
+1 -7
View File
@@ -21,12 +21,6 @@
#define IFCMAX_H #define IFCMAX_H
#include "Max.h" #include "Max.h"
#include "istdplug.h"
#include "stdmat.h"
#include "decomp.h"
#include "shape.h"
#include "splshape.h"
#include "dummy.h"
extern ClassDesc* GetIFCImpDesc(); extern ClassDesc* GetIFCImpDesc();
@@ -38,7 +32,7 @@ public:
const TCHAR * LongDesc(); // = "IfcOpenShell IFC Importer for 3ds Max" const TCHAR * LongDesc(); // = "IfcOpenShell IFC Importer for 3ds Max"
const TCHAR * ShortDesc(); // = "Industry Foundation Classes" const TCHAR * ShortDesc(); // = "Industry Foundation Classes"
const TCHAR * AuthorName(); // = "Thomas Krijnen" const TCHAR * AuthorName(); // = "Thomas Krijnen"
const TCHAR * CopyrightMessage(); // = "Copyight (c) 2011 IfcOpenShell" const TCHAR * CopyrightMessage(); // = "Copyright (c) 2011-2016 IfcOpenShell"
const TCHAR * OtherMessage1(); // = "" const TCHAR * OtherMessage1(); // = ""
const TCHAR * OtherMessage2(); // = "" const TCHAR * OtherMessage2(); // = ""
unsigned int Version(); // = 12 unsigned int Version(); // = 12
-1
View File
@@ -434,4 +434,3 @@ echo - https://www.visualstudio.com/
echo 5. Run this batch script with Visual Studio environment variables set. echo 5. Run this batch script with Visual Studio environment variables set.
echo - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx echo - https://msdn.microsoft.com/en-us/library/ms229859(v=vs.110).aspx
echo. echo.
REM TODO 3ds Max SDK instructions?
+2 -1
View File
@@ -40,7 +40,8 @@ After this, one can build the project using the `IfcOpenShell.sln` file in the b
if wanted. Convenience batch files `build-ifcopenshell.cmd` and `install-ifcopenshell.cmd` can also be used. The batch files if wanted. Convenience batch files `build-ifcopenshell.cmd` and `install-ifcopenshell.cmd` can also be used. The batch files
expect `%1` and `%2` in same fashion as above and possible extra parameters are passed for the `MSBuild` call. The project will expect `%1` and `%2` in same fashion as above and possible extra parameters are passed for the `MSBuild` call. The project will
be installed to `installed-vs<VERSION>-<ARCHITECTURE>\` folder in the project's root folder and the required IfcOpenShell-Python be installed to `installed-vs<VERSION>-<ARCHITECTURE>\` folder in the project's root folder and the required IfcOpenShell-Python
parts are deployed to the `<PYTHONHOME>\Lib\site-packages\` folder. parts are deployed to the `<PYTHONHOME>\Lib\site-packages\` folder. The 3ds Max plug-in, IfcMax.dli, needs to be copied manually
to the 3ds Max's `plugins` folder.
**Note:** All of the dependencies are build as static libraries against the static run-time allowing the developer **Note:** All of the dependencies are build as static libraries against the static run-time allowing the developer
to effortlessly deploy standalone IFCOS binaries. to effortlessly deploy standalone IFCOS binaries.
+2 -1
View File
@@ -59,7 +59,7 @@ set PYTHON_LIBRARY=%PYTHONHOME%\libs\python%PY_VER_MAJOR_MINOR%.lib
set PYTHON_EXECUTABLE=%PYTHONHOME%\python.exe set PYTHON_EXECUTABLE=%PYTHONHOME%\python.exe
set SWIG_DIR=%INSTALL_DIR%\swigwin set SWIG_DIR=%INSTALL_DIR%\swigwin
set PATH=%PATH%;%SWIG_DIR%;%PYTHONHOME% set PATH=%PATH%;%SWIG_DIR%;%PYTHONHOME%
:: TODO 3ds Max SDK? set THREEDS_MAX_SDK_HOME=C:\Program Files\Autodesk\3ds Max 2016 SDK\maxsdk
echo. echo.
call cecho.cmd 0 10 "Script configuration:" call cecho.cmd 0 10 "Script configuration:"
@@ -80,6 +80,7 @@ echo PYTHON_INCLUDE_DIR = %PYTHON_INCLUDE_DIR%
echo PYTHON_LIBRARY = %PYTHON_LIBRARY% echo PYTHON_LIBRARY = %PYTHON_LIBRARY%
echo PYTHON_EXECUTABLE = %PYTHON_EXECUTABLE% echo PYTHON_EXECUTABLE = %PYTHON_EXECUTABLE%
echo SWIG_DIR = %SWIG_DIR% echo SWIG_DIR = %SWIG_DIR%
echo THREEDS_MAX_SDK_HOME = %THREEDS_MAX_SDK_HOME%
echo. echo.
echo CMAKE_INSTALL_PREFIX = %CMAKE_INSTALL_PREFIX% echo CMAKE_INSTALL_PREFIX = %CMAKE_INSTALL_PREFIX%
echo. echo.