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 #ifndef NODEBASEDTISSUE_HPP_
00029 #define NODEBASEDTISSUE_HPP_
00030
00031 #include "AbstractCellCentreBasedTissue.hpp"
00032 #include "AbstractMesh.hpp"
00033
00034 #include <boost/serialization/access.hpp>
00035 #include <boost/serialization/base_object.hpp>
00036 #include <boost/serialization/set.hpp>
00037 #include <boost/serialization/vector.hpp>
00038
00043 template<unsigned DIM>
00044 class NodeBasedTissue : public AbstractCellCentreBasedTissue<DIM>
00045 {
00046 friend class TestNodeBasedTissue;
00047 private:
00048
00050 std::vector<Node<DIM>* > mNodes;
00051
00053 std::vector<unsigned> mDeletedNodeIndices;
00054
00056 bool mAddedNodes;
00057
00059 friend class boost::serialization::access;
00069 template<class Archive>
00070 void serialize(Archive & archive, const unsigned int version)
00071 {
00072 archive & boost::serialization::base_object<AbstractCellCentreBasedTissue<DIM> >(*this);
00073
00074 Validate();
00075 }
00076
00085 unsigned AddNode(Node<DIM>* pNewNode);
00086
00093 void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation);
00094
00098 void Validate();
00099
00103 bool mDeleteNodes;
00104
00105 public:
00106
00117 NodeBasedTissue(const std::vector<Node<DIM>* > nodes,
00118 const std::vector<TissueCell>& rCells,
00119 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00120 bool deleteNodes=true);
00121
00131 NodeBasedTissue(const std::vector<Node<DIM>* > nodes, bool deleteNodes=true);
00132
00144 NodeBasedTissue(const AbstractMesh<DIM,DIM>& rMesh,
00145 const std::vector<TissueCell>& rCells);
00146
00152 ~NodeBasedTissue();
00153
00157 unsigned GetNumNodes();
00158
00166 Node<DIM>* GetNode(unsigned index);
00167
00177 unsigned RemoveDeadCells();
00178
00182 void Clear();
00183
00187 void Update();
00188
00194 std::vector<Node<DIM>* >& rGetNodes();
00195
00201 const std::vector<Node<DIM>* >& rGetNodes() const;
00202
00203 };
00204
00205
00206 #include "TemplatedExport.hpp"
00207 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodeBasedTissue)
00208
00209 namespace boost {
00210 namespace serialization {
00211
00215 template<class Archive, unsigned SPACE_DIM>
00216 inline void save(
00217 Archive & ar,
00218 const Node<SPACE_DIM> &rNode,
00219 const unsigned int )
00220 {
00221
00222 const bool is_deleted = rNode.IsDeleted();
00223 ar << is_deleted;
00224 }
00225
00229 template<class Archive, unsigned SPACE_DIM>
00230 inline void load(
00231 Archive & ar,
00232 Node<SPACE_DIM> &rNode,
00233 const unsigned int )
00234 {
00235
00236 bool is_deleted;
00237 ar >> is_deleted;
00238 #define COVERAGE_IGNORE
00239 if (is_deleted)
00240 {
00241 rNode.MarkAsDeleted();
00242 }
00243 #undef COVERAGE_IGNORE
00244 }
00245
00246
00251 template<class Archive, unsigned SPACE_DIM>
00252 inline void serialize(
00253 Archive & ar,
00254 Node<SPACE_DIM>& rNode,
00255 const unsigned int file_version)
00256 {
00257 boost::serialization::split_free(ar, rNode, file_version);
00258 }
00259
00260
00264 template<class Archive, unsigned DIM>
00265 inline void save_construct_data(
00266 Archive & ar, const Node<DIM> * t, const BOOST_PFTO unsigned int file_version)
00267 {
00268
00269 const unsigned index = t->GetIndex();
00270 ar << index;
00271
00272
00273 const bool is_boundary = t->IsBoundaryNode();
00274 ar << is_boundary;
00275
00276
00277 const c_vector<double, DIM>& r_loc = t->rGetLocation();
00278 for (unsigned i=0; i<DIM; i++)
00279 {
00280 ar << r_loc[i];
00281 }
00282 }
00283
00287 template<class Archive, unsigned DIM>
00288 inline void load_construct_data(
00289 Archive & ar, Node<DIM> * t, const unsigned int file_version)
00290 {
00291
00292 unsigned index;
00293 ar >> index;
00294
00295
00296 bool is_boundary;
00297 ar >> is_boundary;
00298
00299
00300 c_vector<double, DIM> loc;
00301 for (unsigned i=0; i<DIM; i++)
00302 {
00303 ar >> loc[i];
00304 }
00305
00306
00307 ::new(t)Node<DIM>(index, loc, is_boundary);
00308 }
00309
00310
00314 template<class Archive, unsigned DIM>
00315 inline void save_construct_data(
00316 Archive & ar, const NodeBasedTissue<DIM> * t, const BOOST_PFTO unsigned int file_version)
00317 {
00318 ar & t->rGetNodes();
00319 }
00320
00324 template<class Archive, unsigned DIM>
00325 inline void load_construct_data(
00326 Archive & ar, NodeBasedTissue<DIM> * t, const unsigned int file_version)
00327 {
00328
00329 std::vector<Node<DIM>* > nodes;
00330 ar >> nodes;
00331
00332
00333 ::new(t)NodeBasedTissue<DIM>(nodes);
00334 }
00335
00336 }}
00337
00338
00339 #endif