Algorithm Search⌘K

Techniqueadvanced

Tolerant modeling

Also called tolerant geometry, tolerant modelling.

Stores a tolerance with each vertex and edge of a B-rep, so geometry that misses by a small gap still counts as connected, as Jackson described for solid modelers.

Tolerant modeling lets a boundary representation be valid when its geometry does not quite fit together. In an exact B-rep, an edge is a curve that lies on both of its faces, and a vertex is a point that lies on all of its edges. In real models this is false. The edge between two curved faces is the intersection curve of their surfaces, which is computed only approximately. Each face also has its own trim curves in its parameter domain, which map to slightly different space curves. A model read from another system has its own precision. Tolerant modeling gives every edge and vertex its own tolerance: the radius of a tube around the edge curve, or of a ball around the vertex point. The model counts as connected when every face boundary lies in the tube of its edge and every edge end lies in the ball of its vertex. Segal used per-entity tolerances in a polyhedral modeler in 1990, and Jackson described local tolerances for a general B-rep modeler in 1995. The technique is now standard in commercial kernels. Its proved content is simple geometry about tubes and balls. Its value is that a model with small gaps works without moving any geometry.

In plain words

Two tiles are laid next to each other, but their edges do not quite touch: there is a hair-thin gap. An exact program says the tiles are not joined, so the floor has a hole.

A tolerant program draws a thin tube around the shared edge and says: any edge that runs inside this tube is the same edge. The tube is just thick enough to swallow the gap. Each corner gets a small ball in the same way. The floor is now closed, and nothing was moved.

The price is that the tubes and balls must be kept honest. If two tubes are merged, the new tube must hold both. Tubes that grow with every operation can end up swallowing real details of the shape.

When it applies

  • The model is a B-rep with curved faces, whose edges are intersection curves or trim curves that do not exactly lie on the surfaces. This holds for almost every model in a CAD kernel built on floating point.
  • The gaps are small compared with the features of the model, by several orders of magnitude, so that a tolerance can cover the gaps without covering any feature.
  • The model comes from another system, or from operations such as offsets and blends, whose results are approximations. Moving the geometry to close the gaps, as healing does, would change the shape or fail.
  • It does not apply when the gaps are of the same size as real features, such as thin walls and narrow slots, or when exact answers are required. Then use exact geometry, as in exact geometric computation, or heal with a smaller tolerance and repair by hand.

The template

Each edge ee stores a curve CeC_e and a tolerance te≥0t_e \ge 0. Each vertex vv stores a point pvp_v and a tolerance tv≥0t_v \ge 0. A face stores its surface and its boundary loops, where each boundary piece is a curve γF,e\gamma_{F,e} for the edge ee, for example a trim curve mapped into space. The model is tolerantly valid when, for every face FF, edge ee and vertex vv that are incident:

  • (T1) the curve γF,e\gamma_{F,e} lies inside the tube {x:d(x,Ce)≤te}\{x : d(x, C_e) \le t_e\};
  • (T2) the ball B(pv,tv)B(p_v, t_v) contains the end of the tube at vv, which holds when ∣c−pv∣+te≤tv\lvert c - p_v \rvert + t_e \le t_v for the end point cc of CeC_e at vv.

So every point of the model that is said to coincide with another lies within a tolerance of it. The operations keep (T1) and (T2) true.

  1. TOLERANT-SEW(faces, t₀, s) ▷ t₀ default tolerance, s sewing limit
  2. 1give each boundary edge and vertex the tolerance t₀
  3. 2for each pair of vertices u, v with |p_u − p_v| ≤ t_u + t_v + s do
  4. 3replace u, v by the smallest ball that holds B(p_u, t_u) and B(p_v, t_v)
  5. 4for each pair of edges e, f whose ends were merged do
  6. 5h ← the Hausdorff distance between C_e and C_f
  7. 6if h ≤ t_e + t_f + s then
  8. 7C ← a curve between them; t ← max(dist(C, tube_e), dist(C, tube_f))
  9. 8replace e, f by one edge with curve C and tolerance t
  10. 9for each vertex v and each edge e at v do
  11. 10t_v ← max(t_v, |c_e(v) − p_v| + t_e) ▷ restore (T2)
  12. 11return the sewn model

Line L3. The smallest ball containing B(p,s)B(p, s) and B(q,t)B(q, t), with d=∣p−q∣d = \lvert p - q \rvert, is the larger ball if it contains the other (d+t≤sd + t \le s, or d+s≤td + s \le t). Otherwise it has radius R=(d+s+t)/2R = (d + s + t)/2 and centre p+(R−s)(q−p)/dp + (R - s)(q - p)/d. Proof. Let u=(q−p)/du = (q - p)/d. Any ball that contains both balls contains the points p−sup - s u and q+tuq + t u, which are d+s+td + s + t apart, so its radius is at least RR. The given ball has its centre cc on the segment between those two points, at distance RR from each. For x∈B(p,s)x \in B(p, s), ∣x−c∣≤∣x−p∣+∣p−c∣≤s+(R−s)=R\lvert x - c \rvert \le \lvert x - p \rvert + \lvert p - c \rvert \le s + (R - s) = R, and the same holds for B(q,t)B(q, t). This is the two-ball case of the minimum enclosing ball.

Line L7. If the new edge keeps the curve CeC_e, its tolerance must be t=max⁡(te,h+tf)t = \max(t_e, h + t_f). Proof. A point xx within tft_f of CfC_f has a point y∈Cfy \in C_f with ∣x−y∣≤tf\lvert x - y \rvert \le t_f, and yy has a point z∈Cez \in C_e with ∣y−z∣≤h\lvert y - z \rvert \le h, so ∣x−z∣≤h+tf\lvert x - z \rvert \le h + t_f. A curve between the two can do better. Take two parallel segments at distance hh. A cross-section perpendicular to them shows two discs, of radii tet_e and tft_f, with centres hh apart. By the argument of line L3, the best parallel segment has tolerance (h+te+tf)/2(h + t_e + t_f)/2 when neither tube contains the other. When te=tft_e = t_f, that segment is the midline.

Line L10. After the merges, an edge end may lie off its vertex centre, and (T2) asks for the vertex ball to cover the end of the tube. Raising tvt_v restores it. Then (T1) and (T2) hold for every sewn pair: (T1) by line L7, since both old face curves lay in the old tubes, which lie in the new one, and (T2) by line L10.

Classic examples

  • Edges of curved faces. The edge between two NURBS faces is the surface intersection curve, approximated by a spline. The approximation and the two trim curves differ by up to the fitting tolerance. Storing that difference as tet_e makes the edge valid without an exact curve, which usually has no closed form.
  • Imported models. A model from another system arrives with gaps of the size of that system's precision. Instead of healing by moving faces, a tolerant kernel sews it by L2 to L10 and raises the tolerances of the affected edges and vertices. This is the use that Jackson describes.
  • Booleans on near-coincident faces. Two faces that are almost coplanar meet in a curve that is badly conditioned. A tolerant Boolean treats them as coincident within the tolerances of their edges, merges them, and records the larger tolerance. This avoids the inconsistent decisions described under the geometric robustness problem.
  • Offsets and blends. The faces of an offset solid or a rolling-ball blend are approximations of exact offsets. Their edges get tolerances equal to the fitting error.
  • Polyhedral modeling. Segal attached a tolerance to every vertex, edge and face of a polyhedral modeler. When the geometry did not support a decision, he enlarged tolerances so that all the topological decisions agreed. In this way every result was the boundary of a solid.

A worked case. The default tolerance is t0=0.001t_0 = 0.001 mm. A box edge is stored in one face as the segment from (0,0,0)(0, 0, 0) to (1,0,0)(1, 0, 0), and in the next face as the parallel segment from (0,0.003,0.004)(0, 0.003, 0.004) to (1,0.003,0.004)(1, 0.003, 0.004). The gap is 0.0050.005 mm, larger than 2t02 t_0. So without sewing the edges do not coincide. With the sewing limit s=0.01s = 0.01, line L3 merges the vertices (0,0,0)(0, 0, 0) and (0,0.003,0.004)(0, 0.003, 0.004) into the ball of radius (0.005+0.001+0.001)/2=0.0035(0.005 + 0.001 + 0.001)/2 = 0.0035 centred at (0,0.0015,0.002)(0, 0.0015, 0.002), and the same at the other end. If line L7 keeps the first segment, t=0.005+0.001=0.006t = 0.005 + 0.001 = 0.006, and line L10 raises each vertex to 0.0025+0.006=0.00850.0025 + 0.006 = 0.0085. If it takes the midline, t=0.0025+0.001=0.0035t = 0.0025 + 0.001 = 0.0035, and the vertex balls stay at 0.00350.0035. The midline gives tolerances less than half as large.

Variations

  • Global tolerance. One ε\varepsilon for the whole model. This is simple, but too large for small features and too small for the worst gap, and the relation "within ε\varepsilon" is not transitive. Local tolerances avoid a global choice.
  • Edge tolerances only, vertex tolerances only. Some systems store tolerances only on edges, or only on vertices, and derive the others.
  • Tolerant faces. A face may also carry a tolerance, when its surface is an approximation, as in Segal's polyhedral modeler.
  • Healing instead. B-rep healing moves the geometry so that exact incidence holds and tolerances can stay small. Many kernels do both: heal what can be healed, and store tolerances for the rest.
  • Exact or interval geometry. Interval arithmetic gives each computed point an enclosing box, which is a tolerance that comes from the computation itself and not from a choice. Exact geometric computation needs no tolerance at all, but works only on geometry that can be computed exactly.

Pitfalls

  • Tolerance creep. Every merge enlarges a tolerance, and later operations inherit the enlarged value. Merging kk vertices of tolerance tt in a chain with spacing dd gives a ball of radius ((k−1)d+2t)/2((k - 1) d + 2t)/2, so the tolerance grows linearly with the chain. A model whose tolerances have grown to the size of its features is wrong, and every later operation on it is unreliable.
  • Swallowing features. An edge tolerance larger than half the width of a slot makes the slot's walls coincide. Check that no tolerance tube meets a non-adjacent entity.
  • Using the tolerance in some tests and not in others. If a Boolean classifies a point against a face with the face tolerance, but against the edge with zero tolerance, the decisions can disagree, which is the robustness problem again. Every test that involves an entity must use its tolerance.
  • Export to exact systems. A model that is valid only with its tolerances is invalid in a system that ignores them. Heal before exporting to systems that do not read the tolerances.
  • Units. A tolerance of 0.0010.001 is a micron in millimetres and a millimetre in metres. Store tolerances in the model's units and check them against the model's size.

Exercises

  1. Two vertex balls B((0,0,0),1)B((0,0,0), 1) and B((4,0,0),2)B((4,0,0), 2) are merged. Find the smallest enclosing ball. Answer: radius (4+1+2)/2=3.5(4 + 1 + 2)/2 = 3.5, centre (2.5,0,0)(2.5, 0, 0).
  2. Show that tolerant coincidence of vertices, "∣pu−pv∣≤tu+tv\lvert p_u - p_v \rvert \le t_u + t_v", is not transitive, and give three vertices that show it.
  3. Prove the claim of line L7 for parallel segments: among segments parallel to both, the least tolerance that covers both tubes is (h+te+tf)/2(h + t_e + t_f)/2, unless one tube contains the other.
  4. In the worked case, suppose a third face brings a third copy of the edge at (0,−0.003,0.004)(0, -0.003, 0.004) to (1,−0.003,0.004)(1, -0.003, 0.004). Find a curve and a tolerance for the merged edge.

References

  1. David J. Jackson, Boundary representation modelling with local tolerances, Proceedings of the Third ACM Symposium on Solid Modeling and Applications, 247 to 254, 1995, the local tolerances on edges and vertices of a B-rep, which let faces whose boundaries do not meet exactly form a valid solid, and the handling of tolerances in modeling operations
  2. Mark Segal, Using tolerances to guarantee valid polyhedral modeling results, Proceedings of SIGGRAPH 90, Computer Graphics 24(4), 105 to 114, 1990, a tolerance on each vertex, edge and face of a polyhedral modeler, kept and updated so that topological decisions on imprecise data are consistent
  3. Gill Barequet and Subodh Kumar, Repairing CAD models, Proceedings of IEEE Visualization 1997, 363 to 370, the alternative to tolerances, closing cracks between faces by stitching

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW3 standard
  • five exercises