SyFi
0.3
|
00001 // Copyright (C) 2006-2009 Kent-Andre Mardal and Simula Research Laboratory 00002 // 00003 // This file is part of SyFi. 00004 // 00005 // SyFi is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 2 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // SyFi is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with SyFi. If not, see <http://www.gnu.org/licenses/>. 00017 00018 #ifndef PTV_INCLUDED 00019 #define PTV_INCLUDED 00020 00021 #include <functional> 00022 #include <iostream> 00023 00024 class Ptv 00025 { 00026 00027 public: 00028 unsigned int dim; 00029 double* v; 00030 static double tol; 00031 Ptv(unsigned int size_); 00032 Ptv(unsigned int size_, double* v_); 00033 Ptv(double x, double y); 00034 Ptv(double x, double y, double z); 00035 Ptv(const Ptv& p); 00036 Ptv(); 00037 void redim(unsigned int size_, double *v_); 00038 void redim(unsigned int size_); 00039 void fill(double *v_); 00040 00041 virtual ~Ptv(); 00042 00043 const unsigned int size() const; 00044 00045 const double& operator [] (unsigned int i) const; 00046 double& operator [] (unsigned int i); 00047 Ptv& operator = (const Ptv& p); 00048 00049 bool less(const Ptv& p) const; 00050 00051 }; 00052 00053 struct Ptv_is_less : public std::binary_function<Ptv, Ptv, bool> 00054 { 00055 bool operator() (const Ptv &lh, const Ptv &rh) const { return lh.less(rh); } 00056 }; 00057 00058 class Ptv_match : public std::unary_function<Ptv, bool> 00059 { 00060 protected: 00061 static double tol; 00062 unsigned int d; 00063 double v; 00064 public: 00065 Ptv_match(); 00066 Ptv_match(unsigned int d_, double v_); 00067 virtual ~Ptv_match() {} 00068 bool operator() (const Ptv &p); 00069 }; 00070 00071 std::ostream & operator<< ( std::ostream& os, const Ptv& p); 00072 #endif