to_cork_mesh.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef IGL_NO_CORK
  2. #include "to_cork_mesh.h"
  3. template <
  4. typename DerivedV,
  5. typename DerivedF>
  6. IGL_INLINE void igl::to_cork_mesh(
  7. const Eigen::PlainObjectBase<DerivedV > & V,
  8. const Eigen::PlainObjectBase<DerivedF > & F,
  9. CorkTriMesh & mesh)
  10. {
  11. using namespace std;
  12. assert((F.cols() == 0 || F.cols() == 3) && "Facets should be triangles.");
  13. assert((V.cols() == 0 || V.cols() == 3) && "Vertices should be in 3D.");
  14. mesh.n_triangles = F.rows();
  15. mesh.n_vertices = V.rows();
  16. mesh.vertices = new double[mesh.n_vertices*3];
  17. mesh.triangles = new uint[mesh.n_triangles*3];
  18. for(size_t v = 0;v<mesh.n_vertices;v++)
  19. {
  20. for(size_t c = 0;c<3;c++)
  21. {
  22. mesh.vertices[v*3+c] = V(v,c);
  23. }
  24. }
  25. for(size_t f = 0;f<mesh.n_triangles;f++)
  26. {
  27. for(size_t c = 0;c<3;c++)
  28. {
  29. mesh.triangles[f*3+c] = F(f,c);
  30. }
  31. }
  32. }
  33. #ifdef IGL_STATIC_LIBRARY
  34. // Explicit template specialization
  35. template void igl::to_cork_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, CorkTriMesh&);
  36. template void igl::to_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, CorkTriMesh&);
  37. #endif
  38. #endif