cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Fuse fails to clean a face that is based on a somewhat tangled wire

Open voneiden opened this issue 3 years ago • 4 comments

  1. Similar as in CQ SVG export, the wire is created from projected edges using cq.Wire.combine. The result has 7 edges.
  2. The wire edge order is shown in screenshot, it forms a sort of number "8" loop:

image

  1. The wire is then converted to face using cq.Face.makeFromWires - the face looks OK, but the underlying Wire is still tangled
  2. Further attempts to fuse, combine, clean, etc. fail to clean up the underlying wire.
  3. Exporting face to brep shows the 7 edges still there in the brep file, however, importBrep appears to clean the wire (!)
  4. The wire brep seems to be imported with the original 7 edges intact (seems correct).

Attached are both breps for the face and the wire. breps.tar.gz

voneiden avatar Feb 21 '22 20:02 voneiden

I also tried to fuse these two faces (illustrated in wireframe) image

and the result was a face like this (illustrated in wireframe) image

voneiden avatar Feb 21 '22 20:02 voneiden

Tested the imports like this

import cadquery as cq
import logging

logger = logging.getLogger(__name__)

face = cq.Face.importBrep('projected_face.brep')
wire = face.outerWire()
wire2 = cq.Face.importBrep('projected_wire.brep')
logger.info(face.Area())
show_object(face, 'face') # Face is correct size
show_object(wire, 'wire') # Clean wire with 4 edges
show_object(wire2, 'wire2') # Tangled wire, OK as expected

voneiden avatar Feb 21 '22 20:02 voneiden

I wonder if sortWiresByBuildOrder would help here.

jmwright avatar Feb 28 '22 12:02 jmwright

In this case there's only one wire, sortWiresByBuildOrder expects two or more. Under the hood it uses Face.makeFromWires, which does not resolve the issue (step 3 in the original description).

edgesToWires does not change anything either (uses ShapeAnalysis_FreeBounds.ConnectEdgesToWires).

voneiden avatar Mar 06 '22 12:03 voneiden