mirror of https://github.com/CGAL/cgal
Merge pull request #4016 from gdamiand/CGAL-more_viewers-gdamiand
CGAL: more viewers
This commit is contained in:
commit
dc02598a5c
|
|
@ -35,7 +35,7 @@
|
|||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include <queue>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <map>
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
|
@ -161,6 +161,9 @@ public:
|
|||
m_flat_normal_buffer(flat_normal),
|
||||
m_gouraud_normal_buffer(gouraud_normal),
|
||||
m_bb(bbox),
|
||||
m_zero_x(true),
|
||||
m_zero_y(true),
|
||||
m_zero_z(true),
|
||||
m_face_started(false)
|
||||
{}
|
||||
|
||||
|
|
@ -171,6 +174,10 @@ public:
|
|||
if (m_index_buffer!=nullptr) { m_index_buffer->clear(); }
|
||||
if (m_flat_normal_buffer!=nullptr) { m_flat_normal_buffer->clear(); }
|
||||
if (m_gouraud_normal_buffer!=nullptr) { m_gouraud_normal_buffer->clear(); }
|
||||
|
||||
m_zero_x=true;
|
||||
m_zero_y=true;
|
||||
m_zero_z=true;
|
||||
}
|
||||
|
||||
bool is_empty() const
|
||||
|
|
@ -198,6 +205,15 @@ public:
|
|||
bool has_gouraud_normal() const
|
||||
{ return m_gouraud_normal_buffer!=nullptr; }
|
||||
|
||||
bool has_zero_x() const
|
||||
{ return m_zero_x; }
|
||||
|
||||
bool has_zero_y() const
|
||||
{ return m_zero_y; }
|
||||
|
||||
bool has_zero_z() const
|
||||
{ return m_zero_z; }
|
||||
|
||||
// 1.1) Add a point, without color. Return the index of the added point.
|
||||
template<typename KPoint>
|
||||
std::size_t add_point(const KPoint& kp)
|
||||
|
|
@ -210,6 +226,10 @@ public:
|
|||
if (m_bb!=nullptr)
|
||||
{ (*m_bb)=(*m_bb)+p.bbox(); }
|
||||
|
||||
if (m_zero_x && p.x()!=0) { m_zero_x=false; }
|
||||
if (m_zero_y && p.y()!=0) { m_zero_y=false; }
|
||||
if (m_zero_z && p.z()!=0) { m_zero_z=false; }
|
||||
|
||||
return m_pos_buffer->size()-3;
|
||||
}
|
||||
|
||||
|
|
@ -605,8 +625,23 @@ protected:
|
|||
{
|
||||
P_traits cdt_traits(normal);
|
||||
CDT cdt(cdt_traits);
|
||||
|
||||
bool with_vertex_normal=(m_vertex_normals_for_face.size()==m_points_of_face.size());
|
||||
Local_point p1, p2;
|
||||
|
||||
// For each point of the face, store the list of adjacent points and the number of time
|
||||
// the edge is found in the face. For an edge p1, p2, store edge min(p1,p2)->max(p1,p2)
|
||||
std::map<Local_point, std::map<Local_point, unsigned int> > edges;
|
||||
for (unsigned int i=0; i<m_points_of_face.size(); ++i)
|
||||
{
|
||||
p1=m_points_of_face[i];
|
||||
p2=m_points_of_face[i==0?m_points_of_face.size()-1:i-1];
|
||||
if (p2<p1) { std::swap(p1, p2); }
|
||||
|
||||
if (edges.count(p1)==0)
|
||||
{ std::map<Local_point, unsigned int> m; m[p2]=1; edges[p1]=m; }
|
||||
else if (edges[p1].count(p2)==0) { edges[p1][p2]=1; }
|
||||
else { ++(edges[p1][p2]); }
|
||||
}
|
||||
|
||||
// (1) We insert all the edges as contraint in the CDT.
|
||||
typename CDT::Vertex_handle previous=nullptr, first=nullptr;
|
||||
|
|
@ -625,12 +660,22 @@ protected:
|
|||
{ vh->info().index=m_indices_of_points_of_face[i]; }
|
||||
|
||||
if(previous!=nullptr && previous!=vh)
|
||||
{ cdt.insert_constraint(previous, vh); }
|
||||
{
|
||||
p1=m_points_of_face[i]; p2=m_points_of_face[i-1];
|
||||
if (p2<p1) { std::swap(p1, p2); }
|
||||
if ((edges[p1][p2])%2==1) // odd number of time => constraint
|
||||
{ cdt.insert_constraint(previous, vh); }
|
||||
}
|
||||
previous=vh;
|
||||
}
|
||||
|
||||
if (previous!=nullptr && previous!=first)
|
||||
{ cdt.insert_constraint(previous, first); }
|
||||
{
|
||||
p1=m_points_of_face[m_points_of_face.size()-1]; p2=m_points_of_face[0];
|
||||
if (p2<p1) std::swap(p1, p2);
|
||||
if ((edges[p1][p2])%2==1) // odd number of time => constraint
|
||||
{ cdt.insert_constraint(previous, first); }
|
||||
}
|
||||
|
||||
// (2) We mark all external triangles
|
||||
// (2.1) We initialize is_external and is_process values
|
||||
|
|
@ -783,6 +828,10 @@ protected:
|
|||
|
||||
CGAL::Bbox_3* m_bb;
|
||||
|
||||
bool m_zero_x; /// True iff all points have x==0
|
||||
bool m_zero_y; /// True iff all points have y==0
|
||||
bool m_zero_z; /// True iff all points have z==0
|
||||
|
||||
// Local variables, used when we started a new face.
|
||||
bool m_face_started;
|
||||
bool m_started_face_is_colored;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
|
||||
#include <CGAL/Buffer_for_vao.h>
|
||||
#include <CGAL/Qt/CreateOpenGLContext.h>
|
||||
#include <CGAL/Qt/constraint.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
|
|
@ -253,6 +254,39 @@ public:
|
|||
const CGAL::Bbox_3& bounding_box() const
|
||||
{ return m_bounding_box; }
|
||||
|
||||
bool has_zero_x() const
|
||||
{
|
||||
return
|
||||
m_buffer_for_mono_points.has_zero_x() &&
|
||||
m_buffer_for_colored_points.has_zero_x() &&
|
||||
m_buffer_for_mono_segments.has_zero_x() &&
|
||||
m_buffer_for_colored_segments.has_zero_x() &&
|
||||
m_buffer_for_mono_faces.has_zero_x() &&
|
||||
m_buffer_for_colored_faces.has_zero_x();
|
||||
}
|
||||
|
||||
bool has_zero_y() const
|
||||
{
|
||||
return
|
||||
m_buffer_for_mono_points.has_zero_y() &&
|
||||
m_buffer_for_colored_points.has_zero_y() &&
|
||||
m_buffer_for_mono_segments.has_zero_y() &&
|
||||
m_buffer_for_colored_segments.has_zero_y() &&
|
||||
m_buffer_for_mono_faces.has_zero_y() &&
|
||||
m_buffer_for_colored_faces.has_zero_y();
|
||||
}
|
||||
|
||||
bool has_zero_z() const
|
||||
{
|
||||
return
|
||||
m_buffer_for_mono_points.has_zero_z() &&
|
||||
m_buffer_for_colored_points.has_zero_z() &&
|
||||
m_buffer_for_mono_segments.has_zero_z() &&
|
||||
m_buffer_for_colored_segments.has_zero_z() &&
|
||||
m_buffer_for_mono_faces.has_zero_z() &&
|
||||
m_buffer_for_colored_faces.has_zero_z();
|
||||
}
|
||||
|
||||
template<typename KPoint>
|
||||
void add_point(const KPoint& p)
|
||||
{ m_buffer_for_mono_points.add_point(p); }
|
||||
|
|
@ -732,6 +766,23 @@ protected:
|
|||
|
||||
rendering_program_face.release();
|
||||
}
|
||||
|
||||
if (!is_empty() && (has_zero_x() || has_zero_y() || has_zero_z()))
|
||||
{
|
||||
camera()->setType(CGAL::qglviewer::Camera::ORTHOGRAPHIC);
|
||||
// Camera Constraint:
|
||||
constraint.setRotationConstraintType(CGAL::qglviewer::AxisPlaneConstraint::AXIS);
|
||||
constraint.setTranslationConstraintType(CGAL::qglviewer::AxisPlaneConstraint::FREE);
|
||||
|
||||
double cx=0., cy=0., cz=0.;
|
||||
if (has_zero_x()) { cx=1.; }
|
||||
else if (has_zero_y()) { cy=1.; }
|
||||
else { cz=1.; }
|
||||
|
||||
camera()->setViewDirection(CGAL::qglviewer::Vec(-cx,-cy,-cz));
|
||||
constraint.setRotationConstraintDirection(CGAL::qglviewer::Vec(cx, cy, cz));
|
||||
camera()->frame()->setConstraint(&constraint);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void redraw()
|
||||
|
|
@ -1001,6 +1052,9 @@ protected:
|
|||
bool m_are_buffers_initialized;
|
||||
CGAL::Bbox_3 m_bounding_box;
|
||||
|
||||
// CGAL::qglviewer::LocalConstraint constraint;
|
||||
CGAL::qglviewer::WorldConstraint constraint;
|
||||
|
||||
// The following enum gives the indices of different elements of arrays vectors.
|
||||
enum
|
||||
{
|
||||
|
|
@ -1062,33 +1116,11 @@ protected:
|
|||
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)
|
||||
{
|
||||
std::cerr<<"Impossible to draw because 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;
|
||||
}
|
||||
template<class T>
|
||||
void draw(const T&, const char* ="", bool=false)
|
||||
{
|
||||
std::cerr<<"Impossible to draw, CGAL_USE_BASIC_VIEWER is not defined."<<std::endl;
|
||||
}
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ function(cgal_add_compilation_test exe_name)
|
|||
endif()
|
||||
endfunction(cgal_add_compilation_test)
|
||||
|
||||
option(CGAL_TEST_DRAW_FUNCTIONS "If set, the ctest command will not skip the tests of the draw functions.")
|
||||
|
||||
function(cgal_setup_test_properties test_name)
|
||||
if(ARGC GREATER 1)
|
||||
set(exe_name ${ARGV1})
|
||||
|
|
@ -124,6 +126,11 @@ function(cgal_setup_test_properties test_name)
|
|||
# message(STATUS " working dir: ${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_property(TEST "${test_name}"
|
||||
PROPERTY WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
if(NOT CGAL_TEST_DRAW_FUNCTIONS)
|
||||
set_property(TEST "${test_name}"
|
||||
APPEND PROPERTY ENVIRONMENT CGAL_TEST_SUITE=1)
|
||||
endif()
|
||||
|
||||
if(exe_name)
|
||||
set_property(TEST "${test_name}"
|
||||
APPEND PROPERTY DEPENDS "compilation_of__${exe_name}")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ namespace CGAL {
|
|||
/*!
|
||||
\ingroup PkgDrawLinearCellComplex
|
||||
|
||||
Open a new window and draw `alcc`, a model of the `LinearCellComplex` concept. The function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
opens a new window and draws `alcc`, a model of the `LinearCellComplex` concept. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam LCC a model of the `LinearCellComplex` concept.
|
||||
\param alcc the linear cell complex to draw.
|
||||
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ We can observe that the second run is faster than the first one. Indeed, updatin
|
|||
\subsection Linear_cell_complexDraw Draw a Linear Cell Complex
|
||||
\anchor ssecDrawLCC
|
||||
|
||||
A linear cell complex can be visualized by calling the `CGAL::draw()` function as shown in the following example. This function opens a new window showing the given linear cell complex. The function is blocking, that is the program continues as soon as the user closes the window.
|
||||
A linear cell complex can be visualized by calling the \link PkgDrawLinearCellComplex CGAL::draw<LCC>() \endlink function as shown in the following example. This function opens a new window showing the given linear cell complex. A call to this function is blocking, that is the program continues as soon as the user closes the window.
|
||||
|
||||
\cgalExample{Linear_cell_complex/draw_linear_cell_complex.cpp}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
/// \defgroup PkgLinearCellComplexOperations Operations for Linear Cell Complex
|
||||
/// \ingroup PkgLinearCellComplexRef
|
||||
|
||||
/*! Draw.
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_linear_cell_complex.h>
|
||||
\endcode
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
- `CGAL::compute_normal_of_cell_2<LCC>`
|
||||
|
||||
\cgalCRPSubsection{Draw a Linear Cell Complex}
|
||||
- `CGAL::draw<LCC>`
|
||||
- \link PkgDrawLinearCellComplex CGAL::draw<LCC>() \endlink
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ endif()
|
|||
find_package(CGAL COMPONENTS Qt5)
|
||||
|
||||
if(CGAL_Qt5_FOUND)
|
||||
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
|
||||
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
|
||||
endif()
|
||||
|
||||
# For Gprof.
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Linear_cell_complex_base.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
|
|
@ -372,16 +373,26 @@ protected:
|
|||
const DrawingFunctorLCC& m_drawing_functor;
|
||||
};
|
||||
|
||||
template<class LCC, class DrawingFunctorLCC>
|
||||
void draw(const LCC& alcc,
|
||||
const char* title,
|
||||
bool nofill,
|
||||
const DrawingFunctorLCC& drawing_functor)
|
||||
// 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;
|
||||
#else
|
||||
bool cgal_test_suite=false;
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
|
|
@ -389,30 +400,16 @@ void draw(const LCC& alcc,
|
|||
int argc=1;
|
||||
const char* argv[2]={"lccviewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
SimpleLCCViewerQt<LCC, DrawingFunctorLCC> mainwindow(app.activeWindow(),
|
||||
&alcc,
|
||||
title,
|
||||
nofill,
|
||||
drawing_functor);
|
||||
DefaultDrawingFunctorLCC fcolor;
|
||||
SimpleLCCViewerQt<CGAL_LCC_TYPE, DefaultDrawingFunctorLCC>
|
||||
mainwindow(app.activeWindow(), &alcc, title, nofill, fcolor);
|
||||
mainwindow.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
template<class LCC>
|
||||
void draw(const LCC& alcc, const char* title, bool nofill)
|
||||
{
|
||||
DefaultDrawingFunctorLCC f;
|
||||
draw(alcc, title, nofill, f);
|
||||
}
|
||||
|
||||
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"); }
|
||||
// Todo a function taking a const DrawingFunctorLCC& drawing_functor as parameter
|
||||
#undef CGAL_LCC_TYPE
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
/// \defgroup PkgPointSet3Ref 3D Point Set Reference
|
||||
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_point_set_3.h>
|
||||
\endcode
|
||||
*/
|
||||
/// \defgroup PkgDrawPointSet3D Draw a 3D Point Set
|
||||
/// \ingroup PkgPointSet3Ref
|
||||
|
||||
/*!
|
||||
\addtogroup PkgPointSet3Ref
|
||||
|
||||
\cgalPkgDescriptionBegin{3D Point Set, PkgPointSet3}
|
||||
\cgalPkgPicture{point_set_3.png}
|
||||
\cgalPkgSummaryBegin
|
||||
|
|
@ -21,6 +31,9 @@
|
|||
\cgalCRPSection{Class}
|
||||
- `CGAL::Point_set_3<Point,Vector>`
|
||||
|
||||
\cgalCRPSection{Draw a 3D Point Set}
|
||||
- \link PkgDrawPointSet3D CGAL::draw<PS>() \endlink
|
||||
|
||||
\defgroup PkgPointSet3IO Input/Output
|
||||
\ingroup PkgPointSet3Ref
|
||||
|
||||
|
|
|
|||
|
|
@ -163,6 +163,18 @@ overload provided for `CGAL::Point_set_3`:
|
|||
|
||||
\cgalExample{Point_set_3/point_set_advanced.cpp}
|
||||
|
||||
\subsection Point_set_3_Draw Draw a Point Set
|
||||
|
||||
A 3D point set can be visualized by calling the \link PkgDrawPointSet3D CGAL::draw<PS>() \endlink function as shown in the following example. This function opens a new window showing the given point set. A call to this function is blocking, that is the program continues as soon as the user closes the window.
|
||||
|
||||
\cgalExample{Point_set_3/draw_point_set_3.cpp}
|
||||
|
||||
This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
|
||||
\cgalFigureBegin{fig_draw_point_set,draw_point_set.png}
|
||||
Result of the run of the draw_point_set_3 program. A window shows the 3D points and allows to navigate through the 3D scene.
|
||||
\cgalFigureEnd
|
||||
|
||||
\section Point_set_3_History History
|
||||
|
||||
This package has been created to fill the need for a practical data
|
||||
|
|
|
|||
|
|
@ -5,4 +5,5 @@
|
|||
\example Point_set_3/point_set_read_xyz.cpp
|
||||
\example Point_set_3/point_set_read_ply.cpp
|
||||
\example Point_set_3/point_set_advanced.cpp
|
||||
\example Point_set_3/draw_point_set_3.cpp
|
||||
*/
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -7,7 +7,7 @@ project( Point_set_3_Examples )
|
|||
|
||||
|
||||
# CGAL and its components
|
||||
find_package( CGAL QUIET COMPONENTS )
|
||||
find_package( CGAL QUIET COMPONENTS Qt5 )
|
||||
|
||||
if ( NOT CGAL_FOUND )
|
||||
|
||||
|
|
@ -16,6 +16,10 @@ if ( NOT CGAL_FOUND )
|
|||
|
||||
endif()
|
||||
|
||||
if(CGAL_Qt5_FOUND)
|
||||
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
|
||||
endif()
|
||||
|
||||
# Boost and its components
|
||||
find_package( Boost REQUIRED )
|
||||
|
||||
|
|
@ -50,5 +54,7 @@ else()
|
|||
create_single_source_cgal_program( "point_set_algo.cpp" )
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
create_single_source_cgal_program("draw_point_set_3.cpp" )
|
||||
if(CGAL_Qt5_FOUND)
|
||||
target_link_libraries(draw_point_set_3 PUBLIC CGAL::CGAL_Qt5)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Point_set_3.h>
|
||||
#include <CGAL/Point_set_3/IO.h>
|
||||
#include <CGAL/draw_point_set_3.h>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef Kernel::FT FT;
|
||||
typedef Kernel::Point_3 Point;
|
||||
typedef Kernel::Vector_3 Vector;
|
||||
typedef CGAL::Point_set_3<Point> Point_set;
|
||||
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
std::ifstream f (argc > 1 ? argv[1] : "data/oni.xyz");
|
||||
Point_set point_set;
|
||||
|
||||
// Reading input in XYZ format
|
||||
if (!f || !CGAL::read_xyz_point_set (f, point_set))
|
||||
{
|
||||
std::cerr<<"Can't read input file "
|
||||
<<(argc > 1 ? argv[1] : "data/oni.xyz")<< std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL::draw(point_set);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
// Copyright (c) 2016 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
|
||||
#ifndef 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>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPointSet3D
|
||||
|
||||
opens a new window and draws `aps`, an instance of the `CGAL::Point_set_3` class. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam PS an instance of the `CGAL::Point_set_3` class.
|
||||
\param aps the point set to draw.
|
||||
|
||||
*/
|
||||
template<class PS>
|
||||
void draw(const PS& aps);
|
||||
|
||||
} /* namespace CGAL */
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Point_set_3.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
// Viewer class for Point_set
|
||||
template<class PointSet>
|
||||
class SimplePointSetViewerQt : public Basic_viewer_qt
|
||||
{
|
||||
typedef Basic_viewer_qt Base;
|
||||
typedef typename PointSet::Point_map::value_type Point;
|
||||
|
||||
public:
|
||||
/// Construct the viewer.
|
||||
/// @param apointset the point set to view
|
||||
/// @param title the title of the window
|
||||
SimplePointSetViewerQt(QWidget* parent,
|
||||
const PointSet& apointset, const char* title="") :
|
||||
// First draw: vertices; no-edge, no-face; mono-color; no inverse normal
|
||||
Base(parent, title, true, false, false, true, false),
|
||||
pointset(apointset)
|
||||
{
|
||||
compute_elements();
|
||||
}
|
||||
|
||||
protected:
|
||||
void compute_vertex(const Point& p)
|
||||
{
|
||||
add_point(p);
|
||||
// We can use add_point(p, c) with c a CGAL::Color to add a colored point
|
||||
}
|
||||
|
||||
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.
|
||||
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;
|
||||
#else
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
int argc=1;
|
||||
const char* argv[2]={"point_set_viewer","\0"};
|
||||
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
|
||||
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#endif // CGAL_DRAW_POINT_SET_3_H
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
Algebraic_foundations
|
||||
BGL
|
||||
GraphicsView
|
||||
Installation
|
||||
Interval_support
|
||||
Kernel_23
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 2D Polygons"
|
|||
EXAMPLE_PATH = ${CGAL_PACKAGE_DIR}/examples \
|
||||
${CGAL_Stream_support_EXAMPLE_DIR}
|
||||
|
||||
|
||||
EXTRACT_ALL = false
|
||||
HIDE_UNDOC_MEMBERS = true
|
||||
HIDE_UNDOC_CLASSES = true
|
||||
|
|
|
|||
|
|
@ -6,6 +6,22 @@
|
|||
/// \defgroup PkgPolygon2Functions Global Functions
|
||||
/// \ingroup PkgPolygon2Ref
|
||||
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_polygon_2.h>
|
||||
\endcode
|
||||
*/
|
||||
/// \defgroup PkgDrawPolygon2 Draw a 2D Polygon
|
||||
/// \ingroup PkgPolygon2Ref
|
||||
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_polygon_with_holes_2.h>
|
||||
\endcode
|
||||
*/
|
||||
/// \defgroup PkgDrawPolygonWithHoles2 Draw a 2D Polygon with Holes
|
||||
/// \ingroup PkgPolygon2Ref
|
||||
|
||||
/*!
|
||||
\addtogroup PkgPolygon2Ref
|
||||
|
||||
|
|
@ -53,5 +69,11 @@ The assertion flags for the polygons and polygon operations use
|
|||
- `CGAL::right_vertex_2()`
|
||||
- `CGAL::top_vertex_2()`
|
||||
|
||||
\cgalCRPSection{Draw a Polygon_2}
|
||||
- \link PkgDrawPolygon2 CGAL::draw<P>() \endlink
|
||||
|
||||
\cgalCRPSection{Draw a Polygon_with_holes_2}
|
||||
- \link PkgDrawPolygonWithHoles2 CGAL::draw<PH>() \endlink
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,18 @@ and 3D Linear Geometric %Kernel.
|
|||
|
||||
\cgalExample{Polygon/projected_polygon.cpp}
|
||||
|
||||
\subsection subsecPolygonDraw Draw a Polygon
|
||||
|
||||
A polygon can be visualized by calling the \link PkgDrawPolygon2 CGAL::draw<P>() \endlink function as shown in the following example. This function opens a new window showing the given polygon. A call to this function is blocking, that is the program continues as soon as the user closes the window (a version exists for polygon with holes, cf. \link PkgDrawPolygonWithHoles2 CGAL::draw<PH>() \endlink).
|
||||
|
||||
\cgalExample{Polygon/draw_polygon.cpp}
|
||||
|
||||
This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
|
||||
\cgalFigureBegin{fig_draw_polygon,draw_polygon.png}
|
||||
Result of the run of the draw_polygon program. A window shows the polygon and allows to navigate through the scene.
|
||||
\cgalFigureEnd
|
||||
|
||||
*/
|
||||
|
||||
\section secPolygonWithHole Polygons with Holes
|
||||
|
|
|
|||
|
|
@ -4,4 +4,6 @@
|
|||
\example Polygon/Polygon.cpp
|
||||
\example Polygon/projected_polygon.cpp
|
||||
\example Stream_support/Polygon_WKT.cpp
|
||||
\example Polygon/draw_polygon.cpp
|
||||
\example Polygon/draw_polygon_with_holes.cpp
|
||||
*/
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
|
|
@ -6,7 +6,11 @@ cmake_minimum_required(VERSION 3.1...3.15)
|
|||
project( Polygon_Examples )
|
||||
|
||||
|
||||
find_package(CGAL QUIET)
|
||||
find_package(CGAL QUIET COMPONENTS Qt5)
|
||||
|
||||
if(CGAL_Qt5_FOUND)
|
||||
add_definitions(-DCGAL_USE_BASIC_VIEWER -DQT_NO_KEYWORDS)
|
||||
endif()
|
||||
|
||||
if ( CGAL_FOUND )
|
||||
|
||||
|
|
@ -16,6 +20,11 @@ if ( CGAL_FOUND )
|
|||
create_single_source_cgal_program( "${cppfile}" )
|
||||
endforeach()
|
||||
|
||||
if(CGAL_Qt5_FOUND)
|
||||
target_link_libraries(draw_polygon PUBLIC CGAL::CGAL_Qt5)
|
||||
target_link_libraries(draw_polygon_with_holes PUBLIC CGAL::CGAL_Qt5)
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
message(STATUS "This program requires the CGAL library, and will not be compiled.")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
#include <CGAL/draw_polygon_2.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Polygon_2<K> Polygon_2;
|
||||
typedef CGAL::Point_2<K> Point;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a polygon and put some points in it
|
||||
Polygon_2 p;
|
||||
p.push_back(Point(0,0));
|
||||
p.push_back(Point(4,0));
|
||||
p.push_back(Point(4,4));
|
||||
p.push_back(Point(2,2));
|
||||
p.push_back(Point(0,4));
|
||||
|
||||
CGAL::draw(p);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polygon_with_holes_2.h>
|
||||
#include <CGAL/draw_polygon_with_holes_2.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes_2;
|
||||
typedef CGAL::Polygon_2<K> Polygon_2;
|
||||
typedef CGAL::Point_2<K> Point;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a polygon with three holes
|
||||
Polygon_2 outer_polygon;
|
||||
outer_polygon.push_back(Point(0,0)); outer_polygon.push_back(Point(9,0));
|
||||
outer_polygon.push_back(Point(6,8)); outer_polygon.push_back(Point(5,3));
|
||||
outer_polygon.push_back(Point(2,8)); outer_polygon.push_back(Point(0,8));
|
||||
|
||||
std::vector<Polygon_2> holes(3);
|
||||
holes[0].push_back(Point(6,2)); holes[0].push_back(Point(7,1));
|
||||
holes[0].push_back(Point(7,3)); holes[0].push_back(Point(6,3));
|
||||
holes[0].push_back(Point(5,2));
|
||||
|
||||
holes[1].push_back(Point(2,1)); holes[1].push_back(Point(3,1));
|
||||
holes[1].push_back(Point(3,3)); holes[1].push_back(Point(2,2));
|
||||
holes[1].push_back(Point(1,2));
|
||||
|
||||
holes[2].push_back(Point(1,4)); holes[2].push_back(Point(2,4));
|
||||
holes[2].push_back(Point(2,5)); holes[2].push_back(Point(3,5));
|
||||
holes[2].push_back(Point(3,6)); holes[2].push_back(Point(1,6));
|
||||
|
||||
Polygon_with_holes_2 p(outer_polygon, holes.begin(), holes.end());
|
||||
|
||||
// And draw it.
|
||||
CGAL::draw(p);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
// Copyright (c) 1997
|
||||
// Utrecht University (The Netherlands),
|
||||
// ETH Zurich (Switzerland),
|
||||
// INRIA Sophia-Antipolis (France),
|
||||
// Max-Planck-Institute Saarbruecken (Germany),
|
||||
// and Tel-Aviv University (Israel). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 3 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
|
||||
#ifndef CGAL_DRAW_POLYGON_2_H
|
||||
#define CGAL_DRAW_POLYGON_2_H
|
||||
|
||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPolygon2
|
||||
|
||||
opens a new window and draws `ap`, an instance of the `CGAL::Polygon_2` class. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam P an instance of the `CGAL::Polygon_2` class.
|
||||
\param ap the polygon to draw.
|
||||
|
||||
*/
|
||||
template<class P>
|
||||
void draw(const P& ap);
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Polygon_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
// Viewer class for Polygon_2
|
||||
template<class P2>
|
||||
class SimplePolygon2ViewerQt : public Basic_viewer_qt
|
||||
{
|
||||
typedef Basic_viewer_qt Base;
|
||||
typedef typename P2::Point_2 Point;
|
||||
|
||||
public:
|
||||
/// Construct the viewer.
|
||||
/// @param ap2 the polygon to view
|
||||
/// @param title the title of the window
|
||||
SimplePolygon2ViewerQt(QWidget* parent, const P2& ap2,
|
||||
const char* title="Basic Polygon_2 Viewer") :
|
||||
// First draw: vertices; edges, faces; multi-color; no inverse normal
|
||||
Base(parent, title, true, true, true, false, false),
|
||||
p2(ap2)
|
||||
{
|
||||
compute_elements();
|
||||
}
|
||||
|
||||
protected:
|
||||
void compute_elements()
|
||||
{
|
||||
clear();
|
||||
|
||||
if (p2.is_empty()) return;
|
||||
|
||||
Point prev=p2.vertex(p2.size()-1);
|
||||
|
||||
CGAL::Color c(75,160,255);
|
||||
face_begin(c);
|
||||
|
||||
for (typename P2::Vertex_const_iterator i=p2.vertices_begin();
|
||||
i!=p2.vertices_end(); ++i)
|
||||
{
|
||||
add_point(*i); // Add vertex
|
||||
add_segment(prev, *i); // Add segment with previous point
|
||||
add_point_in_face(*i); // Add point in face
|
||||
prev=*i;
|
||||
}
|
||||
|
||||
face_end();
|
||||
}
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
// Test key pressed:
|
||||
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
// if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton)) { ... }
|
||||
|
||||
// Call: * compute_elements() if the model changed, followed by
|
||||
// * redraw() if some viewing parameters changed that implies some
|
||||
// modifications of the buffers
|
||||
// (eg. type of normal, color/mono)
|
||||
// * update() just to update the drawing
|
||||
|
||||
// Call the base method to process others/classicals key
|
||||
Base::keyPressEvent(e);
|
||||
}
|
||||
|
||||
protected:
|
||||
const P2& p2;
|
||||
};
|
||||
|
||||
// Specialization of draw function.
|
||||
template<class T, class C>
|
||||
void draw(const CGAL::Polygon_2<T, C>& ap2,
|
||||
const char* title="Polygon_2 Basic Viewer")
|
||||
{
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite=true;
|
||||
#else
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
int argc=1;
|
||||
const char* argv[2]={"t2_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
SimplePolygon2ViewerQt<CGAL::Polygon_2<T, C> >
|
||||
mainwindow(app.activeWindow(), ap2, title);
|
||||
mainwindow.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#endif // CGAL_DRAW_POLYGON_2_H
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
// Copyright (c) 1997
|
||||
// Utrecht University (The Netherlands),
|
||||
// ETH Zurich (Switzerland),
|
||||
// INRIA Sophia-Antipolis (France),
|
||||
// Max-Planck-Institute Saarbruecken (Germany),
|
||||
// and Tel-Aviv University (Israel). All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation; either version 3 of the License,
|
||||
// or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: LGPL-3.0+
|
||||
//
|
||||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
|
||||
#ifndef CGAL_DRAW_POLYGON_WITH_HOLES_2_H
|
||||
#define CGAL_DRAW_POLYGON_WITH_HOLES_2_H
|
||||
|
||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPolygonWithHoles2
|
||||
|
||||
opens a new window and draws `aph`, an instance of the `CGAL::Polygon_with_holes_2` class. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam PH an instance of the `CGAL::Polygon_with_holes_2` class.
|
||||
\param aph the polygon with holes to draw.
|
||||
|
||||
*/
|
||||
template<class PH>
|
||||
void draw(const PH& aph);
|
||||
|
||||
} /* namespace CGAL */
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Polygon_with_holes_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
// Viewer class for Polygon_2
|
||||
template<class P2>
|
||||
class SimplePolygonWithHoles2ViewerQt : public Basic_viewer_qt
|
||||
{
|
||||
typedef Basic_viewer_qt Base;
|
||||
typedef typename P2::General_polygon_2::Point_2 Point;
|
||||
|
||||
public:
|
||||
/// Construct the viewer.
|
||||
/// @param ap2 the polygon to view
|
||||
/// @param title the title of the window
|
||||
SimplePolygonWithHoles2ViewerQt(QWidget* parent, const P2& ap2,
|
||||
const char* title="Basic Polygon_with_holes_2 Viewer") :
|
||||
// First draw: vertices; edges, faces; multi-color; no inverse normal
|
||||
Base(parent, title, true, true, true, false, false),
|
||||
p2(ap2)
|
||||
{
|
||||
compute_elements();
|
||||
}
|
||||
|
||||
protected:
|
||||
void compute_one_loop_elements(const typename P2::General_polygon_2& p, bool hole)
|
||||
{
|
||||
if (hole)
|
||||
{ add_point_in_face(p.vertex(p.size()-1)); }
|
||||
|
||||
typename P2::General_polygon_2::Vertex_const_iterator prev;
|
||||
for (typename P2::General_polygon_2::Vertex_const_iterator i=p.vertices_begin();
|
||||
i!=p.vertices_end(); ++i)
|
||||
{
|
||||
add_point(*i); // Add vertex
|
||||
if (i!=p.vertices_begin())
|
||||
{ add_segment(*prev, *i); } // Add segment with previous point
|
||||
add_point_in_face(*i); // Add point in face
|
||||
prev=i;
|
||||
}
|
||||
|
||||
// Add the last segment between the last point and the first one
|
||||
add_segment(*prev, *(p.vertices_begin()));
|
||||
}
|
||||
|
||||
void compute_elements()
|
||||
{
|
||||
clear();
|
||||
|
||||
if (p2.outer_boundary().is_empty()) return;
|
||||
|
||||
CGAL::Color c(75,160,255);
|
||||
face_begin(c);
|
||||
|
||||
compute_one_loop_elements(p2.outer_boundary(), false);
|
||||
|
||||
for (typename P2::Hole_const_iterator it=p2.holes_begin(); it!=p2.holes_end(); ++it)
|
||||
{
|
||||
compute_one_loop_elements(*it, true);
|
||||
add_point_in_face(p2.outer_boundary().vertex(p2.outer_boundary().size()-1));
|
||||
}
|
||||
|
||||
face_end();
|
||||
}
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
// Test key pressed:
|
||||
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
// if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton)) { ... }
|
||||
|
||||
// Call: * compute_elements() if the model changed, followed by
|
||||
// * redraw() if some viewing parameters changed that implies some
|
||||
// modifications of the buffers
|
||||
// (eg. type of normal, color/mono)
|
||||
// * update() just to update the drawing
|
||||
|
||||
// Call the base method to process others/classicals key
|
||||
Base::keyPressEvent(e);
|
||||
}
|
||||
|
||||
protected:
|
||||
const P2& p2;
|
||||
};
|
||||
|
||||
// Specialization of draw function.
|
||||
template<class T, class C>
|
||||
void draw(const CGAL::Polygon_with_holes_2<T, C>& ap2,
|
||||
const char* title="Polygon_with_holes_2 Basic Viewer")
|
||||
{
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite=true;
|
||||
#else
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
int argc=1;
|
||||
const char* argv[2]={"t2_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
SimplePolygonWithHoles2ViewerQt<CGAL::Polygon_with_holes_2<T, C> >
|
||||
mainwindow(app.activeWindow(), ap2, title);
|
||||
mainwindow.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#endif // CGAL_DRAW_POLYGON_WITH_HOLES_2_H
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
Algebraic_foundations
|
||||
Circulator
|
||||
GraphicsView
|
||||
Installation
|
||||
Kernel_23
|
||||
Number_types
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ namespace CGAL {
|
|||
/*!
|
||||
\ingroup PkgDrawPolyhedron
|
||||
|
||||
Open a new window and draw `apoly`, an instance of the `CGAL::Polyhedron_3` class. The function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
opens a new window and draws `apoly`, an instance of the `CGAL::Polyhedron_3` class. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam POLY an instance of the `CGAL::Polyhedron_3` class.
|
||||
\param apoly the polyhedron to draw.
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
/// \defgroup PkgPolyhedronIOFunc I/O Functions
|
||||
/// \ingroup PkgPolyhedronRef
|
||||
|
||||
/*! Draw.
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_polyhedron.h>
|
||||
\endcode
|
||||
|
|
@ -73,7 +73,7 @@ surface can be used without knowing the halfedge data structure.
|
|||
- \link PkgPolyhedronIOFunc `read_off()` \endlink
|
||||
|
||||
\cgalCRPSection{Draw a Polyhedron 3}
|
||||
- `CGAL::draw<POLY>`
|
||||
- \link PkgDrawPolyhedron CGAL::draw<POLY>() \endlink
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ are also marked in the program code.
|
|||
\subsection PolyhedronDraw Draw a Polyhedron
|
||||
\anchor ssecDrawPolyhedron
|
||||
|
||||
A polyhedron can be visualized by calling the `CGAL::draw()` function as shown in the following example. This function opens a new window showing the given polyhedron. The function is blocking, that is the program continues as soon as the user closes the window.
|
||||
A polyhedron can be visualized by calling the \link PkgDrawPolyhedron CGAL::draw<POLY>() \endlink function as shown in the following example. This function opens a new window showing the given polyhedron. A call to this function is blocking, that is the program continues as soon as the user closes the window.
|
||||
|
||||
\cgalExample{Polyhedron/draw_polyhedron.cpp}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
|
|
@ -195,16 +196,23 @@ 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;
|
||||
#else
|
||||
bool cgal_test_suite=false;
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
|
|
@ -212,27 +220,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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/// \defgroup PkgSurface_mesh Surface Mesh Reference
|
||||
|
||||
/*! Draw.
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_surface_mesh.h>
|
||||
\endcode
|
||||
|
|
@ -39,7 +39,8 @@ and faces is much simpler and can be used at runtime and not at compile time.}
|
|||
- `CGAL::Surface_mesh<P>`
|
||||
|
||||
\cgalCRPSection{Draw a Surface Mesh}
|
||||
- `CGAL::draw<SM>`
|
||||
|
||||
- \link PkgDrawSurfaceMesh CGAL::draw<SM>() \endlink
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ refering to the right vertices.
|
|||
\section SurfaceMeshDraw Draw a Surface Mesh
|
||||
\anchor ssecDrawSurfaceMesh
|
||||
|
||||
A surface mesh can be visualized by calling the `CGAL::draw()` function as shown in the following example. This function opens a new window showing the given surface mesh. The function is blocking, that is the program continues as soon as the user closes the window.
|
||||
A surface mesh can be visualized by calling the \link PkgDrawSurfaceMesh CGAL::draw<SM>() \endlink as shown in the following example. This function opens a new window showing the given surface mesh. A call to this function is blocking, that is the program continues as soon as the user closes the window.
|
||||
|
||||
\cgalExample{Surface_mesh/draw_surface_mesh.cpp}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@ if ( CGAL_FOUND )
|
|||
create_single_source_cgal_program( "sm_properties.cpp" )
|
||||
|
||||
create_single_source_cgal_program("draw_surface_mesh.cpp")
|
||||
create_single_source_cgal_program("sm_draw_small_faces.cpp")
|
||||
if(CGAL_Qt5_FOUND )
|
||||
target_link_libraries(draw_surface_mesh PUBLIC CGAL::CGAL_Qt5)
|
||||
target_link_libraries(sm_draw_small_faces PUBLIC CGAL::CGAL_Qt5)
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ typedef CGAL::Surface_mesh<Point> Mesh;
|
|||
int main(int argc, char* argv[])
|
||||
{
|
||||
Mesh sm1;
|
||||
std::ifstream in1((argc>1)?argv[1]:"data/triangle.off");
|
||||
std::ifstream in1((argc>1)?argv[1]:"data/elephant.off");
|
||||
in1 >> sm1;
|
||||
|
||||
CGAL::draw(sm1);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,294 @@
|
|||
// Copyright (c) 2018 GeometryFactory (France)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
// You can redistribute it and/or modify it under the terms of the GNU
|
||||
// General Public License as published by the Free Software Foundation,
|
||||
// either version 3 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0+
|
||||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
|
||||
#ifndef CGAL_DRAW_SURFACE_MESH_SMALL_FACES_H
|
||||
#define CGAL_DRAW_SURFACE_MESH_SMALL_FACES_H
|
||||
|
||||
#include <CGAL/license/Surface_mesh.h>
|
||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
template<class SM>
|
||||
class SimpleSurfaceMeshWithSmallFacesViewerQt : public CGAL::Basic_viewer_qt
|
||||
{
|
||||
typedef CGAL::Basic_viewer_qt Base;
|
||||
typedef typename SM::Point Point;
|
||||
typedef typename CGAL::Kernel_traits<Point>::Kernel Kernel;
|
||||
typedef typename SM::Vertex_index vertex_descriptor;
|
||||
typedef typename SM::Face_index face_descriptor;
|
||||
typedef typename SM::Edge_index edge_descriptor;
|
||||
typedef typename SM::Halfedge_index halfedge_descriptor;
|
||||
typedef typename Kernel::FT FT;
|
||||
|
||||
public:
|
||||
/// Construct the viewer.
|
||||
/// @param amesh the surface mesh to view
|
||||
SimpleSurfaceMeshWithSmallFacesViewerQt(QWidget* parent,
|
||||
SM& amesh) :
|
||||
// First draw: no vertex; no edge, faces; multi-color; inverse normal
|
||||
Base(parent, "Surface mesh viewer with small faces", false, false, true, false, false),
|
||||
sm(amesh),
|
||||
m_threshold(85),
|
||||
m_draw_small_faces(true),
|
||||
m_draw_big_faces(true)
|
||||
{
|
||||
// Add custom key description (see keyPressEvent).
|
||||
setKeyDescription(Qt::Key_I, "Increment threshold for small faces");
|
||||
setKeyDescription(Qt::Key_D, "Decrement threshold for small faces");
|
||||
setKeyDescription(Qt::Key_S, "Draw small faces only , big faces only, both");
|
||||
|
||||
if (sm.faces().begin()!=sm.faces().end())
|
||||
{
|
||||
bool exist;
|
||||
typename SM::template Property_map<face_descriptor, FT> faces_size;
|
||||
boost::tie(faces_size, exist)=sm.template property_map<face_descriptor, FT>("f:size");
|
||||
CGAL_assertion(exist);
|
||||
|
||||
m_min_size=faces_size[*(sm.faces().begin())];
|
||||
m_max_size=m_min_size;
|
||||
FT cur_size;
|
||||
|
||||
for (typename SM::Face_range::iterator f=sm.faces().begin(); f!=sm.faces().end(); ++f)
|
||||
{
|
||||
cur_size=faces_size[*f];
|
||||
if (cur_size<m_min_size) m_min_size=cur_size;
|
||||
if (cur_size>m_max_size) m_max_size=cur_size;
|
||||
}
|
||||
}
|
||||
|
||||
compute_elements();
|
||||
}
|
||||
|
||||
protected:
|
||||
void compute_face(face_descriptor fh)
|
||||
{
|
||||
// [Face creation]
|
||||
bool issmall=false;
|
||||
|
||||
// Default color of faces
|
||||
CGAL::Color c(75,160,255);
|
||||
|
||||
// Compare the size of the face with the % m_threshold
|
||||
bool exist;
|
||||
typename SM::template Property_map<face_descriptor, FT> faces_size;
|
||||
boost::tie(faces_size, exist)=sm.template property_map<face_descriptor, FT>("f:size");
|
||||
CGAL_assertion(exist);
|
||||
|
||||
// It it is smaller, color the face in red.
|
||||
if (get(faces_size, fh)<m_min_size+((m_max_size-m_min_size)/(100-m_threshold)))
|
||||
{
|
||||
c=CGAL::Color(255,20,20);
|
||||
issmall=true;
|
||||
}
|
||||
|
||||
if ((issmall && !m_draw_small_faces) || (!issmall && !m_draw_big_faces))
|
||||
{ return; }
|
||||
|
||||
// Add the color of the face, then all its points.
|
||||
face_begin(c);
|
||||
halfedge_descriptor hd=sm.halfedge(fh);
|
||||
do
|
||||
{
|
||||
add_point_in_face(sm.point(sm.source(hd)), get_vertex_normal(hd));
|
||||
hd=sm.next(hd);
|
||||
}
|
||||
while(hd!=sm.halfedge(fh));
|
||||
face_end();
|
||||
/// [Face creation]
|
||||
}
|
||||
|
||||
// Copy from draw_surface_mesh.h
|
||||
void compute_edge(edge_descriptor e)
|
||||
{
|
||||
/// [Edge creation]
|
||||
add_segment(sm.point(sm.source(sm.halfedge(e))),
|
||||
sm.point(sm.target(sm.halfedge(e))));
|
||||
/// [Edge creation]
|
||||
}
|
||||
|
||||
void compute_vertex(vertex_descriptor vh)
|
||||
{
|
||||
/// [Vertex creation]
|
||||
add_point(sm.point(vh));
|
||||
/// [Vertex creation]
|
||||
}
|
||||
|
||||
void compute_elements()
|
||||
{
|
||||
clear();
|
||||
|
||||
for (typename SM::Face_range::iterator f=sm.faces().begin();
|
||||
f!=sm.faces().end(); ++f)
|
||||
{
|
||||
if (*f!=boost::graph_traits<SM>::null_face())
|
||||
{ compute_face(*f); }
|
||||
}
|
||||
|
||||
for (typename SM::Edge_range::iterator e=sm.edges().begin();
|
||||
e!=sm.edges().end(); ++e)
|
||||
{ compute_edge(*e); }
|
||||
|
||||
for (typename SM::Vertex_range::iterator v=sm.vertices().begin();
|
||||
v!=sm.vertices().end(); ++v)
|
||||
{ compute_vertex(*v); }
|
||||
}
|
||||
|
||||
// Call: * compute_elements() if the model changed, followed by
|
||||
// * redraw() if some viewing parameters changed that implies some
|
||||
// modifications of the buffers
|
||||
// (eg. type of normal, color/mono)
|
||||
// * update() just to update the drawing
|
||||
virtual void keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
/// [Keypress]
|
||||
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
if ((e->key()==Qt::Key_I) && (modifiers==Qt::NoButton))
|
||||
{
|
||||
if (m_threshold<100) { ++m_threshold; }
|
||||
displayMessage(QString("Threshold percent=%1%.").arg(m_threshold));
|
||||
compute_elements();
|
||||
redraw();
|
||||
}
|
||||
else if ((e->key()==Qt::Key_D) && (modifiers==Qt::NoButton))
|
||||
{
|
||||
if (m_threshold>0) { --m_threshold; }
|
||||
displayMessage(QString("Threshold percent=%1%.").arg(m_threshold));
|
||||
compute_elements();
|
||||
redraw();
|
||||
}
|
||||
else if ((e->key()==Qt::Key_S) && (modifiers==Qt::NoButton))
|
||||
{
|
||||
QString msg;
|
||||
if (m_draw_small_faces)
|
||||
{
|
||||
if (m_draw_big_faces)
|
||||
{
|
||||
m_draw_big_faces=false;
|
||||
msg=QString("Draw small faces only.");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_draw_big_faces=true; m_draw_small_faces=false;
|
||||
msg=QString("Draw big faces only.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(m_draw_big_faces);
|
||||
m_draw_small_faces=true;
|
||||
msg=QString("Draw small and big faces.");
|
||||
}
|
||||
|
||||
displayMessage(msg);
|
||||
compute_elements();
|
||||
redraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Call the base method to process others/classicals key
|
||||
Base::keyPressEvent(e);
|
||||
}
|
||||
/// [Keypress]
|
||||
}
|
||||
|
||||
protected:
|
||||
typename Kernel::Vector_3 get_face_normal(halfedge_descriptor he)
|
||||
{
|
||||
typename Kernel::Vector_3 normal=CGAL::NULL_VECTOR;
|
||||
halfedge_descriptor end=he;
|
||||
unsigned int nb=0;
|
||||
do
|
||||
{
|
||||
CGAL::internal::newell_single_step_3(sm.point(sm.source(he)),
|
||||
sm.point(sm.target(he)), normal);
|
||||
++nb;
|
||||
he=sm.next(he);
|
||||
}
|
||||
while (he!=end);
|
||||
assert(nb>0);
|
||||
return (typename Kernel::Construct_scaled_vector_3()(normal, 1.0/nb));
|
||||
}
|
||||
|
||||
typename Kernel::Vector_3 get_vertex_normal(halfedge_descriptor he)
|
||||
{
|
||||
typename Kernel::Vector_3 normal=CGAL::NULL_VECTOR;
|
||||
halfedge_descriptor end=he;
|
||||
do
|
||||
{
|
||||
if (!sm.is_border(he))
|
||||
{
|
||||
typename Kernel::Vector_3 n=get_face_normal(he);
|
||||
normal=typename Kernel::Construct_sum_of_vectors_3()(normal, n);
|
||||
}
|
||||
he=sm.next(sm.opposite(he));
|
||||
}
|
||||
while (he!=end);
|
||||
|
||||
if (!typename Kernel::Equal_3()(normal, CGAL::NULL_VECTOR))
|
||||
{ normal=(typename Kernel::Construct_scaled_vector_3()
|
||||
(normal, 1.0/CGAL::sqrt(normal.squared_length()))); }
|
||||
|
||||
return normal;
|
||||
}
|
||||
|
||||
protected:
|
||||
SM& sm;
|
||||
unsigned int m_threshold;
|
||||
FT m_min_size, m_max_size;
|
||||
bool m_draw_small_faces;
|
||||
bool m_draw_big_faces;
|
||||
};
|
||||
|
||||
template<class K>
|
||||
void draw_surface_mesh_with_small_faces(CGAL::Surface_mesh<K>& amesh)
|
||||
{
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite=true;
|
||||
#else
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
int argc=1;
|
||||
const char* argv[2]={"surface_mesh_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
SimpleSurfaceMeshWithSmallFacesViewerQt<CGAL::Surface_mesh<K>>
|
||||
mainwindow(app.activeWindow(), amesh);
|
||||
mainwindow.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
#else // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
template<class K>
|
||||
void draw_surface_mesh_with_small_faces(CGAL::Surface_mesh<K>&)
|
||||
{
|
||||
std::cerr<<"Impossible to draw, CGAL_USE_BASIC_VIEWER is not defined."<<std::endl;
|
||||
}
|
||||
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#endif // CGAL_DRAW_SURFACE_MESH_SMALL_FACES_H
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <boost/foreach.hpp>
|
||||
#include "draw_surface_mesh_small_faces.h"
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
|
||||
typedef Mesh::Vertex_index vertex_descriptor;
|
||||
typedef Mesh::Face_index face_descriptor;
|
||||
typedef K::FT FT;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
Mesh sm;
|
||||
std::ifstream input((argc>1)?argv[1]:"data/elephant.off");
|
||||
input>>sm;
|
||||
|
||||
CGAL::Polygon_mesh_processing::triangulate_faces(sm);
|
||||
|
||||
Mesh::Property_map<face_descriptor, FT> faces_size;
|
||||
bool created;
|
||||
boost::tie(faces_size, created)=sm.add_property_map<face_descriptor, FT>("f:size",0.);
|
||||
CGAL_assertion(created);
|
||||
|
||||
BOOST_FOREACH(face_descriptor fd, sm.faces())
|
||||
{ faces_size[fd]=CGAL::Polygon_mesh_processing::face_area(fd, sm); }
|
||||
|
||||
draw_surface_mesh_with_small_faces(sm);
|
||||
|
||||
sm.remove_property_map(faces_size);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
@ -202,16 +203,16 @@ 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;
|
||||
#else
|
||||
bool cgal_test_suite=false;
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
|
|
@ -219,31 +220,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
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ namespace CGAL {
|
|||
/*!
|
||||
\ingroup PkgDrawTriangulation2
|
||||
|
||||
Open a new window and draw `at2`, a model of the `TriangulationDataStructure_2` concept. The function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
opens a new window and draws `at2`, a model of the `TriangulationDataStructure_2` concept. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam T2 a model of the `TriangulationDataStructure_2` concept.
|
||||
\param at2 the triangulation to draw.
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
/// \defgroup PkgTriangulation2Miscellaneous Miscellaneous
|
||||
/// \ingroup PkgTriangulation2Ref
|
||||
|
||||
/*! Draw.
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_triangulation_2.h>
|
||||
\endcode
|
||||
|
|
@ -107,7 +107,7 @@ are described in Chapter \ref PkgTDS2Ref "2D Triangulation Data Structure".
|
|||
- \link CGAL::Triangulation_2::Locate_type `CGAL::Triangulation_2<Traits,Tds>::Locate_type` \endlink
|
||||
|
||||
\cgalCRPSection{Draw a Triangulation 2}
|
||||
- `CGAL::draw<T2>`
|
||||
- \link PkgDrawTriangulation2 CGAL::draw<T2>() \endlink
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -493,7 +493,7 @@ Finally points on the convex hull are written to <TT>cout</TT>.
|
|||
\subsection Triangulation2Draw Draw a 2D Triangulation
|
||||
\anchor ssecDrawT2
|
||||
|
||||
A 2D triangulation can be visualized by calling the `CGAL::draw()` function as shown in the following example. This function opens a new window showing the given 2D triangulation. The function is blocking, that is the program continues as soon as the user closes the window.
|
||||
A 2D triangulation can be visualized by calling the \link PkgDrawTriangulation2 CGAL::draw<T2>() \endlink function as shown in the following example. This function opens a new window showing the given 2D triangulation. A call to this function is blocking, that is the program continues as soon as the user closes the window.
|
||||
|
||||
\cgalExample{Triangulation_2/draw_triangulation_2.cpp}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Triangulation_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
|
|
@ -136,16 +137,18 @@ 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;
|
||||
#else
|
||||
bool cgal_test_suite=false;
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ namespace CGAL {
|
|||
/*!
|
||||
\ingroup PkgDrawTriangulation3
|
||||
|
||||
Open a new window and draw `at3`, a model of the `TriangulationDataStructure_3` concept. The function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
opens a new window and draws `at3`, a model of the `TriangulationDataStructure_3` concept. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires CGAL_Qt5, and is only available if the flag CGAL_USE_BASIC_VIEWER is defined at compile time.
|
||||
\tparam T3 a model of the `TriangulationDataStructure_3` concept.
|
||||
\param at3 the triangulation to draw.
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
/// \defgroup PkgTriangulation3VertexCellClasses Vertex and Cell Classes
|
||||
/// \ingroup PkgTriangulation3Ref
|
||||
|
||||
/*! Draw.
|
||||
/*!
|
||||
\code
|
||||
#include <CGAL/draw_triangulation_3.h>
|
||||
\endcode
|
||||
|
|
@ -118,7 +118,8 @@ is opposite to the vertex with the same index. See
|
|||
- `CGAL::Triangulation_3::Locate_type`
|
||||
|
||||
\cgalCRPSection{Draw a Triangulation 3}
|
||||
- `CGAL::draw<T3>`
|
||||
|
||||
- \link PkgDrawTriangulation3 CGAL::draw<T3>() \endlink
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ removal of the first 100,000 vertices.
|
|||
\subsection Triangulation3Draw Draw a 3D Triangulation
|
||||
\anchor ssecDrawT3
|
||||
|
||||
A 3D triangulation can be visualized by calling the `CGAL::draw()` function as shown in the following example. This function opens a new window showing the given 3D triangulation. The function is blocking, that is the program continues as soon as the user closes the window.
|
||||
A 3D triangulation can be visualized by calling the \link PkgDrawTriangulation3 CGAL::draw<T3>() \endlink function as shown in the following example. This function opens a new window showing the given 3D triangulation. A call to this function is blocking, that is the program continues as soon as the user closes the window.
|
||||
|
||||
\cgalExample{Triangulation_3/draw_triangulation_3.cpp}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Triangulation_3.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL
|
||||
|
|
@ -142,17 +143,18 @@ 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
|
||||
bool cgal_test_suite=false;
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (!cgal_test_suite)
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue