| 79 | } |
| 80 | |
| 81 | void 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 | |
| 118 | void NodeWriter::write_elem_file(const std::string& filename, Mesh& mesh) { |
| 119 | const size_t num_voxels = mesh.get_num_voxels(); |
nothing calls this directly
no test coverage detected