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

Method write_mesh

src/IO/OBJWriter.cpp:79–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79void OBJWriter::write_mesh(Mesh& mesh) {
80 using namespace OBJWriterHelper;
81 std::ofstream fout(m_filename.c_str());
82 if (!is_anonymous()) {
83 fout << "# Generated with PyMesh" << std::endl;
84 }
85 VectorF texture;
86 VectorI texture_indices;
87 if (mesh.has_attribute("corner_texture")) {
88 texture = mesh.get_attribute("corner_texture");
89 const size_t num_faces = mesh.get_num_faces();
90 const size_t vertex_per_face = mesh.get_vertex_per_face();
91 if (texture.size() != num_faces * vertex_per_face * 2) {
92 // Texture invalid.
93 texture.resize(0);
94 } else {
95 write_texture(fout, texture);
96 texture_indices.resize(num_faces * vertex_per_face);
97 for (size_t i=0; i<num_faces; i++) {
98 for (size_t j=0; j<vertex_per_face; j++) {
99 texture_indices[i*vertex_per_face+j] = i*vertex_per_face+j;
100 }
101 }
102 }
103 }
104
105 write_vertices(fout, mesh.get_vertices(), mesh.get_dim());
106 write_faces(fout, mesh.get_faces(), mesh.get_vertex_per_face(),
107 texture_indices);
108 fout.close();
109}
110
111void OBJWriter::write(
112 const VectorF& vertices,

Callers

nothing calls this directly

Calls 11

write_textureFunction · 0.85
write_verticesFunction · 0.85
write_facesFunction · 0.85
has_attributeMethod · 0.45
get_attributeMethod · 0.45
get_num_facesMethod · 0.45
get_vertex_per_faceMethod · 0.45
sizeMethod · 0.45
get_verticesMethod · 0.45
get_dimMethod · 0.45
get_facesMethod · 0.45

Tested by

no test coverage detected