00001 #ifndef _SpatialEdge_h 00002 #define _SpatialEdge_h 00003 00004 //# Filename: SpatialEdge.h 00005 //# 00006 //# SpatialEdge is a helper class for the spatial index at construction 00007 //# time. 00008 //# 00009 //# Author: Peter Z. Kunszt, based on A. Szalay's code 00010 //# 00011 //# Date: October 15, 1998 00012 //# 00013 //# Copyright (C) 2000 Peter Z. Kunszt, Alex S. Szalay, Aniruddha R. Thakar 00014 //# The Johns Hopkins University 00015 //# 00016 //# Modification History: 00017 //# 00018 //# Oct 18, 2001 : Dennis C. Dinge -- Replaced ValVec with std::vector 00019 //# 00020 00021 #include "SpatialIndex.h" 00022 00023 00024 // Forward declarations 00025 class SpatialIndex; 00026 00027 //######################################################################## 00028 // 00029 // <GROUP> 00030 // <SUMMARY>Class declarations</SUMMARY> 00031 // 00032 00033 //######################################################################## 00034 // 00035 // <SUMMARY> Spatial Edge class </SUMMARY> 00036 // 00037 // The Edges are needed at construction time of the spatial index. 00038 // They are used to generate the midpoints of the nodes in a certain layer. 00039 // The interface is simple: construct a class giving it the SpatialIndex 00040 // and the layer number. Then call makeMidPoints. The SpatialIndex will 00041 // then have its midpoint constructed in every QuadNode. 00042 00043 class LINKAGE SpatialEdge { 00044 public: 00045 // Constructor : give the tree and its layer 00046 SpatialEdge(SpatialIndex & tree, size_t layerindex); 00047 00048 // Destructor 00049 ~SpatialEdge(); 00050 00051 // Interface to class: generate midpoints. 00052 void makeMidPoints(); 00053 00054 private: 00055 struct Edge { 00056 size_t start_; // starting vertex index of edge 00057 size_t end_; // index of end 00058 size_t mid_; // index of center 00059 }; 00060 00061 // Make a new edge, in the temporary edges_ at emindex, at node_[index] 00062 // using the k'th side. Since every edge belongs to two faces, we have] 00063 // to check wether an edge has been already processed or not (i.e. the 00064 // midpoint has been constructed or not). We have a lookup table for 00065 // this purpose. Every edge is stored at lTab[start_]. There may be 00066 // up to 6 edges in every vertex[start_] so if that table place is occupied, 00067 // store it in the next table position (and so on). So we only have to 00068 // look up 6 positions at most. 00069 size_t newEdge(size_t emindex, size_t index, int k); 00070 00071 // insert the edge em into the lookup table 00072 void insertLookup(Edge *em); 00073 00074 // lookup the edge em in the lookup table 00075 Edge * edgeMatch(Edge *em); 00076 00077 // generate a new vertex, which is the midpoint of the current edge. 00078 size_t getMidPoint(Edge * em); 00079 00080 SpatialIndex & tree_; // reference to the tree class 00081 size_t layerindex_; // index of the layer 00082 Edge ** lTab_; // Edges lookup table 00083 Edge * edges_; // Edges array 00084 size_t index_; // index of the vertex that is built 00085 }; 00086 00087 // </GROUP> 00088 // 00089 00090 #endif