1 | /* |
2 | * Copyright 2016-2018 Uber Technologies, Inc. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | /** @file baseCells.h |
17 | * @brief Base cell related lookup tables and access functions. |
18 | */ |
19 | |
20 | #ifndef BASECELLS_H |
21 | #define BASECELLS_H |
22 | |
23 | #include "constants.h" |
24 | #include "coordijk.h" |
25 | #include "faceijk.h" |
26 | |
27 | /** @struct BaseCellData |
28 | * @brief information on a single base cell |
29 | */ |
30 | typedef struct { |
31 | FaceIJK |
32 | homeFijk; ///< "home" face and normalized ijk coordinates on that face |
33 | int isPentagon; ///< is this base cell a pentagon? |
34 | int cwOffsetPent[2]; ///< if a pentagon, what are its two clockwise offset |
35 | /// faces? |
36 | } BaseCellData; |
37 | |
38 | #define INVALID_BASE_CELL 127 |
39 | extern const int baseCellNeighbors[NUM_BASE_CELLS][7]; |
40 | extern const int baseCellNeighbor60CCWRots[NUM_BASE_CELLS][7]; |
41 | |
42 | // resolution 0 base cell data lookup-table (global) |
43 | extern const BaseCellData baseCellData[NUM_BASE_CELLS]; |
44 | |
45 | /** Maximum input for any component to face-to-base-cell lookup functions */ |
46 | #define MAX_FACE_COORD 2 |
47 | |
48 | // Internal functions |
49 | int _isBaseCellPentagon(int baseCell); |
50 | bool _isBaseCellPolarPentagon(int baseCell); |
51 | int _faceIjkToBaseCell(const FaceIJK* h); |
52 | int _faceIjkToBaseCellCCWrot60(const FaceIJK* h); |
53 | void _baseCellToFaceIjk(int baseCell, FaceIJK* h); |
54 | bool _baseCellIsCwOffset(int baseCell, int testFace); |
55 | int _getBaseCellNeighbor(int baseCell, Direction dir); |
56 | Direction _getBaseCellDirection(int originBaseCell, int destinationBaseCell); |
57 | |
58 | #endif |
59 | |