#ifndef _SpatialEdge_h #define _SpatialEdge_h /* //# Filename: SpatialEdge.h //# //# SpatialEdge is a helper class for the spatial index at construction //# time. //# //# //# Author: Peter Z. Kunszt, based on A. Szalay's code //# //# Date: October 15, 1998 //# //# //# //# (c) Copyright The Johns Hopkins University 1998 //# All Rights Reserved //# //# The software and information contained herein are proprietary to The //# Johns Hopkins University, Copyright 1998. This software is furnished //# pursuant to a written license agreement and may be used, copied, //# transmitted, and stored only in accordance with the terms of such //# license and with the inclusion of the above copyright notice. This //# software and information or any other copies thereof may not be //# provided or otherwise made available to any other person. //# //# */ #include "SpatialIndex.h" /* //######################################################################## // // // Class declarations // //######################################################################## // // Spatial Edge class // // The Edges are needed at construction time of the spatial index. // They are used to generate the midpoints of the nodes in a certain layer. // The interface is simple: construct a class giving it the SpatialIndex // and the layer number. Then call makeMidPoints. The SpatialIndex will // then have its midpoint constructed in every QuadNode. */ typedef struct { size_t start_; /* starting vertex index of edge */ size_t end_; /* index of end */ size_t mid_; /* index of center */ } Edge; typedef struct { SpatialIndex * tree_; /* reference to the tree class */ size_t layerindex_; /* index of the layer */ Edge ** lTab_; /* Edges lookup table */ Edge * edges_; /* Edges array */ size_t index_; /* index of the vertex that is built */ } SpatialEdge; /* Constructor : give the tree and its layer */ SpatialEdge * spatialEdgeNew(SpatialIndex * tree, size_t layerindex ); /* Destructor */ void spatialEdgeDelete( SpatialEdge * ); /* Interface to class: generate midpoints. */ void spatialEdgeMakeMidPoints( SpatialEdge * ); /* Make a new edge, in the temporary edges_ at emindex, at node_[index] * using the k'th side. Since every edge belongs to two faces, we have] * to check wether an edge has been already processed or not (i.e. the * midpoint has been constructed or not). We have a lookup table for * this purpose. Every edge is stored at lTab[start_]. There may be * up to 6 edges in every vertex[start_] so if that table place is occupied, * store it in the next table position (and so on). So we only have to * look up 6 positions at most. */ size_t spatialEdgeNewEdge( SpatialEdge *, size_t emindex, size_t index, int k); /* insert the edge em into the lookup table */ void spatialEdgeInsertLookup( SpatialEdge *, Edge *em ); /* lookup the edge em in the lookup table */ Edge * spatialEdgeEdgeMatch( SpatialEdge *, Edge *em ); /* generate a new vertex, which is the midpoint of the current edge. */ size_t spatialEdgeGetMidPoint( SpatialEdge *, Edge * em ); #endif