BRepMesh_IncrementalMesh do not work

		file = osgDB::convertStringFromCurrentCodePageToUTF8(file);
		//TCollection_AsciiString aName((Standard_CString);
		BRepBuilderAPI_Sewing shapeSewer;

		Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile(TCollection_AsciiString{ file.c_str() });
		Standard_Integer numberOfTriangles = aSTLMesh->NbTriangles();

		TopoDS_Vertex Vertex1, Vertex2, Vertex3;
		TopoDS_Shape shape;
		TopoDS_Face face;
		TopoDS_Wire wire;

		//TopoDS_Shell sh;
		//BRep_Builder builder;

		for (Standard_Integer i = 1; i <= numberOfTriangles; i++)
			Poly_Triangle triangle = aSTLMesh->Triangle(i);

			Standard_Integer n1;
			Standard_Integer n2;
			Standard_Integer n3;

			triangle.Get(n1, n2, n3);

			gp_Pnt p1 = aSTLMesh->Node(n1);
			gp_Pnt p2 = aSTLMesh->Node(n2);
			gp_Pnt p3 = aSTLMesh->Node(n3);

			if (!p1.IsEqual(p2, 0.0) && !p1.IsEqual(p3, 0.0))
				Vertex1 = BRepBuilderAPI_MakeVertex(p1);
				Vertex2 = BRepBuilderAPI_MakeVertex(p2);
				Vertex3 = BRepBuilderAPI_MakeVertex(p3);

				wire = BRepBuilderAPI_MakePolygon(Vertex1, Vertex2, Vertex3, Standard_True);
				if (!wire.IsNull())
					face = BRepBuilderAPI_MakeFace(wire);
					if (!face.IsNull()) {

						//builder.Add(sh, face);
						//builder.Add(shape, sh);

		shape = shapeSewer.SewedShape();

		BRepBuilderAPI_MakeSolid solidmaker;
		TopTools_IndexedMapOfShape shellMap;
		TopExp::MapShapes(shape, TopAbs_SHELL, shellMap);

		unsigned int counter = 0;
		for (int ishell = 1; ishell <= shellMap.Extent(); ++ishell) {
			const TopoDS_Shell& shell = TopoDS::Shell(shellMap(ishell));

		TopoDS_Shape solid = solidmaker.Solid();

I create a TopoDS_Shape through reading a stl file, then I want to use BRepMesh_IncrementalMesh to this TopoDS_Shape , I set different linear deflection and angular deflection , but It do not work.  What should I do?

Kirill Gavrilov's picture

Your code creates a TopoDS_Face for each triangle in STL file.
Such geometry cannot be re-triangulated as you can triangulate each triangle only in one way.

To move ahead, a geometry from STL file should be approximated via B-Spline surface(s), which is feasible, but rather non-trivial surface reconstruction process.

hua shi's picture

Is there some demo for this? Thanks.