Importing CAD-Data

Data quality is a BIG issue with imported data (from IGES or STEP files). Fortunately Open CASCADE provides a nice set of tool to heal and fix shapes. This article goes into the detail of different problems you can run into while working with imported CAD data.

Split C0 edges

In my experience, a lot of problems vanish as soon as you start to split edges at their C0 points (Meaning: You end up with smooth edges). Why? I have witnessed cases in which some CAD software exported a rectangular, nearly planar patch by creating a single edge consisting of a NURBS curve having 4 corner points. In UV space, the surrounding edge was quite reaonable, but in 3d space, the resulting spline curve was extremely unstable and showed numerous oscillations near the corners. This resulted in a very bad edge tolerance resulting in bad behaviour during splitting the shape. All in all, I was much better of by

  1. throwing away the monstrous 3d curve
  2. splitting the 2d curve at the corners
  3. creating 4 new 3d curves

TODO: How to do it

Calculate realistic edge tolerances

CAD software seems to not care very much about providing correct tolerances for the shapes. You can employ ShapeAnalysis_Edge to check the so called SameParam property of an edge. This property (if given) claims that for all points on the 3d curve of an edge, the distance to the similar point on all pcurves of that edge is less than the edge tolerance. Similar in which sense: Given the parameter range [A,B] of the 3d curve and the parameter range [c,d] of one of the pcurves: Then ||P((B-A)*t)-P((c-a)*t)|| < tol_edge for t in [0,1]. Although it is claimed, this property is often not actually true. The edges have a tolerance of 1E-7 but checking on a small number of points you'll get distances between similar points which are larger up to 10 million times. Use ShapeFix_Edge::FixSameParam to evaluate the actual edge tolerance. But be careful. The default call to this routine uses only 23 points to check the distance of similar points. Sometimes though it takes up to 200 points to witness a convergence of the distance value.
In many cases, if you end up with a gigantic edge tolerance, it makes sense to simply throw away a 3d curve and let Open CASCADE recreate it from a pcurve. Use TODO to do this.

Check for SameRange property

One has to differ between SameParam and SameRange property. SameRange property guarantees that the parameter range [A,B] and [b,c] is equal for all pcurves and the 3d curve of an edge. Use BRepLib::CheckSameRange to check it and BRepLib::SameRange to enforce this property for an edge.

Squeeze down the edge and vertex tolerance

Another issue is, that Open CASCADE's ShapeFix routines fail to effectively reduce edge and vertex tolerance. TODO