AMCAX Kernel 1.0.0.0
Create Applications with AMCAX Kernel via CMake

Overview

This tutorial helps users to create applications with AMCAX kernel via CMake.

Required Knowledge

The developers need to have some basic knowledge including the modern C++ programming language and CMake features.

Write a Simple Example

Here we provide a simple example to create a box and save the mesh to an OBJ file.

#include <io/OBJTool.hpp>
int main()
{
AMCAX::TopoShape s = AMCAX::MakeBox(1.0, 1.0, 1.0);
AMCAX::BRepMeshIncrementalMesh mesher(s, 0.005, true);
return 0;
}
Class of making a box.
Class of read and write triangular meshes of shapes in OBJ format.
Class of meshing.
Definition: BRepMeshIncrementalMesh.hpp:16
Class of making a box.
Definition: MakeBox.hpp:18
static AMCAX_API bool WriteShape(const TopoShape &shape, const std::string &file, bool divideGroup=true)
Write the mesh of a shape to a file.
Base class of shape, containing an underlying shape with a location and an orientation.
Definition: TopoShape.hpp:15

Write CMakeLists

First, we write some basic settings including CMake required version, project name and version, and C++ standard version.

cmake_minimum_required (VERSION 3.13 FATAL_ERROR)
project(test VERSION 1.0.0)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 17)

Then, the required packages are set and all the required environment are also set.

find_package(AMCAXCommon REQUIRED)
find_package(AMCAXPart REQUIRED)

Finally, add the project of application and set libraries to be linked.

file(GLOB files "*.cpp")
add_executable(test ${files})
target_link_libraries(test AMCAXPart AMCAXCommon)

As an optional setting, the debugger environment is set for debugging using Microsoft Visual Studio.

if(MSVC)
set_target_properties(test PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%;${AMCAXCommon_RUNTIME_DIR};${AMCAXPart_RUNTIME_DIR}")
endif()

Make Project

Finally, the application is build by the following command line.

mkdir build
cd build
cmake .. -DCMAKE_PREFIX_PATH=/path/to/AMCAXKernel
make

An alternative version can be also applied, by setting the path of each package standalone.

mkdir build
cd build
cmake .. -DAMCAXCommon_DIR=/path/to/AMCAXCommon/cmake/AMCAXCommon -DAMCAXPart_DIR=/path/to/AMCAXPart/cmake/AMCAXPart
make