Skip to content

Commit

Permalink
Merge pull request #5 from ramcdona/CMake_Updates
Browse files Browse the repository at this point in the history
CMake updates
  • Loading branch information
dhaumont authored May 25, 2024
2 parents e9ce1b4 + 58ea561 commit 4d26d0f
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 36 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -111,13 +111,17 @@ 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)

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()


Expand Down
9 changes: 8 additions & 1 deletion demo/demo_debug_visualisation_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ along with Visilib. If not, see <http://www.gnu.org/licenses/>
#endif

#ifdef USE_GLUT
#include "GL/gl.h"
#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION \
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif
#endif
#include "demo_debug_visualisation_gl.h"
#include <iostream>
Expand Down
14 changes: 10 additions & 4 deletions demo/demo_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ along with Visilib. If not, see <http://www.gnu.org/licenses/>
#include <windows.h>
#endif
#ifdef USE_GLUT
#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION \
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>
#endif
#endif
#include <string>
#include <iostream>
#include <fstream>
#define _USE_MATH_DEFINES
#include <math.h>

#include "xmmintrin.h"
#include "pmmintrin.h"
// #include "xmmintrin.h"
// #include "pmmintrin.h"

#include "helper_triangle_mesh_container.h"
#include "silhouette_container_embree.h"
Expand All @@ -59,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
Expand Down
27 changes: 19 additions & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,30 @@

set(KIT visilibTest)

create_test_sourcelist(Tests ${KIT}CxxTests.cpp
src/test_math.cpp
)
# ${KIT}CxxTests.cpp

include_directories( ../visilib/ )
set(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 ()
2 changes: 1 addition & 1 deletion visilib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion visilib/math_arithmetic.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace visilib
}

/** @brief Compute the axis aligned bounding box of a set of points.*/
static void getMinMax(const std::vector<MathVector3_<S>>& aPoints, MathVector3_<S>& aMin, MathVector3_<S>& aMax);
static void getMinMax(const std::vector<MathVector3_<S> >& aPoints, MathVector3_<S>& aMin, MathVector3_<S>& aMax);

/** @brief Compute the axis aligned bounding box of a set of points.*/
static void getMinMax(const S* aPoints, size_t pointCount, MathVector3_<S>& aMin, MathVector3_<S>& aMax);
Expand Down
18 changes: 9 additions & 9 deletions visilib/math_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ namespace visilib
bool static isEdgeInsidePolytope(const MathVector3d& a, const MathVector3d& b, PluckerPolytope<P>* aPolytope, const MathVector3d& approximateNormal, PluckerPolyhedron<P>* polyhedron, S tolerance);

template<class S>
static bool isBoxInsideConvexHull(const MathVector3_<S>& AABBMin, const MathVector3_<S>& AABBMax, const std::vector<MathPlane3_<S>>& convexHullPlanes);
static bool isBoxInsideConvexHull(const MathVector3_<S>& AABBMin, const MathVector3_<S>& AABBMax, const std::vector<MathPlane3_<S> >& convexHullPlanes);
};

inline bool MathGeometry::isPointInsidePolygon(const GeometryConvexPolygon& aPolygon, const MathVector3d& aPoint, double tolerance)
Expand Down Expand Up @@ -351,26 +351,26 @@ namespace visilib
}

template<>
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker6<float>, float>(const MathPlucker6<float> & v1, const MathPlucker6<float> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker6<float>> & result, float tolerance)
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker6<float>, float>(const MathPlucker6<float> & v1, const MathPlucker6<float> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker6<float> > & result, float tolerance)
{
return findPluckerEdgeWithQuadricIntersection<MathPlucker6<float>, float>(v1, v2, p1, p2, result, true, tolerance);
}

template<>
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker6<double>, double>(const MathPlucker6<double> & v1, const MathPlucker6<double> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker6<double>> & result, double tolerance)
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker6<double>, double>(const MathPlucker6<double> & v1, const MathPlucker6<double> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker6<double> > & result, double tolerance)
{
return findPluckerEdgeWithQuadricIntersection<MathPlucker6<double>, double>(v1, v2, p1, p2, result, true, tolerance);
}

template<>
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker2<double>, double>(const MathPlucker2<double> & v1, const MathPlucker2<double> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker2<double>> & result, double tolerance)
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker2<double>, double>(const MathPlucker2<double> & v1, const MathPlucker2<double> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker2<double> > & result, double tolerance)
{
return findPluckerEdgeWithQuadricIntersection<MathPlucker2<double>, double>(v1, v2, p1, p2, result, true, tolerance);
}

#ifdef EXACT_ARITHMETIC
template<>
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker6<exact>, exact>(const MathPlucker6<exact> & v1, const MathPlucker6<exact> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker6<exact>> & result, exact tolerance)
inline bool MathGeometry::findPluckerEdgeWithQuadricIntersection<MathPlucker6<exact>, exact>(const MathPlucker6<exact> & v1, const MathPlucker6<exact> & v2, GeometryPositionType p1, GeometryPositionType p2, std::vector<MathPlucker6<exact> > & result, exact tolerance)
{
return findPluckerEdgeWithQuadricIntersection<MathPlucker6<exact>, exact>(v1, v2, p1, p2, result, false, tolerance);
}
Expand Down Expand Up @@ -764,9 +764,9 @@ namespace visilib
template<class S>
inline bool MathGeometry::hitsTriangle(const GeometryRay & ray, const MathVector3_<S> & v0, const MathVector3_<S> & v1, const MathVector3_<S> & v2)
{
MathVector3_<S> A = v0 - convert<MathVector3_<S>>(ray.getStart());
MathVector3_<S> B = v1 - convert<MathVector3_<S>>(ray.getStart());
MathVector3_<S> C = v2 - convert<MathVector3_<S>>(ray.getStart());
MathVector3_<S> A = v0 - convert<MathVector3_<S> >(ray.getStart());
MathVector3_<S> B = v1 - convert<MathVector3_<S> >(ray.getStart());
MathVector3_<S> C = v2 - convert<MathVector3_<S> >(ray.getStart());

S Sx; S Sy; S Sz;
int kx; int ky; int kz;
Expand Down Expand Up @@ -1007,7 +1007,7 @@ namespace visilib
}

template<class S>
inline bool isBoxInsideConvexHull(const MathVector3_<S>& AABBMin, const MathVector3_<S>& AABBMax, const std::vector<MathPlane3_<S>>& convexHullPlanes)
inline bool isBoxInsideConvexHull(const MathVector3_<S>& AABBMin, const MathVector3_<S>& AABBMax, const std::vector<MathPlane3_<S> >& convexHullPlanes)
{
for (const auto& plane: convexHullPlanes)
{
Expand Down
4 changes: 2 additions & 2 deletions visilib/math_plucker_6.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_<S> myBegin = convert<MathVector3_<S>>(aBegin);
MathVector3_<S> myEnd = convert<MathVector3_<S>>(anEnd);
MathVector3_<S> myBegin = convert<MathVector3_<S> >(aBegin);
MathVector3_<S> myEnd = convert<MathVector3_<S> >(anEnd);

mDirection = myEnd - myBegin;
mLocation = MathVector3_<S>::cross(myBegin, myEnd);
Expand Down
2 changes: 1 addition & 1 deletion visilib/plucker_polyhedron.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace visilib
std::vector<P> mLines; /** < @brief The list of Plucker points (Plucker vertices and hyperplanes). */
std::vector<GeometryPositionType> mQuadricRelativePositions; /** < @brief The relative position of the Plucker point relative to the Plucker quadric*/
std::vector<bool> mNormalizations; /** < @brief The normalization status of each Plucker point*/
std::vector<std::vector<size_t>> mFacetsDescription; /** < @brief The facet description (list of all the hyperplanes intersecting at that point) of each Plucker point mLines*/
std::vector<std::vector<size_t> > mFacetsDescription; /** < @brief The facet description (list of all the hyperplanes intersecting at that point) of each Plucker point mLines*/
};

template<class P>
Expand Down
12 changes: 6 additions & 6 deletions visilib/plucker_polytope.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace visilib
@return: a set containing all the edges <i,j> joining the vertices i and j with an intersection with the Plucker Quadric
*/

const std::set<std::pair<size_t, size_t>>& getEdgesIntersectingQuadric()
const std::set<std::pair<size_t, size_t> >& getEdgesIntersectingQuadric()
{
return mEdgesIntersectingQuadric;
}
Expand Down Expand Up @@ -143,7 +143,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<std::pair<MathVector3d, MathVector3d>>& aStabbingLines, const MathPlane3d& aPlane1, const MathPlane3d& aPlane2);
void getExtremalStabbingLinesBackTo3D(std::vector<std::pair<MathVector3d, MathVector3d> >& aStabbingLines, const MathPlane3d& aPlane1, const MathPlane3d& aPlane2);


/** @brief Add an extremal stabbing line to the polytope.
Expand Down Expand Up @@ -193,13 +193,13 @@ namespace visilib

private:

std::set<std::pair<size_t, size_t>> mEdges; /** < @brief The edges of the polytope, each edge is defined by the indices of the two vertices supporting it*/
std::set<std::pair<size_t, size_t>> mEdgesProcessed;
std::set<std::pair<size_t, size_t> > mEdges; /** < @brief The edges of the polytope, each edge is defined by the indices of the two vertices supporting it*/
std::set<std::pair<size_t, size_t> > mEdgesProcessed;
std::vector<P> mExtremalStabbingLines; /** < @brief The ESL of the polytope, at the intersection of an edge and the Plucker Quadric*/
std::set<std::pair<size_t, size_t>> mEdgesIntersectingQuadric; /** < @brief The edges containing an intersection with the Plucker Quadric.*/
std::set<std::pair<size_t, size_t> > mEdgesIntersectingQuadric; /** < @brief The edges containing an intersection with the Plucker Quadric.*/
std::unordered_set<Silhouette*> mSilhouettes; /** < @brief The set of silhouettes associated to the polytope*/
std::unordered_set<size_t> mVertices; /** < @brief The indices of the vertices of the polytope*/
std::vector<std::vector<size_t>> mExtremalStabbingLinesFacets;
std::vector<std::vector<size_t> > mExtremalStabbingLinesFacets;
double mRadius;
P mRepresentativeLine;
};
Expand Down
2 changes: 2 additions & 0 deletions visilib/visibility_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace visilib
{
}

virtual ~VisibilitySolver() = default;

virtual VisibilityResult resolve() = 0;

void attachVisualisationDebugger(HelperVisualDebugger* aDebugger) { mDebugger = aDebugger; }
Expand Down

0 comments on commit 4d26d0f

Please sign in to comment.