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 #ifndef CHASTENODESLIST_HPP_
00031 #define CHASTENODESLIST_HPP_
00032
00033 #include "ChasteSerialization.hpp"
00034 #include <boost/serialization/base_object.hpp>
00035
00036 #include "AbstractChasteRegion.hpp"
00037 #include "Node.hpp"
00038 #include "ChastePoint.hpp"
00039
00040 #include <vector>
00041 using namespace std;
00046 template <unsigned SPACE_DIM>
00047 class ChasteNodesList : public AbstractChasteRegion<SPACE_DIM>
00048 {
00050 friend class boost::serialization::access;
00057 template<class Archive>
00058 void serialize(Archive & archive, const unsigned int version)
00059 {
00060 archive & boost::serialization::base_object<AbstractChasteRegion<SPACE_DIM> >(*this);
00061 }
00062
00063 private:
00064
00066 std::vector< Node<SPACE_DIM>*> mListOfNodes;
00067
00069 bool mOwnNodes;
00070
00071 public:
00072
00079 ChasteNodesList(const std::vector<Node<SPACE_DIM>*> rNodesList,
00080 bool ownNodes=false);
00081
00085 ~ChasteNodesList();
00086
00088 const std::vector< Node<SPACE_DIM>*>& rGetNodesList() const;
00089
00095 bool DoesContain(const ChastePoint<SPACE_DIM>& rPointToCheck) const;
00096
00100 unsigned GetSize() const;
00101
00102 };
00103
00104
00105 #include "SerializationExportWrapper.hpp"
00106 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChasteNodesList)
00107
00108 namespace boost
00109 {
00110 namespace serialization
00111 {
00112
00113 template<class Archive, unsigned SPACE_DIM>
00114 inline void save_construct_data(
00115 Archive & ar, const ChasteNodesList<SPACE_DIM> * t, const unsigned int file_version)
00116 {
00117 const std::vector<Node<SPACE_DIM>* > node_list = t->rGetNodesList();
00118
00119
00120 unsigned size = t->GetSize();
00121 ar & size;
00122
00123
00124 std::vector <ChastePoint<SPACE_DIM>* > point_list;
00125
00126 for (unsigned i = 0; i < node_list.size(); i++)
00127 {
00128 c_vector<double, SPACE_DIM> loc = node_list[i]->rGetLocation();
00129 point_list.push_back(new ChastePoint<SPACE_DIM>(loc));
00130 ar & point_list[i];
00131 unsigned index = node_list[i]->GetIndex();
00132 ar & index;
00133 }
00134
00135
00136 for (unsigned i = 0; i < point_list.size(); i++)
00137 {
00138 delete point_list[i];
00139 }
00140 }
00141
00146 template<class Archive, unsigned SPACE_DIM>
00147 inline void load_construct_data(
00148 Archive & ar, ChasteNodesList<SPACE_DIM> * t, const unsigned int file_version)
00149 {
00150
00151 unsigned size;
00152 ar & size;
00153
00154
00155 std::vector<Node<SPACE_DIM>* > node_list;
00156 for (unsigned i = 0; i < size; i++)
00157 {
00158 ChastePoint<SPACE_DIM>* p_point;
00159 unsigned index;
00160 ar & p_point;
00161 ar & index;
00162
00163 Node<SPACE_DIM>* p_node = new Node<SPACE_DIM>( index, *(p_point));
00164 node_list.push_back(p_node);
00165
00166 delete p_point;
00167 }
00168
00169 ::new(t)ChasteNodesList<SPACE_DIM>(node_list, true);
00170 }
00171 }
00172 }
00173
00174 #endif