Boost.Geometry

repository·develop·Indexed 19 days ago

https://github.com/boostorg/geometry

A C++14 header-only library within the Boost collection providing a comprehensive set of concepts, primitives, and algorithms for geometric computations.

Tokens
1.7K
Snippets
6
Records
10
Agent score
68%

What's inside Boost.Geometry

  1. Overview of Boost.Geometry

    develop

    Boost.Geometry is a C++14 header-only library that provides concepts, primitives, and algorithms for solving various geometry problems. As part of the Boost C++ Libraries collection, it is designed to handle geometric computations efficiently using modern C++ standards.

    Key characteristics:

    • Header-only: No separate compilation or linking of library binaries is required; you only need to include the headers.
    • C++14: Requires a compiler that supports the C++14 standard.
    • Extensible: Provides a framework for defining geometric concepts and algorithms.
  2. Install Qt for the Boost.Geometry Qt example

    develop

    To use the Qt-based examples in Boost.Geometry, you must have the Qt framework installed on your system.

    macOS

    Install Qt using Homebrew:

    brew install qt

    Note: You may see a warning Could NOT find WrapVulkanHeaders. You can ignore this for 2D applications, or install vulkan-tools via brew install vulkan-tools to resolve it.

    Linux (Ubuntu)

    For Qt 6.3 or newer, the project uses qt_standard_project_setup().

    If you are using an older version (e.g., Qt 6.2.4 on Ubuntu 22), you must manually configure the CMakeLists.txt by replacing qt_standard_project_setup with the following settings:

    set(CMAKE_CXX_STANDARD 14)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTORCC ON)

    To resolve Vulkan-related compiler errors or warnings, install the Vulkan SDK following the official LunarG instructions.

    Other Platforms

    Follow the official Qt documentation to install Qt and modify CMakeLists.txt as required for your environment.

    brew install qt
  3. Build and install wxWidgets using CMake

    develop

    To use the wxWidgets example, you must first build and install the wxWidgets framework. This guide uses the CMake approach. Ensure you include git submodules during the clone process.

    1. Clone the repository with submodules: git clone --recurse-submodules git@github.com:wxWidgets/wxWidgets.git
    2. Create a build directory inside the wxWidgets folder.
    3. Run cmake .. to configure.
    4. Build the project using cmake --build ..
    5. Install the framework globally using sudo cmake --build . --target install.
    cd ~git
    git clone --recurse-submodules git@github.com:wxWidgets/wxWidgets.git
    cd wxWidgets
    mkdir my_build_folder
    cd my_build_folder
    cmake ..
    cmake --build .
    sudo cmake --build . --target install
  4. Add a new algorithm to the documentation

    develop

    When adding a new algorithm (e.g., foo) to Boost.Geometry, follow these steps to ensure it is correctly documented across the generated manuals and reference guides:

    1. Doxygen Tagging: In boost/geometry/algorithms/foo.hpp, include \ingroup foo in the Doxygen comments.
    2. Doxygen Configuration: If a new directory is created (e.g., boost/geometry/algorithms/detail/foo), add that path to the Doxyfile located in doc/doxy/.
    3. Group Definition: Define the group foo in doc/doxy/doxygen_input/groups/groups.hpp.
    4. Build Script Update: Include the algorithm foo in doc/make_qbk.py.
    5. Reference Inclusion: In doc/reference.qbk, include the generated file: [include generated/foo.qbk].
    6. Quick Reference: Include a section for foo in doc/quickref.xml following the existing pattern.
    7. Support Status (Optional): Update doc/src/docutils/tools/support_status/support_status.cpp in three specific locations to include the algorithm.
    8. Manual Reference (Optional): Create doc/reference/foo.qbk to include support status, custom text, and examples.
    9. Example Inclusion (Optional): If you have an example file doc/src/examples/algorithm/foo.cpp, include it in doc/imports.qbk.
  5. Build documentation using Doxygen and QuickBook

    develop

    To generate the Boost.Geometry documentation, you must use Doxygen, QuickBook, and the doxygen_xml2qbk tool. Note that doxygen_xml2qbk is a tool specific to Boost.Geometry that translates Doxygen-XML output to QuickBook.

    Prerequisites:

    1. Install Doxygen.
    2. Install QuickBook (refer to the official Boost QuickBook installation guide).

    Build Steps:

    1. Build the doxygen_xml2qbk executable by running b2 in src/docutils/tools/doxygen_xml2qbk.
    2. Add the resulting binary to your PATH (e.g., /usr/local/bin/doxygen_xml2qbk).
    3. Execute the Python script make_qbk.py to orchestrate the build process (this script calls doxygen, doxygen_xml2qbk, and bjam).
  6. Locate Boost.Geometry examples and documentation

    develop

    If you are looking for ways to use the library, the repository contains several directories for learning and implementation:

    • Standalone Examples: Located in the example/ directory.
    • QuickBook Documentation: Sources are in doc/, with embedded code examples found in doc/src/examples/.
    • Spatial Index Examples: Located in the index/ directory.
    • Library Source: The core header files are located in the include/ directory.
  7. Build the Boost.Geometry Qt example with CMake

    develop

    The Qt example is built using CMake and Ninja. Follow these steps to build the project from the example/with_external_libs/qt directory:

    1. Navigate to the example directory.
    2. Create and enter a build directory.
    3. Run CMake with the Ninja generator.
    4. Execute the build using Ninja.
    cd example/with_external_libs/qt
    mkdir my_build_folder
    cd my_build_folder
    cmake .. -G Ninja
    ninja
  8. Run the Boost.Geometry Qt example

    develop

    The Qt example (e.g., qt_world_mapper) accepts an Ascii file containing WKT (Well-Known Text) polygons as its first command-line argument. Boost.Geometry includes several WKT files in its data/ directory for testing.

    Example execution on macOS:

    ././qt_world_mapper.app/Contents/MacOS/qt_world_mapper ../../../data/world.wkt
    ././qt_world_mapper.app/Contents/MacOS/qt_world_mapper ../../../data/world.wkt