Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3mf export and import #1521

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6cc1dc0
Issue #1032: Download lib3mf sources and add to build tree
lvk88 Jan 14, 2023
8dfb925
Issue #1032: Add empty 3mf io plugin
lvk88 Jan 14, 2023
5fbc094
Issue #1032: Add header and source to io_3mf
lvk88 Jan 14, 2023
806a2d5
Issue #1032: Force use of lib3mf bindings from source folder
lvk88 Jan 14, 2023
4a1eefa
Issue #1032: Add 3mf reader first concept
lvk88 Jan 14, 2023
54f30da
Issue #1032: Use name of 3mf object as label in loaded mesh
lvk88 Jan 15, 2023
eba9630
Issue #1032: Load separate 3mf meshes into separate meshobject
lvk88 Jan 15, 2023
cb97da1
Issue #1032: Use name from mesh only if available
lvk88 Jan 21, 2023
cb28ac9
Issue #1032: Read build items and apply transformation to them
lvk88 Jan 22, 2023
87b1949
Issue #1032: Update single mesh variant of open function
lvk88 Jan 22, 2023
db1d6e0
Issue #1032: Add 3mf exporter
lvk88 Jan 22, 2023
ac360d1
Merge branch 'main' into meshlab-1032-add-3mf-export-and-import
lvk88 Aug 15, 2024
a6bcb3c
#1032 : Read material properties from 3mf file if they are available
lvk88 Aug 15, 2024
562a2c5
Apply clang-format
lvk88 Aug 15, 2024
7c8805f
Add switch that enables transforming vertices on import
lvk88 Aug 15, 2024
022719a
#1832: Fix lib3mf build for ninja under Windows
lvk88 Aug 15, 2024
cd2937b
Update copyright years and comments in 3mf plugin
lvk88 Aug 16, 2024
871b3ca
Handle error when lib3mf throws exception
lvk88 Aug 17, 2024
d5ab0ff
Add more exception handling if reading 3mf fails
lvk88 Aug 17, 2024
3eb2147
Enable 3mf reader to read component objects
lvk88 Aug 19, 2024
3650f7f
Remove unused functions in 3mf reader after refactoring
lvk88 Aug 19, 2024
56951e0
Update lib3mf version to 2.3.2
lvk88 Sep 6, 2024
a032ec4
Update lib3mf md5sum
lvk88 Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ if(NOT DEFINED MESHLAB_PLUGINS) # it may be already defined in parent directory
set(MESHLAB_PLUGINS
# IO plugins
meshlabplugins/io_3ds
meshlabplugins/io_3mf
meshlabplugins/io_base
meshlabplugins/io_bre
meshlabplugins/io_collada
Expand Down
3 changes: 3 additions & 0 deletions src/external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ if ((NOT MESHLAB_BUILD_MINI) AND MESHLAB_ALLOW_OPTIONAL_EXTERNAL_LIBRARIES)
# lib3ds - optional, for io_3ds
include(${CMAKE_CURRENT_SOURCE_DIR}/lib3ds.cmake)

# lib3mf - optional, for io_3mf
include(${CMAKE_CURRENT_SOURCE_DIR}/lib3mf.cmake)

# libigl - optional for filter_mesh_booleans
include(${CMAKE_CURRENT_SOURCE_DIR}/libigl.cmake)

Expand Down
73 changes: 73 additions & 0 deletions src/external/lib3mf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#############################################################################
# MeshLab o o #
# A versatile mesh processing toolbox o o #
# _ O _ #
# Copyright(C) 2023 - 2024 \/)\/ #
# Visual Computing Lab /\/| #
# ISTI - Italian National Research Council | #
# \ #
# All rights reserved. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program 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 #
# GNU General Public License (http://www.gnu.org/licenses/gpl.txt) #
# for more details. #
# #
#############################################################################

option(MESHLAB_ALLOW_DOWNLOAD_SOURCE_LIB3MF "Allow download and use of lib3MF source" ON)

if(MESHLAB_ALLOW_DOWNLOAD_SOURCE_LIB3MF)
set(LIB3MF_DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR}/lib3mf-2.3.2)
set(LIB3MF_CHECK ${LIB3MF_DIR}/CMakeLists.txt)

if(NOT EXISTS ${LIB3MF_CHECK})
set(LIB3MF_LINK https://github.com/3MFConsortium/lib3mf/releases/download/v2.3.2/lib3mf-2.3.2-source-with-submodules.zip)
set(LIB3MF_MD5 e9f3f40de2bd58c3f9109d657c86f3a8)
download_and_unzip(
NAME "Lib3MF"
MD5 ${LIB3MF_MD5}
LINK ${LIB3MF_LINK}
DIR ${MESHLAB_EXTERNAL_DOWNLOAD_DIR})
if(NOT download_and_unzip_SUCCESS)
message(STATUS "- Lib3MF - download failed")
endif()
endif()

if(EXISTS ${LIB3MF_CHECK})
message(STATUS "- Lib3MF - Using downloaded Lib3MF sources")
set(MESSAGE_QUIET ON)
set(LIB3MF_TESTS OFF)
add_subdirectory(${LIB3MF_DIR} EXCLUDE_FROM_ALL)

# Well, this is extremely ugly
# But due to some bug in lib3mf CMake function `generate_product_version`,
# it is not possible to build lib3mf with ninja on Windows, because the following
# error message will appear when processing VersionResource.rc
#
# fatal error RC1106: invalid option: -3
#
# I don't know what causes the bug. A workaround is to just simply exclude VersionResource.rc from the list
# of sources associated to the lib3mf target.
if( WIN32 AND CMAKE_GENERATOR STREQUAL "Ninja" )
get_target_property(LIB3MF_SRCS lib3mf SOURCES)
LIST(FILTER LIB3MF_SRCS EXCLUDE REGEX "VersionResource.rc")
SET_TARGET_PROPERTIES(lib3mf PROPERTIES SOURCES "${LIB3MF_SRCS}")
endif()
unset(MESSAGE_QUIET)
else()
message(FATAL " - Lib3MF - Could not add lib3mf to source tree ")
endif()

add_library(external-lib3mf INTERFACE)
target_link_libraries(external-lib3mf INTERFACE lib3mf)
target_include_directories(external-lib3mf INTERFACE ${LIB3MF_DIR}/Autogenerated/Bindings/Cpp)
install(TARGETS lib3mf DESTINATION ${MESHLAB_LIB_INSTALL_DIR})

endif()
34 changes: 34 additions & 0 deletions src/meshlabplugins/io_3mf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#############################################################################
# MeshLab o o #
# A versatile mesh processing toolbox o o #
# _ O _ #
# Copyright(C) 2023 - 2024 \/)\/ #
# Visual Computing Lab /\/| #
# ISTI - Italian National Research Council | #
# \ #
# All rights reserved. #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program 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 #
# GNU General Public License (http://www.gnu.org/licenses/gpl.txt) #
# for more details. #
# #
#############################################################################

set(HEADERS
io_3mf.h
)

set(SOURCES
io_3mf.cpp
)

add_meshlab_plugin(io_3mf ${SOURCES} ${HEADERS})

target_link_libraries(io_3mf PUBLIC external-lib3mf)
Loading
Loading