[Gmsh] Ghost surfaces after cut?

Beriot, Hadrien hadrien.beriot at siemens.com
Mon Jun 22 21:30:41 CEST 2020


Dear Gmsh-ers,

Simple issue, I am constructing a plate with a hole using csg in the python API. In terms of gmsh class members, everything goes well, as after the "occ.cut" operation the "getEntities()" method returns 7 surfaces and 1 volume

[(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (1, 14), (1, 15), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 3)]

which is exactly what is expected. However, oddly enough, when I write a step file and open it in gmsh, I see 21 surfaces, and not 7. These additional "ghost surfaces" come with their own points and curves, but there is no additional volume. I could not spot the problem, I guess it has to do with the fact that the removeObject and removeTool did not completely erase the corresponding surfaces, they are not class members any more, but somehow they reappear at export.

This is problematic for me because I do some computations on the CAD surfaces themselves. I would like to programmatically generate many "swiss cheese" step files with multiple holes, but I need to be 100% sure that there is no duplicate surfaces kept in the cutting process. I am aware that this kind of geometry prep could be done with pythonocc as well but somehow I would prefer staying in the gmsh environment.
Many thanks for your help!
Kind regards,

Hadrien


import os
import gmsh
import math

gmsh.initialize()
gmsh.model.remove()
gmsh.option.setNumber("General.Terminal", 1)
gmsh.model.add("boxwithhole")

# We first create the cube w/ tag 1
gmsh.model.occ.addBox(0, 0, 0, 3000, 2000, 1000, 1)

# We then create the cylinder w/ tag 2
gmsh.model.occ.addCylinder(1500, 1000, -100, 0, 0, 1200, 300, 2)

# We apply a boolean difference
gmsh.model.occ.cut([(3, 1)], [(3, 2)], 3, removeObject = True, removeTool = True)

gmsh.model.occ.synchronize()

print(gmsh.model.getEntities())

# Show the GUI:
this_folder = os.path.dirname(os.path.abspath(__file__))
gmsh.write(os.path.join(this_folder, "boxwithhole.step"))
gmsh.clear()

gmsh.open(os.path.join(this_folder, "boxwithhole.step"))
gmsh.fltk.run()

gmsh.finalize()




[cid:image005.png at 01D648DC.60265C20]  [cid:image006.png at 01D648DC.60265C20]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20200622/77eb0d2a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 29837 bytes
Desc: image005.png
URL: <http://onelab.info/pipermail/gmsh/attachments/20200622/77eb0d2a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.png
Type: image/png
Size: 118449 bytes
Desc: image006.png
URL: <http://onelab.info/pipermail/gmsh/attachments/20200622/77eb0d2a/attachment-0003.png>


More information about the gmsh mailing list