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

STEP models tessellating performance

Vlad Ilchishin's picture
Forums: 

Hello everyone,

I am trying to implement a STEP format reader for a 3D viewer and am experiencing some performance issues when tessellating TopoDS_Shapes. I was searching this forum for some hints to improve performance but can't find any. I was following a straight-froward approach to tessellation (code example is attached bellow) but it seems to me that some pre-processing have to be done to shapes to reach better performance. I was comparing STEP loading performance of my application with CAD Assistant (powered by OCCT v7.1.1.dev) an I have, in average, 50% slower results that CAD Assistant. Have to mention that I'm using OCCT v7.2.0.

Here is my tessellation code:

bool
OCCProxy::tessellateShapes(std::list<TopoDS_Shape> & shapes) {

	for (auto & shape : shapes) {

		BRepMesh_IncrementalMesh incMesh(shape, 1, false, 1);

        // This method collects all TopoDS_Face instances of current shape with help of
        // TopExp_Explorer
		std::list<TopoDS_Face> faces = collectFaces(shape);

		for (auto& face : faces) {
			// Collects tessellated data and populates mesh parameter.
			processFace(face);
		}

		faces.clear();

		_meshes.push_back(mesh);
	}

	return true;
}

bool
OCCProxy::processFace(TopoDS_Face& face) {

	// Use default location for the face.
	TopLoc_Location location = TopLoc_Location(gp_Trsf::gp_Trsf());
	// Get triangulation instance that contains all triangulation-related information.
	const opencascade::handle<Poly_Triangulation> triangulation = BRep_Tool::Triangulation(face, location);


	Poly_Array1OfTriangle occtpTriangles = triangulation.get()->Triangles();

	const TColgp_Array1OfPnt nodes = triangulation.get()->Nodes();

    //**************************
    Process collected nodes and triangles to get mesh information
    //**************************

	return true;
}

Thank you for help in advance,

Vlad

Kirill's picture

I don't know how you filling in std::list<TopoDS_Shape>, but tessellating a shape by shape in loop instead of single shape can be less efficient (if multi-threading is enabled) and produces different result (if relative deflection parameters are passed).
In general, consider playing with BRepMesh_IncrementalMesh parameters - they may affect performance considerably.
Note that tessellation quality can be changed in CAD Assistant and actual parameters are printed in log in verbose mode.

Vlad Ilchishin's picture

Thank you for the reply, Kirill

Well I don't use multithreaded mode, thus looping should be alright, right? I've just thought that using single thread may be the reason of this slowing down.

After all, can the general approach be considered to be correct? 

Thank you very much,

Vlad

Kirill's picture

> After all, can the general approach be considered to be correct? 

If absolute deflection is specified (not relative) then yes, code should work more or less as expected in case if list of shapes has no overlapping (do not share shapes/sub-shapes across).

> I've just thought that using single thread may be the reason of this slowing down.
That is - CAD Assistant uses multi-threading for tessellating shapes (you can see it by CPU utilization in Task Manager).