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

Function test_cell_query

tests/mesh/test-regular-grid.cpp:246–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246void test_cell_query( const geode::RegularGrid3D& grid )
247{
248 geode::OpenGeodeMeshException::test(
249 !grid.contains( geode::Point3D( { 0, 0, 0 } ) ),
250 "Wrong result on contain: point [0,0,0] is shown inside of grid "
251 "where "
252 "it is not." );
253 geode::OpenGeodeMeshException::test(
254 !grid.contains( geode::Point3D( { 1.5, 0, 0 } ) ),
255 "Wrong result on contain: point [1.5,0,0] is shown inside of "
256 "grid where "
257 "it is not." );
258 geode::OpenGeodeMeshException::test(
259 grid.cells( geode::Point3D( { 0, 0, 0 } ) ).empty(),
260 "Wrong query result: point is shown inside of grid where it is "
261 "not." );
262 auto result = grid.cells( geode::Point3D( { -0.5, -1.5, 1.5 } ) );
263 geode::OpenGeodeMeshException::test(
264 result.size() == 2
265 && result.front() == geode::Grid3D::CellIndices( { 0, 0, 0 } )
266 && result.back() == geode::Grid3D::CellIndices( { 0, 1, 0 } ),
267 "Wrong query result" );
268 result = grid.cells( geode::Point3D( { -5.5, -8, 4.5 } ) );
269 geode::OpenGeodeMeshException::test(
270 result.size() == 1
271 && result.front() == geode::Grid3D::CellIndices( { 3, 3, 2 } ),
272 "Wrong query result" );
273 result = grid.cells( geode::Point3D( { -4.5, -6 - 1e-10, 4 } ) );
274 geode::OpenGeodeMeshException::test(
275 result.size() == 8
276 && result[0] == geode::Grid3D::CellIndices( { 2, 2, 1 } )
277 && result[1] == geode::Grid3D::CellIndices( { 3, 2, 1 } )
278 && result[2] == geode::Grid3D::CellIndices( { 2, 3, 1 } )
279 && result[3] == geode::Grid3D::CellIndices( { 3, 3, 1 } )
280 && result[4] == geode::Grid3D::CellIndices( { 2, 2, 2 } )
281 && result[5] == geode::Grid3D::CellIndices( { 3, 2, 2 } )
282 && result[6] == geode::Grid3D::CellIndices( { 2, 3, 2 } )
283 && result[7] == geode::Grid3D::CellIndices( { 3, 3, 2 } ),
284 "Wrong query result" );
285 geode::Point3D near_origin_point{ { 1.5 + geode::GLOBAL_EPSILON / 2,
286 geode::GLOBAL_EPSILON / 2, 1 - geode::GLOBAL_EPSILON / 2 } };
287 geode::OpenGeodeMeshException::test( grid.contains( near_origin_point ),
288 "Wrong result on contain: point is shown outside of grid when "
289 "it should be inside." );
290 result = grid.cells( near_origin_point );
291 geode::OpenGeodeMeshException::test(
292 result.size() == 1
293 && result.front() == geode::Grid3D::CellIndices( { 0, 0, 0 } ),
294 "Wrong query result for point near origin." );
295 geode::Point3D grid_furthest_point{ { -18.5 - geode::GLOBAL_EPSILON / 2,
296 -45 - geode::GLOBAL_EPSILON / 2, 6 + geode::GLOBAL_EPSILON / 2 } };
297 geode::OpenGeodeMeshException::test( grid.contains( grid_furthest_point ),
298 "Wrong result on contain: point is shown outside of grid when "
299 "it should be inside." );
300 result = grid.cells( grid_furthest_point );
301 geode::OpenGeodeMeshException::test(
302 result.size() == 1
303 && result.front() == geode::Grid3D::CellIndices( { 4, 9, 14 } ),

Callers 1

test_gridFunction · 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