$ show pageldev/libOpenDRIVE
libOpenDRIVE is a C++17 library that parses OpenDRIVE (.xodr) road network definition files and generates 3D mesh models for visualization and simulation. The architecture is a classic object-oriented library with a central OpenDriveMap class that loads an XML file and exposes roads, junctions, lanes, road marks, objects, and signals. Key modules include geometry types (Line, Arc, Spiral, ParamPoly3), cubic spline profiles for elevation and lane offsets, a routing graph based on lane connectivity, and multi-resolution mesh generation with triangle strips. The library is dependency-light, relying only on pugixml for XML parsing and a bundled Fresnel integral implementation for spirals. It provides efficient coordinate transforms, surface point queries, and boundary approximation using RamerβDouglasβPeucker or bezier decomposition. Tests using Catch2 validate parsing and routing against a real-world test file.
The LLM identified 3 files worth highlighting for reuse:
A fully templated, self-contained CubicBezier class for 1D and 2D curves. It computes control points from polynomial coefficients, evaluates points and derivatives, builds an arclength-to-parameter map via linear approximation, and supports subcurve extraction. The linear approximation method uses quadratic bezier decomposition with adaptive step sizing, making it efficient and accurate. This component can be extracted with only the Math and Util headers for use in any geometry engine.
A template-heavy math header providing Vec, Mat types with operations like addition, subtraction, scaling, dot product, cross product, Euler angle to rotation matrix conversion, and vector normalization. It does not depend on any internal library headers and uses modern C++ constexpr and SFINAE. The EulerAnglesToMatrix function is particularly clean and reusable for 3D transformations. Can serve as a lightweight math foundation for any project requiring 2D/3D vector algebra.
A collection of generic utility functions: golden section search for unimodal function minimization, RamerβDouglasβPeucker polyline simplification, map key/value extraction, constexpr class member comparison templates (used for generating comparator specializations), and helper to generate triangle strip outline indices. The RDP implementation is iterative and uses pointer arithmetic for efficiency. The class member comparison macros reduce boilerplate for sorted containers. This file is dependency-free on internal types and can be adapted for any C++17 project.