stt/README.md

205 lines
6.3 KiB
Markdown
Raw Normal View History

2024-09-10 16:01:52 +08:00
## Spherical Triangular Tessellation (STT) Generator
### Introduction
2025-01-15 22:42:06 +08:00
The spherical triangular tessellation (STT) is a method to partition a spherical surface into triangular cells. This program generates STT based on an icosahedron and provides various refinement options:
2024-09-10 16:01:52 +08:00
2025-01-15 22:42:06 +08:00
1. Geometric refinement around:
- Points
- Lines
- Polygons
- Circles
2. Topographic refinement based on elevation data
3. Customizable exterior and interior boundaries
2024-09-10 16:01:52 +08:00
2025-02-03 11:46:18 +08:00
### Technical Details
#### Core Algorithm
1. **Base Structure**
- Starts with an icosahedron (20 triangular faces)
- Uses quad-tree data structure for adaptive refinement
- Each face of the icosahedron becomes the root of a quad-tree
2. **Refinement Process**
- Adaptive refinement based on various constraints
- Uses vector calculations for spherical geometry
- Supports multiple levels of refinement (controlled by depth parameter)
3. **Constraint Types**
- Point constraints: Refines mesh around specific points
- Line constraints: Refines along great circle paths
- Polygon constraints: Refines within or around polygon boundaries
- Circle constraints: Refines within spherical caps
- Topographic constraints: Refines based on elevation data
4. **Coordinate Systems**
- Supports multiple reference systems:
* WGS84 ellipsoid
* Spherical Earth
* Lunar sphere
* Custom ellipsoid
* Custom flattened sphere
- Configurable orientation of the base icosahedron
### Algorithm Details
1. **Initialization**
- Creates base icosahedron
- Sets up coordinate system and orientation
- Initializes quad-tree structure
2. **Refinement Process**
- Reads constraint files
- For each triangle:
* Tests intersection with constraints
* Subdivides if needed based on depth and resolution
* Maintains neighbor relationships
3. **Output Generation**
- Generates final mesh
- Computes vertex locations
- Creates neighbor lists
- Exports in various formats
4. **Memory Management**
- Uses dynamic allocation for tree structures
- Automatically cleans up temporary data
- Efficient handling of large datasets
2025-01-15 22:42:06 +08:00
### Files and folders
2024-09-10 16:01:52 +08:00
2025-01-15 22:42:06 +08:00
1. **CMakeLists.txt**: CMake project configuration file
2. **src/**: Source code directory containing all implementation files
3. **doc/**: Example files and test cases
4. **README.md**: Documentation (this file)
5. **archived/**: Legacy source files (for reference only)
2024-09-10 16:01:52 +08:00
### Installation
2025-02-03 11:46:18 +08:00
To compile and install using [CMake](https://cmake.org):
2024-09-10 16:01:52 +08:00
```shell
mkdir build
cd build
2025-01-15 22:42:06 +08:00
cmake ..
make
2024-09-10 16:01:52 +08:00
make install
```
### Usage
```bash
2025-01-15 22:42:06 +08:00
Usage: stt -d<minimal-depth>/<maximal-depth> [options]
Required:
-d<min>/<max> Minimal and maximal depths of the quad-tree structure
2025-02-03 11:46:18 +08:00
Example: -d3/7 for refinement from depth 3 to 7
2025-01-15 22:42:06 +08:00
Optional:
-r<ref> Coordinate reference system:
- 'WGS84': WGS84 ellipsoid
- 'Earth': Spherical Earth
- 'Moon': Lunar sphere
- <eq-rad>/<pole-rad>: Custom ellipsoid
- <eq-rad>,<flat-rate>: Custom flattened sphere
-o<lon>/<lat> Orientation of icosahedron top vertex
2025-02-03 11:46:18 +08:00
Default: 0/90 (North Pole)
2025-01-15 22:42:06 +08:00
Output options:
-m<file> Output Gmsh(.msh) mesh file
-v<file> Output vertices' locations
-t<file> Output triangle centers
-n<file> Output triangle neighbors
Refinement control:
-p<file> Control points file
-l<file> Control lines file
-g<file> Control polygons file
-c<file> Control circles file
-t<file> Topography control file
-s<file> Outline shape file
-k<file> Hole shape file
-z<file> Topography data file
Help:
-h Show this help message
2024-09-10 16:01:52 +08:00
```
2025-01-15 22:42:06 +08:00
### Input File Formats
2024-09-10 16:01:52 +08:00
2025-01-15 22:42:06 +08:00
#### Point Control Format
2025-02-03 11:46:18 +08:00
Controls refinement around specific points. Each point is defined by its location and refinement parameters:
2024-09-10 16:01:52 +08:00
```bash
# <longitude> <latitude> <maximal-depth> <minimal-resolution> <physical-group>
2025-02-03 11:46:18 +08:00
# longitude, latitude: Coordinates in degrees
# maximal-depth: Maximum refinement depth for this point
# minimal-resolution: Minimum cell size in degrees
# physical-group: Group identifier for the refined region
2024-09-10 16:01:52 +08:00
-45 -45 5 1.0 7
45 -45 5 1.0 7
```
2025-01-15 22:42:06 +08:00
#### Circle Control Format
2025-02-03 11:46:18 +08:00
Controls refinement around spherical caps. Each circle is defined by its center, radius, and refinement parameters:
2024-09-10 16:01:52 +08:00
```bash
# <longitude> <latitude> <spherical-cap-degree> <maximal-depth> <minimal-resolution> <physical-group>
2025-02-03 11:46:18 +08:00
# spherical-cap-degree: Angular radius of the cap in degrees
2024-09-10 16:01:52 +08:00
45 60 30 5 0.1 12
-20 -45 20 6 0.1 13
```
2025-01-15 22:42:06 +08:00
#### Line/Polygon Control Format
2025-02-03 11:46:18 +08:00
Controls refinement along lines or around polygons. Each shape is defined by a sequence of points and refinement parameters:
2024-09-10 16:01:52 +08:00
```bash
2025-01-15 22:42:06 +08:00
# First line: <number-of-points> <maximal-depth> <minimal-resolution> <physical-group>
# Following lines: <longitude> <latitude> of each point
2025-02-03 11:46:18 +08:00
# Points are connected in sequence, last point connects to first for polygons
2024-09-10 16:01:52 +08:00
4 6 0.1 5
-10 10
50 15
60 55
-15 50
```
2025-01-15 22:42:06 +08:00
#### Topography Control Format
2025-02-03 11:46:18 +08:00
Controls refinement based on elevation data. The refinement is based on elevation variation within triangles:
2025-01-15 22:42:06 +08:00
```bash
# First line: <maximum-STD> <maximal-depth> <minimal-resolution> <physical-group>
# Following lines: <longitude> <latitude> <elevation(meters)>
2025-02-03 11:46:18 +08:00
# maximum-STD: Maximum allowed standard deviation of elevation within a triangle
2025-01-15 22:42:06 +08:00
200.0 10 -1 5
-179.95 89.95 -4203.20
-179.85 89.95 -4203.07
-179.75 89.95 -4203.47
```
2025-02-03 11:46:18 +08:00
Note: maximum-STD represents the maximum standard deviation of elevation allowed in a triangle. A triangle will be refined if the elevation variation within it exceeds this threshold.
2025-01-15 22:42:06 +08:00
2024-09-10 16:01:52 +08:00
### Examples
2025-01-15 22:42:06 +08:00
1. Multi-resolution STT with geometric constraints:
2024-09-10 16:01:52 +08:00
```bash
2025-02-03 11:46:18 +08:00
# Creates a mesh with depth range 3-7, refined around lines, polygons and circles
2024-09-10 16:01:52 +08:00
stt -d 3/7 -m example.msh -l doc/control_lines.txt -g doc/control_poly.txt -c doc/control_circle.txt
```
2025-02-03 11:46:18 +08:00
2024-09-10 16:01:52 +08:00
![stt-example](doc/stt-example.png)
2025-01-15 22:42:06 +08:00
2. Topography-constrained STT:
```bash
2025-02-03 11:46:18 +08:00
# Creates a mesh with depth range 6-10, refined based on topography data
2025-01-15 22:42:06 +08:00
stt -d 6/10 -m topo_example.msh -t doc/control_topo.txt
```
2025-02-03 11:46:18 +08:00
2025-01-15 22:42:06 +08:00
![topo-example](doc/topo_constraint.png)
2025-02-03 11:46:18 +08:00
### Contact
For any bug reports or you need some help. Please contact Dr. Yi Zhang ([yizhang-geo@zju.edu.cn](yizhang-geo@zju.edu.cn)).