MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / write_raw

Method write_raw

tools/Wires/WireNetwork/WireWriter.cpp:18–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void WireWriter::write_raw(const std::string& filename,
19 const MatrixFr& vertices, const MatrixIr& edges) {
20 const size_t num_vertices = vertices.rows();
21 const size_t dim = vertices.cols();
22 const size_t num_edges = edges.rows();
23 assert(edges.cols() == 2);
24
25 std::ofstream fout(filename.c_str());
26 if (!fout.is_open()) {
27 std::stringstream err_msg;
28 err_msg << "Unable to open file \"" << filename << "\" for writing";
29 throw IOError(err_msg.str());
30 }
31
32 for (size_t i=0; i<num_vertices; i++) {
33 fout << "v";
34 for (size_t j=0; j<dim; j++) {
35 fout << " " << std::fixed << vertices(i,j);
36 }
37 fout << std::endl;
38 }
39
40 for (size_t i=0; i<num_edges; i++) {
41 fout << "l " << edges(i, 0)+1 << " " << edges(i, 1)+1 << std::endl;
42 }
43
44 fout.close();
45}

Callers

nothing calls this directly

Calls 2

IOErrorClass · 0.85
strMethod · 0.45

Tested by

no test coverage detected