orient3D.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "orient3D.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::orient3D(
  13. const Scalar pa[3],
  14. const Scalar pb[3],
  15. const Scalar pc[3],
  16. const Scalar pd[3])
  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::orientation(
  23. typename Kernel::Point_3(pa[0], pa[1], pa[2]),
  24. typename Kernel::Point_3(pb[0], pb[1], pb[2]),
  25. typename Kernel::Point_3(pc[0], pc[1], pc[2]),
  26. typename Kernel::Point_3(pd[0], pd[1], pd[2]))) {
  27. case CGAL::POSITIVE:
  28. return 1;
  29. case CGAL::NEGATIVE:
  30. return -1;
  31. case CGAL::COPLANAR:
  32. return 0;
  33. default:
  34. throw "Invalid orientation";
  35. }
  36. }