opencascade 三角化 3d 中的点云

问题描述 投票:0回答:0

我有一个步骤文件对象。它包括一个 3D 形状。我想用 opencascade 对形状的表面进行三角测量。首先我在每个表面采样点如下:

STEPControl_Reader reader;
reader.ReadFile(file_path);
if (reader.TransferRoots() != IFSelect_RetDone) {
    std::cerr << "Error: Unable to read file." << std::endl;
    return 1;
}

TopoDS_Shape shape = reader.Shape(1);  // the file includes only 1 shape
for (TopExp_Explorer exp(shape, TopAbs_FACE); exp.More(); exp.Next()) {
    TopoDS_Face face = TopoDS::Face(exp.Current()); 
    TopLoc_Location location;
    Handle(Geom_Surface) surface = BRep_Tool::Surface(face, location);

    vector<gp_Pnt> sampled_points;
    // sample the surface
    for (double u = 0.0; u <= 1.0; u += 0.1) {
        for (double v = 0.0; v <= 1.0; v += 0.1) {
            gp_Pnt point(u, v, 0.0);
            // Get the U and V parameter ranges of the surface.
            Standard_Real UMin, UMax, VMin, VMax;
            surface->Bounds(UMin, UMax, VMin, VMax);
           
            // Create a GeomAPI_ProjectPointOnSurf object.
            GeomAPI_ProjectPointOnSurf myProj;
            myProj.Init(point, surface, UMin, UMax, VMin, VMax, Extrema_ExtAlgo::Extrema_ExtAlgo_Grad);

            // Get the closest point on the surface to the projected point.
            gp_Pnt projectedPoint = myProj.NearestPoint();
                    
            sampled_points.push_back(projectedPoint);
        }
    }

    // NOW CREATE A TRIANGULATION FROM sampled_points
}

这可能是 delaunay 三角剖分或其他东西。如何使用 3d 点创建有效的表面三角剖分?

triangulation delaunay opencascade
© www.soinside.com 2019 - 2024. All rights reserved.