From e0682ead82c34f6972fcde7f1fee66b1b0bb8a8f Mon Sep 17 00:00:00 2001 From: yony Date: Fri, 24 May 2024 20:00:08 +0800 Subject: [PATCH] =?UTF-8?q?penalty=5Fpar=5Fdistance=20=E9=98=B6=E6=A2=AF?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=B2=BE=E7=A1=AE=E6=8E=A7=E5=88=B6=20?= =?UTF-8?q?=E7=BA=BF=E7=BC=86=E7=94=9F=E6=88=90=E9=A1=BA=E5=BA=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4=EF=BC=88xml=E6=96=87=E4=BB=B6=EF=BC=89=20MAXBranchPoi?= =?UTF-8?q?ntNumOnSegment=202->4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/Tinyroute_test/answer2ALL.txt | 186 ++++++++++++------ .../{wirexml => temp}/SE_Sa.xml | 14 +- data/Tinyroute_test/temp/START_END.xml | 25 --- data/Tinyroute_test/wirexml/1START_END.xml | 49 +++++ .../START_A-F.xml => wirexml/2NEAR_END.xml} | 30 ++- data/Tinyroute_test/wirexml/3NEAR_START.xml | 53 +++++ include/Const.h | 29 ++- parameters.txt | 10 +- 8 files changed, 278 insertions(+), 118 deletions(-) rename data/Tinyroute_test/{wirexml => temp}/SE_Sa.xml (80%) delete mode 100644 data/Tinyroute_test/temp/START_END.xml create mode 100644 data/Tinyroute_test/wirexml/1START_END.xml rename data/Tinyroute_test/{temp/START_A-F.xml => wirexml/2NEAR_END.xml} (66%) create mode 100644 data/Tinyroute_test/wirexml/3NEAR_START.xml diff --git a/data/Tinyroute_test/answer2ALL.txt b/data/Tinyroute_test/answer2ALL.txt index d596c68..437da70 100644 --- a/data/Tinyroute_test/answer2ALL.txt +++ b/data/Tinyroute_test/answer2ALL.txt @@ -1,82 +1,140 @@ -12 +18 3 1 0 0 -clip196 0 -1020.1 -387.4 172.7 -3.93 0.368 -0.626 -clip204 0 -949.8 -380.8 161.6 -3.934 0.368 -0.626 -clip210 0 -879.5 -374.3 150.4 -3.934 0.368 -0.626 +END 0 +2047.2 -246.71 188.62 -0 -0 -0 +clip45 0 +2018.4 -498.7 208 -0.4 0.043 -0 +clip216 1 +1908 -486 203.4 -0.4 0 0 +1 +36 clip45 100.223 +3 1 0 0 +B 0 +239.95 -188.7 13.2 -0 -0 -0 +clip124 0 +200.9 -303 98.8 -0 -0 0.4 +clip461 0 +198.5 -270.8 239.1 -0 0.166 0.361 +1 +100 clip124 11 +3 1 0 0 +clip277 0 +1227.8 -409.9 179.2 -0 0.046 0.395 +clip479 0 +1222.1 -364.1 314.5 -0 0.193 0.347 +D 0 +1226 -129.3 372.3 -0 -0 -0 +1 +199 clip277 11 +3 1 0 0 +clip859 0 +1923.3 -364.4 459 -0 0.248 0.311 +clip871 0 +1923.3 -328.9 497.3 -0 0.274 0.288 +clip883 0 +1923.3 -290 532.1 -0 0.299 0.262 2 -80 clip196 10 -81 clip204 61.4827 +264 clip859 11 +265 clip871 34.1033 3 1 0 0 -clip226 1 -1797.4 -466.4 229.6 0 1.049 3.86 -clip234 1 -1797.3 -458.6 257.6 0 1.204 3.815 +clip873 0 +1875.7 -326.7 491.7 -0 0.274 0.288 +clip879 0 +1875.7 -308.2 509.2 -0 0.287 0.275 F 0 1872.3 -72.6 496.65 -0 -0 -0 1 -109 clip226 10 -6 1 0 0 -clip1540 1 -768.5 -139.1 416.4 3.974 -0.219 0.397 -clip1751 1 -1040.6 -139.3 416.6 4 0 0 -clip1728 1 -1102.4 -139.3 416.6 4 0 0 -clip1722 1 -1164.2 -139.3 416.6 4 0 0 -clip1714 1 -1226 -139.3 416.6 4 0 0 +566 clip873 11 +4 1 36 199 +clip105 0 +1698.5 -464.3 188.7 -0.4 0.043 -0 +clip262 1 +1588.1 -451.4 184.8 -0.4 0 0 +clip264 1 +1477.5 -438.1 185.5 -0.4 0 0 +clip274 1 +1366.8 -424.5 188 -0.4 0 0 +1 +84 clip262 100.399 +2 1 36 264 +clip313 0 +1908 -457.1 300.2 -0 0.155 0.366 +clip327 0 +1907.9 -436.8 346 -0 0.163 0.362 +0 +2 1 0 265 E 0 1715.3 -72.6 496.65 -0 -0 -0 -1 -704 clip1540 10 -2 1 80 0 -clip471 1 -1020.2 -342.6 305.5 0 1.719 3.612 -C 0 -1040.6 -129.3 372.3 -0 -0 -0 +clip1620 0 +1797.2 -231.3 490.5 0.4 -0 -0 0 -4 1 81 0 -clip215 0 -809.2 -367.7 139.2 -3.97 0.416 -0.25 -clip240 0 -700.6 -356.3 132.7 -3.97 0.427 -0.237 -clip246 0 -521.3 -337 122 -3.97 0.427 -0.237 -B 0 -239.95 -188.7 13.2 -0 -0 -0 +2 1 0 566 +clip851 0 +1875.7 -377.9 433.3 -0 0.234 0.321 +clip861 0 +1875.7 -361.2 454.3 -0 0.248 0.311 +1 +272 clip851 11 +3 1 0 84 +clip198 0 +911.4 -376 165.9 0.4 -0 -0 +clip278 0 +1088.8 -395.4 170.4 0.4 -0 -0 +clip276 0 +1227.8 -409.9 179.2 0.4 -0 -0 2 -102 clip215 99.39 -103 clip240 170.653 -2 1 0 102 -END 0 -2047.2 -246.71 188.62 -0 -0 -0 -clip109 0 -1058.8 -395.4 150.2 -3.97 0.428 -0.239 +141 clip198 11 +142 clip278 11 +1 1 272 36 +clip339 1 +1860.3 -431.9 343.5 0 -0.179 -0.355 0 -2 1 0 102 -clip120 0 -221.6 -305.2 38.8 3.97 -0.427 0.2369 -clip128 0 -400.9 -324.5 49.5 3.97 -0.427 0.2369 +2 1 141 0 +clip1559 0 +934.1 -319.6 289.3 -0 0.222 0.33 +clip1561 0 +934.1 -296.1 321.9 -0 0.242 0.315 +1 +898 clip1559 29.1872 +2 1 0 142 +clip200 0 +802.7 -364.7 159 0.4 -0 -0 +clip204 0 +949.8 -380.8 161.6 0.4 -0 -0 1 -46 clip120 10 -1 1 102 704 -clip1553 0 -768.6 -239.8 339.1 -0 2.744 2.91 +145 clip200 11 +2 1 0 898 +C 0 +1040.6 -129.3 372.3 -0 -0 -0 +clip1565 1 +934 -269.5 351.3 0 -0.267 -0.294 0 -2 1 0 103 +2 1 0 145 +clip135 1 +559.5 -341.6 120.2 0.398 -0.043 0 +clip241 1 +700.6 -356.3 132.7 0.395 -0.045 0 +1 +111 clip135 11 +2 1 100 111 +clip131 1 +380.2 -322.3 109.5 0.398 -0.043 0 +clip247 1 +521.3 -337 122 0.395 -0.045 0 +1 +105 clip131 11 +3 1 105 0 +clip251 0 +342 -317.7 111.3 -0.395 0.045 -0 +clip259 0 +162.4 -298.2 108.7 -0.398 0.042 -0 START 0 14.175 -227.3 104.1 -0 -0 -0 -clip250 1 -342 -317.7 111.3 3.97 -0.427 0.237 -0 -2 1 46 0 -clip1644 1 -240.5 -181.4 -3.2 0.329 3.986 0 +1 +185 clip251 40.8174 +2 1 185 0 +clip1653 1 +276.8 -177.1 -3.2 0 0.4 0 A 0 270.85 71.25 -9.9 -0 -0 -0 0 diff --git a/data/Tinyroute_test/wirexml/SE_Sa.xml b/data/Tinyroute_test/temp/SE_Sa.xml similarity index 80% rename from data/Tinyroute_test/wirexml/SE_Sa.xml rename to data/Tinyroute_test/temp/SE_Sa.xml index ef79999..6e0b50d 100644 --- a/data/Tinyroute_test/wirexml/SE_Sa.xml +++ b/data/Tinyroute_test/temp/SE_Sa.xml @@ -38,31 +38,31 @@ - + - + - + - + - + - + - + diff --git a/data/Tinyroute_test/temp/START_END.xml b/data/Tinyroute_test/temp/START_END.xml deleted file mode 100644 index fab5008..0000000 --- a/data/Tinyroute_test/temp/START_END.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/data/Tinyroute_test/wirexml/1START_END.xml b/data/Tinyroute_test/wirexml/1START_END.xml new file mode 100644 index 0000000..2c3217a --- /dev/null +++ b/data/Tinyroute_test/wirexml/1START_END.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/Tinyroute_test/temp/START_A-F.xml b/data/Tinyroute_test/wirexml/2NEAR_END.xml similarity index 66% rename from data/Tinyroute_test/temp/START_A-F.xml rename to data/Tinyroute_test/wirexml/2NEAR_END.xml index 77bf50a..abfb0ab 100644 --- a/data/Tinyroute_test/temp/START_A-F.xml +++ b/data/Tinyroute_test/wirexml/2NEAR_END.xml @@ -34,29 +34,25 @@ - - - - - - - - - - + + + + + + - - + + - - + - - - + + + + diff --git a/data/Tinyroute_test/wirexml/3NEAR_START.xml b/data/Tinyroute_test/wirexml/3NEAR_START.xml new file mode 100644 index 0000000..c46655e --- /dev/null +++ b/data/Tinyroute_test/wirexml/3NEAR_START.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/include/Const.h b/include/Const.h index 4acecc7..4163f96 100644 --- a/include/Const.h +++ b/include/Const.h @@ -25,9 +25,10 @@ const double minAngle = pi / 144; // const double R = 2000; // 飞机横截面的近似半径 const double MARGIN = 1000; // 布线的空间范围,从STL模型向外延申的长度 //----------------------mark---------------------- -const int MAXBranchPointNumOnSegment = 2; // 分支上的最大分支点数 +const int MAXBranchPointNumOnSegment = 4; // 分支上的最大分支点数 const int MAXPointNum = N + MAXBranchPointNumOnSegment * N; // 最大分支点数加最大卡箍数 -double segmentLength = 3000; // *卡箍到卡箍之间的最长距离 +// segmentLength=2000 报错:Assertion failed: vis[points[i]] == 0, file D:\SOURCE\WireRouting\WireRouting_CMakeDev\include\Path.h, line 72 +double segmentLength = 3000; // *卡箍到卡箍之间的最长距离(搜索半径)(目前2000-3000较好) const double MinClipToBranchPointDistance = 11; // 卡箍到分支点的最短距离 const double MinBranchPointDistance = 11; // 分支点到分支点的最短距离 @@ -42,7 +43,7 @@ double MAXX = -1e9, MINX = 1e9, MAXY = -1e9, MINY = 1e9, MAXZ = -1e9, MINZ = 1e9 vector vertices; // VS2008 vector indices; // VS2008 Mesh mesh; -const double intersection_distance = 100; //* +// const double intersection_distance = 100; //* int intersection_model = 0; typedef P Point3; @@ -124,6 +125,25 @@ inline Vector3 Cross(Vector3 A, Vector3 B) } inline double Area2(Point3 &A, Point3 &B, Point3 &C) { return Length(Cross(B - A, C - A)); } +inline double get_penalty_par_distance(double len) +{ + static const double intersection_distance = 180; + if (len <= intersection_distance) + return 1; + else if (len <= intersection_distance * 1.5) + return 1.4; + else if (len <= intersection_distance * 3) + return 2.6; + else if (len <= intersection_distance * 5) + return 6; + else if (len <= intersection_distance * 10) + return 15; + else if (len <= intersection_distance * 25) + return 30; + else + return 40; +} + /*考虑了连线方向,卡箍方向,连线长度的综合权值函数 A或者B type!=0时代表它们不是卡箍,对应的inOut没有意义 inOut1=0代表沿着A的dir,inOut1=1代表逆着A的dir @@ -163,7 +183,7 @@ inline double distan(P A, P B, int inOut1, int inOut2) // penalty_par_distance = 8; // else // penalty_par_distance = 1; - + penalty_par_distance = get_penalty_par_distance(len); double len1 = sqrt((A.y - Ycenter) * (A.y - Ycenter) + (A.z - Zcenter) * (A.z - Zcenter)); double len2 = sqrt((B.y - Ycenter) * (B.y - Ycenter) + (B.z - Zcenter) * (B.z - Zcenter)); @@ -246,6 +266,7 @@ inline double distan(P A, P B) // penalty_par_distance = 8; // else // penalty_par_distance = 1; + penalty_par_distance = get_penalty_par_distance(len); double len1 = sqrt((A.y - Ycenter) * (A.y - Ycenter) + (A.z - Zcenter) * (A.z - Zcenter)); double len2 = sqrt((B.y - Ycenter) * (B.y - Ycenter) + (B.z - Zcenter) * (B.z - Zcenter)); diff --git a/parameters.txt b/parameters.txt index cde1be3..41c0ad4 100644 --- a/parameters.txt +++ b/parameters.txt @@ -21,4 +21,12 @@ VScode CMake: } cmd: - .\WireRouting.exe createTinyroute ..\\..\\data\\Tinyroute_test\\clip2 ..\\..\\data\\Tinyroute_test\\wirexml ..\\..\\data\\Tinyroute_test\\connector.csv ..\\..\\data\\Tinyroute_test\\OBJ D:\\outFile\\output_ \ No newline at end of file + .\WireRouting.exe createTinyroute ..\\..\\data\\Tinyroute_test\\clip2 ..\\..\\data\\Tinyroute_test\\wirexml ..\\..\\data\\Tinyroute_test\\connector.csv ..\\..\\data\\Tinyroute_test\\OBJ D:\\outFile\\output_ + +VS2008: +createTinyroute +D:\SOURCE\WireRouting\WireRouting_CMakeDev\data\Tinyroute_test\clip2 +D:\SOURCE\WireRouting\WireRouting_CMakeDev\data\Tinyroute_test\wirexml +D:\SOURCE\WireRouting\WireRouting_CMakeDev\data\Tinyroute_test\connector.csv +D:\SOURCE\WireRouting\WireRouting_CMakeDev\data\Tinyroute_test\OBJ +C:\Users\yony\Downloads\output_vs2008 \ No newline at end of file