| 1657 | |
| 1658 | |
| 1659 | void |
| 1660 | testPlane () |
| 1661 | { |
| 1662 | object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__"))))); |
| 1663 | object mainNamespace = mainModule.attr ("__dict__"); |
| 1664 | |
| 1665 | std::cerr << "Testing Plane*:\n"; |
| 1666 | |
| 1667 | std::string code = |
| 1668 | "from imath import *\n" |
| 1669 | "p3f = Plane3f (V3f (1.1, 2.2, 3.3), 4.4)\n" |
| 1670 | "p3d = Plane3d (V3d (5.5, 6.6, 7.7), 8.8)\n" |
| 1671 | "i = 1\n" |
| 1672 | "from wrap import *\n" |
| 1673 | "w = wrap ('Plane3f')\n" |
| 1674 | "n = V3f (1.1, 2.2, 3.3).normalize()\n" |
| 1675 | "assert w.normal().equalWithAbsError (n, 1e-7)\n" |
| 1676 | "assert equal (w.distance(), 4.4, 1e-7)\n" |
| 1677 | "w = wrap ('Plane3d')\n" |
| 1678 | "n = V3d (1.1, 2.2, 3.3).normalize()\n" |
| 1679 | "assert w.normal().equalWithAbsError (n, 1e-7)\n" |
| 1680 | "assert equal (w.distance(), 4.4, 1e-7)\n"; |
| 1681 | |
| 1682 | handle<> ignored (PyRun_String (code.c_str(), Py_file_input, |
| 1683 | mainNamespace.ptr(), mainNamespace.ptr())); |
| 1684 | |
| 1685 | // |
| 1686 | |
| 1687 | extract <object> ep3f (mainNamespace["p3f"]); |
| 1688 | assert (ep3f.check()); |
| 1689 | |
| 1690 | PyObject *p3fObj = ep3f().ptr(); |
| 1691 | assert (p3fObj != 0); |
| 1692 | |
| 1693 | extract <object> ep3d (mainNamespace["p3d"]); |
| 1694 | assert (ep3d.check()); |
| 1695 | |
| 1696 | PyObject *p3dObj = ep3d().ptr(); |
| 1697 | assert (p3dObj != 0); |
| 1698 | |
| 1699 | extract <object> ei (mainNamespace["i"]); |
| 1700 | assert (ei.check()); |
| 1701 | |
| 1702 | PyObject *iObj = ei().ptr(); |
| 1703 | assert (iObj != 0); |
| 1704 | |
| 1705 | // |
| 1706 | |
| 1707 | std::cerr << "Testing Plane3f:\n"; |
| 1708 | |
| 1709 | IMATH_NAMESPACE::Plane3f p3fAsP3f; |
| 1710 | assert (PyImath::Plane3f::convert (p3fObj, &p3fAsP3f) == 1); |
| 1711 | IMATH_NAMESPACE::V3f p3fnf (1.1f, 2.2f, 3.3f); |
| 1712 | p3fnf.normalize(); |
| 1713 | assert (p3fAsP3f.normal.equalWithAbsError (p3fnf, 1e-6f)); |
| 1714 | assert (IMATH_NAMESPACE::equalWithAbsError (p3fAsP3f.distance, 4.4f, 1e-7f)); |
| 1715 | |
| 1716 | IMATH_NAMESPACE::Plane3f p3dAsP3f; |
nothing calls this directly
no test coverage detected