ChastePoint.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CHASTEPOINT_HPP_
00031 #define _CHASTEPOINT_HPP_
00032
00033 #include "ChasteSerialization.hpp"
00034 #include "UblasVectorInclude.hpp"
00035 #include <vector>
00036
00037
00041 template<unsigned DIM>
00042 class ChastePoint
00043 {
00045 friend class boost::serialization::access;
00052 template<class Archive>
00053 void serialize(Archive & archive, const unsigned int version)
00054 {
00055
00056 }
00057
00058 private:
00059
00061 c_vector<double, DIM> mLocation;
00062
00063 public:
00064
00079 ChastePoint(double v1=0, double v2=0, double v3=0);
00080
00088 ChastePoint(std::vector<double> coords);
00089
00095 ChastePoint(c_vector<double, DIM> location);
00096
00100 c_vector<double, DIM>& rGetLocation();
00101
00107 double operator[] (unsigned i) const;
00108
00114 double GetWithDefault(unsigned i, double def=0.0) const;
00115
00122 void SetCoordinate(unsigned i, double value);
00123
00130 bool IsSamePoint(const ChastePoint<DIM>& rPoint) const;
00131 };
00132
00133
00134 #include "SerializationExportWrapper.hpp"
00135
00136 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChastePoint)
00137
00138 namespace boost
00139 {
00140 namespace serialization
00141 {
00142
00143 template<class Archive, unsigned SPACE_DIM>
00144 inline void save_construct_data(
00145 Archive & ar, const ChastePoint<SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00146 {
00147 for (unsigned i = 0; i < SPACE_DIM; i ++)
00148 {
00149
00150
00151 double coord = t->GetWithDefault(i);
00152 ar & coord;
00153 }
00154 }
00155
00160 template<class Archive,unsigned SPACE_DIM>
00161 inline void load_construct_data(
00162 Archive & ar, ChastePoint<SPACE_DIM> * t, const unsigned int file_version)
00163 {
00164 std::vector<double> coords;
00165 coords.resize(SPACE_DIM);
00166 for (unsigned i=0; i<SPACE_DIM; i++)
00167 {
00168 double coordinate;
00169 ar & coordinate;
00170 coords[i] = coordinate;
00171 }
00172
00173 ::new(t)ChastePoint<SPACE_DIM>(coords);
00174 }
00175 }
00176 }
00177
00178
00184 template<>
00185 class ChastePoint<0>
00186 {
00187 public:
00196 ChastePoint(double v1=0, double v2=0, double v3=0);
00197
00204 double operator[] (unsigned i) const;
00205 };
00206
00207 #endif //_CHASTEPOINT_HPP_