xraylib 4.3.0

repository·master·Indexed 41 days ago

https://github.com/tschoonj/xraylib

A specialized library for modeling and calculating the interactions between X-rays and various forms of matter. It provides tools for X-ray physics and material science, featuring native C implementations and .NET bindings via XrayLib.NET.dll.

Tokens
646
Snippets
1
Records
6
Agent score
52%

What's inside xraylib

  1. Understanding XRayInit and data preloading

    master

    The library uses a preloading procedure to handle data initialization:

    1. Modern usage: The routine XRayInit in xrayfiles.c is used to read in the data generated by the src/pr_data.c program.
    2. Legacy compatibility: For older programs that call XRayInit directly (before the preloading procedure was implemented), the library includes a dummy XRayInit located in src/xrayfiles_inline.c to prevent linking errors.
  2. How xraylib data is loaded and updated

    master

    The data files located in the data/ directory are not parsed at runtime. Instead, they are processed during the build phase to create a C source file (src/xrayglob_inline.c) containing variable array definitions. This source file is then compiled directly into the xraylib library.

    Important: If you modify any files in the data/ directory, you must rebuild the entire xraylib library for the changes to take effect in your application.

  3. Use XrayLib.NET.dll in Visual Studio

    master

    To integrate the XrayLib .NET bindings into a Visual Studio project, you must add the XrayLib.NET.dll assembly as a reference. This assembly is a mixed-mode C++/CLI component that provides interop between managed .NET classes and the native libxrl-7.dll functions.

    Steps to add the reference:

    1. Right-click your project in the Solution Explorer.
    2. Select References....
    3. Click Add New Reference....
    4. Select the Browse tab.
    5. Navigate to the xraylib Lib folder and select XrayLib.NET.dll.
    6. Click OK to complete the reference addition.
  4. Install xraylib

    master

    xraylib can be installed using several methods depending on your operating system:

    • Linux/Unix/macOS: Compile from source using GNU Autotools or meson. Detailed compilation instructions are located in the INSTALL file within the repository.
    • Windows: A pre-built installer is available which includes the 64-bit DLL and the necessary xraylib headers.
  5. Initialize XrayLib in C# using the Singleton pattern

    master

    The .NET bindings use a singleton pattern to manage the XrayLib class. Instead of manual instantiation, you access the functionality through the static Instance property. This ensures only one instance of the class exists throughout your program's lifecycle.

    To use it in C#, include the Science namespace and access the instance as shown below.

    using Science;
    
    // Access the singleton instance
    XrayLib xl = XrayLib.Instance;