orient2D.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Qingan Zhou <qnzhou@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "orient2D.h"
  9. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  10. #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
  11. template<typename Scalar>
  12. IGL_INLINE short igl::copyleft::cgal::orient2D(
  13. const Scalar *pa,
  14. const Scalar *pb,
  15. const Scalar *pc)
  16. {
  17. typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck;
  18. typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick;
  19. typedef typename std::conditional<std::is_same<Scalar, Epeck::FT>::value,
  20. Epeck, Epick>::type Kernel;
  21. switch(CGAL::orientation(
  22. typename Kernel::Point_2(pa[0], pa[1]),
  23. typename Kernel::Point_2(pb[0], pb[1]),
  24. typename Kernel::Point_2(pc[0], pc[1])))
  25. {
  26. case CGAL::LEFT_TURN:
  27. return 1;
  28. case CGAL::RIGHT_TURN:
  29. return -1;
  30. case CGAL::COLLINEAR:
  31. return 0;
  32. default:
  33. throw "Invalid orientation";
  34. }
  35. }
  36. #ifdef IGL_STATIC_LIBRARY
  37. // Explicit template instantiation
  38. // generated by autoexplicit.sh
  39. template short igl::copyleft::cgal::orient2D<double>(double const*, double const*, double const*);
  40. #ifdef WIN32
  41. template short igl::copyleft::cgal::orient2D<double>(double const * const, double const * const, double const * const);
  42. #endif
  43. #endif