MCPcopy Create free account
hub / github.com/Kitware/VTK / TestAMRBoxIntersection

Function TestAMRBoxIntersection

Common/DataModel/Testing/Cxx/TestAMRBox.cxx:222–277  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

220
221//------------------------------------------------------------------------------
222int TestAMRBoxIntersection()
223{
224 int rc = 0;
225
226 double h[3];
227 int lo[3];
228 int hi[3];
229
230 vtkAMRBox A0, A, B, I;
231
232 // Here is the initial AMR box
233 h[0] = h[1] = h[2] = 1.0;
234 lo[0] = lo[1] = lo[2] = 8;
235 hi[0] = hi[1] = hi[2] = 16;
236 Construct3DAMRBox(A, lo, hi);
237
238 // Save the initial
239 A0 = A;
240
241 B = A;
242 B.Shrink(2);
243 bool doesIntersect = A.Intersect(B);
244 if (!doesIntersect || (A != B))
245 {
246 std::cerr << "ERROR: Intersecting a fully encompassing box failed!\n";
247 rc++;
248 }
249
250 A = A0;
251 B = A;
252 B.Shift(2, 2, 2);
253
254 // Here is the expected box after intersecting
255 h[0] = h[1] = h[2] = 1.0;
256 lo[0] = lo[1] = lo[2] = 10;
257 hi[0] = hi[1] = hi[2] = 16;
258 Construct3DAMRBox(I, lo, hi);
259
260 doesIntersect = A.Intersect(B);
261 if (!doesIntersect || (A != I))
262 {
263 std::cerr << "ERROR: Intersecting a partially overlapping box failed!\n";
264 rc++;
265 }
266
267 A = A0;
268 B = A;
269 B.Shift(10, 10, 10);
270 doesIntersect = A.Intersect(B);
271 if (doesIntersect)
272 {
273 std::cerr << "ERROR: Intersecting a non-overlapping box failed!\n";
274 rc++;
275 }
276 return (rc);
277}
278
279//------------------------------------------------------------------------------

Callers 1

TestAMRBoxFunction · 0.85

Calls 4

Construct3DAMRBoxFunction · 0.85
IntersectMethod · 0.80
ShrinkMethod · 0.45
ShiftMethod · 0.45

Tested by

no test coverage detected