Building with HOOPS Mesh

After the package is unpacked and the license is activated, this page describes how to compile and link a program against HOOPS Mesh.

Pick the tab that matches your situation. Building Your Own Application is the recommended route for any new project; the legacy tab is kept for projects that were link against the old obfuscated source distribution.

The package is a binary distribution. You only compile your code, and then link it to the pre-compiled libraries.

Package Contents

The HoopsSAM library is designed to link against the third-party packages bundled with the distribution. These packages are tested with HOOPS SAM to ensure compatibility. The distribution includes libraries such as Abaqus, Ansys DPF, Blosc, CGNS, GKLib, HDF5, Intel MKL, Intel OpenMP, and METIS. The exact versions are listed in the corresponding third-party folders and are documented in the release notes for the package. Each third-party software is redistributed under its respective license terms. Tech Soft 3D is not the author of those packages, and redistribution is subject to the license terms included with the distribution. See the appropriate release note page to find a list of the provided packages with their versions. This information is only available starting HOOPS SAM 2.5.0.

The extracted package root is named according to the platform it was generarted on, for example HOOPS_Solve_Access_Mesh_<version>_Windows_x86-64_v142\ on Windows and HOOPS_Solve_Access_Mesh_<version>_Linux_x86-64_glibc235/ on Linux. The HOOPS SAM releases use the Semantic Versioning scheme. The include file base.h defines two macros that can be used to retrieve version information:

  • SYS_VERSION defines a hexadecimal value built up from the major, minor, and patch version numbers. This value is guaranteed to be monotonically increasing for each new release.
  • SYS_VERSIONSTR defines a string built up from the major, minor, and patch version numbers. It may also contain pre-release or other supplemental information if available.
HOOPS_Solve_Access_Mesh_<version>_Windows_x86-64_v142\
│
├── include\                                <- the HEADER files + source files for bindings of FORTRAN, C++, and C#
│   ├── sam\                                <- C API:   base, vis, vdm, vfe, vfs, vfx, msh
│   └── samcpp\                             <- C++ API: core, access
│
├── lib\                                    <- IMPORT libraries, used by the LINKER
│   ├── HoopsSAM_core.lib                   <- Foundation.
│   ├── HoopsSAM_access.lib                 <- Access library: reading and writing CAE files.
│   ├── HoopsSAM_mesh.lib                   <- Mesh library: meshing functionality.
│   ├── HoopsSAM_solve.lib                  <- Solve library: solving functionality.
│   ├── HoopsSAM_linearAlgebraCore.lib      <- linear algebra core functionality used by solve and mesh (internally)
│   ├── HoopsSAM_static_MD.lib              <- static variant, /MD runtime
│   ├── HoopsSAM_static_MT.lib              <- static variant, /MT runtime
│   ├── DataProviderHostLib.lib             <- data provider host library
│   ├── DataProviderPluginHeaders.lib       <- data provider plugin headers library
│   └── zlibstatic.lib                      <- static variant of zlib

│
├── bin\                                    <- the DLLs, loaded by the PROGRAM at run time
│   ├── HoopsSAM_core.dll
│   ├── HoopsSAM_access.dll
│   ├── HoopsSAM_mesh.dll
│   ├── HoopsSAM_solve.dll
│   ├── HoopsSAM_linearAlgebraCore.dll
│   ├── HoopsSAMcs.dll                      <- C# wrapper DLL for HoopsSAM
│   ├── exchangePlugin\                     <- plugin for exchange library
│   ├── openfoamPlugin\                     <- plugin for OpenFOAM reader
│   ├── vtkPlugin\                          <- plugin for VTK readers
│   └── dynamicLoadingLibraries\            <- wrapper libraries for Abaqus, AutoDyn and SAMCEF readers
│
├── thirdparty\                             <- helper libraries/ vendor SDKS
│   ├── intelopenmp-<version>-win64\
│   ├── intelmkl.win-x64\
│   ├── hdf5-<version>-win64\
│   ├── abaqus-odb_api-<year>-win64\
│   └── ...
│
├── Examples\                               <- ready-made sample programs (sam, legacy)
├── cmake\                                  <- helper modules used by the examples
├── DataProviderFramework\                  <- plugin SDKs framework
├── dynamicLoadingWrapperSource\            <- source of the reader wrappers
├── migration_scripts\                      <- scripts to help with migrating between major versions
├── VersionInfo.json
└── README.txt

Important

The files in lib are primarily import libraries used during linking, while the DLLs in bin are loaded at runtime. The only exceptions are the two static libraries.

The next step is to focus on building the program and connecting it to the required components:

Folder Job
include
#include "sam/msh/msh.h"
#include "sam/vis/vis.h"
#include "sam/base/base.h"
lib
HoopsSAM_mesh.lib
HoopsSAM_core.lib
thirdparty Dependency libraries (Intel OpenMP, Intel MKL, HDF5, METIS and GKLib)

Step 1 - Create Your Project Folder

Create an empty folder named MeshExample for the project. It does not need to live next to the distribution. The project consists of two files:

MeshExample/
├── CMakeLists.txt      <- the recipe (Step 3)
└── main.cpp            <- your program (Step 2)

Step 2 - Write A Very Small Program

Create main.cpp. The program below reads a surface file given on the command line, generates a surface mesh from it.

#include "sam/base/base.h"
#include "sam/base/license.h"
#include "sam/hoops_license.h"
#include "sam/vis/vis.h"
#include "sam/msh/msh.h"

#include <cstdio>

int
main(int argc, char** argv)
{
    /* Always validate the license before calling anything else. */
    vsy_LicenseValidate(HOOPS_LICENSE);

    if (argc < 2) {
        std::fprintf(stderr, "usage: mesh_example <surface-file>\n");
        return 2;
    }

    /* Read a surface definition and mesh it. */
    msh_SurfMesh* surfmesh = msh_SurfMeshBegin();
    msh_SurfMeshRead(surfmesh, SYS_ASCII, argv[1]);

    vis_Connect* connect = vis_ConnectBegin();
    vis_ConnectPre(connect, SYS_DOUBLE);
    vis_ConnectDef(connect, 0, 0);

    msh_SurfMeshGenerate(surfmesh, connect);

    msh_SurfMeshEnd(surfmesh);
    vis_ConnectEnd(connect);

    return 0;
}

Warning

The HOOPS_LICENSE must be validated before any calls to the HOOPS Mesh API functions. Please refer to Installing HOOPS Mesh for more details.

Step 3 - Write The CMakeLists.txt

Create CMakeLists.txt next to main.cpp (Step 2). Pick the flavour you want: link against the shared libraries (the usual choice), or link everything into one self-contained executable. The library names differ per platform, so there is one tab per combination.

cmake_minimum_required(VERSION 3.21)

project(MeshExample LANGUAGES CXX)

# --- 1. Path to unpacked distribution------------------------------
set(SAM_ROOT "" CACHE PATH "Root of the HOOPS Solve, Access & Mesh distribution")

set(SAM_INCLUDE_DIR "${SAM_ROOT}/include")
set(SAM_LIB_DIR     "${SAM_ROOT}/lib")

# --- 2. executable --------------------------------------------------------
add_executable(mesh_example main.cpp)
target_compile_features(mesh_example PRIVATE cxx_std_17)

# --- 3. Headers -------------------------------------------------------------
target_include_directories(mesh_example PRIVATE "${SAM_INCLUDE_DIR}")

# --- 4. Libraries -----------------------------------------------------------
target_link_libraries(mesh_example PRIVATE
    "${SAM_LIB_DIR}/HoopsSAM_mesh.lib"
    "${SAM_LIB_DIR}/HoopsSAM_core.lib")

install(TARGETS mesh_example RUNTIME DESTINATION bin)

Note

The transitive dependencies of the main libraries (HoopsSAM_mesh and HoopsSAM_core) are not automatically found at runtime. They are available in the thirdparty folders, so you need to add them to PATH - see Dependencies.

Note

The HOOPS Mesh does not need HOOPS Access to write the generated mesh to any supported CAE input deck format.

Step 4 - Configure And Build

The Visual Studio generator is multi-configuration: you do not choose the build type when you configure, you choose it when you build.

cmake -S . -B MeshExample ^
      -G "Visual Studio 16 2019" -A x64 ^
      -DSAM_ROOT=C:\path\to\HOOPS_Solve_Access_Mesh_<version>_Windows_x86-64_v142

cmake --build MeshExample --config Release

Step 5 - Run It

Compilation and linking alone are not sufficient. At runtime, the program must locate the shared libraries, and it does not retain the build-time search paths. The required locations are provided through environment variables: PATH on Windows and LD_LIBRARY_PATH on Linux.

Note

This step is still needed even if linked statically. Only the HoopsSAM_* libraries (plus METIS and GKlib) end up inside the executable; Intel MKL and Intel OpenMP remain shared libraries, so the thirdparty folders below have to be reachable either way.

set SAM_ROOT=C:\path\to\HOOPS_Solve_Access_Mesh_<version>_Windows_x86-64_v142

set PATH=%SAM_ROOT%\bin;%PATH%
set PATH=%SAM_ROOT%\thirdparty\intelopenmp-2023.1.0-win64\bin;%PATH%
set PATH=%SAM_ROOT%\thirdparty\intelmkl.win-x64\bin;%PATH%

MeshExample\Release\mesh_example.exe C:\path\to\surface.srf

Congratulations, your first program is built with HOOPS Mesh.

Dependencies

A HOOPS Mesh requires some shared libraries to be loaded at run time. Environment variables define the search paths used to locate these components.

For shared linking, the program must also locate HoopsSAM_linearAlgebraCore, which is a transitive dependency of HoopsSAM_Mesh. This library is provided in the same folder as HoopsSAM_Mesh. In addition, HOOPS Mesh depends on two libraries in the thirdparty folder: Intel OpenMP and Intel MKL.

Add the two bin folders to PATH (alongside %SAM_ROOT%\bin, which holds the HOOPS SAM DLLs):

set PATH=%SAM_ROOT%\bin;%PATH%                           :: Add the folder containing HoopsSAM_linearAlgebraCore.dll
set PATH=%SAM_ROOT%\thirdparty\intelopenmp-2023.1.0-win64\bin;%PATH%
set PATH=%SAM_ROOT%\thirdparty\intelmkl.win-x64\bin;%PATH%

For Static linking, in addition to the above libraries, HOOPS Mesh needs Metis and GKLib libraries from the thirdparty folder.

Need Help ?

The project is now ready for use with HOOPS Mesh. For additional support, refer to the support resources or the forum.