diff --git a/.gitignore b/.gitignore index 104d0185a..0d7b8a09c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build build_32bit +lib3MF.pc +Include/Model/COM/NMR_COMVersion.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ab04d083a..5453440e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,26 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 3.0.2) IF (NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 3.1) cmake_policy(SET CMP0054 OLD) ENDIF () -project (lib3MF) +# Define Project and Version Numbers +# increase major version on every backward-compatibility breaking change of the API +# increase minor version on every backward compatible change of the API +# increase patch version on every change that does not alter the API +project (lib3MF + VERSION 1.8.1 + DESCRIPTION "Lib3MF is a C++ implementation of the 3D Manufacturing Format file standard.") -# Define Version -set(LIB3MF_VERSION_MAJOR 1) # increase on every backward-compatibility breaking change of the API -set(LIB3MF_VERSION_MINOR 8) # increase on every backward compatible change of the API -set(LIB3MF_VERSION_MICRO 0) # increase on on every change that does not alter the API - -set(CMAKE_INSTALL_BINDIR bin CACHE PATH "directory for installing binary files") -set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "directory for installing library files") -set(CMAKE_INSTALL_INCLUDEDIR include/lib3mf CACHE PATH "directory for installing header files") +include(GNUInstallDirs) # By default no COM interface is built # use the cmake option -DNMR_COM_NATIVE:BOOL=ON to build the COM interface option(NMR_COM_NATIVE "Implement a COM interface" OFF) +option(USE_INCLUDED_ZLIB "Use included zlib" ON) +option(USE_INCLUDED_LIBZIP "Use included libzip" ON) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # using GCC add_definitions(-DBUILD_DLL) @@ -76,13 +78,13 @@ if (WIN32) NAME "lib3MF" FILE_DESCRIPTION "Lib3MF is the reference-implementation of the 3D Manufacturing Format file standard" BUNDLE "3MF Consortium" - VERSION_MAJOR ${LIB3MF_VERSION_MAJOR} - VERSION_MINOR ${LIB3MF_VERSION_MINOR} - VERSION_PATCH ${LIB3MF_VERSION_MICRO} + VERSION_MAJOR ${PROJECT_VERSION_MAJOR} + VERSION_MINOR ${PROJECT_VERSION_MINOR} + VERSION_PATCH ${PROJECT_VERSION_PATCH} VERSION_REVISION ${BUILD_NUMBER} - PRODUCT_VERSION_MAJOR ${LIB3MF_VERSION_MAJOR} - PRODUCT_VERSION_MINOR ${LIB3MF_VERSION_MINOR} - PRODUCT_VERSION_PATCH ${LIB3MF_VERSION_MICRO} + PRODUCT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} + PRODUCT_VERSION_MINOR ${PROJECT_VERSION_MINOR} + PRODUCT_VERSION_PATCH ${PROJECT_VERSION_PATCH} COMPANY_NAME "3MF Consortium" ) message("VERSION_FILES_OUTPUTLOCATION ... " ${VERSION_FILES_OUTPUTLOCATION}) @@ -100,8 +102,8 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES PREFIX "" IMPORT_PREFIX "") if (UNIX OR MINGW) target_compile_options(${PROJECT_NAME}_s PUBLIC "-fPIC") # Uncomment the following to but the version info into the .so-file. - SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES VERSION "${LIB3MF_VERSION_MAJOR}.${LIB3MF_VERSION_MINOR}.${LIB3MF_VERSION_MICRO}.${BUILD_NUMBER}") - SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES SOVERSION "${LIB3MF_VERSION_MAJOR}") + SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") + SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES SOVERSION "${PROJECT_VERSION_MAJOR}") if (NOT APPLE) SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES LINK_FLAGS -s) endif() @@ -130,8 +132,8 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "" IMPORT_PREFIX "") target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_s) if (UNIX OR MINGW) # Uncomment the following to but the version info into the .so-file. - SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION "${LIB3MF_VERSION_MAJOR}.${LIB3MF_VERSION_MINOR}.${LIB3MF_VERSION_MICRO}.${BUILD_NUMBER}") - SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION "${LIB3MF_VERSION_MAJOR}") + SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${BUILD_NUMBER}") + SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION "${PROJECT_VERSION_MAJOR}") endif() install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -142,8 +144,14 @@ install(DIRECTORY Include/Common DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") ######################################################### -option(LIB3MF_TESTS "Switch whether the tests of Lib3MF should be build" ON) +configure_file(lib3MF.pc.in lib3MF.pc @ONLY) +install(FILES ${CMAKE_BINARY_DIR}/lib3MF.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +######################################################### +option(LIB3MF_TESTS "Switch whether the tests of Lib3MF should be build" ON) +if(NOT DEFINED LIB3MF_TESTS) + set(LIB3MF_TESTS TRUE) +endif() message("LIB3MF_TESTS ... " ${LIB3MF_TESTS}) if(LIB3MF_TESTS) include(CTest) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..7adc7ef4f --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,58 @@ +# Contributor's Guide +Lib3MF is an open source project. + +Contributions are welcome and we are always looking for people that improve the implementation of the specification and extensions of 3MF. + +You can also contribute by reporting bugs in the [Issue tracker](../../issues), helping review pull requests, participate in discussions about issues and more. + +## Filing issues +1. When filing an issue to report errors or problems, make sure to answer these five questions: + 1. Which version of lib3mf are you using? + + a) The API call `lib3mf_geinterfaceversion` exports lib3mf version number. + + b) Windows only: The properties of lib3mfs binary contain version information (e.g. right click on the DLL -> Properties -> Details). + 2. Which operating system are you using? + 3. What did you do? + 4. What did you expect to see? + 5. What did you see instead? + +2. When contributing to this repository, please first discuss the change you wish to make via issue with the [maintainers](#maintainers) of this repository. This way, we can ensure that there is no overlap between contributions or development work by the 3MF consortium itself. + +## Submitting a pull request +When ready to contribute, fork this repository and submit a pull request that references the issue it resolves. Be sure to include a clear and detailed description of the changes you've made so that we can verify them and eventually merge. + +lib3mf follows the [git-flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) branching model. New developments are integrated into the [develop](../../tree/develop)-branch. lib3mf's maintainers will create releases from the develop-branch when appropriate. + + +## Maintainers +Maintainers are responsible for responding to pull requests and issues, as well as guiding the direction of the project. + +We currently have two maintainers: +- Alexander Oster alexander.oster@autodesk.com +- Martin Weismann martin.weismann@autodesk.com + +If you've established yourself as an impactful contributor to the project, and are willing take on the extra work, we'd love to have your help maintaining it! Email the current maintainers for details. + + + +## Building lib3mf from source +1. Clone the repository\ +`git clone https://github.com/3MFConsortium/lib3mf` +2. Enter local checkout\ +`cd lib3mf` +3. Initialize the [googletest](https://github.com/google/googletest) submodule by running\ +`git submodule update --init` +4. To generate projects for Visual Studio or Unix Makefiles use the scripts in the folder [cmake](cmake):\ +Call `GenerateVS2015.bat` (Windows) or `GenerateMake.sh` (Linux, Mac), or +define other targets by specifying custom [CMake generators](https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html).\ +A new folder `build` is created and contains projects for the IDE/build target you selected. +5. Build the projects: + * Windows: + 1. Open the VS Solution in the build folder and build it + 2. Select the project you want to run as "Start Up Project" + 3. Run/debug this project in VS + * Linux/Mac: + 1. navigate to the `build`-folder + 2. Call `make` to build the projects + 3. Run/debug a project \ No newline at end of file diff --git a/Include/Model/COM/.gitignore b/Include/Model/COM/.gitignore deleted file mode 100644 index cf08148e1..000000000 --- a/Include/Model/COM/.gitignore +++ /dev/null @@ -1 +0,0 @@ -NMR_COMVersion.h diff --git a/Include/Model/COM/NMR_COMVersion.h.in b/Include/Model/COM/NMR_COMVersion.h.in index 208c085ba..148d3d8fa 100644 --- a/Include/Model/COM/NMR_COMVersion.h.in +++ b/Include/Model/COM/NMR_COMVersion.h.in @@ -33,16 +33,16 @@ NMR_COMVersion.h defines the current implementation version. #ifndef __NMR_MODELCOMVERSION #define __NMR_MODELCOMVERSION -// version of the core-sepcification implemented by this library +// version of the core-specification implemented by this library #define NMR_APIVERSION_MAJOR 1 #define NMR_APIVERSION_MINOR 1 // Interface version for the API -#define NMR_APIVERSION_INTERFACE_MAJOR ${LIB3MF_VERSION_MAJOR} +#define NMR_APIVERSION_INTERFACE_MAJOR ${PROJECT_VERSION_MAJOR} -#define NMR_APIVERSION_INTERFACE_MINOR ${LIB3MF_VERSION_MINOR} +#define NMR_APIVERSION_INTERFACE_MINOR ${PROJECT_VERSION_MINOR} -#define NMR_APIVERSION_INTERFACE_MICRO ${LIB3MF_VERSION_MICRO} +#define NMR_APIVERSION_INTERFACE_MICRO ${PROJECT_VERSION_PATCH} // Interface version for extension API diff --git a/Lib3MF-1.docx b/Lib3MF-1.docx index e67044001..2725602f9 100644 Binary files a/Lib3MF-1.docx and b/Lib3MF-1.docx differ diff --git a/Lib3MF-1.pdf b/Lib3MF-1.pdf index 01341b017..c9fe3360e 100644 Binary files a/Lib3MF-1.pdf and b/Lib3MF-1.pdf differ diff --git a/README.md b/README.md index b8262a840..116931f45 100644 --- a/README.md +++ b/README.md @@ -19,44 +19,26 @@ platform specific functionalities, which are now covered by the WinRT platform ( and ZIP compression). This will come when time passes. ## Using lib3MF -The current code runs on Windows, Linux and Mac and has very little external dependencies. +The current code runs on Windows, Linux and Mac and has a small number of external dependencies. -### Dependencies +### 1. Obtain dependencies * Unix: [uuid](https://linux.die.net/man/3/uuid) * Linux (Ubuntu/Debian): `sudo apt-get install uuid-dev` * MAC: `brew install ossp-uuid` -You then have two options: - - +### 2. Download the precompiled binary SDK of lib3mf +You can download the compiled shared libarary as part of a minimal SDK from the [official releases](https://github.com/3MFConsortium/lib3mf/releases), +or use the [nightly builds](https://github.com/3MFConsortium/lib3mf-binaries). -### A) Build lib3mf yourself -1. Clone the repository\ -`git clone https://github.com/3MFConsortium/lib3mf` -2. Enter local checkout\ -`cd lib3mf` -3. Initialize the [googletest](https://github.com/google/googletest) submodule by running\ -`git submodule update --init` -4. To generate projects for Visual Studio or Unix Makefiles use the scripts in the folder [cmake](cmake):\ -Call `GenerateVS2015.bat` (Windows) or `GenerateMake.sh` (Linux, Mac), or -define other targets by specifying custom [CMake generators](https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html).\ -A new folder `build` is created and contains projects for the IDE/build target you selected. -5. Build the projects: - * Windows: - 1. Open the VS Solution in the build folder and build it - 2. Select the project you want to run as "Start Up Project" - 3. Run/debug this project in VS - * Linux/Mac: - 1. navigate to the `build`-folder - 2. Call `make` to build the projects - 3. Run/debug a project +### 3. Examples +You are best of starting with on of the examples that are shipped with the binary SDK. +From there, you should be able to include lib3mf in your host application or service. -### B) Download the precompiled binary SDK of lib3mf -Instead of building lib3MF from source, you can download the compiled shared libarary as part of a minimal SDK from the [official releases](https://github.com/3MFConsortium/lib3mf/releases), -or use the [nightly builds](https://github.com/3MFConsortium/lib3mf-binaries). +## Contributing +lib3mf an open source project and supported by the [3MF Consortium](https://3mf.io/). -## Examples -For example code, please refer to the examples in the SDK (SDK/Examples). They are also part of the binary SDK from the [official releases](https://github.com/3MFConsortium/lib3mf/releases). +Contributions are welcome and we are always looking for people that improve the implementation of the specification and extensions of 3MF. Have a look at the [contributor's guide](CONTRIBUTING.md) for details. +This guide also contains a section about building lib3mf from source. ## Documentation For a more detailed documentation, please take a look into the [PDF](Lib3MF-1.pdf) in the root directory diff --git a/SDK/Examples/Source/ExtractInfo.cpp b/SDK/Examples/Source/ExtractInfo.cpp index ea2ef610e..40cf4b6ca 100644 --- a/SDK/Examples/Source/ExtractInfo.cpp +++ b/SDK/Examples/Source/ExtractInfo.cpp @@ -50,43 +50,37 @@ HRESULT ShowObjectProperties(_In_ PLib3MFModelObjectResource * pObject) { HRESULT hResult; DWORD nNeededChars; - std::vector pBuffer; - std::wstring sName; - std::wstring sPartNumber; + std::vector pBuffer; + std::string sName; + std::string sPartNumber; // Retrieve Mesh Name Length - hResult = lib3mf_object_getname(pObject, NULL, 0, &nNeededChars); + hResult = lib3mf_object_getnameutf8(pObject, NULL, 0, &nNeededChars); if (hResult != LIB3MF_OK) return hResult; // Retrieve Mesh Name if (nNeededChars > 0) { pBuffer.resize(nNeededChars + 1); - hResult = lib3mf_object_getname(pObject, &pBuffer[0], nNeededChars + 1, NULL); + hResult = lib3mf_object_getnameutf8(pObject, &pBuffer[0], nNeededChars + 1, NULL); pBuffer[nNeededChars] = 0; - sName = std::wstring(&pBuffer[0]); + sName = std::string(&pBuffer[0]); } - - // Output Name in local codepage - std::string sAnsiName(sName.begin(), sName.end()); - std::cout << " Name: \"" << sAnsiName << "\"" << std::endl; + std::cout << " Name: \"" << sName << "\"" << std::endl; // Retrieve Mesh Part Number Length - hResult = lib3mf_object_getpartnumber(pObject, NULL, 0, &nNeededChars); + hResult = lib3mf_object_getpartnumberutf8(pObject, NULL, 0, &nNeededChars); if (hResult != LIB3MF_OK) return hResult; // Retrieve Mesh Name if (nNeededChars > 0) { pBuffer.resize(nNeededChars + 1); - hResult = lib3mf_object_getpartnumber(pObject, &pBuffer[0], nNeededChars + 1, NULL); + hResult = lib3mf_object_getpartnumberutf8(pObject, &pBuffer[0], nNeededChars + 1, NULL); pBuffer[nNeededChars] = 0; - sPartNumber = std::wstring(&pBuffer[0]); + sPartNumber = std::string(&pBuffer[0]); } - - // Output Part number in local codepage - std::string sAnsiPartNumber(sPartNumber.begin(), sPartNumber.end()); - std::cout << " Part number: \"" << sAnsiPartNumber << "\"" << std::endl; + std::cout << " Part number: \"" << sPartNumber << "\"" << std::endl; // Output Object type DWORD ObjectType; @@ -702,9 +696,9 @@ int main(int argc, char* argv[]) } // Retrieve Mesh Part Number Length - std::wstring sPartNumber; + std::string sPartNumber; DWORD nNeededChars; - hResult = lib3mf_builditem_getpartnumber(pBuildItem, NULL, 0, &nNeededChars); + hResult = lib3mf_builditem_getpartnumberutf8(pBuildItem, NULL, 0, &nNeededChars); if (hResult != LIB3MF_OK) { lib3mf_release(pBuildItem); lib3mf_release(pBuildItemIterator); @@ -714,16 +708,13 @@ int main(int argc, char* argv[]) // Retrieve Mesh Name if (nNeededChars > 0) { - std::vector pBuffer; + std::vector pBuffer; pBuffer.resize(nNeededChars + 1); - hResult = lib3mf_builditem_getpartnumber(pBuildItem, &pBuffer[0], nNeededChars + 1, NULL); + hResult = lib3mf_builditem_getpartnumberutf8(pBuildItem, &pBuffer[0], nNeededChars + 1, NULL); pBuffer[nNeededChars] = 0; - sPartNumber = std::wstring(&pBuffer[0]); + sPartNumber = std::string(&pBuffer[0]); } - - // Output Part number in local codepage - std::string sAnsiPartNumber(sPartNumber.begin(), sPartNumber.end()); - std::cout << " Part number: \"" << sAnsiPartNumber << "\"" << std::endl; + std::cout << " Part number: \"" << sPartNumber << "\"" << std::endl; // Release Build Item lib3mf_release(pBuildItem); diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index cd23835e7..7b8b08ad7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1,4 +1,11 @@ -file(GLOB LIBZIP_FILES ./Source/Libraries/libzip/*.c) +if (USE_INCLUDED_LIBZIP) + file(GLOB LIBZIP_FILES ./Source/Libraries/libzip/*.c) +endif() + +if (USE_INCLUDED_ZLIB) + file(GLOB ZLIB_FILES ./Source/Libraries/zlib/*.c) +endif() + if(NMR_COM_NATIVE) # sources for native COM implementation set(SRCS_COM @@ -29,6 +36,7 @@ set(SRCS_UNIX_MAIN ./Source/Main/main.cpp ) + set(SRCS_COMMON ${SRCS_COM} ./Source/Common/3MF_ProgressMonitor.cpp @@ -77,17 +85,7 @@ ${SRCS_COM} ./Source/Common/Platform/NMR_XmlReader.cpp ./Source/Common/Platform/NMR_XmlWriter.cpp ./Source/Common/Platform/NMR_XmlWriter_Native.cpp -./Source/Libraries/zlib/adler32.c -./Source/Libraries/zlib/compress.c -./Source/Libraries/zlib/crc32.c -./Source/Libraries/zlib/deflate.c -./Source/Libraries/zlib/infback.c -./Source/Libraries/zlib/inffast.c -./Source/Libraries/zlib/inflate.c -./Source/Libraries/zlib/inftrees.c -./Source/Libraries/zlib/trees.c -./Source/Libraries/zlib/uncompr.c -./Source/Libraries/zlib/zutil.c +${ZLIB_FILES} ./Source/Model/Classes/NMR_PackageResourceID.cpp ./Source/Model/Classes/NMR_Model.cpp ./Source/Model/Classes/NMR_ModelAttachment.cpp diff --git a/lib3MF.pc.in b/lib3MF.pc.in new file mode 100644 index 000000000..9afb6ee88 --- /dev/null +++ b/lib3MF.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -l3MF -lzip -lz +Cflags: -I${includedir}