Chaste  Build::
VesselNetwork.hpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4  All rights reserved.
5 
6  University of Oxford means the Chancellor, Masters and Scholars of the
7  University of Oxford, having an administrative office at Wellington
8  Square, Oxford OX1 2JD, UK.
9 
10  This file is part of Chaste.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34  */
35 
36 #ifndef VESSELNETWORK_HPP_
37 #define VESSELNETWORK_HPP_
38 
39 #include <vector>
40 #include <set>
41 #include <map>
42 #include "Vessel.hpp"
43 #include "VesselSegment.hpp"
44 #include "VesselNode.hpp"
45 #include "UblasIncludes.hpp"
46 #include "UnitCollection.hpp"
47 #include "AbstractVesselNetworkComponent.hpp"
48 
52 template<unsigned DIM>
53 class VesselNetwork : public boost::enable_shared_from_this<VesselNetwork<DIM> >, public AbstractVesselNetworkComponent<DIM>
54 {
55 
56 private:
57 
61  std::vector<boost::shared_ptr<Vessel<DIM> > > mVessels;
62 
66  std::vector<boost::shared_ptr<VesselSegment<DIM> > > mSegments;
67 
72 
76  std::vector<boost::shared_ptr<VesselNode<DIM> > > mNodes;
77 
82 
86  std::vector<boost::shared_ptr<VesselNode<DIM> > > mVesselNodes;
87 
92 
93 public:
94 
98  VesselNetwork();
99 
104  static boost::shared_ptr<VesselNetwork<DIM> > Create();
105 
109  virtual ~VesselNetwork();
110 
115  void AddVessel(boost::shared_ptr<Vessel<DIM> > pVessel);
116 
121  void AddVessels(std::vector<boost::shared_ptr<Vessel<DIM> > > vessels);
122 
127  void CopySegmentFlowProperties(unsigned index=0);
128 
133  std::vector<boost::shared_ptr<Vessel<DIM> > > CopyVessels();
134 
140  std::vector<boost::shared_ptr<Vessel<DIM> > > CopyVessels(std::vector<boost::shared_ptr<Vessel<DIM> > > vessels);
141 
148  virtual boost::shared_ptr<VesselNode<DIM> > DivideVessel(boost::shared_ptr<Vessel<DIM> > pVessel,
149  const DimensionalChastePoint<DIM>& rLocation);
150 
157  virtual void ExtendVessel(boost::shared_ptr<Vessel<DIM> > pVessel, boost::shared_ptr<VesselNode<DIM> > pEndNode,
158  boost::shared_ptr<VesselNode<DIM> > pNewNode);
159 
166  virtual boost::shared_ptr<Vessel<DIM> > FormSprout(const DimensionalChastePoint<DIM>& sproutBaseLocation,
167  const DimensionalChastePoint<DIM>& sproutTipLocation);
168 
174  units::quantity<unit::length> GetDistanceToNearestNode(const DimensionalChastePoint<DIM>& rLocation);
175 
181  boost::shared_ptr<VesselNode<DIM> > GetNearestNode(const DimensionalChastePoint<DIM>& rLocation);
182 
188  boost::shared_ptr<VesselNode<DIM> > GetNearestNode(boost::shared_ptr<VesselNode<DIM> > pInputNode);
189 
195  std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > GetNearestSegment(boost::shared_ptr<VesselSegment<DIM> > pSegment);
196 
203  std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > GetNearestSegment(boost::shared_ptr<VesselNode<DIM> > pNode,
204  bool sameVessel = true);
205 
211  std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > GetNearestSegment(const DimensionalChastePoint<DIM>& rLocation);
212 
218  boost::shared_ptr<Vessel<DIM> > GetNearestVessel(const DimensionalChastePoint<DIM>& rLocation);
219 
225  unsigned GetNodeIndex(boost::shared_ptr<VesselNode<DIM> > pNode);
226 
233  unsigned NumberOfNodesNearLocation(const DimensionalChastePoint<DIM>& rLocation, double tolerance = 0.0);
234 
240  std::pair<DimensionalChastePoint<DIM>, DimensionalChastePoint<DIM> > GetExtents(bool useRadii = false);
241 
248  boost::shared_ptr<VesselNode<DIM> > GetNode(unsigned index);
249 
254  std::vector<boost::shared_ptr<VesselNode<DIM> > > GetNodes();
255 
260  unsigned GetNumberOfNodes();
261 
266  unsigned GetNumberOfVesselNodes();
267 
272  unsigned GetNumberOfVessels();
273 
278  unsigned GetMaxBranchesOnNode();
279 
284  std::map<std::string, double> GetOutputData();
285 
290  std::vector<boost::shared_ptr<VesselNode<DIM> > > GetVesselEndNodes();
291 
297  unsigned GetVesselIndex(boost::shared_ptr<Vessel<DIM> > pVessel);
298 
304  unsigned GetVesselSegmentIndex(boost::shared_ptr<VesselSegment<DIM> > pVesselSegment);
305 
310  std::vector<boost::shared_ptr<VesselSegment<DIM> > > GetVesselSegments();
311 
317  boost::shared_ptr<Vessel<DIM> > GetVessel(unsigned index);
318 
323  std::vector<boost::shared_ptr<Vessel<DIM> > > GetVessels();
324 
330  bool NodeIsInNetwork(boost::shared_ptr<VesselNode<DIM> > pSourceNode);
331 
336  void MergeShortVessels(units::quantity<unit::length> cutoff = 10.0 * 1.e-6 * unit::metres);
337 
343  void MergeCoincidentNodes(double tolerance = 0.0);
344 
351  void MergeCoincidentNodes(std::vector<boost::shared_ptr<Vessel<DIM> > > pVessels, double tolerance = 0.0);
352 
359  void MergeCoincidentNodes(std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes, double tolerance = 0.0);
360 
366  void RemoveVessel(boost::shared_ptr<Vessel<DIM> > pVessel, bool deleteVessel = false);
367 
373  void RemoveShortVessels(units::quantity<unit::length> cutoff = 10.0* 1.e-6 * unit::metres, bool endsOnly = true);
374 
379  void SetNodeRadii(units::quantity<unit::length> radius);
380 
385 
390  void SetSegmentProperties(boost::shared_ptr<VesselSegment<DIM> > prototype);
391 
396  void SetSegmentRadii(units::quantity<unit::length> radius);
397 
402  void SetSegmentViscosity(units::quantity<unit::dynamic_viscosity> viscosity);
403 
408  void Translate(DimensionalChastePoint<DIM> rTranslationVector);
409 
415  void Translate(DimensionalChastePoint<DIM> rTranslationVector, std::vector<boost::shared_ptr<Vessel<DIM> > > vessels);
416 
420  void UpdateNodes();
421 
425  void UpdateSegments();
426 
430  void UpdateVesselNodes();
431 
435  void UpdateVesselIds();
436 
441  void UpdateAll(bool merge=false);
442 
450  bool VesselCrossesLineSegment(const DimensionalChastePoint<DIM>& rCoord1, const DimensionalChastePoint<DIM>& rCoord2, double tolerance = 1e-6);
451 
456  void Write(const std::string& rFileName);
457 
458 };
459 
460 #endif /* VESSELNETWORK_HPP_ */
virtual boost::shared_ptr< Vessel< DIM > > FormSprout(const DimensionalChastePoint< DIM > &sproutBaseLocation, const DimensionalChastePoint< DIM > &sproutTipLocation)
void CopySegmentFlowProperties(unsigned index=0)
void MergeShortVessels(units::quantity< unit::length > cutoff=10.0 *1.e-6 *unit::metres)
std::pair< DimensionalChastePoint< DIM >, DimensionalChastePoint< DIM > > GetExtents(bool useRadii=false)
void RemoveShortVessels(units::quantity< unit::length > cutoff=10.0 *1.e-6 *unit::metres, bool endsOnly=true)
boost::shared_ptr< Vessel< DIM > > GetNearestVessel(const DimensionalChastePoint< DIM > &rLocation)
std::vector< boost::shared_ptr< VesselNode< DIM > > > GetVesselEndNodes()
std::vector< boost::shared_ptr< VesselSegment< DIM > > > GetVesselSegments()
unsigned GetNumberOfVessels()
bool VesselCrossesLineSegment(const DimensionalChastePoint< DIM > &rCoord1, const DimensionalChastePoint< DIM > &rCoord2, double tolerance=1e-6)
void SetNodeRadiiFromSegments()
void UpdateAll(bool merge=false)
virtual void ExtendVessel(boost::shared_ptr< Vessel< DIM > > pVessel, boost::shared_ptr< VesselNode< DIM > > pEndNode, boost::shared_ptr< VesselNode< DIM > > pNewNode)
unsigned GetNodeIndex(boost::shared_ptr< VesselNode< DIM > > pNode)
void AddVessel(boost::shared_ptr< Vessel< DIM > > pVessel)
void SetSegmentProperties(boost::shared_ptr< VesselSegment< DIM > > prototype)
static boost::shared_ptr< VesselNetwork< DIM > > Create()
boost::shared_ptr< VesselNode< DIM > > GetNearestNode(const DimensionalChastePoint< DIM > &rLocation)
unsigned GetVesselIndex(boost::shared_ptr< Vessel< DIM > > pVessel)
boost::shared_ptr< VesselNode< DIM > > GetNode(unsigned index)
unsigned NumberOfNodesNearLocation(const DimensionalChastePoint< DIM > &rLocation, double tolerance=0.0)
void Write(const std::string &rFileName)
bool NodeIsInNetwork(boost::shared_ptr< VesselNode< DIM > > pSourceNode)
std::vector< boost::shared_ptr< VesselSegment< DIM > > > mSegments
void SetSegmentViscosity(units::quantity< unit::dynamic_viscosity > viscosity)
std::vector< boost::shared_ptr< Vessel< DIM > > > mVessels
unsigned GetNumberOfVesselNodes()
bool mVesselNodesUpToDate
std::pair< boost::shared_ptr< VesselSegment< DIM > >, units::quantity< unit::length > > GetNearestSegment(boost::shared_ptr< VesselSegment< DIM > > pSegment)
void Translate(DimensionalChastePoint< DIM > rTranslationVector)
void MergeCoincidentNodes(double tolerance=0.0)
void SetNodeRadii(units::quantity< unit::length > radius)
boost::shared_ptr< Vessel< DIM > > GetVessel(unsigned index)
void SetSegmentRadii(units::quantity< unit::length > radius)
virtual boost::shared_ptr< VesselNode< DIM > > DivideVessel(boost::shared_ptr< Vessel< DIM > > pVessel, const DimensionalChastePoint< DIM > &rLocation)
std::vector< boost::shared_ptr< VesselNode< DIM > > > mNodes
void UpdateVesselNodes()
void AddVessels(std::vector< boost::shared_ptr< Vessel< DIM > > > vessels)
unsigned GetVesselSegmentIndex(boost::shared_ptr< VesselSegment< DIM > > pVesselSegment)
virtual ~VesselNetwork()
std::vector< boost::shared_ptr< VesselNode< DIM > > > mVesselNodes
units::quantity< unit::length > GetDistanceToNearestNode(const DimensionalChastePoint< DIM > &rLocation)
std::vector< boost::shared_ptr< VesselNode< DIM > > > GetNodes()
unsigned GetMaxBranchesOnNode()
std::vector< boost::shared_ptr< Vessel< DIM > > > GetVessels()
std::map< std::string, double > GetOutputData()
std::vector< boost::shared_ptr< Vessel< DIM > > > CopyVessels()
unsigned GetNumberOfNodes()
void RemoveVessel(boost::shared_ptr< Vessel< DIM > > pVessel, bool deleteVessel=false)