Closed mia0120 closed 2 years ago
That's because cut_mesh
role is only to cuts the mesh faces, but not to remove the faces inside the holes (you can see the result below)
result, frontier = cut_mesh(rectangle, cylinder)
pierce
is the boolean operation that does what you want
rectangle = flatsurface(wire([ # rectangular surface from a rectangular outline Wire
vec3(-1,-1,0),
vec3(1,-1,0),
vec3(1,1,0),
vec3(-1,1,0),
]))
cylinder = extrusion(Z, Circle((O,Z), 0.5)) # note that the cylinder face normals are oriented outside (the surface color is bright) so the faces to remove are inside the cylinder
result = pierce(rectangle, cylinder)
show([result], options={'display_wire':True})
However, the boolean operations are quite expensive in term of performance for any mesh, and to use is for simple planar operations like this can be avoided in this case.
You can directly use flatsurface
with the appropriate Web
rectangle = wire([ # rectangular Wire
vec3(-1,-1,0),
vec3(1,-1,0),
vec3(1,1,0),
vec3(-1,1,0),
]) .close()
circle = Circle((O,-Z), 0.5) # note that the circle axis is flipped (Z is negative) to ensure that the contour winding is consistent. This is the equivalent of the face normals in the previous solution
result = flatsurface(web([ # generate a surface by triangulating the given loops
rectangle,
circle,
]))
show([result], options={'display_wire':True})
This will give the exact same result
Hope this help !
Nonetheless I agree that the boolean operation docs are lacking nice screenshots to explain this ;)
I need a rectangular flat surface with a hole. First I create a rectangular surface with a flatsurface command and a disk with Circle command. Then using cut_mesh, I try to empty first rectangular surface. But cut_mesh command turns the part to a tuple object. How can I create this flat surface?![image](https://user-images.githubusercontent.com/98092736/155286210-3d50f71e-afc9-49ea-9a70-80415a29cf40.png)