| 345 | } |
| 346 | |
| 347 | void testGrid(point_count_t xlimit, point_count_t ylimit, point_count_t zlimit) |
| 348 | { |
| 349 | point_count_t size = 1; |
| 350 | if (xlimit) |
| 351 | size *= xlimit; |
| 352 | if (ylimit) |
| 353 | size *= ylimit; |
| 354 | if (zlimit) |
| 355 | size *= zlimit; |
| 356 | if (!xlimit && !ylimit && !zlimit) |
| 357 | return; |
| 358 | |
| 359 | Options ops; |
| 360 | |
| 361 | ops.add("bounds", BOX3D(0, 0, 0, |
| 362 | (double)xlimit, (double)ylimit, (double)zlimit)); |
| 363 | ops.add("mode", "grid"); |
| 364 | FauxReader reader; |
| 365 | reader.setOptions(ops); |
| 366 | |
| 367 | PointTable table; |
| 368 | reader.prepare(table); |
| 369 | PointViewSet viewSet = reader.execute(table); |
| 370 | EXPECT_EQ(viewSet.size(), 1u); |
| 371 | PointViewPtr view = *viewSet.begin(); |
| 372 | EXPECT_EQ(view->size(), size); |
| 373 | |
| 374 | PointId index = 0; |
| 375 | int x = 0; |
| 376 | int y = 0; |
| 377 | int z = 0; |
| 378 | for (PointId index = 0; index < size; index++) |
| 379 | { |
| 380 | EXPECT_EQ(x, view->getFieldAs<int>(Dimension::Id::X, index)); |
| 381 | EXPECT_EQ(y, view->getFieldAs<int>(Dimension::Id::Y, index)); |
| 382 | EXPECT_EQ(z, view->getFieldAs<int>(Dimension::Id::Z, index)); |
| 383 | bool incNext = true; |
| 384 | if (xlimit) |
| 385 | { |
| 386 | x++; |
| 387 | if (x >= (int)xlimit) |
| 388 | x = 0; |
| 389 | else |
| 390 | incNext = false; |
| 391 | } |
| 392 | |
| 393 | if (ylimit && incNext) |
| 394 | { |
| 395 | y++; |
| 396 | if (y >= (int)ylimit) |
| 397 | y = 0; |
| 398 | else |
| 399 | incNext = false; |
| 400 | } |
| 401 | |
| 402 | if (zlimit && incNext) |
| 403 | z++; |
| 404 | } |