MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_cell_query

Function test_cell_query

tests/mesh/test-light-regular-grid.cpp:229–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229void test_cell_query( const geode::LightRegularGrid3D& grid )
230{
231 geode::OpenGeodeMeshException::test(
232 !grid.contains( geode::Point3D( { 0, 0, 0 } ) ),
233 "Wrong result on contain: point is shown inside of grid where "
234 "it is not." );
235 geode::OpenGeodeMeshException::test(
236 !grid.contains( geode::Point3D( { 1.5, 0, 0 } ) ),
237 "Wrong result on contain: point is shown inside of grid where "
238 "it is not." );
239 geode::OpenGeodeMeshException::test(
240 grid.cells( geode::Point3D( { 0, 0, 0 } ) ).empty(),
241 "Wrong query result: point is shown inside of grid where it is "
242 "not." );
243 auto result = grid.cells( geode::Point3D( { 2, 2, 2 } ) );
244 geode::OpenGeodeMeshException::test(
245 result.size() == 2
246 && result.front() == geode::Grid3D::CellIndices( { 0, 0, 0 } )
247 && result.back() == geode::Grid3D::CellIndices( { 0, 1, 0 } ),
248 "Wrong query result" );
249 result = grid.cells( geode::Point3D( { 5, 7, 9 } ) );
250 geode::OpenGeodeMeshException::test(
251 result.size() == 1
252 && result.front() == geode::Grid3D::CellIndices( { 3, 3, 2 } ),
253 "Wrong query result" );
254 result = grid.cells( geode::Point3D( { 4.5, 6, 7 - 1e-10 } ) );
255 geode::OpenGeodeMeshException::test(
256 result.size() == 8
257 && result[0] == geode::Grid3D::CellIndices( { 2, 2, 1 } )
258 && result[1] == geode::Grid3D::CellIndices( { 3, 2, 1 } )
259 && result[2] == geode::Grid3D::CellIndices( { 2, 3, 1 } )
260 && result[3] == geode::Grid3D::CellIndices( { 3, 3, 1 } )
261 && result[4] == geode::Grid3D::CellIndices( { 2, 2, 2 } )
262 && result[5] == geode::Grid3D::CellIndices( { 3, 2, 2 } )
263 && result[6] == geode::Grid3D::CellIndices( { 2, 3, 2 } )
264 && result[7] == geode::Grid3D::CellIndices( { 3, 3, 2 } ),
265 "Wrong query result" );
266 geode::Point3D near_origin_point{ { 1.5 - geode::GLOBAL_EPSILON / 2,
267 -geode::GLOBAL_EPSILON / 2, 1 - geode::GLOBAL_EPSILON / 2 } };
268 geode::OpenGeodeMeshException::test( grid.contains( near_origin_point ),
269 "Wrong result on contain: point is shown outside of grid when "
270 "it should be inside." );
271 result = grid.cells( near_origin_point );
272 geode::OpenGeodeMeshException::test(
273 result.size() == 1
274 && result.front() == geode::Grid3D::CellIndices( { 0, 0, 0 } ),
275 "Wrong query result for point near origin." );
276 geode::Point3D grid_furthest_point{ { 6.5 + geode::GLOBAL_EPSILON / 2,
277 20 + geode::GLOBAL_EPSILON / 2, 46 + geode::GLOBAL_EPSILON / 2 } };
278 geode::OpenGeodeMeshException::test( grid.contains( grid_furthest_point ),
279 "Wrong result on contain: point is shown outside of grid when "
280 "it should be inside." );
281 result = grid.cells( grid_furthest_point );
282 geode::OpenGeodeMeshException::test(
283 result.size() == 1
284 && result.front() == geode::Grid3D::CellIndices( { 4, 9, 14 } ),
285 "Wrong query result for point near origin furthest corner." );
286}

Callers 1

testFunction · 0.70

Calls 5

emptyMethod · 0.80
testFunction · 0.70
containsMethod · 0.45
cellsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected