Skip to content

Commit

Permalink
moved CGALS's rational interface outside of AFM's folder
Browse files Browse the repository at this point in the history
  • Loading branch information
mlivesu committed May 27, 2024
1 parent 70aa8ba commit ab742a4
Show file tree
Hide file tree
Showing 7 changed files with 3,414 additions and 31 deletions.
2 changes: 2 additions & 0 deletions cinolib-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ if(CINOLIB_USES_CGAL)
if(CGAL_FOUND)
target_link_libraries(cinolib INTERFACE CGAL::CGAL)
target_compile_definitions(cinolib INTERFACE CINOLIB_USES_CGAL)
# thin wrapper for MPFR (https://github.com/advanpix/mpreal)
target_include_directories(cinolib INTERFACE ${cinolib_DIR}/external/mpreal/)
else()
message("Could not find CGAL!")
set(CINOLIB_USES_CGAL OFF)
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(CINOLIB_USES_SHEWCHUK_PREDICATES ON )
set(CINOLIB_USES_INDIRECT_PREDICATES ON )
set(CINOLIB_USES_GRAPH_CUT OFF)
set(CINOLIB_USES_BOOST OFF)
set(CINOLIB_USES_VTK ON ) # optional, if added VTK formats will be supported everywhere
set(CINOLIB_USES_VTK OFF) # optional, if added VTK formats will be supported everywhere
set(CINOLIB_USES_SPECTRA ON )
set(CINOLIB_USES_CGAL ON )

Expand Down
3,377 changes: 3,377 additions & 0 deletions external/mpreal/mpreal.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/cinolib/AFM/AFM.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#ifdef CINOLIB_USES_CGAL

#include <cinolib/meshes/drawable_trimesh.h>
#include <cinolib/AFM/rationals.h>
#include <cinolib/rationals.h>
#include <cinolib/profiler.h>

namespace cinolib
Expand Down
2 changes: 1 addition & 1 deletion include/cinolib/AFM/flip_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Italy *
*********************************************************************************/
#include <cinolib/AFM/flip_checks.h>
#include <cinolib/AFM/rationals.h>
#include <cinolib/rationals.h>
#include <cinolib/predicates.h>

namespace cinolib
Expand Down
44 changes: 23 additions & 21 deletions include/cinolib/AFM/rationals.cpp → include/cinolib/rationals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* 16149 Genoa, *
* Italy *
*********************************************************************************/
#include <cinolib/AFM/rationals.h>
#include <cinolib/rationals.h>
#include <cinolib/predicates.h>

namespace cinolib
Expand Down Expand Up @@ -65,21 +65,22 @@ bool rationals_are_working()

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template <class T>
CINO_INLINE
CGAL_Q orient3d(const CGAL_Q * pa,
const CGAL_Q * pb,
const CGAL_Q * pc,
const CGAL_Q * pd)
T orient3d(const T * pa,
const T * pb,
const T * pc,
const T * pd)
{
CGAL_Q adx = pa[0] - pd[0];
CGAL_Q bdx = pb[0] - pd[0];
CGAL_Q cdx = pc[0] - pd[0];
CGAL_Q ady = pa[1] - pd[1];
CGAL_Q bdy = pb[1] - pd[1];
CGAL_Q cdy = pc[1] - pd[1];
CGAL_Q adz = pa[2] - pd[2];
CGAL_Q bdz = pb[2] - pd[2];
CGAL_Q cdz = pc[2] - pd[2];
T adx = pa[0] - pd[0];
T bdx = pb[0] - pd[0];
T cdx = pc[0] - pd[0];
T ady = pa[1] - pd[1];
T bdy = pb[1] - pd[1];
T cdy = pc[1] - pd[1];
T adz = pa[2] - pd[2];
T bdz = pb[2] - pd[2];
T cdz = pc[2] - pd[2];

return adx * (bdy * cdz - bdz * cdy)
+ bdx * (cdy * adz - cdz * ady)
Expand All @@ -88,15 +89,16 @@ CGAL_Q orient3d(const CGAL_Q * pa,

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template <class T>
CINO_INLINE
CGAL_Q orient2d(const CGAL_Q * pa,
const CGAL_Q * pb,
const CGAL_Q * pc)
T orient2d(const T * pa,
const T * pb,
const T * pc)
{
CGAL_Q acx = pa[0] - pc[0];
CGAL_Q bcx = pb[0] - pc[0];
CGAL_Q acy = pa[1] - pc[1];
CGAL_Q bcy = pb[1] - pc[1];
T acx = pa[0] - pc[0];
T bcx = pb[0] - pc[0];
T acy = pa[1] - pc[1];
T bcy = pb[1] - pc[1];

return acx * bcy - acy * bcx;
}
Expand Down
16 changes: 9 additions & 7 deletions include/cinolib/AFM/rationals.h → include/cinolib/rationals.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ typedef CGAL::Lazy_exact_nt<CGAL::Gmpq> CGAL_Q;

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template <class T>
CINO_INLINE
CGAL_Q orient3d(const CGAL_Q * pa,
const CGAL_Q * pb,
const CGAL_Q * pc,
const CGAL_Q * pd);
T orient3d(const T * pa,
const T * pb,
const T * pc,
const T * pd);

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

template <class T>
CINO_INLINE
CGAL_Q orient2d(const CGAL_Q * pa,
const CGAL_Q * pb,
const CGAL_Q * pc);
T orient2d(const T * pa,
const T * pb,
const T * pc);

//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Expand Down

0 comments on commit ab742a4

Please sign in to comment.