Project structure

The code developed during this internship is organized into several key components, each responsible for different aspects of the terrain mesh generation and processing workflow. This section provides an overview of the project structure, introducing the main classes and their interactions, as well as the overall workflow.

The project is structured around a few core concepts:

  1. Terrain generators:

    • TerrainGenerator: This is an abstract base class that defines a common interface for all terrain generation methods. It declares a virtual generate() method that is implemented by specific generator classes.

    • LambdaGenerator: A concrete implementation of TerrainGenerator, this class generates a terrain mesh based on a user-defined lambda function. This allows for flexible and customizable terrain generation based on mathematical functions.

    • GpsGenerator: Another implementation of TerrainGenerator, this class generates terrain meshes using real-world elevation data sourced from the Mapbox Terrain-RGB v1 API. It converts geographical coordinates into elevation data, which is then used to construct the mesh.

  2. Data management:

    • ElevationGrid: This class is responsible for managing the grid of elevation data used in the GpsGenerator. It stores elevation values in a 2D grid and provides methods to access and manipulate these values.

    • TileDownloader: This utility class handles the retrieval of elevation data tiles from the Mapbox API. It includes methods for converting geographical coordinates into tile indices, downloading tiles, and decoding the elevation data encoded in the PNG images.

  3. Mesh processing:

    • ContourConstraint: This class applies contour line constraints to the generated terrain mesh, refining the mesh based on the contour lines to ensure that the mesh density is concentrated in areas with significant topographical variation. It uses computational geometry algorithms to achieve this.

The relationships between these classes are illustrated in the following UML diagram:


uml structure
Figure 1. Terrain mesh generation and processing workflow

This diagram represents the flow of data and control in the project. Starting from the terrain generation using either a mathematical function or real-world data, the process moves through contour line generation and finally to mesh refinement. The interactions between the classes ensure that the generated mesh is both accurate and optimized for the specific use case.

This structure lays the groundwork for the more detailed discussions that follow in the subsequent sections:



References