
Mon, 05/22/2023 - 00:26
I am currently working on a project that involves tesselating shapes using the BRepMesh_IncrementalMesh class in Open CASCADE Technology, and storing the vertix and index buffers for visualiation. However, I have encountered an issue specifically related to closed surfaces, such as spheres, where the tesselation process leaves a visible seam line, as shown in the attached image.
int main()
{
// Create a sphere shape
const Standard_Real r = 1.0;
TopoDS_Shape shape = BRepPrimAPI_MakeSphere(r);
// Perform meshing on the shape
BRepMesh_IncrementalMesh aMesher(shape, 1, TRUE, 0.1,FALSE);
// Vector to store the vertices
std::vector<gp_Pnt> vertices;
// Vector to store the indices
std::vector<int> indices;
// Vector to store the normals
std::vector<gp_Vec> normals;
// Explorer to iterate over sub-shapes (faces) of the shape
TopExp_Explorer ex;
// Iterate over each face of the shape
for (ex.Init(shape, TopAbs_FACE); ex.More(); ex.Next())
{
// Extract the current face
TopoDS_Face face = TopoDS::Face(ex.Current());
// Location of the face
TopLoc_Location location;
// Retrieve the triangulation of the face
const Handle(Poly_Triangulation)& triangulation = BRep_Tool::Triangulation(face, location);
// Check if the face has a triangulation
if (!triangulation.IsNull())
{
// Compute the nodal normals if not already defined
if (!triangulation->HasNormals())
{
// Compute the nodal normals
BRepLib_ToolTriangulatedShape::ComputeNormals(face, triangulation);
}
// Retrieve the number of vertices in the triangulation
const Standard_Integer numVertices = triangulation->NbNodes();
std::cout << numVertices << "\n";
// Iterate over each vertex in the triangulation
for (Standard_Integer i = 1; i <= numVertices; ++i)
{
// Retrieve the coordinates of the current vertex
const gp_Pnt& vertex = triangulation->Node(i);
// Add the vertex to the vector
vertices.push_back(vertex);
//Retrieve the normal of the current vertex
const gp_Vec& normal = triangulation->Normal(i);
// Add the normal to the vector
normals.push_back(normal);
}
// Retrieve the number of triangles in the triangulation
const Standard_Integer numTriangles = triangulation->NbTriangles();
std::cout << numTriangles << "\n";
// Iterate over each triangle in the triangulation
for (Standard_Integer i = 1; i <= numTriangles; ++i)
{
// Retrieve the indices of the current triangle
Standard_Integer index1, index2, index3;
triangulation->Triangle(i).Get(index1, index2, index3);
// Add the indices to the vector
indices.push_back(index1);
indices.push_back(index3);
indices.push_back(index2);
}
}
}
I have observed that the vertices along the seam line are not properly connected, resulting in an undesirable visual artifact. My goal is to achieve a seamless tesselation for closed surfaces, where the vertices connect smoothly without any visible seams.
I wanted to reach out to inquire if there are any techniques, methods, or specific features in OCCT that can help me address this issue. Is there a way to modify the tesselation process or apply a stitching algorithm to ensure that the vertices along the seam line are properly connected?
Thanks for your support
Mon, 05/22/2023 - 17:26
It is unclear which visualization technique you're using to visualize this seam edge, and why it is if any problem to you. In OCCT viewer sphere is visualized smoothly connected at seam edge.