Fix Polyhedron example

This commit is contained in:
Maxime Gimeno 2018-05-29 11:57:13 +02:00
parent 6e878c4f66
commit fd15c8e040
3 changed files with 14 additions and 10 deletions

View File

@ -9,10 +9,7 @@ cmake_minimum_required(VERSION 2.8.10)
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()
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
endif()
if ( CGAL_FOUND )
@ -30,8 +27,8 @@ if ( CGAL_FOUND )
create_single_source_cgal_program( "${cppfile}" )
endforeach()
if(CGAL_Qt5_FOUND AND TARGET QGLViewer::QGLViewer)
target_link_libraries(draw_polyhedron CGAL::CGAL_Qt5 QGLViewer::QGLViewer)
if(CGAL_Qt5_FOUND )
target_link_libraries(draw_polyhedron CGAL::CGAL_Qt5)
endif()
else()

View File

@ -3,6 +3,9 @@
#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/draw_polyhedron.h>
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
@ -10,7 +13,11 @@ int main()
{
std::cerr<<"Loading OFF file ... "<<std::endl;
Polyhedron P;
std::cin>>P;
std::string filename;
std::cin>>filename;
std::cout<<filename<<std::endl;
std::ifstream in(filename);
in >> P;
CGAL::draw(P);

View File

@ -63,11 +63,11 @@ public:
/// @param title the title of the window
/// @param anofaces if true, do not draw faces (faces are not computed; this can be
/// usefull for very big object where this time could be long)
SimplePolyhedronViewerQt(const Polyhedron& apoly, const char* title="",
SimplePolyhedronViewerQt(QWidget* parent,const Polyhedron& apoly, const char* title="",
bool anofaces=false,
const ColorFunctor& fcolor=ColorFunctor()) :
// First draw: no vertex; edges, faces; mono-color; inverse normal
Base(title, false, true, true, true, false),
Base(parent, title, false, true, true, true, false),
poly(apoly),
m_nofaces(anofaces),
m_fcolor(fcolor)
@ -205,7 +205,7 @@ void draw(const Polyhedron& apoly,
QApplication app(argc,const_cast<char**>(argv));
SimplePolyhedronViewerQt<Polyhedron, ColorFunctor>
mainwindow(apoly, title, nofill, fcolor);
mainwindow(app.activeWindow(), apoly, title, nofill, fcolor);
#if !defined(CGAL_TEST_SUITE)
mainwindow.show();