64 using Vertex =
typename Mesh::Vertex;
66 using Face =
typename Mesh::Face;
70 using Faces =
typename Mesh::Faces;
89 if (!
file.is_open()) {
90 std::cerr <<
"Error in MeshIO::read: Could not open the file '" <<
filename
100 if (!std::getline(
file,
line) ||
line !=
"PCL half-edge mesh") {
102 <<
"): Wrong file format.\n";
109 <<
"): Number of vertices / half-edges / faces not found.\n";
117 <<
"): Could not read the number of vertices / half-edges / faces.\n";
123 <<
"): Invalid number of vertices / half-edges / faces.\n";
136 <<
"): Could not read the line.\n";
143 <<
"): Could not read the vertex.\n";
161 <<
"): Could not read the line.\n";
168 <<
"): Could not read the half-edge.\n";
183 <<
"): Could not read the line.\n";
190 <<
"): Could not read the face.\n";
198 if (Mesh::HasVertexData::value)
199 mesh.vertex_data_cloud_.resize(
n_v);
200 if (Mesh::HasHalfEdgeData::value)
201 mesh.half_edge_data_cloud_.resize(
n_he);
202 if (Mesh::HasEdgeData::value)
203 mesh.edge_data_cloud_.resize(
n_he / 2);
204 if (Mesh::HasFaceData::value)
205 mesh.face_data_cloud_.resize(
n_f);
221 if (!
file.is_open()) {
222 std::cerr <<
"Error in MeshIO::write: Could not open the file '" <<
filename
227 file <<
"PCL half-edge mesh\n";
228 file <<
mesh.sizeVertices() <<
" " <<
mesh.sizeHalfEdges() <<
" "
229 <<
mesh.sizeFaces() <<
"\n";
232 for (
typename Vertices::const_iterator
it =
mesh.vertices_.begin();
233 it !=
mesh.vertices_.end();
235 file <<
it->idx_outgoing_half_edge_ <<
"\n";
239 for (
typename HalfEdges::const_iterator
it =
mesh.half_edges_.begin();
240 it !=
mesh.half_edges_.end();
242 file <<
it->idx_terminating_vertex_ <<
" " <<
it->idx_next_half_edge_ <<
" "
243 <<
it->idx_prev_half_edge_ <<
" " <<
it->idx_face_ <<
"\n";
247 for (
typename Faces::const_iterator
it =
mesh.faces_.begin();
250 file <<
it->idx_inner_half_edge_ <<
"\n";
Iterator class for point clouds with or without given indices.
Read / write the half-edge mesh from / to a file.
typename Mesh::VertexIndex VertexIndex
typename Mesh::FaceIndex FaceIndex
typename Mesh::HalfEdges HalfEdges
typename Mesh::HalfEdgeIndex HalfEdgeIndex
bool read(const std::string &filename, Mesh &mesh) const
Read the mesh from a file with the given filename.
typename Mesh::Faces Faces
typename Mesh::Vertex Vertex
typename Mesh::Vertices Vertices
bool write(const std::string &filename, const Mesh &mesh) const
Write the mesh to a file with the given filename.
typename Mesh::HalfEdge HalfEdge