The Tiny HTM Library
include/tinyhtm/htm.h
Go to the documentation of this file.
00001 
00014 #ifndef HTM_HTM_H
00015 #define HTM_HTM_H
00016 
00017 #include "geometry.h"
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 
00029 #define HTM_MAX_LEVEL 24
00030 
00032 #define HTM_DEC_MAX_LEVEL 18
00033 
00036 enum htm_root {
00037     HTM_S0 = 0,
00038     HTM_S1 = 1,
00039     HTM_S2 = 2,
00040     HTM_S3 = 3,
00041     HTM_N0 = 4,
00042     HTM_N1 = 5,
00043     HTM_N2 = 6,
00044     HTM_N3 = 7,
00045     HTM_NROOTS = 8
00046 };
00047 
00050 struct htm_ids {
00051     size_t n;   
00052     size_t cap; 
00053     struct htm_range range[]; 
00057 };
00058 
00061 struct htm_v3p {
00062     struct htm_v3 v;  
00063     void * payload;   
00064 } HTM_ALIGNED(16);
00065 
00068 struct htm_tri {
00069     struct htm_v3 verts[3]; 
00070     struct htm_v3 center;   
00071     double radius;          
00072     int64_t id;             
00073     int level;              
00074 };
00075 
00076 
00082 int64_t htm_v3_id(const struct htm_v3 *point, int level);
00083 
00093 enum htm_errcode htm_v3p_idsort(struct htm_v3p *points,
00094                                 int64_t *ids,
00095                                 size_t n,
00096                                 int level);
00097 
00101 int htm_level(int64_t id);
00102 
00110 enum htm_errcode htm_tri_init(struct htm_tri *tri, int64_t id);
00111 
00155 struct htm_ids * htm_s2circle_ids(struct htm_ids *ids,
00156                                   const struct htm_v3 *center,
00157                                   double radius,
00158                                   int level,
00159                                   size_t maxranges,
00160                                   enum htm_errcode *err);
00161 
00204 struct htm_ids * htm_s2ellipse_ids(struct htm_ids *ids,
00205                                    const struct htm_s2ellipse *ellipse,
00206                                    int level,
00207                                    size_t maxranges,
00208                                    enum htm_errcode *err);
00209 
00210 
00253 struct htm_ids * htm_s2cpoly_ids(struct htm_ids *ids,
00254                                  const struct htm_s2cpoly *poly,
00255                                  int level,
00256                                  size_t maxranges,
00257                                  enum htm_errcode *err);
00258 
00265 int64_t htm_idtodec(int64_t id);
00266 
00270 #ifdef __cplusplus
00271 }
00272 #endif
00273 
00274 #endif /* HTM_HTM_H */
00275