PrCellStructure.h

00001 //===========================================================================
00002 // GoTools - SINTEF Geometry Tools version 1.1
00003 //
00004 // GoTools module: parametrization
00005 //
00006 // Copyright (C) 2000-2005 SINTEF ICT, Applied Mathematics, Norway.
00007 //
00008 // This program is free software; you can redistribute it and/or          
00009 // modify it under the terms of the GNU General Public License            
00010 // as published by the Free Software Foundation version 2 of the License. 
00011 //
00012 // This program is distributed in the hope that it will be useful,        
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of         
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          
00015 // GNU General Public License for more details.                           
00016 //
00017 // You should have received a copy of the GNU General Public License      
00018 // along with this program; if not, write to the Free Software            
00019 // Foundation, Inc.,                                                      
00020 // 59 Temple Place - Suite 330,                                           
00021 // Boston, MA  02111-1307, USA.                                           
00022 //
00023 // Contact information: E-mail: tor.dokken@sintef.no                      
00024 // SINTEF ICT, Department of Applied Mathematics,                         
00025 // P.O. Box 124 Blindern,                                                 
00026 // 0314 Oslo, Norway.                                                     
00027 //
00028 // Other licenses are also available for this software, notably licenses
00029 // for:
00030 // - Building commercial software.                                        
00031 // - Building software whose source code you wish to keep private.        
00032 //===========================================================================
00033 #ifndef PRCELLSTRUCTURE_H
00034 #define PRCELLSTRUCTURE_H
00035 
00036 #include "Array.h"
00037 using Go::Vector3D;
00038 #include <vector>
00039 using std::vector;
00040 using std::istream;
00041 using std::ostream;
00042 
00043 /*<PrCellStructure-syntax: */
00044 
00053 class PrCellStructure
00054 {
00055 private:
00056     vector<Vector3D> xyz_;
00057     //VecSimplest(CgPoint3d) xyz_;
00058     int n_; // no points,
00059     double min_[3]; // min value in each coordinate
00060     int ncells_[3]; // number of cells in each coordinate
00061     double cell_size_; // dimension of cell, each cell is a cube
00062     vector<vector<int> > ind_;
00063     //VecSimplest(PrIntList) ind_;
00064     int max_no_cells_;
00065 
00066     void makeCellStructure();
00067 
00068 public:
00070     PrCellStructure() {}
00077     PrCellStructure(int n, double* xyz_points, int max_no_cells = 10);
00078 
00080     virtual ~PrCellStructure() {};
00081 
00086     void      attach(int n, const double* xyz_points);
00087 
00091     void      setNumCells(int max_no_cells) {max_no_cells_ = max_no_cells; }
00092 
00095     int       getNumCells() const {return max_no_cells_; }
00096 
00098     int       getNumNodes() const {return xyz_.size(); }
00099 
00101     Vector3D get3dNode(int i) const {return xyz_[i]; }
00102 
00106     void       set3dNode(int i, const Vector3D& p) 
00107     {xyz_[i].x() = p.x(); xyz_[i].y() = p.y(); xyz_[i].z() = p.z();}
00108 
00117     void getBall(const Vector3D& p, double radius,
00118                  vector<int>& neighbours, int notP = 0) const;
00119 
00128     void getKNearest(const Vector3D& p, int k,
00129                      vector<int>& neighbours, int notP = 0) const;
00130 
00132     int getI(int i, int j, int k) const
00133     {return i + ncells_[0] * (j + ncells_[1] * k); }
00134 
00136     void getIJK(int ii, int& i, int& j, int& k) const;
00137 
00143     void whichCell(const Vector3D& xyz, int& i, int& j, int& k) const;
00144 
00145     //print and scan routines
00147     void print(ostream& os);
00148 
00150     void scan(istream& is);
00151 };
00152 
00153 /*>PrCellStructure-syntax: */
00154 
00155 /*Class:PrCellStructure
00156 
00157 Name:              PrCellStructure
00158 Syntax:            @PrCellStructure-syntax
00159 Keywords:
00160 Description:       This class represents a set of points in three dimensions
00161                    and a cell structure: a 3D grid of cubical cells
00162                    each with a local list of those points which lie inside it.
00163                    This allows one to perform various queries, such as
00164                    finding all points in a ball, very efficiently.
00165                    Creating the cell structure requires only O(N) operations,
00166                    where $N$ is the number of points.
00167 Member functions:
00168 
00169 Constructors:
00170 Files:
00171 Example:
00172 
00173 
00174 See also:
00175 Developed by:      SINTEF Applied Mathematics, Oslo, Norway
00176 Author:            Michael Floater, SINTEF
00177 Date:              Sep. 99
00178 */
00179 
00180 #endif // PRCELLSTRUCTURE_H

Generated on Tue Jun 12 11:05:05 2007 for GoTools Parametrization Library by  doxygen 1.5.1