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
00036 #include <vector>
00037
00038 #include "Exception.hpp"
00039
00043 template<unsigned DIM>
00044 class ChastePoint
00045 {
00047 friend class boost::serialization::access;
00054 template<class Archive>
00055 void serialize(Archive & archive, const unsigned int version)
00056 {
00057
00058 }
00059
00060 private:
00061
00063 c_vector<double, DIM> mLocation;
00064
00065 public:
00066
00081 ChastePoint(double v1=0, double v2=0, double v3=0);
00082
00090 ChastePoint(std::vector<double> coords);
00091
00097 ChastePoint(c_vector<double, DIM> location);
00098
00102 c_vector<double, DIM>& rGetLocation();
00103
00109 double operator[] (unsigned i) const;
00110
00116 double GetWithDefault(unsigned i, double def=0.0) const;
00117
00124 void SetCoordinate(unsigned i, double value);
00125
00132 bool IsSamePoint(const ChastePoint<DIM>& rPoint) const;
00133 };
00134
00135
00136 #include "SerializationExportWrapper.hpp"
00137
00138 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChastePoint)
00139
00140 namespace boost
00141 {
00142 namespace serialization
00143 {
00144
00145 template<class Archive, unsigned SPACE_DIM>
00146 inline void save_construct_data(
00147 Archive & ar, const ChastePoint<SPACE_DIM> * t, const BOOST_PFTO unsigned int file_version)
00148 {
00149 for (unsigned i = 0; i < SPACE_DIM; i ++)
00150 {
00151
00152
00153 double coord = t->GetWithDefault(i);
00154 ar & coord;
00155 }
00156 }
00157
00162 template<class Archive,unsigned SPACE_DIM>
00163 inline void load_construct_data(
00164 Archive & ar, ChastePoint<SPACE_DIM> * t, const unsigned int file_version)
00165 {
00166 std::vector<double> coords;
00167 coords.resize(SPACE_DIM);
00168 for (unsigned i = 0 ; i < SPACE_DIM; i ++)
00169 {
00170 double coordinate;
00171 ar & coordinate;
00172 coords[i] = coordinate;
00173 }
00174
00175 ::new(t)ChastePoint<SPACE_DIM>(coords);
00176 }
00177 }
00178 }
00179
00183 template<>
00184 class ChastePoint<0>
00185 {
00186 public:
00187
00196 ChastePoint(double v1=0, double v2=0, double v3=0)
00197 {
00198 }
00199
00205 double operator[] (unsigned i) const
00206 {
00207 EXCEPTION("Zero-dimensional point has no data");
00208 }
00209 };
00210
00211
00212 #endif //_CHASTEPOINT_HPP_