diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 8b162a1d5..9ee6e60c5 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -9,6 +9,11 @@ if (MINGW) add_compile_options(-Wa,-mbig-obj) endif () +set(OpenVDBUtils_SOURCES "") +if (TARGET OpenVDB::openvdb) + set(OpenVDBUtils_SOURCES OpenVDBUtils.cpp OpenVDBUtils.hpp) +endif() + add_library(libslic3r STATIC pchheader.cpp pchheader.hpp @@ -174,6 +179,7 @@ add_library(libslic3r STATIC MinAreaBoundingBox.cpp miniz_extension.hpp miniz_extension.cpp + ${OpenVDBUtils_SOURCES} SLA/SLACommon.hpp SLA/SLABoilerPlate.hpp SLA/SLAPad.hpp @@ -222,10 +228,13 @@ target_link_libraries(libslic3r qhull semver TBB::tbb - # OpenVDB::openvdb ${CMAKE_DL_LIBS} ) +if (TARGET OpenVDB::openvdb) + target_link_libraries(libslic3r OpenVDB::openvdb) +endif() + if(WIN32) target_link_libraries(libslic3r Psapi.lib) endif() diff --git a/tests/hollowing/openvdb_utils.cpp b/src/libslic3r/OpenVDBUtils.cpp similarity index 97% rename from tests/hollowing/openvdb_utils.cpp rename to src/libslic3r/OpenVDBUtils.cpp index 62d3a14d7..a5d4f0db6 100644 --- a/tests/hollowing/openvdb_utils.cpp +++ b/src/libslic3r/OpenVDBUtils.cpp @@ -1,6 +1,5 @@ #define NOMINMAX -#include "openvdb_utils.hpp" - +#include "OpenVDBUtils.hpp" #include #include @@ -55,7 +54,7 @@ openvdb::FloatGrid::Ptr meshToVolume(const TriangleMesh & mesh, const openvdb::math::Transform &tr) { return openvdb::tools::meshToVolume( - TriangleMeshDataAdapter{mesh}, tr); + TriangleMeshDataAdapter{mesh}, tr); } openvdb::FloatGrid::Ptr meshToVolume(const sla::Contour3D & mesh, @@ -78,7 +77,7 @@ sla::Contour3D volumeToMesh(const openvdb::FloatGrid &grid, std::vector points; std::vector triangles; std::vector quads; - + openvdb::tools::volumeToMesh(grid, points, triangles, quads, isovalue, adaptivity, relaxDisorientedTriangles); diff --git a/tests/hollowing/openvdb_utils.hpp b/src/libslic3r/OpenVDBUtils.hpp similarity index 90% rename from tests/hollowing/openvdb_utils.hpp rename to src/libslic3r/OpenVDBUtils.hpp index 9854d924d..e42403887 100644 --- a/tests/hollowing/openvdb_utils.hpp +++ b/src/libslic3r/OpenVDBUtils.hpp @@ -1,5 +1,5 @@ -#ifndef OPENVDB_UTILS_HPP -#define OPENVDB_UTILS_HPP +#ifndef OPENVDBUTILS_HPP +#define OPENVDBUTILS_HPP #include #include @@ -20,4 +20,4 @@ sla::Contour3D volumeToMesh(const openvdb::FloatGrid &grid, } // namespace Slic3r -#endif // OPENVDB_UTILS_HPP +#endif // OPENVDBUTILS_HPP diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0d2266dc5..f77b4bd25 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -27,5 +27,4 @@ add_subdirectory(libslic3r) add_subdirectory(timeutils) add_subdirectory(fff_print) add_subdirectory(sla_print) -add_subdirectory(hollowing) -add_subdirectory(example) +# add_subdirectory(example) diff --git a/tests/hollowing/CMakeLists.txt b/tests/hollowing/CMakeLists.txt deleted file mode 100644 index 9679a1b77..000000000 --- a/tests/hollowing/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -if(TARGET OpenVDB::openvdb) - add_executable(hollowing_tests hollowing_test_main.cpp hollowing_tests.cpp openvdb_utils.cpp openvdb_utils.hpp) - - #find_package(GTest REQUIRED) - #target_link_libraries(hollowing_tests libslic3r OpenVDB::openvdb GTest::GTest GTest::Main) - #target_compile_definitions(hollowing_tests PRIVATE TEST_DATA_DIR=R"\(${TEST_DATA_DIR}\)") - - target_link_libraries(hollowing_tests test_common libslic3r OpenVDB::openvdb) -endif() diff --git a/tests/hollowing/hollowing_test_main.cpp b/tests/hollowing/hollowing_test_main.cpp deleted file mode 100644 index b2aa80259..000000000 --- a/tests/hollowing/hollowing_test_main.cpp +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/tests/libslic3r/CMakeLists.txt b/tests/libslic3r/CMakeLists.txt index 98aab498e..b4f5ba01e 100644 --- a/tests/libslic3r/CMakeLists.txt +++ b/tests/libslic3r/CMakeLists.txt @@ -1,4 +1,5 @@ get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME) + add_executable(${_TEST_NAME}_tests ${_TEST_NAME}_tests.cpp test_3mf.cpp @@ -7,6 +8,11 @@ add_executable(${_TEST_NAME}_tests test_polygon.cpp test_stl.cpp ) + +if (TARGET OpenVDB::openvdb) + target_sources(${_TEST_NAME}_tests PRIVATE test_hollowing.cpp) +endif() + target_link_libraries(${_TEST_NAME}_tests test_common libslic3r) set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") diff --git a/tests/hollowing/hollowing_tests.cpp b/tests/libslic3r/test_hollowing.cpp similarity index 96% rename from tests/hollowing/hollowing_tests.cpp rename to tests/libslic3r/test_hollowing.cpp index a7b2874eb..0e211c33c 100644 --- a/tests/hollowing/hollowing_tests.cpp +++ b/tests/libslic3r/test_hollowing.cpp @@ -2,7 +2,7 @@ #include #include -#include "openvdb_utils.hpp" +#include "libslic3r/OpenVDBUtils.hpp" #include "libslic3r/Format/OBJ.hpp" #if defined(WIN32) || defined(_WIN32)