mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-01 05:01:10 -06:00
Add OpenVDBUtils into libslic3r, hollwing tests in libslic3r_test
This commit is contained in:
parent
9dafc324f0
commit
a8a5a884f9
8 changed files with 24 additions and 21 deletions
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
40
tests/libslic3r/test_hollowing.cpp
Normal file
40
tests/libslic3r/test_hollowing.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "libslic3r/OpenVDBUtils.hpp"
|
||||
#include "libslic3r/Format/OBJ.hpp"
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define PATH_SEPARATOR R"(\)"
|
||||
#else
|
||||
#define PATH_SEPARATOR R"(/)"
|
||||
#endif
|
||||
|
||||
static Slic3r::TriangleMesh load_model(const std::string &obj_filename)
|
||||
{
|
||||
Slic3r::TriangleMesh mesh;
|
||||
auto fpath = TEST_DATA_DIR PATH_SEPARATOR + obj_filename;
|
||||
Slic3r::load_obj(fpath.c_str(), &mesh);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
TEST_CASE("Load object", "[Hollowing]") {
|
||||
Slic3r::TriangleMesh mesh = load_model("20mm_cube.obj");
|
||||
|
||||
Slic3r::sla::Contour3D imesh = Slic3r::sla::convert_mesh(mesh);
|
||||
auto ptr = Slic3r::meshToVolume(imesh, {});
|
||||
|
||||
REQUIRE(ptr);
|
||||
|
||||
Slic3r::sla::Contour3D omesh = Slic3r::volumeToMesh(*ptr, -1., 0.0, true);
|
||||
|
||||
REQUIRE(!omesh.empty());
|
||||
|
||||
std::fstream outfile{"out.obj", std::ios::out};
|
||||
omesh.to_obj(outfile);
|
||||
|
||||
imesh.merge(omesh);
|
||||
std::fstream merged_outfile("merged_out.obj", std::ios::out);
|
||||
imesh.to_obj(merged_outfile);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue