Modified Point_set_3 to use new APIs version.

This commit is contained in:
Mostafa-ashraf19 2022-09-23 01:48:59 +02:00
parent 5fbaf43434
commit c1037f9040
1 changed files with 35 additions and 67 deletions

View File

@ -9,12 +9,13 @@
// //
// //
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr> // Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
#ifndef CGAL_DRAW_POINT_SET_3_H #ifndef CGAL_DRAW_POINT_SET_3_H
#define CGAL_DRAW_POINT_SET_3_H #define CGAL_DRAW_POINT_SET_3_H
#include <CGAL/license/Point_set_3.h>
#include <CGAL/Qt/Basic_viewer_qt.h> #include <CGAL/Qt/Basic_viewer_qt.h>
#include <CGAL/license/Point_set_3.h>
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
namespace CGAL { namespace CGAL {
@ -36,82 +37,49 @@ void draw(const PS& aps);
#ifdef CGAL_USE_BASIC_VIEWER #ifdef CGAL_USE_BASIC_VIEWER
#include <CGAL/Qt/init_ogl_context.h>
#include <CGAL/Point_set_3.h> #include <CGAL/Point_set_3.h>
#include <CGAL/Qt/init_ogl_context.h>
#include <CGAL/Random.h> #include <CGAL/Random.h>
namespace CGAL namespace CGAL {
{
// Viewer class for Point_set namespace draw_function_for_PointSet {
template<class PointSet>
class SimplePointSetViewerQt : public Basic_viewer_qt
{
typedef Basic_viewer_qt Base;
typedef typename PointSet::Point_map::value_type Point;
public: template <typename BufferType = float, class PointSet>
/// Construct the viewer. void compute_vertex(const typename PointSet::Point_map::value_type &p,
/// @param apointset the point set to view GraphicBuffer<BufferType> &graphic_buffer) {
/// @param title the title of the window graphic_buffer.add_point(p);
SimplePointSetViewerQt(QWidget* parent,
const PointSet& apointset, const char* title="") : // We can use add_point(p, c) with c a CGAL::IO::Color to add a colored point
// First draw: vertices; no-edge, no-face; mono-color; no inverse normal // E.g: graphic_buffer.add_point(p, CGAL::IO::Color(100, 125, 200));
Base(parent, title, true, false, false, true, false), }
pointset(apointset)
{ template <typename BufferType = float, class PointSet>
compute_elements(); void compute_elements(const PointSet *pointset,
GraphicBuffer<BufferType> &graphic_buffer) {
for (typename PointSet::const_iterator it = pointset->begin();
it != pointset->end(); ++it) {
compute_vertex<float, PointSet>(pointset->point(*it), graphic_buffer);
} }
}
protected: } // namespace draw_function_for_PointSet
void compute_vertex(const Point& p)
{ template <typename BufferType = float, class PointSet>
add_point(p); void add_in_graphic_buffer_point_set(GraphicBuffer<BufferType> &graphic_buffer,
// We can use add_point(p, c) with c a CGAL::IO::Color to add a colored point const PointSet *aPointSet = nullptr) {
if (aPointSet != nullptr) {
draw_function_for_PointSet::compute_elements(aPointSet, graphic_buffer);
} }
}
void compute_elements()
{
clear();
for (typename PointSet::const_iterator it=pointset.begin();
it!=pointset.end(); ++it)
{ compute_vertex(pointset.point(*it)); }
}
virtual void keyPressEvent(QKeyEvent *e)
{
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
Base::keyPressEvent(e);
}
protected:
const PointSet& pointset;
};
// Specialization of draw function. // Specialization of draw function.
template<class P, class V> template <class P, class V>
void draw(const Point_set_3<P, V>& apointset, void draw(const Point_set_3<P, V> &apointset,
const char* title="Point_set_3 Basic Viewer") const char *title = "Point_set_3 Basic Viewer") {
{ GraphicBuffer<float> buffer;
#if defined(CGAL_TEST_SUITE) add_in_graphic_buffer_point_set(buffer, &apointset);
bool cgal_test_suite=true; draw_buffer(buffer);
#else
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
#endif
if (!cgal_test_suite)
{
CGAL::Qt::init_ogl_context(4,3);
int argc=1;
const char* argv[2]={"point_set_viewer", nullptr};
QApplication app(argc,const_cast<char**>(argv));
SimplePointSetViewerQt<Point_set_3<P, V> > mainwindow(app.activeWindow(),
apointset,
title);
mainwindow.show();
app.exec();
}
} }
} // End namespace CGAL } // End namespace CGAL