Assistance with the use of CADMesh

I have a question that may have an easy answer, but it currently eludes me! I would like to ingest two separate .obj files that represent volume elements of my instrument using CAD Mesh. If I ingest just one file, I have no problem placing it anywhere in my World Volume. See here:

To produce this figure in my DetectorConstruction class, I open the .obj file to process it; however, if I try to open another .obj file, I am unable to while this file is opened.

The line in question is

auto ram1_mesh = CADMesh::TesselatedMesh::FromOBJ(“file.obj”);

Is there a way to free ram1_mesh so that another file could be opened?

Furthermore, I tried concatenating these two files, and according to the CADMesh multiple example, I should be able to pick off each entry and include it in my geometrical setup. I can do it, but I get a good first volume, but a rather faulty second volume.

I would like to ask all of you if you have any experience with inputting physical volumes by way of .obj files, into Geant4 using CADMesh, I’d like some advice for the problem I am facing by using more than one file in DetectorConstruction? I appreciate your time.

Tom Eden


Did you try to do the same but with .stl files? I tried to do with more than one .stl files and there were no problems for me. Maybe it will be useful if you attached you .odj files in order someone else would try to launch your geometry?


Thanks for your reply. No, I did not try using .stl files, but I will give your suggestion a try let you know how that goes.



I think I found the bug in my code that prevented me to open and read multiple .obj files; therefore, I believe this issue has been resolved. Thanks for your help!