Merge remote-tracking branch 'cgal/master' into SDG-Fix_doc-GF

This commit is contained in:
Mael Rouxel-Labbé 2021-02-22 17:19:40 +01:00
commit 5efa544734
319 changed files with 40556 additions and 3970 deletions

View File

@ -50,7 +50,7 @@ jobs:
run: |
set -x
sudo apt-get update && sudo apt-get install -y graphviz ssh bibtex2html
sudo pip install lxml
sudo pip install lxml
sudo pip install 'pyquery==1.4.1' # it seems to be the last py2 compatible version
wget --no-verbose -O doxygen_exe https://cgal.geometryfactory.com/~mgimeno/doxygen/build_1_8_13/bin/doxygen
sudo mv doxygen_exe /usr/bin/doxygen
@ -92,7 +92,7 @@ jobs:
egrep -v " ${PR_NUMBER}\." index.html > tmp.html || true
echo "<li><a href=https://cgal.github.io/${PR_NUMBER}/$ROUND/Manual/index.html>Manual for PR ${PR_NUMBER} ($ROUND).</a></li>" >> ./tmp.html
mv tmp.html index.html
git add ${PR_NUMBER}/$ROUND && git commit -q --amend -m "base commit" && git push -q -f -u origin master
git add ${PR_NUMBER}/$ROUND index.html && git commit -q --amend -m "base commit" && git push -q -f -u origin master
else
exit 1
fi

View File

@ -19,18 +19,16 @@
#include <QApplication>
#include <CGAL/Qt/resources.h>
#include <QMimeData>
#include <CGAL/Qt/init_ogl_context.h>
int main(int argc, char **argv)
{
CGAL::Qt::init_ogl_context(4,3);
QApplication app(argc, argv);
app.setOrganizationDomain("inria.fr");
app.setOrganizationName("INRIA");
app.setApplicationName("AABB tree demo");
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
app.setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
// Import resources from libCGALQt (Qt5).
CGAL_QT_INIT_RESOURCES;

View File

@ -23,7 +23,7 @@ include_directories(BEFORE ./ ./include)
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
# Find Qt5 itself
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Gui Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Gui Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)
@ -54,7 +54,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND)
#${CGAL_Qt5_MOC_FILES}
)
# Link with Qt libraries
target_link_libraries(AABB_demo PRIVATE Qt5::OpenGL Qt5::Gui Qt5::Xml
target_link_libraries(AABB_demo PRIVATE Qt5::OpenGL Qt5::Gui
CGAL::CGAL CGAL::CGAL_Qt5)
add_to_cached_list(CGAL_EXECUTABLE_TARGETS AABB_demo)

View File

@ -22,8 +22,6 @@ MainWindow::MainWindow(QWidget* parent)
// saves some pointers from ui, for latter use.
m_pViewer = ui->viewer;
// does not save the state of the viewer
m_pViewer->setStateFileName(QString());
// accepts drop events
setAcceptDrops(true);
@ -45,6 +43,7 @@ MainWindow::MainWindow(QWidget* parent)
MainWindow::~MainWindow()
{
m_pViewer->makeCurrent();
delete ui;
}

View File

@ -91,8 +91,8 @@ void Scene::compile_shaders()
//Vertex source code
const char vertex_source[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"uniform highp mat4 mvp_matrix;\n"
"uniform highp mat4 f_matrix;\n"
"void main(void)\n"
@ -103,10 +103,11 @@ void Scene::compile_shaders()
//Vertex source code
const char fragment_source[] =
{
"#version 120 \n"
"#version 150 \n"
"uniform highp vec4 color; \n"
"out highp vec4 out_color; \n"
"void main(void) { \n"
"gl_FragColor = color; \n"
"out_color = color; \n"
"} \n"
"\n"
};
@ -139,26 +140,27 @@ void Scene::compile_shaders()
//Vertex source code
const char tex_vertex_source[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"attribute highp vec2 tex_coord; \n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"in highp vec2 tex_coord; \n"
"uniform highp mat4 mvp_matrix;\n"
"uniform highp mat4 f_matrix;\n"
"varying highp vec2 texc;\n"
"out highp vec2 texc;\n"
"void main(void)\n"
"{\n"
" gl_Position = mvp_matrix * f_matrix * vertex;\n"
" texc = tex_coord;\n"
" texc = tex_coord;\n"
"}"
};
//Vertex source code
const char tex_fragment_source[] =
{
"#version 120 \n"
"uniform sampler2D texture;\n"
"varying highp vec2 texc;\n"
"#version 150 \n"
"uniform sampler2D s_texture;\n"
"in highp vec2 texc;\n"
"out highp vec4 out_color; \n"
"void main(void) { \n"
"gl_FragColor = texture2D(texture, texc.st);\n"
"out_color = vec4(texture(s_texture, texc));\n"
"} \n"
"\n"
};
@ -1319,12 +1321,8 @@ void Scene::deactivate_cutting_plane()
}
void Scene::initGL()
{
gl = new QOpenGLFunctions_2_1();
if(!gl->initializeOpenGLFunctions())
{
qFatal("ERROR : OpenGL Functions not initialized. Check your OpenGL Verison (should be >=3.3)");
exit(1);
}
gl = new QOpenGLFunctions();
gl->initializeOpenGLFunctions();
gl->glGenTextures(1, &textureId);
compile_shaders();

View File

@ -86,7 +86,7 @@ public:
private:
// member data
QOpenGLFunctions_2_1 *gl;
QOpenGLFunctions *gl;
Bbox m_bbox;
Polyhedron *m_pPolyhedron;
std::list<Point> m_points;

View File

@ -26,7 +26,6 @@
#include <CGAL/internal/AABB_tree/Primitive_helper.h>
#include <boost/optional.hpp>
#include <boost/bind.hpp>
/// \file AABB_traits.h
@ -274,13 +273,13 @@ public:
switch(Traits::longest_axis(bbox))
{
case AT::CGAL_AXIS_X: // sort along x
std::nth_element(first, middle, beyond, boost::bind(Traits::less_x,_1,_2,m_traits));
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_x(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Y: // sort along y
std::nth_element(first, middle, beyond, boost::bind(Traits::less_y,_1,_2,m_traits));
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_y(p1, p2, this->m_traits); });
break;
case AT::CGAL_AXIS_Z: // sort along z
std::nth_element(first, middle, beyond, boost::bind(Traits::less_z,_1,_2,m_traits));
std::nth_element(first, middle, beyond, [this](const Primitive& p1, const Primitive& p2){ return Traits::less_z(p1, p2, this->m_traits); });
break;
default:
CGAL_error();

View File

@ -302,13 +302,13 @@ to_interval( const Real_embeddable& x) {
}
template <typename NT>
NT approximate_sqrt(const NT& nt, CGAL::Field_tag)
NT approximate_sqrt(const NT& nt, CGAL::Null_functor)
{
return NT(sqrt(CGAL::to_double(nt)));
}
template <typename NT>
NT approximate_sqrt(const NT& nt, CGAL::Field_with_sqrt_tag)
template <typename NT, typename Sqrt>
NT approximate_sqrt(const NT& nt, Sqrt sqrt)
{
return sqrt(nt);
}
@ -316,9 +316,12 @@ NT approximate_sqrt(const NT& nt, CGAL::Field_with_sqrt_tag)
template <typename NT>
NT approximate_sqrt(const NT& nt)
{
// the initial version of this function was using Algebraic_category
// for the dispatch but some ring type (like Gmpz) provides a Sqrt
// functor even if not being Field_with_sqrt.
typedef CGAL::Algebraic_structure_traits<NT> AST;
typedef typename AST::Algebraic_category Algebraic_category;
return approximate_sqrt(nt, Algebraic_category());
typedef typename AST::Sqrt Sqrt;
return approximate_sqrt(nt, Sqrt());
}
CGAL_NTS_END_NAMESPACE

View File

@ -5,18 +5,16 @@
#include <CGAL/Qt/resources.h>
#include <CGAL/Qt/init_ogl_context.h>
int main(int argc, char** argv)
{
QApplication application(argc,argv);
CGAL::Qt::init_ogl_context(4,3);
QApplication application(argc,argv);
application.setOrganizationDomain("geometryfactory.com");
application.setOrganizationName("GeometryFactory");
application.setApplicationName("Alpha Shape Reconstruction");
//for Windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
application.setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
// Import resources from libCGALQt (Qt5).
// See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE

View File

@ -18,7 +18,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -29,14 +29,14 @@ void Viewer::compile_shaders()
//Vertex source code
const char vertex_source[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"attribute highp vec3 normal;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"in highp vec3 normal;\n"
"uniform highp mat4 mvp_matrix;\n"
"uniform highp mat4 mv_matrix; \n"
"varying highp vec4 fP; \n"
"varying highp vec3 fN; \n"
"out highp vec4 fP; \n"
"out highp vec3 fN; \n"
"void main(void)\n"
"{\n"
" fP = mv_matrix * vertex; \n"
@ -47,15 +47,16 @@ void Viewer::compile_shaders()
//Fragment source code
const char fragment_source[] =
{
"#version 120 \n"
"varying highp vec4 fP; \n"
"varying highp vec3 fN; \n"
"#version 150 \n"
"in highp vec4 fP; \n"
"in highp vec3 fN; \n"
"uniform highp vec4 color; \n"
"uniform highp vec4 light_pos; \n"
"uniform highp vec4 light_diff; \n"
"uniform highp vec4 light_spec; \n"
"uniform highp vec4 light_amb; \n"
"uniform float spec_power ; \n"
"out highp vec4 out_color; \n"
"void main(void) { \n"
@ -70,7 +71,7 @@ void Viewer::compile_shaders()
" highp vec4 diffuse = abs(dot(N,L)) * light_diff * color; \n"
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
"gl_FragColor = light_amb*color + diffuse + specular ; \n"
"out_color = light_amb*color + diffuse + specular ; \n"
"} \n"
"\n"
};
@ -105,8 +106,8 @@ rendering_program.bind();
//Vertex source code
const char vertex_source_points[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"uniform highp mat4 mvp_matrix;\n"
"uniform highp float point_size;\n"
@ -119,11 +120,12 @@ const char vertex_source_points[] =
//Vertex source code
const char fragment_source_points[] =
{
"#version 120 \n"
"#version 150 \n"
"uniform highp vec4 color; \n"
"out highp vec4 out_color; \n"
"void main(void) { \n"
"gl_FragColor = color; \n"
"out_color = color; \n"
"} \n"
"\n"
};

View File

@ -21,6 +21,7 @@ public:
Viewer(QWidget* parent);
~Viewer()
{
makeCurrent();
buffers[0].destroy();
buffers[1].destroy();
buffers[2].destroy();

View File

@ -3,9 +3,6 @@
cmake_minimum_required(VERSION 3.1...3.15)
project(Arrangement_on_surface_2_Demo)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(NOT POLICY CMP0070 AND POLICY CMP0053)
# Only set CMP0053 to OLD with CMake<3.10, otherwise there is a warning.
cmake_policy(SET CMP0053 OLD)

View File

@ -159,11 +159,11 @@ namespace CGAL {
{ return CK_Equal_2()(a0, a1); }
result_type
operator() ( const Line_arc_2 &a0, const Circular_arc_2 &a1) const
operator() ( const Line_arc_2 &/*a0*/, const Circular_arc_2 &/*a1*/) const
{ return false; }
result_type
operator() ( const Circular_arc_2 &a0, const Line_arc_2 &a1) const
operator() ( const Circular_arc_2 &/*a0*/, const Line_arc_2 &/*a1*/) const
{ return false; }
result_type

View File

@ -295,13 +295,6 @@ public:
return y;
}
//! \brief the same as \c evaluate but arguments are passed by value
//! (needed to substitute variables in bivariate polynomial)
inline static NT binded_eval(Poly_1 poly, NT x)
{
return evaluate(poly, x);
}
//! \brief evalutates a polynomial at certain x-coordinate
static NT evaluate(const Poly_1& poly, const NT& x,
bool *error_bounds_ = nullptr)
@ -913,10 +906,9 @@ void get_precached_poly(int var, const NT& key, int /* level */, Poly_1& poly)
// }
if(not_cached||not_found) {
poly = Poly_1(::boost::make_transform_iterator(coeffs->begin(),
boost::bind2nd(std::ptr_fun(binded_eval), key1)),
::boost::make_transform_iterator(coeffs->end(),
boost::bind2nd(std::ptr_fun(binded_eval), key1)));
auto fn = [&key1](const Poly_1& poly){ return evaluate(poly, key1); };
poly = Poly_1(::boost::make_transform_iterator(coeffs->begin(), fn),
::boost::make_transform_iterator(coeffs->end(), fn));
if(not_cached)
return;
// all available space consumed: drop the least recently used entry

View File

@ -16,7 +16,6 @@
#include <CGAL/basic.h>
#include <CGAL/function_objects.h>
#include <boost/functional.hpp>
/*! \file CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h
* \brief
@ -107,11 +106,13 @@ struct Transform {
template <class X>
OutputPoly_2 operator()(const CGAL::Polynomial<X>& p, Op op = Op()) const {
Transform<typename OutputPoly_2::NT, typename InputPoly_2::NT, Op> tr;
typedef typename InputPoly_2::NT NT_in;
typedef typename OutputPoly_2::NT NT_out;
Transform<NT_out, NT_in, Op> tr;
auto fn = [&op, &tr](const NT_in& v){ return tr(v, op); };
return OutputPoly_2(
::boost::make_transform_iterator(p.begin(), boost::bind2nd(tr, op)),
::boost::make_transform_iterator(p.end(), boost::bind2nd(tr, op)));
::boost::make_transform_iterator(p.begin(), fn),
::boost::make_transform_iterator(p.end(), fn));
}
OutputPoly_2 operator()(

View File

@ -18,7 +18,7 @@
#include <CGAL/boost/graph/IO/Generic_facegraph_builder.h>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <boost/container/flat_map.hpp>
#include <fstream>
@ -271,7 +271,7 @@ bool read_GOCAD(const std::string& fname, Graph& g,
/// \cgalParamNBegin{stream_precision}
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
/// \cgalParamType{int}
/// \cgalParamDefault{`6`}
/// \cgalParamDefault{`the precision of the stream `os``}
/// \cgalParamNEnd
/// \cgalNamedParamsEnd
///
@ -303,8 +303,7 @@ bool write_GOCAD(std::ostream& os,
if(!os.good())
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os.precision(precision);
set_stream_precision_from_NP(os, np);
os << "GOCAD TSurf 1\n"
"HEADER {\n"
@ -380,7 +379,7 @@ bool write_GOCAD(std::ostream& os, const char* name, const Graph& g,
/// \cgalParamNBegin{stream_precision}
/// \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
/// \cgalParamType{int}
/// \cgalParamDefault{`6`}
/// \cgalParamDefault{`the precision of the stream `os``}
/// \cgalParamNEnd
/// \cgalNamedParamsEnd
///
@ -454,6 +453,7 @@ bool write_GOCAD(const std::string& fname,
{
std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII);
return write_GOCAD(os, fname.c_str(), g, np);
}

View File

@ -117,8 +117,7 @@ public:
if(!m_os.good())
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
m_os.precision(precision);
set_stream_precision_from_NP(m_os, np);
VPM vpm = choose_parameter(get_parameter(np, internal_np::vertex_point),
get_const_property_map(CGAL::vertex_point, g));

View File

@ -231,7 +231,7 @@ bool read_OBJ(const std::string& fname, Graph& g,
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd
\cgalNamedParamsEnd
@ -285,6 +285,11 @@ bool write_OBJ(std::ostream& os, const Graph& g,
\cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
must be available in `Graph`.}
\cgalParamNEnd
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamNEnd
\cgalNamedParamsEnd
\returns `true` if writing was successful, `false` otherwise.

View File

@ -284,9 +284,9 @@ bool read_OFF(const std::string& fname, Graph& g,
\deprecated This function is deprecated since \cgal 5.2, `CGAL::read_OFF()` should be used instead.
*/
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
CGAL_DEPRECATED bool read_off(std::ostream& os, Graph& g, const CGAL_BGL_NP_CLASS& np)
CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g, const CGAL_BGL_NP_CLASS& np)
{
return read_OFF(os, g, np);
return read_OFF(is, g, np);
}
/*!
@ -300,6 +300,18 @@ CGAL_DEPRECATED bool read_off(const char* fname, Graph& g, const CGAL_BGL_NP_CLA
return read_OFF(fname, g, np);
}
template <typename Graph>
CGAL_DEPRECATED bool read_off(std::istream& is, Graph& g)
{
return read_off(is, g, parameters::all_default());
}
template <typename Graph>
CGAL_DEPRECATED bool read_off(const char* fname, Graph& g)
{
return read_off(fname, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -374,7 +386,7 @@ bool write_OFF_BGL(std::ostream& os,
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd
\cgalNamedParamsEnd
@ -483,6 +495,7 @@ bool write_OFF(const std::string& fname,
std::cerr<<"Could not create file.";
return false;
}
return write_OFF(os, g, np);
}
@ -510,6 +523,11 @@ CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g, const CGAL_BGL_
return write_OFF(os, g, np);
}
template <typename Graph>
CGAL_DEPRECATED bool write_off(std::ostream& os, const Graph& g)
{
return write_off(os, g, CGAL::parameters::all_default());
}
/*!
\ingroup PkgBGLIOFctDeprecated
@ -521,6 +539,11 @@ CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g, const CGAL_BGL
return write_OFF(fname, g, np);
}
template <typename Graph>
CGAL_DEPRECATED bool write_off(const char* fname, const Graph& g)
{
return write_off(fname, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL

View File

@ -311,7 +311,7 @@ bool read_PLY(const std::string& fname, Graph& g,
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamDefault{`the precision of the stream `os``}
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
\cgalParamNEnd
\cgalNamedParamsEnd
@ -361,8 +361,7 @@ bool write_PLY(std::ostream& os,
if(!os.good())
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os.precision(precision);
set_stream_precision_from_NP(os, np);
// Write header
os << "ply" << std::endl
@ -550,6 +549,7 @@ bool write_PLY(const std::string& fname,
{
std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII);
return write_PLY(os, g, comments, np);
}
}

View File

@ -231,7 +231,7 @@ bool read_STL(const std::string& fname, Graph& g) { return read_STL(fname, g, pa
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamDefault{`the precision of the stream `os``}
\cgalParamExtra{This parameter is only meaningful while using ASCII encoding.}
\cgalParamNEnd
\cgalNamedParamsEnd
@ -262,8 +262,7 @@ bool write_STL(std::ostream& os,
if(!os.good())
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os.precision(precision);
set_stream_precision_from_NP(os, np);
if(get_mode(os) == IO::BINARY)
{
@ -372,6 +371,7 @@ bool write_STL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS
{
std::ofstream os(fname);
CGAL::set_mode(os, CGAL::IO::ASCII);
return write_STL(os, g, np);
}
}

View File

@ -420,7 +420,7 @@ void write_polys_points(std::ostream& os,
* \cgalParamNBegin{stream_precision}
* \cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
* \cgalParamType{int}
* \cgalParamDefault{`6`}
* \cgalParamDefault{`the precision of the stream `os``}
* \cgalParamNEnd
* \cgalNamedParamsEnd
*
@ -439,8 +439,7 @@ bool write_VTP(std::ostream& os,
if(!os.good())
return false;
const int precision = choose_parameter(get_parameter(np, internal_np::stream_precision), 6);
os.precision(precision);
set_stream_precision_from_NP(os, np);
os << "<?xml version=\"1.0\"?>\n"
<< "<VTKFile type=\"PolyData\" version=\"0.1\"";
@ -539,6 +538,7 @@ bool write_VTP(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS
}
else
os.open(fname);
return write_VTP(os, g, np);
}
@ -564,6 +564,12 @@ CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g, const CGAL_BGL_
return write_VTP(os, g, np);
}
template <typename Graph>
CGAL_DEPRECATED bool write_vtp(std::ostream& os, const Graph& g)
{
return write_vtp(os, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL

View File

@ -59,7 +59,7 @@ namespace CGAL {
\cgalParamNBegin{stream_precision}
\cgalParamDescription{a parameter used to set the precision (i.e. how many digits are generated) of the output stream}
\cgalParamType{int}
\cgalParamDefault{`6`}
\cgalParamDefault{`the precision of the stream `os``}
\cgalParamNEnd
\cgalNamedParamsEnd
@ -70,7 +70,8 @@ bool write_WRL(std::ostream& os,
const Graph& g,
const CGAL_BGL_NP_CLASS& np)
{
IO::internal::Generic_facegraph_printer<std::ostream, Graph, CGAL::File_writer_VRML_2> printer(os);
CGAL::VRML_2_ostream vos(os);
IO::internal::Generic_facegraph_printer<CGAL::VRML_2_ostream, Graph, CGAL::File_writer_VRML_2> printer(vos);
return printer(g, np);
}
@ -108,8 +109,8 @@ bool write_WRL(std::ostream& os,
template <typename Graph, typename CGAL_BGL_NP_TEMPLATE_PARAMETERS>
bool write_WRL(const std::string& fname, const Graph& g, const CGAL_BGL_NP_CLASS& np)
{
std::ifstream is(fname);
return write_WRL(is, g, np);
std::ofstream os(fname);
return write_WRL(os, g, np);
}
template <typename Graph>
@ -130,6 +131,12 @@ CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g, const CGAL_BGL_
return write_WRL(os, g, np);
}
template <typename Graph>
CGAL_DEPRECATED bool write_wrl(std::ostream& os, const Graph& g)
{
return write_wrl(os, g, parameters::all_default());
}
#endif // CGAL_NO_DEPRECATED_CODE
} // namespace CGAL

View File

@ -167,6 +167,8 @@ void copy_face_graph_impl(const SourceMesh& sm, TargetMesh& tm,
for(tm_vertex_descriptor v : vertices(tm))
{
tm_halfedge_descriptor h = halfedge(v, tm);
if (h==boost::graph_traits<TargetMesh>::null_halfedge())
continue;
tm_halfedge_descriptor next_around_vertex=h;
do{
next_around_vertex=opposite(next(next_around_vertex, tm), tm);

View File

@ -27,6 +27,20 @@
namespace CGAL {
namespace parameters
{
template <class Parameter, class NamedParameters>
struct Is_default
{
typedef typename internal_np::Lookup_named_param_def <
Parameter,
NamedParameters,
internal_np::Param_not_found > ::type NP_type;
static const bool value = boost::is_same<NP_type, internal_np::Param_not_found>::value;
typedef CGAL::Boolean_tag<value> type;
};
} // end of parameters namespace
// forward declarations to avoid dependency to Solver_interface
template <typename FT, unsigned int dim>
class Default_diagonalize_traits;
@ -560,6 +574,21 @@ CGAL_DEF_GET_INITIALIZED_INDEX_MAP(face, typename boost::graph_traits<Graph>::fa
Alpha_expansion_boost_adjacency_list_tag
>::type type;
};
template<typename NP>
void set_stream_precision_from_NP(std::ostream& os, const NP& np)
{
using parameters::get_parameter;
using parameters::choose_parameter;
using parameters::is_default_parameter;
if(!is_default_parameter(get_parameter(np, internal_np::stream_precision)))
{
const int precision = choose_parameter<int>(get_parameter(np,
internal_np::stream_precision));
os.precision(precision);
}
}
} //namespace CGAL

View File

@ -61,6 +61,7 @@ CGAL_add_named_parameter(geom_traits_t, geom_traits, geom_traits)
CGAL_add_named_parameter(vertex_incident_patches_t, vertex_incident_patches, vertex_incident_patches_map)
CGAL_add_named_parameter(density_control_factor_t, density_control_factor, density_control_factor)
CGAL_add_named_parameter(use_delaunay_triangulation_t, use_delaunay_triangulation, use_delaunay_triangulation)
CGAL_add_named_parameter(use_2d_constrained_delaunay_triangulation_t, use_2d_constrained_delaunay_triangulation, use_2d_constrained_delaunay_triangulation)
CGAL_add_named_parameter(fairing_continuity_t, fairing_continuity, fairing_continuity)
CGAL_add_named_parameter(sparse_linear_solver_t, sparse_linear_solver, sparse_linear_solver)
CGAL_add_named_parameter(number_of_relaxation_steps_t, number_of_relaxation_steps, number_of_relaxation_steps)
@ -117,6 +118,7 @@ CGAL_add_named_parameter(volume_threshold_t, volume_threshold, volume_threshold)
CGAL_add_named_parameter(dry_run_t, dry_run, dry_run)
CGAL_add_named_parameter(do_not_modify_t, do_not_modify, do_not_modify)
CGAL_add_named_parameter(allow_self_intersections_t, allow_self_intersections, allow_self_intersections)
CGAL_add_named_parameter(non_manifold_feature_map_t, non_manifold_feature_map, non_manifold_feature_map)
CGAL_add_named_parameter(polyhedral_envelope_epsilon_t, polyhedral_envelope_epsilon, polyhedral_envelope_epsilon)
// List of named parameters that we use in the package 'Surface Mesh Simplification'

View File

@ -98,6 +98,8 @@ create_single_source_cgal_program(
create_single_source_cgal_program( "graph_traits_inheritance.cpp" )
create_single_source_cgal_program("test_deprecated_io.cpp")
if(OpenMesh_FOUND)
target_link_libraries(test_clear PRIVATE ${OPENMESH_LIBRARIES})
target_compile_definitions(test_clear PRIVATE -DCGAL_USE_OPENMESH)
@ -129,6 +131,8 @@ if (VTK_FOUND)
if(VTK_LIBRARIES)
target_link_libraries(test_bgl_read_write PRIVATE ${VTK_LIBRARIES})
target_compile_definitions(test_bgl_read_write PRIVATE -DCGAL_USE_VTK)
target_link_libraries(test_deprecated_io PRIVATE ${VTK_LIBRARIES})
target_compile_definitions(test_deprecated_io PRIVATE -DCGAL_USE_VTK)
else()
message(STATUS "Tests that use VTK will not be compiled.")
endif()

View File

@ -35,6 +35,57 @@ test_copy_face_graph_nm_umbrella()
}
}
template <typename T>
void
test_copy_face_graph_isolated_vertices()
{
typedef Kernel::Point_3 Point_3;
{
T s, t;
add_vertex(s);
CGAL::copy_face_graph(s, t);
}
{
T s, t;
add_vertex(t);
CGAL::copy_face_graph(s, t);
}
{
T s, t;
CGAL::make_triangle(Point_3(), Point_3(), Point_3(), s);
add_vertex(s);
t=s;
CGAL::copy_face_graph(s, t);
}
{
T s, t;
CGAL::make_triangle(Point_3(), Point_3(), Point_3(), s);
add_vertex(s);
add_vertex(t);
CGAL::copy_face_graph(s, t);
}
{
T s, t;
CGAL::make_tetrahedron(Point_3(), Point_3(), Point_3(), Point_3(), s);
add_vertex(s);
t=s;
CGAL::copy_face_graph(s, t);
}
{
T s, t;
CGAL::make_tetrahedron(Point_3(), Point_3(), Point_3(), Point_3(), s);
add_vertex(s);
add_vertex(t);
CGAL::copy_face_graph(s, t);
}
}
template <typename T>
void
join_face_test()
@ -619,6 +670,7 @@ void
test_Euler_operations()
{
test_copy_face_graph_nm_umbrella<Graph>();
test_copy_face_graph_isolated_vertices<Graph>();
join_face_test<Graph>();
add_vertex_and_face_to_border_test<Graph>();
add_face_to_border_test<Graph>();

View File

@ -171,10 +171,10 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(num_vertices(fg) == 8 && num_faces(fg) == 4);
for(const auto v : vertices(fg))
for(auto v : vertices(fg))
assert(get(vcm, v) != CGAL::Color());
for(const auto f : faces(fg))
for(auto f : faces(fg))
assert(get(fcm, f) != CGAL::Color());
// write with OFF
@ -192,10 +192,10 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(are_equal_meshes(fg, fg2));
for(const auto v : vertices(fg2))
for(auto v : vertices(fg2))
assert(get(vcm2, v) != CGAL::Color());
for(const auto f : faces(fg2))
for(auto f : faces(fg2))
assert(get(fcm2, f) != CGAL::Color());
}
@ -211,7 +211,7 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(are_equal_meshes(fg, fg2));
for(const auto v : vertices(fg2))
for(auto v : vertices(fg2))
assert(get(vcm2, v) != CGAL::Color());
}
}
@ -224,7 +224,7 @@ void test_bgl_OFF(const char* filename)
ok = CGAL::read_OFF("data/mesh_with_normals.off", fg, CGAL::parameters::vertex_normal_map(vnm));
assert(ok);
for(const auto v : vertices(fg))
for(auto v : vertices(fg))
assert(get(vnm, v) != CGAL::NULL_VECTOR);
// write with OFF
@ -240,7 +240,7 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(are_equal_meshes(fg, fg2));
for(const auto v : vertices(fg2))
for(auto v : vertices(fg2))
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
}
@ -256,7 +256,7 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(are_equal_meshes(fg, fg2));
for(const auto v : vertices(fg2))
for(auto v : vertices(fg2))
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
}
}
@ -278,13 +278,13 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(num_vertices(fg) != 0 && num_faces(fg) != 0);
for(const auto v : vertices(fg))
for(auto v : vertices(fg))
{
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
assert(get(vcm2, v) != CGAL::Color());
}
for(const auto f : faces(fg))
for(auto f : faces(fg))
assert(get(fcm2, f) != CGAL::Color());
fg.clear();
is.close();
@ -301,7 +301,7 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(num_vertices(fg) != 0 && num_faces(fg) != 0);
for(const auto v : vertices(fg))
for(auto v : vertices(fg))
{
assert(get(vnm, v) != CGAL::NULL_VECTOR);
assert(get(vcm, v) != CGAL::Color());
@ -328,13 +328,13 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(are_equal_meshes(fg, fg2));
for(const auto v : vertices(fg2))
for(auto v : vertices(fg2))
{
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
assert(get(vcm2, v) != CGAL::Color());
}
for(const auto f : faces(fg2))
for(auto f : faces(fg2))
assert(get(fcm2, f) != CGAL::Color());
}
@ -359,13 +359,13 @@ void test_bgl_OFF(const char* filename)
assert(ok);
assert(are_equal_meshes(fg, fg2));
for(const auto v : vertices(fg2))
for(auto v : vertices(fg2))
{
assert(get(vnm2, v) != CGAL::NULL_VECTOR);
assert(get(vcm2, v) != CGAL::Color());
}
for(const auto f : faces(fg2))
for(auto f : faces(fg2))
assert(get(fcm2, f) != CGAL::Color());
}
}
@ -526,12 +526,12 @@ void test_bgl_PLY(const std::string filename,
assert(ok);
assert(num_vertices(fg) == 4 && num_faces(fg) == 4);
for(const auto v : vertices(fg))
for(auto v : vertices(fg))
{
assert(get(vcm, v) != CGAL::Color());
}
for(const auto f : faces(fg))
for(auto f : faces(fg))
assert(get(fcm, f) != CGAL::Color());
// write with PLY
@ -561,10 +561,10 @@ void test_bgl_PLY(const std::string filename,
assert(are_equal_meshes(fg, fg2));
// @tmp
// for(const auto v : vertices(fg2))
// for(auto v : vertices(fg2))
// assert(get(vcm2, v) != CGAL::Color());
// for(const auto f : faces(fg2))
// for(auto f : faces(fg2))
// assert(get(fcm2, f) != CGAL::Color());
}
@ -586,10 +586,10 @@ void test_bgl_PLY(const std::string filename,
assert(are_equal_meshes(fg, fg2));
// @tmp
// for(const auto v : vertices(fg2))
// for(auto v : vertices(fg2))
// assert(get(vcm2, v) != CGAL::Color());
// for(const auto f : faces(fg2))
// for(auto f : faces(fg2))
// assert(get(fcm2, f) != CGAL::Color());
}

View File

@ -63,6 +63,7 @@ void test(const NamedParameters& np)
assert(get_parameter(np, CGAL::internal_np::vertex_incident_patches).v == 11);
assert(get_parameter(np, CGAL::internal_np::density_control_factor).v == 12);
assert(get_parameter(np, CGAL::internal_np::use_delaunay_triangulation).v == 13);
assert(get_parameter(np, CGAL::internal_np::use_2d_constrained_delaunay_triangulation).v == 4573);
assert(get_parameter(np, CGAL::internal_np::fairing_continuity).v == 14);
assert(get_parameter(np, CGAL::internal_np::sparse_linear_solver).v == 15);
assert(get_parameter(np, CGAL::internal_np::number_of_relaxation_steps).v == 16);
@ -106,6 +107,8 @@ void test(const NamedParameters& np)
assert(get_parameter(np, CGAL::internal_np::allow_self_intersections).v == 66);
assert(get_parameter(np, CGAL::internal_np::polyhedral_envelope_epsilon).v == 67);
assert(get_parameter(np, CGAL::internal_np::maximum_number_of_faces).v == 78910);
assert(get_parameter(np, CGAL::internal_np::non_manifold_feature_map).v == 60);
assert(get_parameter(np, CGAL::internal_np::filter).v == 61);
// Named parameters that we use in the package 'Surface Mesh Simplification'
assert(get_parameter(np, CGAL::internal_np::get_cost_policy).v == 34);
@ -163,6 +166,7 @@ void test(const NamedParameters& np)
check_same_type<11>(get_parameter(np, CGAL::internal_np::vertex_incident_patches));
check_same_type<12>(get_parameter(np, CGAL::internal_np::density_control_factor));
check_same_type<13>(get_parameter(np, CGAL::internal_np::use_delaunay_triangulation));
check_same_type<4573>(get_parameter(np, CGAL::internal_np::use_2d_constrained_delaunay_triangulation));
check_same_type<14>(get_parameter(np, CGAL::internal_np::fairing_continuity));
check_same_type<15>(get_parameter(np, CGAL::internal_np::sparse_linear_solver));
check_same_type<16>(get_parameter(np, CGAL::internal_np::number_of_relaxation_steps));
@ -219,6 +223,8 @@ void test(const NamedParameters& np)
check_same_type<62>(get_parameter(np, CGAL::internal_np::halfedges_keeper));
check_same_type<64>(get_parameter(np, CGAL::internal_np::do_simplify_border));
check_same_type<78910>(get_parameter(np, CGAL::internal_np::maximum_number_of_faces));
check_same_type<60>(get_parameter(np, CGAL::internal_np::non_manifold_feature_map));
check_same_type<61>(get_parameter(np, CGAL::internal_np::filter));
// Named parameters that we use in the package 'Surface Mesh Simplification'
check_same_type<34>(get_parameter(np, CGAL::internal_np::get_cost_policy));
@ -310,6 +316,7 @@ int main()
.vertex_incident_patches_map(A<11>(11))
.density_control_factor(A<12>(12))
.use_delaunay_triangulation(A<13>(13))
.use_2d_constrained_delaunay_triangulation(A<4573>(4573))
.fairing_continuity(A<14>(14))
.sparse_linear_solver(A<15>(15))
.number_of_relaxation_steps(A<16>(16))
@ -344,6 +351,8 @@ int main()
.throw_on_self_intersection(A<43>(43))
.clip_volume(A<44>(44))
.use_compact_clipper(A<45>(45))
.non_manifold_feature_map(A<60>(60))
.filter(A<61>(61))
.apply_per_connected_component(A<46>(46))
.output_iterator(A<47>(47))
.erase_all_duplicates(A<48>(48))

View File

@ -0,0 +1,58 @@
#include <CGAL/internal/disable_deprecation_warnings_and_errors.h>
#include <fstream>
#include <iostream>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/generators.h>
#include <CGAL/boost/graph/IO/OFF.h>
#include <CGAL/boost/graph/IO/VTK.h>
#include <CGAL/boost/graph/IO/WRL.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> SM;
int main()
{
// OFF
SM sm_in, sm_out;
Point_3 p0(0,0,0), p1(1,0,0), p2(0,1,0);
CGAL::make_triangle(p0, p1, p2, sm_out);
bool ok = CGAL::write_off("tmp.off", sm_out);
assert(ok);
ok = CGAL::read_off("tmp.off", sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
sm_in.clear();
std::ofstream os("tmp.off");
ok = CGAL::write_off(os, sm_out);
assert(ok);
os.close();
std::ifstream is("tmp.off");
ok = CGAL::read_off(is, sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
is.close();
sm_in.clear();
#ifdef CGAL_USE_VTK
//vtk
os.open("tmp.vtp");
ok = CGAL::write_vtp(os, sm_out);
assert(ok);
os.close();
ok = CGAL::read_VTP("tmp.vtp", sm_in);
assert(ok);
assert(num_vertices(sm_in) == 3 && num_faces(sm_in) == 1);
sm_in.clear();
#endif
//wrl
os.open("tmp.wrl");
ok = CGAL::write_wrl(os, sm_out);
assert(ok);
os.close();
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,45 @@
/*! \file oriented_side.cpp
* Compute the oriented side of a point and a polygon with holes.
*/
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
# define nice(os) ((os == CGAL::ON_ORIENTED_BOUNDARY) ? "on boundary" : \
(os == CGAL::POSITIVE) ? "inside" : "outside")
int main() {
Polygon_2 hole;
hole.push_back(Point_2(1, 1));
hole.push_back(Point_2(1, 2));
hole.push_back(Point_2(2, 2));
hole.push_back(Point_2(2, 1));
Polygon_2 out;
out.push_back(Point_2(0, 0));
out.push_back(Point_2(3, 0));
out.push_back(Point_2(3, 3));
out.push_back(Point_2(0, 3));
Polygon_with_holes_2 pwh(out, &hole, &hole+1);
std::cout << pwh << std::endl;
auto os = CGAL::oriented_side(Point_2(0, 0), pwh);
std::cout << "(0,0) is : " << nice(os) << std::endl;
os = CGAL::oriented_side(Point_2(0.5, 0.5), pwh);
std::cout << "(0,0) is : " << nice(os) << std::endl;
os = CGAL::oriented_side(Point_2(1, 1), pwh);
std::cout << "(0,0) is : " << nice(os) << std::endl;
os = CGAL::oriented_side(Point_2(2.5, 2.5), pwh);
std::cout << "(0,0) is : " << nice(os) << std::endl;
os = CGAL::oriented_side(Point_2(3, 3), pwh);
std::cout << "(0,0) is : " << nice(os) << std::endl;
os = CGAL::oriented_side(Point_2(3.5, 3.5), pwh);
std::cout << "(0,0) is : " << nice(os) << std::endl;
return 0;
}

View File

@ -809,7 +809,7 @@ OutputIterator complement (const Polygon_with_holes_2<Kernel, Container>& pgn,
}
template <class Arr_traits, typename OutputIterator, class Traits>
OutputIterator complement (const General_polygon_with_holes_2<Arr_traits>& pgn,
OutputIterator complement (const General_polygon_with_holes_2<General_polygon_2<Arr_traits> >& pgn,
OutputIterator oi, Traits& tr)
{
General_polygon_set_2<Traits> gps(tr);

View File

@ -32,9 +32,10 @@
#include <CGAL/QP_solver/QP_full_exact_pricing.h>
#include <CGAL/boost/iterator/counting_iterator.hpp>
#include <CGAL/boost/iterator/transform_iterator.hpp>
#include <boost/functional.hpp>
#include <CGAL/NT_converter.h>
#include <functional>
// here is how it works. We have d+2 variables:
// R (big radius), r (small radius), c (center). The problem is
//
@ -258,9 +259,6 @@ private:
typedef QP_access_by_index
<typename std::vector<Point>::const_iterator, int> Point_by_index;
typedef boost::binder2nd< std::divides<int> >
Divide;
typedef std::vector<int> Index_vector;
typedef std::vector<NT> NT_vector;
@ -272,7 +270,7 @@ public:
typedef CGAL::Join_input_iterator_1<
Basic_variable_index_iterator,
CGAL::Unary_compose_1<Point_by_index,Divide> >
std::function<Point(int)> >
Support_point_iterator;
@ -331,9 +329,7 @@ public:
"support_points_begin: not enough points");
return Support_point_iterator(
solver->basic_original_variable_indices_begin(),
CGAL::compose1_1(
Point_by_index( points.begin()),
boost::bind2nd( std::divides<int>(), 2)));
[this](int i){ return Point_by_index(this->points.begin())(i/2); });
}
Support_point_iterator
@ -342,9 +338,7 @@ public:
"support_points_begin: not enough points");
return Support_point_iterator(
solver->basic_original_variable_indices_end(),
CGAL::compose1_1(
Point_by_index( points.begin()),
boost::bind2nd( std::divides<int>(), 2)));
[this](int i){ return Point_by_index(this->points.begin())(i/2); });
}
int number_of_inner_support_points() const { return static_cast<int>(inner_indices.size());}
@ -592,9 +586,7 @@ private:
bool
check_dimension( std::size_t offset = 0)
{ return ( std::find_if( points.begin()+offset, points.end(),
CGAL::compose1_1( boost::bind2nd(
std::not_equal_to<int>(), d),
tco.access_dimension_d_object()))
[this](const Point& p){ return this->d != this->tco.access_dimension_d_object()(p); })
== points.end()); }
// compute smallest enclosing annulus

View File

@ -290,8 +290,8 @@ bounding_box_2(ForwardIterator f, ForwardIterator l, const Traits& t)
return rect(v(rect(*xmin, *ymin), 0), v(rect(*xmax, *ymax), 2));
} // bounding_box_2(f, l, t)
template < class ForwardIterator >
inline typename
std::iterator_traits< ForwardIterator >::value_type::R::Iso_rectangle_2
inline
auto
bounding_box_2(ForwardIterator f, ForwardIterator l)
// PRE: f != l.
{

View File

@ -20,8 +20,7 @@
#include <CGAL/basic.h>
#include <CGAL/Optimisation/assertions.h>
#include <iterator>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <functional>
#ifdef CGAL_OPTIMISATION_EXPENSIVE_PRECONDITION_TAG
#include <CGAL/Polygon_2_algorithms.h>
@ -70,13 +69,16 @@ convex_bounding_box_2(
typedef typename Traits::Point_2 Point_2;
typedef typename Traits::Less_xy_2 Less_xy_2;
typedef typename Traits::Less_yx_2 Less_yx_2;
typedef boost::function2<bool,Point_2,Point_2> Greater_xy_2;
typedef boost::function2<bool,Point_2,Point_2> Greater_yx_2;
typedef std::function<bool(const Point_2&,
const Point_2&)> Greater_xy_2;
typedef Greater_xy_2 Greater_yx_2;
Less_xy_2 less_xy_2 = t.less_xy_2_object();
Less_yx_2 less_yx_2 = t.less_yx_2_object();
Greater_xy_2 greater_xy_2 = boost::bind(less_xy_2, _2, _1);
Greater_yx_2 greater_yx_2 = boost::bind(less_yx_2, _2, _1);
Greater_xy_2 greater_xy_2 = [&less_xy_2](const Point_2& p1, const Point_2& p2)
{ return less_xy_2(p2, p1); };
Greater_yx_2 greater_yx_2 = [&less_yx_2](const Point_2& p1, const Point_2& p2)
{ return less_yx_2(p2, p1); };
if (less_xy_2(*minx, *f) ||
(less_yx_2(*minx, *f) && !less_xy_2(*f, *minx)))
@ -268,21 +270,21 @@ namespace Optimisation {
// ---------------------------------------------------------------
// Right_of_implicit_line_2
// ---------------------------------------------------------------
typedef boost::function3<bool,Point_2,Point_2,Direction_2>
typedef std::function<bool(const Point_2&, const Point_2& , const Direction_2&)>
Right_of_implicit_line_2;
Right_of_implicit_line_2 right_of_implicit_line_2_object() const {
return boost::bind(has_on_negative_side_2_object(),
boost::bind(construct_line_2_object(), _2, _3),
_1);
return [this](const Point_2& p1, const Point_2& p2, const Direction_2& d)
{ return this->has_on_negative_side_2_object()(this->construct_line_2_object()(p2, d), p1); };
}
typedef boost::function2<Direction_2,Point_2,Point_2>
typedef std::function<Direction_2(const Point_2&, const Point_2&)>
Construct_direction_2;
Construct_direction_2 construct_direction_2_object() const {
return boost::bind(Base::construct_direction_2_object(),
boost::bind(construct_vector_2_object(), _1, _2));
return [this](const Point_2& p1, const Point_2& p2)
{ return this->Base::construct_direction_2_object()(
this->construct_vector_2_object()(p1, p2)); };
}
template < class Kernel >
@ -324,13 +326,11 @@ namespace Optimisation {
rotate_direction_by_multiple_of_pi_2_object() const
{ return Rotate_direction_by_multiple_of_pi_2(*this); }
typedef boost::function2<bool,Direction_2,Direction_2>
typedef std::function<bool(const Direction_2&, const Direction_2&)>
Less_angle_with_x_axis_2;
Less_angle_with_x_axis_2 less_angle_with_x_axis_2_object() const {
return boost::bind(std::equal_to<Comparison_result>(),
boost::bind(compare_angle_with_x_axis_2_object(),
_1, _2),
SMALLER);
return [this](const Direction_2& d1, const Direction_2& d2)
{ return this->compare_angle_with_x_axis_2_object()(d1, d2) == SMALLER; };
}
};

View File

@ -22,7 +22,6 @@
#include <algorithm>
#include <iterator>
#include <vector>
#include <boost/bind.hpp>
#if defined(BOOST_MSVC)
# pragma warning(push)
@ -235,14 +234,16 @@ struct Staircases : public Loc_domain< Traits_ > {
do {
brstc.push_back(*i++);
i = find_if(i, ysort.end(),
boost::bind(this->traits.less_x_2_object(), brstc.back(), _1));
[this](const Point_2& p)
{ return this->traits.less_x_2_object()(this->brstc.back(), p);});
} while (i != ysort.end());
// top-left
Riterator j = ysort.rbegin();
do {
tlstc.push_back(*j++);
j = find_if(j, ysort.rend(),
boost::bind(this->traits.less_x_2_object(), _1, tlstc.back()));
[this](const Point_2& p)
{ return this->traits.less_x_2_object()(p, this->tlstc.back());});
} while (j != ysort.rend());
// build left-bottom and right-top staircases
@ -252,14 +253,16 @@ struct Staircases : public Loc_domain< Traits_ > {
do {
lbstc.push_back(*i++);
i = find_if(i, xsort.end(),
boost::bind(this->traits.less_y_2_object(), _1, lbstc.back()));
[this](const Point_2& p)
{ return this->traits.less_y_2_object()(p, this->lbstc.back());});
} while (i != xsort.end());
// right-top
j = xsort.rbegin();
do {
rtstc.push_back(*j++);
j = find_if(j, xsort.rend(),
boost::bind(this->traits.less_y_2_object(), rtstc.back(), _1));
[this](const Point_2& p)
{ return this->traits.less_y_2_object()(this->rtstc.back(), p);});
} while (j != xsort.rend());
} // Staircases(b, e, t)
@ -300,16 +303,20 @@ struct Staircases : public Loc_domain< Traits_ > {
min_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_x_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), p, _1),
boost::bind(this->traits.less_y_2_object(), p, _1)));
[&p, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(p, pt) &&
this->traits.less_y_2_object()(p, pt);
});
Citerator j =
max_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_x_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), _1, q),
boost::bind(this->traits.less_y_2_object(), q, _1)));
[&q, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(pt, q) &&
this->traits.less_y_2_object()(q, pt);
});
return Intervall(i == this->pts.end() ? this->maxx : *i,
j == this->pts.end() ? this->minx : *j);
} // top_intervall()
@ -326,16 +333,20 @@ struct Staircases : public Loc_domain< Traits_ > {
min_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_x_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), p, _1),
boost::bind(this->traits.less_y_2_object(), _1, p)));
[&p, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(p, pt) &&
this->traits.less_y_2_object()(pt, p);
});
Citerator j =
max_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_x_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), _1, q),
boost::bind(this->traits.less_y_2_object(), _1, q)));
[&q, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(pt, q) &&
this->traits.less_y_2_object()(pt, q);
});
return Intervall(i == this->pts.end() ? this->maxx : *i,
j == this->pts.end() ? this->minx : *j);
} // bottom_intervall()
@ -352,16 +363,20 @@ struct Staircases : public Loc_domain< Traits_ > {
min_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_y_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), _1, p),
boost::bind(this->traits.less_y_2_object(), p, _1)));
[&p, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(pt, p) &&
this->traits.less_y_2_object()(p, pt);
});
Citerator j =
max_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_y_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), _1, q),
boost::bind(this->traits.less_y_2_object(), _1, q)));
[&q, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(pt, q) &&
this->traits.less_y_2_object()(pt, q);
});
return Intervall(i == this->pts.end() ? this->maxy : *i,
j == this->pts.end() ? this->miny : *j);
} // left_intervall()
@ -378,16 +393,20 @@ struct Staircases : public Loc_domain< Traits_ > {
min_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_y_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), p, _1),
boost::bind(this->traits.less_y_2_object(), p, _1)));
[&p, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(p, pt) &&
this->traits.less_y_2_object()(p, pt);
});
Citerator j =
max_element_if(
this->pts.begin(), this->pts.end(),
this->traits.less_y_2_object(),
boost::bind(std::logical_and< bool >(),
boost::bind(this->traits.less_x_2_object(), q, _1),
boost::bind(this->traits.less_y_2_object(), _1, q)));
[&q, this](const Point_2& pt)
{
return this->traits.less_x_2_object()(q, pt) &&
this->traits.less_y_2_object()(pt, q);
});
return Intervall(i == this->pts.end() ? this->maxy : *i,
j == this->pts.end() ? this->miny : *j);
} // right_intervall()
@ -487,6 +506,7 @@ two_cover_points(
using std::less;
typedef typename Traits::FT FT;
typedef typename Traits::Point_2 Point_2;
typename Traits::Infinity_distance_2 dist =
d.traits.infinity_distance_2_object();
typename Traits::Signed_infinity_distance_2 sdist =
@ -504,11 +524,8 @@ two_cover_points(
if (d.end() ==
find_if(d.begin(),
d.end(),
boost::bind(less<FT>(),
d.r,
boost::bind(Min<FT>(),
boost::bind(dist, d[0], _1),
boost::bind(dist, d[2], _1)))))
[&dist,&d](const Point_2& p)
{ return d.r < Min<FT>()(dist(d[0], p), dist(d[2],p)); }))
{
*o++ = d[0];
*o++ = d[2];
@ -520,11 +537,8 @@ two_cover_points(
if (d.end() ==
find_if(d.begin(),
d.end(),
boost::bind(less<FT>(),
d.r,
boost::bind(Min<FT>(),
boost::bind(dist, d[1], _1),
boost::bind(dist, d[3], _1)))))
[&dist,&d](const Point_2& p)
{ return d.r < Min<FT>()(dist(d[1], p), dist(d[3],p)); }))
{
*o++ = d[1];
*o++ = d[3];
@ -551,7 +565,6 @@ three_cover_points(
CGAL_optimisation_precondition(!d.empty());
// typedefs:
typedef typename Traits::FT FT;
typedef typename Traits::Point_2 Point_2;
typedef typename Loc_domain< Traits >::Iterator Iterator;
typename Traits::Infinity_distance_2 dist =
@ -565,7 +578,8 @@ three_cover_points(
// find first point not covered by the rectangle at d[k]
Iterator i = find_if(d.begin(), d.end(),
boost::bind(less<FT>(), d.r, boost::bind(dist, corner, _1)));
[&d,&dist, &corner](const Point_2& p)
{ return d.r < dist(corner, p); });
// are all points already covered?
if (i == d.end()) {
@ -608,12 +622,12 @@ three_cover_points(
CGAL_optimisation_expensive_assertion(
save_end == find_if(d.end(), save_end,
boost::bind(less<FT>(), d.r, boost::bind(dist, corner, _1))));
[&d, &dist, &corner](const Point_2& p)
{ return d.r < dist(corner, p); }));
CGAL_optimisation_expensive_assertion(
d.end() == find_if(d.begin(), d.end(),
boost::bind(std::greater_equal<FT>(),
d.r,
boost::bind(dist, corner, _1))));
[&d,&dist, &corner](const Point_2& p)
{ return d.r >= dist(corner, p); }));
two_cover_points(d, o, ok);
@ -702,7 +716,8 @@ four_cover_points(Staircases< Traits >& d, OutputIterator o, bool& ok)
// find first point not covered by the rectangle at d[k]
Iterator i = find_if(d.begin(), d.end(),
boost::bind(less<FT>(), d.r, boost::bind(dist, corner, _1)));
[&d,&dist,&corner](const Point_2& p)
{ return d.r < dist(corner, p); });
// are all points already covered?
if (i == d.end()) {
@ -745,12 +760,12 @@ four_cover_points(Staircases< Traits >& d, OutputIterator o, bool& ok)
CGAL_optimisation_expensive_assertion(
save_end == find_if(d.end(), save_end,
boost::bind(less<FT>(), d.r, boost::bind(dist, corner, _1))));
[&d,&dist,&corner](const Point_2& p)
{ return d.r < dist(corner, p); }));
CGAL_optimisation_expensive_assertion(
d.end() == find_if(d.begin(), d.end(),
boost::bind(std::greater_equal<FT>(),
d.r,
boost::bind(dist, corner, _1))));
[&d,&dist,&corner](const Point_2& p)
{ return d.r >= dist(corner, p); }));
three_cover_points(d, o, ok);

View File

@ -22,8 +22,6 @@
#include <CGAL/Rectangular_p_center_traits_2.h>
#include <algorithm>
#include <vector>
#include <boost/bind.hpp>
#include <boost/function.hpp>
namespace CGAL {
@ -38,8 +36,6 @@ rectangular_2_center_2(
Traits& t)
{
using std::pair;
using std::greater;
using std::less;
typedef typename Traits::Iso_rectangle_2 Rectangle;
typedef typename Traits::Point_2 Point;
@ -53,7 +49,6 @@ rectangular_2_center_2(
P_below_right;
typedef typename Traits::Construct_point_2_below_left_implicit_point_2
P_below_left;
typedef boost::function1<FT, Point> Gamma;
// fetch function objects from traits class
CVertex v = t.construct_vertex_2_object();
@ -72,15 +67,15 @@ rectangular_2_center_2(
// two cases: top-left & bottom-right or top-right & bottom-left
Min< FT > minft;
Gamma gamma1 =
boost::bind(minft, boost::bind(dist, v(bb, 0), _1), boost::bind(dist, v(bb, 2), _1));
Gamma gamma2 =
boost::bind(minft, boost::bind(dist, v(bb, 1), _1), boost::bind(dist, v(bb, 3), _1));
auto gamma1 =
[&minft, &bb, &dist, &v](const Point& p){ return minft(dist( v(bb, 0), p), dist(v(bb, 2),p));};
auto gamma2 =
[&minft, &bb, &dist, &v](const Point& p){ return minft(dist( v(bb, 1), p), dist(v(bb, 3),p));};
pair< ForwardIterator, ForwardIterator > cand =
min_max_element(f, l,
boost::bind(greater<FT>(), boost::bind(gamma1, _1), boost::bind(gamma1, _2)),
boost::bind(less<FT>(), boost::bind(gamma2, _1), boost::bind(gamma2, _2)));
[&gamma1](const Point& p1, const Point& p2){ return std::greater<FT>()(gamma1(p1), gamma1(p2)); },
[&gamma2](const Point& p1, const Point& p2){ return std::less<FT>()(gamma2(p1), gamma2(p2)); });
// return the result
if (gamma1(*cand.first) < gamma2(*cand.second)) {
@ -106,9 +101,6 @@ rectangular_3_center_2_type1(
typename Traits::FT& rad,
Traits& t)
{
using std::max;
using std::less;
typedef typename Traits::FT FT;
typedef typename Traits::Iso_rectangle_2 Rectangle;
typedef typename Traits::Point_2 Point;
@ -124,7 +116,6 @@ rectangular_3_center_2_type1(
P_below_right;
typedef typename Traits::Construct_point_2_below_left_implicit_point_2
P_below_left;
typedef boost::function1<FT, Point> Gamma;
// fetch function objects from traits class
Rect rect = t.construct_iso_rectangle_2_object();
@ -158,14 +149,14 @@ rectangular_3_center_2_type1(
RandomAccessIterator e = l;
bool b_empty = true;
Min< FT > minft;
Gamma gamma = boost::bind(minft,
boost::bind(dist, v(r, i), _1),
boost::bind(dist, v(r, 2 + i), _1));
auto gamma = [&minft, &dist, &v, &r, i](const Point& p)
{ return minft(dist(v(r, i), p), dist(v(r, 2 + i), p)); };
while (e - s > 1) {
// step (a)
RandomAccessIterator m = s + (e - s - 1) / 2;
std::nth_element(s, m, e, boost::bind(less<FT>(), boost::bind(gamma, _1), boost::bind(gamma, _2)));
std::nth_element(s, m, e, [&gamma](const Point& p1, const Point& p2)
{return gamma(p1) < gamma(p2);});
// step (b)
Rectangle b_prime = bounding_box_2(m + 1, e, t);
@ -220,8 +211,9 @@ struct Rectangular_3_center_2_type2_operations_base {
typedef typename R::Infinity_distance_2 Infinity_distance_2;
typedef typename R::Less_x_2 Less_x_2;
typedef typename R::Less_y_2 Less_y_2;
typedef boost::function2<bool,Point_2,Point_2> Greater_x_2;
typedef boost::function2<bool,Point_2,Point_2> Greater_y_2;
typedef std::function<bool(const Point_2& ,
const Point_2&)> Greater_x_2;
typedef Greater_x_2 Greater_y_2;
typedef Min< Point_2, Less_x_2 > Min_x_2;
typedef Max< Point_2, Less_x_2 > Max_x_2;
typedef Min< Point_2, Less_y_2 > Min_y_2;
@ -236,15 +228,15 @@ struct Rectangular_3_center_2_type2_operations_base {
Construct_point_2_below_right_implicit_point_2;
typedef typename R::Construct_point_2_below_left_implicit_point_2
Construct_point_2_below_left_implicit_point_2;
typedef boost::function1<FT,Point_2> Delta;
typedef std::function<FT(const Point_2&)> Delta;
Delta delta() const { return delta_; }
Less_x_2 less_x_2_object() const { return r_.less_x_2_object(); }
Less_y_2 less_y_2_object() const { return r_.less_y_2_object(); }
Greater_x_2 greater_x_2_object() const
{ return boost::bind(less_x_2_object(),_2,_1); }
{ return [this](const Point_2& p1, const Point_2& p2){ return this->less_x_2_object()(p2, p1); }; }
Greater_y_2 greater_y_2_object() const
{ return boost::bind(less_y_2_object(),_2,_1); }
{ return [this](const Point_2& p1, const Point_2& p2){ return this->less_y_2_object()(p2, p1); }; }
Infinity_distance_2 distance() const
{ return r_.infinity_distance_2_object(); }
Construct_vertex_2 construct_vertex_2_object() const
@ -277,7 +269,7 @@ struct Rectangular_3_center_2_type2_operations_base {
public:
Rectangular_3_center_2_type2_operations_base(R& r, const Point_2& p)
: r_(r), delta_(boost::bind(r.infinity_distance_2_object(), p, _1))
: r_(r), delta_([&r, &p](const Point_2& q){ return r.infinity_distance_2_object()(p, q); })
{}
};
@ -846,10 +838,6 @@ rectangular_3_center_2_type2(
Operations op)
{
BOOST_USING_STD_MAX();
using std::less;
using std::greater;
using std::greater_equal;
using std::not_equal_to;
using std::logical_and;
using std::max_element;
using std::find_if;
@ -894,7 +882,7 @@ rectangular_3_center_2_type2(
{
// First try whether the best radius so far can be reached at all
RandomAccessIterator m =
partition(f, l, boost::bind(greater< FT >(), rad, boost::bind(op.delta(), _1)));
partition(f, l, [&rad, &op](const Point& p){ return rad > op.delta()(p); });
IP pos = min_max_element(m, l, op.compare_x(), op.compare_y());
// extreme points of the two other squares
Point q_t =
@ -905,11 +893,11 @@ rectangular_3_center_2_type2(
op.place_y_square(op.place_y_square(Q_r_empty, Q_r, *pos.second, r),
r,
rad);
boost::function1<bool,FT> le_rad = boost::bind(greater_equal<FT>(), rad, _1);
auto le_rad = [&rad](const FT& v){return rad >= v;};
RandomAccessIterator b1 =
partition(m, l, boost::bind(le_rad, boost::bind(op.distance(), q_t, _1)));
partition(m, l, [&le_rad, &op, q_t](const Point& p){ return le_rad(op.distance()(q_t, p)); });
RandomAccessIterator b2 =
partition(b1, l, boost::bind(le_rad, boost::bind(op.distance(), q_r, _1)));
partition(b1, l, [&le_rad, &op, q_r](const Point& p){ return le_rad(op.distance()(q_r, p)); });
if (b2 != l)
return o;
@ -921,8 +909,7 @@ rectangular_3_center_2_type2(
while (e - s > 6) {
std::ptrdiff_t cutoff = (e - s) / 2;
RandomAccessIterator m = s + cutoff - 1;
std::nth_element(s, m, e,
boost::bind(less<FT>(), boost::bind(op.delta(), _1), boost::bind(op.delta(), _2)));
std::nth_element(s, m, e, [&op](const Point& p1, const Point& p2){ return op.delta()(p1) < op.delta()(p2); });
// step (b)
IP pos = min_max_element(m + 1, e, op.compare_x(), op.compare_y());
@ -935,13 +922,11 @@ rectangular_3_center_2_type2(
Point q_r = op.place_y_square(q_r_afap, r, op.delta()(*m));
// check for covering
boost::function1<bool,FT>
le_delta_m = boost::bind(greater_equal<FT>(), op.delta()(*m), _1);
auto le_delta_m = [&op, m](const FT& v){ return op.delta()(*m) >= v; };
RandomAccessIterator b1 =
partition(m + 1, e,
boost::bind(le_delta_m, boost::bind(op.distance(), q_t, _1)));
partition(m + 1, e, [&le_delta_m, &op, & q_t](const Point& p){ return le_delta_m(op.distance()(q_t, p)); });
RandomAccessIterator b2 =
partition(b1, e, boost::bind(le_delta_m, boost::bind(op.distance(), q_r, _1)));
partition(b1, e, [&le_delta_m, &op, & q_r](const Point& p){ return le_delta_m(op.distance()(q_r, p)); });
if (b2 != e)
s = m;
@ -960,7 +945,7 @@ rectangular_3_center_2_type2(
std::ptrdiff_t cutoff = (e - s) / fraction;
RandomAccessIterator m = s + cutoff - 1;
std::nth_element(s, m, e,
boost::bind(less<FT>(), boost::bind(op.delta(), _1), boost::bind(op.delta(), _2)));
[&op](const Point& p1, const Point& p2){ return op.delta()(p1) < op.delta()(p2); });
// step (b)
IP pos = min_max_element(m + 1, e, op.compare_x(), op.compare_y());
@ -1007,16 +992,16 @@ rectangular_3_center_2_type2(
// partition the range [m+1, e) into ranges
// [m+1, b1), [b1, b2), [b2, b3) and [b3, e)
// R G cap q_t G cap q_r none
boost::function1<bool,FT>
le_delta_m = boost::bind(greater_equal<FT>(), op.delta()(*m), _1);
auto le_delta_m = [&op, m](const FT& v){ return op.delta()(*m) >= v; };
RandomAccessIterator b2 =
partition(m + 1, e, boost::bind(le_delta_m, boost::bind(op.distance(), q_t, _1)));
partition(m + 1, e,
[&le_delta_m, &op, &q_t](const Point& p) { return le_delta_m(op.distance()(q_t, p)); });
RandomAccessIterator b1 =
partition(m + 1, b2,
boost::bind(le_delta_m, boost::bind(op.distance(), q_r, _1)));
[&le_delta_m, &op, &q_r](const Point& p) { return le_delta_m(op.distance()(q_r, p)); });
RandomAccessIterator b3 =
partition(b2, e, boost::bind(le_delta_m, boost::bind(op.distance(), q_r, _1)));
partition(b2, e,
[&le_delta_m, &op, &q_r](const Point& p) { return le_delta_m(op.distance()(q_r, p)); });
// step (c)
if (b3 != e ||
@ -1100,9 +1085,8 @@ rectangular_3_center_2_type2(
// step 1
RandomAccessIterator s_m = s_b + (s_e - s_b - 1) / 2;
std::nth_element(s_b, s_m, s_e,
boost::bind(less<FT>(),
boost::bind(op.delta(), _1),
boost::bind(op.delta(), _2)));
[&op](const Point& p1, const Point& p2)
{ return op.delta()(p1) < op.delta()(p2); });
// step 2 (as above)
Point q_t_m = q_t_afap;
@ -1138,14 +1122,17 @@ CGAL_3CENTER_REPEAT_CHECK:
// partition the range [s_b+1, e) into ranges
// [s_b+1, b1), [b1, b2), [b2, b3) and [b3, e)
// R G cap q_t G cap q_r none
boost::function1<bool,FT>
le_delta_sb = boost::bind(greater_equal<FT>(), op.delta()(*s_b), _1);
b2 = partition(s_b + 1, e, boost::bind(le_delta_sb,
boost::bind(op.distance(), q_t, _1)));
b1 = partition(s_b + 1, b2, boost::bind(le_delta_sb,
boost::bind(op.distance(), q_r, _1)));
auto le_delta_sb = [&op, s_b](const FT& v){ return op.delta()(*s_b) >= v;} ;
b2 = partition(s_b + 1, e,
[&le_delta_sb, &op, &q_t](const Point& p)
{ return le_delta_sb(op.distance()(q_t, p)); });
b1 = partition(s_b + 1, b2,
[&le_delta_sb, &op, &q_r](const Point& p)
{ return le_delta_sb(op.distance()(q_r, p)); });
b3 = partition(b2, e,
boost::bind(le_delta_sb, boost::bind(op.distance(), q_r, _1)));
[&le_delta_sb, &op, &q_r](const Point& p)
{ return le_delta_sb(op.distance()(q_r, p)); });
if (b3 != e ||
(!Q_t_empty && op.compute_x_distance(q_t, Q_t) > op.delta()(*s_b)) ||
@ -1183,7 +1170,7 @@ CGAL_3CENTER_REPEAT_CHECK:
std::vector< Point > tmppts(f, l);
RandomAccessIterator ii =
partition(tmppts.begin(), tmppts.end(),
boost::bind(le_delta_sb, boost::bind(op.delta(), _1)));
[&le_delta_sb, &op](const FT& v){ return le_delta_sb(op.delta()(v)); });
IP tmppos = min_max_element(ii, tmppts.end(),
op.compare_x(), op.compare_y());
)
@ -1228,12 +1215,8 @@ CGAL_3CENTER_REPEAT_CHECK:
// we have to take the next smaller radius
RandomAccessIterator next =
max_element_if(s, s_b,
boost::bind(less<FT>(),
boost::bind(op.delta(), _1),
boost::bind(op.delta(), _2)),
boost::bind(not_equal_to<FT>(),
op.delta()(*s_b),
boost::bind(op.delta(), _1)));
[&op](const Point& p1, const Point& p2){ return op.delta()(p1) < op.delta()(p2); },
[&op, s_b](const Point& p){ return op.delta()(*s_b) != op.delta()(p); });
rho_max = op.delta()(*s_b);
q_t_at_rho_max = q_t, q_r_at_rho_max = q_r;
CGAL_optimisation_assertion(op.delta()(*next) < op.delta()(*s_b));
@ -1243,14 +1226,13 @@ CGAL_3CENTER_REPEAT_CHECK:
q_r = op.place_y_square(q_r_afap, r, op.delta()(*next));
// again check for covering
boost::function1<bool,FT>
le_delta_next = boost::bind(greater_equal<FT>(), op.delta()(*next), _1);
auto le_delta_next = [&op, next](const FT& v){ return op.delta()(*next) >= v; };
b2 = partition(s_b, e,
boost::bind(le_delta_next, boost::bind(op.distance(), q_t, _1)));
[&op, &le_delta_next, &q_t](const Point& p){ return le_delta_next( op.distance()(q_t,p) ); });
b1 = partition(s_b, b2,
boost::bind(le_delta_next, boost::bind(op.distance(), q_r, _1)));
[&op, &le_delta_next, &q_r](const Point& p){ return le_delta_next( op.distance()(q_r,p) ); });
b3 = partition(b2, e,
boost::bind(le_delta_next, boost::bind(op.distance(), q_r, _1)));
[&op, &le_delta_next, &q_r](const Point& p){ return le_delta_next( op.distance()(q_r,p) ); });
if (b3 != e ||
(!Q_t_empty && op.compute_x_distance(q_t, Q_t) > op.delta()(*next)) ||
@ -1304,7 +1286,7 @@ CGAL_3CENTER_REPEAT_CHECK:
Point q_t_afap = op.place_x_square(Q_t_empty, Q_t, r);
Point q_r_afap = op.place_y_square(Q_r_empty, Q_r, r);
if (s != e) {
sort(s, e, boost::bind(less<FT>(), boost::bind(op.delta(), _1), boost::bind(op.delta(), _2)));
sort(s, e, [&op](const Point& p1, const Point& p2){ return op.delta()(p1) < op.delta()(p2);});
rho_max = op.delta()(*--t);
} else
rho_max = rho_min;
@ -1347,16 +1329,15 @@ CGAL_3CENTER_REPEAT_CHECK:
q_r = op.place_y_square(q_r_afap, r, try_rho);
// check for covering
boost::function1<bool,FT>
greater_rho_max = boost::bind(less<FT>(), try_rho, _1);
auto greater_rho_max = [&try_rho](const FT& v){ return try_rho < v; };
if ((!Q_t_empty && op.compute_x_distance(q_t, Q_t) > try_rho) ||
(!Q_r_empty && op.compute_y_distance(q_r, Q_r) > try_rho) ||
e != find_if(
t + 1,
e,
boost::bind(logical_and<bool>(),
boost::bind(greater_rho_max, boost::bind(op.distance(), q_t, _1)),
boost::bind(greater_rho_max, boost::bind(op.distance(), q_r, _1)))))
[&greater_rho_max, &q_t, &q_r, &op](const Point& p)
{ return greater_rho_max(op.distance()(q_t,p)) &&
greater_rho_max(op.distance()(q_r,p)); }))
{
rho_min = try_rho;
q_t_q_r_cover_at_rho_min = 0;
@ -1393,17 +1374,15 @@ CGAL_3CENTER_REPEAT_CHECK:
CGAL_optimisation_assertion(rho_min >= 0);
FT rad_2 = q_t_q_r_cover_at_rho_min;
if (s_at_rho_min != e_at_rho_min) {
boost::function1<FT,Point>
mydist = boost::bind(Min<FT>(),
boost::bind(op.distance(), q_t_at_rho_min, _1),
boost::bind(op.distance(), q_r_at_rho_min, _1));
auto mydist = [&q_t_at_rho_min, &q_r_at_rho_min, &op](const Point& p)
{ return Min<FT>()( op.distance()(q_t_at_rho_min, p),
op.distance()(q_r_at_rho_min, p)); };
rad_2 =
max BOOST_PREVENT_MACRO_SUBSTITUTION (
rad_2,
mydist(*max_element(s_at_rho_min, e_at_rho_min,
boost::bind(less< FT >(),
boost::bind(mydist, _1),
boost::bind(mydist, _2)))));
[&mydist](const Point& p1, const Point& p2)
{ return mydist(p1) < mydist(p2); })));
}
CGAL_optimisation_assertion(rad_2 == 0 || rad_2 > rho_min);

View File

@ -316,7 +316,6 @@ rectangular_p_center_2_matrix_search(
const Traits& t)
{
typedef typename Traits::FT FT;
using std::minus;
return rectangular_p_center_2_matrix_search(
f,
@ -325,7 +324,9 @@ rectangular_p_center_2_matrix_search(
r,
pf,
t,
boost::bind(Max<FT>(), 0, boost::bind(minus<FT>(), _1, _2)));
std::function<FT(const FT&, const FT&)>(
[](const FT& a, const FT& b) { return Max<FT>()(0, std::minus<FT>()(a,b)); }
));
} // Pcenter_matrix_search( ... )

View File

@ -32,15 +32,11 @@ if(NOT TARGET CGAL::Eigen3_support)
return()
endif()
find_package(IPE 6)
find_package(IPE 7)
if(IPE_FOUND)
if (${IPE_VERSION} EQUAL "7")
set(WITH_IPE_7 ON)
elseif(${IPE_VERSION} EQUAL "6")
set(WITH_IPE_7 OFF)
else()
message("-- Error: ${IPE_VERSION} is not a supported version of IPE (only 6 and 7 are).")
if ( NOT ${IPE_VERSION} EQUAL "7")
message("-- Error: ${IPE_VERSION} is not a supported version of IPE (only 7 is).")
set(IPE_FOUND FALSE)
endif()
endif()
@ -52,7 +48,6 @@ if(IPE_FOUND AND IPE_VERSION)
#setting installation directory
get_filename_component(IPE_LIBRARY_DIR ${IPE_LIBRARIES} PATH)
if (IPE_FOUND AND NOT IPELET_INSTALL_DIR)
if (WITH_IPE_7)
remove_leading_zero(IPE_MINOR_VERSION_1)
remove_leading_zero(IPE_MINOR_VERSION_2)
set(INSTALL_PATHS "${IPE_LIBRARY_DIR}/ipe/7.${IPE_MINOR_VERSION_1}.${IPE_MINOR_VERSION_2}/ipelets/")
@ -62,24 +57,6 @@ if(IPE_FOUND AND IPE_VERSION)
DOC "The folder where ipelets will be installed"
ENV IPELETPATH
)
else()
foreach (VER RANGE 28 40)
string(REPLACE XX ${VER} PATHC "${IPE_LIBRARY_DIR}/ipe/6.0preXX/ipelets/" )
set(INSTALL_PATHS ${INSTALL_PATHS} ${PATHC})
endforeach()
set(INSTALL_PATHS ${INSTALL_PATHS} ${PATHC})
set(INSTALL_PATHS ${INSTALL_PATHS} /usr/lib64/ipe/6.0/ipelets)
set(INSTALL_PATHS ${INSTALL_PATHS} /usr/lib/ipe/6.0/ipelets)
find_library(
IPELET_INSTALL_DIR_FILES
NAMES align
PATHS ${INSTALL_PATHS} ENV IPELETPATH)
if(IPELET_INSTALL_DIR_FILES)
get_filename_component(IPELET_INSTALL_DIR ${IPELET_INSTALL_DIR_FILES}
PATH)
endif()
endif()
endif()
set(CGAL_IPELETS ${CGAL_IPELETS})
@ -116,18 +93,13 @@ if(IPE_FOUND AND IPE_VERSION)
foreach(IPELET ${CGAL_IPELETS})
add_library(CGAL_${IPELET} MODULE ${IPELET}.cpp)
target_include_directories(CGAL_${IPELET} BEFORE PRIVATE ${IPE_INCLUDE_DIR})
if (WITH_IPE_7)
target_compile_definitions(CGAL_${IPELET} PRIVATE CGAL_USE_IPE_7)
endif()
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_${IPELET})
target_link_libraries(CGAL_${IPELET} PRIVATE CGAL::CGAL CGAL::Eigen3_support
${IPE_LIBRARIES})
if(IPELET_INSTALL_DIR)
install(TARGETS CGAL_${IPELET} DESTINATION ${IPELET_INSTALL_DIR})
if (WITH_IPE_7)
install(FILES ./lua/libCGAL_${IPELET}.lua DESTINATION ${IPELET_INSTALL_DIR}) #only for ipe 7
endif()
install(FILES ./lua/libCGAL_${IPELET}.lua DESTINATION ${IPELET_INSTALL_DIR}) #only for ipe 7
endif ()
cgal_add_compilation_test(CGAL_${IPELET})
endforeach(IPELET)
@ -140,6 +112,10 @@ if(IPE_FOUND AND IPE_VERSION)
add_to_cached_list(CGAL_EXECUTABLE_TARGETS simple_triangulation)
target_link_libraries(simple_triangulation CGAL::Eigen3_support
${IPE_LIBRARIES})
target_include_directories(simple_triangulation BEFORE PRIVATE ${IPE_INCLUDE_DIR})
if (WITH_IPE_7)
target_compile_definitions(simple_triangulation PRIVATE CGAL_USE_IPE_7)
endif()
cgal_add_compilation_test(simple_triangulation)
else()

View File

@ -110,11 +110,7 @@ void generator::protected_run(int fn)
else
segments.reserve(nbelements);
#ifdef CGAL_USE_IPE_7
get_IpePage()->deselectAll();
#else
get_IpePage()->DeselectAll();
#endif
switch(fn){
case 0:{//random point in a circle

View File

@ -126,7 +126,6 @@ void enveloppeIpelet::protected_run(int fn)
Vsite0.insert(Vsite0.end(),*(Vsite0.begin()+1));
std::vector<ASite>::iterator Vsiteite0 = Vsite0.begin();
std::vector<ASite>::iterator Vsiteite00 = Vsite0.end()-2;
#ifdef CGAL_USE_IPE_7
for(std::vector<ASite>::iterator it=Vsiteite00 ; it!=Vsiteite0 ; --it){//draw precise convex hull computing tangency point to circles
double c_rad = it->weight();
if(c_rad!=0){
@ -155,36 +154,6 @@ void enveloppeIpelet::protected_run(int fn)
ipe::Shape shape;
shape.appendSubPath(SSPseg_ipe);
get_IpePage()->append(ipe::EPrimarySelected,CURRENTLAYER,new ipe::Path(CURRENTATTRIBUTES,shape));
#else
for(std::vector<ASite>::iterator it=Vsiteite00 ; it!=Vsiteite0 ; --it){//draw precise convex hull computing tangency point to circles
double c_rad = it->weight();
if(c_rad!=0){
Point_2 p_pt = (it-1)->point(); //previous neighbor
Point_2 c_pt = it->point();
Point_2 n_pt = (it+1)->point(); //next neighbor
double p_rad = (it-1)->weight();
double n_rad = (it+1)->weight();
IpeVector pt_ipe=tangency_point(c_rad,p_rad,c_pt,p_pt);
IpeVector pt_ipe0=tangency_point(c_rad,n_rad,c_pt,n_pt,-1);
if(it!=Vsiteite00)
SSPseg_ipe->AppendSegment(pt_ipe1,pt_ipe0);
SSPseg_ipe->AppendArc(IpeMatrix(c_rad,0,0,c_rad,c_pt.x(),c_pt.y()),pt_ipe0,pt_ipe);
pt_ipe1=pt_ipe;
}
else{
Point_2 c_pt = it->point();
IpeVector pt_ipe=IpeVector(c_pt.x(),c_pt.y());
if(it!=Vsiteite00)
SSPseg_ipe->AppendSegment(pt_ipe1,pt_ipe);
pt_ipe1=pt_ipe;
}
}
SSPseg_ipe->SetClosed(true);
IpePath* obj_ipe1 = new IpePath(get_IpeletHelper()->Attributes());
obj_ipe1 -> AddSubPath(SSPseg_ipe);
get_IpePage()->push_back(IpePgObject(IpePgObject::ESecondary,get_IpeletHelper()->CurrentLayer(),obj_ipe1));
#endif
}
break;

View File

@ -13,8 +13,4 @@
#include <CGAL/config.h>
#ifdef CGAL_USE_IPE_7
#include <CGAL/CGAL_Ipelet_base_v7.h>
#else
#include <CGAL/CGAL_Ipelet_base_v6.h>
#endif

View File

@ -246,8 +246,8 @@ bisector_of_linesC2(const FT &pa, const FT &pb, const FT &pc,
FT &a, FT &b, FT &c)
{
// We normalize the equations of the 2 lines, and we then add them.
FT n1 = CGAL_NTS sqrt(CGAL_NTS square(pa) + CGAL_NTS square(pb));
FT n2 = CGAL_NTS sqrt(CGAL_NTS square(qa) + CGAL_NTS square(qb));
FT n1 = CGAL_NTS approximate_sqrt( FT(CGAL_NTS square(pa) + CGAL_NTS square(pb)) );
FT n2 = CGAL_NTS approximate_sqrt( FT(CGAL_NTS square(qa) + CGAL_NTS square(qb)) );
a = n2 * pa + n1 * qa;
b = n2 * pb + n1 * qb;
c = n2 * pc + n1 * qc;

View File

@ -366,10 +366,10 @@ bisector_of_planesC3(const FT &pa, const FT &pb, const FT &pc, const FT &pd,
FT &a, FT &b, FT &c, FT &d)
{
// We normalize the equations of the 2 planes, and we then add them.
FT n1 = CGAL_NTS sqrt(CGAL_NTS square(pa) + CGAL_NTS square(pb) +
CGAL_NTS square(pc));
FT n2 = CGAL_NTS sqrt(CGAL_NTS square(qa) + CGAL_NTS square(qb) +
CGAL_NTS square(qc));
FT n1 = CGAL_NTS approximate_sqrt( FT(CGAL_NTS square(pa) + CGAL_NTS square(pb) +
CGAL_NTS square(pc)) );
FT n2 = CGAL_NTS approximate_sqrt( FT(CGAL_NTS square(qa) + CGAL_NTS square(qb) +
CGAL_NTS square(qc)) );
a = n2 * pa + n1 * qa;
b = n2 * pb + n1 * qb;
c = n2 * pc + n1 * qc;

View File

@ -12,7 +12,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL)
find_package(Qt5 QUIET COMPONENTS Script OpenGL)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -1,17 +1,12 @@
#include "Viewer.h"
#include <qapplication.h>
#include <CGAL/Qt/init_ogl_context.h>
int main(int argc, char** argv)
{
// Read command lines arguments.
CGAL::Qt::init_ogl_context(4,3);
QApplication application(argc,argv);
// Instantiate the viewer.
Viewer viewer;
//for Windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
application.setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
viewer.setWindowTitle("Intersection points of randomly generated circles.");
// Make the viewer window visible on screen.

View File

@ -11,6 +11,14 @@ Viewer::Viewer(QWidget* parent )
{
extension_is_found = false;
}
Viewer::~Viewer()
{
makeCurrent();
for(int i=0; i<3; ++i)
vao[i].destroy();
for(int i=0; i<9; ++i)
buffers[i].destroy();
}
void Viewer::compile_shaders()
{
@ -32,16 +40,16 @@ void Viewer::compile_shaders()
//Vertex source code
const char vertex_source[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"attribute highp vec3 normal;\n"
"attribute highp vec4 center;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"in highp vec3 normal;\n"
"in highp vec4 center;\n"
"uniform highp mat4 mvp_matrix;\n"
"uniform highp mat4 mv_matrix; \n"
"varying highp vec4 fP; \n"
"varying highp vec3 fN; \n"
"out highp vec4 fP; \n"
"out highp vec3 fN; \n"
"void main(void)\n"
"{\n"
" fP = mv_matrix * vertex; \n"
@ -52,15 +60,16 @@ void Viewer::compile_shaders()
//Vertex source code
const char fragment_source[] =
{
"#version 120 \n"
"varying highp vec4 fP; \n"
"varying highp vec3 fN; \n"
"#version 150 \n"
"in highp vec4 fP; \n"
"in highp vec3 fN; \n"
"uniform highp vec4 color; \n"
"uniform highp vec4 light_pos; \n"
"uniform highp vec4 light_diff; \n"
"uniform highp vec4 light_spec; \n"
"uniform highp vec4 light_amb; \n"
"uniform float spec_power ; \n"
"out highp vec4 out_color; \n"
"void main(void) { \n"
@ -75,7 +84,7 @@ void Viewer::compile_shaders()
" highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n"
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
"gl_FragColor = light_amb*color + diffuse ; \n"
"out_color = light_amb*color + diffuse ; \n"
"} \n"
"\n"
};
@ -111,8 +120,8 @@ void Viewer::compile_shaders()
//Vertex source code
const char vertex_source_no_ext[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"uniform highp mat4 mvp_matrix;\n"
"void main(void)\n"
"{\n"
@ -123,10 +132,11 @@ void Viewer::compile_shaders()
//Vertex source code
const char fragment_source_no_ext[] =
{
"#version 120 \n"
"#version 150 \n"
"uniform highp vec4 color; \n"
"out highp vec4 out_color; \n"
"void main(void) { \n"
"gl_FragColor = color; \n"
"out_color = color; \n"
"} \n"
"\n"
};
@ -669,8 +679,6 @@ void Viewer::compute_elements()
{
pos_points.resize(0);
pos_lines.resize(0);
// Restore previous viewer state.
restoreStateFromFile();
//random generator of points within a sphere
typedef CGAL::Creator_uniform_3<EPIC::FT,EPIC::Point_3> Creator;

View File

@ -13,6 +13,7 @@ class Viewer : public CGAL::QGLViewer
{
public:
Viewer(QWidget* parent = 0);
~Viewer();
GLuint dl_nb;
protected :
virtual void draw();

View File

@ -290,14 +290,10 @@ public:
The output file is written in a binary format that is readable by
the `load_configuration()` method.
*/
#if defined(DOXYGEN_RUNNING) || \
(defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \
defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION))
void save_configuration (std::ostream& output) const
{
m_rfc->write(output);
}
#endif
/*!
\brief loads a configuration from the stream `input`.
@ -314,9 +310,6 @@ public:
format for ETHZ Random Forest changed in CGAL 5.2.
*/
#if defined(DOXYGEN_RUNNING) || \
(defined(CGAL_LINKED_WITH_BOOST_IOSTREAMS) && \
defined(CGAL_LINKED_WITH_BOOST_SERIALIZATION))
void load_configuration (std::istream& input)
{
CGAL::internal::liblearning::RandomForest::ForestParams params;
@ -324,7 +317,6 @@ public:
m_rfc->read(input);
}
#endif
/// @}

View File

@ -123,7 +123,7 @@ public:
CGAL_precondition (m_labels.is_valid_ground_truth (ground_truth));
CGAL_precondition (m_labels.is_valid_ground_truth (result));
for (const auto& p : CGAL::make_range
for (const auto p : CGAL::make_range
(boost::make_zip_iterator(boost::make_tuple(ground_truth.begin(), result.begin())),
boost::make_zip_iterator(boost::make_tuple(ground_truth.end(), result.end()))))
{

View File

@ -2,7 +2,6 @@
#include <CGAL/ch_graham_andrew.h>
#include <vector>
#include <algorithm>
#include <boost/bind.hpp>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
@ -23,7 +22,8 @@ ch_graham_anderson( InputIterator first, InputIterator beyond,
std::vector< Point_2 > V (first, beyond);
typename std::vector< Point_2 >::iterator it =
std::min_element(V.begin(), V.end(), Less_xy_2());
std::sort( V.begin(), V.end(), boost::bind(Less_rotate_ccw_2(), *it, _1, _2) );
const Point_2 p = *it;
std::sort( V.begin(), V.end(), [&p](const Point_2& p1, const Point_2& p2){return Less_rotate_ccw_2()(p, p1, p2);} );
if ( *(V.begin()) != *(V.rbegin()) )
{
result = CGAL::ch_graham_andrew_scan( V.begin(), V.end(), result, ch_traits);

View File

@ -25,7 +25,6 @@
#include <CGAL/ch_graham_andrew.h>
#include <CGAL/algorithm.h>
#include <CGAL/IO/Tee_for_output_iterator.h>
#include <boost/bind.hpp>
#include <CGAL/tuple.h>
#include <CGAL/utility.h>
#include <iterator>
@ -296,9 +295,11 @@ ch_akl_toussaint(ForwardIterator first, ForwardIterator last,
std::sort( std::next(region2.begin() ), region2.end(),
ch_traits.less_xy_2_object() );
std::sort( std::next(region3.begin() ), region3.end(),
boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
[&ch_traits](const Point_2& p1, const Point_2& p2)
{ return ch_traits.less_xy_2_object()(p2, p1); });
std::sort( std::next(region4.begin() ), region4.end(),
boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
[&ch_traits](const Point_2& p1, const Point_2& p2)
{ return ch_traits.less_xy_2_object()(p2, p1); });
if (! equal_points(*w,*s) )
{

View File

@ -26,7 +26,6 @@
#include <CGAL/algorithm.h>
#include <list>
#include <algorithm>
#include <boost/bind.hpp>
namespace CGAL {
template <class InputIterator, class OutputIterator, class Traits>
@ -43,7 +42,6 @@ ch_bykat(InputIterator first, InputIterator last,
typedef typename Traits::Equal_2 Equal_2;
Left_turn_2 left_turn = ch_traits.left_turn_2_object();
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
Equal_2 equal_points = ch_traits.equal_2_object();
if (first == last) return result;
@ -77,18 +75,23 @@ ch_bykat(InputIterator first, InputIterator last,
H.push_back( a );
L.push_back( P.begin() );
R.push_back( l = std::partition(P.begin(), P.end(),
boost::bind(left_turn, boost::cref(a), boost::cref(b), _1)));
r = std::partition( l, P.end(), boost::bind(left_turn, boost::cref(b), boost::cref(a), _1));
[&left_turn, &a, &b](const Point_2& p){ return left_turn(a,b,p); }) );
r = std::partition( l, P.end(), [&left_turn, &a, &b](const Point_2& p){ return left_turn(b,a,p); });
for (;;)
{
// This functor must be in the for loop so that the Convex_hull_constructive traits_2 works correctly
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
if ( l != r)
{
Point_2 c = *std::min_element( l, r, boost::bind(less_dist, boost::cref(a), boost::cref(b), _1, _2));
Point_2 c = *std::min_element( l, r, [&less_dist,&a,&b](const Point_2&p1, const Point_2& p2)
{ return less_dist(a, b, p1, p2); });
H.push_back( b );
L.push_back( l );
R.push_back( l = std::partition(l, r, boost::bind(left_turn, boost::cref(b), boost::cref(c), _1)));
r = std::partition(l, r, boost::bind(left_turn, boost::cref(c), boost::cref(a), _1));
R.push_back( l = std::partition(l, r, [&left_turn,&c,&b](const Point_2&p)
{ return left_turn(b, c, p); }));
r = std::partition(l, r, [&left_turn,&c,&a](const Point_2&p)
{ return left_turn(c, a, p); });
b = c;
}
else
@ -173,8 +176,10 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last,
H.push_back( a );
L.push_back( Pbegin );
Left_turn_2 left_turn = ch_traits.left_turn_2_object();
R.push_back( l = std::partition( Pbegin, Pend, boost::bind(left_turn, boost::cref(a), boost::cref(b), _1)));
r = std::partition( l, Pend, boost::bind(left_turn, boost::cref(b), boost::cref(a), _1));
R.push_back( l = std::partition( Pbegin, Pend, [&left_turn,&a,&b](const Point_2&p)
{ return left_turn(a, b, p); }));
r = std::partition( l, Pend, [&left_turn,&a,&b](const Point_2&p)
{ return left_turn(b, a, p); });
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
for (;;)
@ -183,11 +188,14 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last,
{
if ( r-l > CGAL_ch_THRESHOLD )
{
Point_2 c = *std::min_element( l, r, boost::bind(less_dist, boost::cref(a), boost::cref(b), _1, _2));
Point_2 c = *std::min_element( l, r, [&less_dist,&a,&b](const Point_2&p1, const Point_2& p2)
{ return less_dist(a, b, p1, p2); });
H.push_back( b );
L.push_back( l );
R.push_back( l = std::partition(l, r, boost::bind(left_turn, boost::cref(b), boost::cref(c), _1)));
r = std::partition(l, r, boost::bind(left_turn, boost::cref(c), boost::cref(a), _1));
R.push_back( l = std::partition(l, r, [&left_turn,&c,&b](const Point_2&p)
{ return left_turn(b, c, p); }));
r = std::partition(l, r, [&left_turn,&a,&c](const Point_2&p)
{ return left_turn(c, a, p); });
b = c;
}
else
@ -201,8 +209,8 @@ ch_bykat_with_threshold(InputIterator first, InputIterator last,
}
else
{
std::sort(std::next(l), r,
boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
std::sort(std::next(l), r, [&ch_traits](const Point_2&p1, const Point_2& p2)
{ return ch_traits.less_xy_2_object()(p2, p1); });
}
ch__ref_graham_andrew_scan(l, std::next(r), res, ch_traits);
std::swap( a, *l);

View File

@ -25,7 +25,6 @@
#include <CGAL/algorithm.h>
#include <list>
#include <algorithm>
#include <boost/bind.hpp>
namespace CGAL {
@ -45,7 +44,8 @@ ch__recursive_eddy(List& L,
CGAL_ch_precondition( \
std::find_if(a_it, b_it, \
boost::bind(left_turn, *b_it, *a_it, _1)) \
[&left_turn, a_it, b_it](const Point_2& p)
{ return left_turn(*b_it, *a_it, p); }) \
!= b_it );
@ -53,11 +53,14 @@ ch__recursive_eddy(List& L,
Less_dist less_dist = ch_traits.less_signed_distance_to_line_2_object();
ListIterator
c_it = std::min_element( f_it, b_it, // max before
boost::bind(less_dist, *a_it, *b_it, _1, _2));
[&less_dist, a_it, b_it](const Point_2& p1, const Point_2& p2)
{ return less_dist(*a_it, *b_it, p1, p2); });
Point_2 c = *c_it;
c_it = std::partition(f_it, b_it, boost::bind(left_turn, c, *a_it, _1));
f_it = std::partition(c_it, b_it, boost::bind(left_turn, *b_it, c, _1));
c_it = std::partition(f_it, b_it, [&left_turn, &c, a_it](const Point_2& p)
{return left_turn(c, *a_it, p);});
f_it = std::partition(c_it, b_it, [&left_turn, &c, b_it](const Point_2& p)
{return left_turn(*b_it, c, p);});
c_it = L.insert(c_it, c);
L.erase( f_it, b_it );
@ -104,7 +107,8 @@ ch_eddy(InputIterator first, InputIterator last,
L.erase(e);
e = std::partition(L.begin(), L.end(),
boost::bind(left_turn, ep, wp, _1) );
[&left_turn, &wp, &ep](const Point_2& p)
{return left_turn(ep, wp, p);} );
L.push_front(wp);
e = L.insert(e, ep);
@ -112,7 +116,8 @@ ch_eddy(InputIterator first, InputIterator last,
{
ch__recursive_eddy( L, L.begin(), e, ch_traits);
}
w = std::find_if( e, L.end(), boost::bind(left_turn, wp, ep, _1) );
w = std::find_if( e, L.end(), [&left_turn, &wp, &ep](const Point_2& p)
{ return left_turn(wp, ep, p); });
if ( w == L.end() )
{
L.erase( ++e, L.end() );

View File

@ -24,7 +24,6 @@
#include <CGAL/Convex_hull_2/ch_assertions.h>
#include <CGAL/ch_selected_extreme_points_2.h>
#include <algorithm>
#include <boost/bind.hpp>
namespace CGAL {
@ -65,7 +64,8 @@ ch_jarvis_march(ForwardIterator first, ForwardIterator last,
Point previous_point = start_p; )
ForwardIterator it = std::min_element( first, last,
boost::bind(rotation_predicate, boost::cref(start_p), _1, _2) );
[&start_p, &rotation_predicate](const Point& p1, const Point& p2)
{return rotation_predicate(start_p, p1, p2);} );
while (! equal_points(*it, stop_p) )
{
CGAL_ch_exactness_assertion( \
@ -80,7 +80,8 @@ ch_jarvis_march(ForwardIterator first, ForwardIterator last,
constructed_points <= count_points + 1 );
it = std::min_element( first, last,
boost::bind(rotation_predicate, *it, _1, _2) );
[it, &rotation_predicate](const Point& p1, const Point& p2)
{return rotation_predicate(*it, p1, p2);} );
}
CGAL_ch_postcondition( \
is_ccw_strongly_convex_2( res.output_so_far_begin(), \

View File

@ -43,7 +43,6 @@
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/is_iterator.h>
#include <boost/bind.hpp>
#include <boost/next_prior.hpp>
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/type_traits/is_same.hpp>
@ -576,7 +575,8 @@ farthest_outside_point(Face_handle f, std::list<Point>& outside_set,
Outside_set_iterator farthest_it =
std::max_element(outside_set.begin(),
outside_set.end(),
boost::bind(less_dist_to_plane, plane, _1, _2));
[&less_dist_to_plane,&plane](const Point& p1, const Point& p2)
{ return less_dist_to_plane(plane, p1, p2); });
return farthest_it;
}
@ -795,8 +795,10 @@ ch_quickhull_face_graph(std::list<typename Traits::Point_3>& points,
// plane.
std::pair<P3_iterator, P3_iterator> min_max;
min_max = CGAL::min_max_element(points.begin(), points.end(),
boost::bind(compare_dist, plane, _1, _2),
boost::bind(compare_dist, plane, _1, _2));
[&compare_dist, &plane](const Point_3& p1, const Point_3& p2)
{ return compare_dist(plane, p1, p2); },
[&compare_dist, &plane](const Point_3& p1, const Point_3& p2)
{ return compare_dist(plane, p1, p2); });
P3_iterator max_it;
if (coplanar(*point1_it, *point2_it, *point3_it, *min_max.second))
{
@ -929,8 +931,10 @@ convex_hull_3(InputIterator first, InputIterator beyond,
Less_dist less_dist = traits.less_distance_to_point_3_object();
P3_iterator_pair endpoints =
min_max_element(points.begin(), points.end(),
boost::bind(less_dist, *points.begin(), _1, _2),
boost::bind(less_dist, *points.begin(), _1, _2));
[&points, &less_dist](const Point_3& p1, const Point_3& p2)
{ return less_dist(*points.begin(), p1, p2); },
[&points, &less_dist](const Point_3& p1, const Point_3& p2)
{ return less_dist(*points.begin(), p1, p2); });
typename Traits::Construct_segment_3 construct_segment =
traits.construct_segment_3_object();
@ -1032,8 +1036,10 @@ void convex_hull_3(InputIterator first, InputIterator beyond,
Less_dist less_dist = traits.less_distance_to_point_3_object();
P3_iterator_pair endpoints =
min_max_element(points.begin(), points.end(),
boost::bind(less_dist, *points.begin(), _1, _2),
boost::bind(less_dist, *points.begin(), _1, _2));
[&points, &less_dist](const Point_3& p1, const Point_3& p2)
{ return less_dist(*points.begin(), p1, p2); },
[&points, &less_dist](const Point_3& p1, const Point_3& p2)
{ return less_dist(*points.begin(), p1, p2); });
Convex_hull_3::internal::add_isolated_points(*endpoints.first, polyhedron);
Convex_hull_3::internal::add_isolated_points(*endpoints.second, polyhedron);
return;

View File

@ -30,11 +30,16 @@ This section describes a minimal example of a program that uses \cgal and Qt5 fo
\subsection subcmake CMakeLists.txt
\dontinclude Surface_mesh/CMakeLists.txt
\skip cmake
\until if ( CGAL_FOUND )
\skip cmake_minimum_required
\until project
\skip #CGAL_Qt5 is needed for the drawing.
\until endif()
\skip #create the executable of the application
\until "draw_surface_mesh.cpp"
\skip if(CGAL_Qt5_FOUND )
\skip if(CGAL_Qt5_FOUND)
\until target_link_libraries(draw_surface_mesh PUBLIC CGAL::CGAL_Qt5)
\skip endif
\until #end of the file

View File

@ -154,6 +154,10 @@ executables should be linked with the CMake imported target
The \sc{libpointmatcher} web site is <A
HREF="https://github.com/ethz-asl/libpointmatcher">`https://github.com/ethz-asl/libpointmatcher`</A>.
\attention On Windows, we only support version 1.3.1 of PointMatcher with version 3.3.7 of Eigen, with some changes to the recipe at
`https://github.com/ethz-asl/libpointmatcher/blob/master/doc/CompilationWindows.md`:`NABO_INCLUDE_DIR` becomes `libnabo_INCLUDE_DIRS`
and `NABO_LIBRARY` becomes `libnabo_LIBRARIES` in the "Build libpointmatcher" section.
\subsection thirdpartyLeda LEDA
<b>Version 6.2 or later</b>

View File

@ -0,0 +1,146 @@
// Copyright (c) 2011 GeometryFactory Sarl (France)
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Andreas Fabri
#ifndef CGAL_INTERNAL_STATIC_FILTERS_COMPARE_DISTANCE_3_H
#define CGAL_INTERNAL_STATIC_FILTERS_COMPARE_DISTANCE_3_H
#include <CGAL/Profile_counter.h>
#include <CGAL/internal/Static_filters/tools.h>
#include <cmath>
#include <iostream>
namespace CGAL {
namespace internal {
namespace Static_filters_predicates {
template < typename K_base >
class Compare_distance_3
: public K_base::Compare_distance_3
{
typedef typename K_base::Point_3 Point_3;
typedef typename K_base::Vector_3 Vector_3;
typedef typename K_base::Compare_distance_3 Base;
public:
typedef typename Base::result_type result_type;
using Base::operator();
result_type operator()(const Point_3 &p, const Point_3& q, const Point_3& r) const
{
CGAL_BRANCH_PROFILER(std::string("semi-static attempts/calls to : ") +
std::string(CGAL_PRETTY_FUNCTION), tmp);
Get_approx<Point_3> get_approx; // Identity functor for all points
// but lazy points
if(q == r){
return EQUAL;
}
double px, py, pz, qx, qy, qz, rx, ry, rz;
if (fit_in_double(get_approx(p).x(), px) && fit_in_double(get_approx(p).y(), py) &&
fit_in_double(get_approx(p).z(), pz) &&
fit_in_double(get_approx(q).x(), qx) && fit_in_double(get_approx(q).y(), qy) &&
fit_in_double(get_approx(q).z(), qz) &&
fit_in_double(get_approx(r).x(), rx) && fit_in_double(get_approx(r).y(), ry) &&
fit_in_double(get_approx(r).z(), rz))
{
CGAL_BRANCH_PROFILER_BRANCH(tmp);
double qpx;
qpx = (qx - px);
double qpy;
qpy = (qy - py);
double qpz;
qpz = (qz - pz);
double qp2;
qp2 = ((square( qpx ) + square( qpy )) + square( qpz ));
double rpx;
rpx = (rx - px);
double rpy;
rpy = (ry - py);
double rpz;
rpz = (rz - pz);
double rp2;
rp2 = ((square( rpx ) + square( rpy )) + square( rpz ));
Sign int_tmp_result = EQUAL;
double double_tmp_result;
double eps;
double_tmp_result = (qp2 - rp2);
double max1 = CGAL::abs(qpx);
if( (max1 < CGAL::abs(qpy)) )
{
max1 = CGAL::abs(qpy);
}
if( (max1 < CGAL::abs(qpz)) )
{
max1 = CGAL::abs(qpz);
}
if( (max1 < CGAL::abs(rpx)) )
{
max1 = CGAL::abs(rpx);
}
if( (max1 < CGAL::abs(rpy)) )
{
max1 = CGAL::abs(rpy);
}
if( (max1 < CGAL::abs(rpz)) )
{
max1 = CGAL::abs(rpz);
}
if( (max1 < 2.42701102401884262260e-147) )
{
return Base::operator()(p, q, r);
}
else
{
if( (max1 > 8.37987995621411946582e+152) )
{
return Base::operator()(p, q, r);
}
eps = (3.77746921267322435884e-15 * (max1 * max1));
if( (double_tmp_result > eps) )
{
int_tmp_result = LARGER;
}
else
{
if( (double_tmp_result < -eps) )
{
int_tmp_result = SMALLER;
}
else
{
return Base::operator()(p, q, r);
}
}
}
return int_tmp_result;
}
return Base::operator()(p, q, r);
}
}; // end class Compare_distance_3
} // end namespace Static_filters_predicates
} // end namespace internal
} // end namespace CGAL
#endif // CGAL_INTERNAL_STATIC_FILTERS_COMPARE_DISTANCE_3_H

View File

@ -71,7 +71,7 @@
#include <CGAL/internal/Static_filters/Compare_squared_radius_3.h>
#include <CGAL/internal/Static_filters/Compare_weighted_squared_radius_3.h>
#include <CGAL/internal/Static_filters/Power_side_of_oriented_power_sphere_3.h>
#include <CGAL/internal/Static_filters/Compare_distance_3.h>
// #include <CGAL/internal/Static_filters/Coplanar_orientation_3.h>
// #include <CGAL/internal/Static_filters/Coplanar_side_of_bounded_circle_3.h>
@ -126,6 +126,8 @@ public:
typedef Static_filters_predicates::Compare_weighted_squared_radius_3<K_base> Compare_weighted_squared_radius_3;
typedef Static_filters_predicates::Power_side_of_oriented_power_sphere_3<K_base> Power_side_of_oriented_power_sphere_3;
typedef Static_filters_predicates::Compare_distance_3<K_base> Compare_distance_3;
Orientation_2
orientation_2_object() const
{ return Orientation_2(); }
@ -195,6 +197,9 @@ public:
compare_weighted_squared_radius_3_object() const
{ return Compare_weighted_squared_radius_3(); }
Compare_distance_3
compare_distance_3_object() const
{ return Compare_distance_3();}
enum { Has_static_filters = true };

View File

@ -23,7 +23,6 @@
#include <algorithm>
#include <numeric>
#include <CGAL/Random_convex_set_traits_2.h>
#include <boost/functional.hpp>
namespace CGAL {
@ -80,7 +79,7 @@ random_convex_set_2( std::size_t n,
points.begin(),
points.end(),
points.begin(),
boost::bind2nd( Sum(), scale( centroid, FT( -1))));
[&centroid, &sum, &scale](const Point_2& p) { return sum(p, scale(centroid, FT( -1))); });
// sort them according to their direction's angle
// w.r.t. the positive x-axis:
@ -102,8 +101,9 @@ random_convex_set_2( std::size_t n,
points.begin(),
points.end(),
points.begin(),
boost::bind2nd( Sum(), sum( centroid,
scale( new_centroid, FT( -1)))));
[&centroid, &new_centroid, &sum, &scale](const Point_2& p)
{return sum(p, sum( centroid, scale(new_centroid, FT( -1)))); }
);
// compute maximal coordinate:
FT maxcoord( max_coordinate(
@ -118,7 +118,7 @@ random_convex_set_2( std::size_t n,
points.begin(),
points.end(),
o,
boost::bind2nd( Scale(), FT( pg.range()) / maxcoord));
[&pg, &maxcoord, &scale](const Point_2& p){ return scale(p, FT( pg.range()) / maxcoord); });
} // random_convex_set_2( n, o, pg, t)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
include_directories(BEFORE ./include)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)
add_definitions(-DQT_NO_KEYWORDS)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
include_directories(BEFORE ./include)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)
add_definitions(-DQT_NO_KEYWORDS)

View File

@ -14,7 +14,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -14,7 +14,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
include_directories(BEFORE ./include)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -12,7 +12,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
include_directories(BEFORE ./include)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -25,7 +25,7 @@ if(NOT TARGET CGAL::Eigen3_support)
return()
endif()
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)
include(${CGAL_USE_FILE})

View File

@ -20,7 +20,7 @@ set(QT_USE_QTMAIN TRUE)
set(QT_USE_QTSCRIPT TRUE)
set(QT_USE_QTOPENGL TRUE)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
include_directories(BEFORE ./include)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -3,6 +3,7 @@
#include <CGAL/config.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/algorithm.h>
#include <CGAL/Timer.h>
#include <vector>
#include <utility>
@ -96,7 +97,7 @@ class Constraints_loader {
for(Points_iterator it = points.begin(); it != points.end(); ++it) {
indices.push_back(it);
}
std::random_shuffle(indices.begin(), indices.end());
CGAL::cpp98::random_shuffle(indices.begin(), indices.end());
CGAL::spatial_sort(indices.begin(), indices.end(),
sort_traits);

View File

@ -20,7 +20,7 @@ set(QT_USE_QTMAIN TRUE)
set(QT_USE_QTSCRIPT TRUE)
set(QT_USE_QTOPENGL TRUE)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
include_directories(BEFORE ./include)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -3,6 +3,7 @@
#include <CGAL/config.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/algorithm.h>
#include <CGAL/Timer.h>
#include <vector>
#include <utility>
@ -96,7 +97,7 @@ class Constraints_loader {
for(Points_iterator it = points.begin(); it != points.end(); ++it) {
indices.push_back(it);
}
std::random_shuffle(indices.begin(), indices.end());
CGAL::cpp98::random_shuffle(indices.begin(), indices.end());
CGAL::spatial_sort(indices.begin(), indices.end(),
sort_traits);

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)
set(CMAKE_AUTOMOC ON)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -15,7 +15,7 @@ endif()
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)
find_package(Qt5 QUIET COMPONENTS Xml Script OpenGL Svg)
find_package(Qt5 QUIET COMPONENTS Script OpenGL Svg)
if(CGAL_Qt5_FOUND AND Qt5_FOUND)

View File

@ -54,21 +54,20 @@
namespace CGAL
{
//------------------------------------------------------------------------------
const char vertex_source_color[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"attribute highp vec3 normal;\n"
"attribute highp vec3 color;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"in highp vec3 normal;\n"
"in highp vec3 color;\n"
"uniform highp mat4 mvp_matrix;\n"
"uniform highp mat4 mv_matrix; \n"
"varying highp vec4 fP; \n"
"varying highp vec3 fN; \n"
"varying highp vec4 fColor; \n"
"out highp vec4 fP; \n"
"out highp vec3 fN; \n"
"out highp vec4 fColor; \n"
"uniform highp float point_size; \n"
"void main(void)\n"
@ -83,15 +82,16 @@ const char vertex_source_color[] =
const char fragment_source_color[] =
{
"#version 120 \n"
"varying highp vec4 fP; \n"
"varying highp vec3 fN; \n"
"varying highp vec4 fColor; \n"
"#version 150 \n"
"in highp vec4 fP; \n"
"in highp vec3 fN; \n"
"in highp vec4 fColor; \n"
"uniform highp vec4 light_pos; \n"
"uniform highp vec4 light_diff; \n"
"uniform highp vec4 light_spec; \n"
"uniform highp vec4 light_amb; \n"
"uniform float spec_power ; \n"
"out vec4 out_color; \n"
"void main(void) { \n"
" highp vec3 L = light_pos.xyz - fP.xyz; \n"
@ -104,18 +104,18 @@ const char fragment_source_color[] =
" highp vec3 R = reflect(-L, N); \n"
" highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n"
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
" gl_FragColor = light_amb*fColor + diffuse ; \n"
" out_color = light_amb*fColor + diffuse ; \n"
"} \n"
"\n"
};
const char vertex_source_p_l[] =
{
"#version 120 \n"
"attribute highp vec4 vertex;\n"
"attribute highp vec3 color;\n"
"#version 150 \n"
"in highp vec4 vertex;\n"
"in highp vec3 color;\n"
"uniform highp mat4 mvp_matrix;\n"
"varying highp vec4 fColor; \n"
"out highp vec4 fColor; \n"
"uniform highp float point_size; \n"
"void main(void)\n"
"{\n"
@ -127,10 +127,11 @@ const char vertex_source_p_l[] =
const char fragment_source_p_l[] =
{
"#version 120 \n"
"varying highp vec4 fColor; \n"
"#version 150 \n"
"in highp vec4 fColor; \n"
"out vec4 out_color; \n"
"void main(void) { \n"
"gl_FragColor = fColor; \n"
"out_color = fColor; \n"
"} \n"
"\n"
};
@ -358,6 +359,7 @@ public:
~Basic_viewer_qt()
{
makeCurrent();
for (unsigned int i=0; i<NB_VBO_BUFFERS; ++i)
buffers[i].destroy();
@ -1262,8 +1264,6 @@ protected:
virtual void init()
{
// Restore previous viewer state.
restoreStateFromFile();
initializeOpenGLFunctions();
// Light default parameters

View File

@ -458,10 +458,6 @@ void DemosMainWindow::readState(QString groupname, Options /*what_to_save*/)
move(pos);
}
QByteArray mainWindowState = settings.value("state").toByteArray();
if(!mainWindowState.isNull()) {
this->restoreState(mainWindowState);
}
settings.endGroup();
}

View File

@ -14,7 +14,6 @@
#ifndef QGLVIEWER_CAMERA_H
#define QGLVIEWER_CAMERA_H
#include <QMap>
#include <QDomElement>
#include <CGAL/Qt/vec.h>
#include <CGAL/Qt/quaternion.h>
#include <CGAL/export/Qt.h>
@ -435,15 +434,6 @@ public Q_SLOTS:
void setFlySpeed(qreal speed);
//@}
/*! @name XML representation */
//@{
public:
virtual QDomElement domElement(const QString &name,
QDomDocument &document) const;
public Q_SLOTS:
virtual void initFromDOMElement(const QDomElement &element);
//@}
private Q_SLOTS:
void onFrameModified();

View File

@ -21,7 +21,6 @@
#include <CGAL/Qt/camera.h>
#include <CGAL/Qt/manipulatedCameraFrame.h>
#include <CGAL/Qt/domUtils.h>
#include <CGAL/Qt/keyFrameInterpolator.h>
namespace CGAL{
@ -45,7 +44,6 @@ Camera::Camera(QObject *parent)
// Requires the interpolationKfi_
setFrame(new ManipulatedCameraFrame());
// #CONNECTION# All these default values identical in initFromDOMElement.
// Requires fieldOfView() to define focusDistance()
setSceneRadius(1.0);
@ -61,7 +59,6 @@ Camera::Camera(QObject *parent)
// projectionMatrix_ below.
setType(PERSPECTIVE);
// #CONNECTION# initFromDOMElement default values
setZNearCoefficient(0.005);
setZClippingCoefficient(sqrt(3.0));
@ -883,10 +880,13 @@ void Camera::interpolateTo(const Frame &fr, qreal duration) {
imprecision along the viewing direction. */
CGAL_INLINE_FUNCTION
Vec Camera::pointUnderPixel(const QPoint &pixel, bool &found) const {
float depth;
float depth = 2.0;
// Qt uses upper corner for its origin while GL uses the lower corner.
dynamic_cast<QOpenGLFunctions*>(parent())->glReadPixels(pixel.x(), screenHeight() - 1 - pixel.y(), 1, 1,
GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
if(auto p = dynamic_cast<QOpenGLFunctions*>(parent()))
{
p->glReadPixels(pixel.x(), screenHeight() - 1 - pixel.y(), 1, 1,
GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
}
found = depth < 1.0;
Vec point(pixel.x(), pixel.y(), depth);
point = unprojectedCoordinatesOf(point);
@ -2016,153 +2016,6 @@ void Camera::deletePath(unsigned int i) {
////////////////////////////////////////////////////////////////////////////////
/*! Returns an XML \c QDomElement that represents the Camera.
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
Concatenates the Camera parameters, the ManipulatedCameraFrame::domElement()
and the paths' KeyFrameInterpolator::domElement().
Use initFromDOMElement() to restore the Camera state from the resulting \c
QDomElement.
If you want to save the Camera state in a file, use:
\code
QDomDocument document("myCamera");
doc.appendChild( myCamera->domElement("Camera", document) );
QFile f("myCamera.xml");
if (f.open(IO_WriteOnly))
{
QTextStream out(&f);
document.save(out, 2);
}
\endcode
Note that the CGAL::QGLViewer::camera() is automatically saved by
CGAL::QGLViewer::saveStateToFile() when a CGAL::QGLViewer is closed. Use
CGAL::QGLViewer::restoreStateFromFile() to restore it back. */
CGAL_INLINE_FUNCTION
QDomElement Camera::domElement(const QString &name,
QDomDocument &document) const {
QDomElement de = document.createElement(name);
QDomElement paramNode = document.createElement("Parameters");
paramNode.setAttribute("fieldOfView", QString::number(fieldOfView()));
paramNode.setAttribute("zNearCoefficient",
QString::number(zNearCoefficient()));
paramNode.setAttribute("zClippingCoefficient",
QString::number(zClippingCoefficient()));
paramNode.setAttribute("orthoCoef", QString::number(orthoCoef_));
paramNode.setAttribute("sceneRadius", QString::number(sceneRadius()));
paramNode.appendChild(sceneCenter().domElement("SceneCenter", document));
switch (type()) {
case Camera::PERSPECTIVE:
paramNode.setAttribute("Type", "PERSPECTIVE");
break;
case Camera::ORTHOGRAPHIC:
paramNode.setAttribute("Type", "ORTHOGRAPHIC");
break;
}
de.appendChild(paramNode);
de.appendChild(frame()->domElement("ManipulatedCameraFrame", document));
// KeyFrame paths
for (QMap<unsigned int, KeyFrameInterpolator *>::ConstIterator
it = kfi_.begin(),
end = kfi_.end();
it != end; ++it) {
QDomElement kfNode =
(it.value())->domElement("KeyFrameInterpolator", document);
kfNode.setAttribute("index", QString::number(it.key()));
de.appendChild(kfNode);
}
return de;
}
/*! Restores the Camera state from a \c QDomElement created by domElement().
Use the following code to retrieve a Camera state from a file created using
domElement(): \code
// Load DOM from file
QDomDocument document;
QFile f("myCamera.xml");
if (f.open(IO_ReadOnly))
{
document.setContent(&f);
f.close();
}
// Parse the DOM tree
QDomElement main = document.documentElement();
myCamera->initFromDOMElement(main);
\endcode
The frame() pointer is not modified by this method. The frame() state is
however modified.
\attention The original keyFrameInterpolator() are deleted and should be copied
first if they are shared. */
CGAL_INLINE_FUNCTION
void Camera::initFromDOMElement(const QDomElement &element) {
QDomElement child = element.firstChild().toElement();
QMutableMapIterator<unsigned int, KeyFrameInterpolator *> it(kfi_);
while (it.hasNext()) {
it.next();
deletePath(it.key());
}
while (!child.isNull()) {
if (child.tagName() == "Parameters") {
// #CONNECTION# Default values set in constructor
//setFieldOfView(DomUtils::qrealFromDom(child, "fieldOfView", CGAL_PI / 4.0));
setZNearCoefficient(
DomUtils::qrealFromDom(child, "zNearCoefficient", 0.005));
setZClippingCoefficient(
DomUtils::qrealFromDom(child, "zClippingCoefficient", sqrt(3.0)));
orthoCoef_ =
DomUtils::qrealFromDom(child, "orthoCoef", tan(fieldOfView() / 2.0));
setSceneRadius(
DomUtils::qrealFromDom(child, "sceneRadius", sceneRadius()));
setType(PERSPECTIVE);
QString type = child.attribute("Type", "PERSPECTIVE");
if (type == "PERSPECTIVE")
setType(Camera::PERSPECTIVE);
if (type == "ORTHOGRAPHIC")
setType(Camera::ORTHOGRAPHIC);
QDomElement child2 = child.firstChild().toElement();
while (!child2.isNull()) {
/* Although the scene does not change when a camera is loaded, restore
the saved center and radius values. Mainly useful when a the viewer is
restored on startup, with possible additional cameras. */
if (child2.tagName() == "SceneCenter")
setSceneCenter(Vec(child2));
child2 = child2.nextSibling().toElement();
}
}
if (child.tagName() == "ManipulatedCameraFrame")
frame()->initFromDOMElement(child);
if (child.tagName() == "KeyFrameInterpolator") {
unsigned int index = DomUtils::uintFromDom(child, "index", 0);
setKeyFrameInterpolator(index, new KeyFrameInterpolator(frame()));
if (keyFrameInterpolator(index))
keyFrameInterpolator(index)->initFromDOMElement(child);
}
child = child.nextSibling().toElement();
}
}
/*! Gives the coefficients of a 3D half-line passing through the Camera eye and
pixel (x,y).

View File

@ -1,183 +0,0 @@
/****************************************************************************
Copyright (c) 2018 GeometryFactory Sarl (France).
Copyright (C) 2002-2014 Gilles Debunne. All rights reserved.
This file is part of a fork of the QGLViewer library version 2.7.0.
*****************************************************************************/
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-only
#ifndef QGLVIEWER_DOMUTILS_H
#define QGLVIEWER_DOMUTILS_H
#include <qglobal.h>
#include <QColor>
#include <QDomElement>
#include <QString>
#include <QStringList>
#include <math.h>
#ifndef DOXYGEN
// QDomElement loading with syntax checking.
class DomUtils {
private:
static void warning(const QString &message) {
qWarning("%s", message.toLatin1().constData());
}
public:
static qreal qrealFromDom(const QDomElement &e, const QString &attribute,
qreal defValue) {
qreal value = defValue;
if (e.hasAttribute(attribute)) {
const QString s = e.attribute(attribute);
bool ok;
value = s.toDouble(&ok);
if (!ok) {
warning(QString("'%1' is not a valid qreal syntax for attribute \"%2\" "
"in initialization of \"%3\". Setting value to %4.")
.arg(s)
.arg(attribute)
.arg(e.tagName())
.arg(QString::number(defValue)));
value = defValue;
}
} else {
warning(QString("\"%1\" attribute missing in initialization of \"%2\". "
"Setting value to %3.")
.arg(attribute)
.arg(e.tagName())
.arg(QString::number(value)));
}
#if defined(isnan)
// The "isnan" method may not be available on all platforms.
// Find its equivalent or simply remove these two lines
if (isnan(value))
warning(
QString(
"Warning, attribute \"%1\" initialized to Not a Number in \"%2\"")
.arg(attribute)
.arg(e.tagName()));
#endif
return value;
}
static int intFromDom(const QDomElement &e, const QString &attribute,
int defValue) {
int value = defValue;
if (e.hasAttribute(attribute)) {
const QString s = e.attribute(attribute);
bool ok;
value = s.toInt(&ok);
if (!ok) {
warning(
QString("'%1' is not a valid integer syntax for attribute \"%2\" "
"in initialization of \"%3\". Setting value to %4.")
.arg(s)
.arg(attribute)
.arg(e.tagName())
.arg(QString::number(defValue)));
value = defValue;
}
} else {
warning(QString("\"%1\" attribute missing in initialization of \"%2\". "
"Setting value to %3.")
.arg(attribute)
.arg(e.tagName())
.arg(QString::number(value)));
}
return value;
}
static unsigned int uintFromDom(const QDomElement &e,
const QString &attribute,
unsigned int defValue) {
unsigned int value = defValue;
if (e.hasAttribute(attribute)) {
const QString s = e.attribute(attribute);
bool ok;
value = s.toUInt(&ok);
if (!ok) {
warning(
QString("'%1' is not a valid unsigned integer syntax for attribute "
"\"%2\" in initialization of \"%3\". Setting value to %4.")
.arg(s)
.arg(attribute)
.arg(e.tagName())
.arg(QString::number(defValue)));
value = defValue;
}
} else {
warning(QString("\"%1\" attribute missing in initialization of \"%2\". "
"Setting value to %3.")
.arg(attribute)
.arg(e.tagName())
.arg(QString::number(value)));
}
return value;
}
static bool boolFromDom(const QDomElement &e, const QString &attribute,
bool defValue) {
bool value = defValue;
if (e.hasAttribute(attribute)) {
const QString s = e.attribute(attribute);
if (s.toLower() == QString("true"))
value = true;
else if (s.toLower() == QString("false"))
value = false;
else {
warning(
QString("'%1' is not a valid boolean syntax for attribute \"%2\" "
"in initialization of \"%3\". Setting value to %4.")
.arg(s)
.arg(attribute)
.arg(e.tagName())
.arg(defValue ? "true" : "false"));
}
} else {
warning(QString("\"%1\" attribute missing in initialization of \"%2\". "
"Setting value to %3.")
.arg(attribute)
.arg(e.tagName())
.arg(value ? "true" : "false"));
}
return value;
}
static void setBoolAttribute(QDomElement &element, const QString &attribute,
bool value) {
element.setAttribute(attribute, (value ? "true" : "false"));
}
static QDomElement QColorDomElement(const QColor &color, const QString &name,
QDomDocument &doc) {
QDomElement de = doc.createElement(name);
de.setAttribute("red", QString::number(color.red()));
de.setAttribute("green", QString::number(color.green()));
de.setAttribute("blue", QString::number(color.blue()));
return de;
}
static QColor QColorFromDom(const QDomElement &e) {
int color[3];
QStringList attribute;
attribute << "red"
<< "green"
<< "blue";
for (int i = 0; i < attribute.count(); ++i)
color[i] = DomUtils::intFromDom(e, attribute[i], 0);
return QColor(color[0], color[1], color[2]);
}
};
#endif // DOXYGEN
#endif //QGLVIEWER_DOMUTILS_H

View File

@ -425,14 +425,6 @@ public:
}
//@}
/*! @name XML representation */
//@{
public:
virtual QDomElement domElement(const QString &name,
QDomDocument &document) const;
public Q_SLOTS:
virtual void initFromDOMElement(const QDomElement &element);
//@}
private:
// P o s i t i o n a n d o r i e n t a t i o n

View File

@ -21,7 +21,6 @@
#include <CGAL/Qt/frame.h>
#include <CGAL/Qt/constraint.h>
#include <CGAL/Qt/domUtils.h>
#include <math.h>
namespace CGAL{
@ -999,68 +998,6 @@ void Frame::getTransformOfFrom(const qreal src[3], qreal res[3],
res[i] = r[i];
}
//////////////////////////// STATE //////////////////////////////
/*! Returns an XML \c QDomElement that represents the Frame.
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
The resulting QDomElement looks like:
\code
<name>
<position x=".." y=".." z=".." />
<orientation q0=".." q1=".." q2=".." q3=".." />
</name>
\endcode
Use initFromDOMElement() to restore the Frame state from the resulting \c
QDomElement.
See Vec::domElement() for a complete example. See also
Quaternion::domElement(), Camera::domElement()...
\attention The constraint() and referenceFrame() are not saved in the
QDomElement. */
CGAL_INLINE_FUNCTION
QDomElement Frame::domElement(const QString &name,
QDomDocument &document) const {
// TODO: use translation and rotation instead when referenceFrame is coded...
QDomElement e = document.createElement(name);
e.appendChild(position().domElement("position", document));
e.appendChild(orientation().domElement("orientation", document));
return e;
}
/*! Restores the Frame state from a \c QDomElement created by domElement().
See domElement() for the \c QDomElement syntax. See the
Vec::initFromDOMElement() and Quaternion::initFromDOMElement() documentations
for details on default values if an argument is missing.
\attention The constraint() and referenceFrame() are not restored by this
method and are left unchanged. */
CGAL_INLINE_FUNCTION
void Frame::initFromDOMElement(const QDomElement &element) {
// TODO: use translation and rotation instead when referenceFrame is coded...
// Reset default values. Attention: destroys constraint.
// *this = Frame();
// This instead ? Better : what is not set is not changed.
// setPositionAndOrientation(Vec(), Quaternion());
QDomElement child = element.firstChild().toElement();
while (!child.isNull()) {
if (child.tagName() == "position")
setPosition(Vec(child));
if (child.tagName() == "orientation")
setOrientation(Quaternion(child).normalized());
child = child.nextSibling().toElement();
}
}
///////////////////////////////// ALIGN /////////////////////////////////

View File

@ -0,0 +1,53 @@
// Copyright (c) 2021 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL$
// $Id$
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Maxime Gimeno
#ifndef CGAL_QT_CONTEXT_INITIALIZATION_H
#define CGAL_QT_CONTEXT_INITIALIZATION_H
#include <CGAL/license/GraphicsView.h>
#include <QSurfaceFormat>
#include <QCoreApplication>
namespace CGAL
{
namespace Qt
{
inline void init_ogl_context(int major, int minor) {
QSurfaceFormat fmt;
#ifdef Q_OS_MAC
if(major == 4)
{
fmt.setVersion(4, 1);
}
else
{
fmt.setVersion(major, minor);
}
#else
fmt.setVersion(major, minor);
#endif
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
//for windows
QCoreApplication::setAttribute(::Qt::AA_UseDesktopOpenGL);
//We set the locale to avoid any trouble with VTK
setlocale(LC_ALL, "C");
}
} //end Qt
} //end CGAL
#endif // CGAL_QT_CONTEXT_INITIALIZATION_H

View File

@ -281,14 +281,6 @@ public Q_SLOTS:
virtual void interpolateAtTime(qreal time);
//@}
/*! @name XML representation */
//@{
public:
virtual QDomElement domElement(const QString &name,
QDomDocument &document) const;
virtual void initFromDOMElement(const QDomElement &element);
//@}
private Q_SLOTS:
virtual void update();
virtual void invalidateValues() {

View File

@ -19,7 +19,6 @@
#endif
#include <CGAL/Qt/keyFrameInterpolator.h>
#include <CGAL/Qt/domUtils.h>
namespace CGAL{
namespace qglviewer{
@ -37,7 +36,6 @@ KeyFrameInterpolator::KeyFrameInterpolator(Frame *frame)
interpolationSpeed_(1.0), interpolationStarted_(false),
closedPath_(false), loopInterpolation_(false), pathIsValid_(false),
valuesAreValid_(true), currentFrameValid_(false)
// #CONNECTION# Values cut pasted initFromDOMElement()
{
setFrame(frame);
for (int i = 0; i < 4; ++i)
@ -458,85 +456,6 @@ void KeyFrameInterpolator::interpolateAtTime(qreal time) {
Q_EMIT interpolated();
}
/*! Returns an XML \c QDomElement that represents the KeyFrameInterpolator.
The resulting QDomElement holds the KeyFrameInterpolator parameters as well as
the path keyFrames (if the keyFrame is defined by a pointer to a Frame, use its
current value).
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
Use initFromDOMElement() to restore the ManipulatedFrame state from the
resulting QDomElement.
See Vec::domElement() for a complete example. See also
Quaternion::domElement(), Camera::domElement()...
Note that the Camera::keyFrameInterpolator() are automatically saved by
CGAL::QGLViewer::saveStateToFile() when a CGAL::QGLViewer is closed. */
CGAL_INLINE_FUNCTION
QDomElement KeyFrameInterpolator::domElement(const QString &name,
QDomDocument &document) const {
QDomElement de = document.createElement(name);
int count = 0;
Q_FOREACH (KeyFrame *kf, keyFrame_) {
Frame fr(kf->position(), kf->orientation());
QDomElement kfNode = fr.domElement("KeyFrame", document);
kfNode.setAttribute("index", QString::number(count));
kfNode.setAttribute("time", QString::number(kf->time()));
de.appendChild(kfNode);
++count;
}
de.setAttribute("nbKF", QString::number(keyFrame_.count()));
de.setAttribute("time", QString::number(interpolationTime()));
de.setAttribute("speed", QString::number(interpolationSpeed()));
de.setAttribute("period", QString::number(interpolationPeriod()));
DomUtils::setBoolAttribute(de, "closedPath", closedPath());
DomUtils::setBoolAttribute(de, "loop", loopInterpolation());
return de;
}
/*! Restores the KeyFrameInterpolator state from a \c QDomElement created by
domElement().
Note that the frame() pointer is not included in the domElement(): you need to
setFrame() after this method to attach a Frame to the KeyFrameInterpolator.
See Vec::initFromDOMElement() for a complete code example.
See also Camera::initFromDOMElement() and Frame::initFromDOMElement(). */
CGAL_INLINE_FUNCTION
void KeyFrameInterpolator::initFromDOMElement(const QDomElement &element) {
qDeleteAll(keyFrame_);
keyFrame_.clear();
QDomElement child = element.firstChild().toElement();
while (!child.isNull()) {
if (child.tagName() == "KeyFrame") {
Frame fr;
fr.initFromDOMElement(child);
qreal time = DomUtils::qrealFromDom(child, "time", 0.0);
addKeyFrame(fr, time);
}
child = child.nextSibling().toElement();
}
// #CONNECTION# Values cut pasted from constructor
setInterpolationTime(DomUtils::qrealFromDom(element, "time", 0.0));
setInterpolationSpeed(DomUtils::qrealFromDom(element, "speed", 1.0));
setInterpolationPeriod(DomUtils::intFromDom(element, "period", 40));
setClosedPath(DomUtils::boolFromDom(element, "closedPath", false));
setLoopInterpolation(DomUtils::boolFromDom(element, "loop", false));
// setFrame(nullptr);
pathIsValid_ = false;
valuesAreValid_ = false;
currentFrameValid_ = false;
stopInterpolation();
}
#ifndef DOXYGEN

View File

@ -199,15 +199,6 @@ protected Q_SLOTS:
virtual void spin();
//@}
/*! @name XML representation */
//@{
public:
virtual QDomElement domElement(const QString &name,
QDomDocument &document) const;
public Q_SLOTS:
virtual void initFromDOMElement(const QDomElement &element);
//@}
#ifndef DOXYGEN
protected:
virtual void startAction(

View File

@ -21,7 +21,6 @@
#include <CGAL/number_type_config.h>
#include <CGAL/Qt/manipulatedCameraFrame.h>
#include <CGAL/Qt/camera.h>
#include <CGAL/Qt/domUtils.h>
#include <CGAL/Qt/qglviewer.h>
#include <QMouseEvent>
@ -117,69 +116,6 @@ void ManipulatedCameraFrame::updateSceneUpVector() {
sceneUpVector_ = inverseTransformOf(Vec(0.0, 1.0, 0.0));
}
////////////////////////////////////////////////////////////////////////////////
// S t a t e s a v i n g a n d r e s t o r i n g //
////////////////////////////////////////////////////////////////////////////////
/*! Returns an XML \c QDomElement that represents the ManipulatedCameraFrame.
Adds to the ManipulatedFrame::domElement() the ManipulatedCameraFrame specific
informations in a \c ManipulatedCameraParameters child QDomElement.
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
Use initFromDOMElement() to restore the ManipulatedCameraFrame state from the
resulting \c QDomElement.
See Vec::domElement() for a complete example. See also
Quaternion::domElement(), Frame::domElement(), Camera::domElement()... */
CGAL_INLINE_FUNCTION
QDomElement ManipulatedCameraFrame::domElement(const QString &name,
QDomDocument &document) const {
QDomElement e = ManipulatedFrame::domElement(name, document);
QDomElement mcp = document.createElement("ManipulatedCameraParameters");
mcp.setAttribute("flySpeed", QString::number(flySpeed()));
DomUtils::setBoolAttribute(mcp, "rotatesAroundUpVector",
rotatesAroundUpVector());
DomUtils::setBoolAttribute(mcp, "zoomsOnPivotPoint", zoomsOnPivotPoint());
mcp.appendChild(sceneUpVector().domElement("sceneUpVector", document));
e.appendChild(mcp);
return e;
}
/*! Restores the ManipulatedCameraFrame state from a \c QDomElement created by
domElement().
First calls ManipulatedFrame::initFromDOMElement() and then initializes
ManipulatedCameraFrame specific parameters. */
CGAL_INLINE_FUNCTION
void ManipulatedCameraFrame::initFromDOMElement(const QDomElement &element) {
// No need to initialize, since default sceneUpVector and flySpeed are not
// meaningful. It's better to keep current ones. And it would destroy
// constraint() and referenceFrame(). *this = ManipulatedCameraFrame();
ManipulatedFrame::initFromDOMElement(element);
QDomElement child = element.firstChild().toElement();
while (!child.isNull()) {
if (child.tagName() == "ManipulatedCameraParameters") {
setFlySpeed(DomUtils::qrealFromDom(child, "flySpeed", flySpeed()));
setRotatesAroundUpVector(
DomUtils::boolFromDom(child, "rotatesAroundUpVector", false));
setZoomsOnPivotPoint(
DomUtils::boolFromDom(child, "zoomsOnPivotPoint", false));
QDomElement schild = child.firstChild().toElement();
while (!schild.isNull()) {
if (schild.tagName() == "sceneUpVector")
setSceneUpVector(Vec(schild));
schild = schild.nextSibling().toElement();
}
}
child = child.nextSibling().toElement();
}
}
////////////////////////////////////////////////////////////////////////////////
// M o u s e h a n d l i n g //

View File

@ -302,15 +302,6 @@ public:
virtual void checkIfGrabsMouse(int x, int y, const Camera *const camera);
//@}
/*! @name XML representation */
//@{
public:
virtual QDomElement domElement(const QString &name,
QDomDocument &document) const;
public Q_SLOTS:
virtual void initFromDOMElement(const QDomElement &element);
//@}
#ifndef DOXYGEN
protected:
Quaternion deformedBallQuaternion(int x, int y, qreal cx, qreal cy,

View File

@ -21,7 +21,6 @@
#include <CGAL/Qt/manipulatedFrame.h>
#include <CGAL/Qt/camera.h>
#include <CGAL/Qt/domUtils.h>
#include <CGAL/Qt/qglviewer.h>
#include <cstdlib>
@ -43,7 +42,6 @@ namespace qglviewer{
CGAL_INLINE_FUNCTION
ManipulatedFrame::ManipulatedFrame()
: action_(NO_MOUSE_ACTION), keepsGrabbingMouse_(false) {
// #CONNECTION# initFromDOMElement and accessor docs
setRotationSensitivity(1.0);
setTranslationSensitivity(1.0);
setSpinningSensitivity(0.3);
@ -101,71 +99,7 @@ void ManipulatedFrame::checkIfGrabsMouse(int x, int y,
(fabs(y - proj.y) < thresold)));
}
////////////////////////////////////////////////////////////////////////////////
// S t a t e s a v i n g a n d r e s t o r i n g //
////////////////////////////////////////////////////////////////////////////////
/*! Returns an XML \c QDomElement that represents the ManipulatedFrame.
Adds to the Frame::domElement() the ManipulatedFrame specific informations in a
\c ManipulatedParameters child QDomElement.
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
Use initFromDOMElement() to restore the ManipulatedFrame state from the
resulting \c QDomElement.
See Vec::domElement() for a complete example. See also
Quaternion::domElement(), Camera::domElement()... */
CGAL_INLINE_FUNCTION
QDomElement ManipulatedFrame::domElement(const QString &name,
QDomDocument &document) const {
QDomElement e = Frame::domElement(name, document);
QDomElement mp = document.createElement("ManipulatedParameters");
mp.setAttribute("rotSens", QString::number(rotationSensitivity()));
mp.setAttribute("transSens", QString::number(translationSensitivity()));
mp.setAttribute("spinSens", QString::number(spinningSensitivity()));
mp.setAttribute("wheelSens", QString::number(wheelSensitivity()));
mp.setAttribute("zoomSens", QString::number(zoomSensitivity()));
e.appendChild(mp);
return e;
}
/*! Restores the ManipulatedFrame state from a \c QDomElement created by
domElement().
Fields that are not described in \p element are set to their default values (see
ManipulatedFrame()).
First calls Frame::initFromDOMElement() and then initializes ManipulatedFrame
specific parameters. Note that constraint() and referenceFrame() are not
restored and are left unchanged.
See Vec::initFromDOMElement() for a complete code example. */
CGAL_INLINE_FUNCTION
void ManipulatedFrame::initFromDOMElement(const QDomElement &element) {
// Not called since it would set constraint() and referenceFrame() to nullptr.
// *this = ManipulatedFrame();
Frame::initFromDOMElement(element);
stopSpinning();
QDomElement child = element.firstChild().toElement();
while (!child.isNull()) {
if (child.tagName() == "ManipulatedParameters") {
// #CONNECTION# constructor default values and accessor docs
setRotationSensitivity(DomUtils::qrealFromDom(child, "rotSens", 1.0));
setTranslationSensitivity(
DomUtils::qrealFromDom(child, "transSens", 1.0));
setSpinningSensitivity(DomUtils::qrealFromDom(child, "spinSens", 0.3));
setWheelSensitivity(DomUtils::qrealFromDom(child, "wheelSens", 1.0));
setZoomSensitivity(DomUtils::qrealFromDom(child, "zoomSens", 1.0));
}
child = child.nextSibling().toElement();
}
}
////////////////////////////////////////////////////////////////////////////////
// M o u s e h a n d l i n g //

View File

@ -179,9 +179,7 @@ public:
/*! Returns the background color of the viewer.
This method is provided for convenience since the background color is an
OpenGL state variable set with \c glClearColor(). However, this internal
representation has the advantage that it is saved (resp. restored) with
saveStateToFile() (resp. restoreStateFromFile()).
OpenGL state variable set with \c glClearColor().
Use setBackgroundColor() to define and activate a background color.
@ -667,9 +665,8 @@ protected:
initialize some of the OpenGL flags. The default implementation is empty. See
initializeGL().
Typical usage include camera() initialization (showEntireScene()), previous
viewer state restoration (restoreStateFromFile()), OpenGL state modification
and display list creation.
Typical usage include camera() initialization (showEntireScene()),
OpenGL state modification and display list creation.
Note that initializeGL() modifies the standard OpenGL context. These values
can be restored back in this method.
@ -719,7 +716,6 @@ protected:
virtual void keyPressEvent(QKeyEvent *);
virtual void keyReleaseEvent(QKeyEvent *);
virtual void timerEvent(QTimerEvent *);
virtual void closeEvent(QCloseEvent *);
//@}
/*! @name Object selection */
@ -921,35 +917,11 @@ protected:
//@{
public:
QString stateFileName() const;
virtual QDomElement domElement(const QString &name,
QDomDocument &document) const;
Q_SIGNALS:
void needNewContext();
public Q_SLOTS:
virtual void initFromDOMElement(const QDomElement &element);
virtual void saveStateToFile(); // cannot be const because of QMessageBox
virtual bool restoreStateFromFile();
/*! Defines the stateFileName() used by saveStateToFile() and
restoreStateFromFile().
The file name can have an optional prefix directory (no prefix meaning
current directory). If the directory does not exist, it will be created by
saveStateToFile().
\code
// Name depends on the displayed 3D model. Saved in current directory.
setStateFileName(3DModelName() + ".xml");
// Files are stored in a dedicated directory under user's home directory.
setStateFileName(QDir::homeDirPath + "/.config/myApp.xml");
\endcode */
void setStateFileName(const QString &name) { stateFileName_ = name; }
protected:
static void saveStateToFileForAllViewers();
//@}
/*! @name QGLViewer pool */
@ -1167,8 +1139,6 @@ protected:
QMap<WheelBindingPrivate, MouseActionPrivate> wheelBinding_;
QMap<ClickBindingPrivate, qglviewer::ClickAction> clickBinding_;
::Qt::Key currentlyPressedKey_;
// S t a t e F i l e
QString stateFileName_;
// H e l p w i n d o w
QTabWidget *helpWidget_;

View File

@ -24,7 +24,6 @@
#include <CGAL/Qt/qglviewer.h>
#include <CGAL/Qt/manipulatedCameraFrame.h>
#include <CGAL/Qt/camera.h>
#include <CGAL/Qt/domUtils.h>
#include <CGAL/Qt/keyFrameInterpolator.h>
#include <CGAL/Qt/image_interface.h>
@ -103,7 +102,6 @@ void CGAL::QGLViewer::defaultConstructor() {
// It will be set when setFullScreen(false) is called after
// setFullScreen(true)
// #CONNECTION# default values in initFromDOMElement()
manipulatedFrame_ = nullptr;
manipulatedFrameIsACamera_ = false;
mouseGrabberIsAManipulatedFrame_ = false;
@ -116,9 +114,7 @@ void CGAL::QGLViewer::defaultConstructor() {
setSceneRadius(1.0);
showEntireScene();
setStateFileName(".qglviewer.xml");
// #CONNECTION# default values in initFromDOMElement()
setAxisIsDrawn(false);
setGridIsDrawn(false);
setFPSIsDisplayed(false);
@ -180,11 +176,6 @@ other viewer's indexes) and allocated memory is released. The camera() is
deleted and should be copied before if it is shared by an other viewer. */
CGAL_INLINE_FUNCTION
CGAL::QGLViewer::~QGLViewer() {
// See closeEvent comment. Destructor is called (and not closeEvent) only when
// the widget is embedded. Hence we saveToFile here. It is however a bad idea
// if virtual domElement() has been overloaded ! if (parent())
// saveStateToFileForAllViewers();
CGAL::QGLViewer::QGLViewerPool().removeAll(this);
camera()->deleteLater();
@ -217,16 +208,6 @@ void CGAL::QGLViewer::initializeGL() {
|| QCoreApplication::arguments().contains(QStringLiteral("--old")))
{
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setVersion(2,0);
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setSamples(0);
format.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(format);
needNewContext();
qDebug()<<"GL 4.3 context initialization failed. ";
is_ogl_4_3 = false;
}
else
@ -659,7 +640,7 @@ void CGAL::QGLViewer::setCameraIsEdited(bool edit) {
cameraIsEdited_ = edit;
if (edit) {
previousCameraZClippingCoefficient_ = camera()->zClippingCoefficient();
// #CONNECTION# 5.0 also used in domElement() and in initFromDOMElement().
camera()->setZClippingCoefficient(5.0);
} else
camera()->setZClippingCoefficient(previousCameraZClippingCoefficient_);
@ -751,7 +732,7 @@ void CGAL::QGLViewer::setDefaultMouseBindings() {
(mh == qglviewer::FRAME) ? frameKeyboardModifiers : cameraKeyboardModifiers;
setMouseBinding(modifiers, ::Qt::LeftButton, mh, qglviewer::ROTATE);
setMouseBinding(modifiers, ::Qt::MidButton, mh, qglviewer::ZOOM);
setMouseBinding(modifiers, ::Qt::MiddleButton, mh, qglviewer::ZOOM);
setMouseBinding(modifiers, ::Qt::RightButton, mh, qglviewer::TRANSLATE);
setMouseBinding(::Qt::Key_R, modifiers, ::Qt::LeftButton, mh, qglviewer::SCREEN_ROTATE);
@ -761,7 +742,7 @@ void CGAL::QGLViewer::setDefaultMouseBindings() {
setWheelBinding(::Qt::Key_Z, ::Qt::NoModifier, qglviewer::CAMERA, qglviewer::ZOOM_FOV);
// Z o o m o n r e g i o n
setMouseBinding(::Qt::ShiftModifier, ::Qt::MidButton, qglviewer::CAMERA, qglviewer::ZOOM_ON_REGION);
setMouseBinding(::Qt::ShiftModifier, ::Qt::MiddleButton, qglviewer::CAMERA, qglviewer::ZOOM_ON_REGION);
// S e l e c t
setMouseBinding(::Qt::ShiftModifier, ::Qt::LeftButton, qglviewer::SELECT);
@ -769,7 +750,7 @@ void CGAL::QGLViewer::setDefaultMouseBindings() {
setMouseBinding(::Qt::ShiftModifier, ::Qt::RightButton, qglviewer::RAP_FROM_PIXEL);
// D o u b l e c l i c k
setMouseBinding(::Qt::NoModifier, ::Qt::LeftButton, qglviewer::ALIGN_CAMERA, true);
setMouseBinding(::Qt::NoModifier, ::Qt::MidButton, qglviewer::SHOW_ENTIRE_SCENE, true);
setMouseBinding(::Qt::NoModifier, ::Qt::MiddleButton, qglviewer::SHOW_ENTIRE_SCENE, true);
setMouseBinding(::Qt::NoModifier, ::Qt::RightButton, qglviewer::CENTER_SCENE, true);
setMouseBinding(frameKeyboardModifiers, ::Qt::LeftButton, qglviewer::ALIGN_FRAME, true);
@ -1076,46 +1057,6 @@ void CGAL::QGLViewer::stopAnimation() {
killTimer(animationTimerId_);
}
/*! Overloading of the \c QWidget method.
Saves the viewer state using saveStateToFile() and then calls
QOpenGLWidget::closeEvent(). */
CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::closeEvent(QCloseEvent *e) {
// When the user clicks on the window close (x) button:
// - If the viewer is a top level window, closeEvent is called and then saves
// to file. - Otherwise, nothing happen s:( When the user press the
// EXIT_VIEWER keyboard shortcut: - If the viewer is a top level window,
// saveStateToFile() is also called - Otherwise, closeEvent is NOT called and
// keyPressEvent does the job.
/* After tests:
E : Embedded widget
N : Widget created with new
C : closeEvent called
D : destructor called
E N C D
y y
y n y
n y y
n n y y
closeEvent is called iif the widget is NOT embedded.
Destructor is called iif the widget is created on the stack
or if widget (resp. parent if embedded) is created with WDestructiveClose
flag.
closeEvent always before destructor.
Close using qApp->closeAllWindows or (x) is identical.
*/
// #CONNECTION# Also done for EXIT_VIEWER in keyPressEvent().
saveStateToFile();
QOpenGLWidget::closeEvent(e);
}
/*! Simple wrapper method: calls \c select(event->pos()).
@ -1236,7 +1177,7 @@ static QString mouseButtonsString(::Qt::MouseButtons b) {
result += CGAL::QGLViewer::tr("Left", "left mouse button");
addAmpersand = true;
}
if (b & ::Qt::MidButton) {
if (b & ::Qt::MiddleButton) {
if (addAmpersand)
result += " & ";
result += CGAL::QGLViewer::tr("Middle", "middle mouse button");
@ -1786,7 +1727,7 @@ Mouse tab.
\c ::Qt::AltModifier, \c ::Qt::ShiftModifier, \c ::Qt::MetaModifier). Possibly
combined using the \c "|" operator.
\p button is one of the ::Qt::MouseButtons (\c ::Qt::LeftButton, \c ::Qt::MidButton,
\p button is one of the ::Qt::MouseButtons (\c ::Qt::LeftButton, \c ::Qt::MiddleButton,
\c ::Qt::RightButton...).
\p doubleClick indicates whether or not the user has to double click this button
@ -2369,7 +2310,6 @@ void CGAL::QGLViewer::handleKeyboardAction(qglviewer::KeyboardAction id) {
toggleTextIsEnabled();
break;
case qglviewer::EXIT_VIEWER:
saveStateToFileForAllViewers();
qApp->closeAllWindows();
break;
case qglviewer::FULL_SCREEN:
@ -3066,27 +3006,27 @@ void CGAL::QGLViewer::toggleCameraMode() {
camera()->frame()->stopSpinning();
setMouseBinding(modifiers, ::Qt::LeftButton, qglviewer::CAMERA, qglviewer::MOVE_FORWARD);
setMouseBinding(modifiers, ::Qt::MidButton, qglviewer::CAMERA, qglviewer::LOOK_AROUND);
setMouseBinding(modifiers, ::Qt::MiddleButton, qglviewer::CAMERA, qglviewer::LOOK_AROUND);
setMouseBinding(modifiers, ::Qt::RightButton, qglviewer::CAMERA, qglviewer::MOVE_BACKWARD);
setMouseBinding(::Qt::Key_R, modifiers, ::Qt::LeftButton, qglviewer::CAMERA, qglviewer::ROLL);
setMouseBinding(::Qt::NoModifier, ::Qt::LeftButton, qglviewer::NO_CLICK_ACTION, true);
setMouseBinding(::Qt::NoModifier, ::Qt::MidButton, qglviewer::NO_CLICK_ACTION, true);
setMouseBinding(::Qt::NoModifier, ::Qt::MiddleButton, qglviewer::NO_CLICK_ACTION, true);
setMouseBinding(::Qt::NoModifier, ::Qt::RightButton, qglviewer::NO_CLICK_ACTION, true);
setWheelBinding(modifiers, qglviewer::CAMERA, qglviewer::MOVE_FORWARD);
} else {
// Should stop flyTimer. But unlikely and not easy.
setMouseBinding(modifiers, ::Qt::LeftButton, qglviewer::CAMERA, qglviewer::ROTATE);
setMouseBinding(modifiers, ::Qt::MidButton, qglviewer::CAMERA, qglviewer::ZOOM);
setMouseBinding(modifiers, ::Qt::MiddleButton, qglviewer::CAMERA, qglviewer::ZOOM);
setMouseBinding(modifiers, ::Qt::RightButton, qglviewer::CAMERA, qglviewer::TRANSLATE);
setMouseBinding(::Qt::Key_R, modifiers, ::Qt::LeftButton, qglviewer::CAMERA,
qglviewer::SCREEN_ROTATE);
setMouseBinding(::Qt::NoModifier, ::Qt::LeftButton, qglviewer::ALIGN_CAMERA, true);
setMouseBinding(::Qt::NoModifier, ::Qt::MidButton, qglviewer::SHOW_ENTIRE_SCENE, true);
setMouseBinding(::Qt::NoModifier, ::Qt::MiddleButton, qglviewer::SHOW_ENTIRE_SCENE, true);
setMouseBinding(::Qt::NoModifier, ::Qt::RightButton, qglviewer::CENTER_SCENE, true);
setWheelBinding(modifiers, qglviewer::CAMERA, qglviewer::ZOOM);
@ -3578,352 +3518,6 @@ void CGAL::QGLViewer::drawGrid(qreal size, int nbSubdivisions) {
// S t a t i c m e t h o d s : Q G L V i e w e r P o o l //
////////////////////////////////////////////////////////////////////////////////
/*! saveStateToFile() is called on all the CGAL::QGLViewers using the QGLViewerPool().
*/
CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::saveStateToFileForAllViewers() {
Q_FOREACH (CGAL::QGLViewer *viewer, CGAL::QGLViewer::QGLViewerPool()) {
if (viewer)
viewer->saveStateToFile();
}
}
//////////////////////////////////////////////////////////////////////////
// S a v e s t a t e b e t w e e n s e s s i o n s //
//////////////////////////////////////////////////////////////////////////
/*! Returns the state file name. Default value is \c .qglviewer.xml.
This is the name of the XML file where saveStateToFile() saves the viewer state
(camera state, widget geometry, display flags... see domElement()) on exit. Use
restoreStateFromFile() to restore this state later (usually in your init()
method).
Setting this value to \c QString() will disable the automatic state file
saving that normally occurs on exit.
If more than one viewer are created by the application, this function will
return a numbered file name (as in ".qglviewer1.xml", ".qglviewer2.xml"... using
QGLViewer::QGLViewerIndex()) for extra viewers. Each viewer will then read back
its own information in restoreStateFromFile(), provided that the viewers are
created in the same order, which is usually the case. */
CGAL_INLINE_FUNCTION
QString CGAL::QGLViewer::stateFileName() const {
QString name = stateFileName_;
if (!name.isEmpty() && QGLViewer::QGLViewerIndex(this) > 0) {
QFileInfo fi(name);
if (fi.suffix().isEmpty())
name += QString::number(QGLViewer::QGLViewerIndex(this));
else
name = fi.absolutePath() + '/' + fi.completeBaseName() +
QString::number(QGLViewer::QGLViewerIndex(this)) + "." +
fi.suffix();
}
return name;
}
/*! Saves in stateFileName() an XML representation of the CGAL::QGLViewer state,
obtained from domElement().
Use restoreStateFromFile() to restore this viewer state.
This method is automatically called when a viewer is closed (using Escape or
using the window's upper right \c x close button). setStateFileName() to \c
QString() to prevent this. */
CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::saveStateToFile() {
QString name = stateFileName();
if (name.isEmpty())
return;
QFileInfo fileInfo(name);
if (fileInfo.isDir()) {
QMessageBox::warning(
this, tr("Save to file error", "Message box window title"),
tr("State file name (%1) references a directory instead of a file.")
.arg(name));
return;
}
const QString dirName = fileInfo.absolutePath();
if (!QFileInfo(dirName).exists()) {
QDir dir;
if (!(dir.mkdir(dirName))) {
QMessageBox::warning(this,
tr("Save to file error", "Message box window title"),
tr("Unable to create directory %1").arg(dirName));
return;
}
}
// Write the DOM tree to file
QFile f(name);
if (f.open(QIODevice::WriteOnly)) {
QTextStream out(&f);
QDomDocument doc("QGLVIEWER");
doc.appendChild(domElement("CGAL::QGLViewer", doc));
doc.save(out, 2);
f.flush();
f.close();
} else
QMessageBox::warning(
this, tr("Save to file error", "Message box window title"),
tr("Unable to save to file %1").arg(name) + ":\n" + f.errorString());
}
/*! Restores the CGAL::QGLViewer state from the stateFileName() file using
initFromDOMElement().
States are saved using saveStateToFile(), which is automatically called on
viewer exit.
Returns \c true when the restoration is successful. Possible problems are an non
existing or unreadable stateFileName() file, an empty stateFileName() or an XML
syntax error.
A manipulatedFrame() should be defined \e before calling this method, so that
its state can be restored. Initialization code put \e after this function will
override saved values: \code void Viewer::init()
{
// Default initialization goes here (including the declaration of a possible
manipulatedFrame).
if (!restoreStateFromFile())
showEntireScene(); // Previous state cannot be restored: fit camera to scene.
// Specific initialization that overrides file savings goes here.
}
\endcode */
CGAL_INLINE_FUNCTION
bool CGAL::QGLViewer::restoreStateFromFile() {
QString name = stateFileName();
if (name.isEmpty())
return false;
QFileInfo fileInfo(name);
if (!fileInfo.isFile())
// No warning since it would be displayed at first start.
return false;
if (!fileInfo.isReadable()) {
QMessageBox::warning(
this, tr("Problem in state restoration", "Message box window title"),
tr("File %1 is not readable.").arg(name));
return false;
}
// Read the DOM tree form file
QFile f(name);
if (f.open(QIODevice::ReadOnly)) {
QDomDocument doc;
doc.setContent(&f);
f.close();
QDomElement main = doc.documentElement();
initFromDOMElement(main);
} else {
QMessageBox::warning(
this, tr("Open file error", "Message box window title"),
tr("Unable to open file %1").arg(name) + ":\n" + f.errorString());
return false;
}
return true;
}
/*! Returns an XML \c QDomElement that represents the CGAL::QGLViewer.
Used by saveStateToFile(). restoreStateFromFile() uses initFromDOMElement() to
restore the CGAL::QGLViewer state from the resulting \c QDomElement.
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
The created QDomElement contains state values (axisIsDrawn(), FPSIsDisplayed(),
isFullScreen()...), viewer geometry, as well as camera() (see
CGAL::qglviewer::Camera::domElement()) and manipulatedFrame() (if defined, see
CGAL::qglviewer::ManipulatedFrame::domElement()) states.
Overload this method to add your own attributes to the state file:
\code
CGAL_INLINE_FUNCTION
QDomElement Viewer::domElement(const QString& name, QDomDocument& document)
const
{
// Creates a custom node for a light
QDomElement de = document.createElement("Light");
de.setAttribute("state", (lightIsOn()?"on":"off"));
// Note the include of the ManipulatedFrame domElement method.
de.appendChild(lightManipulatedFrame()->domElement("LightFrame", document));
// Get default state domElement and append custom node
CGAL_INLINE_FUNCTION
QDomElement res = CGAL::QGLViewer::domElement(name, document);
res.appendChild(de);
return res;
}
\endcode
See initFromDOMElement() for the associated restoration code.
\attention For the manipulatedFrame(), CGAL::qglviewer::Frame::constraint() and
CGAL::qglviewer::Frame::referenceFrame() are not saved. See
CGAL::qglviewer::Frame::domElement(). */
CGAL_INLINE_FUNCTION
QDomElement CGAL::QGLViewer::domElement(const QString &name,
QDomDocument &document) const {
QDomElement de = document.createElement(name);
QDomElement stateNode = document.createElement("State");
// hasMouseTracking() is not saved
stateNode.appendChild(DomUtils::QColorDomElement(
foregroundColor(), "foregroundColor", document));
stateNode.appendChild(DomUtils::QColorDomElement(
backgroundColor(), "backgroundColor", document));
// Revolve or fly camera mode is not saved
de.appendChild(stateNode);
QDomElement displayNode = document.createElement("Display");
DomUtils::setBoolAttribute(displayNode, "axisIsDrawn", axisIsDrawn());
DomUtils::setBoolAttribute(displayNode, "gridIsDrawn", gridIsDrawn());
DomUtils::setBoolAttribute(displayNode, "FPSIsDisplayed", FPSIsDisplayed());
DomUtils::setBoolAttribute(displayNode, "cameraIsEdited", cameraIsEdited());
// textIsEnabled() is not saved
de.appendChild(displayNode);
QDomElement geometryNode = document.createElement("Geometry");
DomUtils::setBoolAttribute(geometryNode, "fullScreen", isFullScreen());
if (isFullScreen()) {
geometryNode.setAttribute("prevPosX", QString::number(prevPos_.x()));
geometryNode.setAttribute("prevPosY", QString::number(prevPos_.y()));
} else {
QWidget *tlw = topLevelWidget();
geometryNode.setAttribute("width", QString::number(tlw->width()));
geometryNode.setAttribute("height", QString::number(tlw->height()));
geometryNode.setAttribute("posX", QString::number(tlw->pos().x()));
geometryNode.setAttribute("posY", QString::number(tlw->pos().y()));
}
de.appendChild(geometryNode);
// Restore original Camera zClippingCoefficient before saving.
if (cameraIsEdited())
camera()->setZClippingCoefficient(previousCameraZClippingCoefficient_);
de.appendChild(camera()->domElement("Camera", document));
if (cameraIsEdited())
// #CONNECTION# 5.0 from setCameraIsEdited()
camera()->setZClippingCoefficient(5.0);
if (manipulatedFrame())
de.appendChild(
manipulatedFrame()->domElement("ManipulatedFrame", document));
return de;
}
/*! Restores the CGAL::QGLViewer state from a \c QDomElement created by domElement().
Used by restoreStateFromFile() to restore the CGAL::QGLViewer state from a file.
Overload this method to retrieve custom attributes from the CGAL::QGLViewer state
file. This code corresponds to the one given in the domElement() documentation:
\code
CGAL_INLINE_FUNCTION
void Viewer::initFromDOMElement(const QDomElement& element)
{
// Restore standard state
CGAL_INLINE_FUNCTION
CGAL::QGLViewer::initFromDOMElement(element);
QDomElement child=element.firstChild().toElement();
while (!child.isNull())
{
if (child.tagName() == "Light")
{
if (child.hasAttribute("state"))
setLightOn(child.attribute("state").toLower() == "on");
// Assumes there is only one child. Otherwise you need to parse child's children
recursively. QDomElement lf = child.firstChild().toElement(); if (!lf.isNull()
&& lf.tagName() == "LightFrame")
lightManipulatedFrame()->initFromDomElement(lf);
}
child = child.nextSibling().toElement();
}
}
\endcode
CGAL_INLINE_FUNCTION
See also CGAL::qglviewer::Camera::initFromDOMElement(),
CGAL::qglviewer::ManipulatedFrame::initFromDOMElement().
\note The manipulatedFrame() \e pointer is not modified by this method. If
defined, its state is simply set from the \p element values. */
CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::initFromDOMElement(const QDomElement &element) {
QDomElement child = element.firstChild().toElement();
bool tmpCameraIsEdited = cameraIsEdited();
while (!child.isNull()) {
if (child.tagName() == "State") {
// #CONNECTION# default values from defaultConstructor()
// setMouseTracking(DomUtils::boolFromDom(child, "mouseTracking", false));
// if ((child.attribute("cameraMode", "revolve") == "fly") &&
// (cameraIsInRevolveMode())) toggleCameraMode();
QDomElement ch = child.firstChild().toElement();
while (!ch.isNull()) {
if (ch.tagName() == "foregroundColor")
setForegroundColor(DomUtils::QColorFromDom(ch));
if (ch.tagName() == "backgroundColor")
setBackgroundColor(DomUtils::QColorFromDom(ch));
ch = ch.nextSibling().toElement();
}
}
if (child.tagName() == "Display") {
// #CONNECTION# default values from defaultConstructor()
setAxisIsDrawn(DomUtils::boolFromDom(child, "axisIsDrawn", false));
setGridIsDrawn(DomUtils::boolFromDom(child, "gridIsDrawn", false));
setFPSIsDisplayed(DomUtils::boolFromDom(child, "FPSIsDisplayed", false));
}
if (child.tagName() == "Geometry") {
setFullScreen(DomUtils::boolFromDom(child, "fullScreen", false));
if (!isFullScreen())
{
int width = DomUtils::intFromDom(child, "width", 600);
int height = DomUtils::intFromDom(child, "height", 400);
topLevelWidget()->resize(width, height);
camera()->setScreenWidthAndHeight(this->width(), this->height());
QPoint pos;
pos.setX(DomUtils::intFromDom(child, "posX", 0));
pos.setY(DomUtils::intFromDom(child, "posY", 0));
topLevelWidget()->move(pos);
}
}
child = child.nextSibling().toElement();
}
// The Camera always stores its "real" zClippingCoef in domElement(). If it is
// edited, its "real" coef must be saved and the coef set to 5.0, as is done
// in setCameraIsEdited(). BUT : Camera and Display are read in an arbitrary
// order. We must initialize Camera's "real" coef BEFORE calling
// setCameraIsEdited. Hence this temp cameraIsEdited and delayed call
cameraIsEdited_ = tmpCameraIsEdited;
if (cameraIsEdited_) {
previousCameraZClippingCoefficient_ = camera()->zClippingCoefficient();
// #CONNECTION# 5.0 from setCameraIsEdited.
camera()->setZClippingCoefficient(5.0);
}
}
CGAL_INLINE_FUNCTION
void CGAL::QGLViewer::copyBufferToTexture(GLint , GLenum ) {

View File

@ -300,12 +300,6 @@ public:
static Quaternion randomQuaternion();
//@}
/*! @name XML representation */
//@{
explicit Quaternion(const QDomElement &element);
QDomElement domElement(const QString &name, QDomDocument &document) const;
void initFromDOMElement(const QDomElement &element);
//@}
#ifdef DOXYGEN
/*! @name Output stream */

View File

@ -20,7 +20,6 @@
#endif
#include <CGAL/number_type_config.h>
#include <CGAL/Qt/quaternion.h>
#include <CGAL/Qt/domUtils.h>
#include <stdlib.h> // RAND_MAX
// All the methods are declared inline in Quaternion.h
@ -211,71 +210,6 @@ qreal Quaternion::angle() const {
return (angle <= CGAL_PI) ? angle : 2.0 * CGAL_PI - angle;
}
/*! Returns an XML \c QDomElement that represents the Quaternion.
\p name is the name of the QDomElement tag. \p doc is the \c QDomDocument
factory used to create QDomElement.
When output to a file, the resulting QDomElement will look like:
\code
<name q0=".." q1=".." q2=".." q3=".." />
\endcode
Use initFromDOMElement() to restore the Quaternion state from the resulting \c
QDomElement. See also the Quaternion(const QDomElement&) constructor.
CGAL_INLINE_FUNCTION
See the Vec::domElement() documentation for a complete QDomDocument creation
and saving example.
CGAL_INLINE_FUNCTION
See also Frame::domElement(), Camera::domElement(),
CGAL_INLINE_FUNCTION
KeyFrameInterpolator::domElement()... */
CGAL_INLINE_FUNCTION
QDomElement Quaternion::domElement(const QString &name,
QDomDocument &document) const {
QDomElement de = document.createElement(name);
de.setAttribute("q0", QString::number(q[0]));
de.setAttribute("q1", QString::number(q[1]));
de.setAttribute("q2", QString::number(q[2]));
de.setAttribute("q3", QString::number(q[3]));
return de;
}
/*! Restores the Quaternion state from a \c QDomElement created by domElement().
The \c QDomElement should contain the \c q0, \c q1 , \c q2 and \c q3
attributes. If one of these attributes is missing or is not a number, a warning
is displayed and these fields are respectively set to 0.0, 0.0, 0.0 and 1.0
(identity Quaternion).
See also the Quaternion(const QDomElement&) constructor. */
CGAL_INLINE_FUNCTION
void Quaternion::initFromDOMElement(const QDomElement &element) {
Quaternion q(element);
*this = q;
}
/*! Constructs a Quaternion from a \c QDomElement representing an XML code of
the form \code< anyTagName q0=".." q1=".." q2=".." q3=".." />\endcode
If one of these attributes is missing or is not a number, a warning is
displayed and the associated value is respectively set to 0, 0, 0 and 1
(identity Quaternion).
See also domElement() and initFromDOMElement(). */
CGAL_INLINE_FUNCTION
Quaternion::Quaternion(const QDomElement &element) {
QStringList attribute;
attribute << "q0"
<< "q1"
<< "q2"
<< "q3";
for (int i = 0; i < attribute.size(); ++i)
q[i] = DomUtils::qrealFromDom(element, attribute[i], ((i < 3) ? 0.0 : 1.0));
}
/*! Returns the Quaternion associated 4x4 OpenGL rotation matrix.
Use \c glMultMatrixd(q.matrix()) to apply the rotation represented by

View File

@ -16,8 +16,6 @@
#include <iostream>
#include <math.h>
#include <QDomElement>
// Included by all files as vec.h is at the end of the include hierarchy
#include <CGAL/export/Qt.h>
@ -334,12 +332,6 @@ Normalizing a null vector will result in \c NaN values. */
void projectOnPlane(const Vec &normal);
//@}
/*! @name XML representation */
//@{
explicit Vec(const QDomElement &element);
QDomElement domElement(const QString &name, QDomDocument &document) const;
void initFromDOMElement(const QDomElement &element);
//@}
#ifdef DOXYGEN
/*! @name Output stream */

Some files were not shown because too many files have changed in this diff Show More