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
00112 const c_vector<double, DIM>& rGetLocation() const;
00113
00119 double operator[] (unsigned i) const;
00120
00126 double GetWithDefault(unsigned i, double def=0.0) const;
00127
00134 void SetCoordinate(unsigned i, double value);
00135
00142 bool IsSamePoint(const ChastePoint<DIM>& rPoint) const;
00143 };
00144
00145
00146 #include "SerializationExportWrapper.hpp"
00147
00148 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChastePoint)
00149
00150 namespace boost
00151 {
00152 namespace serialization
00153 {
00154
00155 template<class Archive, unsigned SPACE_DIM>
00156 inline void save_construct_data(
00157 Archive & ar, const ChastePoint<SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00158 {
00159 for (unsigned i = 0; i < SPACE_DIM; i ++)
00160 {
00161
00162
00163 double coord = t->GetWithDefault(i);
00164 ar & coord;
00165 }
00166 }
00167
00172 template<class Archive,unsigned SPACE_DIM>
00173 inline void load_construct_data(
00174 Archive & ar, ChastePoint<SPACE_DIM> * t, const unsigned int file_version)
00175 {
00176 std::vector<double> coords;
00177 coords.resize(SPACE_DIM);
00178 for (unsigned i=0; i<SPACE_DIM; i++)
00179 {
00180 double coordinate;
00181 ar & coordinate;
00182 coords[i] = coordinate;
00183 }
00184
00185 ::new(t)ChastePoint<SPACE_DIM>(coords);
00186 }
00187 }
00188 }
00189
00190
00196 template<>
00197 class ChastePoint<0>
00198 {
00199 public:
00208 ChastePoint(double v1=0, double v2=0, double v3=0);
00209
00216 double operator[] (unsigned i) const;
00217 };
00218
00219 #endif //_CHASTEPOINT_HPP_