Wildmeshing Toolkit
get_vf.cpp
Go to the documentation of this file.
1 #include <wmtk/TriMesh.hpp>
3 
4 #include <igl/remove_duplicate_vertices.h>
5 #include <wmtk/utils/Logger.hpp>
6 
8 std::tuple<std::pair<std::vector<double>, uint32_t>, std::pair<std::vector<uint32_t>, uint32_t>>
9 get_vf(const TriMesh& trimesh)
10 {
12 
13  trimesh.serialize(writer);
14 
15  std::vector<double> vV;
16  std::vector<uint32_t> vF;
17 
18  MatrixX<int64_t> F_tmp;
19  MatrixX<double> V_tmp;
20  writer.get_FV_matrix(F_tmp);
21  writer.get_position_matrix(V_tmp);
22 
23  // debug code
26 
27  Eigen::VectorXi IV, _;
28  igl::remove_duplicate_vertices(V_tmp, F_tmp, 0, V, IV, _, F);
29 
30  wmtk::logger().info("removed duplicated vertices {} -> {}", V_tmp.rows(), V.rows());
31 
32  const uint32_t npts = V.rows();
33  const uint32_t ntri = F.rows();
34  vV.resize(V.size());
35  vF.resize(F.size());
36  Eigen::MatrixX<double>::MapType VT(vV.data(), 3, npts);
37  Eigen::MatrixX<uint32_t>::MapType FT(vF.data(), 3, ntri);
38  VT = V.transpose();
39  FT = F.transpose().cast<uint32_t>();
40  return std::make_tuple(std::make_pair(vV, npts), std::make_pair(vF, ntri));
41 }
42 } // namespace wmtk::components::internal
void serialize(MeshWriter &writer, const Mesh *local_root=nullptr) const
Definition: Mesh.cpp:92
void get_position_matrix(MatrixX< double > &matrix)
void get_FV_matrix(MatrixX< int64_t > &matrix)
std::tuple< std::pair< std::vector< double >, uint32_t >, std::pair< std::vector< uint32_t >, uint32_t > > get_vf(const TriMesh &trimesh)
Definition: get_vf.cpp:9
spdlog::logger & logger()
Retrieves the current logger.
Definition: Logger.cpp:58
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Definition: Types.hpp:14