28 throw std::invalid_argument(
"No filename given");
30 std::ifstream input(filename.c_str());
43 input.read(
reinterpret_cast<char*
>(*v),
sizeof(
float) * 3);
44 input.read(
reinterpret_cast<char*
>(*n),
sizeof(
float) * 3);
48 for (
int i = 0; i < 3; ++i)
50 for (
int i = 0; i < 3; ++i)
67 std::string
const& filename,
bool format_binary)
69 if (mesh ==
nullptr || mesh->get_vertices().empty())
70 throw std::invalid_argument(
"Input mesh is empty");
72 throw std::invalid_argument(
"No filename given");
73 if (mesh->get_vertex_normals().size() != mesh->get_vertices().size())
74 throw std::invalid_argument(
"No vertex normals given");
76 std::ofstream out(filename.c_str(), std::ios::binary);
82 for (std::size_t i = 0; i < verts.size(); ++i)
88 out.write(
reinterpret_cast<char const*
>(*v),
sizeof(
float) * 3);
89 out.write(
reinterpret_cast<char const*
>(*n),
sizeof(
float) * 3);
93 out << v[0] <<
" " << v[1] <<
" " << v[2] <<
" "
94 << n[0] <<
" " << n[1] <<
" " << n[2] << std::endl;
Vector class for arbitrary dimensions and types.
std::vector< math::Vec3f > VertexList
std::vector< math::Vec3f > NormalList
std::shared_ptr< TriangleMesh > Ptr
std::shared_ptr< TriangleMesh const > ConstPtr
Exception class for file exceptions with additional filename.
#define MVE_NAMESPACE_BEGIN
#define MVE_NAMESPACE_END
#define MVE_GEOM_NAMESPACE_END
#define MVE_GEOM_NAMESPACE_BEGIN
TriangleMesh::Ptr load_npts_mesh(std::string const &filename, bool format_binary)
Simple importer for Kazhdan's .npts ASCII and binary files.
void save_npts_mesh(TriangleMesh::ConstPtr mesh, std::string const &filename, bool format_binary)
Simple exporter for Kazhdan's .npts ASCII and binary files.