CadQuery / CadQuery/cadquery

mirrorY/mirrorX deliver unexpected edges back

Open
#125 16 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

I am trying to visualize interims steps when working with cadquery. Doing so, I ran into some issues with `mirrorY`et. al. (btw. it does not seem to be a problem when using `extrude()`, only when you try to visualize the wires):

### 1) Method close() works fine

```python
import cadquery as cq
from jupyter_cadquery.cadquery import Assembly, Part, Edges, Faces, Wires, show

yz = cq.Workplane("YZ")
xy = cq.Workplane("YX")

diam = 5.2
base_thickness = 2
base_width = 38
base_length = 64
gap = 6

holder_thickness = 1
holder_length = 22

holder_width = diam + 2 * holder_thickness
holder_height = diam + holder_thickness

side_margin = base_width/2 - holder_width
bottom_margin = 15

base = (xy
.vLineTo(-base_length/2 + gap/2, forConstruction=True)
.hLineTo(-gap/2)
.vLineTo(-base_length/2)
.hLineTo(-base_width/2)
.vLineTo(-base_length/2 + 10)
.hLineTo(-base_width/2 + gap/2)
.vLineTo(holder_length / 2 - 2)
.hLineTo(-base_width/2)
.vLineTo(holder_length / 2)
.threePointArc((-base_width*3/8, base_length*3/8), (-gap/2, base_length/2))
.vLineTo((base_length-gap)/2)
.hLineTo(0)
)
Wires(base.close())
```
![image](https://user-images.githubusercontent.com/954408/57197288-d6584580-6f65-11e9-8132-6a25814d5738.png)

### 2) Method mirrorY() returns unexpected edges

```
base = (xy
.vLineTo(-base_length/2 + gap/2, forConstruction=True)
.hLineTo(-gap/2)
.vLineTo(-base_length/2)
.hLineTo(-base_width/2)
.vLineTo(-base_length/2 + 10)
.hLineTo(-base_width/2 + gap/2)
.vLineTo(holder_length / 2 - 2)
.hLineTo(-base_width/2)
.vLineTo(holder_length / 2)
.threePointArc((-base_width*3/8, base_length*3/8), (-gap/2, base_length/2))
.vLineTo((base_length-gap)/2)
.hLineTo(0)

)

Wires(base.mirrorY())
```

![image](https://user-images.githubusercontent.com/954408/57197312-13bcd300-6f66-11e9-9372-679e80704df5.png)

### 3) Own mirrorY without wire consolidation returns what I would expect

```python
def my_mirrorY(workplane):
n = workplane.wire(forConstruction=False)
mirroredWires = workplane.plane.mirrorInPlane(n.wires().vals(), 'Y')
for w in mirroredWires:
n.objects.append(w)
n._addPendingWire(w)
return n

base = (xy
.vLineTo(-base_length/2 + gap/2, forConstruction=True)
.hLineTo(-gap/2)
.vLineTo(-base_length/2)
.hLineTo(-base_width/2)
.vLineTo(-base_length/2 + 10)
.hLineTo(-base_width/2 + gap/2)
.vLineTo(holder_length / 2 - 2)
.hLineTo(-base_width/2)
.vLineTo(holder_length / 2)
.threePointArc((-base_width*3/8, base_length*3/8), (-gap/2, base_length/2))
.vLineTo((base_length-gap)/2)
.hLineTo(0)
)
Wires(my_mirrorY(base))
```

![image](https://user-images.githubusercontent.com/954408/57197330-51216080-6f66-11e9-8a90-139f28891ecb.png)

Note, `Wires()` uses `OCC.Extend.TopologyUtils.discretize_wire` to extract drawable edges

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.