Download cpp/tools/tools.cpp from USTC3DVer/Lite3DReg: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/spaces/USTC3DVer/Lite3DReg/resolve/main/cpp/tools/tools.cpp
- Command line
-
hf download hf://spaces/USTC3DVer/Lite3DReg/cpp/tools/tools.cpp
-
curl -L -o tools.cpp https://huggingface.co/spaces/USTC3DVer/Lite3DReg/resolve/main/cpp/tools/tools.cpp
2.06 kB
| Scalar mesh_scaling(Mesh& src_mesh, Mesh& tar_mesh) | |
| { | |
| Vec3 max(-1e12, -1e12, -1e12); | |
| Vec3 min(1e12, 1e12, 1e12); | |
| for(auto it = src_mesh.vertices_begin(); it != src_mesh.vertices_end(); it++) | |
| { | |
| for(int j = 0; j < 3; j++) | |
| { | |
| if(src_mesh.point(*it)[j] > max[j]) | |
| { | |
| max[j] = src_mesh.point(*it)[j]; | |
| } | |
| if(src_mesh.point(*it)[j] < min[j]) | |
| { | |
| min[j] = src_mesh.point(*it)[j]; | |
| } | |
| } | |
| } | |
| for(auto it = tar_mesh.vertices_begin(); it != tar_mesh.vertices_end(); it++) | |
| { | |
| for(int j = 0; j < 3; j++) | |
| { | |
| if(tar_mesh.point(*it)[j] > max[j]) | |
| { | |
| max[j] = tar_mesh.point(*it)[j]; | |
| } | |
| if(tar_mesh.point(*it)[j] < min[j]) | |
| { | |
| min[j] = tar_mesh.point(*it)[j]; | |
| } | |
| } | |
| } | |
| Scalar scale = (max-min).norm(); | |
| for(auto it = src_mesh.vertices_begin(); it != src_mesh.vertices_end(); it++) | |
| { | |
| Vec3 p = src_mesh.point(*it); | |
| p = p/scale; | |
| src_mesh.set_point(*it, p); | |
| } | |
| for(auto it = tar_mesh.vertices_begin(); it != tar_mesh.vertices_end(); it++) | |
| { | |
| Vec3 p = tar_mesh.point(*it); | |
| p = p/scale; | |
| tar_mesh.set_point(*it, p); | |
| } | |
| return scale; | |
| } | |
| Vector3 Vec2Eigen(Vec3 s) | |
| { | |
| return Vector3(s[0], s[1], s[2]); | |
| } | |
| bool my_mkdir(std::string file_path) | |
| { | |
| if(access(file_path.c_str(), 06)) | |
| { | |
| std::cout << "file_path : (" << file_path << ") didn't exist or no write ability!!" << std::endl; | |
| if(mkdir(file_path.c_str(), S_IRWXU)) | |
| { | |
| std::cout << "mkdir " << file_path << " is wrong! please check upper path " << std::endl; | |
| exit(0); | |
| } | |
| std::cout<< "mkdir " << file_path << " success!! " << std::endl; | |
| } | |
| } | |