From 6bf40929ae3ec676d30203e50f929a85fec0b86d Mon Sep 17 00:00:00 2001 From: Alan <37482427+alemon-aquaveo@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:20:01 -0600 Subject: [PATCH] bug fix for the point connection fixer --- test_files/meshing/bug_14016.txt | 1 + test_files/meshing/bug_14016_base.2dm | 340 +++++++++--------- xmsmesher/meshing/MePolyMesher.cpp | 1 + .../meshing/detail/MePointConnectionFixer.cpp | 16 +- 4 files changed, 186 insertions(+), 172 deletions(-) diff --git a/test_files/meshing/bug_14016.txt b/test_files/meshing/bug_14016.txt index fc784ba5..d2f675c3 100644 --- a/test_files/meshing/bug_14016.txt +++ b/test_files/meshing/bug_14016.txt @@ -86,5 +86,6 @@ INSIDE 20 BIAS 0.2 CONST_SIZE_FUNCTION 20.0 0.2 REMOVE_INTERNAL_FOUR_TRIANGLE_PTS +FIX_POINT_CONNECTIONS END_POLYGON RETURN_CELL_POLYGONS diff --git a/test_files/meshing/bug_14016_base.2dm b/test_files/meshing/bug_14016_base.2dm index 8cc3be9f..322d9f04 100644 --- a/test_files/meshing/bug_14016_base.2dm +++ b/test_files/meshing/bug_14016_base.2dm @@ -305,54 +305,62 @@ E3T 303 168 195 196 1 E3T 304 168 196 169 1 E3T 305 169 196 197 1 E3T 306 169 197 170 1 -E3T 307 170 197 198 1 -E3T 308 170 198 171 1 -E3T 309 171 198 172 1 -E3T 310 172 198 199 1 -E3T 311 172 199 173 1 -E3T 312 173 179 174 1 -E3T 313 173 199 179 1 -E3T 314 175 178 176 1 -E3T 315 176 178 177 1 -E3T 316 179 199 180 1 -E3T 317 180 198 181 1 -E3T 318 180 199 198 1 -E3T 319 181 198 200 1 -E3T 320 181 200 182 1 -E3T 321 182 200 201 1 -E3T 322 182 201 183 1 -E3T 323 183 201 202 1 -E3T 324 183 202 184 1 -E3T 325 184 202 203 1 -E3T 326 184 203 185 1 -E3T 327 185 203 186 1 -E3T 328 186 203 204 1 -E3T 329 186 204 187 1 -E3T 330 187 204 188 1 -E3T 331 188 204 205 1 -E3T 332 188 205 189 1 -E3T 333 189 205 190 1 -E3T 334 190 205 191 1 -E3T 335 191 205 206 1 -E3T 336 191 206 192 1 -E3T 337 192 206 207 1 -E3T 338 192 207 193 1 -E3T 339 193 207 194 1 -E3T 340 194 207 208 1 -E3T 341 194 208 195 1 -E3T 342 195 208 209 1 -E3T 343 195 209 196 1 -E3T 344 196 209 197 1 -E3T 345 197 200 198 1 -E3T 346 197 209 200 1 -E3T 347 200 209 201 1 -E3T 348 201 208 202 1 -E3T 349 201 209 208 1 -E3T 350 202 207 203 1 -E3T 351 202 208 207 1 -E3T 352 203 207 204 1 -E3T 353 204 206 205 1 -E3T 354 204 207 206 1 +E3T 307 170 197 209 1 +E3T 308 170 209 171 1 +E3T 309 171 209 210 1 +E3T 310 171 210 172 1 +E3T 311 172 198 173 1 +E3T 312 172 210 198 1 +E3T 313 173 179 174 1 +E3T 314 173 198 179 1 +E3T 315 175 178 176 1 +E3T 316 176 178 177 1 +E3T 317 179 198 180 1 +E3T 318 180 198 208 1 +E3T 319 180 208 181 1 +E3T 320 181 199 182 1 +E3T 321 181 208 199 1 +E3T 322 182 199 200 1 +E3T 323 182 200 183 1 +E3T 324 183 200 201 1 +E3T 325 183 201 184 1 +E3T 326 184 201 202 1 +E3T 327 184 202 185 1 +E3T 328 185 202 186 1 +E3T 329 186 202 203 1 +E3T 330 186 203 187 1 +E3T 331 187 203 188 1 +E3T 332 188 203 204 1 +E3T 333 188 204 189 1 +E3T 334 189 204 190 1 +E3T 335 190 204 191 1 +E3T 336 191 204 205 1 +E3T 337 191 205 192 1 +E3T 338 192 205 212 1 +E3T 339 192 212 193 1 +E3T 340 193 212 213 1 +E3T 341 193 213 194 1 +E3T 342 194 206 195 1 +E3T 343 194 213 206 1 +E3T 344 195 206 207 1 +E3T 345 195 207 196 1 +E3T 346 196 207 197 1 +E3T 347 197 199 209 1 +E3T 348 197 207 199 1 +E3T 349 198 210 208 1 +E3T 350 199 207 200 1 +E3T 351 199 208 209 1 +E3T 352 200 206 201 1 +E3T 353 200 207 206 1 +E3T 354 201 206 211 1 +E3T 355 201 211 202 1 +E3T 356 202 211 203 1 +E3T 357 203 205 204 1 +E3T 358 203 211 205 1 +E3T 359 205 211 212 1 +E3T 360 206 213 211 1 +E3T 361 208 210 209 1 +E3T 362 211 213 212 1 ND 1 -27.207332 59.3978365 0.0 ND 2 -26.667342 61.6235694 0.0 ND 3 -25.954291 63.9136978 0.0 @@ -431,134 +439,138 @@ ND 75 -24.519405 59.1810558 0.0 ND 76 -24.217913 62.2590122 0.0 ND 77 -22.770674 65.0899446 0.0 ND 78 -20.991212 68.306736 0.0 -ND 79 -18.829901 71.531031 0.0 -ND 80 -17.037732 74.5795457 0.0 -ND 81 -13.519333 76.5799087 0.0 -ND 82 -9.5670989 79.1906221 0.0 -ND 83 -5.7478882 81.5977728 0.0 -ND 84 -1.5894256 83.0472885 0.0 -ND 85 3.43870671 85.5619699 0.0 -ND 86 9.03530515 87.0941989 0.0 -ND 87 14.0046573 89.0743972 0.0 -ND 88 19.5957915 89.1865881 0.0 -ND 89 26.4325811 89.9760833 0.0 -ND 90 33.8488663 89.5865896 0.0 -ND 91 40.3285317 90.0152724 0.0 -ND 92 47.581191 88.7084441 0.0 -ND 93 55.9201381 86.8076402 0.0 -ND 94 63.7625496 83.9309972 0.0 -ND 95 71.4036062 80.5776408 0.0 -ND 96 75.4715221 72.5833645 0.0 -ND 97 79.0431922 64.1158977 0.0 -ND 98 81.0686549 56.0106608 0.0 -ND 99 81.9722609 47.5811662 0.0 -ND 100 80.0517615 38.6268914 0.0 -ND 101 73.3575545 32.2122229 0.0 -ND 102 65.4389892 29.3956943 0.0 +ND 79 -18.845111 71.5267439 0.0 +ND 80 -17.047362 74.58625 0.0 +ND 81 -13.52569 76.5851165 0.0 +ND 82 -9.5547928 79.1969864 0.0 +ND 83 -5.7441942 81.5904099 0.0 +ND 84 -1.5919607 83.0536373 0.0 +ND 85 3.43058147 85.55415 0.0 +ND 86 9.03890545 87.1090604 0.0 +ND 87 14.0065631 89.0735563 0.0 +ND 88 19.5950174 89.1876448 0.0 +ND 89 26.419164 89.9831047 0.0 +ND 90 33.8109096 89.6447485 0.0 +ND 91 40.3438382 90.0672006 0.0 +ND 92 47.5882217 88.688993 0.0 +ND 93 55.873621 86.7892381 0.0 +ND 94 63.8215267 84.0027384 0.0 +ND 95 71.4013981 80.567034 0.0 +ND 96 75.4671042 72.5851142 0.0 +ND 97 79.0422442 64.1161187 0.0 +ND 98 81.0687935 56.0109236 0.0 +ND 99 81.9722404 47.5812006 0.0 +ND 100 80.0517646 38.6268967 0.0 +ND 101 73.3575553 32.2122235 0.0 +ND 102 65.4389894 29.3956943 0.0 ND 103 58.7630781 25.4626963 0.0 ND 104 50.996376 25.5226789 0.0 ND 105 43.5167535 24.7966782 0.0 ND 106 36.4401612 24.6480919 0.0 ND 107 29.7699868 24.7129266 0.0 -ND 108 23.2828923 25.2419278 0.0 -ND 109 17.0723357 26.6961003 0.0 -ND 110 11.3023875 27.8143261 0.0 -ND 111 5.25506336 29.3527065 0.0 -ND 112 0.38084378 31.2230009 0.0 -ND 113 -3.2695511 34.0898325 0.0 -ND 114 -7.6898146 36.6117198 0.0 +ND 108 23.2828948 25.2419195 0.0 +ND 109 17.07234 26.6960843 0.0 +ND 110 11.3023763 27.8143145 0.0 +ND 111 5.25506235 29.3527053 0.0 +ND 112 0.38084143 31.2229958 0.0 +ND 113 -3.2695564 34.089831 0.0 +ND 114 -7.689815 36.6117203 0.0 ND 115 -11.620615 39.000068 0.0 -ND 116 -14.216387 41.8211415 0.0 -ND 117 -17.261301 44.6633211 0.0 +ND 116 -14.216387 41.8211414 0.0 +ND 117 -17.261301 44.663321 0.0 ND 118 -20.122953 46.8245908 0.0 ND 119 -21.557944 50.0089177 0.0 ND 120 -23.474594 53.2955179 0.0 -ND 121 75.9128912 44.769451 0.0 -ND 122 76.0225817 50.7037914 0.0 -ND 123 70.1676445 51.2087738 0.0 -ND 124 65.9528125 47.3618811 0.0 -ND 125 59.6679285 47.1679118 0.0 -ND 126 52.7846508 48.141511 0.0 -ND 127 45.9313506 48.2861689 0.0 -ND 128 39.2482306 46.5203698 0.0 -ND 129 33.0855952 43.703406 0.0 -ND 130 28.106972 39.7224744 0.0 -ND 131 25.1792546 35.1076381 0.0 -ND 132 26.4274603 29.9413926 0.0 -ND 133 32.4192124 29.6971699 0.0 -ND 134 35.1840553 34.6749054 0.0 +ND 121 75.9128902 44.7694461 0.0 +ND 122 76.0227428 50.703636 0.0 +ND 123 70.1677122 51.2085226 0.0 +ND 124 65.952865 47.3616906 0.0 +ND 125 59.6847134 47.130111 0.0 +ND 126 52.786895 48.1162397 0.0 +ND 127 45.9438324 48.2673805 0.0 +ND 128 39.2400613 46.4893392 0.0 +ND 129 33.0836032 43.7059092 0.0 +ND 130 28.1072059 39.7219081 0.0 +ND 131 25.1792103 35.1076112 0.0 +ND 132 26.4274677 29.9413916 0.0 +ND 133 32.4192137 29.6971699 0.0 +ND 134 35.1840552 34.6749055 0.0 ND 135 41.0484711 36.8517156 0.0 ND 136 46.5856915 39.504937 0.0 ND 137 53.4869274 38.4164543 0.0 ND 138 60.6817947 36.4601425 0.0 -ND 139 67.2555348 36.7158588 0.0 -ND 140 72.8964426 39.8613284 0.0 -ND 141 72.0057942 57.1283207 0.0 -ND 142 64.0811842 53.2561498 0.0 -ND 143 56.274985 53.8342092 0.0 -ND 144 47.7363281 53.765851 0.0 -ND 145 39.5444505 52.4581685 0.0 -ND 146 31.9874833 49.2329249 0.0 -ND 147 25.582296 44.4642314 0.0 -ND 148 21.4409458 38.2155626 0.0 -ND 149 21.2632598 31.2861763 0.0 -ND 150 15.1537993 34.0430968 0.0 -ND 151 8.53692056 33.1939508 0.0 -ND 152 2.46841407 36.1228293 0.0 -ND 153 -3.6552877 39.5494772 0.0 -ND 154 -9.0372727 41.7515363 0.0 -ND 155 -12.738077 45.7819658 0.0 -ND 156 -16.952835 49.4070423 0.0 -ND 157 -20.064471 52.897034 0.0 -ND 158 -21.036961 57.1270924 0.0 -ND 159 -21.473534 61.3096669 0.0 -ND 160 -18.863364 65.0025902 0.0 -ND 161 -17.184223 68.6872576 0.0 -ND 162 -13.450861 71.761607 0.0 -ND 163 -9.4978366 74.9602274 0.0 -ND 164 -4.3984654 77.1778428 0.0 -ND 165 1.89848125 79.552981 0.0 -ND 166 8.38029941 81.4254728 0.0 -ND 167 14.8719442 84.0439511 0.0 -ND 168 22.1465504 83.655756 0.0 -ND 169 30.5623556 83.6353309 0.0 -ND 170 39.92714 82.8444057 0.0 -ND 171 48.627919 81.8800783 0.0 -ND 172 56.2546078 78.4968854 0.0 -ND 173 65.2017913 73.1803413 0.0 -ND 174 70.6044176 65.2782225 0.0 -ND 175 39.9585602 30.5747341 0.0 +ND 139 67.2555349 36.7158587 0.0 +ND 140 72.8964422 39.861327 0.0 +ND 141 72.015539 57.1180375 0.0 +ND 142 64.1066881 53.2735421 0.0 +ND 143 56.3407084 53.8165499 0.0 +ND 144 47.7822006 53.6649728 0.0 +ND 145 39.5176861 52.3543067 0.0 +ND 146 32.0147353 49.2258994 0.0 +ND 147 25.61208 44.467548 0.0 +ND 148 21.4643839 38.1976638 0.0 +ND 149 21.2622325 31.2824652 0.0 +ND 150 15.1682153 34.0194878 0.0 +ND 151 8.53477241 33.1511311 0.0 +ND 152 2.45317051 36.1037615 0.0 +ND 153 -3.6632284 39.5318915 0.0 +ND 154 -9.047425 41.7363998 0.0 +ND 155 -12.748896 45.7844706 0.0 +ND 156 -16.9595 49.4051287 0.0 +ND 157 -20.063681 52.8975099 0.0 +ND 158 -21.037885 57.1272179 0.0 +ND 159 -21.472518 61.3095049 0.0 +ND 160 -18.84512 65.0095829 0.0 +ND 161 -17.168739 68.6734509 0.0 +ND 162 -13.563014 71.792622 0.0 +ND 163 -9.5189653 75.0354057 0.0 +ND 164 -4.4092453 77.174227 0.0 +ND 165 1.89201523 79.5615188 0.0 +ND 166 8.39785064 81.5300426 0.0 +ND 167 14.8812715 84.0252928 0.0 +ND 168 22.1316755 83.6657258 0.0 +ND 169 30.5268203 83.6503741 0.0 +ND 170 39.5675168 83.2126611 0.0 +ND 171 48.430098 81.5669475 0.0 +ND 172 57.1363264 78.7735021 0.0 +ND 173 65.2205149 73.1446739 0.0 +ND 174 70.6398939 65.2836082 0.0 +ND 175 39.9585604 30.5747342 0.0 ND 176 47.3494959 34.542235 0.0 -ND 177 55.4340333 31.8248069 0.0 +ND 177 55.4340334 31.8248069 0.0 ND 178 47.4704212 29.9130439 0.0 -ND 179 62.0525125 61.7030483 0.0 -ND 180 51.0035383 61.7801278 0.0 -ND 181 41.6113321 60.6008945 0.0 -ND 182 32.0789601 56.4314245 0.0 -ND 183 23.4497783 50.999637 0.0 -ND 184 16.2371143 43.9058894 0.0 -ND 185 8.71778931 39.8293971 0.0 -ND 186 0.91030377 43.8268184 0.0 -ND 187 -6.3016974 46.087909 0.0 -ND 188 -11.211196 51.2091328 0.0 -ND 189 -16.343119 55.079091 0.0 -ND 190 -16.804804 60.7873666 0.0 -ND 191 -12.841008 65.7127787 0.0 -ND 192 -6.5827295 70.0863442 0.0 -ND 193 -0.4637056 73.2379413 0.0 -ND 194 6.69949248 74.3391915 0.0 -ND 195 15.8536104 76.4870599 0.0 -ND 196 25.1755545 77.4966984 0.0 -ND 197 34.3213256 75.5257086 0.0 -ND 198 45.1860927 72.4227303 0.0 -ND 199 55.9512771 69.6774918 0.0 -ND 200 34.610337 66.2460597 0.0 -ND 201 23.6962106 60.9444974 0.0 -ND 202 13.9403645 55.9991453 0.0 -ND 203 6.62570778 50.3941545 0.0 -ND 204 -2.853467 54.0246915 0.0 -ND 205 -10.925622 58.0202224 0.0 -ND 206 -6.1658042 62.9350695 0.0 -ND 207 3.26634881 63.6216949 0.0 -ND 208 13.8024167 67.3038169 0.0 -ND 209 24.4795303 70.0247483 0.0 +ND 179 62.0804474 61.7083727 0.0 +ND 180 51.5051336 60.664273 0.0 +ND 181 41.3892967 59.3762299 0.0 +ND 182 31.9953121 56.4547215 0.0 +ND 183 23.4614612 51.0164762 0.0 +ND 184 16.2406658 43.8500594 0.0 +ND 185 8.71581096 39.8105178 0.0 +ND 186 0.90457654 43.7643272 0.0 +ND 187 -6.3315927 46.064596 0.0 +ND 188 -11.218337 51.2345573 0.0 +ND 189 -16.336572 55.0791433 0.0 +ND 190 -16.806949 60.7900095 0.0 +ND 191 -12.806703 65.6331429 0.0 +ND 192 -7.338566 70.2471966 0.0 +ND 193 -0.3580959 73.27383 0.0 +ND 194 7.22267298 75.0137509 0.0 +ND 195 15.9001033 76.4341509 0.0 +ND 196 25.0977654 77.5246516 0.0 +ND 197 33.546417 75.5631604 0.0 +ND 198 55.8173969 69.2446027 0.0 +ND 199 35.0494269 66.1995268 0.0 +ND 200 23.7048488 60.9719009 0.0 +ND 201 14.6082554 55.1672779 0.0 +ND 202 7.10386134 49.0545363 0.0 +ND 203 -2.7897834 53.1603243 0.0 +ND 204 -10.909057 58.0384239 0.0 +ND 205 -5.4905528 62.2699547 0.0 +ND 206 13.6676628 66.6988914 0.0 +ND 207 24.4156106 69.9667622 0.0 +ND 208 45.6404576 67.0961928 0.0 +ND 209 41.8746109 74.70096 0.0 +ND 210 49.7810137 74.4429613 0.0 +ND 211 4.69440689 59.7276655 0.0 +ND 212 -1.230497 66.8572734 0.0 +ND 213 4.88785774 68.6060447 0.0 diff --git a/xmsmesher/meshing/MePolyMesher.cpp b/xmsmesher/meshing/MePolyMesher.cpp index 123468d2..542daf90 100644 --- a/xmsmesher/meshing/MePolyMesher.cpp +++ b/xmsmesher/meshing/MePolyMesher.cpp @@ -710,6 +710,7 @@ void MePolyMesherImpl::FixPointsWithTooManyConnections() if (m_tin->NumPoints() != nPts) { FindAllPolyPointIdxs(); + m_points = m_tin->PointsPtr(); } else { diff --git a/xmsmesher/meshing/detail/MePointConnectionFixer.cpp b/xmsmesher/meshing/detail/MePointConnectionFixer.cpp index 55e1317f..8bfd1f9b 100644 --- a/xmsmesher/meshing/detail/MePointConnectionFixer.cpp +++ b/xmsmesher/meshing/detail/MePointConnectionFixer.cpp @@ -121,8 +121,8 @@ BSHP MePointConnectionFixerImpl::Fix(const VecInt& a_noDeletePts) m_removePts.insert(i); CalcPolygonFromPointIndex(); CreateNewPoints(); - } - } + } + } CreateNewTin(); return m_outTin; } // MePointConnectionFixerImpl::Fix @@ -197,7 +197,7 @@ void MePointConnectionFixerImpl::CreateNewPoints() lengths.push_back(Mdist(p0.x, p0.y, p1.x, p1.y)); if (lengths.back() > maxDist) maxDist = lengths.back(); - } + } int numNewPts(0); VecPt3d newPoly; double factor(0.75); @@ -215,21 +215,21 @@ void MePointConnectionFixerImpl::CreateNewPoints() const Pt3d& p1(input.m_outPoly[i]); Pt3d p = (p0 + p1) / 2; newPoly.push_back(p); - } - } + } + } factor -= 0.1; - } + } newPoly.pop_back(); // remove first point from the end input.m_outPoly = newPoly; mpInput.m_polys[0] = input; pm->MeshIt(mpInput, 0, mpPts, mpTris, mpCells); - } + } // the new points should be the points in mpPts that are after the // input polygon for (size_t i = input.m_outPoly.size(); i < mpPts.size(); ++i) { m_newPts.push_back(mpPts[i]); - } + } } // MePointConnectionFixerImpl::CreateNewPoints //------------------------------------------------------------------------------ /// \brief Creates a new TIN incorporating the new points