Academia.eduAcademia.edu

Outline

CGAL Made More Accessible

2022, arXiv (Cornell University)

https://doi.org/10.48550/ARXIV.2202.13889

Abstract

We introduce Python bindings that enable the convenient, efficient, and reliable use of software modules of Cgal (The Computational Geometry Algorithms Library), which are written in C++, from within code written in Python. There are different tools that facilitate the creation of such bindings. We present a short study that compares three main tools, which leads to the tool of choice. The implementation of algorithms and data structures in computational geometry presents tremendous difficulties, such as obtaining robust software despite the use of (inexact) floating point arithmetic, found in standard hardware, and meticulous handling of all degenerate cases, which typically are in abundance. The code of Cgal extensively uses function and class templates in order to handle these difficulties, which implies that the programmer has to make many choices that are resolved during compile time (of the C++ modules). While bindings take effect at run time (of the Python code), the type of the C++ objects that are bound must be known when the bindings are generated, that is, when they are compiled. The types of the bound objects are instances (instantiated types) of C++ function and class templates. The number of object types that can potentially be bound, in implementation of generic computational-geometry algorithms, is enormous; thus, the generation of the bindings for all these types in advance is practically impossible. For example, the programmer needs to choose among a dozen types of curves (e.g., line segments, circular arcs, geodesic arcs on a sphere, or polycurves of any curve type) to yield a desired arrangement type; often there are several choices to make, resulting in a prohibitively large number of combinations. We present a system that rapidly generates bindings for desired object types according to user prescriptions, which enables the convenient use of any subset of bound object types concurrently. After many years, in which the usage of these packages was restricted to C++ experts, the introduction of the bindings made them easily accessible to newcomers and practitioners in non-computing fields, as we report in the paper. Additional information can be found at http://acg.cs.tau.ac.il/cgal-python-bindings. The bindings software can be found at https://bitbucket.org/taucgl/cgal-python-bindings.

References (36)

  1. D. Abrahams and R. W. Grosse-Kunstleve. Building hybrid systems with boost.python. C/C++ Users Journal, pages 31-39, 2003.
  2. M. H. Austern. Generic Programming and the Stl. Addison-Wesley, Boston, MA, USA, 1999.
  3. A. Baram, E. Fogel, D. Halperin, M. Hemmer, and S. Morr. Exact Minkowski sums of polygons with holes. Computational Geometry: Theory and Applications, 1:01-01, 2015.
  4. S. Behnel, R. Bradshaw, C. Citro, L. Dalcín, D. S. Seljebotn, and K. Smith. Cython: The best of both worlds. Computational Sciences Engineering, 13(2):31-39, 2011.
  5. E. Berberich, E. Fogel, D. Halperin, M. Kerber, and O. Setter. Arrangements on parametric surfaces II: Con- cretizations and applications. Mathematics in Computer Science, 4:67-91, 2010.
  6. E. Berberich, E. Fogel, D. Halperin, K. Mehlhorn, and R. Wein. Arrangements on parametric surfaces I: General framework and infrastructure. Mathematics in Computer Science, 4:45-66, 2010.
  7. J.-D. Boissonnat and M. Yvinec. Triangulations. In Algorithmic Geometry. Cambridge University Press, 1998. Translated by Hervé Brönnimann.
  8. H. Brönnimann, A. Fabri, G.-J. Giezeman, S. Hert, M. Hoffmann, L. Kettner, S. Pion, and S. Schirra. 2D and 3D linear geometry kernel. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  9. M. Caroli, A. Pellé, M. Rouxel-Labbé, and M. Teillaud. 3D periodic triangulations. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  10. M. Caroli and M. Teillaud. Computing 3d periodic triangulations. In Proceedings of the 17th Annual European Symposium on Algorithms (ESA), volume 5757 of LNCS, pages 37-48. Springer-Verlag, 2009.
  11. T. K. F. Da. 2D alpha shapes. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  12. T. K. F. Da, S. Loriot, and M. Yvinec. 3D alpha shapes. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  13. O. Devillers, L. Kettner, S. Pion, M. Seel, and M. Yvinec. Handles and circulators. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  14. E. Flato, D. Halperin, I. Hanniel, O. Nechushtan, and E. Ezra. The design and implementation of planar maps in CGAL. ACM J. Exp. Algorithmics, 5:13, 2000.
  15. E. Fogel, D. Halperin, and R. Wein. Cgal Arrangements and Their Applications, A Step by Step Guide. Springer- Verlag, Berlin Heidelberg, Germany, 2012.
  16. E. Fogel, O. Setter, R. Wein, G. Zucker, B. Zukerman, and D. Halperin. 2D regularized boolean set-operations. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  17. GEOS contributors. GEOS coordinate transformation software library. Open Source Geospatial Foundation, 2021.
  18. D. Halperin, J.-C. Latombe, and R. H. Wilson. A general framework for assembly planning: The motion space approach. Algorithmica, 26:577-601, 2000.
  19. D. Halperin and M. Sharir. Arrangements and their applications in robotics: Recent developments. In K. Gold- bergs, D. Halperin, J.-C. Latombe, and R. Wilson, editors, International Workshop on Algorithmic Foundations of Robotics, pages 495-511. A.K. Peters, Ltd., Boston, MA, 1995.
  20. D. Halperin and M. Sharir. Arrangements. In J. E. Goodman, J. O'Rourke, and C. Tóth, editors, Handbook of Computational Geometry, chapter 28. Chapman & Hall/CRC, 3rd edition, 2017.
  21. H. Har-Gil, Y. Jacobson, A. Prönneke, J. F. Staiger, O. Tomer, D. Halperin, and P. Blinder. Neural collision detection: an open source library to study the three-dimensional interactions of neurons and other tree-like structures. bioRxiv, 2021.
  22. W. Jakob. nanobind - seamless operability between c++17 and python, 2022. https://github.com/wjakob/nanobind.
  23. C. Jamin, S. Pion, and M. Teillaud. 3D triangulations. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  24. N. Kruithof. 2D periodic triangulations. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  25. W. Lavrijsen and A. Dutta. High-performance python-c++ bindings with pypy and cling. In Proceedings of the 6th Workshop on Python, pages 27-35. IEEE Computer Society Press, 2016.
  26. J. W. Martin, A. K. Yan, C. Bailey-Kellogg, P. Zhou, and B. R. Donald. A geometric arrangement algorithm for structure determination of symmetric protein homo-oligomers from noes and rdcs. Journal of Computational Biology, 18(11):1507-1523, 2011.
  27. K. Martin and B. Hoffman. Mastering CMake. Kitware, Inc, 4th edition, 2008.
  28. M. Meyerovitch. Robust, generic and efficient construction of envelopes of surfaces in three-dimensional space. In Proceedings of the 14th Annual European Symposium on Algorithms (ESA), volume 4168 of LNCS, pages 792-803. Springer-Verlag, 2006.
  29. M. Seel. dD geometry kernel. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  30. H. Tangelder and A. Fabri. dD spatial searching. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  31. The Cgal Project. Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  32. M. J. van Kreveld, É. Schramm, and A. Wolff. Algorithms for the placement of diagrams on maps. In Proceedings of the 12th ACM International Workshop Geographic Information Systems, pages 222-231, Washington, DC, USA, 2004. PUB-ACM.
  33. R. Wein, A. Baram, E. Flato, E. Fogel, M. Hemmer, and S. Morr. 2D minkowski sums. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  34. R. Wein, E. Berberich, E. Fogel, D. Halperin, M. Hemmer, O. Salzman, and B. Zukerman. 2D arrangements. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.
  35. R. Wein, E. Fogel, B. Zukerman, and D. Halperin. Advanced programming techniques applied to Cgal's arrange- ment package. Computational Geometry: Theory and Applications, 38(1-2):37-63, 2007.
  36. M. Yvinec. 2D triangulations. In Cgal User and Reference Manual. Cgal Editorial Board, 5.5 edition, 2022.