module_traffic_light_rule.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. #include <cfloat>
  2. #include "module_traffic_light_rule.h"
  3. #include "module_traffic_light_manager.h"
  4. bool rule::sort_vehicle(const uint64_t lhs, const uint64_t rhs, const traffic_light_group_ptr& g)
  5. {
  6. pos_data* v1 = traffic_light_manager::instance()->get_position(lhs);
  7. pos_data* v2 = traffic_light_manager::instance()->get_position(rhs);
  8. double d1 = DBL_MAX, d2 = DBL_MAX;
  9. if(nullptr != v2){
  10. d2 = g->dist(v2->x, v2->y);
  11. }
  12. if(nullptr != v1){
  13. d1 = g->dist(v1->x, v1->y);
  14. }
  15. return d1 < d2;
  16. }
  17. traffic_light_ptr rule::find_nearby_light(const point& p, traffic_light_group_ptr g)
  18. {
  19. traffic_light_ptr pl = nullptr;
  20. double max = DBL_MAX;
  21. //查找最近的红绿灯
  22. for(auto it = g->m_vt_lights.begin(); it != g->m_vt_lights.end(); ++it)
  23. {
  24. traffic_light_ptr tmp = traffic_light_manager::instance()->find_light((*it)->m_light_id);
  25. double dt = tmp->dist(p.x, p.y);
  26. if(dt < max){
  27. max = dt;
  28. pl = tmp;
  29. }
  30. }
  31. return pl;
  32. }
  33. void crossing_rule::change_state(const uint64_t vid, traffic_light_group_ptr g)
  34. {
  35. pos_data* cp = traffic_light_manager::instance()->get_position(vid);
  36. if(nullptr != cp){
  37. // 查找离车辆最近的红绿灯
  38. traffic_light_ptr pl = find_nearby_light(point(cp->x, cp->y), g);
  39. // 设置来车方向为绿灯,其他方向为红灯
  40. if(nullptr != pl){
  41. log_info("[traffic_light] card_id=%lld, light_id=%d", vid, pl->m_light_id);
  42. g->set_light(pl->m_light_id, green, red);
  43. }
  44. }
  45. }
  46. // 获得车辆是否大车的标记
  47. bool crossing_rule::get_vehicle_state(const uint64_t& vid)
  48. {
  49. bool s = false;
  50. pos_data* v = traffic_light_manager::instance()->get_position(vid);
  51. if(nullptr != v){
  52. s = v->m_bigger;
  53. }
  54. return s;
  55. }
  56. bool crossing_rule::find_light(const uint64_t& vid, traffic_light_group_ptr g, bool a)
  57. {
  58. pos_data* cp = traffic_light_manager::instance()->get_position(vid);
  59. if(nullptr != cp){
  60. line l;
  61. traffic_light_ptr pl = find_nearby_light(point(cp->x, cp->y), g);
  62. if(nullptr == pl){
  63. return false;
  64. }
  65. if(!a){
  66. if(1 == pl->m_special){
  67. // 判断是否在线上
  68. if(pl->m_line_group.contain(cp->x, cp->y, 0.5)){
  69. // 判断行车方向
  70. double d = cp->m_speed * pl->m_direct_distance;
  71. if(d < 0){
  72. return true;
  73. }
  74. }
  75. }
  76. }else{
  77. // 判断是否在线上
  78. if(pl->m_line_group.contain(cp->x, cp->y, 1.0)){
  79. double d = cp->m_speed * pl->m_direct_distance;
  80. if(d < 0){
  81. return true;
  82. }
  83. }
  84. }
  85. }
  86. return false;
  87. }
  88. bool crossing_rule::handle_manual_ctrl(traffic_light_group_ptr g)
  89. {
  90. if(g->is_time_out()){
  91. g->reset();
  92. return true;
  93. }
  94. return false;
  95. }
  96. bool crossing_rule::handle_crossing(traffic_light_group_ptr g)
  97. {
  98. // 查找一定范围的车辆
  99. std::vector<uint64_t> vtl = traffic_light_manager::instance()->find_nearby_vehicle(point(static_cast<int>(g->x), static_cast<int>(g->y)), g->m_scope, 0);
  100. if(vtl.empty()){
  101. if(g->m_card_id > 0 && g->m_priority == priority_crossing)
  102. {
  103. // 释放红绿灯组
  104. g->reset();
  105. return true;
  106. }
  107. return false;
  108. }
  109. // 是否已经有车记录
  110. if(g->m_card_id > 0)
  111. {
  112. auto it = std::find(vtl.begin(), vtl.end(), g->m_card_id);
  113. if(it != vtl.end()){
  114. return false;
  115. }
  116. }
  117. std::sort(vtl.begin(), vtl.end(), [&](const uint64_t& lhs, const uint64_t& rhs){
  118. return sort_vehicle(lhs, rhs, g);
  119. });
  120. // 设置优先级以及卡id
  121. g->set_crossing(vtl[0], priority_crossing);
  122. // 修改红绿灯组状态
  123. change_state(vtl[0], g);
  124. return true;
  125. }
  126. bool crossing_rule::handle_avoidance(traffic_light_group_ptr g)
  127. {
  128. // 查看是否是大车,true表示特殊红绿灯,需要检测大车避让规则
  129. bool flag = false;
  130. do{
  131. auto vt = traffic_light_manager::instance()->find_nearby_vehicle(point(static_cast<int>(g->x), static_cast<int>(g->y)), g->m_scope, 0);
  132. // 筛选大车
  133. if(vt.empty()){
  134. flag = true;
  135. break;
  136. }
  137. vt.erase(std::remove_if(vt.begin(), vt.end(), [&](const uint64_t& vid){
  138. return get_vehicle_state(vid);
  139. }),
  140. vt.end());
  141. if(vt.empty()){
  142. flag = true;
  143. break;
  144. }
  145. // 查看离最近的点是否为特殊点,判断位置是否在直线上,判断方向
  146. vt.erase(std::remove_if(vt.begin(), vt.end(), [&](const uint64_t& vid){
  147. return find_light(vid, g);
  148. }),
  149. vt.end());
  150. if(vt.empty()){
  151. flag = true;
  152. break;
  153. }
  154. // 特殊规则保留id且优先级2,避让规则置空id,优先级2
  155. if(priority_avoidance == g->get_priority()){
  156. if(0 == g->m_card_id){
  157. break;
  158. }else{
  159. auto it = std::find(vt.begin(), vt.end(), g->m_card_id);
  160. if(it != vt.end()){
  161. break;
  162. }
  163. }
  164. }
  165. // 排序,找到离之最近的大车
  166. std::sort(vt.begin(), vt.end(), [&](const uint64_t& vid, const uint64_t& cid){
  167. return sort_vehicle(vid, cid, g);
  168. });
  169. change_state(vt[0], g);
  170. g->set_crossing(vt[0], priority_avoidance);
  171. return true;
  172. }while(false);
  173. if(flag){
  174. // 找不到之前的车辆,则初始化
  175. if(priority_avoidance == g->get_priority() && g->m_card_id > 0){
  176. g->reset();
  177. }else{
  178. flag = false;
  179. }
  180. }
  181. return flag;
  182. }
  183. vt_traffic_group crossing_rule::handle_rule(pos_data& p)
  184. {
  185. vt_traffic_group llist;
  186. for(auto it = m_vt_group.begin(); it != m_vt_group.end(); ++it){
  187. // 获取控制权
  188. (*it)->get_turn();
  189. int priority = (*it)->get_priority();
  190. bool flag = false;
  191. do{
  192. if(priority_manual_ctrl == priority){
  193. flag = handle_manual_ctrl(*it);
  194. if(flag){
  195. break;
  196. }
  197. }
  198. if(priority <= priority_avoidance && (*it)->m_special){
  199. flag = handle_avoidance(*it);
  200. if(flag){
  201. break;
  202. }
  203. }
  204. if(priority <= priority_crossing){
  205. flag = handle_crossing(*it);
  206. if(flag){
  207. break;
  208. }
  209. }
  210. }while(false);
  211. (*it)->release_turn();
  212. if(flag){
  213. llist.push_back(*it);
  214. }
  215. }
  216. return std::move(llist);
  217. }
  218. vt_traffic_group avoidance_rule::find_group(const pos_data& p)
  219. {
  220. return find_group(point(p.x, p.y), p.m_area_id, p.m_speed, p);
  221. }
  222. vt_traffic_group avoidance_rule::find_group(const point& po , int area_id, double speed, const pos_data& pd)
  223. {
  224. vt_traffic_group llist;
  225. if(0 == pd.m_card_id || 0 == pd.m_type){
  226. std::move(llist);
  227. }
  228. // 获取车辆所在地图区域内的所有红绿灯组
  229. vt_traffic_group vg = m_map_area_group[area_id];
  230. double dist = 0.0;
  231. for(std::size_t i = 0; i < vg.size(); ++i){
  232. traffic_light_group_ptr pg = vg[i];
  233. if(nullptr == pg){
  234. continue;
  235. }
  236. // 如果此灯组被控制了,则不允许使用
  237. if(vg[i]->get_status() && vg[i]->m_card_id != pd.m_card_id){
  238. log_info("[traffic_light] card_id=%lld was control light group, gid=%d", pd.m_card_id, vg[i]->m_group_id);
  239. continue;
  240. }
  241. // 求灯组到车辆的距离(车辆在灯组的左下方,则距离值取反)
  242. dist = vg[i]->dist_direct(po.x, po.y);
  243. // 车辆在灯组左边或下边
  244. if(dist <= 0){
  245. // 速度方向与前进方向一致
  246. if(speed > 0){
  247. // 车辆到灯组的距离小于指定距离
  248. if(vg[i]->dist(po.x, po.y) <= g_max_scope){
  249. llist.push_back(vg[i]);
  250. }
  251. // 紧挨着的一个灯组到车距离小于指定阈值
  252. if(i + 1 < vg.size()){
  253. if(vg[i+1]->dist(po.x, po.y) <= g_max_scope){
  254. llist.push_back(vg[i+1]);
  255. }
  256. }
  257. }else if(speed < 0){
  258. // 速度方向与前进方向不一致,判断运动方向的灯组是否在可控范围
  259. if(i >= 1 && vg[i - 1]->dist(po.x, po.y) <= g_max_scope){
  260. llist.push_back(vg[i-1]);
  261. }
  262. if(i >= 2 && vg[i-2]->dist(po.x, po.y) <= g_max_scope){
  263. llist.push_back(vg[i-2]);
  264. }
  265. }
  266. break;
  267. }
  268. }
  269. // 车辆在灯组右边或上边
  270. if(dist > 0 && speed < 0){
  271. std::size_t i = vg.size();
  272. if(i >= 1 && vg[i-1]->dist(po.x, po.y) <= g_max_scope){
  273. llist.push_back(vg[i-1]);
  274. }
  275. if(i >= 2 && vg[i-2]->dist(po.x, po.y) <= g_max_scope){
  276. llist.push_back(vg[i-2]);
  277. }
  278. }
  279. return std::move(llist);
  280. }
  281. bool avoidance_rule::find_vehicle_in_group(vt_traffic_group& vg, std::vector<pos_data>& vv)
  282. {
  283. if(vv.size() < 2){
  284. log_error("[traffic_light] vv's size less than 2");
  285. return false;
  286. }
  287. bool flag = true;
  288. double d = vg[0]->dist(vv[1].x, vv[1].y);
  289. line tl(*vg[0], *vg[1]);
  290. if(tl.contain(vv[1].x, vv[1].y, 1))
  291. {
  292. if(vv[1].m_speed * vv[0].m_speed < 0 && d > g_mid_vehicle_length_group){
  293. flag = false;
  294. }
  295. }
  296. return flag;
  297. }
  298. bool avoidance_rule::get_vehicle(const pos_data& p, vt_traffic_group& vg)
  299. {
  300. double d = vg[0]->dist(*vg[1]);
  301. std::vector<uint64_t> vt1 = traffic_light_manager::instance()->find_nearby_vehicle(point(static_cast<int>(vg[0]->x), static_cast<int>(vg[0]->y)), static_cast<int>(d), vg[0]->m_card_id);
  302. std::vector<uint64_t> vt2 = traffic_light_manager::instance()->find_nearby_vehicle(point(static_cast<int>(vg[1]->x), static_cast<int>(vg[1]->y)), static_cast<int>(d), vg[1]->m_card_id);
  303. std::sort(vt1.begin(), vt1.end());
  304. std::sort(vt2.begin(), vt2.end());
  305. std::vector<uint64_t> vti;
  306. std::set_intersection(vt1.begin(), vt1.end(), vt2.begin(), vt2.end(), std::back_inserter(vti));
  307. if(vti.empty()){
  308. return false;
  309. }
  310. // 筛选出符合条件的车辆,离第一个红绿灯距离进行排序
  311. vti.erase(std::remove_if(vti.begin(), vti.end(), [&](const uint64_t& vid) -> bool {
  312. pos_data* tp = traffic_light_manager::instance()->get_position(vid);
  313. if(tp == nullptr){
  314. return true;
  315. }
  316. std::vector<pos_data> vv;
  317. vv.push_back(p);
  318. vv.push_back(*tp);
  319. return find_vehicle_in_group(vg, vv);
  320. }));
  321. return vti.empty()?false:true;
  322. }
  323. void avoidance_rule::insert(traffic_light_group_ptr g, pos_data& p, vt_traffic_group& vg, const int lc, const int lcr)
  324. {
  325. p.m_light_group.push_back(g->m_group_id);
  326. if(g->get_priority() < priority_avoidance){
  327. // 红绿灯组优先级取初始值0或路口控制1
  328. change_group(g, point(p.x, p.y), lc, lcr);
  329. vg.push_back(g);
  330. }
  331. traffic_light_ptr pl = find_nearby_light(point(p.x, p.y), g);
  332. g->m_green_light_id = pl->m_light_id;
  333. // 灯组绑定车辆的卡号
  334. g->m_card_id = p.m_card_id;
  335. g->set_status(true);
  336. }
  337. void avoidance_rule::erase(bool a, pos_data& p, vt_traffic_group& vg)
  338. {
  339. if(p.m_light_group.size() <= 0){
  340. return;
  341. }
  342. traffic_light_group_ptr pg = nullptr;
  343. bool flag = false;
  344. if(a){
  345. pg = traffic_light_manager::instance()->find_group(p.m_light_group.front());
  346. p.m_light_group.pop_front();
  347. }else{
  348. pg = traffic_light_manager::instance()->find_group(p.m_light_group.back());
  349. p.m_light_group.pop_back();
  350. }
  351. if(nullptr == pg){
  352. return;
  353. }
  354. pg->get_turn();
  355. if(pg->get_priority() <= priority_avoidance){
  356. // 重置灯组
  357. pg->reset();
  358. flag = true;
  359. }
  360. pg->release_turn();
  361. pg->set_status(false);
  362. if(flag){
  363. vg.push_back(pg);
  364. }
  365. }
  366. void avoidance_rule::change_group(const traffic_light_group_ptr& g, const point& p, const int& lc, const int& lcr)
  367. {
  368. // 1.取离p最近的灯组信息
  369. traffic_light_ptr pl = find_nearby_light(point(p.x, p.y), g);
  370. if(nullptr == pl){
  371. return;
  372. }
  373. // 2.获取灯组中临近车辆的灯id
  374. g->m_green_light_id = pl->m_light_id;
  375. g->get_turn();
  376. // 3.设置灯组中灯号为ld的灯颜色为lc,其余灯颜色为lcr
  377. g->set_avoidance(pl->m_light_id, lc, lcr);
  378. g->release_turn();
  379. }
  380. bool avoidance_rule::is_different(traffic_light_group_ptr g, const point& p, const int& lc, const int& lcr)
  381. {
  382. bool b = false;
  383. traffic_light_ptr pl = find_nearby_light(p, g);
  384. if(g->is_different(pl->m_light_id, lc, lcr)){
  385. b = true;
  386. }
  387. return b;
  388. }
  389. vt_traffic_group avoidance_rule::handle_rule(pos_data& p)
  390. {
  391. vt_traffic_group llist;
  392. if(p.m_card_id == 0|| p.m_type == 0){
  393. return std::move(llist);
  394. }
  395. auto it = m_map_area_group.find(p.m_area_id);
  396. if(it != m_map_area_group.end()){
  397. // 根据车卡的定位坐标以及定位区域信息获取红绿灯组
  398. vt_traffic_group vtg = find_group(p);
  399. if(vtg.size() == 0){
  400. // 所在区域没有可以控制的红绿灯组
  401. switch(p.m_light_group.size())
  402. {
  403. case 1:
  404. // 当前车辆控制的路口为1个,释放该炉口控制
  405. erase(true, p, llist);
  406. break;
  407. case 2:
  408. // 当前车辆控制的路口为两个,释放这两个路口的控制
  409. erase(true, p, llist);
  410. erase(false, p, llist);
  411. break;
  412. }
  413. }else if(1 == vtg.size()){
  414. // 所在区域存在1个红绿灯组
  415. switch(p.m_light_group.size())
  416. {
  417. case 0:
  418. // 当前卡没有绑定红绿灯组,绑定此灯组,并设置灯组颜色为绿色
  419. insert(vtg[0], p, llist, green, red);
  420. break;
  421. case 1:
  422. //当前卡绑定了1个红绿灯组
  423. if(p.m_light_group.front() != vtg[0]->m_group_id){
  424. // 检查当前卡绑定的红绿灯组与区域找到的是不是同一个
  425. // 不是,释放之前的绑定,再绑定新灯组
  426. erase(true, p, llist);
  427. insert(vtg[0], p, llist, green, red);
  428. }else{
  429. // 当前卡绑定的红绿灯组与区域找到的是同一个
  430. traffic_light_ptr pl = find_nearby_light(point(p.x, p.y), vtg[0]);
  431. if(nullptr != pl && pl->m_light_id != vtg[0]->m_green_light_id){
  432. erase(true, p, llist);
  433. }
  434. }
  435. break;
  436. }
  437. }else if(2 == p.m_light_group.size()){
  438. // 当前卡绑定了2个红绿灯组
  439. traffic_light_group_ptr g = vtg[0];
  440. if(p.m_light_group.front() == g->m_group_id){
  441. // 第一个绑定的红绿灯组与区域找到的是同一个,删除第二个
  442. erase(false, p, llist);
  443. if(g->get_priority() <= priority_avoidance){
  444. change_group(g, point(p.x, p.y), green, red);
  445. llist.push_back(g);
  446. }
  447. }else if(p.m_light_group.back() == g->m_group_id){
  448. // 第二个绑定的红绿灯组与区域找到的是同一个,删除第一个
  449. erase(true, p, llist);
  450. if(g->get_priority() <= priority_avoidance){
  451. change_group(g, point(p.x, p.y), green, red);
  452. llist.push_back(g);
  453. }
  454. }else{
  455. // 两个都不是,全部删除
  456. erase(true, p, llist);
  457. erase(false, p, llist);
  458. insert(g, p, llist, green, red);
  459. }
  460. }else if(2 == vtg.size()){
  461. // 所在区域存在两个红绿灯组,巷道相遇逻辑
  462. // 判断两个灯组中是否有车
  463. bool b = get_vehicle(p, vtg);
  464. light_color la, lb;
  465. if(b){
  466. la = red;
  467. lb = spark;
  468. }else{
  469. la = green;
  470. lb = red;
  471. }
  472. switch(p.m_light_group.size()){
  473. case 0:
  474. // 当前卡没有绑定红绿灯组,绑定2个灯组
  475. insert(vtg[0], p, llist, la, lb);
  476. insert(vtg[1], p, llist, green, spark);
  477. break;
  478. case 1:
  479. // 当前卡有绑定1个红绿灯组,更新
  480. if(p.m_light_group.front() == vtg[0]->m_group_id){
  481. if(vtg[0]->get_priority() <= priority_avoidance){
  482. change_group(vtg[0], point(p.x, p.y), la, lb);
  483. llist.push_back(vtg[0]);
  484. }
  485. insert(vtg[1], p, llist, green, spark);
  486. }else if(p.m_light_group.front() == vtg[1]->m_group_id){
  487. if(vtg[1]->get_priority() <= priority_avoidance)
  488. {
  489. change_group(vtg[1], point(p.x, p.y), green, spark);
  490. llist.push_back(vtg[1]);
  491. }
  492. p.m_light_group.push_front(vtg[0]->m_group_id);
  493. if(vtg[0]->get_priority() < priority_avoidance)
  494. {
  495. change_group(vtg[0], point(p.x, p.y), la, lb);
  496. llist.push_back(vtg[0]);
  497. }
  498. }else{
  499. // 两个都不相等
  500. erase(false, p, llist);
  501. insert(vtg[0], p, llist, la, lb);
  502. insert(vtg[1], p, llist, green, spark);
  503. }
  504. break;
  505. case 2:
  506. // 当前卡有绑定2个红绿灯组,更新
  507. {
  508. std::list<int>::iterator ito = std::find(p.m_light_group.begin(), p.m_light_group.end(), vtg[0]->m_group_id);
  509. std::list<int>::iterator itt = std::find(p.m_light_group.begin(), p.m_light_group.end(), vtg[1]->m_group_id);
  510. if(ito != p.m_light_group.end())
  511. {
  512. if(itt != p.m_light_group.end())
  513. {
  514. if(p.m_light_group.front() == vtg[0]->m_group_id){
  515. if(is_different(vtg[0], point(p.x, p.y), la, lb)){
  516. llist.push_back(vtg[0]);
  517. }
  518. if(is_different(vtg[1], point(p.x, p.y), green, spark)){
  519. llist.push_back(vtg[1]);
  520. }
  521. }else{
  522. p.m_light_group.clear();
  523. if(vtg[0]->get_priority() <= priority_avoidance){
  524. change_group(vtg[0], point(p.x, p.y), la, lb);
  525. llist.push_back(vtg[0]);
  526. }
  527. if(vtg[1]->get_priority() <= priority_avoidance){
  528. change_group(vtg[1], point(p.x, p.y), green, spark);
  529. llist.push_back(vtg[1]);
  530. }
  531. p.m_light_group.push_back(vtg[0]->m_group_id);
  532. p.m_light_group.push_back(vtg[1]->m_group_id);
  533. }
  534. }
  535. else
  536. {
  537. if(p.m_light_group.front() == vtg[0]->m_group_id){
  538. erase(false, p, llist);
  539. insert(vtg[1], p, llist, green, spark);
  540. }else{
  541. erase(true, p, llist);
  542. if(vtg[0]->get_priority() <= priority_avoidance){
  543. change_group(vtg[0], point(p.x, p.y), la, lb);
  544. llist.push_back(vtg[0]);
  545. }
  546. insert(vtg[1], p, llist, green, spark);
  547. }
  548. }
  549. }
  550. else
  551. {
  552. if(itt != p.m_light_group.end()){
  553. if(p.m_light_group.front() == vtg[1]->m_group_id){
  554. erase(false, p, llist);
  555. }else{
  556. erase(true, p, llist);
  557. }
  558. if(vtg[1]->get_priority() <= priority_avoidance){
  559. change_group(vtg[1], point(p.x, p.y), green, spark);
  560. llist.push_back(vtg[1]);
  561. }
  562. p.m_light_group.push_front(vtg[1]->m_group_id);
  563. if(vtg[0]->get_priority() < priority_avoidance){
  564. change_group(vtg[0], point(p.x, p.y), la, lb);
  565. llist.push_back(vtg[0]);
  566. }
  567. }else{
  568. erase(true, p, llist);
  569. erase(true, p, llist);
  570. insert(vtg[0], p, llist, la, lb);
  571. insert(vtg[1], p, llist, green, spark);
  572. }
  573. }
  574. }
  575. break;
  576. }
  577. }
  578. }
  579. return std::move(llist);
  580. }