For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Problems Exporting Pre-tessellated Geometry to STEP

Michael Kaiser's picture


I'm working with a large project that is using Occ 6.9.0. I need to write out triangular meshes as STEP files. The meshes are just collections of vertices and vertex indices as would be used in an OpenGL render buffer.

I've tried the following, incomplete, code which gets a wireframe STEP file but is quite slow on export.

for( int p=0; p<srcMesh.m_indx.Length(); p+=3 )
	int v0 = srcMesh.m_indx[p+0];
	int v1 = srcMesh.m_indx[p+1];
	int v2 = srcMesh.m_indx[p+2];

	BRepBuilderAPI_MakePolygon poly;
	poly.Add( gp_Pnt(srcMesh.m_vert[v0].x, srcMesh.m_vert[v0].y, srcMesh.m_vert[v0].z) );
	poly.Add( gp_Pnt(srcMesh.m_vert[v1].x, srcMesh.m_vert[v1].y, srcMesh.m_vert[v1].z) );
	poly.Add( gp_Pnt(srcMesh.m_vert[v2].x, srcMesh.m_vert[v2].y, srcMesh.m_vert[v2].z) );

	TopoDS_Shape shape = poly.Shape();

	status = aWriter.Transfer( shape, STEPControl_AsIs );

So I tried the following which I had hoped would be faster.

STEPControl_Writer aWriter;
BRep_Builder builder;


TColgp_Array1OfPnt points(1, (Standard_Integer)srcMesh.m_vert.Length());
for( int v=0; v<srcMesh.m_vert.Length(); ++v )
	points(v+1) = gp_Pnt(srcMesh.m_vert[v].x, srcMesh.m_vert[v].y, srcMesh.m_vert[v].z);

Poly_Array1OfTriangle tris(1, (Standard_Integer)srcMesh.m_indx.Length()/ 3);
for( int p=0, q=1; p<srcMesh.m_indx.Length(); p+=3, ++q )
	int v0 = srcMesh.m_indx[p+0];
	int v1 = srcMesh.m_indx[p+1];
	int v2 = srcMesh.m_indx[p+2];
	tris.ChangeValue(q) = Poly_Triangle( v0+1, v1+1, v2+1 );

Poly_Triangulation * triangulation = new Poly_Triangulation( points, tris );
TopoDS_Face face;
builder.MakeFace(face, triangulation);

status = aWriter.Transfer( face, STEPControl_FacetedBrep );
if( status != IFSelect_RetDone )
	printf("Failed %s\n", ToString(status));

The problem with the 2nd block of code is that STEPControl_Writer::Transfer() always returns IFSelect_RetFail because deep inside XSControl_Controller.cxx the function TransferFinder() fails to find a Transfer_Binder from a map it creates earlier in the process.

So is there a fast and correct way of transferring triangle data into the OpenCascade environment so it can be exported to STEP?

Is there a problem with the 2nd block of code that can easily be fixed or should I go with creating the triangles one at a time?

Thanks in advance.

Roman Lygin's picture

Hi Michael,

The STEP format provides various so called shape_representations. In order to transfer triangulation data the facetted_brep would be the most appropriate (comparing for instance, to advanced_brep_shape_representation tailored for precise geometry). To the best of my knowledge you cannot directly feed triangulation data via OCC API to receive facetted_brep in STEP, as OCC STEP API is primarily tailored to accept precise geometry (via TopoDS_Shape).

We implemented writing facetted_brep in our product ourselves. If interested to learn more feel free to drop me an email at roman dot lygin at gmail dot com.



Michael Kaiser's picture

Thank you Roman,

I was wondering if I should do the same as you have. I have a workaround for now involving other file formats but reducing our reliance on OCC/OCAF and other 3rdparty libraries is something I will need to look at as a side project.

Thanks again,


Forum supervisor's picture

Hello Michael,

We sent to you a personal message - please, check your mailbox.

Best regards,

Forum supervisor