Download cpp/io/io.h from USTC3DVer/Lite3DReg: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/spaces/USTC3DVer/Lite3DReg/resolve/main/cpp/io/io.h
- Command line
-
hf download hf://spaces/USTC3DVer/Lite3DReg/cpp/io/io.h
-
curl -L -o io.h https://huggingface.co/spaces/USTC3DVer/Lite3DReg/resolve/main/cpp/io/io.h
2.53 kB
| inline bool read_by_openmesh(const std::string filename, Mesh& mesh) | |
| { | |
| OpenMesh::IO::Options opt_read = OpenMesh::IO::Options::VertexNormal; | |
| mesh.request_vertex_normals(); | |
| bool read_OK = OpenMesh::IO::read_mesh(mesh, filename,opt_read); | |
| std::cout << "filename = " << filename << std::endl; | |
| if (read_OK) | |
| { | |
| mesh.request_vertex_status(); | |
| mesh.request_edge_status(); | |
| mesh.request_face_status(); | |
| mesh.request_face_normals(); | |
| mesh.update_face_normals(); | |
| if(mesh.n_faces()>0) | |
| mesh.update_vertex_normals(); | |
| Vec3 MeshScales; | |
| MeshScales[0] = 0.0; MeshScales[1] = 0.0; MeshScales[2] = 0.0; | |
| for (Mesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end(); ++v_it) | |
| { | |
| MeshScales += mesh.point(*v_it); | |
| } | |
| MeshScales /= mesh.n_vertices(); | |
| return true; | |
| } | |
| std::cout << "#vertices = " << mesh.n_vertices() << std::endl; | |
| return false; | |
| } | |
| //---openmesh for output | |
| inline bool write_by_openmesh(const char* filename, Mesh& mesh, Scalar scale) | |
| { | |
| for (Mesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end(); ++v_it) | |
| { | |
| mesh.point(*v_it) = mesh.point(*v_it)*scale; | |
| } | |
| OpenMesh::IO::Options opt_write = OpenMesh::IO::Options::VertexNormal; | |
| bool ok = OpenMesh::IO::write_mesh(mesh, filename,opt_write); | |
| return ok; | |
| } | |
| // If it exists, read the initial rigid transformation matrix. | |
| template <class MatrixType> | |
| bool read_transMat(MatrixType& trans, const std::string& filename) | |
| { | |
| std::ifstream input(filename); | |
| std::string line; | |
| int rows, cols; | |
| std::vector<std::vector<double>> total_data; | |
| while (getline(input, line)) { | |
| if(line[0] == 'V' || line[0] == 'M') | |
| continue; | |
| std::istringstream iss(line); | |
| std::vector<double> lineVec; | |
| while (iss) { | |
| double item; | |
| if (iss >> item) | |
| lineVec.push_back(item); | |
| } | |
| cols = lineVec.size(); | |
| total_data.push_back(lineVec); | |
| } | |
| if (total_data.size() == 0) | |
| { | |
| std::cout << filename << " is empty !! " << std::endl; | |
| return false; | |
| } | |
| rows = total_data.size(); | |
| trans.resize(rows, cols); | |
| std::cout << "rows = " << rows << " cols = " << cols << std::endl; | |
| for (int i = 0; i < rows; i++) | |
| { | |
| for (int j = 0; j < cols; j++) | |
| { | |
| trans(i, j) = total_data[i][j]; | |
| } | |
| } | |
| input.close(); | |
| std::cout << "read trans = \n" << trans << std::endl; | |
| return true; | |
| } | |