incircle.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "incircle.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::incircle(
  13. const Scalar *pa,
  14. const Scalar *pb,
  15. const Scalar *pc,
  16. const Scalar *pd)
  17. {
  18. typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck;
  19. typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick;
  20. typedef typename std::conditional<std::is_same<Scalar, Epeck::FT>::value,
  21. Epeck, Epick>::type Kernel;
  22. switch(CGAL::side_of_oriented_circle(
  23. typename Kernel::Point_2(pa[0], pa[1]),
  24. typename Kernel::Point_2(pb[0], pb[1]),
  25. typename Kernel::Point_2(pc[0], pc[1]),
  26. typename Kernel::Point_2(pd[0], pd[1]))) {
  27. case CGAL::ON_POSITIVE_SIDE:
  28. return 1;
  29. case CGAL::ON_NEGATIVE_SIDE:
  30. return -1;
  31. case CGAL::ON_ORIENTED_BOUNDARY:
  32. return 0;
  33. default:
  34. throw "Invalid incircle result";
  35. }
  36. }
  37. #ifdef IGL_STATIC_LIBRARY
  38. // Explicit template instantiation
  39. // generated by autoexplicit.sh
  40. template short igl::copyleft::cgal::incircle<double>(double const*, double const*, double const*, double const*);
  41. #ifdef WIN32
  42. template short igl::copyleft::cgal::incircle<double>(double const * const,double const * const,double const * const,double const * const);
  43. #endif
  44. #endif