Discrepancy in computation times when applying distToShape (BRepExtrema_DistShapeShape) to similar component pairs in FreeCAD

Forums: 

Dear developers,

In an attempt to create a FreeCAD workbench for assembly sequence planning, I am currently comparing a few functions in OpenCascade for detecting whether or not two TopoShapes touch. The distToShape function from FreeCAD's TopoShape API (which uses the BRepExtrema_DistShapeShape class) is an interesting function in this regard, which is often suggested on fora. However, when applying this function on pairs of seemingly similar components, computation times can differ by orders of magnitude. I am turning to this forum to get some insights in what could be causing this behaviour.

Please find via following link (the file sizes exceeded the upload limit) a simple FreeCAD macro, and the CAD models of a multiplate clutch and an air compressor. The following two tables show for each model the pair of components (together with their properties) that are compared in this study:

Air compressor

Component 2_001 9_001
No. vertices 232 290
No. faces 163 195
No. edges 398 482

Multiplate clutch

Component 2_001 13_001
No. vertices 278 292
No. faces 141 146
No. edges 417 438

The attached macro script performs the distToShape function (FreeCAD's TopoShape API) on both pairs of components. Under the hood, this distToShape function creates an instance of the BRepExtrema_DistShapeShape class of OCCT after which its Perform function is executed.

Although these pairs of components seem to be fairly similar in terms of the number of vertices/faces/edges, the computation time for the multiplate clutch pair (6.081 s) exceeds the air compressor pair (0.357 s) by orders of magnitude (17x).

These results make one suspect that there exist some other property---besides the number of vertices, faces and edges---related to the complexity of a shape that is adversely affecting the computation time of the underlying algorithm. Or could there be something "wrong" with the TopoShapes themselves? Some digging around inside the Perform function of the BRepExtrema_DistShapeShape class teaches me that the SolidTreatment function often requires a lot more processing time when being applied on shapes of the multiplate clutch model compared to other assembly models.

Does anyone happen to have made the same observations before and/or have an explanation for them? Unfortunately, I could not find much information about the BRepExtrema_DistShapeShape's Perform and SolidTreatment functions.

Any help or insights would be greatly appreciated.

FreeCAD and system information:
OS: Ubuntu 22.04.2 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.
Build type: Release
Branch: unknown
Hash: 1faf86c3da12c1712e1d5ec015721d9aa02f8672
Python 3.10.4, Qt 5.15.3, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.1
Locale: English/United States (en_US)

Best regards,
Martijn