38 #include "SmartPointers.hpp" 39 #include "OutputFileHandler.hpp" 40 #include "SegmentFlowProperties.hpp" 41 #include "VesselNetwork.hpp" 42 #include "VesselNetworkWriter.hpp" 44 template <
unsigned DIM>
48 mSegmentsUpToDate(false),
50 mNodesUpToDate(false),
52 mVesselNodesUpToDate(false)
57 template <
unsigned DIM>
63 template <
unsigned DIM>
70 template <
unsigned DIM>
79 template <
unsigned DIM>
88 template <
unsigned DIM>
91 boost::shared_ptr<SegmentFlowProperties<DIM> > properties =
GetVesselSegments()[index]->GetFlowProperties();
92 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
93 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator it;
94 for(it = segments.begin(); it != segments.end(); it++)
96 (*it)->SetFlowProperties(*properties);
100 template <
unsigned DIM>
106 template <
unsigned DIM>
109 typename std::vector<boost::shared_ptr<Vessel<DIM> > >::iterator vessel_iter;
110 std::vector<boost::shared_ptr<Vessel<DIM> > > new_vessels;
111 for(vessel_iter = vessels.begin(); vessel_iter != vessels.end(); vessel_iter++)
113 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator segment_iter;
114 std::vector<boost::shared_ptr<VesselSegment<DIM> > > new_segments;
115 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments = (*vessel_iter)->GetSegments();
116 for(segment_iter = segments.begin(); segment_iter != segments.end(); segment_iter++)
129 template <
unsigned DIM>
133 boost::shared_ptr<VesselSegment<DIM> > p_segment;
136 if (pVessel->GetStartNode()->IsCoincident(location) || pVessel->GetEndNode()->IsCoincident(location))
139 if (pVessel->GetStartNode()->IsCoincident(location))
141 return pVessel->GetStartNode();
145 return pVessel->GetEndNode();
150 bool locatedInsideVessel =
false;
151 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments = pVessel->GetSegments();
152 for (
unsigned idx = 0; idx < segments.size(); idx++)
154 if (segments[idx]->GetDistance(location)/segments[idx]->GetNode(0)->GetReferenceLengthScale() <= 1e-6)
156 locatedInsideVessel =
true;
157 p_segment = segments[idx];
161 if(!locatedInsideVessel)
163 EXCEPTION(
"There is no segment at the requested division location.");
167 boost::shared_ptr<VesselNode<DIM> > p_new_node = pVessel->DivideSegment(location);
170 std::vector<boost::shared_ptr<VesselSegment<DIM> > > start_segments;
171 std::vector<boost::shared_ptr<VesselSegment<DIM> > > end_segments;
172 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments = pVessel->GetSegments();
173 unsigned segment_index = segments.size()+1;
174 for (
unsigned idx = 0; idx < segments.size(); idx++)
176 start_segments.push_back(segments[idx]);
177 if (segments[idx]->
GetNode(1)->IsCoincident(location))
184 if (segment_index == segments.size()-1)
186 EXCEPTION(
"Vessel segment not found.");
188 for (
unsigned idx = segment_index+1; idx < segments.size(); idx++)
190 end_segments.push_back(segments[idx]);
195 p_new_vessel1->CopyDataFromExistingVessel(pVessel);
196 p_new_vessel2->CopyDataFromExistingVessel(pVessel);
197 p_new_vessel1->GetFlowProperties()->SetRegressionTime(pVessel->GetFlowProperties()->GetRegressionTime());
198 p_new_vessel2->GetFlowProperties()->SetRegressionTime(pVessel->GetFlowProperties()->GetRegressionTime());
210 template <
unsigned DIM>
214 if(pVessel->GetStartNode() == pEndNode)
217 p_segment->SetFlowProperties(*(pEndNode->GetSegments()[0]->GetFlowProperties()));
218 p_segment->SetRadius(pEndNode->GetSegments()[0]->GetRadius());
219 pVessel->AddSegment(p_segment);
224 p_segment->SetFlowProperties(*(pEndNode->GetSegments()[0]->GetFlowProperties()));
225 p_segment->SetRadius(pEndNode->GetSegments()[0]->GetRadius());
226 pVessel->AddSegment(p_segment);
234 template <
unsigned DIM>
239 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > nearest_segment =
GetNearestSegment(sproutBaseLocation);
240 if (nearest_segment.second / nearest_segment.first->GetNode(0)->GetReferenceLengthScale() > 1e-6)
242 EXCEPTION(
"No vessel located at sprout base.");
246 boost::shared_ptr<VesselNode<DIM> > p_new_node =
DivideVessel(nearest_segment.first->GetVessel(), sproutBaseLocation);
250 p_new_node_at_tip->SetLocation(sproutTipLocation);
251 p_new_node_at_tip->SetIsMigrating(
true);
252 p_new_node_at_tip->GetFlowProperties()->SetIsInputNode(
false);
253 p_new_node_at_tip->GetFlowProperties()->SetIsOutputNode(
false);
255 p_new_segment->CopyDataFromExistingSegment(nearest_segment.first);
256 p_new_segment->GetFlowProperties()->SetFlowRate(0.0*unit::metre_cubed_per_second);
257 p_new_segment->GetFlowProperties()->SetImpedance(0.0*unit::pascal_second_per_metre_cubed);
258 p_new_segment->GetFlowProperties()->SetHaematocrit(0.0);
259 p_new_segment->GetFlowProperties()->SetGrowthStimulus(0.0*unit::per_second);
263 p_new_vessel->GetFlowProperties()->SetRegressionTime(nearest_segment.first->GetVessel()->GetFlowProperties()->GetRegressionTime());
268 template <
unsigned DIM>
271 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
272 for(
unsigned idx=0; idx<nodes.size(); idx++)
274 units::quantity<unit::length> av_radius = 0.0 * unit::metres;
275 for(
unsigned jdx=0; jdx<nodes[idx]->GetNumberOfSegments(); jdx++)
277 av_radius += nodes[idx]->GetSegment(jdx)->GetRadius();
279 av_radius /= double(nodes[idx]->GetNumberOfSegments());
280 nodes[idx]->SetRadius(av_radius);
284 template <
unsigned DIM>
287 units::quantity<unit::length> x_max = -DBL_MAX*unit::metres;
288 units::quantity<unit::length> y_max = -DBL_MAX*unit::metres;
289 units::quantity<unit::length> z_max = -DBL_MAX*unit::metres;
291 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
292 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator it;
293 for(it = nodes.begin(); it != nodes.end(); it++)
295 units::quantity<unit::length> length_scale = (*it)->rGetLocation().GetReferenceLengthScale();
296 c_vector<double, DIM> location = (*it)->rGetLocation().GetLocation(length_scale);
297 if(location[0]*length_scale > x_max)
299 x_max = location[0]*length_scale;
302 x_max += (*it)->GetRadius();
305 if(location[1]*length_scale > y_max)
307 y_max = location[1]*length_scale;
310 y_max += (*it)->GetRadius();
315 if(location[2]*length_scale > z_max)
317 z_max = location[2]*length_scale;
320 z_max += (*it)->GetRadius();
326 units::quantity<unit::length> x_min = x_max;
327 units::quantity<unit::length> y_min = y_max;
328 units::quantity<unit::length> z_min = z_max;
329 for(it = nodes.begin(); it != nodes.end(); it++)
331 units::quantity<unit::length> length_scale = (*it)->rGetLocation().GetReferenceLengthScale();
332 c_vector<double, DIM> location = (*it)->rGetLocation().GetLocation(length_scale);
333 if(location[0]*length_scale < x_min)
335 x_min = location[0]*length_scale;
338 x_min -= (*it)->GetRadius();
341 if(location[1]*length_scale < y_min)
343 y_min = location[1]*length_scale;
346 y_min -= (*it)->GetRadius();
351 if(location[2]*length_scale < z_min)
353 z_min = location[2]*length_scale;
356 z_min -= (*it)->GetRadius();
368 template<
unsigned DIM>
375 template <
unsigned DIM>
378 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
379 boost::shared_ptr<VesselNode<DIM> > nearest_node;
380 units::quantity<unit::length> min_distance = DBL_MAX*unit::metres;
382 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator node_iter;
383 for(node_iter = nodes.begin(); node_iter != nodes.end(); node_iter++)
385 units::quantity<unit::length> node_distance = (*node_iter)->GetDistance(rLocation);
386 if (node_distance < min_distance)
388 min_distance = node_distance;
389 nearest_node = (*node_iter) ;
395 template <
unsigned DIM>
398 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
399 boost::shared_ptr<VesselNode<DIM> > nearest_node;
400 units::quantity<unit::length> min_distance = DBL_MAX*unit::metres;
402 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator node_iter;
403 for(node_iter = nodes.begin(); node_iter != nodes.end(); node_iter++)
405 if((*node_iter) != pInputNode)
407 units::quantity<unit::length> node_distance = (*node_iter)->GetDistance(pInputNode->rGetLocation());
408 if (node_distance < min_distance)
410 min_distance = node_distance;
411 nearest_node = (*node_iter) ;
418 template <
unsigned DIM>
421 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
422 boost::shared_ptr<VesselNode<DIM> > nearest_node;
423 units::quantity<unit::length> min_distance = DBL_MAX*unit::metres;
425 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator node_iter;
426 for(node_iter = nodes.begin(); node_iter != nodes.end(); node_iter++)
428 units::quantity<unit::length> node_distance = (*node_iter)->GetDistance(location);
429 if (node_distance < min_distance)
431 min_distance = node_distance;
432 nearest_node = (*node_iter) ;
439 template <
unsigned DIM>
442 boost::shared_ptr<VesselSegment<DIM> > nearest_segment;
443 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
444 units::quantity<unit::length> length_scale = segments[0]->GetNode(0)->GetReferenceLengthScale();
446 double min_distance = DBL_MAX;
447 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator segment_iter;
448 for(segment_iter = segments.begin(); segment_iter != segments.end(); segment_iter++)
450 if(!pSegment->IsConnectedTo((*segment_iter)))
453 c_vector<double, DIM> u = (*segment_iter)->GetNode(1)->rGetLocation().GetLocation(length_scale) -
454 (*segment_iter)->GetNode(0)->rGetLocation().GetLocation(length_scale);
455 c_vector<double, DIM> v = pSegment->GetNode(1)->rGetLocation().GetLocation(length_scale) -
456 pSegment->GetNode(0)->rGetLocation().GetLocation(length_scale);
457 c_vector<double, DIM> w = (*segment_iter)->GetNode(0)->rGetLocation().GetLocation(length_scale) -
458 pSegment->GetNode(0)->rGetLocation().GetLocation(length_scale);
460 double a = inner_prod(u,u);
461 double b = inner_prod(u,v);
462 double c = inner_prod(v,v);
463 double d = inner_prod(u,w);
464 double e = inner_prod(v,w);
466 double dv = a * c - b * b;
467 double sc, sn, sd = dv;
468 double tc, tn ,td = dv;
519 else if((-d + b) > a)
530 sc = (std::abs(sn) < 1.e-12 ? 0.0 : sn/sd);
531 tc = (std::abs(tn) < 1.e-12 ? 0.0 : tn/td);
532 c_vector<double, DIM> dp = w + (sc * u) - (tc * v);
534 double segment_distance = norm_2(dp);
535 if (segment_distance < min_distance)
537 min_distance = segment_distance;
538 nearest_segment = (*segment_iter) ;
543 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > return_pair =
544 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> >(nearest_segment, min_distance * length_scale);
548 template <
unsigned DIM>
552 boost::shared_ptr<VesselSegment<DIM> > nearest_segment;
553 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
555 units::quantity<unit::length> min_distance = DBL_MAX * unit::metres;
556 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator segment_iter;
557 for(segment_iter = segments.begin(); segment_iter != segments.end(); segment_iter++)
559 units::quantity<unit::length> segment_distance = (*segment_iter)->GetDistance(pNode->rGetLocation());
561 if (segment_distance < min_distance && (*segment_iter)->GetNode(0) != pNode && (*segment_iter)->GetNode(1) != pNode)
565 min_distance = segment_distance;
566 nearest_segment = (*segment_iter) ;
570 bool same_vessel =
false;
571 std::vector<boost::shared_ptr<VesselSegment<DIM> > > node_segs = pNode->GetSegments();
572 for(
unsigned idx=0;idx<node_segs.size();idx++)
574 if(node_segs[idx]->
GetVessel() == (*segment_iter)->GetVessel())
581 min_distance = segment_distance;
582 nearest_segment = (*segment_iter);
587 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > return_pair =
588 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> >(nearest_segment, min_distance);
592 template <
unsigned DIM>
595 boost::shared_ptr<VesselSegment<DIM> > nearest_segment;
596 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
598 units::quantity<unit::length> min_distance = DBL_MAX * unit::metres;
599 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator segment_iter;
600 for(segment_iter = segments.begin(); segment_iter != segments.end(); segment_iter++)
602 units::quantity<unit::length> segment_distance = (*segment_iter)->GetDistance(location);
603 if (segment_distance < min_distance)
605 min_distance = segment_distance;
606 nearest_segment = (*segment_iter) ;
609 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > return_pair =
610 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> >(nearest_segment, min_distance);
614 template <
unsigned DIM>
620 template <
unsigned DIM>
623 std::vector<boost::shared_ptr<Vessel<DIM> > > vessels_to_remove;
625 for(
unsigned idx=0; idx<
mVessels.size(); idx++)
627 if(
mVessels[idx]->GetLength() < cutoff)
629 if(endsOnly && (
mVessels[idx]->GetStartNode()->GetNumberOfSegments() == 1 ||
mVessels[idx]->GetEndNode()->GetNumberOfSegments() == 1 ))
631 vessels_to_remove.push_back(
mVessels[idx]);
635 vessels_to_remove.push_back(
mVessels[idx]);
640 for(
unsigned idx=0; idx<vessels_to_remove.size(); idx++)
646 template <
unsigned DIM>
649 std::vector<boost::shared_ptr<Vessel<DIM> > > vessels_to_merge;
650 for(
unsigned idx=0; idx<
mVessels.size(); idx++)
652 if(
mVessels[idx]->GetLength() < cutoff)
654 vessels_to_merge.push_back(
mVessels[idx]);
659 for(
unsigned idx=0; idx<vessels_to_merge.size(); idx++)
661 vessels_to_merge[idx]->GetEndNode()->SetLocation(vessels_to_merge[idx]->GetStartNode()->rGetLocation());
671 template <
unsigned DIM>
674 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
675 unsigned num_nodes = 0;
677 for(
unsigned idx = 0; idx < nodes.size(); idx++)
679 if(nodes[idx]->GetDistance(rLocation)/nodes[idx]->GetReferenceLengthScale() <= tolerance + 1.e-6)
687 template <
unsigned DIM>
698 template <
unsigned DIM>
709 template <
unsigned DIM>
720 template <
unsigned DIM>
731 template <
unsigned DIM>
734 std::vector<boost::shared_ptr<VesselNode<DIM> > > vec_nodes =
GetNodes();
738 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator it;
739 for(it = vec_nodes.begin(); it != vec_nodes.end(); it++)
747 EXCEPTION(
"Node is not in the network.");
751 template <
unsigned DIM>
757 template <
unsigned DIM>
767 template <
unsigned DIM>
772 EXCEPTION(
"Requested vessel index out of range");
778 template <
unsigned DIM>
785 template <
unsigned DIM>
789 unsigned num_nodes = nodes.size();
792 unsigned max_num_branches = 0;
793 for(
unsigned node_index = 0; node_index < num_nodes; node_index++)
795 boost::shared_ptr<VesselNode<DIM> > p_each_node = nodes[node_index];
796 unsigned num_segments_on_node = nodes[node_index]->GetNumberOfSegments();
798 if (num_segments_on_node > max_num_branches)
800 max_num_branches = num_segments_on_node;
803 return max_num_branches;
806 template <
unsigned DIM>
810 typename std::vector<boost::shared_ptr<Vessel<DIM> > >::iterator it;
819 EXCEPTION(
"Input vessel is not in the network.");
822 template <
unsigned DIM>
826 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
827 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator it;
828 for(it = segments.begin(); it != segments.end(); it++)
830 if(*it == pVesselSegment)
836 EXCEPTION(
"Input vessel is not in the network.");
839 template <
unsigned DIM>
850 template <
unsigned DIM>
853 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
854 return (std::find(nodes.begin(), nodes.end(), pSourceNode) != nodes.end());
857 template <
unsigned DIM>
863 template <
unsigned DIM>
866 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes;
867 for(
unsigned idx = 0; idx <pVessels.size(); idx++)
869 std::vector<boost::shared_ptr<VesselNode<DIM> > > vessel_nodes = pVessels[idx]->GetNodes();
870 nodes.insert(nodes.end(), vessel_nodes.begin(), vessel_nodes.end());
875 template <
unsigned DIM>
878 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator it;
879 typename std::vector<boost::shared_ptr<VesselNode<DIM> > >::iterator it2;
880 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator it3;
882 for(it = nodes.begin(); it != nodes.end(); it++)
884 for(it2 = nodes.begin(); it2 != nodes.end(); it2++)
890 bool is_coincident =
false;
893 is_coincident = (*it)->GetDistance((*it2)->rGetLocation())/(*it)->GetReferenceLengthScale() <= tolerance;
897 is_coincident = (*it)->IsCoincident((*it2)->rGetLocation());
904 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments = (*it2)->GetSegments();
905 for(it3 = segments.begin(); it3 != segments.end(); it3++)
907 if ((*it3)->GetNode(0) == (*it2))
909 (*it3)->ReplaceNode(0, (*it));
911 else if(((*it3)->GetNode(1) == (*it2)))
913 (*it3)->ReplaceNode(1, (*it));
925 template <
unsigned DIM>
928 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
930 typename std::vector<boost::shared_ptr<VesselSegment<DIM> > >::iterator it;
931 for(it = segments.begin(); it != segments.end(); it++)
933 (*it)->SetRadius(prototype->GetRadius());
934 (*it)->GetFlowProperties()->SetImpedance(prototype->GetFlowProperties()->GetImpedance());
935 (*it)->GetFlowProperties()->SetHaematocrit(prototype->GetFlowProperties()->GetHaematocrit());
936 (*it)->GetFlowProperties()->SetFlowRate(prototype->GetFlowProperties()->GetFlowRate());
937 (*it)->GetFlowProperties()->SetViscosity(prototype->GetFlowProperties()->GetViscosity());
941 template <
unsigned DIM>
947 template <
unsigned DIM>
950 std::set<boost::shared_ptr<VesselNode<DIM> > > nodes;
951 for(
unsigned idx = 0; idx <vessels.size(); idx++)
953 std::vector<boost::shared_ptr<VesselNode<DIM> > > vessel_nodes = vessels[idx]->GetNodes();
954 std::copy(vessel_nodes.begin(), vessel_nodes.end(), std::inserter(nodes, nodes.begin()));
957 typename std::set<boost::shared_ptr<VesselNode<DIM> > >::iterator node_iter;
958 for(node_iter = nodes.begin(); node_iter != nodes.end(); node_iter++)
962 (*node_iter)->SetLocation(old_loc);
966 template <
unsigned DIM>
970 typename std::vector<boost::shared_ptr<Vessel<DIM> > >::iterator it = std::find(
mVessels.begin(),
mVessels.end(), pVessel);
981 EXCEPTION(
"Vessel is not contained inside network.");
989 template <
unsigned DIM>
992 std::vector<boost::shared_ptr<VesselNode<DIM> > > nodes =
GetNodes();
994 for(
unsigned idx=0; idx<nodes.size();idx++)
996 nodes[idx]->SetRadius(radius);
1001 template <
unsigned DIM>
1004 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
1006 for(
unsigned idx=0; idx<segments.size();idx++)
1008 segments[idx]->SetRadius(radius);
1012 template <
unsigned DIM>
1015 std::vector<boost::shared_ptr<VesselSegment<DIM> > > segments =
GetVesselSegments();
1016 for(
unsigned idx=0; idx<segments.size(); idx++)
1018 segments[idx]->GetFlowProperties()->SetViscosity(viscosity);
1022 template <
unsigned DIM>
1035 template<
unsigned DIM>
1039 typename std::vector<boost::shared_ptr<Vessel<DIM> > >::iterator it;
1042 for (
unsigned idx=0; idx<(*it)->GetNumberOfNodes(); idx++)
1044 (*it)->GetNode(idx)->SetComparisonId(0);
1049 for (
unsigned idx=0; idx<(*it)->GetNumberOfNodes(); idx++)
1051 if((*it)->GetNode(idx)->GetComparisonId()==0)
1053 mNodes.push_back((*it)->GetNode(idx));
1054 (*it)->GetNode(idx)->SetComparisonId(1);
1061 template<
unsigned DIM>
1065 typename std::vector<boost::shared_ptr<Vessel<DIM> > >::iterator it;
1068 std::vector<boost::shared_ptr<VesselSegment<DIM> > > vessel_segments = (*it)->GetSegments();
1069 std::copy(vessel_segments.begin(), vessel_segments.end(), std::back_inserter(
mSegments));
1074 template<
unsigned DIM>
1078 typename std::vector<boost::shared_ptr<Vessel<DIM> > >::iterator it;
1081 (*it)->UpdateNodes();
1082 (*it)->GetStartNode()->SetComparisonId(0);
1083 (*it)->GetEndNode()->SetComparisonId(0);
1087 if((*it)->GetStartNode()->GetComparisonId()==0)
1090 (*it)->GetStartNode()->SetComparisonId(1);
1092 if((*it)->GetEndNode()->GetComparisonId()==0)
1095 (*it)->GetEndNode()->SetComparisonId(1);
1101 template<
unsigned DIM>
1104 for(
unsigned idx=0;idx<
mVessels.size();idx++)
1110 template<
unsigned DIM>
1116 std::pair<boost::shared_ptr<VesselSegment<DIM> >, units::quantity<unit::length> > nearest_segment =
GetNearestSegment(temp_segment);
1120 double nearest_seg_dist = nearest_segment.second / nearest_segment.first->GetNode(0)->GetReferenceLengthScale();
1121 double coord1_distance = nearest_segment.first->GetDistance(coordinate_1) / nearest_segment.first->GetNode(0)->GetReferenceLengthScale();
1122 double coord2_distance = nearest_segment.first->GetDistance(coordinate_2) / nearest_segment.first->GetNode(0)->GetReferenceLengthScale();
1124 bool crosses_segment = (nearest_seg_dist<= tolerance) && (coord1_distance > tolerance) && (coord2_distance > tolerance);
1125 return crosses_segment;
1128 template<
unsigned DIM>
1132 p_writer->SetFileName(rFileName);
1133 p_writer->SetVesselNetwork(this->shared_from_this());
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)
static boost::shared_ptr< VesselNode< DIM > > Create(double v1=0.0, double v2=0.0, double v3=0.0)
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)
static boost::shared_ptr< VesselNetworkWriter< DIM > > Create()
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)
std::map< std::string, double > mOutputData
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)
static boost::shared_ptr< VesselSegment< DIM > > Create(boost::shared_ptr< VesselNode< DIM > > pNode1, boost::shared_ptr< VesselNode< DIM > > pNode2)
std::vector< boost::shared_ptr< Vessel< DIM > > > mVessels
static boost::shared_ptr< Vessel< DIM > > Create(boost::shared_ptr< VesselSegment< DIM > > pSegment)
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)
static BaseUnits * Instance()
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 AddVessels(std::vector< boost::shared_ptr< Vessel< DIM > > > vessels)
unsigned GetVesselSegmentIndex(boost::shared_ptr< VesselSegment< DIM > > pVesselSegment)
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()
void Translate(DimensionalChastePoint< DIM > rVector)
std::vector< boost::shared_ptr< Vessel< DIM > > > GetVessels()
std::map< std::string, double > GetOutputData()
std::vector< boost::shared_ptr< Vessel< DIM > > > CopyVessels()
units::quantity< unit::length > GetReferenceLengthScale()
unsigned GetNumberOfNodes()
void RemoveVessel(boost::shared_ptr< Vessel< DIM > > pVessel, bool deleteVessel=false)