From 8a197a630556481ce11c5eb619006ec5308dafba Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Wed, 3 Apr 2019 15:08:14 +0200 Subject: [PATCH] Work on 3ds max plug-in --- cmake/CMakeLists.txt | 17 ++++++++++++----- src/ifcmax/CMakeLists.txt | 19 +++++++++++++------ src/ifcmax/IfcMax.cpp | 8 ++++++-- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b4513c41e4..c580f5b34c 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -23,6 +23,14 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # not necessary, but encouraged project (IfcOpenShell) +foreach(max_year RANGE 2014 2030) +set(max_sdk "$ENV{ADSK_3DSMAX_SDK_${max_year}}") +if (NOT "${max_sdk}" STREQUAL "") +MESSAGE(STATUS "Autodesk 3ds Max SDK found at ${max_sdk}") +set(HAS_MAX TRUE) +endif() +endforeach() + OPTION(UNICODE_SUPPORT "Build IfcOpenShell with Unicode support (requires ICU)." ON) OPTION(COLLADA_SUPPORT "Build IfcConvert with COLLADA support (requires OpenCOLLADA)." ON) OPTION(IFCXML_SUPPORT "Build IfcParse with ifcXML support (requires libxml2)." ON) @@ -35,8 +43,11 @@ OPTION(BUILD_GEOMSERVER "Build IfcGeomServer executable." ON) OPTION(BUILD_CONVERT "Build IfcConvert executable." ON) OPTION(USE_VLD "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF) OPTION(USE_MMAP "Adds a command line options to parse IFC files from memory mapped files using Boost.Iostreams" OFF) -OPTION(BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." OFF) +if (${HAS_MAX}) +OPTION(BUILD_IFCMAX "Build IfcMax, a 3ds Max plug-in, Windows-only." ON) +endif() OPTION(BUILD_SHARED_LIBS "Build IfcParse and IfcGeom as shared libs (SO/DLL)." OFF) + # 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) @@ -100,10 +111,6 @@ UNIFY_ENVVARS_AND_CACHE(LIBXML2_INCLUDE_DIR) UNIFY_ENVVARS_AND_CACHE(LIBXML2_LIBRARIES) UNIFY_ENVVARS_AND_CACHE(PCRE_LIBRARY_DIR) UNIFY_ENVVARS_AND_CACHE(PYTHON_EXECUTABLE) -IF(WIN32) - UNIFY_ENVVARS_AND_CACHE(THREEDS_MAX_SDK_HOME) -ENDIF() - # Set INSTALL_RPATH for target MACRO(SET_INSTALL_RPATHS _target _paths) diff --git a/src/ifcmax/CMakeLists.txt b/src/ifcmax/CMakeLists.txt index c9096f846f..7db41dc2e1 100644 --- a/src/ifcmax/CMakeLists.txt +++ b/src/ifcmax/CMakeLists.txt @@ -16,25 +16,32 @@ # along with this program. If not, see . # # # ################################################################################ +foreach(max_year RANGE 2014 2030) + +set(max_sdk "$ENV{ADSK_3DSMAX_SDK_${max_year}}") +if (NOT "${max_sdk}" STREQUAL "") INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS} ${ICU_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} ${THREEDS_MAX_SDK_HOME}/include + ${Boost_INCLUDE_DIRS} ${max_sdk}/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 + ${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} ${max_sdk}/lib/x64/Release ) -ADD_LIBRARY(IfcMax SHARED IfcMax.h IfcMax.cpp) +ADD_LIBRARY(IfcMax_${max_year} SHARED IfcMax.h IfcMax.cpp) # TODO: find the minimal subset of 3dsmax libraries to reference -TARGET_LINK_LIBRARIES(IfcMax ${IFCOPENSHELL_LIBRARIES} Comctl32.lib zlibdll.lib bmm.lib core.lib CustDlg.lib edmodel.lib expr.lib +TARGET_LINK_LIBRARIES(IfcMax_${max_year} ${IFCOPENSHELL_LIBRARIES} 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") +SET_TARGET_PROPERTIES(IfcMax_${max_year} PROPERTIES SUFFIX ".dli") -INSTALL(TARGETS IfcMax RUNTIME DESTINATION ${BINDIR}) +INSTALL(TARGETS IfcMax_${max_year} RUNTIME DESTINATION ${BINDIR}) + +endif() +endforeach() \ No newline at end of file diff --git a/src/ifcmax/IfcMax.cpp b/src/ifcmax/IfcMax.cpp index 64017f5501..6252e97353 100644 --- a/src/ifcmax/IfcMax.cpp +++ b/src/ifcmax/IfcMax.cpp @@ -24,7 +24,10 @@ #include #include "IfcMax.h" -#include "../ifcgeom/IfcGeomIterator.h" + +#include "../ifcgeom_schema_agnostic/IfcGeomIterator.h" +#include "../ifcgeom_schema_agnostic/IfcGeomMaterial.h" +#include "../ifcgeom/IfcGeomElement.h" static const int NUM_MATERIAL_SLOTS = 24; @@ -226,7 +229,8 @@ int IFCImp::DoImport(const TCHAR *name, ImpInterface *impitfc, Interface *itfc, const char* fn_mb = name; #endif - IfcGeom::Iterator iterator(settings, fn_mb); + IfcParse::IfcFile file(fn_mb); + IfcGeom::Iterator iterator(settings, &file); delete fn_mb; if (!iterator.initialize()) return false;