* Add draw examples in the 5 concerned packages (Polyhedron, Surface_mesh, T2, T3, LCC)

* Update FindQGLViewel to add a target.
This commit is contained in:
Guillaume Damiand 2018-02-13 11:31:21 +01:00 committed by Maxime Gimeno
parent 202781aa93
commit 53769e98a7
19 changed files with 144 additions and 182 deletions

View File

@ -329,7 +329,7 @@ struct Correct_invalid_attributes_functor
unsigned int nb=0;
bool found_dart = false;
for ( CGAL::CMap_dart_iterator_basic_of_cell<CMap,i>
for ( typename CMap::template Dart_of_cell_basic_range<i>::iterator
it(amap, adart, amark); it.cont(); ++it, ++nb )
{
if ( a!=amap.template attribute<i>(it) )

View File

@ -1,81 +0,0 @@
# - Try to find QGLViewer
# Once done this will define
#
# QGLVIEWER_FOUND - system has QGLViewer
# QGLVIEWER_INCLUDE_DIR - the QGLViewer include directory
# QGLVIEWER_LIBRARIES - Link these to use QGLViewer
# QGLVIEWER_DEFINITIONS - Compiler switches required for using QGLViewer
#
if(POLICY CMP0072)
# About the use of OpenGL
cmake_policy(SET CMP0072 NEW)
endif()
find_package(OpenGL QUIET)
find_package(Qt5 QUIET COMPONENTS OpenGL Xml)
# first look in user defined locations
find_path(QGLVIEWER_INCLUDE_DIR
NAMES QGLViewer/qglviewer.h
NO_DEFAULT_PATH
PATHS ENV QGLVIEWERROOT
/usr/local/include
)
find_library(QGLVIEWER_LIBRARY_RELEASE
NAMES qglviewer-qt5 qglviewer QGLViewer-qt5 QGLViewer QGLViewer2-qt5 QGLViewer2
NO_DEFAULT_PATH
PATHS ENV QGLVIEWERROOT
ENV LD_LIBRARY_PATH
ENV LIBRARY_PATH
/usr/local/lib
PATH_SUFFIXES QGLViewer QGLViewer/release
)
find_library(QGLVIEWER_LIBRARY_DEBUG
NAMES dqglviewer dQGLViewer-qt5 dQGLViewer dQGLViewer2-qt5 dQGLViewer2 QGLViewerd2-qt5 QGLViewerd2
NO_DEFAULT_PATH
PATHS /usr/local/lib
ENV QGLVIEWERROOT
ENV LD_LIBRARY_PATH
ENV LIBRARY_PATH
PATH_SUFFIXES QGLViewer QGLViewer/debug
)
#now try the standard paths
if (NOT QGLVIEWER_INCLUDE_DIR OR NOT QGLVIEWER_LIBRARY_RELEASE OR NOT QGLVIEWER_LIBRARY_DEBUG)
find_path(QGLVIEWER_INCLUDE_DIR
NAMES QGLViewer/qglviewer.h)
find_library(QGLVIEWER_LIBRARY_RELEASE
NAMES qglviewer-qt5 qglviewer QGLViewer-qt5 QGLViewer QGLViewer2-qt5 QGLViewer2)
find_library(QGLVIEWER_LIBRARY_DEBUG
NAMES dqglviewer dQGLViewer-qt5 dQGLViewer dQGLViewer2-qt5 dQGLViewer2 QGLViewerd2-qt5 QGLViewerd2)
endif()
if(QGLVIEWER_LIBRARY_RELEASE)
if(QGLVIEWER_LIBRARY_DEBUG)
set(QGLVIEWER_LIBRARIES_ Qt5::Xml Qt5::OpenGL ${OPENGL_LIBRARIES} optimized ${QGLVIEWER_LIBRARY_RELEASE} debug ${QGLVIEWER_LIBRARY_DEBUG})
else()
set(QGLVIEWER_LIBRARIES_ Qt5::Xml Qt5::OpenGL ${OPENGL_LIBRARIES} ${QGLVIEWER_LIBRARY_RELEASE})
endif()
set(QGLVIEWER_LIBRARIES ${QGLVIEWER_LIBRARIES_} CACHE FILEPATH "The QGLViewer library")
endif()
IF(QGLVIEWER_INCLUDE_DIR AND QGLVIEWER_LIBRARIES)
SET(QGLVIEWER_FOUND TRUE)
ENDIF(QGLVIEWER_INCLUDE_DIR AND QGLVIEWER_LIBRARIES)
IF(QGLVIEWER_FOUND)
IF(NOT QGLViewer_FIND_QUIETLY)
MESSAGE(STATUS "Found QGLViewer: ${QGLVIEWER_LIBRARIES}")
ENDIF(NOT QGLViewer_FIND_QUIETLY)
ELSE(QGLVIEWER_FOUND)
IF(QGLViewer_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find QGLViewer")
ENDIF(QGLViewer_FIND_REQUIRED)
ENDIF(QGLVIEWER_FOUND)

View File

@ -58,7 +58,6 @@ qt5_wrap_ui(uis MainWindow.ui CreateMesh.ui CreateMenger.ui
# qrc files (resources files, that contain icons, at least)
qt5_add_resources (CGAL_Qt5_RESOURCE_FILES ./Linear_cell_complex_3.qrc)
add_executable(Linear_cell_complex_3_demo
Linear_cell_complex_3_demo.cpp MainWindow.cpp
Viewer.cpp Linear_cell_complex_3_subdivision.cpp

View File

@ -11,6 +11,13 @@ endif()
find_package(CGAL COMPONENTS Qt5)
if(CGAL_Qt5_FOUND)
find_package(QGLViewer)
if (TARGET QGLViewer::QGLViewer)
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()
endif()
# For Gprof.
# ADD_DEFINITIONS("-pg")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
@ -18,44 +25,31 @@ find_package(CGAL COMPONENTS Qt5)
# To use valgrind, we must disable rounding math ckeck.
# add_definition(-DCGAL_DISABLE_ROUNDING_MATH_CHECK)
if ( CGAL_FOUND )
include(${CGAL_USE_FILE})
if (CGAL_FOUND)
include( ${CGAL_USE_FILE} )
include( CGAL_CreateSingleSourceCGALProgram )
include(CGAL_CreateSingleSourceCGALProgram)
include_directories(BEFORE ../../include)
create_single_source_cgal_program("gmap_linear_cell_complex_3.cpp")
create_single_source_cgal_program("linear_cell_complex_3.cpp")
create_single_source_cgal_program("linear_cell_complex_4.cpp")
create_single_source_cgal_program("linear_cell_complex_3_attributes_management.cpp")
create_single_source_cgal_program("linear_cell_complex_3_operations.cpp")
create_single_source_cgal_program("linear_cell_complex_3_with_colored_vertices.cpp")
create_single_source_cgal_program("linear_cell_complex_3_with_mypoint.cpp")
create_single_source_cgal_program("linear_cell_complex_4.cpp")
create_single_source_cgal_program("plane_graph_to_lcc_2.cpp")
create_single_source_cgal_program("linear_cell_complex_3_attributes_management.cpp")
create_single_source_cgal_program("voronoi_2.cpp")
create_single_source_cgal_program("voronoi_3.cpp")
create_single_source_cgal_program("gmap_linear_cell_complex_3.cpp")
create_single_source_cgal_program("linear_cell_complex_3_operations.cpp")
create_single_source_cgal_program("draw_linear_cell_complex.cpp")
if(TARGET CGAL::CGAL_Qt5)
find_package(Qt5 REQUIRED COMPONENTS OpenGL Xml)
find_package(QGLViewer REQUIRED)
find_package(OpenGL REQUIRED)
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_NO_KEYWORDS)
include_directories( ${QGLVIEWER_INCLUDE_DIR} )
add_definitions(${QGLVIEWER_DEFINITIONS})
target_link_libraries(draw_linear_cell_complex CGAL::CGAL_Qt5 Qt5::Xml
${QT_LIBRARIES}
${QGLVIEWER_LIBRARIES}
${OPENGL_gl_LIBRARY})
target_compile_definitions(draw_linear_cell_complex PRIVATE CGAL_USE_BASIC_VIEWER)
create_single_source_cgal_program("draw_linear_cell_complex.cpp")
if(CGAL_Qt5_FOUND AND TARGET QGLViewer::QGLViewer)
target_link_libraries(draw_linear_cell_complex CGAL::CGAL_Qt5 QGLViewer::QGLViewer)
endif()
else()
message(STATUS "This program requires the CGAL library, "
"and will not be compiled.")
message(STATUS "This program requires the CGAL library, and will not be compiled.")
endif()

View File

@ -6,17 +6,18 @@ project( Polyhedron_Examples )
cmake_minimum_required(VERSION 2.8.10)
# If you want to visualize a polyhedron, you can use the following viewer
# based on qt. Just uncomment the following line, plus the line find_package(CGALBasicViewer) below
# find_package(CGAL COMPONENTS Qt5)
find_package(CGAL COMPONENTS Qt5)
# If you don't want to visualize, use the following line (otherwise comment it)
find_package(CGAL QUIET)
if(CGAL_Qt5_FOUND)
find_package(QGLViewer)
if (TARGET QGLViewer::QGLViewer)
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()
endif()
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
# find_package(CGALBasicViewer)
include( CGAL_CreateSingleSourceCGALProgram )
@ -27,15 +28,12 @@ if ( CGAL_FOUND )
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
create_single_source_cgal_program( "${cppfile}" )
if (USE_BASIC_VIEWER)
get_filename_component(exe_name "${cppfile}" NAME_WE)
target_link_libraries("${exe_name}" ${BASIC_VIEWER_LIBRARIES})
qt5_use_modules("${exe_name}" ${BASIC_VIEWER_MODULES})
endif(USE_BASIC_VIEWER)
endforeach()
if(CGAL_Qt5_FOUND AND TARGET QGLViewer::QGLViewer)
target_link_libraries(draw_polyhedron CGAL::CGAL_Qt5 QGLViewer::QGLViewer)
endif()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")

View File

@ -0,0 +1,18 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/draw_polyhedron.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
int main()
{
std::cerr<<"Loading OFF file ... "<<std::endl;
Polyhedron P;
std::cin>>P;
CGAL::draw(P);
return EXIT_SUCCESS;
}

View File

@ -8,10 +8,6 @@
#include <algorithm>
#include <vector>
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Polyhedron_viewer_qt.h>
#endif
using std::cerr;
using std::endl;
using std::cout;
@ -160,9 +156,5 @@ int main() {
cerr << "Intersection : " << user_time.time() << " seconds." << endl;
write_off();
#ifdef CGAL_USE_BASIC_VIEWER
display(P);
#endif // CGAL_USE_BASIC_VIEWER
return 0;
}

View File

@ -213,7 +213,7 @@ void draw(const Polyhedron& apoly,
const char* title="Polyhedron Viewer",
bool nofill=false)
{
return display<Polyhedron, DefaultColorFunctorPolyhedron>
return draw<Polyhedron, DefaultColorFunctorPolyhedron>
(apoly, title, nofill);
}

View File

@ -6,17 +6,18 @@ project( Surface_mesh_Examples )
cmake_minimum_required(VERSION 2.8.11)
# If you want to visualize a surface mesh, you can use the following viewer
# based on qt. Just uncomment the following line, plus the line find_package(CGALBasicViewer) below
# find_package(CGAL COMPONENTS Qt5)
find_package(CGAL COMPONENTS Qt5)
# If you don't want to visualize, use the following line (otherwise comment it)
find_package(CGAL QUIET)
if(CGAL_Qt5_FOUND)
find_package(QGLViewer)
if (TARGET QGLViewer::QGLViewer)
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()
endif()
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
# find_package(CGALBasicViewer)
include( CGAL_CreateSingleSourceCGALProgram )
@ -24,11 +25,6 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "sm_derivation.cpp" )
create_single_source_cgal_program( "sm_join.cpp" )
if (USE_BASIC_VIEWER)
target_link_libraries("sm_join" ${BASIC_VIEWER_LIBRARIES})
qt5_use_modules("sm_join" ${BASIC_VIEWER_MODULES})
endif(USE_BASIC_VIEWER)
create_single_source_cgal_program( "sm_aabbtree.cpp" )
create_single_source_cgal_program( "sm_bgl.cpp" )
create_single_source_cgal_program( "sm_circulators.cpp" )
@ -38,6 +34,11 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "sm_memory.cpp" )
create_single_source_cgal_program( "sm_properties.cpp" )
create_single_source_cgal_program("draw_surface_mesh.cpp")
if(CGAL_Qt5_FOUND AND TARGET QGLViewer::QGLViewer)
target_link_libraries(draw_surface_mesh CGAL::CGAL_Qt5 QGLViewer::QGLViewer)
endif()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")

View File

@ -0,0 +1,19 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/draw_surface_mesh.h>
#include <fstream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
int main(int argc, char* argv[])
{
Mesh sm1;
std::ifstream in1((argc>1)?argv[1]:"data/triangle.off");
in1 >> sm1;
CGAL::draw(sm1);
return EXIT_SUCCESS;
}

View File

@ -5,10 +5,6 @@
#include <boost/foreach.hpp>
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Surface_mesh_viewer_qt.h>
#endif
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
@ -40,9 +36,4 @@ int main(int argc, char* argv[])
std::cout << sm1 << std::endl;
#ifdef CGAL_USE_BASIC_VIEWER
display(sm1);
#endif // CGAL_USE_BASIC_VIEWER
}

View File

@ -6,7 +6,14 @@ project( Triangulation_2_Examples )
cmake_minimum_required(VERSION 2.8.10)
find_package(CGAL QUIET)
find_package(CGAL COMPONENTS Qt5)
if(CGAL_Qt5_FOUND)
find_package(QGLViewer)
if (TARGET QGLViewer::QGLViewer)
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()
endif()
if ( CGAL_FOUND )
@ -22,6 +29,10 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "${cppfile}" )
endforeach()
if(CGAL_Qt5_FOUND AND TARGET QGLViewer::QGLViewer)
target_link_libraries(draw_triangulation_2 CGAL::CGAL_Qt5 QGLViewer::QGLViewer)
endif()
else()
message(STATUS "This program requires the CGAL library, and will not be compiled.")

View File

@ -0,0 +1,21 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/draw_triangulation_2.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_2<K> Triangulation;
typedef Triangulation::Point Point;
int main() {
std::ifstream in("data/triangulation_prog1.cin");
std::istream_iterator<Point> begin(in);
std::istream_iterator<Point> end;
Triangulation t;
t.insert(begin, end);
CGAL::draw(t);
return EXIT_SUCCESS;
}

View File

@ -3,10 +3,6 @@
#include <fstream>
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Triangulation_2_viewer_qt.h>
#endif
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Regular_triangulation_2<K> Regular_triangulation;
@ -29,9 +25,5 @@ int main()
std::cout << "number of hidden vertices : " ;
std::cout << rt.number_of_hidden_vertices() << std::endl;
#ifdef CGAL_USE_BASIC_VIEWER
CGAL::display(rt);
#endif // CGAL_USE_BASIC_VIEWER
return 0;
}

View File

@ -153,7 +153,7 @@ template<class T2>
void draw(const T2& at2,
const char* title="T2 Viewer",
bool nofill=false)
{ return display<T2, DefaultColorFunctorT2>(at2, title, nofill); }
{ draw<T2, DefaultColorFunctorT2>(at2, title, nofill); }
} // End namespace CGAL

View File

@ -3,7 +3,11 @@ project( Triangulation_3_Examples )
cmake_minimum_required(VERSION 2.8.12)
find_package(CGAL QUIET)
find_package(CGAL COMPONENTS Qt5)
if(CGAL_Qt5_FOUND)
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()
if ( CGAL_FOUND )
create_single_source_cgal_program( "adding_handles_3.cpp" )
@ -20,19 +24,9 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "simple_triangulation_3.cpp" )
create_single_source_cgal_program( "simplex.cpp" )
find_package( TBB QUIET )
if( TBB_FOUND )
include( CGAL_target_use_TBB )
create_single_source_cgal_program( "parallel_insertion_and_removal_in_regular_3.cpp" )
create_single_source_cgal_program( "parallel_insertion_in_delaunay_3.cpp" )
create_single_source_cgal_program( "sequential_parallel.cpp" )
CGAL_target_use_TBB( parallel_insertion_and_removal_in_regular_3 )
CGAL_target_use_TBB( parallel_insertion_in_delaunay_3 )
CGAL_target_use_TBB( sequential_parallel )
else()
message(STATUS "NOTICE: a few examples require TBB and will not be compiled.")
create_single_source_cgal_program("draw_triangulation_3.cpp")
if(CGAL_Qt5_FOUND)
target_link_libraries(draw_triangulation_3 CGAL::CGAL_Qt5)
endif()
else()

View File

@ -0,0 +1,21 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/draw_triangulation_3.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K> DT3;
typedef CGAL::Creator_uniform_3<double,K::Point_3> Creator;
int main()
{
std::vector<K::Point_3> points;
CGAL::Random_points_in_sphere_3<K::Point_3,Creator> g(1.0);
CGAL::cpp11::copy_n(g, 50, std::back_inserter(points));
DT3 dt3(points.begin(), points.end());
CGAL::draw(dt3);
return EXIT_SUCCESS;
}

View File

@ -3,10 +3,6 @@
#include <cassert>
#include <vector>
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Triangulation_3_viewer_qt.h>
#endif
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT Weight;
@ -44,10 +40,6 @@ int main()
std::cout << "Number of vertices : " << T.number_of_vertices() << std::endl;
#ifdef CGAL_USE_BASIC_VIEWER
display(T);
#endif // CGAL_USE_BASIC_VIEWER
// removal of all vertices
int count = 0;
while (T.number_of_vertices() > 0) {

View File

@ -157,7 +157,7 @@ template<class T3>
void draw(const T3& at3,
const char* title="t3_viewer",
bool nofill=false)
{ return display<T3, DefaultColorFunctor>(at3, title, nofill); }
{ draw<T3, DefaultColorFunctorT3>(at3, title, nofill); }
} // End namespace CGAL