From 00bcaaadf18eda942b0e1b86a05e7280a57bcb52 Mon Sep 17 00:00:00 2001
From: yy1717 <fctom1215@outlook.com>
Date: 星期一, 22 二月 2021 13:33:18 +0800
Subject: [PATCH] 适应紧密排布的科目二场地
---
lib/src/main/cpp/test_items/area_exam.cpp | 40 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/lib/src/main/cpp/test_items/area_exam.cpp b/lib/src/main/cpp/test_items/area_exam.cpp
index 9eaded6..f4dcce9 100644
--- a/lib/src/main/cpp/test_items/area_exam.cpp
+++ b/lib/src/main/cpp/test_items/area_exam.cpp
@@ -201,6 +201,8 @@
static int EnterMap(const car_model *car, LIST_CAR_MODEL &CarModelList, LIST_AREA_MAP &mapList)
{
+ vector<int> score(mapList.size(), 0); // 鍦哄湴閲嶅悎鏃讹紝杞﹀ご灏鹃兘鍦ㄥ唴鐨勪紭鍏�
+
for (int i = 0; i < mapList.size() && car != NULL; ++i) {
// 杞﹀墠杞垨鍚庤疆杞ㄨ抗瓒婅繃瑙﹀彂绾�
if (mapList[i].type == MAP_TYPE_STOP_START) {
@@ -233,7 +235,18 @@
if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine1) > 0.1 &&
DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine2) > 0.1)
- return i;
+ score[i]++;
+ }
+ // 杞﹀熬椤剁偣鍦ㄥ満鍦板唴
+ if (IntersectionOf(car->carXY[ car->axial[AXIAL_REAR] ], &mapList[i].map) == GM_Containment) {
+ Line enterLine1, enterLine2;
+
+ MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+ MakeLine(&enterLine2, &(mapList[i].map.point[6]), &(mapList[i].map.point[7]));
+
+ if (DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine1) > 0.1 &&
+ DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine2) > 0.1)
+ score[i]++;
}
}
if (mapList[i].type == MAP_TYPE_PART_EDGE) {
@@ -244,7 +257,16 @@
MakeLine(&enterLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine) > 0.1)
- return i;
+ score[i]++;
+ }
+ // 杞﹀熬椤剁偣鍦ㄥ満鍦板唴
+ if (IntersectionOf(car->carXY[ car->axial[AXIAL_REAR] ], &mapList[i].map) == GM_Containment) {
+ Line enterLine;
+
+ MakeLine(&enterLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+
+ if (DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine) > 0.1)
+ score[i]++;
}
}
if (mapList[i].type == MAP_TYPE_TURN_90) {
@@ -257,6 +279,7 @@
return i;
}
if (mapList[i].type == MAP_TYPE_CURVE) {
+ // 杞﹀墠杞垨鍚庤疆杞ㄨ抗瓒婅繃瑙﹀彂绾�
Line triggerLine;
MakeLine(&triggerLine, &mapList[i].map2.point[0], &mapList[i].map.point[0]);
@@ -264,6 +287,19 @@
return i;
}
}
+
+ for (int i = 0; i < score.size(); ++i) {
+ if (score[i] == 2) {
+ return i;
+ }
+ }
+
+ for (int i = 0; i < score.size(); ++i) {
+ if (score[i] == 1) {
+ return i;
+ }
+ }
+
return -1;
}
--
Gitblit v1.8.0