From 6a90e59223a7abea17fbc9a28df84dae898f8381 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:14:57 -0800 Subject: [PATCH 01/11] Bump required CMake version to somewhat recent version. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7019f16..6073bbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ # top-level CMakeLists.txt # !! To be run from 'cmakeout' subdirectory !! -cmake_minimum_required (VERSION 2.4.0 FATAL_ERROR) +cmake_minimum_required (VERSION 3.1 FATAL_ERROR) set( VISILIB_LIB_NAME "visilib" ) set( VISILIB_DEMO_NAME "visilibDemo" ) From 8e59074249be6d18aced367f21d0d0d33487e432 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:17:26 -0800 Subject: [PATCH 02/11] Fix GLUT library variable in CMake find_package(GLUT) now sets GLUT_LIBRARIES instead of GLUT_LIBRARY --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6073bbc..cc7f8c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ if (GLUT_FOUND) include_directories(${GLUT_INCLUDE_DIRS}) link_directories(${GLUT_LIBRARY_DIRS}) add_definitions(${GLUT_DEFINITIONS}) - set (LIBS ${GLUT_LIBRARY}) + set (LIBS ${GLUT_LIBRARIES}) else() message(ERROR " GLUT not found!") endif() From 61ba06d0b986bd15aaf8c1b18ca5df73169adafc Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:18:08 -0800 Subject: [PATCH 03/11] Don't force linking with math and std++ libraries. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc7f8c3..91c805b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,7 +111,7 @@ if(NOT WIN32) add_definitions(${OpenGL_DEFINITIONS}) - set(LIBS ${LIBS} ${OPENGL_LIBRARIES} m stdc++) + set(LIBS ${LIBS} ${OPENGL_LIBRARIES}) if(NOT OPENGL_FOUND) message(ERROR " OPENGL not found!") endif(NOT OPENGL_FOUND) From dc70fc1699d62d316f1b5353c85c605667a6b644 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:18:21 -0800 Subject: [PATCH 04/11] Require C++11 in CMake --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 91c805b..faeeca6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,10 @@ if(NOT WIN32) endif(NOT WIN32) +set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use") +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + ENABLE_TESTING() From 773acced96488d98b378f244167e81360ca0c565 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:19:21 -0800 Subject: [PATCH 05/11] Make #include of OpenGL headers work on Apple too. --- demo/demo_debug_visualisation_gl.cpp | 9 ++++++++- demo/demo_main.cpp | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/demo/demo_debug_visualisation_gl.cpp b/demo/demo_debug_visualisation_gl.cpp index 8fa33a2..84dc8e5 100644 --- a/demo/demo_debug_visualisation_gl.cpp +++ b/demo/demo_debug_visualisation_gl.cpp @@ -23,7 +23,14 @@ along with Visilib. If not, see #endif #ifdef USE_GLUT -#include "GL/gl.h" +#ifdef __APPLE__ +#define GL_SILENCE_DEPRECATION \ +#include +#include +#else +#include +#include +#endif #endif #include "demo_debug_visualisation_gl.h" #include diff --git a/demo/demo_main.cpp b/demo/demo_main.cpp index cd701c8..965124e 100644 --- a/demo/demo_main.cpp +++ b/demo/demo_main.cpp @@ -22,9 +22,15 @@ along with Visilib. If not, see #include #endif #ifdef USE_GLUT +#ifdef __APPLE__ +#define GL_SILENCE_DEPRECATION \ +#include +#include +#else #include #include #endif +#endif #include #include #include From 2b6f46f80b58a82f23f990e824cd3b549c424af0 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:20:43 -0800 Subject: [PATCH 06/11] Disable SSE intrinsics code This code at least needs to be conditional as it does not work on Apple silicon chips. Disabling these commands had no obvious adverse effect, so I'm not sure the SSE instructions are ever explicitly called. --- demo/demo_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/demo_main.cpp b/demo/demo_main.cpp index 965124e..916cbe0 100644 --- a/demo/demo_main.cpp +++ b/demo/demo_main.cpp @@ -37,8 +37,8 @@ along with Visilib. If not, see #define _USE_MATH_DEFINES #include -#include "xmmintrin.h" -#include "pmmintrin.h" +// #include "xmmintrin.h" +// #include "pmmintrin.h" #include "helper_triangle_mesh_container.h" #include "silhouette_container_embree.h" @@ -65,8 +65,8 @@ namespace visilibDemo bool init() { - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); +// _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); +// _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); readConfig("config.txt"); forceDisplay = true; #ifdef USE_GLUT From 0faa55ed77626b820820e6e994ddb4769313943e Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:21:11 -0800 Subject: [PATCH 07/11] The visilib library is header only, so mark it as INTERFACE instead of STATIC --- visilib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visilib/CMakeLists.txt b/visilib/CMakeLists.txt index ea64934..75454a8 100644 --- a/visilib/CMakeLists.txt +++ b/visilib/CMakeLists.txt @@ -90,7 +90,7 @@ source_group( external FILES ${ConvexHullSrc} ) source_group( include FILES ${Headers} ) source_group( src FILES ${Sources} ) -add_library( ${VISILIB_LIB_NAME} STATIC +add_library( ${VISILIB_LIB_NAME} INTERFACE ${GeometrySrc} ${GeometryHeader} ${HelperSrc} From 0496e320d4b0c774281daab23ed8a20be2a285f0 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:22:25 -0800 Subject: [PATCH 08/11] Add a space to template declarations to clarify >> vs. > > --- visilib/math_arithmetic.h | 2 +- visilib/math_geometry.h | 18 +++++++++--------- visilib/math_plucker_6.h | 4 ++-- visilib/plucker_polyhedron.h | 2 +- visilib/plucker_polytope.h | 12 ++++++------ 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/visilib/math_arithmetic.h b/visilib/math_arithmetic.h index 61fd165..0446ee8 100644 --- a/visilib/math_arithmetic.h +++ b/visilib/math_arithmetic.h @@ -45,7 +45,7 @@ namespace visilib } /** @brief Compute the axis aligned bounding box of a set of points.*/ - static void getMinMax(const std::vector>& aPoints, MathVector3_& aMin, MathVector3_& aMax); + static void getMinMax(const std::vector >& aPoints, MathVector3_& aMin, MathVector3_& aMax); /** @brief Compute the axis aligned bounding box of a set of points.*/ static void getMinMax(const S* aPoints, size_t pointCount, MathVector3_& aMin, MathVector3_& aMax); diff --git a/visilib/math_geometry.h b/visilib/math_geometry.h index fd87899..e41d4e6 100644 --- a/visilib/math_geometry.h +++ b/visilib/math_geometry.h @@ -162,7 +162,7 @@ namespace visilib bool static isEdgeInsidePolytope(const MathVector3d& a, const MathVector3d& b, PluckerPolytope

* aPolytope, const MathVector3d& approximateNormal, PluckerPolyhedron

* polyhedron, S tolerance); template - static bool isBoxInsideConvexHull(const MathVector3_& AABBMin, const MathVector3_& AABBMax, const std::vector>& convexHullPlanes); + static bool isBoxInsideConvexHull(const MathVector3_& AABBMin, const MathVector3_& AABBMax, const std::vector >& convexHullPlanes); }; inline bool MathGeometry::isPointInsidePolygon(const GeometryConvexPolygon& aPolygon, const MathVector3d& aPoint, double tolerance) @@ -350,26 +350,26 @@ namespace visilib } template<> - inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, float>(const MathPlucker6 & v1, const MathPlucker6 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector> & result, float tolerance) + inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, float>(const MathPlucker6 & v1, const MathPlucker6 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector > & result, float tolerance) { return findPluckerEdgeWithQuadricIntersection, float>(v1, v2, p1, p2, result, true, tolerance); } template<> - inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, double>(const MathPlucker6 & v1, const MathPlucker6 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector> & result, double tolerance) + inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, double>(const MathPlucker6 & v1, const MathPlucker6 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector > & result, double tolerance) { return findPluckerEdgeWithQuadricIntersection, double>(v1, v2, p1, p2, result, true, tolerance); } template<> - inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, double>(const MathPlucker2 & v1, const MathPlucker2 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector> & result, double tolerance) + inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, double>(const MathPlucker2 & v1, const MathPlucker2 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector > & result, double tolerance) { return findPluckerEdgeWithQuadricIntersection, double>(v1, v2, p1, p2, result, true, tolerance); } #ifdef EXACT_ARITHMETIC template<> - inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, exact>(const MathPlucker6 & v1, const MathPlucker6 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector> & result, exact tolerance) + inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection, exact>(const MathPlucker6 & v1, const MathPlucker6 & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector > & result, exact tolerance) { return findPluckerEdgeWithQuadricIntersection, exact>(v1, v2, p1, p2, result, false, tolerance); } @@ -762,9 +762,9 @@ namespace visilib template inline bool MathGeometry::hitsTriangle(const GeometryRay & ray, const MathVector3_ & v0, const MathVector3_ & v1, const MathVector3_ & v2) { - MathVector3_ A = v0 - convert>(ray.getStart()); - MathVector3_ B = v1 - convert>(ray.getStart()); - MathVector3_ C = v2 - convert>(ray.getStart()); + MathVector3_ A = v0 - convert >(ray.getStart()); + MathVector3_ B = v1 - convert >(ray.getStart()); + MathVector3_ C = v2 - convert >(ray.getStart()); S Sx; S Sy; S Sz; int kx; int ky; int kz; @@ -1005,7 +1005,7 @@ namespace visilib } template - inline bool isBoxInsideConvexHull(const MathVector3_& AABBMin, const MathVector3_& AABBMax, const std::vector>& convexHullPlanes) + inline bool isBoxInsideConvexHull(const MathVector3_& AABBMin, const MathVector3_& AABBMax, const std::vector >& convexHullPlanes) { for (const auto& plane: convexHullPlanes) { diff --git a/visilib/math_plucker_6.h b/visilib/math_plucker_6.h index f9ff8b5..594cd5b 100644 --- a/visilib/math_plucker_6.h +++ b/visilib/math_plucker_6.h @@ -64,8 +64,8 @@ namespace visilib /**@brief Construct a plucker point from a 3D line defined by two points*/ MathPlucker6(const MathVector3d& aBegin, const MathVector3d& anEnd) { - MathVector3_ myBegin = convert>(aBegin); - MathVector3_ myEnd = convert>(anEnd); + MathVector3_ myBegin = convert >(aBegin); + MathVector3_ myEnd = convert >(anEnd); mDirection = myEnd - myBegin; mLocation = MathVector3_::cross(myBegin, myEnd); diff --git a/visilib/plucker_polyhedron.h b/visilib/plucker_polyhedron.h index d6fc7bc..c6b5ad7 100644 --- a/visilib/plucker_polyhedron.h +++ b/visilib/plucker_polyhedron.h @@ -133,7 +133,7 @@ namespace visilib std::vector

mLines; /** < @brief The list of Plucker points (Plucker vertices and hyperplanes). */ std::vector mQuadricRelativePositions; /** < @brief The relative position of the Plucker point relative to the Plucker quadric*/ std::vector mNormalizations; /** < @brief The normalization status of each Plucker point*/ - std::vector> mFacetsDescription; /** < @brief The facet description (list of all the hyperplanes intersecting at that point) of each Plucker point mLines*/ + std::vector > mFacetsDescription; /** < @brief The facet description (list of all the hyperplanes intersecting at that point) of each Plucker point mLines*/ }; template diff --git a/visilib/plucker_polytope.h b/visilib/plucker_polytope.h index 9d912aa..2af85c3 100644 --- a/visilib/plucker_polytope.h +++ b/visilib/plucker_polytope.h @@ -92,7 +92,7 @@ namespace visilib @return: a set containing all the edges joining the vertices i and j with an intersection with the Plucker Quadric */ - const std::set>& getEdgesIntersectingQuadric() + const std::set >& getEdgesIntersectingQuadric() { return mEdgesIntersectingQuadric; } @@ -134,7 +134,7 @@ namespace visilib @param aPlane1: first plane that will be intersected by each stabbing lines to define the first point of the extremal line in 3D @param aPlane2: second plane that will be intersected by each stabbing lines to define the second point of the extremal line in 3D */ - void getExtremalStabbingLinesBackTo3D(std::vector>& aStabbingLines, const MathPlane3d& aPlane1, const MathPlane3d& aPlane2); + void getExtremalStabbingLinesBackTo3D(std::vector >& aStabbingLines, const MathPlane3d& aPlane1, const MathPlane3d& aPlane2); /** @brief Add an extremal stabbing line to the polytope. @@ -184,13 +184,13 @@ namespace visilib private: - std::set> mEdges; /** < @brief The edges of the polytope, each edge is defined by the indices of the two vertices supporting it*/ - std::set> mEdgesProcessed; + std::set > mEdges; /** < @brief The edges of the polytope, each edge is defined by the indices of the two vertices supporting it*/ + std::set > mEdgesProcessed; std::vector

mExtremalStabbingLines; /** < @brief The ESL of the polytope, at the intersection of an edge and the Plucker Quadric*/ - std::set> mEdgesIntersectingQuadric; /** < @brief The edges containing an intersection with the Plucker Quadric.*/ + std::set > mEdgesIntersectingQuadric; /** < @brief The edges containing an intersection with the Plucker Quadric.*/ std::unordered_set mSilhouettes; /** < @brief The set of silhouettes associated to the polytope*/ std::unordered_set mVertices; /** < @brief The indices of the vertices of the polytope*/ - std::vector> mExtremalStabbingLinesFacets; + std::vector > mExtremalStabbingLinesFacets; double mRadius; P mRepresentativeLine; }; From de3b077b8c35d4bd9d6480718e473f447585f1b7 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:23:18 -0800 Subject: [PATCH 09/11] Add missing default virtual destructor --- visilib/visibility_solver.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/visilib/visibility_solver.h b/visilib/visibility_solver.h index 8b2e964..c751b0d 100644 --- a/visilib/visibility_solver.h +++ b/visilib/visibility_solver.h @@ -41,6 +41,8 @@ namespace visilib { } + virtual ~VisibilitySolver() = default; + virtual VisibilityResult resolve() = 0; void attachVisualisationDebugger(HelperVisualDebugger* aDebugger) { mDebugger = aDebugger; } From 3bbf2dd1b4a598bda7b2271066b31b6f2030f1f9 Mon Sep 17 00:00:00 2001 From: Rob McDonald Date: Sat, 11 Nov 2023 17:25:02 -0800 Subject: [PATCH 10/11] Attempt to update adding tests to newer CMake. This still isn't working, it seems like create_test_sourcelist doesn't like to add tests in subdirectories. This may be why there were multiple calls to add_executable before. However, that does not work in new CMake. Perhaps there is another way to add additional files. --- test/CMakeLists.txt | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4177caf..3d55436 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,19 +18,30 @@ set(KIT visilibTest) -create_test_sourcelist(Tests ${KIT}CxxTests.cpp - src/test_math.cpp - ) +# ${KIT}CxxTests.cpp -include_directories( ../visilib/ ) +create_test_sourcelist(Tests + ./src/test_full.cpp + ./src/test_math.cpp + ./src/test_visibility.cpp + ../demo/demo_helper.cpp +) -add_executable(visilibTest src/test_math.cpp) -add_executable(visilibTest src/test_visibility.cpp) -add_executable(visilibTest src/test_full.cpp) +include_directories( ../visilib/ ) -add_executable(visilibTest ../demo/demo_helper.cpp) +add_executable(visilibTest ${Tests}) target_link_libraries(visilibTest ${LIBS}) #add_test(NAME stc_test_math COMMAND ${KIT}CxxTests stc_test_math}) add_test(NAME visilibTest COMMAND visilibTest) + +# remove the test driver source file +set (TestsToRun ${Tests}) +list ( REMOVE_ITEM TestsToRun src/test_full.cxx) + +# Add all the ADD_TEST for each test +foreach (test ${TestsToRun}) + get_filename_component (TName ${test} NAME_WE) + add_test (NAME ${TName} COMMAND test_full ${TName}) +endforeach () From 58ea561964a5cdc8f6a17aadbc8a08b8829ee044 Mon Sep 17 00:00:00 2001 From: Denis Haumont Date: Sat, 25 May 2024 12:40:16 +0200 Subject: [PATCH 11/11] Compilation fix --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d55436..bf75770 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -20,7 +20,7 @@ set(KIT visilibTest) # ${KIT}CxxTests.cpp -create_test_sourcelist(Tests +set(Tests ./src/test_full.cpp ./src/test_math.cpp ./src/test_visibility.cpp