18#include <lagrange/fs/filesystem.h>
32template <
typename DerivedV,
typename DerivedE>
34 const fs::path &filename,
35 const Eigen::MatrixBase<DerivedV> &V,
36 const Eigen::MatrixBase<DerivedE> &E)
38 using namespace Eigen;
39 fs::ofstream out(filename);
41 throw std::runtime_error(
"failed to open file " + filename.string());
43 Eigen::MatrixXd VV = V.template cast<double>();
44 VV.conservativeResize(V.rows(), 3);
47 << VV.rows() <<
" " << E.rows() <<
" 0\n"
48 << VV.format(IOFormat(FullPrecision, DontAlignCols,
" ",
"\n",
"",
"",
"",
"\n"))
49 << (E.array()).format(
50 IOFormat(FullPrecision, DontAlignCols,
" ",
"\n",
"2 ",
"",
"",
"\n"));
63template <
typename DerivedV,
typename DerivedE>
65 const fs::path &filename,
66 const Eigen::MatrixBase<DerivedV> &V,
67 const Eigen::MatrixBase<DerivedE> &E)
69 if (filename.extension() ==
".off") {
72 throw std::runtime_error(
"Unsupported file extension");
Main namespace for Lagrange.
Definition: AABBIGL.h:30
void save_graph(const fs::path &filename, const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedE > &E)
Saves a 2D undirected graph (V,E) based on filename extension.
Definition: save_graph.h:64
void save_graph_off(const fs::path &filename, const Eigen::MatrixBase< DerivedV > &V, const Eigen::MatrixBase< DerivedE > &E)
Saves a 2D undirected graph (V,E) using off format.
Definition: save_graph.h:33