|
@ -8,6 +8,8 @@ |
|
|
* ------------------------------------ |
|
|
* ------------------------------------ |
|
|
**/ |
|
|
**/ |
|
|
|
|
|
|
|
|
|
|
|
#include <igl/WindingNumberTree.h> |
|
|
|
|
|
#include <igl/WindingNumberAABB.h> |
|
|
#include <iostream> |
|
|
#include <iostream> |
|
|
#include <igl/marching_cubes.h> |
|
|
#include <igl/marching_cubes.h> |
|
|
#include <igl/voxel_grid.h> |
|
|
#include <igl/voxel_grid.h> |
|
@ -15,16 +17,73 @@ |
|
|
#include <igl/readOBJ.h> |
|
|
#include <igl/readOBJ.h> |
|
|
#include <igl/read_triangle_mesh.h> |
|
|
#include <igl/read_triangle_mesh.h> |
|
|
#include <igl/in_element.h> |
|
|
#include <igl/in_element.h> |
|
|
|
|
|
#include <igl/signed_distance.h> |
|
|
#include <boost/log/trivial.hpp> |
|
|
#include <boost/log/trivial.hpp> |
|
|
#include <boost/filesystem.hpp> |
|
|
#include <boost/filesystem.hpp> |
|
|
#include <Eigen/Core> |
|
|
#include <Eigen/Core> |
|
|
|
|
|
#include <pMesh/io/writer/VTKWriter.h> |
|
|
|
|
|
#include <pMesh/mesh/TriangleMesh.h> |
|
|
|
|
|
#include <pMesh/io/adapter/DefaultWriteAdapter.h> |
|
|
#include "test-path.h" |
|
|
#include "test-path.h" |
|
|
|
|
|
|
|
|
int main() { |
|
|
int main() { |
|
|
auto mesh_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "quarter_sphere.obj"; |
|
|
auto mesh_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "hole_quarter_sphere.obj"; |
|
|
|
|
|
auto inside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "inside_output_point.vtk"; |
|
|
|
|
|
auto outside_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "outside_output_point.vtk"; |
|
|
|
|
|
auto mc_out_point_path = boost::filesystem::path(LOCAL_TEST_DATA_BASE_PATH) / "hole_quarter_sphere_mc.obj"; |
|
|
Eigen::MatrixXd V; |
|
|
Eigen::MatrixXd V; |
|
|
Eigen::MatrixXi F; |
|
|
Eigen::MatrixXi F; |
|
|
igl::read_triangle_mesh(mesh_path.string(), V, F); |
|
|
igl::read_triangle_mesh(mesh_path.string(), V, F); |
|
|
|
|
|
|
|
|
|
|
|
// typedef Eigen::Matrix<double, 1, 3> RowVector3S;
|
|
|
|
|
|
// igl::WindingNumberAABB<RowVector3S, Eigen::MatrixXd, Eigen::MatrixXi> hier3;
|
|
|
|
|
|
// hier3.set_mesh(V, F);
|
|
|
|
|
|
// hier3.grow();
|
|
|
|
|
|
// igl::AABB<Eigen::MatrixXd, 3> aabb;
|
|
|
|
|
|
// igl::signed_distance_pseudonormal(aabb,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd GV; |
|
|
|
|
|
Eigen::RowVector3i res; |
|
|
|
|
|
const int s = 10; |
|
|
|
|
|
igl::voxel_grid(V, 0, s, 1, GV, res); |
|
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd S; |
|
|
|
|
|
Eigen::MatrixXi I; |
|
|
|
|
|
Eigen::MatrixXd C; |
|
|
|
|
|
Eigen::MatrixXd N; |
|
|
|
|
|
|
|
|
|
|
|
igl::signed_distance(GV, V, F, igl::SIGNED_DISTANCE_TYPE_PSEUDONORMAL, S, I, C, N); |
|
|
|
|
|
|
|
|
|
|
|
pMesh::SurfaceMesh inside_mesh; |
|
|
|
|
|
pMesh::SurfaceMesh outside_mesh; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < GV.rows(); ++i) { |
|
|
|
|
|
auto p = GV.row(i); |
|
|
|
|
|
if (S(i) < 0) { |
|
|
|
|
|
// std::cout << hier3.winding_number(p) << std::endl;
|
|
|
|
|
|
auto v = pMesh::Surface::Vertex(inside_mesh.v_size(), GV.row(i)); |
|
|
|
|
|
auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(inside_mesh.v_size())}}); |
|
|
|
|
|
inside_mesh.vertices.emplace_back(v); |
|
|
|
|
|
inside_mesh.faces.emplace_back(f); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
auto v = pMesh::Surface::Vertex(outside_mesh.v_size(), GV.row(i)); |
|
|
|
|
|
auto f = pMesh::Surface::Face({.vertices={pMesh::Surface::VertexHandle(outside_mesh.v_size())}}); |
|
|
|
|
|
outside_mesh.vertices.emplace_back(v); |
|
|
|
|
|
outside_mesh.faces.emplace_back(f); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
pMesh::io::VTKWriter(1, inside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(inside_mesh)(); |
|
|
|
|
|
pMesh::io::VTKWriter(1, outside_out_point_path.string()) << pMesh::io::DefaultSurfaceWriteAdapter(outside_mesh)(); |
|
|
|
|
|
|
|
|
|
|
|
Eigen::MatrixXd SV, BV; |
|
|
|
|
|
Eigen::MatrixXi SF, BF; |
|
|
|
|
|
|
|
|
|
|
|
igl::marching_cubes(S, GV, res(0), res(1), res(2), 0, SV, SF); |
|
|
|
|
|
|
|
|
|
|
|
igl::writeOBJ(mc_out_point_path.string(), SV, SF); |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|