CadQuery / CadQuery/cadquery

Multiple split with Faces produce inconsistent results

Open
#1,461 3 comments 0 reactions 0 assignees View on GitHub
bug OCC kernel issue
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")
```

![image_480](https://github.com/CadQuery/cadquery/assets/4851220/8d3536bf-a1dd-4e4b-a145-33c6831d985b)

It is however expected to keep all the split solids
a grid of [5,5,5] provide expected results :
![image_480](https://github.com/CadQuery/cadquery/assets/4851220/226b5606-6339-4ed9-a8b1-15fd39512fc7)

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.