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 "AbstractTetrahedralMesh.hpp"
00033 #include "NodeBoxCollection.hpp"
00034
00035 #include <boost/serialization/access.hpp>
00036 #include <boost/serialization/base_object.hpp>
00037 #include <boost/serialization/set.hpp>
00038 #include <boost/serialization/vector.hpp>
00039
00044 template<unsigned DIM>
00045 class NodeBasedTissue : public AbstractCellCentreBasedTissue<DIM>
00046 {
00047 friend class TestNodeBasedTissue;
00048 friend class TestNodeBoxCollection;
00049 private:
00050
00052 std::vector<Node<DIM>* > mNodes;
00053
00055 std::vector<unsigned> mDeletedNodeIndices;
00056
00058 bool mAddedNodes;
00059
00061 NodeBoxCollection<DIM> *mpNodeBoxCollection;
00062
00064 c_vector<double, DIM> mMinSpatialPositions;
00065
00067 c_vector<double, DIM> mMaxSpatialPositions;
00068
00070 std::set< std::pair<Node<DIM>*, Node<DIM>* > > mNodePairs;
00071
00075 bool mDeleteNodes;
00076
00078 friend class boost::serialization::access;
00088 template<class Archive>
00089 void serialize(Archive & archive, const unsigned int version)
00090 {
00091 archive & boost::serialization::base_object<AbstractCellCentreBasedTissue<DIM> >(*this);
00092
00093 Validate();
00094 }
00095
00104 unsigned AddNode(Node<DIM>* pNewNode);
00105
00112 void SetNode(unsigned nodeIndex, ChastePoint<DIM>& rNewLocation);
00113
00117 void Validate();
00118
00125 void SplitUpIntoBoxes(double cutOffLength, c_vector<double, 2*DIM> domainSize);
00126
00130 void FindMaxAndMin();
00131
00132 public:
00133
00144 NodeBasedTissue(const std::vector<Node<DIM>* > nodes,
00145 const std::vector<TissueCell>& rCells,
00146 const std::vector<unsigned> locationIndices=std::vector<unsigned>(),
00147 bool deleteNodes=true);
00148
00158 NodeBasedTissue(const std::vector<Node<DIM>* > nodes, bool deleteNodes=true);
00159
00170 NodeBasedTissue(const AbstractMesh<DIM,DIM>& rMesh,
00171 const std::vector<TissueCell>& rCells);
00172
00178 ~NodeBasedTissue();
00179
00183 unsigned GetNumNodes();
00184
00192 Node<DIM>* GetNode(unsigned index);
00193
00203 unsigned RemoveDeadCells();
00204
00209 void Clear();
00210
00216 void Update(bool hasHadBirthsOrDeaths=true);
00217
00223 std::vector<Node<DIM>* >& rGetNodes();
00224
00230 const std::vector<Node<DIM>* >& rGetNodes() const;
00231
00235 NodeBoxCollection<DIM>* GetNodeBoxCollection();
00236
00240 std::set< std::pair<Node<DIM>*, Node<DIM>* > >& rGetNodePairs();
00241 };
00242
00243
00244 #include "TemplatedExport.hpp"
00245 EXPORT_TEMPLATE_CLASS_SAME_DIMS(NodeBasedTissue)
00246
00247 namespace boost {
00248 namespace serialization {
00249
00253 template<class Archive, unsigned SPACE_DIM>
00254 inline void save(
00255 Archive & ar,
00256 const Node<SPACE_DIM>& rNode,
00257 const unsigned int )
00258 {
00259
00260 const bool is_deleted = rNode.IsDeleted();
00261 ar << is_deleted;
00262 }
00263
00267 template<class Archive, unsigned SPACE_DIM>
00268 inline void load(
00269 Archive & ar,
00270 Node<SPACE_DIM>& rNode,
00271 const unsigned int )
00272 {
00273
00274 bool is_deleted;
00275 ar >> is_deleted;
00276 #define COVERAGE_IGNORE
00277 if (is_deleted)
00278 {
00279 rNode.MarkAsDeleted();
00280 }
00281 #undef COVERAGE_IGNORE
00282 }
00283
00284
00289 template<class Archive, unsigned SPACE_DIM>
00290 inline void serialize(
00291 Archive & ar,
00292 Node<SPACE_DIM>& rNode,
00293 const unsigned int file_version)
00294 {
00295 boost::serialization::split_free(ar, rNode, file_version);
00296 }
00297
00298
00302 template<class Archive, unsigned DIM>
00303 inline void save_construct_data(
00304 Archive & ar, const Node<DIM> * t, const BOOST_PFTO unsigned int file_version)
00305 {
00306
00307 const unsigned index = t->GetIndex();
00308 ar << index;
00309
00310
00311 const bool is_boundary = t->IsBoundaryNode();
00312 ar << is_boundary;
00313
00314
00315 const c_vector<double, DIM>& r_loc = t->rGetLocation();
00316 for (unsigned i=0; i<DIM; i++)
00317 {
00318 ar << r_loc[i];
00319 }
00320 }
00321
00325 template<class Archive, unsigned DIM>
00326 inline void load_construct_data(
00327 Archive & ar, Node<DIM> * t, const unsigned int file_version)
00328 {
00329
00330 unsigned index;
00331 ar >> index;
00332
00333
00334 bool is_boundary;
00335 ar >> is_boundary;
00336
00337
00338 c_vector<double, DIM> loc;
00339 for (unsigned i=0; i<DIM; i++)
00340 {
00341 ar >> loc[i];
00342 }
00343
00344
00345 ::new(t)Node<DIM>(index, loc, is_boundary);
00346 }
00347
00348
00352 template<class Archive, unsigned DIM>
00353 inline void save_construct_data(
00354 Archive & ar, const NodeBasedTissue<DIM> * t, const BOOST_PFTO unsigned int file_version)
00355 {
00356 ar & t->rGetNodes();
00357 }
00358
00362 template<class Archive, unsigned DIM>
00363 inline void load_construct_data(
00364 Archive & ar, NodeBasedTissue<DIM> * t, const unsigned int file_version)
00365 {
00366
00367 std::vector<Node<DIM>* > nodes;
00368 ar >> nodes;
00369
00370
00371 ::new(t)NodeBasedTissue<DIM>(nodes);
00372 }
00373
00374 }}
00375
00376
00377 #endif