所以我试图用CGAL构建一个非结构化点集的网格:Advancing_front_surface_reconstruction。
然而,当它在某些情况下起作用时,我认为该功能永远不会在其他一些情况下结束,我不知道为什么。
我在for循环中使用它。它适用于X次迭代(X每次都变化),算法很快(小于1s),但随后在一次迭代时卡住。 没有分段错误,没有错误。只是算法运行而且永无止境。 我尝试让它运行一个小时,没有。
有任何线索吗?
编辑:对我所做的更多解释。
我正在尝试实施this paper,尤其是零件轮廓变化计算(论文的第3部分)。
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> CGAL_Mesh;
typedef std::vector<K::Point_3> Polyline_type;
typedef std::vector<Polyline_type > Polylines;
float GC::generateApproximatedProfileCurves(Vector_vector_points profiles_samples){
float epsilon = 0.01f;
int nb_profiles = aligned_profiles.size();
if( nb_profiles < 1){
return 0.0f;
}
std::vector<Point_3> control_profiles;
// Vector to check if a profile has already been added to the approximated shape
std::vector<bool> control_profiles_indices(nb_profiles, false);
// Initialization of the approximated shape with start and end profiles
std::vector<Point_3> cs_points(Utils::getAllPoints(aligned_profiles[0]));
control_profiles.insert(control_profiles.end(), cs_points.begin(), cs_points.end());
control_profiles_indices[0] = true;
std::vector<Point_3> ce_points(Utils::getAllPoints(aligned_profiles[nb_profiles-1]));
control_profiles.insert(control_profiles.end(), ce_points.begin(), ce_points.end());
control_profiles_indices[nb_profiles-1] = true;
bool done = false;
float sumDist = 0.0f;
while( !done ){
// Generation of the approximated shape from the points of the control profiles
CGAL_Mesh approximated_shape = Utils::generateMesh(control_profiles);
float max_dist = 0.0f;
int max_index = -1;
for(int i = 1; i < nb_profiles-1; i++){
if( !control_profiles_indices[i]){
Point_3 profile_centroid = aligned_centroids[i];
// Conversion from Point_3 to Vec3f
Vec3f v_profile_centroid(profile_centroid.x(), profile_centroid.y(), profile_centroid.z());
// Computation of the corresponding profile on the approximated shape
Polylines approx_profile(Utils::cross_section(Vec3f(0,1,0), v_profile_centroid, approximated_shape));
// Gets points of this corresponding profile
std::vector<Point_3> approx_profile_samples(sampleProfileCurve(approx_profile, nb_profile_samples));
// Distance between profile and his corresponding profile
float dist = Utils::Haussdorf(profiles_samples[i], approx_profile_samples);
if( dist > max_dist){
max_dist = dist;
max_index = i;
}
}
}
// If max_dist > epsilon, adds the profile to the control profiles
if((max_dist > epsilon) && (max_index != -1)){
sumDist += max_dist;
control_profiles_indices[max_index] = true;
// Adds points of the profiles to be added to the vector of control_profiles
std::vector<Point_3> control_prfl_points(Utils::getAllPoints(aligned_profiles[max_index]));
control_profiles.insert(control_profiles.end(), control_prfl_points.begin(),
control_prfl_points.end());
approximated_shape.clear();
}else{
done = true;
}
}
return sumDist;
}
存储的avec配置文件是aligned_profiles向量。对齐质心中的质心。以及profiles_samples中每个配置文件的样本(向量&lt; vector&gt;)。
原始点集是 感谢
这是函数Utils :: generateMesh,代码来自CGAL示例
static CGAL_Mesh generateMesh(std::vector<Point_3> points){
CGAL_Mesh m;
Construct construct(m,points.begin(),points.end());
CGAL::advancing_front_surface_reconstruction(points.begin(),
points.end(),
construct);
return m;
}
的表面采样