| 10 | { |
| 11 | |
| 12 | TEST(RadiusAssignFilterTest, basic_usage) |
| 13 | { |
| 14 | Options ro; |
| 15 | ro.add("filename", Support::datapath("filters/radiusassign/grid_20x10x10.txt")); |
| 16 | StageFactory factory; |
| 17 | Stage& r = *(factory.createStage("readers.text")); |
| 18 | r.setOptions(ro); |
| 19 | |
| 20 | std::vector<std::string> is3ds = {"false", "false", "true", "true"}; |
| 21 | std::vector<double> radVals = {1, 3.5, 1, 3.5}; |
| 22 | std::vector<unsigned int> nbUpdatedPoints = {0, 0, 0, 0}; |
| 23 | std::vector<unsigned int> nbExpectedUpdatedPoints = {10, 370, 1, 179}; |
| 24 | |
| 25 | for (size_t ii = 0; ii < radVals.size(); ii++) |
| 26 | { |
| 27 | Options ao; |
| 28 | ao.add("value", "Classification=1"); |
| 29 | ao.add("where", "(X == 5) && (Y == 5) && (Z == 5)"); |
| 30 | |
| 31 | Stage& a = *(factory.createStage("filters.assign")); |
| 32 | a.setInput(r); |
| 33 | a.setOptions(ao); |
| 34 | |
| 35 | Options fo; |
| 36 | fo.add("is3d", is3ds[ii]); |
| 37 | fo.add("reference_domain", "Classification[1:1]"); |
| 38 | fo.add("update_expression", "Classification = 2"); |
| 39 | fo.add("radius", radVals[ii]); |
| 40 | |
| 41 | Stage& f = *(factory.createStage("filters.radiusassign")); |
| 42 | f.setInput(a); |
| 43 | f.setOptions(fo); |
| 44 | |
| 45 | PointTable table; |
| 46 | f.prepare(table); |
| 47 | PointViewSet viewSet = f.execute(table); |
| 48 | PointViewPtr view = *viewSet.begin(); |
| 49 | |
| 50 | EXPECT_EQ(1u, viewSet.size()); |
| 51 | |
| 52 | PointRef point(*view, 0); |
| 53 | |
| 54 | for (PointId id = 0; id < view->size(); ++id) |
| 55 | { |
| 56 | point.setPointId(id); |
| 57 | if (view->getFieldAs<unsigned int>(Dimension::Id::Classification, id) == 2) |
| 58 | nbUpdatedPoints[ii] += 1; |
| 59 | } |
| 60 | // Check that some points are updated |
| 61 | EXPECT_TRUE(nbUpdatedPoints[ii] == nbExpectedUpdatedPoints[ii]) |
| 62 | << "Found: '" << nbUpdatedPoints[ii] << "'" << std::endl |
| 63 | << "expected: '" << nbExpectedUpdatedPoints[ii] <<"'" << std::endl; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | |
| 68 |
nothing calls this directly
no test coverage detected