-
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
Track and Match CQ Objects On an Export-Import Round Trip #1243
Comments
Yes that would be a really useful feature for me. The only tiny detail is that the Brep exported is also slightly differently to the default cadquery brep. I use some code Adam wrote to merge shared surfaces link in the Brep file. This makes is easier to mesh in subsequent steps. Full details of the messy workflow I have assembled are here in this unfinished paper I am working on. But having this round trip feature would allow the unreliable brep-part-finder package to be removed. |
@shimwell is this in the end about storing user defined labels per shape of subshape (e.g. face) that can survive the face merging process? So something like: As a user I want to be able to add labels to my models and use them to reference arbitrary shapes, possibly after merging duplicate faces. |
For me I just need to track the volumes. The removal of shared surfaces is a bit of a distraction. It happens in the workflow. But I just need to correlate the volumes in an assembly with the volumes in a brep file. I think in many cases the volume order is the same but not guaranteed to be the same |
Is there anything I can do to help with this |
Hm, you could check if |
I've checked with the DAGMC community and we think BOPAlgo_MakeConnected that would be great for merging surfaces which is one of the things we would find very useful. The existing workflow uses the BOPALgo_Splitter (which you provided an example of a while ago) and this has also worked well for us. @pshriwise and @ebknudsen might have further comments |
Thanks @shimwell. I'm still not sure if this is at all about import/export. Based on the paper I concluded that you want to do this imprinting and matching in the back-end of What I have in mind so far is something like:
If it turns out that you do need to serialize, then using XDE/OCAF (native OCCT formats) would be preferred. |
The writing of a brep file to disk was done so that we can read it in by gmsh and meshed. I couldn't find another way of getting the geometry fro cadquery to gmsh so I currently write a brep file as they can both interact with that. I actually also tried making triangular meshes in cadquery (then we wouldn't need to export) but that didn't result in watertight meshes a the surface mesh in gmsh did. If this had worked then the brep format could be avoided |
Thanks Adam. Yes this interface is done in memory currently. Perhaps I've used the wrong terminology but a BREP "object" is passed between these stages |
OK, so does what I proposed above (points 1-6) solve the problem you have? |
Yes, it would be perfect. |
Great! For my understanding, how do you actually pass the "material tag" information to gmsh? |
The brep gets meshed by gmsh and each volume is meshed. The meshed representation of each volume (coords and triangles) are then passed along with the material tags are then passed to pymoab based package that saves the collections as tagged volumes in a DAGMC formated h5m file. So gmsh doesn't do much with the material tags it just passes then along and keep the same order of material tags and brep volumes. I guess we wouldn't need to pass the material tags to gmsh in the future. We would just get the meshed volumes back and already know what material tag each one of them is. Then we can write them to h5m format |
Unrelated to this issue, but @shimwell it seems that gmsh can in principle import from memory: https://gitlab.onelab.info/gmsh/gmsh/blob/gmsh_4_11_1/api/gmsh.py#L8437. I'm going to add |
Wow super useful find there. Yes I would be super keen to test that |
@shimwell latest OCP (7.7.1 - not released, but available via cadquery channel) has |
Thanks @adam-urbanczyk I have tried the following and I shall continue tomorrow I created a new conda env with this environment.yml file and this command
running
I then proceeded to run this file that makes a cadquery shape and converts it to OCC then trys to import with gsm import gmsh
import cadquery as cq
result = cq.Workplane("XY").box(3, 3, 0.5).edges("|Z").fillet(0.125)
topods = result.toOCC()
gmsh.model.occ.importShapesNativePointer(topods) Unfortunately this last line errored with the message
I shall continue tomorrow, thanks for your efforts on adding these features |
I think it should be: gmsh.model.occ.importShapesNativePointer(topods._address()) |
FWIW this seems to work (or at least does not crash). I'll open another issue, gmsh import might be interesting for other users. import OCP
import gmsh
gmsh.initialize()
s = OCP.BRepPrimAPI.BRepPrimAPI_MakeBox(1,1,1).Solid()
gmsh.model.occ.importShapesNativePointer(s._address()) |
User Story: As a user, I want to be able to export a CQ object or assembly to STEP/BRep, then import it again and be able to match the imported objects with the original pre-export CQ objects.
This will require some work on the CQ internals to accomplish.
Reference: Google Groups
@shimwell Please feel free to add additional details.
Related to #449
The text was updated successfully, but these errors were encountered: