| 1 |
#include "gtest/gtest.h" |
| 2 |
|
| 3 |
#include "stk_middle_mesh/predicates/edge_intersection_primitive.hpp" |
| 4 |
|
| 5 |
namespace stk { |
| 6 |
namespace middle_mesh { |
| 7 |
namespace impl { |
| 8 |
|
| 9 |
using namespace predicates::impl; |
| 10 |
|
| 11 |
TEST(EdgeIntersectionPrimitive, LinearbInteriorgInteriorIntersectionComputation) |
| 12 |
{ |
| 13 |
utils::Point b0(0.5, -0.5, 0), b1(0.5, 0.5, 0); |
| 14 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 15 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 16 |
|
| 17 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 18 |
edgeIntersectionData.compute_beta(); |
| 19 |
|
| 20 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 21 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0.5); |
| 22 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 23 |
|
| 24 |
edgeIntersectionData.compute_alpha(); |
| 25 |
|
| 26 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 27 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0.5); |
| 28 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 29 |
} |
| 30 |
|
| 31 |
TEST(EdgeIntersectionPrimitive, LinearbInteriorgInteriorIntersectionResult) |
| 32 |
{ |
| 33 |
utils::Point b0(0.5, -0.5, 0), b1(0.5, 0.5, 0); |
| 34 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 35 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 36 |
|
| 37 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 38 |
EXPECT_TRUE(result.intersection1_found()); |
| 39 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0.5); |
| 40 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0.5); |
| 41 |
} |
| 42 |
|
| 43 |
TEST(EdgeIntersectionPrimitive, LinearbVertex0gVertex0IntersectionComputation) |
| 44 |
{ |
| 45 |
utils::Point b0(0, 0, 0), b1(0, 1, 0); |
| 46 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 47 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 48 |
|
| 49 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 50 |
edgeIntersectionData.compute_beta(); |
| 51 |
|
| 52 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 53 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0); |
| 54 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 55 |
|
| 56 |
edgeIntersectionData.compute_alpha(); |
| 57 |
|
| 58 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 59 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0); |
| 60 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 61 |
} |
| 62 |
|
| 63 |
TEST(EdgeIntersectionPrimitive, LinearbVertex0gVertex0IntersectionResult) |
| 64 |
{ |
| 65 |
utils::Point b0(0, 0, 0), b1(0, 1, 0); |
| 66 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 67 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 68 |
|
| 69 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 70 |
EXPECT_TRUE(result.intersection1_found()); |
| 71 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0); |
| 72 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0); |
| 73 |
} |
| 74 |
|
| 75 |
TEST(EdgeIntersectionPrimitive, LinearbVertex1gVertex0IntersectionComputation) |
| 76 |
{ |
| 77 |
utils::Point b0(1, 0, 0), b1(1, 1, 0); |
| 78 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 79 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 80 |
|
| 81 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 82 |
edgeIntersectionData.compute_beta(); |
| 83 |
|
| 84 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 85 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 1); |
| 86 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 87 |
|
| 88 |
edgeIntersectionData.compute_alpha(); |
| 89 |
|
| 90 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 91 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0); |
| 92 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 93 |
} |
| 94 |
|
| 95 |
TEST(EdgeIntersectionPrimitive, LinearbVertex1gVertex0IntersectionResult) |
| 96 |
{ |
| 97 |
utils::Point b0(1, 0, 0), b1(1, 1, 0); |
| 98 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 99 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 100 |
|
| 101 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 102 |
EXPECT_TRUE(result.intersection1_found()); |
| 103 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 1); |
| 104 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0); |
| 105 |
} |
| 106 |
|
| 107 |
TEST(EdgeIntersectionPrimitive, LinearbVertex0gVertex1IntersectionComputation) |
| 108 |
{ |
| 109 |
utils::Point b0(0, -1, 0), b1(0, 0, 0); |
| 110 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 111 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 112 |
|
| 113 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 114 |
edgeIntersectionData.compute_beta(); |
| 115 |
|
| 116 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 117 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0); |
| 118 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 119 |
|
| 120 |
edgeIntersectionData.compute_alpha(); |
| 121 |
|
| 122 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 123 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 1); |
| 124 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 125 |
} |
| 126 |
|
| 127 |
TEST(EdgeIntersectionPrimitive, LinearbVertex0gVertex1IntersectionResult) |
| 128 |
{ |
| 129 |
utils::Point b0(0, -1, 0), b1(0, 0, 0); |
| 130 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 131 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 132 |
|
| 133 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 134 |
EXPECT_TRUE(result.intersection1_found()); |
| 135 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0); |
| 136 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 1); |
| 137 |
} |
| 138 |
|
| 139 |
TEST(EdgeIntersectionPrimitive, LinearbVertex1gVertex1IntersectionComputation) |
| 140 |
{ |
| 141 |
utils::Point b0(1, -1, 0), b1(1, 0, 0); |
| 142 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 143 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 144 |
|
| 145 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 146 |
edgeIntersectionData.compute_beta(); |
| 147 |
|
| 148 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 149 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 1); |
| 150 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 151 |
|
| 152 |
edgeIntersectionData.compute_alpha(); |
| 153 |
|
| 154 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 155 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 1); |
| 156 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 157 |
} |
| 158 |
|
| 159 |
TEST(EdgeIntersectionPrimitive, LinearbVertex1gVertex1IntersectionResult) |
| 160 |
{ |
| 161 |
utils::Point b0(1, -1, 0), b1(1, 0, 0); |
| 162 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 163 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 164 |
|
| 165 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 166 |
EXPECT_TRUE(result.intersection1_found()); |
| 167 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 1); |
| 168 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 1); |
| 169 |
} |
| 170 |
|
| 171 |
TEST(EdgeIntersectionPrimitive, LinearbInteriorgVertexIntersectionComputation) |
| 172 |
{ |
| 173 |
utils::Point b0(0, -0.5, 0), b1(0, 0.5, 0); |
| 174 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 175 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 176 |
|
| 177 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 178 |
edgeIntersectionData.compute_beta(); |
| 179 |
|
| 180 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 181 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0); |
| 182 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 183 |
|
| 184 |
edgeIntersectionData.compute_alpha(); |
| 185 |
|
| 186 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 187 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0.5); |
| 188 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 189 |
} |
| 190 |
|
| 191 |
TEST(EdgeIntersectionPrimitive, LinearbInteriorgVertexIntersectionResult) |
| 192 |
{ |
| 193 |
utils::Point b0(0, -0.5, 0), b1(0, 0.5, 0); |
| 194 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 195 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 196 |
|
| 197 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 198 |
EXPECT_TRUE(result.intersection1_found()); |
| 199 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0); |
| 200 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0.5); |
| 201 |
} |
| 202 |
|
| 203 |
TEST(EdgeIntersectionPrimitive, LinearbVertexgInteriorIntersectionComputation) |
| 204 |
{ |
| 205 |
utils::Point b0(0.5, 0, 0), b1(0.5, 1, 0); |
| 206 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 207 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 208 |
|
| 209 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 210 |
edgeIntersectionData.compute_beta(); |
| 211 |
|
| 212 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 213 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0.5); |
| 214 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 215 |
|
| 216 |
edgeIntersectionData.compute_alpha(); |
| 217 |
|
| 218 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 219 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0); |
| 220 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 221 |
} |
| 222 |
|
| 223 |
TEST(EdgeIntersectionPrimitive, LinearbVertexgInteriorIntersectionResult) |
| 224 |
{ |
| 225 |
utils::Point b0(0.5, 0, 0), b1(0.5, 1, 0); |
| 226 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 227 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 228 |
|
| 229 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 230 |
EXPECT_TRUE(result.intersection1_found()); |
| 231 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0.5); |
| 232 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0); |
| 233 |
} |
| 234 |
|
| 235 |
TEST(EdgeIntersectionPrimitive, LinearbgParallelIntersectionComputation1) |
| 236 |
{ |
| 237 |
utils::Point b0(0, 0, 0), b1(1, 0, 0); |
| 238 |
utils::Point g0(0, 1, 0), g1(1, 1, 0); |
| 239 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 240 |
|
| 241 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 242 |
edgeIntersectionData.compute_beta(); |
| 243 |
|
| 244 |
EXPECT_FALSE(edgeIntersectionData.is_beta_1_valid()); |
| 245 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 246 |
|
| 247 |
edgeIntersectionData.compute_alpha(); |
| 248 |
|
| 249 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_1_valid()); |
| 250 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 251 |
} |
| 252 |
|
| 253 |
TEST(EdgeIntersectionPrimitive, LinearbgParallelIntersectionResult1) |
| 254 |
{ |
| 255 |
utils::Point b0(0, 0, 0), b1(1, 0, 0); |
| 256 |
utils::Point g0(0, 1, 0), g1(1, 1, 0); |
| 257 |
utils::Point d0(0, 0, 1), d1(0, 0, 1); |
| 258 |
|
| 259 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 260 |
EXPECT_FALSE(result.intersection1_found()); |
| 261 |
} |
| 262 |
|
| 263 |
TEST(EdgeIntersectionPrimitive, LinearbgParallelIntersectionComputation2) |
| 264 |
{ |
| 265 |
utils::Point b0(0, 0, 0), b1(1, 0, 0); |
| 266 |
utils::Point g0(0, 1, 0), g1(1, 1, 0); |
| 267 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 268 |
|
| 269 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 270 |
edgeIntersectionData.compute_beta(); |
| 271 |
|
| 272 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 273 |
EXPECT_NEAR(edgeIntersectionData.get_beta_1_value(), 0.634, 1e-4); |
| 274 |
EXPECT_FALSE(edgeIntersectionData.is_beta_2_valid()); |
| 275 |
|
| 276 |
edgeIntersectionData.compute_alpha(); |
| 277 |
|
| 278 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 279 |
EXPECT_FALSE(edgeIntersectionData.is_alpha_2_valid()); |
| 280 |
} |
| 281 |
|
| 282 |
TEST(EdgeIntersectionPrimitive, LinearbgParallelIntersectionResult2) |
| 283 |
{ |
| 284 |
utils::Point b0(0, 0, 0), b1(1, 0, 0); |
| 285 |
utils::Point g0(0, 1, 0), g1(1, 1, 0); |
| 286 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 287 |
|
| 288 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 289 |
EXPECT_TRUE(result.intersection1_found()); |
| 290 |
} |
| 291 |
|
| 292 |
TEST(EdgeIntersectionPrimitive, QuadraticbInteriorgInteriorOneSolutionIntersectionComputation) |
| 293 |
{ |
| 294 |
utils::Point b0(0.5, -0.5, 0), b1(0.5, 0.5, 0); |
| 295 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 296 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 297 |
|
| 298 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 299 |
edgeIntersectionData.compute_beta(); |
| 300 |
|
| 301 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 302 |
EXPECT_NEAR(edgeIntersectionData.get_beta_1_value(), 0.5, 1e-13); |
| 303 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 304 |
EXPECT_NEAR(edgeIntersectionData.get_beta_2_value(), 0.634, 1e-4); |
| 305 |
|
| 306 |
edgeIntersectionData.compute_alpha(); |
| 307 |
|
| 308 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 309 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0.5); |
| 310 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 311 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_2_value(), 0.366025, 1e-4); |
| 312 |
} |
| 313 |
|
| 314 |
TEST(EdgeIntersectionPrimitive, QuadraticbInteriorgInteriorOneSolutionIntersectionResult) |
| 315 |
{ |
| 316 |
utils::Point b0(0.5, -0.5, 0), b1(0.5, 0.5, 0); |
| 317 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 318 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 319 |
|
| 320 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 321 |
EXPECT_TRUE(result.intersection1_found()); |
| 322 |
EXPECT_NEAR(result.get_beta1(), 0.5, 1e-13); |
| 323 |
EXPECT_NEAR(result.get_alpha1(), 0.5, 1e-13); |
| 324 |
} |
| 325 |
|
| 326 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex0gVertex0OneSolutionIntersectionComputation) |
| 327 |
{ |
| 328 |
utils::Point b0(0, 0, 0), b1(0, 1, 0); |
| 329 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 330 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 331 |
|
| 332 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 333 |
edgeIntersectionData.compute_beta(); |
| 334 |
|
| 335 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 336 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0); |
| 337 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 338 |
EXPECT_NEAR(edgeIntersectionData.get_beta_2_value(), 0.634, 1e-4); |
| 339 |
|
| 340 |
edgeIntersectionData.compute_alpha(); |
| 341 |
|
| 342 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 343 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0); |
| 344 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 345 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_2_value(), -0.633975, 1e-4); |
| 346 |
} |
| 347 |
|
| 348 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex0gVertex0OneSolutionIntersectionResult) |
| 349 |
{ |
| 350 |
utils::Point b0(0, 0, 0), b1(0, 1, 0); |
| 351 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 352 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 353 |
|
| 354 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 355 |
EXPECT_TRUE(result.intersection1_found()); |
| 356 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0); |
| 357 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0); |
| 358 |
} |
| 359 |
|
| 360 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex1gVertex0IntersectionOneSolutionComputation) |
| 361 |
{ |
| 362 |
utils::Point b0(1, 0, 0), b1(1, 1, 0); |
| 363 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 364 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 365 |
|
| 366 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 367 |
edgeIntersectionData.compute_beta(); |
| 368 |
|
| 369 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 370 |
EXPECT_NEAR(edgeIntersectionData.get_beta_1_value(), 0.634, 1e-4); |
| 371 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 372 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_2_value(), 1); |
| 373 |
|
| 374 |
edgeIntersectionData.compute_alpha(); |
| 375 |
|
| 376 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 377 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_1_value(), 0.366025, 1e-4); |
| 378 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 379 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_2_value(), 0, 1e-13); |
| 380 |
} |
| 381 |
|
| 382 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex1gVertex0OneSolutionIntersectionResult) |
| 383 |
{ |
| 384 |
utils::Point b0(1, 0, 0), b1(1, 1, 0); |
| 385 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 386 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 387 |
|
| 388 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 389 |
EXPECT_TRUE(result.intersection1_found()); |
| 390 |
EXPECT_TRUE(result.intersection2_found()); |
| 391 |
|
| 392 |
EXPECT_NEAR(result.get_beta1(), 0.633975, 1e-4); |
| 393 |
EXPECT_NEAR(result.get_alpha1(), 0.366025, 1e-4); |
| 394 |
|
| 395 |
EXPECT_NEAR(result.get_beta2(), 1, 1e-13); |
| 396 |
EXPECT_NEAR(result.get_alpha2(), 0, 1e-13); |
| 397 |
} |
| 398 |
|
| 399 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex0gVertex1OneSolutionIntersectionComputation) |
| 400 |
{ |
| 401 |
utils::Point b0(0, -1, 0), b1(0, 0, 0); |
| 402 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 403 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 404 |
|
| 405 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 406 |
edgeIntersectionData.compute_beta(); |
| 407 |
|
| 408 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 409 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0); |
| 410 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 411 |
EXPECT_NEAR(edgeIntersectionData.get_beta_2_value(), 0.634, 1e-4); |
| 412 |
|
| 413 |
edgeIntersectionData.compute_alpha(); |
| 414 |
|
| 415 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 416 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 1); |
| 417 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 418 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_2_value(), 0.366025, 1e-4); |
| 419 |
} |
| 420 |
|
| 421 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex0gVertex1OneSolutionIntersectionResult) |
| 422 |
{ |
| 423 |
utils::Point b0(0, -1, 0), b1(0, 0, 0); |
| 424 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 425 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 426 |
|
| 427 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 428 |
EXPECT_TRUE(result.intersection1_found()); |
| 429 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0); |
| 430 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 1); |
| 431 |
} |
| 432 |
|
| 433 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex1gVertex1OneSolutionIntersectionComputation) |
| 434 |
{ |
| 435 |
utils::Point b0(1, -1, 0), b1(1, 0, 0); |
| 436 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 437 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 438 |
|
| 439 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 440 |
edgeIntersectionData.compute_beta(); |
| 441 |
|
| 442 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 443 |
EXPECT_NEAR(edgeIntersectionData.get_beta_1_value(), 0.634, 1e-4); |
| 444 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 445 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_2_value(), 1); |
| 446 |
|
| 447 |
edgeIntersectionData.compute_alpha(); |
| 448 |
|
| 449 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 450 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_1_value(), 1.36603, 1e-4); |
| 451 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 452 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_2_value(), 1); |
| 453 |
} |
| 454 |
|
| 455 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertex1gVertex1OneSolutionIntersectionResult) |
| 456 |
{ |
| 457 |
utils::Point b0(1, -1, 0), b1(1, 0, 0); |
| 458 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 459 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 460 |
|
| 461 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 462 |
EXPECT_TRUE(result.intersection1_found()); |
| 463 |
EXPECT_TRUE(result.intersection2_found()); |
| 464 |
|
| 465 |
EXPECT_NEAR(result.get_beta1(), 0.633975, 1e-4); |
| 466 |
EXPECT_NEAR(result.get_alpha1(), 1.36603, 1e-4); |
| 467 |
|
| 468 |
EXPECT_DOUBLE_EQ(result.get_beta2(), 1); |
| 469 |
EXPECT_DOUBLE_EQ(result.get_alpha2(), 1); |
| 470 |
} |
| 471 |
|
| 472 |
TEST(EdgeIntersectionPrimitive, QuadraticbInteriorgVertexOneSolutionIntersectionComputation) |
| 473 |
{ |
| 474 |
utils::Point b0(0, -0.5, 0), b1(0, 0.5, 0); |
| 475 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 476 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 477 |
|
| 478 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 479 |
edgeIntersectionData.compute_beta(); |
| 480 |
|
| 481 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 482 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_beta_1_value(), 0); |
| 483 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 484 |
EXPECT_NEAR(edgeIntersectionData.get_beta_2_value(), 0.634, 1e-4); |
| 485 |
|
| 486 |
edgeIntersectionData.compute_alpha(); |
| 487 |
|
| 488 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 489 |
EXPECT_DOUBLE_EQ(edgeIntersectionData.get_alpha_1_value(), 0.5); |
| 490 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 491 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_2_value(), -0.133975, 1e-4); |
| 492 |
} |
| 493 |
|
| 494 |
TEST(EdgeIntersectionPrimitive, QuadraticbInteriorgVertexOneSolutionIntersectionResult) |
| 495 |
{ |
| 496 |
utils::Point b0(0, -0.5, 0), b1(0, 0.5, 0); |
| 497 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 498 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 499 |
|
| 500 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 501 |
EXPECT_TRUE(result.intersection1_found()); |
| 502 |
EXPECT_DOUBLE_EQ(result.get_beta1(), 0); |
| 503 |
EXPECT_DOUBLE_EQ(result.get_alpha1(), 0.5); |
| 504 |
} |
| 505 |
|
| 506 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertexgInteriorOneSolutionIntersectionComputation) |
| 507 |
{ |
| 508 |
utils::Point b0(0.5, 0, 0), b1(0.5, 1, 0); |
| 509 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 510 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 511 |
|
| 512 |
EdgeIntersectionData edgeIntersectionData(b0, b1, g0, g1, d0, d1); |
| 513 |
edgeIntersectionData.compute_beta(); |
| 514 |
|
| 515 |
EXPECT_TRUE(edgeIntersectionData.is_beta_1_valid()); |
| 516 |
EXPECT_NEAR(edgeIntersectionData.get_beta_1_value(), 0.5, 1e-13); |
| 517 |
EXPECT_TRUE(edgeIntersectionData.is_beta_2_valid()); |
| 518 |
EXPECT_NEAR(edgeIntersectionData.get_beta_2_value(), 0.634, 1e-4); |
| 519 |
|
| 520 |
edgeIntersectionData.compute_alpha(); |
| 521 |
|
| 522 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_1_valid()); |
| 523 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_1_value(), 0, 1e-13); |
| 524 |
EXPECT_TRUE(edgeIntersectionData.is_alpha_2_valid()); |
| 525 |
EXPECT_NEAR(edgeIntersectionData.get_alpha_2_value(), -0.133975, 1e-4); |
| 526 |
} |
| 527 |
|
| 528 |
TEST(EdgeIntersectionPrimitive, QuadraticbVertexgInteriorOneSolutionIntersectionResult) |
| 529 |
{ |
| 530 |
utils::Point b0(0.5, 0, 0), b1(0.5, 1, 0); |
| 531 |
utils::Point g0(0, 0, 0), g1(1, 0, 0); |
| 532 |
utils::Point d0(0, 0, 1), d1(1 / std::sqrt(3), 1 / std::sqrt(3), -1 / std::sqrt(3)); |
| 533 |
|
| 534 |
EdgeIntersectionResult result = compute_edge_intersection(b0, b1, g0, g1, d0, d1); |
| 535 |
EXPECT_TRUE(result.intersection1_found()); |
| 536 |
EXPECT_NEAR(result.get_beta1(), 0.5, 1e-13); |
| 537 |
EXPECT_NEAR(result.get_alpha1(), 0, 1e-13); |
| 538 |
} |
| 539 |
|
| 540 |
TEST(EdgeIntersectionPrimitive, Regression) |
| 541 |
{ |
| 542 |
// from James Overfelt, 5/25/2023 |
| 543 |
const stk::middle_mesh::utils::Point edge1Pt1 (1.0000000000000002, 0, 0.39999999999999997); |
| 544 |
const stk::middle_mesh::utils::Point edge1Pt2 (1, 0.20000000000000107, 0.40000000000000019); |
| 545 |
const stk::middle_mesh::utils::Point edge2Pt1 (1, -3.388131789017199e-18, 0.44999999999999996); |
| 546 |
const stk::middle_mesh::utils::Point edge2Pt2 (1.0000000000000002, -1.3552527156068807e-18, 0.41999999999999998); |
| 547 |
const stk::middle_mesh::utils::Point pt1Normal (0.031079502397333692, -2.091728074970464e-16, 1.1501726385137537e-16); |
| 548 |
const stk::middle_mesh::utils::Point pt2Normal (0.02493346738921879, -0.016448179238063677, 1.0961226633804594e-16); |
| 549 |
EdgeIntersectionResult result = stk::middle_mesh::predicates::impl::compute_edge_intersection(edge1Pt1, edge1Pt2, edge2Pt1, edge2Pt2, |
| 550 |
pt1Normal, pt2Normal, 1e-12, 0.25); |
| 551 |
|
| 552 |
EXPECT_TRUE(result.intersection1_found()); |
| 553 |
EXPECT_FALSE(result.intersection2_found()); |
| 554 |
} |
| 555 |
|
| 556 |
} // namespace impl |
| 557 |
} // namespace middle_mesh |
| 558 |
} // namespace stk |