-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GMSH integration #1346
Comments
I have added a few line to the end of the above example that mesh the geometry and write a import gmsh
import cadquery as cq
result = cq.Workplane("XY").box(3, 3, 0.5).edges("|Z").fillet(0.5)
topods = result.toOCC()
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
volumes = gmsh.model.occ.importShapesNativePointer(topods._address())
gmsh.model.occ.synchronize()
gmsh.option.setNumber("Mesh.Algorithm", 1)
gmsh.option.setNumber("Mesh.MeshSizeMin", 20)
gmsh.option.setNumber("Mesh.MeshSizeMax", 30)
gmsh.model.mesh.generate(2)
gmsh.write("gmsh_of_cadquery_in_memory.msh") |
When exporting workplanes that have surfaces in contact it is nice to merge those surfaces together. This allows the meshing to be conformal at the surface boundary between the two workplanes. I think this code does the same as above but works for two workplanes that contact on a surface. import cadquery as cq
import OCP
import gmsh
workplane1 = cq.Workplane("XY").cylinder(height=10, radius=4)
workplane2 = cq.Workplane("XY").cylinder(height=10, radius=5).cut(workplane1)
bldr = OCP.BOPAlgo.BOPAlgo_Splitter()
bldr.AddArgument(workplane1.val().wrapped)
bldr.AddArgument(workplane2.val().wrapped)
bldr.SetNonDestructive(True)
bldr.Perform()
bldr.Images()
merged_surface_compound = cq.Compound(bldr.Shape())
# it looks like cq.Compound does not have a toOCC method like cq.workplane does
# however it has a val().wrapped which returns a OCP.TopoDS.TopoDS_Solid
topods = merged_surface_compound.wrapped
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
volumes = gmsh.model.occ.importShapesNativePointer(topods._address())
gmsh.model.occ.synchronize()
gmsh.option.setNumber("Mesh.Algorithm", 1)
gmsh.option.setNumber("Mesh.MeshSizeMin", 0.1)
gmsh.option.setNumber("Mesh.MeshSizeMax", 2)
gmsh.model.mesh.generate(2)
gmsh.write("gmsh_of_cadquery_compound_in_memory.msh") I shall confirm if this works or not soon |
Great! Thanks for the investigation @shimwell . |
With OCP 7.7.1 it should be possible to import OCCT shapes from memory
The text was updated successfully, but these errors were encountered: