00001 /**************************************************************************** 00002 * VCGLib o o * 00003 * Visual and Computer Graphics Library o o * 00004 * _ O _ * 00005 * Copyright(C) 2004 \/)\/ * 00006 * Visual Computing Lab /\/| * 00007 * ISTI - Italian National Research Council | * 00008 * \ * 00009 * All rights reserved. * 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This program is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 00020 * for more details. * 00021 * * 00022 ****************************************************************************/ 00023 /**************************************************************************** 00024 History 00025 00026 $Log: not supported by cvs2svn $ 00027 00028 ****************************************************************************/ 00029 00030 #ifndef VCG_BMT_H 00031 #define VCG_BMT_H 00032 00033 #include <string> 00034 #include <vector> 00035 00036 #include <vcg/space/sphere3.h> 00037 #include <wrap/mt/mt.h> 00038 00039 namespace vcg { 00040 00048 class Bmt { 00049 public: 00051 class Cell { 00052 public: 00053 //this effectively limits databases to 4Gb in size. 00054 unsigned int offset; 00055 float error; 00056 Sphere3f sphere; 00057 float Error() { return error; } 00058 }; 00059 00061 unsigned int signature; 00063 Sphere3f sphere; 00064 00065 std::vector<Cell> index; 00066 std::vector< MT<Bmt::Cell>::Update > history; 00067 00068 00069 00070 Bmt(); 00071 ~Bmt(); 00072 bool Load(const std::string &filename); 00073 char *GetData(unsigned int &size, unsigned int offset); 00074 00075 private: 00076 FILE *fp; 00077 unsigned int index_offset; 00078 unsigned int index_size; 00079 unsigned int history_offset; 00080 unsigned int history_size; 00081 }; 00082 00083 class BmtBuilder { 00084 public: 00085 BmtBuilder(); 00086 ~BmtBuilder(); 00087 00089 unsigned int signature; 00091 Sphere3f sphere; 00092 std::vector<Bmt::Cell> index; 00093 std::vector<std::vector<unsigned int > > creation; 00094 std::vector<std::vector<unsigned int > > deletion; 00095 00096 bool Create(unsigned int signature); 00097 00098 unsigned int AddCell(Bmt::Cell cell, unsigned int size, char *data); 00099 void AddUpdate(std::vector<unsigned int> &created, std::vector<unsigned int> &erased); 00100 00101 bool Save(const std::string &filename); 00102 private: 00103 FILE *ftmp; 00104 FILE *fout; 00105 }; 00106 00107 float Distance(Bmt::Cell &cell, Point3f &p); 00108 00109 }//end namespace 00110 00111 #endif