| 1355 | |
| 1356 | |
| 1357 | void |
| 1358 | testLine () |
| 1359 | { |
| 1360 | object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__"))))); |
| 1361 | object mainNamespace = mainModule.attr ("__dict__"); |
| 1362 | |
| 1363 | std::cerr << "Testing Line*:\n"; |
| 1364 | |
| 1365 | std::string code = |
| 1366 | "from imath import *\n" |
| 1367 | "l3f = Line3f (V3f (1.1, 2.2, 3.3), V3f (4.4, 5.5, 6.6))\n" |
| 1368 | "l3d = Line3d (V3d (7.7, 8.8, 9.9), V3d (10.10, 11.11, 12.12))\n" |
| 1369 | "i = 1\n" |
| 1370 | "from wrap import *\n" |
| 1371 | "w = wrap ('Line3f')\n" |
| 1372 | "p1 = V3f (1.1, 2.2, 3.3)\n" |
| 1373 | "p2 = V3f (4.4, 5.5, 6.6)\n" |
| 1374 | "d = (p2 - p1).normalize()\n" |
| 1375 | "assert w.pos().equalWithAbsError (p1, 1e-6)\n" |
| 1376 | "assert w.dir().equalWithAbsError (d, 1e-6)\n" |
| 1377 | "w = wrap ('Line3d')\n" |
| 1378 | "p1 = V3d (1.1, 2.2, 3.3)\n" |
| 1379 | "p2 = V3d (4.4, 5.5, 6.6)\n" |
| 1380 | "d = (p2 - p1).normalize()\n" |
| 1381 | "assert w.pos().equalWithAbsError (p1, 1e-6)\n" |
| 1382 | "assert w.dir().equalWithAbsError (d, 1e-6)\n"; |
| 1383 | |
| 1384 | handle<> ignored (PyRun_String (code.c_str(), Py_file_input, |
| 1385 | mainNamespace.ptr(), mainNamespace.ptr())); |
| 1386 | |
| 1387 | // |
| 1388 | |
| 1389 | extract <object> el3f (mainNamespace["l3f"]); |
| 1390 | assert (el3f.check()); |
| 1391 | |
| 1392 | PyObject *l3fObj = el3f().ptr(); |
| 1393 | assert (l3fObj != 0); |
| 1394 | |
| 1395 | extract <object> el3d (mainNamespace["l3d"]); |
| 1396 | assert (el3d.check()); |
| 1397 | |
| 1398 | PyObject *l3dObj = el3d().ptr(); |
| 1399 | assert (l3dObj != 0); |
| 1400 | |
| 1401 | extract <object> ei (mainNamespace["i"]); |
| 1402 | assert (ei.check()); |
| 1403 | |
| 1404 | PyObject *iObj = ei().ptr(); |
| 1405 | assert (iObj != 0); |
| 1406 | |
| 1407 | // |
| 1408 | |
| 1409 | std::cerr << "Testing Line3f:\n"; |
| 1410 | |
| 1411 | IMATH_NAMESPACE::Line3f l3fAsL3f; |
| 1412 | assert (PyImath::Line3f::convert (l3fObj, &l3fAsL3f) == 1); |
| 1413 | IMATH_NAMESPACE::V3f l3fP1f (1.1f, 2.2f, 3.3f); |
| 1414 | IMATH_NAMESPACE::V3f l3fP2f (4.4f, 5.5f, 6.6f); |
nothing calls this directly
no test coverage detected