Multiple split with Faces produce inconsistent results
- Dominant language
- Python
- Stars
- 5.8k
- Forks
- 541
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 5
Description
We are trying to generate multiple cuts to 'raster' basic geometries
The sample code below produces inconsistent results with missing parts of the split ellipsoid
```python
import cadquery as cq
import numpy as np
a_x=0.15
a_y=0.31
a_z=0.4
grid=[4, 4, 4]
transform_mat = cq.Matrix(
[
[a_x, 0, 0, 0.],
[0, a_y, 0, 0.],
[0, 0, a_z, 0.],
]
)
sphere = cq.Solid.makeSphere(1.0, cq.Vector(0, 0, 0), angleDegrees1=-90)
ellipsoid = sphere.transformGeometry(transform_mat)
solidList = []
for solid in ellipsoid.Solids():
wk_plane = cq.Workplane().add(solid)
xgrid = np.linspace(-0.5, 0.5, num=grid[0], endpoint=False)[1:]
ygrid = np.linspace(-0.5, 0.5, num=grid[0], endpoint=False)[1:]
zgrid = np.linspace(-0.5, 0.5, num=grid[0], endpoint=False)[1:]
print(ygrid)
for i in xgrid:
Plane_x = cq.Face.makePlane(None, None, basePnt=(i, 0, 0), dir=(1, 0, 0))
wk_plane = wk_plane.split(cq.Workplane().add(Plane_x))
print('x:', len(wk_plane.val().Solids()))
for j in ygrid:
Plane_y = cq.Face.makePlane(None, None, basePnt=(0, j, 0), dir=(0, 1, 0))
wk_plane = wk_plane.solids().split(cq.Workplane().add(Plane_y), keepBottom=True, keepTop=True)
print('y:', len(wk_plane.val().Solids()))
for k in zgrid:
Plane_z = cq.Face.makePlane(None, None, basePnt=(0, 0, k), dir=(0, 0, 1))
wk_plane = wk_plane.split(cq.Workplane().add(Plane_z), keepBottom=True, keepTop=True)
print('z:', len(wk_plane.val().Solids()))
for subsolid in wk_plane.val().Solids():
solidList.append(subsolid)
compound = cq.Compound.makeCompound(solidList)
cq.exporters.export(compound, "compound.step")
```

It is however expected to keep all the split solids
a grid of [5,5,5] provide expected results :

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.