jianbaoxia
CAD master
Hello everyone, I'm JianBaoXia.
Today I attempted to triangulate a B-spline surface, but the results were not satisfactory. The outcome is shown in the image below:
It is evident that triangulation seems to fail in regions with high curvature. I am unsure if this is a limitation of the OCCT algorithms or if I have not used the related tools correctly.
There is my demo:
Today I attempted to triangulate a B-spline surface, but the results were not satisfactory. The outcome is shown in the image below:
It is evident that triangulation seems to fail in regions with high curvature. I am unsure if this is a limitation of the OCCT algorithms or if I have not used the related tools correctly.
There is my demo:
Code:
Handle(Poly_Triangulation) BuildTriangulation(const TopoDS_Face& face, const Standard_Real& linDeflection)
{
// ! 1、
Handle(Poly_CoherentTriangulation) tris = new Poly_CoherentTriangulation;
BRepMesh_IncrementalMesh meshGen(face, linDeflection);
TopLoc_Location L; //!
const Handle(Poly_Triangulation)& poly = BRep_Tool::Triangulation(face, L);
//! 2、add note
std::unordered_map<int, int> nodesMap;
for (int iNode = 1; iNode <= poly->NbNodes(); ++iNode)
{
const int n = tris->SetNode(poly->Node(iNode).Transformed(L).XYZ());
nodesMap.insert({ iNode, n });
}
// 3、add triangle
for (int iTri = 1; iTri <= poly->NbTriangles(); ++iTri)
{
const Poly_Triangle& tri = poly->Triangle(iTri);
int iNodes[3];
tri.Get(iNodes[0], iNodes[1], iNodes[2]);
if (face.Orientation() == TopAbs_REVERSED)
std::swap(iNodes[1], iNodes[2]);
tris->AddTriangle(nodesMap[iNodes[0]], nodesMap[iNodes[1]], nodesMap[iNodes[2]]);
}
return tris->GetTriangulation();
}