一、输入:
argv[1]是网格文件,
argv[2]是PU-GAN网络模型预测的点
argv[3]是sampling seed,也有可能没有这一项
二、目的
1.计算预测点到网格中距离它最近点的point2surface distance(和真实模型的比对)
2.计算每一个比例p的面积中点的uniformity (该值越小越好)
(1)Uimbalance中表示一个p比例的面积中偏差多少(应该有多少点,实际有多少点)
(2)Uclutter表示每个p比例的面积中点和最近点距离的偏差值(实际距离多少,准确距离应该是多少)
三、代码
里面没有Chamfer Distance(CD) 和Hausdorff distance (HD),两种测量方式的计算
#include <cstdlib>
#include <math.h> /* sqrt */
#include <iostream>
#include <fstream>
#include <iterator>
#include <list>
#include <string>
#include <unistd.h>
#include <chrono>
#include <ctime>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Random.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh_shortest_path.h>
#include <CGAL/Polygon_mesh_processing/compute_normal.h>
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Polygon_mesh_processing/distance.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_tree.h>
// 我们使用了多线程来加速整个过程
// 定义线程数量
#define THREAD 4
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> Triangle_mesh;
typedef CGAL::Surface_mesh_shortest_path_traits<Kernel, Triangle_mesh> Traits;
typedef CGAL::Surface_mesh_shortest_path<Traits> Surface_mesh_shortest_path;
typedef Surface_mesh_shortest_path::Face_location Face_location;
typedef boost::graph_traits<Triangle_mesh> Graph_traits;
typedef Graph_traits::vertex_iterator vertex_iterator;
typedef Graph_traits::face_iterator face_iterator;
typedef Graph_traits::face_descriptor face_descriptor;
typedef CGAL::AABB_face_graph_triangle_primitive<Triangle_mesh> AABB_face_graph_primitive;
typedef CGAL::AABB_traits<Kernel, AABB_face_graph_primitive> AABB_face_graph_traits;
typedef CGAL::AABB_tree<AABB_face_graph_traits> Tree;
typedef Traits::Barycentric_coordinate Barycentric_coordinate;
typedef Traits::FT FT;
typedef Traits::Point_3 Point_3;
typedef Traits::Vector_3 Vector_3;
void calculate_mean_var(std::vector<float> v){
double sum = std::accumulate(std::begin(v), std::end(v), 0.0);
double mean = sum / v.size();
double accum = 0.0;
std::for_each (std::begin(v), std::end(v), [&](const double d) {
accum += (d - mean) * (d - mean);
});
double stdev = sqrt(accum / (v.size()-1));
auto max = std::max_element(std::begin(v), std::end(v));
auto min = std::min_element(std::begin(v), std::end(v));
std::cout<<"Mean: "<<mean<<" std: "<<stdev<<" min: "<<*min<<" max: "<<*max<<std::endl;
}
// 计算each disk的密度
void *calculate_density(void* args){
// 计算距离
Triangle_mesh *tmesh =( Triangle_mesh *)(((void**)args)[0]);
std::vector<Face_location> *pred_face_locations = (std::vector<Face_location> *)(((void**)args)[1]);
std::vector<Face_location> *sample_face_locations = (std::vector<Face_location> *)(((void**)args)[2]);
std::vector<Point_3> *sample_points = (std