ChasteNodesList.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 CHASTENODESLIST_HPP_
00038 #define CHASTENODESLIST_HPP_
00039
00040 #include "ChasteSerialization.hpp"
00041 #include <boost/serialization/base_object.hpp>
00042
00043 #include "AbstractChasteRegion.hpp"
00044 #include "Node.hpp"
00045 #include "ChastePoint.hpp"
00046
00047 #include <vector>
00048 using namespace std;
00053 template <unsigned SPACE_DIM>
00054 class ChasteNodesList : public AbstractChasteRegion<SPACE_DIM>
00055 {
00057 friend class boost::serialization::access;
00064 template<class Archive>
00065 void serialize(Archive & archive, const unsigned int version)
00066 {
00067 archive & boost::serialization::base_object<AbstractChasteRegion<SPACE_DIM> >(*this);
00068 }
00069
00070 private:
00071
00073 std::vector< Node<SPACE_DIM>*> mListOfNodes;
00074
00076 bool mOwnNodes;
00077
00078 public:
00079
00086 ChasteNodesList(const std::vector<Node<SPACE_DIM>*> rNodesList,
00087 bool ownNodes=false);
00088
00092 ~ChasteNodesList();
00093
00095 const std::vector< Node<SPACE_DIM>*>& rGetNodesList() const;
00096
00102 bool DoesContain(const ChastePoint<SPACE_DIM>& rPointToCheck) const;
00103
00107 unsigned GetSize() const;
00108
00109 };
00110
00111
00112 #include "SerializationExportWrapper.hpp"
00113 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChasteNodesList)
00114
00115 namespace boost
00116 {
00117 namespace serialization
00118 {
00119
00120 template<class Archive, unsigned SPACE_DIM>
00121 inline void save_construct_data(
00122 Archive & ar, const ChasteNodesList<SPACE_DIM> * t, const unsigned int file_version)
00123 {
00124 const std::vector<Node<SPACE_DIM>* > node_list = t->rGetNodesList();
00125
00126
00127 unsigned size = t->GetSize();
00128 ar & size;
00129
00130
00131 std::vector <ChastePoint<SPACE_DIM>* > point_list;
00132
00133 for (unsigned i = 0; i < node_list.size(); i++)
00134 {
00135 c_vector<double, SPACE_DIM> loc = node_list[i]->rGetLocation();
00136 point_list.push_back(new ChastePoint<SPACE_DIM>(loc));
00137 ar & point_list[i];
00138 unsigned index = node_list[i]->GetIndex();
00139 ar & index;
00140 }
00141
00142
00143 for (unsigned i = 0; i < point_list.size(); i++)
00144 {
00145 delete point_list[i];
00146 }
00147 }
00148
00153 template<class Archive, unsigned SPACE_DIM>
00154 inline void load_construct_data(
00155 Archive & ar, ChasteNodesList<SPACE_DIM> * t, const unsigned int file_version)
00156 {
00157
00158 unsigned size;
00159 ar & size;
00160
00161
00162 std::vector<Node<SPACE_DIM>* > node_list;
00163 for (unsigned i = 0; i < size; i++)
00164 {
00165 ChastePoint<SPACE_DIM>* p_point;
00166 unsigned index;
00167 ar & p_point;
00168 ar & index;
00169
00170 Node<SPACE_DIM>* p_node = new Node<SPACE_DIM>( index, *(p_point));
00171 node_list.push_back(p_node);
00172
00173 delete p_point;
00174 }
00175
00176 ::new(t)ChasteNodesList<SPACE_DIM>(node_list, true);
00177 }
00178 }
00179 }
00180
00181 #endif