Method for rapidly importing CAD model into Geant4 based on CADMesh

Through the CADMesh-based method, the problems of CAD model import efficiency and accuracy in Geant4 are solved, efficient and accurate model import and simulation are achieved, and multi-format compatibility and visual interaction are supported, suitable for particle physics and medical imaging fields.

CN120387352APending Publication Date: 2025-07-29INST OF ENERGY HEFEI COMPREHENSIVE NAT SCI CENT (ANHUI ENERGY LAB)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510466735.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-07-29

AI Technical Summary

Technical Problem

The prior art is difficult to quickly and accurately import CAD models into Geant4, especially the processing of complex geometric structures is inconvenient, resulting in low simulation efficiency and poor accuracy.

Method used

Using a CADMesh-based method, we check model errors through preprocessing, integrate it into the Geant4 project using the CADMesh.hh header file, write and introduce entity code, and verify model import through visualization tools, supporting multi-format compatibility and parameterized adjustment.

Benefits of technology

It significantly improves model import efficiency and simulation accuracy, ensures model geometric integrity, reduces cross-platform collaboration costs, and provides an efficient and flexible detector modeling solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120387352A_ABST
    Figure CN120387352A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of Monte Carlo analog simulation, in particular to a method for rapidly importing a CAD model into Geant4 based on CADMesh. According to the technical scheme, the method comprises the following steps that a CAD model is preprocessed, and whether model errors, including file position errors, file name errors, file format errors and geometric overlap errors, exist in the CAD model or not is checked; according to the method, efficient integration of the CAD model and Geant4 is achieved through a standardized process, the model importing efficiency and simulation precision are remarkably improved, the geometric integrity of the model is ensured through a preprocessing mechanism, precise modeling is supported through a parameterized adjustment function, simulation reliability is ensured through visual verification and particle transport testing, and the simulation efficiency is improved. The multi-format compatibility and the automatic integration characteristic greatly reduce the cross-platform cooperation cost, and an efficient and flexible detector modeling solution is provided for the fields of particle physics, medical images and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Monte Carlo simulation, and in particular to a method for quickly importing a CAD model into Geant4 based on CADMesh. Background Art

[0002] In the fields of particle physics, radiotherapy dose calculation, radiation protection simulation, etc., an accurate three-dimensional geometric model is crucial for simulating the interaction between particles and matter. Although the traditional Geant4 simulation toolkit is powerful, its built-in modeling method is not convenient for dealing with complex geometric structures. Especially for non-professionals, it is difficult to use the constructive solid geometry representation (CSG) for modeling. Therefore, directly importing CAD models into Geant4 has become an important research direction. CAD models are widely used in engineering design and simulation due to their accuracy and intuitiveness. How to quickly and accurately import these models into Geant4 has become a key step in improving simulation efficiency and accuracy.

[0003] Therefore, this application proposes a method for quickly importing a CAD model into Geant4 based on CADMesh. Summary of the Invention

[0004] The object of the present invention is to propose a method for quickly importing a CAD model into Geant4 based on CADMesh for the solution in the background art that does not quickly and accurately import the CAD model into Geant4.

[0005] The technical solution of the present invention: A method for quickly importing a CAD model into Geant4 based on CADMesh includes the following steps:

[0006] Step 1: Preprocess the CAD model to check whether there are model errors in the CAD model, including file location errors, file name errors, file format errors, and geometric overlap errors;

[0007] Step 2: Copy the CADMesh.hh header file to the include directory of the project;

[0008] Step 3: Copy the CAD model file to be imported to the root directory of the project;

[0009] Step 4: Modify the CMakeLists.txt file of the project and add the CAD model file name to the test_SCRIPTS configuration item;

[0010] Step 5: Add the #include CADMesh.hh header file to the DetectorConstruction.cc file and write the code for introducing the entity;

[0011] Step 6: Compile the Geant4 project and run the simulation to verify whether the CAD model is correctly imported.

[0012] Optionally, the geometric overlap error check in step 1 includes detecting whether there are non-closed surfaces, intersecting geometries, or redundant vertices in the model.

[0013] Optionally, the code for introducing the entity in step 5 specifically includes:

[0014] Load the CAD model file through the CADMesh interface to generate geometric entities;

[0015] Adjust the dimensions and spatial positions of the geometric entities based on user-defined parameters;

[0016] Assign material properties to the geometric entities and associate their logical volumes with the physical structure of the detector.

[0017] Optionally, the verification process of running the simulation in step 6 includes:

[0018] Check the geometric rendering of the CAD model in Geant4 through a visualization tool;

[0019] Run a particle emission simulation experiment to confirm that the response of the model to particle transport meets expectations.

[0020] Optionally, the CAD model file format is one of STL, OBJ, or PLY.

[0021] Optionally, the CADMesh.hh header file is integrated into the Geant4 project dependencies through the CMake compilation system.

[0022] Optionally, the modification of the CMakeLists.txt file further includes: adding link instructions and path configurations for the CADMesh library.

[0023] Optionally, in step 5, adding the #includeCADMesh.hh header file to the DetectorConstruction.cc file and writing the code for introducing the entity specifically includes creating an entity object, setting the model dimensions, defining the relative position of the model to the coordinate origin, configuring the model material, and embedding the logical volume into the detector construction.

[0024] Optionally, it further includes a graphical user interface, and the interface includes:

[0025] (1) Model tree display area, used to show the hierarchical structure of the CAD model;

[0026] (2) CAD display area, used to present the 3D graphics of the imported CAD model;

[0027] (3) Information panel, used to show the geometric properties of the selected component;

[0028] (4) Material configuration area, used to specify material properties for the selected component;

[0029] (5) Console output area, used to show the real-time status information of model import and processing.

[0030] Compared with the prior art, the present application includes at least one of the following beneficial technical effects:

[0031] The present invention is mainly reflected in the import efficiency, model quality, simulation accuracy and compatibility. In terms of import efficiency, a set of standardized processes greatly shortens the import time. The CADMesh.hh header file is automatically integrated by the CMake compilation system, reducing the cumbersome manual configuration operations.

[0032] In terms of model quality, a comprehensive error check is performed on the CAD model in the preprocessing stage, especially the detection of geometric overlap errors, ensuring the integrity and accuracy of the model structure, and providing a reliable basis for subsequent simulations.

[0033] The geometric presentation of the model is visually checked through visualization tools, and the particle transport response is verified through particle emission simulation experiments to ensure that the simulation results truly reflect the physical scenario. In addition, the present invention supports multiple common CAD model file formats, is very convenient when integrated with Geant4, and is easy to expand functions according to requirements, showing good compatibility and expandability.

[0034] The present invention realizes the efficient integration of the CAD model and Geant4 through a standardized process, significantly improving the model import efficiency and simulation accuracy: its preprocessing mechanism ensures the geometric integrity of the model, the parametric adjustment function supports precise modeling, the visual verification and particle transport test guarantee the reliability of the simulation, and the multi-format compatibility and automated integration characteristics greatly reduce the cross-platform collaboration cost, providing an efficient and flexible detector modeling solution for fields such as particle physics and medical imaging.

[0035] The present invention also provides a dedicated graphical user interface to realize the visual operation and status monitoring of the CAD model import process. This interface integrates functions such as model tree display, geometric information viewing, material configuration and debugging information output, supports the completion of technical processes through intuitive interaction methods, and greatly reduces the technical use threshold. Brief Description of the Drawings

[0036] Figure 1 It is a flowchart of a method for quickly importing a CAD model into Geant4 based on CADMesh;

[0037] Figure 2 It is a demonstration diagram for importing a CAD model into Geant4.

[0038] Figure 3 It is a schematic diagram of the CAD model import operation interface provided by the embodiment of the present invention, showing function modules such as a model tree, a part list, a CAD display area, model information, and material selection. Detailed implementation manners

[0039] The technical solution of the present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.

[0040] Embodiment

[0041] As Figure 1 shown, a method for quickly importing a CAD model into Geant4 based on CADMesh proposed by the present invention will be described in detail for each step process below.

[0042] Step 1: Preprocess the CAD model, comprehensively check the CAD model to ensure that there are no errors in file location, file name, file format, and geometric overlap. Among them, the geometric overlap error check includes detecting whether there are non-closed surfaces, intersecting geometries, or redundant vertices in the model. By preprocessing the CAD model, problems such as program crashes or inaccurate simulation results caused by model errors can be avoided during subsequent import and simulation processes. For example, non-closed surfaces may cause abnormal particle penetration during the simulation process, intersecting geometries may cause confusion in geometric calculations, and redundant vertices will increase the computational amount and reduce the simulation efficiency. By checking and fixing these problems in advance, the accuracy and efficiency of the simulation can be improved. Use the built-in check tools of professional CAD software (such as SolidWorks, AutoCAD) to check the geometric errors of the model. For file location, file name, and file format errors, their correctness can be ensured through manual checking and modification.

[0043] Step 2: Copy the CADMesh.hh header file and copy it to the include directory of the project. This header file is integrated into the Geant4 project dependencies through the CMake build system. Copying the CADMesh.hh header file to the include directory of the project enables the project to find and include this header file, so that the interfaces and functions provided by CADMesh can be used. This facilitates the calling of relevant functions of CADMesh in the Geant4 project to load and process CAD models, laying a foundation for subsequent model import and simulation work.

[0044] Step 3: Copy the CAD model file and copy the CAD model file to be imported to the root directory of the project. Copying the CAD model file to the root directory of the project facilitates specifying the path of the model file in the subsequent code. This can avoid the problem of not being able to find the model file due to incorrect file path settings and improve the success rate of model import.

[0045] Step 4: Modify the CMakeLists.txt file of the project. Modify the CMakeLists.txt file of the project, add the CAD model file name to the test_SCRIPTS configuration item, and add the link instruction and path configuration for the CADMesh library. By modifying the CMakeLists.txt file and adding the CAD model file name to the test_SCRIPTS configuration item, CMake can know that it needs to process this model file when compiling the project. Adding the link instruction and path configuration for the CADMesh library enables the project to correctly link the CADMesh library during the compilation process, so as to use its provided functions. This can ensure that the project can be successfully compiled and run, realizing the import of the CAD model.

[0046] Step 5: Write the code to introduce the entity in the DetectorConstruction.cc file. Add the #include "CADMesh.hh" header file in the DetectorConstruction.cc file and write the code to introduce the entity. The code to introduce the entity specifically includes: loading the CAD model file through the CADMesh interface to generate geometric entities; adjusting the size and spatial position of the geometric entities based on user-defined parameters; assigning material properties to the geometric entities and associating their logical volumes with the physical structure of the detector. Specifically, it also includes creating entity objects, setting the model size, defining the relative position of the model with respect to the coordinate origin, configuring the model material, and embedding the logical volume into the detector construction. Introducing the CADMesh.hh header file and writing the code to introduce the entity in the DetectorConstruction.cc file enables us to load the CAD model during the detector construction process in Geant4 and integrate it into the physical structure of the detector. By adjusting the size, position, and material properties of the geometric entities, the model can be customized according to actual needs, thus more accurately simulating the real physical scenario.

[0047] Step 6: Compile the Geant4 project and run the simulation. Compile the Geant4 project and run the simulation to verify whether the CAD model is correctly imported. The verification process of running the simulation includes: checking the geometric rendering of the CAD model in Geant4 through a visualization tool; running a particle emission simulation experiment to confirm that the response of the model to particle transport meets expectations. Compiling the Geant4 project and running the simulation can ensure the correctness of the entire import process. By checking the geometric rendering of the CAD model through a visualization tool, it is possible to visually check whether the model is correctly imported and whether there are geometric deformations. Running a particle emission simulation experiment can verify the performance of the model in particle transport simulation, ensuring that the response of the model to particles conforms to the actual physical situation, thus guaranteeing the reliability of the simulation results. Through this method, the demonstration of importing the CAD model into Geant4 is as Figure 2 shown.

[0048] It is worth noting that the method of the present invention improves the model import efficiency. This method provides a set of clear and systematic steps, covering the complete process from CAD model preprocessing to final verification of import in Geant4. For example, by directly copying the CADMesh.hh header file to the include directory of the project, copying the CAD model file to the root directory of the project, and making corresponding modifications to the CMakeLists.txt file, etc., complex manual configuration and programming are avoided, greatly shortening the time and effort required for model import. The CADMesh.hh header file is integrated into the Geant4 project dependencies through the CMake compilation system, enabling the project to automatically recognize and use the functions of CADMesh during compilation without additional complex settings by developers, further improving the import efficiency.

[0049] In the CAD model preprocessing stage, detailed checks are carried out on errors such as file location, file name, file format, and geometric overlap. In particular, the detection of non-closed surfaces, intersecting geometries, or redundant vertices in geometric overlap errors can discover and solve problems that may lead to inaccurate simulation results in advance. For example, non-closed surfaces may cause abnormal particle penetration during simulation, and this method can effectively avoid such situations, ensuring that the geometric structure of the model meets the actual requirements. In the introduced entity code, it is allowed to adjust the size and spatial position of geometric entities based on user-defined parameters and assign material properties to them. This enables the model to be precisely customized according to the actual physical scenario, improving the accuracy and reliability of the simulation. For example, in medical physics simulations, model parameters can be set according to the actual material properties of human tissues and the precise positions of organs, so as to more realistically simulate the interaction between particles and human tissues.

[0050] In the verification process of running the simulation, the geometric presentation of the CAD model in Geant4 can be visually inspected through visualization tools. Developers can promptly discover problems such as deformation or missing of the model, ensuring that the geometric structure of the model is not damaged during the import process. For example, in the simulation of high-energy physics experimental devices, through visual inspection, it can be clearly seen whether the geometric shape of the detector is correct, providing a reliable basis for subsequent experimental design. Run the particle emission simulation experiment to confirm that the response of the model to particle transport meets expectations. This helps to verify the performance of the model in the actual physical process, ensuring that the simulation results can accurately reflect real physical phenomena. For example, in nuclear physics research, by observing the particle transport process in the model, it can be verified whether the simulation of nuclear reactions by the model is accurate, providing strong support for in-depth study of nuclear physics phenomena.

[0051] The method of the present invention supports common CAD model file formats such as STL, OBJ, or PLY, increasing the flexibility of model import. Different CAD software may generate model files in different formats. Developers can choose the appropriate file format for import according to their needs without performing complex format conversions, improving work efficiency. It is easy to integrate and expand, and is seamlessly integrated with Geant4: By modifying the CMakeLists.txt file to add link instructions and path configurations for the CADMesh library, CADMesh can be seamlessly integrated with the Geant4 project. Developers can easily apply this method in existing Geant4 projects without making large-scale modifications to the overall project architecture. This method provides a clear code structure and interfaces, and developers can expand and customize the introduced entity code according to actual needs. For example, more geometric transformation operations, material property settings, etc. can be added to meet the simulation needs of different fields.

[0052] As Figure 3 shown, the CAD model import operation interface of the present invention includes the following functional areas and operation processes:

[0053] (1) Menu bar: Provides four main function entry points: File, View, Material, and About;

[0054] (2) Model tree and part list: The left panel shows the hierarchical structure of the imported CAD model (assembly_1 and its sub-parts) and the plane list (base plate, support column, etc.), and supports selecting specific components by clicking;

[0055] (3) CAD display area: The central main area displays a prompt "Please import a CAD file for display". CAD model files in formats such as STL and STEP can be loaded through the "Import CAD File" button at the top;

[0056] (4) Information panel: Real-time displays the detailed information of the currently selected component (such as mounting bracket), including the parent assembly, index number, transparency setting, color value, material property (such as aluminum), and physical volume (45.2 cm 3 );

[0057] (5) Console output: Displays system debugging information at the bottom, such as status information like "Checking material database... Total updated materials = 32", "Loading STEP file", etc.;

[0058] (6) Material selection panel: Configures the material properties for the selected component (such as fasteners), provides "Clear" and "Add Material" operation buttons, and supports selection from a preset material library (shape materials, aluminum, steel, etc.).

[0059] This interface realizes the visual interaction with the method described in Claims 1-8. The specific operation process includes:

[0060] (1) Execute the model preprocessing of Claim 1 and the file loading of Claim 3 through the "Import CAD File" button.

[0061] (2) View and verify the geometric rendering information of Claim 4 in the information panel.

[0062] (3) Implement the material property configuration described in Claims 5 and 8 through the material selection panel.

[0063] (4) The console outputs real-time feedback on the CMake integration process described in Claim 6 and the compilation and linking status described in Claim 7.

[0064] The present invention realizes the efficient integration of the CAD model and Geant4 through a standardized process, significantly improving the model import efficiency and simulation accuracy. Specifically, it is reflected in: (1) Visual interaction interface: providing an integrated graphical operation interface, including a model tree display, a part list management, a CAD visualization display area, a model property information panel, and a material configuration module, supporting one-click model loading and verification through the "Import CAD File" button; (2) Preprocessing mechanism: real-time feedback on the model inspection status through the interface console (such as "Checking the material database... The total number of updated materials = 32") to ensure the geometric integrity of the model; (3) Parametric modeling: intuitively display and adjust part parameters in the information panel (such as the transparency of the mounting bracket 0.75, the color value #FFA500, the aluminum material properties, and the volume of 45.2 cm 3 ); (4) Verification system: combining the visual presentation in the interface and the console output information (such as "Loading the STEP file 'assembly_1.stp'") to achieve double verification of geometric rendering inspection and particle transport test; (5) Material management: realizing the precise allocation of the material properties described in the claims through a dedicated material selection panel (such as configuring the shape material / metal material for fasteners). Through the coordination of the above interface and method, the preprocessing mechanism of the present invention ensures the geometric integrity of the model, the parametric adjustment function supports precise modeling, the visual verification and particle transport test guarantee the simulation reliability, and the multi-format compatibility and automated integration characteristics greatly reduce the cross-platform collaboration cost, providing an efficient and flexible detector modeling solution for fields such as particle physics and medical imaging.

[0065] The above specific embodiments are only several alternative embodiments of the present invention. Based on the technical solution of the present invention and the relevant revelations of the above embodiments, those skilled in the art can make various alternative improvements and combinations to the above specific embodiments.

Claims

1. A method for quickly importing a CAD model into Geant4 based on CADMesh, characterized in that, It includes the following steps: Step 1: Preprocess the CAD model and check for model errors in the CAD model, including file location errors, file name errors, file format errors, and geometric overlap errors; Step 2: Copy the CADMesh.hh header file to the include directory of the project; Step 3: Copy the CAD model file to be imported to the root directory of the project; Step 4: Modify the CMakeLists.txt file of the project and add the CAD model file name to the test_SCRIPTS configuration item; Step 5: Add the #inlcude CADMesh.hh header file to the DetectorConstruction.cc file and write the code for introducing entities; Step 6: Compile the Geant4 project and run the simulation to verify whether the CAD model is imported correctly.

2. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, characterized in that, The geometric overlap error check in Step 1 includes detecting whether there are non-closed surfaces, intersecting geometries, or redundant vertices in the model.

3. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, characterized in that, The code for introducing entities in Step 5 specifically includes: Load the CAD model file through the CADMesh interface to generate geometric entities; Adjust the size and spatial position of the geometric entities based on user-defined parameters; Assign material properties to the geometric entities and associate their logical volumes with the physical structure of the detector.

4. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, wherein, The verification process of running the simulation in Step 6 includes: Check the geometric rendering of the CAD model in Geant4 through a visualization tool; Run a particle emission simulation experiment to confirm that the response of the model to particle transport meets expectations.

5. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, characterized in that, The CAD model file format is one of STL, OBJ, or PLY.

6. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, characterized in that, The CADMesh.hh header file is integrated into the Geant4 project dependencies through the CMake compilation system.

7. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, characterized in that, The modification of the CMakeLists.txt file further includes: adding link instructions and path configurations for the CADMesh library.

8. A method for quickly importing a CAD model into Geant4 based on CADMesh according to claim 1, characterized in that, In Step 5, adding the #inlcude CADMesh.hh header file to the DetectorConstruction.cc file and writing the code for introducing entities specifically includes creating entity objects, setting model sizes, defining the relative position of the model to the coordinate origin, configuring model materials, and embedding the logical volume into the detector construction.

9. A method for quickly importing a CAD model into Geant4 based on CADMesh according to any one of claims 1-8, characterized in that, It also includes a graphical user interface, and the interface includes: (1) A model tree display area for displaying the hierarchical structure of the CAD model; (2) A CAD display area for presenting the 3D graphics of the imported CAD model; (3) An information panel for displaying the geometric properties of the selected components; (4) A material configuration area for specifying material properties for the selected components; (5) A console output area for displaying real-time status information on model import and processing.