|
||||
File indexing completed on 2024-11-15 09:58:11
0001 // -*- C++ -*- 0002 /////////////////////////////////////////////////////////////////////////////// 0003 // File: quadtree.h // 0004 // Description: header file for quadtree management (Cquadtree class) // 0005 // This file is part of the SISCone project. // 0006 // For more details, see http://projects.hepforge.org/siscone // 0007 // // 0008 // Copyright (c) 2006 Gavin Salam and Gregory Soyez // 0009 // // 0010 // This program is free software; you can redistribute it and/or modify // 0011 // it under the terms of the GNU General Public License as published by // 0012 // the Free Software Foundation; either version 2 of the License, or // 0013 // (at your option) any later version. // 0014 // // 0015 // This program is distributed in the hope that it will be useful, // 0016 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 0017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 0018 // GNU General Public License for more details. // 0019 // // 0020 // You should have received a copy of the GNU General Public License // 0021 // along with this program; if not, write to the Free Software // 0022 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 0023 // // 0024 // $Revision:: $// 0025 // $Date:: $// 0026 /////////////////////////////////////////////////////////////////////////////// 0027 0028 #ifndef __QUADTREE_H__ 0029 #define __QUADTREE_H__ 0030 0031 #include "momentum.h" 0032 #include <stdio.h> 0033 0034 namespace siscone{ 0035 0036 /** 0037 * \class Cquadtree 0038 * \brief Implementation of a 2D quadtree. 0039 * 0040 * This class implements the traditional two-dimensional quadtree. 0041 * The elements at each node are of 'Cmomentum' type. 0042 */ 0043 class Cquadtree{ 0044 public: 0045 /// default ctor 0046 Cquadtree(); 0047 0048 /// ctor with initialisation (see init for details) 0049 Cquadtree(double _x, double _y, double _half_size_x, double _half_size_y); 0050 0051 /// default destructor 0052 /// at destruction, everything is destroyed except 0053 /// physical values at the leaves 0054 ~Cquadtree(); 0055 0056 /** 0057 * init the tree. 0058 * By initializing the tree, we mean setting the cell parameters 0059 * and preparing the object to act as a seed for a new tree. 0060 * \param _x x-position of the center 0061 * \param _y y-position of the center 0062 * \param _half_size_x x-size of the cell 0063 * \param _half_size_y y-size of the cell 0064 * \return 0 on success, 1 on error. Note that if the cell or its 0065 * parent is already filled, we return an error. 0066 */ 0067 int init(double _x, double _y, double _half_size_x, double _half_size_y); 0068 0069 /** 0070 * adding a particle to the tree. 0071 * This method adds one vector to the quadtree structure which 0072 * is updated consequently. 0073 * \param v_add vector to add 0074 * \return 0 on success 1 on error 0075 */ 0076 int add(Cmomentum *v_add); 0077 0078 /** 0079 * circle intersection. 0080 * computes the intersection with a circle of given centre and radius. 0081 * The output takes the form of a quadtree with all squares included 0082 * in the circle. 0083 * \param cx circle centre x coordinate 0084 * \param cy circle centre y coordinate 0085 * \param cR2 circle radius SQUARED 0086 * \return the checksum for that intersection 0087 */ 0088 Creference circle_intersect(double cx, double cy, double cR2); 0089 0090 /** 0091 * output a data file for drawing the grid. 0092 * This can be used to output a data file containing all the 0093 * grid subdivisions. The file contents is as follows: 0094 * first and second columns give center of the cell, the third 0095 * gives the size. 0096 * \param flux opened stream to write to 0097 * \return 0 on success, 1 on error 0098 */ 0099 int save(FILE *flux); 0100 0101 /** 0102 * output a data file for drawing the tree leaves. 0103 * This can be used to output a data file containing all the 0104 * tree leaves. The file contents is as follows: 0105 * first and second columns give center of the cell, the third 0106 * gives the size. 0107 * \param flux opened stream to write to 0108 * \return 0 on success, 1 on error 0109 */ 0110 int save_leaves(FILE *flux); 0111 0112 double centre_x; ///< x-position of the centre of the cell 0113 double centre_y; ///< y-position of the centre of the cell 0114 double half_size_x; ///< HALF size of the cell 0115 double half_size_y; ///< HALF size of the cell 0116 0117 Cmomentum *v; ///< physical contents 0118 0119 Cquadtree* children[2][2]; ///< sub-cells ( 0,1->left-right; 0,1->bottom,top) 0120 bool has_child; ///< true if not a leaf 0121 }; 0122 0123 } 0124 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |