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

Method write_face_file

src/IO/NodeWriter.cpp:81–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void NodeWriter::write_face_file(const std::string& filename, Mesh& mesh) {
82 const size_t num_faces = mesh.get_num_faces();
83 const size_t vertex_per_face = mesh.get_vertex_per_face();
84 if (num_faces == 0) return;
85 if (vertex_per_face != 3) {
86 throw IOError("Only triangle is supported in .face file.");
87 }
88
89 std::ofstream fout(filename.c_str());
90 fout.precision(16);
91 if (!is_anonymous()) {
92 fout << "# Generated with PyMesh" << std::endl;
93 }
94 VectorF bd_marker;
95 if (m_with_face_bd_marker) {
96 if (!mesh.has_attribute("face_boundary_marker")) {
97 throw IOError("Attribute \"face_boundary_marker\" does not exist.");
98 } else {
99 bd_marker = mesh.get_attribute("face_boundary_marker");
100 assert(num_faces == bd_marker.size());
101 }
102 }
103
104 const VectorI& faces = mesh.get_faces();
105 fout << num_faces << " " << m_with_face_bd_marker << std::endl;
106 for (size_t i=0; i<num_faces; i++) {
107 fout << i;
108 for (size_t j=0; j<vertex_per_face; j++) {
109 fout << " " << faces[i*vertex_per_face+ j];
110 }
111 if (m_with_face_bd_marker) {
112 fout << " " << bd_marker[i];
113 }
114 fout << std::endl;
115 }
116}
117
118void NodeWriter::write_elem_file(const std::string& filename, Mesh& mesh) {
119 const size_t num_voxels = mesh.get_num_voxels();

Callers

nothing calls this directly

Calls 7

IOErrorClass · 0.85
get_num_facesMethod · 0.45
get_vertex_per_faceMethod · 0.45
has_attributeMethod · 0.45
get_attributeMethod · 0.45
sizeMethod · 0.45
get_facesMethod · 0.45

Tested by

no test coverage detected