File indexing completed on 2024-04-28 07:31:41
0001 #ifndef _SpatialEdge_h 0002 #define _SpatialEdge_h 0003 0004 //# Filename: SpatialEdge.h 0005 //# 0006 //# SpatialEdge is a helper class for the spatial index at construction 0007 //# time. 0008 //# 0009 //# Author: Peter Z. Kunszt, based on A. Szalay's code 0010 //# 0011 //# Date: October 15, 1998 0012 //# 0013 //# SPDX-FileCopyrightText: 2000 Peter Z. Kunszt Alex S. Szalay, Aniruddha R. Thakar 0014 //# The Johns Hopkins University 0015 //# 0016 //# Modification History: 0017 //# 0018 //# Oct 18, 2001 : Dennis C. Dinge -- Replaced ValVec with std::vector 0019 //# 0020 0021 #include "SpatialIndex.h" 0022 0023 // Forward declarations 0024 class SpatialIndex; 0025 0026 //######################################################################## 0027 // 0028 // <GROUP> 0029 // <SUMMARY>Class declarations</SUMMARY> 0030 // 0031 0032 //######################################################################## 0033 // 0034 // <SUMMARY> Spatial Edge class </SUMMARY> 0035 // 0036 // The Edges are needed at construction time of the spatial index. 0037 // They are used to generate the midpoints of the nodes in a certain layer. 0038 // The interface is simple: construct a class giving it the SpatialIndex 0039 // and the layer number. Then call makeMidPoints. The SpatialIndex will 0040 // then have its midpoint constructed in every QuadNode. 0041 0042 class LINKAGE SpatialEdge 0043 { 0044 public: 0045 // Constructor : give the tree and its layer 0046 SpatialEdge(SpatialIndex &tree, size_t layerindex); 0047 0048 // Destructor 0049 ~SpatialEdge(); 0050 0051 // Interface to class: generate midpoints. 0052 void makeMidPoints(); 0053 0054 private: 0055 struct Edge 0056 { 0057 size_t start_; // starting vertex index of edge 0058 size_t end_; // index of end 0059 size_t mid_; // index of center 0060 }; 0061 0062 // Make a new edge, in the temporary edges_ at emindex, at node_[index] 0063 // using the k'th side. Since every edge belongs to two faces, we have] 0064 // to check whether an edge has been already processed or not (i.e. the 0065 // midpoint has been constructed or not). We have a lookup table for 0066 // this purpose. Every edge is stored at lTab[start_]. There may be 0067 // up to 6 edges in every vertex[start_] so if that table place is occupied, 0068 // store it in the next table position (and so on). So we only have to 0069 // look up 6 positions at most. 0070 size_t newEdge(size_t emindex, size_t index, int k); 0071 0072 // insert the edge em into the lookup table 0073 void insertLookup(Edge *em); 0074 0075 // lookup the edge em in the lookup table 0076 Edge *edgeMatch(Edge *em); 0077 0078 // generate a new vertex, which is the midpoint of the current edge. 0079 size_t getMidPoint(Edge *em); 0080 0081 SpatialIndex &tree_; // reference to the tree class 0082 size_t layerindex_; // index of the layer 0083 Edge **lTab_; // Edges lookup table 0084 Edge *edges_; // Edges array 0085 size_t index_; // index of the vertex that is built 0086 }; 0087 0088 // </GROUP> 0089 // 0090 0091 #endif