Update all draw_XXX functions to use specialized version, allowing to use different draw in a same program.

This commit is contained in:
Guillaume Damiand 2018-09-06 18:43:32 +02:00
parent 6a6ea48789
commit 2c8af2ebcc
7 changed files with 96 additions and 173 deletions

View File

@ -1039,43 +1039,16 @@ private:
QOpenGLShaderProgram rendering_program_p_l;
};
} // End namespace CGAL
#else // CGAL_USE_BASIC_VIEWER
namespace CGAL
{
template<class T, class ColorFunctor>
void draw(const T&, const char*, bool, const ColorFunctor&)
{
std::cerr<<"Impossible to draw because CGAL_USE_BASIC_VIEWER is not defined."
<<std::endl;
}
template<class T>
void draw(const T&, const char*, bool)
void draw(const T& t, const char* ="", bool=false)
{
std::cerr<<"Impossible to draw because CGAL_USE_BASIC_VIEWER is not defined."
<<std::endl;
std::cerr<<"Impossible to draw, CGAL_USE_BASIC_VIEWER is not defined."<<std::endl;
}
template<class T>
void draw(const T&, const char*)
{
std::cerr<<"Impossible to draw because CGAL_USE_BASIC_VIEWER is not defined."
<<std::endl;
}
template<class T>
void draw(const T&)
{
std::cerr<<"Impossible to draw because CGAL_USE_BASIC_VIEWER is not defined."
<<std::endl;
}
} // End namespace CGAL
#endif // CGAL_USE_BASIC_VIEWER
} // End namespace CGAL
#endif // CGAL_BASIC_VIEWER_QT_H

View File

@ -25,6 +25,7 @@
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Linear_cell_complex_base.h>
#include <CGAL/Random.h>
namespace CGAL
@ -198,11 +199,21 @@ protected:
const ColorFunctor& m_fcolor;
};
template<class LCC, class ColorFunctor>
void draw(const LCC& alcc,
const char* title,
bool nofill,
const ColorFunctor& fcolor)
// Specialization of draw function.
#define CGAL_LCC_TYPE CGAL::Linear_cell_complex_base \
<d_, ambient_dim, Traits_, Items_, Alloc_, Map, Refs, Storage_>
template < unsigned int d_, unsigned int ambient_dim,
class Traits_,
class Items_,
class Alloc_,
template<unsigned int,class,class,class,class>
class Map,
class Refs,
class Storage_>
void draw(const CGAL_LCC_TYPE& alcc,
const char* title="LCC for CMap Basic Viewer",
bool nofill=false)
{
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite=true;
@ -215,30 +226,15 @@ void draw(const LCC& alcc,
int argc=1;
const char* argv[2]={"lccviewer","\0"};
QApplication app(argc,const_cast<char**>(argv));
SimpleLCCViewerQt<LCC, ColorFunctor> mainwindow(app.activeWindow(),
alcc,
title,
nofill,
fcolor);
DefaultColorFunctorLCC fcolor;
SimpleLCCViewerQt<CGAL_LCC_TYPE, DefaultColorFunctorLCC>
mainwindow(app.activeWindow(), alcc, title, nofill, fcolor);
mainwindow.show();
app.exec();
}
}
template<class LCC>
void draw(const LCC& alcc, const char* title, bool nofill)
{
DefaultColorFunctorLCC c;
draw(alcc, title, nofill, c);
}
template<class LCC>
void draw(const LCC& alcc, const char* title)
{ draw(alcc, title, false); }
template<class LCC>
void draw(const LCC& alcc)
{ draw(alcc, "Basic LCC Viewer"); }
#undef CGAL_LCC_TYPE
} // End namespace CGAL

View File

@ -26,6 +26,7 @@
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Point_set_3.h>
#include <CGAL/Random.h>
namespace CGAL
@ -77,8 +78,10 @@ protected:
const PointSet& pointset;
};
template<class PointSet>
void draw(const PointSet& apointset, const char* title)
// Specialization of draw function.
template<class P, class V>
void draw(const Point_set_3<P, V>& apointset,
const char* title="Point_set_3 Basic Viewer")
{
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite=true;
@ -91,7 +94,7 @@ void draw(const PointSet& apointset, const char* title)
int argc=1;
const char* argv[2]={"point_set_viewer","\0"};
QApplication app(argc,const_cast<char**>(argv));
SimplePointSetViewerQt<PointSet> mainwindow(app.activeWindow(),
SimplePointSetViewerQt<Point_set_3<P, V> > mainwindow(app.activeWindow(),
apointset,
title);
mainwindow.show();
@ -99,10 +102,6 @@ void draw(const PointSet& apointset, const char* title)
}
}
template<class PointSet>
void draw(const PointSet& apointset)
{ draw(apointset, "Basic Point_set Viewer"); }
} // End namespace CGAL
#endif // CGAL_USE_BASIC_VIEWER

View File

@ -26,6 +26,7 @@
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Random.h>
namespace CGAL
@ -194,11 +195,18 @@ protected:
const ColorFunctor& m_fcolor;
};
template<class Polyhedron, class ColorFunctor>
void draw(const Polyhedron& apoly,
const char* title,
bool nofill,
const ColorFunctor& fcolor)
// Specialization of draw function.
#define CGAL_POLY_TYPE CGAL::Polyhedron_3 \
<PolyhedronTraits_3, PolyhedronItems_3, T_HDS, Alloc>
template<class PolyhedronTraits_3,
class PolyhedronItems_3,
template < class T, class I, class A>
class T_HDS,
class Alloc>
void draw(const CGAL_POLY_TYPE& apoly,
const char* title="Polyhedron Basic Viewer",
bool nofill=false)
{
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite=true;
@ -211,27 +219,15 @@ void draw(const Polyhedron& apoly,
int argc=1;
const char* argv[2]={"polyhedron_viewer","\0"};
QApplication app(argc,const_cast<char**>(argv));
SimplePolyhedronViewerQt<Polyhedron, ColorFunctor>
DefaultColorFunctorPolyhedron fcolor;
SimplePolyhedronViewerQt<CGAL_POLY_TYPE, DefaultColorFunctorPolyhedron>
mainwindow(app.activeWindow(), apoly, title, nofill, fcolor);
mainwindow.show();
app.exec();
}
}
template<class Polyhedron>
void draw(const Polyhedron& apoly, const char* title, bool nofill)
{
DefaultColorFunctorPolyhedron c;
draw(apoly, title, nofill, c);
}
template<class Polyhedron>
void draw(const Polyhedron& apoly, const char* title)
{ draw(apoly, title, false); }
template<class Polyhedron>
void draw(const Polyhedron& apoly)
{ draw(apoly, "Basic Polyhedron Viewer"); }
#undef CGAL_POLY_TYPE
} // End namespace CGAL

View File

@ -41,6 +41,7 @@ void draw(const SM& asm);
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Surface_mesh.h>
#include <CGAL/Random.h>
namespace CGAL
@ -201,11 +202,11 @@ protected:
const ColorFunctor& m_fcolor;
};
template<class SM, class ColorFunctor>
void draw(const SM& amesh,
const char* title,
bool nofill,
const ColorFunctor& fcolor)
// Specialization of draw function.
template<class K>
void draw(const Surface_mesh<K>& amesh,
const char* title="Surface_mesh Basic Viewer",
bool nofill=false)
{
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite=true;
@ -218,31 +219,14 @@ void draw(const SM& amesh,
int argc=1;
const char* argv[2]={"surface_mesh_viewer","\0"};
QApplication app(argc,const_cast<char**>(argv));
SimpleSurfaceMeshViewerQt<SM, ColorFunctor> mainwindow(app.activeWindow(),
amesh,
title,
nofill,
fcolor);
DefaultColorFunctorSM fcolor;
SimpleSurfaceMeshViewerQt<Surface_mesh<K>, DefaultColorFunctorSM>
mainwindow(app.activeWindow(), amesh, title, nofill, fcolor);
mainwindow.show();
app.exec();
}
}
template<class SM>
void draw(const SM& amesh, const char* title, bool nofill)
{
DefaultColorFunctorSM c;
draw(amesh, title, nofill, c);
}
template<class SM>
void draw(const SM& amesh, const char* title)
{ draw(amesh, title, false); }
template<class SM>
void draw(const SM& amesh)
{ draw(amesh, "Basic Surface_mesh Viewer"); }
} // End namespace CGAL
#endif // CGAL_USE_BASIC_VIEWER

View File

@ -26,6 +26,7 @@
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Triangulation_2.h>
#include <CGAL/Random.h>
namespace CGAL
@ -136,11 +137,13 @@ protected:
const ColorFunctor& m_fcolor;
};
template<class T2, class ColorFunctor>
void draw(const T2& at2,
const char* title,
bool nofill,
const ColorFunctor& fcolor)
// Specialization of draw function.
#define CGAL_T2_TYPE CGAL::Triangulation_2<Gt, Tds>
template<class Gt, class Tds>
void draw(const CGAL_T2_TYPE& at2,
const char* title="Triangulation_2 Basic Viewer",
bool nofill=false)
{
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite=true;
@ -153,30 +156,15 @@ void draw(const T2& at2,
int argc=1;
const char* argv[2]={"t2_viewer","\0"};
QApplication app(argc,const_cast<char**>(argv));
SimpleTriangulation2ViewerQt<T2, ColorFunctor> mainwindow(app.activeWindow(),
at2,
title,
nofill,
fcolor);
DefaultColorFunctorT2 fcolor;
SimpleTriangulation2ViewerQt<CGAL_T2_TYPE, DefaultColorFunctorT2>
mainwindow(app.activeWindow(), at2, title, nofill, fcolor);
mainwindow.show();
app.exec();
}
}
template<class T2>
void draw(const T2& at2, const char* title, bool nofill)
{
DefaultColorFunctorT2 c;
draw(at2, title, nofill, c);
}
template<class T2>
void draw(const T2& at2, const char* title)
{ draw(at2, title, false); }
template<class T2>
void draw(const T2& at2)
{ draw(at2, "Basic T2 Viewer"); }
#undef CGAL_T2_TYPE
} // End namespace CGAL

View File

@ -26,6 +26,7 @@
#ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Triangulation_3.h>
#include <CGAL/Random.h>
namespace CGAL
@ -142,13 +143,14 @@ protected:
const ColorFunctor& m_fcolor;
};
template<class T3, class ColorFunctor>
void draw(const T3& at3,
const char* title,
bool nofill,
const ColorFunctor& fcolor)
{
// Specialization of draw function.
#define CGAL_T3_TYPE CGAL::Triangulation_3<Gt, Tds, Lock_data_structure>
template<class Gt, class Tds, class Lock_data_structure>
void draw(const CGAL_T3_TYPE& at3,
const char* title="T3 Basic Viewer",
bool nofill=false)
{
#if defined(CGAL_TEST_SUITE)
bool cgal_test_suite=true;
#else
@ -160,30 +162,15 @@ void draw(const T3& at3,
int argc=1;
const char* argv[2]={"t3_viewer","\0"};
QApplication app(argc,const_cast<char**>(argv));
SimpleTriangulation3ViewerQt<T3, ColorFunctor> mainwindow(app.activeWindow(),
at3,
title,
nofill,
fcolor);
DefaultColorFunctorT3 fcolor;
SimpleTriangulation3ViewerQt<CGAL_T3_TYPE, DefaultColorFunctorT3>
mainwindow(app.activeWindow(), at3, title, nofill, fcolor);
mainwindow.show();
app.exec();
}
}
template<class T3>
void draw(const T3& at3, const char* title, bool nofill)
{
DefaultColorFunctorT3 c;
draw(at3, title, nofill, c);
}
template<class T3>
void draw(const T3& at3, const char* title)
{ draw(at3, title, false); }
template<class T3>
void draw(const T3& at3)
{ draw(at3, "Basic T3 Viewer"); }
#undef CGAL_T3_TYPE
} // End namespace CGAL