| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "region.hpp" | |||
| 2 | #include "geometry.hpp" | |||
| 3 | #include "system.hpp" | |||
| 4 | ||||
| 5 | ✗ | TrajectoryVector Region::insert_trajectory(const SurfaceVector& s_vec) | ||
| 6 | { | |||
| 7 | #ifdef DBG_GEOMETRY | |||
| 8 | cout << "DBG/GEOMETRY: Region::insertTrajectory() called\n"; | |||
| 9 | #endif | |||
| 10 | ||||
| 11 | TrajectoryVector t_vec; | |||
| 12 | ✗ | double t_length(0.); | ||
| 13 | ✗ | SurfaceVector new_base(s_vec); | ||
| 14 | ||||
| 15 | ✗ | std::vector<PointAtEdge> end_point; | ||
| 16 | ||||
| 17 | // gather coordinates of the trajectory to be created | |||
| 18 | ✗ | get_trajectory_coordinates(new_base, t_length, end_point, t_vec); | ||
| 19 | ||||
| 20 | // create the trajectory | |||
| 21 | ✗ | t_vec.trajectory = trajectories.create(new_base, end_point, t_length); | ||
| 22 | ||||
| 23 | // make a list of intersections of the created trajectory with all other trajectories | |||
| 24 | ✗ | make_intersection_list(t_vec.trajectory); | ||
| 25 | ||||
| 26 | // increase total number of intersections accordingly | |||
| 27 | ✗ | geometry->system->count_intersections += 2 * (t_vec.trajectory->intersections.size()); | ||
| 28 | ||||
| 29 | ✗ | return t_vec; | ||
| 30 | } | |||
| 31 | ||||
| 32 | ✗ | void Region::remove_trajectory(Trajectory* tr) | ||
| 33 | { | |||
| 34 | #ifdef DBG_GEOMETRY | |||
| 35 | cout << "DBG/GEOMETRY: Region::removeTrajectory() called\n"; | |||
| 36 | #endif | |||
| 37 | ||||
| 38 | #ifdef DBG_ASSERT | |||
| 39 | // when removing a trajectory, it should be already run out of segments | |||
| 40 | if (!tr->segments.empty()) | |||
| 41 | { | |||
| 42 | cout << "Big problem"; | |||
| 43 | } | |||
| 44 | ||||
| 45 | // when removing a trajectory, it should be already run out of tips (i.e. notification list empty) | |||
| 46 | if (!tr->notificationList.empty()) | |||
| 47 | { | |||
| 48 | cout << "oh dear\n"; | |||
| 49 | } | |||
| 50 | #endif | |||
| 51 | ||||
| 52 | // decrease total number of intersections in the geometry | |||
| 53 | ✗ | geometry->system->count_intersections -= 2 * (tr->intersections.size()); | ||
| 54 | ||||
| 55 | // skip the first intersection iterator, as it is a garbage | |||
| 56 | IntersectionItr is(++tr->intersections.begin()); | |||
| 57 | ||||
| 58 | Trajectory* other_tr(nullptr); | |||
| 59 | ||||
| 60 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | while (is != tr->intersections.end()) | |
| 61 | { | |||
| 62 | ✗ | other_tr = is->second.other_trajectory; | ||
| 63 | ||||
| 64 | // invalidate all the intersetion for the other trajectory | |||
| 65 | ✗ | other_tr->invalidate_intersection(is->second.mirror); | ||
| 66 | ||||
| 67 | // erase all the intersections for the other trajectory | |||
| 68 | ✗ | other_tr->intersections.erase(is->second.mirror); | ||
| 69 | ||||
| 70 | is++; | |||
| 71 | } | |||
| 72 | ||||
| 73 | // now clear all itersections of the trajectory | |||
| 74 | tr->intersections.clear(); | |||
| 75 | ||||
| 76 | // important to inform the linked (previous/next) trajectories about this removal | |||
| 77 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (tr->prev_tr.trajectory != nullptr) | |
| 78 | { | |||
| 79 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (tr->prev_tr.dir == Direction::BACKWARD) | |
| 80 | { | |||
| 81 | ✗ | tr->prev_tr.trajectory->next_tr.trajectory = nullptr; | ||
| 82 | } | |||
| 83 | else | |||
| 84 | { | |||
| 85 | ✗ | tr->prev_tr.trajectory->prev_tr.trajectory = nullptr; | ||
| 86 | } | |||
| 87 | ||||
| 88 | ✗ | tr->prev_tr.trajectory = nullptr; | ||
| 89 | } | |||
| 90 | ||||
| 91 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (tr->next_tr.trajectory != nullptr) | |
| 92 | { | |||
| 93 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (tr->next_tr.dir == Direction::FORWARD) | |
| 94 | { | |||
| 95 | ✗ | tr->next_tr.trajectory->prev_tr.trajectory = nullptr; | ||
| 96 | } | |||
| 97 | else | |||
| 98 | { | |||
| 99 | ✗ | tr->next_tr.trajectory->next_tr.trajectory = nullptr; | ||
| 100 | } | |||
| 101 | ✗ | tr->next_tr.trajectory = nullptr; | ||
| 102 | } | |||
| 103 | ||||
| 104 | // now remove the trajectory | |||
| 105 | ✗ | trajectories.remove(tr); | ||
| 106 | ✗ | } | ||
| 107 | ||||
| 108 | ✗ | double Region::optical_length() | ||
| 109 | { | |||
| 110 | Trajectory* tr(trajectories.first()); | |||
| 111 | double sum(0.0); | |||
| 112 | ||||
| 113 | // calculate total optical length present in this region | |||
| 114 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | while (tr != nullptr) | |
| 115 | { | |||
| 116 | ✗ | sum += tr->covered_length(); | ||
| 117 | tr = tr->next(); | |||
| 118 | } | |||
| 119 | ✗ | return sum; | ||
| 120 | } | |||
| 121 | ||||
| 122 | ✗ | RegionMTTipTag Region::register_on_region(MTTip* p_tip, TipType tiptype, MTType mttype) | ||
| 123 | { | |||
| 124 | // update length | |||
| 125 | ✗ | update_region_length(); | ||
| 126 | ||||
| 127 | // minus tip | |||
| 128 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (tiptype == TipType::MINUS) | |
| 129 | { | |||
| 130 | ✗ | return minus_tip_list.insert(minus_tip_list.end(), p_tip); | ||
| 131 | } | |||
| 132 | ||||
| 133 | // plus tip | |||
| 134 | else | |||
| 135 | { | |||
| 136 | // insert growing MT | |||
| 137 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (mttype == MTType::GROWING) | |
| 138 | { | |||
| 139 | ✗ | geometry->system->growing_tips_reg[face_tag]++; | ||
| 140 | ✗ | return growing_plus_tip_list.insert(growing_plus_tip_list.end(), p_tip); | ||
| 141 | } | |||
| 142 | ||||
| 143 | // insert shrinking MT | |||
| 144 | else | |||
| 145 | { | |||
| 146 | ✗ | return shrinking_plus_tip_list.insert(shrinking_plus_tip_list.end(), p_tip); | ||
| 147 | } | |||
| 148 | } | |||
| 149 | } | |||
| 150 | ||||
| 151 | ✗ | void Region::unregister_from_region(RegionMTTipTag tag, TipType tiptype, MTType mttype) | ||
| 152 | { | |||
| 153 | // update length | |||
| 154 | ✗ | update_region_length(); | ||
| 155 | ||||
| 156 | // minus tip | |||
| 157 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (tiptype == TipType::MINUS) | |
| 158 | { | |||
| 159 | ✗ | minus_tip_list.erase(tag); | ||
| 160 | } | |||
| 161 | ||||
| 162 | // plus tip | |||
| 163 | else | |||
| 164 | { | |||
| 165 | // erase growing MT | |||
| 166 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if (mttype == MTType::GROWING) | |
| 167 | { | |||
| 168 | ✗ | geometry->system->growing_tips_reg[face_tag]--; | ||
| 169 | ✗ | growing_plus_tip_list.erase(tag); | ||
| 170 | } | |||
| 171 | ||||
| 172 | // erase shrinking MT | |||
| 173 | else | |||
| 174 | { | |||
| 175 | ✗ | shrinking_plus_tip_list.erase(tag); | ||
| 176 | } | |||
| 177 | } | |||
| 178 | ✗ | return; | ||
| 179 | } | |||
| 180 | ||||
| 181 | ✗ | void Region::update_region_length(bool force_update) | ||
| 182 | { | |||
| 183 | // can go wrong on position cache refresh, a cleaner solution required | |||
| 184 |
0/2✗ Decision 'true' not taken.
✗ Decision 'false' not taken.
|
✗ | if ((previous_update_tag == geometry->system->current_time_tag) && (!force_update)) | |
| 185 | { | |||
| 186 | return; | |||
| 187 | } | |||
| 188 | ||||
| 189 | ✗ | total_length += geometry->system->time_queue.progression(previous_update_tag) | ||
| 190 | ✗ | * (geometry->system->p.v_min * (shrinking_plus_tip_list.size()) | ||
| 191 | ✗ | - geometry->system->p.v_tm * (minus_tip_list.size())) | ||
| 192 | ✗ | + geometry->system->v_plus_queue.progression(previous_update_tag) | ||
| 193 | ✗ | * (geometry->system->p.v_plus * (growing_plus_tip_list.size())); | ||
| 194 | ||||
| 195 | ✗ | previous_update_tag = geometry->system->current_time_tag; | ||
| 196 | ||||
| 197 | ✗ | return; | ||
| 198 | } | |||
| 199 |