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
00031
00032
00033
00034
00035
00036
00037 #ifndef _CHASTEPOINT_HPP_
00038 #define _CHASTEPOINT_HPP_
00039
00040 #include "ChasteSerialization.hpp"
00041 #include "UblasVectorInclude.hpp"
00042 #include <vector>
00043
00044
00048 template<unsigned DIM>
00049 class ChastePoint
00050 {
00052 friend class boost::serialization::access;
00059 template<class Archive>
00060 void serialize(Archive & archive, const unsigned int version)
00061 {
00062
00063 }
00064
00065 private:
00066
00068 c_vector<double, DIM> mLocation;
00069
00070 public:
00071
00086 ChastePoint(double v1=0, double v2=0, double v3=0);
00087
00095 ChastePoint(std::vector<double> coords);
00096
00102 ChastePoint(c_vector<double, DIM> location);
00103
00107 c_vector<double, DIM>& rGetLocation();
00108
00114 double operator[] (unsigned i) const;
00115
00121 double GetWithDefault(unsigned i, double def=0.0) const;
00122
00129 void SetCoordinate(unsigned i, double value);
00130
00137 bool IsSamePoint(const ChastePoint<DIM>& rPoint) const;
00138 };
00139
00140
00141 #include "SerializationExportWrapper.hpp"
00142
00143 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChastePoint)
00144
00145 namespace boost
00146 {
00147 namespace serialization
00148 {
00149
00150 template<class Archive, unsigned SPACE_DIM>
00151 inline void save_construct_data(
00152 Archive & ar, const ChastePoint<SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00153 {
00154 for (unsigned i = 0; i < SPACE_DIM; i ++)
00155 {
00156
00157
00158 double coord = t->GetWithDefault(i);
00159 ar & coord;
00160 }
00161 }
00162
00167 template<class Archive,unsigned SPACE_DIM>
00168 inline void load_construct_data(
00169 Archive & ar, ChastePoint<SPACE_DIM> * t, const unsigned int file_version)
00170 {
00171 std::vector<double> coords;
00172 coords.resize(SPACE_DIM);
00173 for (unsigned i=0; i<SPACE_DIM; i++)
00174 {
00175 double coordinate;
00176 ar & coordinate;
00177 coords[i] = coordinate;
00178 }
00179
00180 ::new(t)ChastePoint<SPACE_DIM>(coords);
00181 }
00182 }
00183 }
00184
00185
00191 template<>
00192 class ChastePoint<0>
00193 {
00194 public:
00203 ChastePoint(double v1=0, double v2=0, double v3=0);
00204
00211 double operator[] (unsigned i) const;
00212 };
00213
00214 #endif //_CHASTEPOINT_HPP_