Merge remote-tracking branch 'cgal/master' into Mesh-3-edge-distance-criterium-aclement
|
|
@ -2,8 +2,8 @@
|
|||
/usr/local/bin/cmake --version
|
||||
FACTOR=$1
|
||||
set -ex
|
||||
cd Polyhedron/demo
|
||||
/usr/local/bin/cmake -S Polyhedron -B build -DCGAL_DIR=$2
|
||||
cd Lab/demo
|
||||
/usr/local/bin/cmake -S Lab -B build -DCGAL_DIR=$2
|
||||
LIST_OF_PLUGINS=$(/usr/local/bin/cmake --build build -t help | egrep 'plugin$' |& cut -d\ -f2)
|
||||
PLUGINS_ARRAY=(${LIST_OF_PLUGINS});
|
||||
NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
name: Test Polyhedron Demo
|
||||
name: Compile CGAL Lab
|
||||
|
||||
on: [push, pull_request,workflow_dispatch]
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ Number_types
|
|||
Polyhedron
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Spatial_sorting
|
||||
Stream_support
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ private:
|
|||
|
||||
Polynomial poly_;
|
||||
int number_of_real_roots_;
|
||||
IT* numerator;
|
||||
IT* denominator_exponent;
|
||||
bool* is_exact;
|
||||
std::vector<IT> numerator;
|
||||
std::vector<IT> denominator_exponent;
|
||||
std::vector<bool> is_exact;
|
||||
IT LEFT,SCALE,DENOM;
|
||||
bool is_strong_;
|
||||
int k;
|
||||
|
|
@ -91,9 +91,9 @@ public:
|
|||
k(kk),
|
||||
interval_given(false) {
|
||||
|
||||
numerator = new IT[CGAL::degree(P)];
|
||||
denominator_exponent = new IT[CGAL::degree(P)];
|
||||
is_exact = new bool[CGAL::degree(P)];
|
||||
numerator.resize(CGAL::degree(P));
|
||||
denominator_exponent.resize(CGAL::degree(P));
|
||||
is_exact.resize(CGAL::degree(P));
|
||||
number_of_real_roots_ = 0;
|
||||
if(CGAL::degree(P) == 0)
|
||||
{
|
||||
|
|
@ -116,9 +116,9 @@ public:
|
|||
k(kk),
|
||||
interval_given(true) {
|
||||
|
||||
numerator = new IT[CGAL::degree(P)];
|
||||
denominator_exponent = new IT[CGAL::degree(P)];
|
||||
is_exact = new bool[CGAL::degree(P)];
|
||||
numerator.resize(CGAL::degree(P));
|
||||
denominator_exponent.resize(CGAL::degree(P));
|
||||
is_exact.resize(CGAL::degree(P));
|
||||
number_of_real_roots_ = 0;
|
||||
if(CGAL::degree(P) == 0)
|
||||
{
|
||||
|
|
@ -153,9 +153,9 @@ public:
|
|||
k(D.k),
|
||||
interval_given(D.interval_given) {
|
||||
|
||||
numerator = new IT[CGAL::degree(poly_)];
|
||||
denominator_exponent = new IT[CGAL::degree(poly_)];
|
||||
is_exact = new bool[CGAL::degree(poly_)];
|
||||
numerator.resize(CGAL::degree(poly_));
|
||||
denominator_exponent.resize(CGAL::degree(poly_));
|
||||
is_exact.resize(CGAL::degree(poly_));
|
||||
for(int i=0; i<number_of_real_roots(); i++)
|
||||
{
|
||||
numerator[i] = D.numerator[i];
|
||||
|
|
@ -166,9 +166,6 @@ public:
|
|||
|
||||
// destructor
|
||||
~Descartes() {
|
||||
delete[] numerator;
|
||||
delete[] denominator_exponent;
|
||||
delete[] is_exact;
|
||||
}
|
||||
|
||||
public: // functions
|
||||
|
|
|
|||
|
|
@ -1153,15 +1153,17 @@ private:
|
|||
if(!is_positive(alpha) || !is_positive(offset))
|
||||
{
|
||||
#ifdef CGAL_AW3_DEBUG
|
||||
std::cerr << "Error: invalid input parameters: " << alpha << " and" << offset << std::endl;
|
||||
std::cerr << "Error: invalid input parameters: " << alpha << " and " << offset << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef CGAL_AW3_DEBUG
|
||||
if(refining && alpha > m_alpha)
|
||||
std::cerr << "Warning: refining with an alpha greater than the last iteration's!" << std::endl;
|
||||
if(refining && offset != m_offset)
|
||||
std::cerr << "Warning: refining with a different offset value!" << std::endl;
|
||||
#endif
|
||||
|
||||
m_alpha = FT(alpha);
|
||||
m_sq_alpha = square(m_alpha);
|
||||
|
|
|
|||
|
|
@ -17,36 +17,63 @@
|
|||
#ifndef CGAL_DRAW_ARRANGEMENT_2_H
|
||||
#define CGAL_DRAW_ARRANGEMENT_2_H
|
||||
|
||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
#include <CGAL/Qt/Basic_viewer.h>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
/*! \ingroup PkgArrangementOnSurface2Draw
|
||||
*
|
||||
* opens a new window and draws `arr`, an instance of the `CGAL::Arrangement_2`
|
||||
* class template. A call to this function is blocking; that is, the program
|
||||
* continues only after the user closes the window. This function requires
|
||||
* `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is
|
||||
* defined. Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link
|
||||
* with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
*
|
||||
* \tparam GeometryTraits_2 a geometry traits type, a model of a 2D arrangement
|
||||
* traits concept. At this point it must be an instance of either
|
||||
* `CGAL::Arr_segment_traits_2` or `CGAL::Arr_conic_traits_2`.
|
||||
*
|
||||
* \tparam Dcel the \dcel type, a model of the `ArrangementDcel` concept.
|
||||
*
|
||||
* \param arr the 2D arrangement to draw.
|
||||
* \param title the window title.
|
||||
*
|
||||
* \sa `ArrangementDcel`
|
||||
* \sa `ArrangementTraits_2`
|
||||
|
||||
opens a new window and draws `arr`, an instance of the `CGAL::Arrangement_2` class template. Parameters of the drawing are taken from the optional graphics scene options parameter.
|
||||
|
||||
A call to this function blocks the execution of the program until the drawing window is closed. This function requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined.
|
||||
Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
|
||||
|
||||
\tparam GeometryTraits_2 a geometry traits type, a model of a 2D arrangement traits concept. At this point it must be an instance of either `CGAL::Arr_segment_traits_2` or `CGAL::Arr_conic_traits_2`.
|
||||
\tparam Dcel the \dcel type, a model of the `ArrangementDcel` concept.
|
||||
\tparam GSOptions a model of `GraphicsSceneOptions` concept.
|
||||
|
||||
\param arr the 2D arrangement to draw.
|
||||
\param gso the graphics scene options parameter.
|
||||
|
||||
\sa `ArrangementDcel`
|
||||
\sa `ArrangementTraits_2`
|
||||
*/
|
||||
template <typename GeometryTraits_2, typename Dcel, typename GSOptions>
|
||||
void draw(const Arrangement_2<GeometryTraits_2, Dcel>& arr, const GSOptions& gso);
|
||||
|
||||
/*! \ingroup PkgArrangementOnSurface2Draw
|
||||
|
||||
A shortcut to `CGAL::draw(arr, Graphics_scene_options{})`.
|
||||
*/
|
||||
template <typename GeometryTraits_2, typename Dcel>
|
||||
void draw(const Arrangement_2<GeometryTraits_2, Dcel>& arr);
|
||||
|
||||
/*! \ingroup PkgArrangementOnSurface2Draw
|
||||
|
||||
adds the vertices, edges and faces of `arr` into the given graphic scene `gs`. Parameters of the cells are taken from the optional graphics scene options parameter `gso`. Note that `gs` is not cleared before being filled (to enable to draw several data structures in the same basic viewer).
|
||||
|
||||
\tparam GeometryTraits_2 a geometry traits type, a model of a 2D arrangement traits concept. At this point it must be an instance of either `CGAL::Arr_segment_traits_2` or `CGAL::Arr_conic_traits_2`.
|
||||
\tparam Dcel the \dcel type, a model of the `ArrangementDcel` concept.
|
||||
\tparam GSOptions a model of `GraphicsSceneOptions` concept.
|
||||
|
||||
\param arr the 2D arrangement to draw.
|
||||
\param gs the graphic scene to fill.
|
||||
\param gso the graphics scene options parameter.
|
||||
*/
|
||||
template <typename GeometryTraits_2, typename Dcel, typename GSOptions>
|
||||
void add_to_graphics_scene(const Arrangement_2<GeometryTraits_2, Dcel>& arr,
|
||||
CGAL::Graphics_scene& gs, const GSOptions& gso);
|
||||
|
||||
/*! \ingroup PkgArrangementOnSurface2Draw
|
||||
|
||||
A shortcut to `CGAL::add_to_graphics_scene(arr, gs, Graphics_scene_options{})`.
|
||||
*/
|
||||
template <typename GeometryTraits_2, typename Dcel>
|
||||
void draw(const Arrangement_2<GeometryTraits_2, Dcel>& arr,
|
||||
const char* title = "2D Arrangement Basic Viewer");
|
||||
void add_to_graphics_scene(const Arrangement_2<GeometryTraits_2, Dcel>& arr,
|
||||
CGAL::Graphics_scene& gs);
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
||||
|
|
|
|||
|
|
@ -100,13 +100,24 @@ int main() {
|
|||
<< arr.number_of_faces() << std::endl;
|
||||
|
||||
std::size_t id(0);
|
||||
CGAL::draw(arr, [&] (Arrangement_2::Face_const_handle) -> CGAL::IO::Color {
|
||||
float h = 360.0f * id++ / arr.number_of_faces();
|
||||
float s = 0.5;
|
||||
float v = 0.5;
|
||||
auto [r, g, b] = hsv_to_rgb(h, s, v);
|
||||
return CGAL::IO::Color(r,g,b);
|
||||
}, "hsv colors", true);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
CGAL::Graphics_scene_options<Arrangement_2,
|
||||
typename Arrangement_2::Vertex_const_handle,
|
||||
typename Arrangement_2::Halfedge_const_handle,
|
||||
typename Arrangement_2::Face_const_handle> gso;
|
||||
gso.colored_face=[](const Arrangement_2&, Arrangement_2::Face_const_handle) -> bool
|
||||
{ return true; };
|
||||
|
||||
gso.face_color=[&id](const Arrangement_2& arr, Arrangement_2::Face_const_handle) -> CGAL::IO::Color
|
||||
{
|
||||
float h = 360.0f * id++ / arr.number_of_faces();
|
||||
float s = 0.5;
|
||||
float v = 0.5;
|
||||
auto [r, g, b] = hsv_to_rgb(h, s, v);
|
||||
return CGAL::IO::Color(r,g,b);
|
||||
};
|
||||
|
||||
CGAL::draw(arr, gso, "hsv colors");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ Algebraic_kernel_d
|
|||
Arithmetic_kernel
|
||||
Arrangement_on_surface_2
|
||||
BGL
|
||||
Basic_viewer
|
||||
CGAL_Core
|
||||
Cartesian_kernel
|
||||
Circular_kernel_2
|
||||
|
|
@ -10,7 +11,6 @@ Circulator
|
|||
Distance_2
|
||||
Distance_3
|
||||
Filtered_kernel
|
||||
GraphicsView
|
||||
HalfedgeDS
|
||||
Hash_map
|
||||
Homogeneous_kernel
|
||||
|
|
|
|||
|
|
@ -510,11 +510,12 @@ Dynamic property tags, such as `dynamic_vertex_property_t`, are a generalization
|
|||
value type of the dynamic property map, and a default value.
|
||||
`boost::property_map<G,T>::%type` is used to obtain the
|
||||
type of the dynamic property map for a graph of type `G`, for a
|
||||
dynamic property tag `T`. This type must be default constructible and assignable.
|
||||
dynamic property tag `T`. This type must be assignable, and if no
|
||||
default is provided it must be default constructible.
|
||||
As for ordinary properties, the function `%get()` is overloaded and
|
||||
serves for retrieving a property map for a given graph and dynamic
|
||||
property tag, as well as for retrieving a value for a given key and
|
||||
property map.
|
||||
property map. The default value is provided as third parameter.
|
||||
|
||||
The following example shows how to attach a `string` property to vertices and
|
||||
a `double` value to the halfedges of a graph.
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ ALIASES += "bgllink{1}=<a href=\"http://www.boost.org/libs/graph/doc/\1.html\">
|
|||
EXTRACT_ALL=NO
|
||||
HIDE_UNDOC_MEMBERS = YES
|
||||
HIDE_UNDOC_CLASSES = YES
|
||||
WARN_IF_INCOMPLETE_DOC = NO
|
||||
|
||||
# macros to be used inside the code
|
||||
ALIASES += "cgalAssociatedTypesBegin=<dl class=\"params\"><dt>Associated Types</dt><dd> <table class=\"params\">"
|
||||
|
|
|
|||
|
|
@ -449,6 +449,9 @@ the requirement for traversal of all faces in a graph.
|
|||
/// \defgroup PkgBGLHelperFct Helper Functions
|
||||
/// \ingroup PkgBGLRef
|
||||
|
||||
/// \defgroup PkgBGLGeneratorFct Generator Functions
|
||||
/// \ingroup PkgBGLRef
|
||||
|
||||
/// \defgroup PkgBGLIterators Iterators and Circulators
|
||||
/// \ingroup PkgBGLRef
|
||||
|
||||
|
|
@ -520,7 +523,14 @@ by attaching and initializing external IDs to the elements of the graph.
|
|||
Generic convenience functions for testing if an edge is a border edge, if a mesh is triangular,
|
||||
for conversion between models of different `FaceGraph` concepts, etc.
|
||||
|
||||
Most functions are in the header file `<CGAL/boost/graph/helpers.h>`
|
||||
All functions are in the header file `<CGAL/boost/graph/helpers.h>`
|
||||
*/
|
||||
|
||||
/*!
|
||||
\addtogroup PkgBGLGeneratorrFct
|
||||
Generic convenience functions for generating meshes such as a triangle, a quad, or a grid.
|
||||
|
||||
All functions are in the header file `<CGAL/boost/graph/generators.h>`
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
|
@ -667,6 +677,7 @@ user might encounter.
|
|||
- `CGAL::is_valid_face_graph()`
|
||||
- `CGAL::is_valid_polygon_mesh()`
|
||||
|
||||
\cgalCRPSection{Generator Functions}
|
||||
- `CGAL::is_tetrahedron()`
|
||||
- `CGAL::is_hexahedron()`
|
||||
- `CGAL::make_triangle()`
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/selection.h>
|
||||
#include <CGAL/boost/graph/IO/OFF.h>
|
||||
|
||||
#include <CGAL/Random.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <CGAL/boost/graph/Graph_with_descriptor_with_graph.h>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
#include <CGAL/boost/graph/io.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,23 +19,15 @@
|
|||
#include <CGAL/Random.h>
|
||||
#include <CGAL/function_objects.h>
|
||||
|
||||
#include <CGAL/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
#include <CGAL/boost/graph/copy_face_graph.h>
|
||||
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Euler {
|
||||
|
||||
// Some forward declaration to break the helpers.h > generators.h > Euler_operations.h cycle
|
||||
template< typename Graph>
|
||||
void fill_hole(typename boost::graph_traits<Graph>::halfedge_descriptor h,
|
||||
Graph& g);
|
||||
|
||||
template<typename Graph , typename VertexRange >
|
||||
typename boost::graph_traits<Graph>::face_descriptor add_face(const VertexRange& vr,
|
||||
Graph& g);
|
||||
|
||||
} // namespace Euler
|
||||
|
||||
namespace internal {
|
||||
|
||||
|
|
@ -126,7 +118,7 @@ random_face_in_mesh(const Graph& g, CGAL::Random& rnd = get_default_random())
|
|||
} // namespace internal
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
*
|
||||
* \brief creates an isolated triangle
|
||||
* with its vertices initialized to `p0`, `p1` and `p2`, and adds it to the graph `g`.
|
||||
|
|
@ -256,7 +248,7 @@ struct Default_grid_maker
|
|||
} // namespace internal
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
*
|
||||
* \brief creates an isolated quad with
|
||||
* its vertices initialized to `p0`, `p1`, `p2`, and `p3`, and adds it to the graph `g`.
|
||||
|
|
@ -287,17 +279,35 @@ make_quad(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
|
|||
}
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
* \brief creates an isolated hexahedron
|
||||
* with its vertices initialized to `p0`, `p1`, ...\ , and `p7`, and adds it to the graph `g`.
|
||||
* \image html hexahedron.png
|
||||
* \image latex hexahedron.png
|
||||
* \returns the halfedge that has the target vertex associated with `p0`, in the face with the vertices with the points `p0`, `p1`, `p2`, and `p3`.
|
||||
* \returns the halfedge that has the target vertex associated with `p0`,
|
||||
* in the face with the vertices with the points `p0`, `p1`, `p2`, and `p3`
|
||||
* (or `p0`, `p2` and `p3` when `do_not_triangulate` is set to `false`).
|
||||
*
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
* among the ones listed below
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{do_not_triangulate_faces}
|
||||
* \cgalParamDescription{a Boolean used to specify whether the hexadron's faces
|
||||
* should be triangulated or not.
|
||||
* The default value is `true`, and faces are not triangulated.}
|
||||
* \cgalParamDefault{true}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
**/
|
||||
template<typename Graph, typename P>
|
||||
template<typename P,
|
||||
typename Graph,
|
||||
typename NamedParameters = parameters::Default_named_parameters>
|
||||
typename boost::graph_traits<Graph>::halfedge_descriptor
|
||||
make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
||||
const P& p4, const P& p5, const P& p6, const P& p7, Graph& g)
|
||||
const P& p4, const P& p5, const P& p6, const P& p7,
|
||||
Graph& g,
|
||||
const NamedParameters& np = parameters::default_values())
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph> Traits;
|
||||
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
|
||||
|
|
@ -306,6 +316,9 @@ make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
|||
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
|
||||
Point_property_map ppmap = get(CGAL::vertex_point, g);
|
||||
|
||||
const bool triangulate = !parameters::choose_parameter(
|
||||
parameters::get_parameter(np, internal_np::do_not_triangulate_faces), true);
|
||||
|
||||
vertex_descriptor v0, v1, v2, v3, v4, v5, v6, v7;
|
||||
v0 = add_vertex(g);
|
||||
v1 = add_vertex(g);
|
||||
|
|
@ -326,6 +339,14 @@ make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
|||
|
||||
halfedge_descriptor ht = internal::make_quad(v4, v5, v6, v7, g);
|
||||
halfedge_descriptor hb = prev(internal::make_quad(v0, v3, v2, v1, g), g);
|
||||
|
||||
std::array<halfedge_descriptor, 6> he_faces;
|
||||
if(triangulate)
|
||||
{
|
||||
he_faces[0] = hb;
|
||||
he_faces[1] = ht;
|
||||
}
|
||||
|
||||
for(int i=0; i <4; ++i)
|
||||
{
|
||||
halfedge_descriptor h = halfedge(add_edge(g), g);
|
||||
|
|
@ -342,14 +363,72 @@ make_hexahedron(const P& p0, const P& p1, const P& p2, const P& p3,
|
|||
for(int i=0; i <4; ++i)
|
||||
{
|
||||
Euler::fill_hole(opposite(hb, g), g);
|
||||
if(triangulate)
|
||||
he_faces[i+2] = opposite(hb, g);
|
||||
hb = next(hb, g);
|
||||
}
|
||||
|
||||
if(triangulate)
|
||||
{
|
||||
for (halfedge_descriptor hi : he_faces)
|
||||
{
|
||||
halfedge_descriptor nnhi = next(next(hi, g), g);
|
||||
Euler::split_face(hi, nnhi, g);
|
||||
}
|
||||
}
|
||||
|
||||
return next(next(hb, g), g);
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
* \brief creates an isolated hexahedron
|
||||
* equivalent to `c`, and adds it to the graph `g`.
|
||||
* \returns the halfedge that has the target vertex associated with `c.min()`,
|
||||
* aligned with x-axis,
|
||||
* in the bottom face of the cuboid.
|
||||
*
|
||||
* \tparam IsoCuboid a model of `IsoCuboid_3`
|
||||
* \tparam Graph a model of `MutableFaceGraph`
|
||||
* \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
*
|
||||
* \param c the iso-cuboid describing the geometry of the hexahedron
|
||||
* \param g the graph to which the hexahedron will be appended
|
||||
* \param np an optional sequence of \ref bgl_namedparameters "Named Parameters"
|
||||
* among the ones listed below
|
||||
* \cgalNamedParamsBegin
|
||||
* \cgalParamNBegin{do_not_triangulate_faces}
|
||||
* \cgalParamDescription{a Boolean used to specify whether the hexadron's faces
|
||||
* should be triangulated or not.
|
||||
* The default value is `true`, and faces are not triangulated.}
|
||||
* \cgalParamDefault{true}
|
||||
* \cgalParamNEnd
|
||||
* \cgalParamNBegin{geom_traits}
|
||||
* \cgalParamDescription{an instance of a geometric traits class model of `Kernel`.}
|
||||
* \cgalParamNEnd
|
||||
* \cgalNamedParamsEnd
|
||||
**/
|
||||
template<typename IsoCuboid,
|
||||
typename Graph,
|
||||
typename NamedParameters = parameters::Default_named_parameters>
|
||||
typename boost::graph_traits<Graph>::halfedge_descriptor
|
||||
make_hexahedron(const IsoCuboid& c,
|
||||
Graph& g,
|
||||
const NamedParameters& np = parameters::default_values())
|
||||
{
|
||||
using GT = typename GetGeomTraits<Graph, NamedParameters>::type;
|
||||
GT gt = parameters::choose_parameter<GT>(
|
||||
parameters::get_parameter(np, internal_np::geom_traits));
|
||||
typename GT::Construct_vertex_3 v = gt.construct_vertex_3_object();
|
||||
|
||||
return CGAL::make_hexahedron(v(c, 0), v(c, 1), v(c, 2), v(c, 3),
|
||||
v(c, 4), v(c, 5), v(c, 6), v(c, 7),
|
||||
g,
|
||||
np);
|
||||
}
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
* \brief creates an isolated tetrahedron
|
||||
* with its vertices initialized to `p0`, `p1`, `p2`, and `p3`, and adds it to the graph `g`.
|
||||
* \image html tetrahedron.png
|
||||
|
|
@ -447,7 +526,7 @@ make_tetrahedron(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
|
|||
}
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
*
|
||||
* \brief creates a triangulated regular prism, outward oriented,
|
||||
* having `nb_vertices` vertices in each of its bases and adds it to the graph `g`.
|
||||
|
|
@ -547,7 +626,7 @@ make_regular_prism(typename boost::graph_traits<Graph>::vertices_size_type nb_ve
|
|||
}
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
* \brief creates a pyramid, outward oriented, having `nb_vertices` vertices in its base and adds it to the graph `g`.
|
||||
*
|
||||
* If `center` is `(0, 0, 0)`, then the first point of the base is `(radius, 0, 0)`
|
||||
|
|
@ -635,7 +714,7 @@ make_pyramid(typename boost::graph_traits<Graph>::vertices_size_type nb_vertices
|
|||
}
|
||||
|
||||
/**
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
*
|
||||
* \brief creates an icosahedron, outward oriented, centered in `center` and adds it to the graph `g`.
|
||||
*
|
||||
|
|
@ -730,7 +809,7 @@ make_icosahedron(Graph& g,
|
|||
}
|
||||
|
||||
/*!
|
||||
* \ingroup PkgBGLHelperFct
|
||||
* \ingroup PkgBGLGeneratorFct
|
||||
*
|
||||
* \brief creates a row major ordered grid with `i` cells along the width and `j` cells
|
||||
* along the height and adds it to the graph `g`.
|
||||
|
|
|
|||
|
|
@ -1081,8 +1081,5 @@ int halfedge_index_in_face(typename boost::graph_traits<Graph>::halfedge_descrip
|
|||
|
||||
} // namespace CGAL
|
||||
|
||||
// Here at the bottom because helpers.h must include generators (for backward compatibility reasons),
|
||||
// and Euler_operations.h needs helpers.h
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
#endif // CGAL_BOOST_GRAPH_HELPERS_H
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2018-2020 GeometryFactory (France)
|
||||
// Copyright (c) 2018-2022 GeometryFactory (France)
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
|
|
@ -9,199 +9,151 @@
|
|||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
// Laurent Rineau <laurent.rineau@cgal.org>
|
||||
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||
|
||||
#ifndef CGAL_DRAW_FACE_GRAPH_H
|
||||
#define CGAL_DRAW_FACE_GRAPH_H
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Graphics_scene.h>
|
||||
#include <CGAL/Graphics_scene_options.h>
|
||||
#include <CGAL/Dynamic_property_map.h>
|
||||
#include <CGAL/Random.h>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
// Default color functor; user can change it to have its own face color
|
||||
struct DefaultColorFunctorFaceGraph
|
||||
namespace draw_function_for_FG {
|
||||
|
||||
template <typename FG, typename GSOptions>
|
||||
void compute_elements(const FG &fg,
|
||||
CGAL::Graphics_scene &graphics_scene,
|
||||
const GSOptions &gs_options)
|
||||
{
|
||||
template<typename Graph>
|
||||
CGAL::IO::Color operator()(const Graph& /*g*/,
|
||||
typename boost::graph_traits<Graph>::face_descriptor /*f*/) const
|
||||
using Point=typename boost::property_map_value<FG, CGAL::vertex_point_t>::type;
|
||||
using Kernel = typename CGAL::Kernel_traits<Point>::Kernel;
|
||||
using Vector = typename Kernel::Vector_3;
|
||||
|
||||
auto vnormals = get(CGAL::dynamic_vertex_property_t<Vector>(), fg);
|
||||
auto point_pmap = get(CGAL::vertex_point, fg);
|
||||
for (auto v : vertices(fg))
|
||||
{
|
||||
return get_random_color(CGAL::get_default_random());
|
||||
}
|
||||
|
||||
// edges and vertices are black by default
|
||||
template<typename Graph>
|
||||
CGAL::IO::Color operator()(const Graph& /*g*/,
|
||||
typename boost::graph_traits<Graph>::edge_descriptor /*e*/) const
|
||||
{
|
||||
return IO::black();
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
CGAL::IO::Color operator()(const Graph& /*g*/,
|
||||
typename boost::graph_traits<Graph>::vertex_descriptor /*v*/) const
|
||||
{
|
||||
return IO::black();
|
||||
}
|
||||
};
|
||||
|
||||
class SimpleFaceGraphViewerQt : public Basic_viewer_qt
|
||||
{
|
||||
using Base = Basic_viewer_qt;
|
||||
|
||||
public:
|
||||
SimpleFaceGraphViewerQt(QWidget* parent) :
|
||||
Base(parent, "", false, true, true, true, false),
|
||||
m_compute_elements_impl([]{})
|
||||
{
|
||||
}
|
||||
|
||||
/// Construct the viewer.
|
||||
/// @param g the face graph to view
|
||||
/// @param title the title of the window
|
||||
/// @param anofaces if true, do not draw faces (faces are not computed; this can be
|
||||
/// useful for very big objects where this time could be long)
|
||||
template <typename Graph>
|
||||
SimpleFaceGraphViewerQt(QWidget* parent,
|
||||
const Graph& g,
|
||||
const char* title="Basic Face Graph Viewer",
|
||||
bool anofaces=false) :
|
||||
SimpleFaceGraphViewerQt(parent, g, title, anofaces, DefaultColorFunctorFaceGraph())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
SimpleFaceGraphViewerQt(QWidget* parent,
|
||||
const Graph& g,
|
||||
const char* title,
|
||||
bool anofaces,
|
||||
ColorFunctor fcolor) :
|
||||
// First draw: no vertex; edges, faces; mono-color; inverse normal
|
||||
Base(parent, title, false, true, true, true, false),
|
||||
m_compute_elements_impl(compute_elements_functor(g, anofaces, fcolor))
|
||||
{
|
||||
}
|
||||
|
||||
void init() override {
|
||||
compute_elements();
|
||||
Base::init();
|
||||
}
|
||||
|
||||
void compute_elements() {
|
||||
m_compute_elements_impl();
|
||||
}
|
||||
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
void set_face_graph(const Graph& g,
|
||||
bool anofaces,
|
||||
ColorFunctor fcolor) {
|
||||
m_compute_elements_impl = compute_elements_functor(g, anofaces, fcolor);
|
||||
}
|
||||
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
void set_face_graph(const Graph& g,
|
||||
bool anofaces=false) {
|
||||
set_mesh(g, anofaces, DefaultColorFunctorFaceGraph());
|
||||
}
|
||||
protected:
|
||||
template <typename Graph, typename ColorFunctor>
|
||||
std::function<void()>
|
||||
compute_elements_functor(const Graph& g,
|
||||
bool anofaces,
|
||||
ColorFunctor fcolor)
|
||||
{
|
||||
using Point = typename boost::property_map_value<Graph, CGAL::vertex_point_t>::type;
|
||||
using Kernel = typename CGAL::Kernel_traits<Point>::Kernel;
|
||||
using Vector = typename Kernel::Vector_3;
|
||||
|
||||
auto vnormals = get(CGAL::dynamic_vertex_property_t<Vector>(), g);
|
||||
auto point_pmap = get(CGAL::vertex_point, g);
|
||||
for (auto v : vertices(g))
|
||||
Vector n(NULL_VECTOR);
|
||||
int i = 0;
|
||||
for (auto h : halfedges_around_target(halfedge(v, fg), fg))
|
||||
{
|
||||
Vector n(NULL_VECTOR);
|
||||
int i=0;
|
||||
for (auto h : halfedges_around_target(halfedge(v, g), g))
|
||||
if (!is_border(h, fg))
|
||||
{
|
||||
if (!is_border(h, g))
|
||||
Vector ni = CGAL::cross_product(
|
||||
Vector(get(point_pmap, source(h, fg)),
|
||||
get(point_pmap, target(h, fg))),
|
||||
Vector(get(point_pmap, target(h, fg)),
|
||||
get(point_pmap, target(next(h, fg), fg))));
|
||||
if (ni!=NULL_VECTOR)
|
||||
{
|
||||
Vector ni = CGAL::cross_product(
|
||||
Vector(get(point_pmap, source(h, g)), get(point_pmap, target(h, g))),
|
||||
Vector(get(point_pmap, target(h, g)), get(point_pmap, target(next(h, g), g))));
|
||||
if (ni != NULL_VECTOR)
|
||||
{
|
||||
n+=ni;
|
||||
++i;
|
||||
}
|
||||
n += ni;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
put(vnormals, v, n/i);
|
||||
}
|
||||
|
||||
// This function return a lambda expression, type-erased in a
|
||||
// `std::function<void()>` object.
|
||||
return [this, &g, vnormals, anofaces, fcolor, point_pmap]()
|
||||
{
|
||||
this->clear();
|
||||
|
||||
if (!anofaces)
|
||||
{
|
||||
for (auto fh: faces(g))
|
||||
{
|
||||
const CGAL::IO::Color& c = fcolor(g, fh);
|
||||
face_begin(c);
|
||||
auto hd=halfedge(fh, g);
|
||||
const auto first_hd = hd;
|
||||
do
|
||||
{
|
||||
auto v = source(hd, g);
|
||||
add_point_in_face(get(point_pmap, v), get(vnormals, v));
|
||||
hd=next(hd, g);
|
||||
}
|
||||
while(hd!=first_hd);
|
||||
face_end();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto e: edges(g))
|
||||
{
|
||||
const CGAL::IO::Color& c = fcolor(g, e);
|
||||
add_segment(get(point_pmap, source(halfedge(e, g), g)),
|
||||
get(point_pmap, target(halfedge(e, g), g)),
|
||||
c);
|
||||
}
|
||||
|
||||
for (auto v: vertices(g))
|
||||
{
|
||||
const CGAL::IO::Color& c = fcolor(g, v);
|
||||
this->add_point(get(point_pmap, v), c);
|
||||
}
|
||||
};
|
||||
put(vnormals, v, n / i);
|
||||
}
|
||||
|
||||
void keyPressEvent(QKeyEvent *e) override
|
||||
if (gs_options.are_faces_enabled())
|
||||
{
|
||||
// Test key pressed:
|
||||
// const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
// if ((e->key()==Qt::Key_PageUp) && (modifiers==Qt::NoButton)) { ... }
|
||||
|
||||
// Call: * compute_elements() if the model changed, followed by
|
||||
// * redraw() if some viewing parameters changed that implies some
|
||||
// modifications of the buffers
|
||||
// (eg. type of normal, color/mono)
|
||||
// * update() just to update the drawing
|
||||
|
||||
// Call the base method to process others/classicals key
|
||||
Base::keyPressEvent(e);
|
||||
for (auto fh : faces(fg))
|
||||
{
|
||||
if (fh != boost::graph_traits<FG>::null_face() && // face exists
|
||||
gs_options.draw_face(fg, fh)) // face is drawn
|
||||
{
|
||||
if(gs_options.colored_face(fg, fh)) // face is colored
|
||||
{ graphics_scene.face_begin(gs_options.face_color(fg, fh)); }
|
||||
else
|
||||
{ graphics_scene.face_begin(); }
|
||||
auto hd = halfedge(fh, fg);
|
||||
const auto first_hd = hd;
|
||||
do
|
||||
{
|
||||
auto v = source(hd, fg);
|
||||
graphics_scene.add_point_in_face(get(point_pmap, v), get(vnormals, v));
|
||||
hd = next(hd, fg);
|
||||
}
|
||||
while (hd != first_hd);
|
||||
graphics_scene.face_end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
std::function<void()> m_compute_elements_impl;
|
||||
};
|
||||
if(gs_options.are_edges_enabled())
|
||||
{
|
||||
for (auto e : edges(fg))
|
||||
{
|
||||
if(gs_options.colored_edge(fg, e)) // edge is colored
|
||||
{
|
||||
graphics_scene.add_segment(get(point_pmap, source(halfedge(e, fg), fg)),
|
||||
get(point_pmap, target(halfedge(e, fg), fg)),
|
||||
gs_options.edge_color(fg, e));
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics_scene.add_segment(get(point_pmap, source(halfedge(e, fg), fg)),
|
||||
get(point_pmap, target(halfedge(e, fg), fg)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(gs_options.are_vertices_enabled())
|
||||
{
|
||||
for (auto v : vertices(fg))
|
||||
{
|
||||
if(gs_options.colored_vertex(fg, v)) // vertex is colored
|
||||
{
|
||||
graphics_scene.add_point(get(point_pmap, v),
|
||||
gs_options.vertex_color(fg, v));
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics_scene.add_point(get(point_pmap, v));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // draw_function_for_FG
|
||||
|
||||
template <class FG, class GSOptions>
|
||||
void add_to_graphics_scene_for_fg(const FG &fg,
|
||||
CGAL::Graphics_scene &graphics_scene,
|
||||
const GSOptions &gs_options)
|
||||
{
|
||||
draw_function_for_FG::compute_elements(fg, graphics_scene, gs_options);
|
||||
}
|
||||
|
||||
template <class FG>
|
||||
void add_to_graphics_scene_for_fg(const FG &fg,
|
||||
CGAL::Graphics_scene &graphics_scene)
|
||||
{
|
||||
Graphics_scene_options<FG,
|
||||
typename boost::graph_traits<FG>::vertex_descriptor,
|
||||
typename boost::graph_traits<FG>::edge_descriptor,
|
||||
typename boost::graph_traits<FG>::face_descriptor>
|
||||
gs_options;
|
||||
|
||||
gs_options.colored_face = [](const FG&,
|
||||
typename boost::graph_traits<FG>::face_descriptor) -> bool
|
||||
{ return true; };
|
||||
|
||||
gs_options.face_color = [] (const FG&,
|
||||
typename boost::graph_traits<FG>::face_descriptor fh) -> CGAL::IO::Color
|
||||
{
|
||||
if (fh==boost::graph_traits<FG>::null_face())
|
||||
{ return CGAL::IO::Color(100, 125, 200); }
|
||||
|
||||
return get_random_color(CGAL::get_default_random());
|
||||
};
|
||||
|
||||
add_to_graphics_scene_for_fg(fg, graphics_scene, gs_options);
|
||||
}
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#endif // CGAL_DRAW_SURFACE_MESH_H
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
||||
typedef K::Point_3 Point_3;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef K::Point_3 Point_3;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "test_Prefix.h"
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
#include <CGAL/IO/OFF.h>
|
||||
#include <CGAL/Polygon_mesh_processing/border.h>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include <CGAL/boost/graph/Face_filtered_graph.h>
|
||||
#include <CGAL/boost/graph/named_params_helper.h>
|
||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
#include <CGAL/use.h>
|
||||
#include "test_Prefix.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/boost/graph/Euler_operations.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ Number_types
|
|||
Polygon
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Spatial_sorting
|
||||
Stream_support
|
||||
|
|
|
|||
|
|
@ -0,0 +1,173 @@
|
|||
namespace CGAL {
|
||||
/*!
|
||||
|
||||
\mainpage User Manual
|
||||
\anchor Chapter_Basic_viewer
|
||||
\anchor ChapterBasicViewer
|
||||
|
||||
\author Guillaume Damiand and Mostafa Ashraf
|
||||
\cgalAutoToc
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_Intro Introduction
|
||||
|
||||
The basic viewer package provides interactive visualization for most \cgal packages, such as
|
||||
\ref PkgArrangementOnSurface2Ref "2D Arrangements",
|
||||
\ref PkgBooleanSetOperations2Ref "2D Boolean Set",
|
||||
\ref PkgLinearCellComplexRef "Linear cell complex",
|
||||
\ref PkgNef3Ref "3D Nef",
|
||||
\ref PkgPeriodic2Triangulation2Ref "2D Periodic Triangulations",
|
||||
\ref PkgPointSet3Ref "3D Point Set",
|
||||
\ref PkgPolygon2Ref "2D Polygon",
|
||||
\ref PkgPolyhedronRef "3D Polyhedral Surface",
|
||||
\ref PkgStraightSkeleton2Ref "2D Straight Skeleton",
|
||||
\ref PkgSurface_mesh "Surface Mesh",
|
||||
\ref PkgTriangulation2Ref "2D Triangulation",
|
||||
\ref PkgTriangulation3Ref "3D Triangulation",
|
||||
\ref PkgVoronoiDiagram2Ref "2D Voronoi Diagram",
|
||||
and more.
|
||||
|
||||
The most simple use case of the basic viewer is the call of the global `draw()` function. There is one draw function for each \cgal package. Such a call opens a new interactive window showing the given model and allowing to navigate in the scene, show or hide some specific cells, show the interior of the model if any, etc.
|
||||
|
||||
The drawing can be tuned using `Graphics_scene_options`, for example to change the color of some cells or hide some cells.
|
||||
|
||||
More complex usage can be achieved by using the `Graphics_scene` class. Different \cgal data structures can be added in a same `Graphics_scene` allowing to visualize them simultaneously in a same window. Like for the draw function, the drawing parameters can be tuned thanks to the `Graphics_scene_options`.
|
||||
|
||||
Two classes are based on \qt.
|
||||
- `CGAL::Qt::Basic_viewer` is a \qt widget that inherits from `QGLViewer` (libQGLViewer is an open source C++ library based on \qt that eases the creation of OpenGL 3D viewers).
|
||||
- `CGAL::Qt::QApplication_and_basic_viewer` which regroups a `Qt::QApplication` and a `CGAL::Qt::Basic_viewer`.
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_SoftwareDesign Software Design
|
||||
|
||||
The diagram in \cgalFigureRef{fig_basic_viewer_diagram_class} shows the main classes and functions of this package.
|
||||
|
||||
\cgalFigureBegin{fig_basic_viewer_diagram_class,basic_viewer_diagramme_class.svg}
|
||||
UML diagram of the classes and functions of the package (only partial representation).
|
||||
\cgalFigureEnd
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_BasicUsage Basic Usage: The Global Draw Functions
|
||||
|
||||
A first simple solution provided to draw the different data structures of \cgal is the global `draw()` function. This function is templated by the type of the data structure to draw. The following example shows how it can be used.
|
||||
|
||||
\cgalExample{Basic_viewer/draw_lcc.cpp}
|
||||
|
||||
This example creates a 3D linear cell complex of a hexahedron, and draws it. The result is shown in the following figure.
|
||||
|
||||
\cgalFigureBegin{basic_viewer_ex1,lcc_draw.png}
|
||||
Example of drawing of a 3D LCC.
|
||||
\cgalFigureEnd
|
||||
|
||||
Users can interact with the viewer using some specific keys or mouse interactions. Pressing key 'h' makes pop up a help window showing the different shortcuts and mouse interactions. The main functionalities of the viewer are:
|
||||
|
||||
<ul>
|
||||
<li> Versatile Rendering:
|
||||
|
||||
The viewer supports the rendering of various geometric elements, such as points, edges, faces, rays, and lines.
|
||||
Different rendering modes, including mono and colored representation, are available for these elements.</li>
|
||||
|
||||
<li> Camera Control:
|
||||
|
||||
The viewer allows users to move the camera, switch between 2D and 3D viewing modes, adjusting the camera accordingly.
|
||||
Camera settings, such as orthographic or perspective projection, can be configured based on the dimension of the scene.</li>
|
||||
|
||||
<li> User Interaction:
|
||||
|
||||
Users can interact with the viewer through keyboard inputs, enabling them to control rendering options, toggle the display of elements, and adjust visual parameters.
|
||||
Key presses are mapped to specific actions, such as toggling the clipping plane, changing rendering modes, adjusting the size of elements, and modifying ambient light color.</li>
|
||||
|
||||
<li> Clipping Plane:
|
||||
|
||||
The viewer includes support for a clipping plane, enabling users to selectively render parts of the scene.
|
||||
The clipping plane can be toggled on and off, and its rendering style can be modified (solid, wireframe, etc.).</li>
|
||||
</ul>
|
||||
|
||||
\subsection BV_GraphicSceneOptions Tuning with Graphics Scene Options
|
||||
|
||||
There is one specialization of each draw function that takes graphics scene options as additional parameter, allowing to tune the drawing.
|
||||
|
||||
The `Graphics_scene_options` class provides a set of options and customization parameters for rendering geometric structures in a graphics scene. Its main purpose is to allow users to control the visual appearance of various cells such as vertices, edges, faces, and volumes in a graphical representation of a given data structure.
|
||||
|
||||
The following example shows how to use graphics scene options to tune the drawing of a surface mesh. We define our own class `My_graphics_scene_options` that inherits from `Graphics_scene_options` to get all the default parameters. In this class, we only override the two methods `colored_vertex` and `vertex_color` to draw all vertices in color, and chose randomly green or blue colors for one out of two vertices.
|
||||
|
||||
\cgalExample{Basic_viewer/draw_surface_mesh_vcolor.cpp}
|
||||
|
||||
The result of this example can be shown in \cgalFigureRef{basic_viewer_ex2}.
|
||||
|
||||
\cgalFigureBegin{basic_viewer_ex2,draw_surface_mesh_vcolor.png}
|
||||
Example of tuned drawing of a 3D surface mesh where some vertex colors are changed.
|
||||
\cgalFigureEnd
|
||||
|
||||
The drawing options can depend on the cells. In the following example the color of each face depends on its height.
|
||||
|
||||
\cgalExample{Basic_viewer/draw_surface_mesh_height.cpp}
|
||||
|
||||
The result of this example is shown in \cgalFigureRef{basic_viewer_ex3}.
|
||||
|
||||
\cgalFigureBegin{basic_viewer_ex3,draw_surface_height.png}
|
||||
Example of mesh drawing with a color for each face computed depending on its height.
|
||||
\cgalFigureEnd
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_GraphicsScene The Graphics Scene
|
||||
|
||||
It is possible to do more advanced visualizations by using the class `Graphics_scene`. It is a container class for various geometric elements, such as points, segments, rays, lines, faces and texts. It provides several methods to add elements, possibly with individual colors. Things are a little bit different for faces. You must call `face_begin()` to start a new face (possibly with a color), add all the points in the face by using `add_point_in_face()`, and call `face_end()` to finish the face. Note that the given polygonal face is internally triangulated.
|
||||
|
||||
This class also stores the normal of the faces (computed automatically), and possibly the normal of the vertices that can be provided by the users.
|
||||
|
||||
Users can either fill directly a `Graphics_scene` using these methods, or by using a global function `add_to_graphics_scene()` that fills the scene using all the geometric elements of a given \cgal data structure. Like for the draw functions, there is an overload of `add_to_graphics_scene()` for each \cgal package.
|
||||
|
||||
A `Graphics_scene` can be drawn using the basic viewer thanks to the `draw_graphics_scene()` function.
|
||||
|
||||
The following example shows in a same viewer both a `Point_set_3` and a `Polyhedron_3`. Note that, like the draw functions, each `add_to_graphics_scene()` can use an optional `Graphics_scene_options` as parameter allowing to tune the drawing of the given data structure. In the example, we change the color of all vertices of the point set.
|
||||
|
||||
\cgalExample{Basic_viewer/draw_mesh_and_points.cpp}
|
||||
|
||||
The result of this example is shown in \cgalFigureRef{basic_viewer_ex4} where we can see in green the original points of the point cloud, superposed with the polyhedron surface reconstructed by the Poisson surface reconstruction method.
|
||||
|
||||
\cgalFigureBegin{basic_viewer_ex4,draw_mesh_and_points.png}
|
||||
Example of drawing of a point cloud and a polyhedron in a same viewer.
|
||||
\cgalFigureEnd
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_BasicViewer The Basic Viewer Class
|
||||
|
||||
The class `CGAL::Qt::Basic_viewer` is a \qt widget that inherits from `QGLViewer` and mainly stores a `Graphics_scene` and allows to visualize it and interact with the scene. Since this class is a \qt widget, it can be used into more complex \qt code to create more advanced demos.
|
||||
|
||||
In the following example, we create two graphics scenes, one filled with a point cloud, a second one filled with the polyhedral surface reconstructed by the Poisson surface reconstruction method. Then, we create two basic viewers associated with these two scenes. The two basic viewers are added into a \qt layout allowing to visualize the two scenes side by side.
|
||||
|
||||
\cgalExample{Basic_viewer/draw_several_windows.cpp}
|
||||
|
||||
The result of this example is shown in \cgalFigureRef{basic_viewer_ex5}.
|
||||
|
||||
\cgalFigureBegin{basic_viewer_ex5,draw_several_windows.png}
|
||||
Example of drawing of two `Basic_viewer` side by side.
|
||||
\cgalFigureEnd
|
||||
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_Interactions Adding Interaction
|
||||
|
||||
In the previous examples, the models are only drawn once and there is no interaction with the user to update the drawing.
|
||||
|
||||
It is possible to define such interactions thanks to the class `CGAL::Qt::QApplication_and_basic_viewer`. In this class, you can define your own function that is called automatically by the viewer when a user presses a key. This can be used to change some parameters and update the drawing accordingly.
|
||||
|
||||
We illustrate this possibility in the following example that shows a surface mesh, while coloring the small faces in red. To do so, we use our own graphics scene options than change the color of a face depending on its size. A face is considered small if its size is below a certain threshold. This threshold can be updated by the user, pressing key 'I' to increase it and 'D' to decrease it. This is done in the key pressed function defined in the `QApplication_and_basic_viewer`. When the threshold changes, the graphics scene is recomputed to take the modification of the size threshold into account.
|
||||
|
||||
\cgalExample{Basic_viewer/draw_surface_mesh_small_faces.cpp}
|
||||
|
||||
The result of this example is shown in \cgalFigureRef{basic_viewer_ex6}, showing to the left the initial drawing of the 3D model, and to the right the same model after having changed the size threshold.
|
||||
|
||||
\cgalFigureBegin{basic_viewer_ex6,draw_surface_mesh_small_faces.png}
|
||||
Two examples of drawing of a mesh with small faces in red. <B>Left</B>: With the initial threshold. <B>Right</B>: After having increased the threshold.
|
||||
\cgalFigureEnd
|
||||
|
||||
<!-- /////////////////////////////////////////////////////////////////////////////// -->
|
||||
\section BV_Design Design and Implementation History
|
||||
|
||||
This package was started by Mostafa Ashraf during his 2022 GSoC project. Guillaume Damiand, who mentored the project, reworked large parts of the package, wrote examples and the manual.
|
||||
|
||||
*/
|
||||
|
||||
} /* namespace CGAL */
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
||||
The class `Graphics_scene` stores points, segments, triangles, rays, and lines. Elements can be added, possibly with associated colors. Non triangular faces can be directly added and are triangulated internally.
|
||||
|
||||
*/
|
||||
class Graphics_scene {
|
||||
public:
|
||||
/// adds the given point in the scene.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint>
|
||||
void add_point(const KPoint &p);
|
||||
|
||||
/// adds the given colored point in the scene.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint>
|
||||
void add_point(const KPoint &p, const CGAL::IO::Color &color);
|
||||
|
||||
/// adds the given segment in the scene.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint>
|
||||
void add_segment(const KPoint &p1, const KPoint &p2);
|
||||
|
||||
/// adds the given colored segment in the scene.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint>
|
||||
void add_segment(const KPoint &p1, const KPoint &p2,
|
||||
const CGAL::IO::Color &color);
|
||||
|
||||
/// adds the given ray in the scene: a half line starting from `p` and having `v` as direction.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
/// \tparam KVector a model of `Kernel::Vector_2` or `Kernel::Vector_3`.
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_ray(const KPoint &p, const KVector &v);
|
||||
|
||||
/// adds the given colored ray in the scene: a half line starting from `p` and having `v` as direction.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
/// \tparam KVector a model of `Kernel::Vector_2` or `Kernel::Vector_3`.
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_ray(const KPoint &p, const KVector &v,
|
||||
const CGAL::IO::Color &color);
|
||||
|
||||
/// adds the given line in the scene, defined by `p` and `v` as direction.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
/// \tparam KVector a model of `Kernel::Vector_2` or `Kernel::Vector_3`.
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_line(const KPoint &p, const KVector &v);
|
||||
|
||||
/// adds the given colored line in the scene, defined by `p` and `v` as direction.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
/// \tparam KVector a model of `Kernel::Vector_2` or `Kernel::Vector_3`.
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_line(const KPoint &p, const KVector &v,
|
||||
const CGAL::IO::Color &color);
|
||||
|
||||
/// starts a new face.
|
||||
void face_begin();
|
||||
|
||||
/// starts a new colored face.
|
||||
void face_begin(const CGAL::IO::Color &color);
|
||||
|
||||
/// return `true` iff a face is started.
|
||||
bool a_face_started() const;
|
||||
|
||||
/// adds the given point in the current face.
|
||||
/// @pre `a_face_started()`
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint> bool add_point_in_face(const KPoint &kp);
|
||||
|
||||
/// adds the given point in the current face, having the vertex normal.
|
||||
/// @pre `a_face_started()`
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
/// \tparam KVector a model of `Kernel::Vector_2` or `Kernel::Vector_3`.
|
||||
template <typename KPoint, typename KVector>
|
||||
bool add_point_in_face(const KPoint &kp, const KVector &p_normal);
|
||||
|
||||
/// ends the current face.
|
||||
/// @pre `a_face_started()`
|
||||
void face_end();
|
||||
|
||||
/// adds the given text at the given position in the scene.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint>
|
||||
void add_text(const KPoint &kp, const char *txt);
|
||||
|
||||
/// adds the given text at the given position in the scene.
|
||||
/// \tparam KPoint a model of `Kernel::Point_2`, `Kernel::Point_3`, `Kernel::WeightedPoint_2` or `Kernel::WeightedPoint_3`.
|
||||
template <typename KPoint>
|
||||
void add_text(const KPoint &kp, const std::string &txt);
|
||||
|
||||
/// returns `true` iff the scene has no element.
|
||||
bool empty() const;
|
||||
|
||||
/// clears the scene, i.e., removes all points, segments, triangles, and text.
|
||||
void clear();
|
||||
|
||||
/// returns the bounding box of all the elements in the scene.
|
||||
const CGAL::Bbox_3& bounding_box() const;
|
||||
|
||||
/// returns `true` if the scene is in 2D, i.e., lies on the XY or XZ or YZ plane.
|
||||
bool is_two_dimensional() const;
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
||||
The class `Graphics_scene_options` is used to tune the way that the cells of a given data structure of \cgal are considered.
|
||||
The different `std::function` can be modified to change for example the behavior of the drawing.
|
||||
`VolumeDescriptor` can be `void` for data structures that do not represent volumes.
|
||||
|
||||
This class is a model of `GraphicsSceneOptions` when `VolumeDescriptor` is `void`, or a model of `GraphicsSceneOptionsWithVolumes` otherwise (`VolumeDescriptor` non `void`).
|
||||
|
||||
\tparam DS a data structure of \cgal.
|
||||
\tparam VertexDescriptor a descriptor of vertices of `DS`.
|
||||
\tparam EdgeDescriptor a descriptor of edges of `DS`.
|
||||
\tparam FaceDescriptor a descriptor of faces of `DS`.
|
||||
\tparam VolumeDescriptor a descriptor of volumes of `DS`. `void` by default.
|
||||
|
||||
\cgalModels{GraphicsSceneOptions or GraphicsSceneOptionsWithVolumes}
|
||||
*/
|
||||
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor,
|
||||
typename VolumeDescriptor=void>
|
||||
struct Graphics_scene_options
|
||||
{
|
||||
public:
|
||||
typedef VertexDescriptor vertex_descriptor;
|
||||
typedef EdgeDescriptor edge_descriptor;
|
||||
typedef FaceDescriptor face_descriptor;
|
||||
typedef VolumeDescriptor volume_descriptor;
|
||||
|
||||
};
|
||||
|
||||
} // End namespace CGAL
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
namespace CGAL {
|
||||
namespace Qt {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
||||
The class `Basic_viewer` is a Qt widget based on `QGLViewer` that allows to visualize 3D elements: points, segments, triangles, rays and lines. This class stores a reference to a `Graphics_scene`. Elements are added through the scene. This class requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined. Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
|
||||
CGAL::QGLViewer is our internal fork of <a href="https://github.com/GillesDebunne/libQGLViewer">QGLViewer class</a> which is <em>A versatile 3D OpenGL viewer based on QOpenGLWidget</em>.
|
||||
*/
|
||||
class Basic_viewer : public CGAL::QGLViewer
|
||||
{
|
||||
public:
|
||||
/// Constructor given a pointer on a `QWidget` (can be a `nullptr`) and a `Graphics_scene`.
|
||||
/// `title` will be the title of the window.
|
||||
Basic_viewer(QWidget* parent,
|
||||
const Graphics_scene& scene,
|
||||
const char* title="");
|
||||
|
||||
/// enables or disables the drawing of vertices.
|
||||
void draw_vertices(bool b);
|
||||
|
||||
/// enables or disables the drawing of edges.
|
||||
void draw_edges(bool b);
|
||||
|
||||
/// enables or disables the drawing of rays.
|
||||
void draw_rays(bool b);
|
||||
|
||||
/// enables or disables the drawing of lines.
|
||||
void draw_lines(bool b);
|
||||
|
||||
/// enables or disables the drawing of faces.
|
||||
void draw_faces(bool b);
|
||||
|
||||
/// enables or disables the use of only one color (if `b` is `true`) or the use of multiple colors (if `b` is `false`).
|
||||
void use_mono_color(bool b);
|
||||
|
||||
/// enables or disables the drawing of texts.
|
||||
void draw_text(bool b);
|
||||
|
||||
/// sets the color used for vertices in mono color mode.
|
||||
void vertices_mono_color(const CGAL::IO::Color& c);
|
||||
|
||||
/// sets the color used for edges in mono color mode.
|
||||
void edges_mono_color(const CGAL::IO::Color& c);
|
||||
|
||||
/// sets the color used for rays in mono color mode.
|
||||
void rays_mono_color(const CGAL::IO::Color& c);
|
||||
|
||||
/// sets the color used for lines in mono color mode.
|
||||
void lines_mono_color(const CGAL::IO::Color& c);
|
||||
|
||||
/// sets the color used for faces in mono color mode.
|
||||
void faces_mono_color(const CGAL::IO::Color& c);
|
||||
|
||||
/// toggles the drawing of vertices.
|
||||
void toggle_draw_vertices();
|
||||
|
||||
/// toggles the drawing of edges.
|
||||
void toggle_draw_edges();
|
||||
|
||||
/// toggles the drawing of rays.
|
||||
void toggle_draw_rays();
|
||||
|
||||
/// toggles the drawing of lines.
|
||||
void toggle_draw_lines();
|
||||
|
||||
/// toggles the drawing of faces.
|
||||
void toggle_draw_faces();
|
||||
|
||||
/// toggles the use of mono color mode.
|
||||
void toggle_use_mono_color();
|
||||
|
||||
/// toggles the drawing of text.
|
||||
void toggle_draw_text();
|
||||
|
||||
/// returns `true` if vertices are drawn.
|
||||
bool draw_vertices() const;
|
||||
|
||||
/// returns `true` if edges are drawn.
|
||||
bool draw_edges() const;
|
||||
|
||||
/// returns `true` if rays are drawn.
|
||||
bool draw_rays() const;
|
||||
|
||||
/// returns `true` if lines are drawn.
|
||||
bool draw_lines() const;
|
||||
|
||||
/// returns `true` if faces are drawn.
|
||||
bool draw_faces() const;
|
||||
|
||||
/// returns `true` if mono color mode is used.
|
||||
bool use_mono_color() const;
|
||||
|
||||
/// returns `true` if normals are reversed.
|
||||
bool reverse_normal() const;
|
||||
|
||||
/// returns `true` if text are drawn.
|
||||
bool draw_text() const;
|
||||
|
||||
/// returns the mono color used for vertices.
|
||||
const CGAL::IO::Color& vertices_mono_color() const;
|
||||
|
||||
/// returns the mono color used for edges.
|
||||
const CGAL::IO::Color& edges_mono_color() const;
|
||||
|
||||
/// returns the mono color used for rays.
|
||||
const CGAL::IO::Color& rays_mono_color() const;
|
||||
|
||||
/// returns the mono color used for lines.
|
||||
const CGAL::IO::Color& lines_mono_color() const;
|
||||
|
||||
/// returns the mono color used for faces.
|
||||
const CGAL::IO::Color& faces_mono_color() const;
|
||||
|
||||
/// returns `true` if the clipping plane is enabled.
|
||||
bool clipping_plane_enabled() const;
|
||||
|
||||
/// returns the clipping plane when it is enabled.
|
||||
CGAL::Exact_predicates_inexact_constructions_kernel::Plane_3 clipping_plane() const;
|
||||
|
||||
/// returns the graphics scene of the viewer.
|
||||
const Graphics_scene& graphics_scene() const;
|
||||
|
||||
/// reverses all normals of vertices and faces.
|
||||
void reverse_all_normals();
|
||||
|
||||
/// draws the viewer without recomputing all internal buffers.
|
||||
virtual void draw();
|
||||
|
||||
/// redraws the viewer, i.e., recompute all internal buffers and update the window.
|
||||
virtual void redraw();
|
||||
|
||||
/// Function called when a key is pressed. Users can define their own function in order
|
||||
/// to add specific behavior.
|
||||
std::function<bool(QKeyEvent *, CGAL::Qt::Basic_viewer *)> on_key_pressed;
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
||||
The class `QApplication_and_basic_viewer` regroups a `Basic_viewer` and Qt `QApplication`. The `QApplication` is created in the constructor, but started by the `run()` method. This allows for example users to modify the `on_key_pressed` method of the `Basic_viewer` to define their own behavior.
|
||||
|
||||
This class requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined. Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
|
||||
*/
|
||||
class QApplication_and_basic_viewer
|
||||
{
|
||||
public:
|
||||
/// Constructor given a `Graphics_scene` and possibly a title.
|
||||
QApplication_and_basic_viewer(const CGAL::Graphics_scene& gs,
|
||||
const char* title="CGAL Basic Viewer");
|
||||
|
||||
/// runs the `QApplication`, i.e., open the Qt window. A call to this method is blocking, that is the program continues as soon as the user closes the window.
|
||||
void run();
|
||||
|
||||
/// returns a reference to the `Basic_viewer` associated with this.
|
||||
Basic_viewer& basic_viewer();
|
||||
};
|
||||
|
||||
} // End namespace Qt
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/*!
|
||||
\ingroup PkgBasicViewerClasses
|
||||
|
||||
opens a new window and draws the given `Graphics_scene` (which must have been filled before). `title` will be the title of the window. A call to this method is blocking, that is the program continues as soon as the user closes the window. This function requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined. Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition CGAL_USE_BASIC_VIEWER.
|
||||
*/
|
||||
void draw_graphics_scene(const Graphics_scene& graphic_scene,
|
||||
const char *title="CGAL Basic Viewer")
|
||||
{}
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
/*!
|
||||
\ingroup PkgBasicViewerConcepts
|
||||
|
||||
The concept `GraphicsSceneOptions` defines data and methods used to tune the way that the cells of a given data structure of \cgal are considered for drawing or to be added into a graphics scene.
|
||||
The different `std::function` can be modified to change for example the behavior of the drawing.
|
||||
|
||||
\cgalHasModelsBegin
|
||||
\cgalHasModelsBare{\link CGAL::Graphics_scene_options `CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>`\endlink}
|
||||
\cgalHasModelsEnd
|
||||
|
||||
*/
|
||||
class GraphicsSceneOptions
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
A data structure of \cgal.
|
||||
*/
|
||||
typedef unspecified_type DS;
|
||||
|
||||
/*!
|
||||
A descriptor of vertices of `DS`
|
||||
*/
|
||||
typedef unspecified_type vertex_descriptor;
|
||||
|
||||
/*!
|
||||
A descriptor of edges of `DS`
|
||||
*/
|
||||
typedef unspecified_type edge_descriptor;
|
||||
|
||||
/*!
|
||||
A descriptor of faces of `DS`
|
||||
*/
|
||||
typedef unspecified_type face_descriptor;
|
||||
|
||||
/// `std::function` that returns `true` if the given vertex must be ignored, `false` otherwise.
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, vertex_descriptor)> ignore_vertex;
|
||||
|
||||
/// `std::function` that returns `true` if the given edge must be ignored, `false` otherwise.
|
||||
/// Returns `true` by default.
|
||||
std::function<bool(const DS &, edge_descriptor)> ignore_edge;
|
||||
|
||||
/// `std::function` that returns `true` if the given face must be ignored, `false` otherwise.
|
||||
/// Returns `true` by default.
|
||||
std::function<bool(const DS &, face_descriptor)> ignore_face;
|
||||
|
||||
/// `std::function` that returns `true` if the given vertex is colored, `false` otherwise.
|
||||
/// Returns `false` by default.
|
||||
/// For non colored vertices, this is the role of the user of a graphic scene to decide which color must be used (cf. for example `Basic_viewer`, `vertices_mono_color`).
|
||||
std::function<bool(const DS &, vertex_descriptor)> is_vertex_colored;
|
||||
|
||||
/// `std::function` that returns `true` if the given edge is colored, `false` otherwise.
|
||||
/// For non colored edges, this is the role of the user of a graphic scene to decide which color must be used (cf. for example `Basic_viewer`, `edges_mono_color`).
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, edge_descriptor)> is_edge_colored;
|
||||
|
||||
/// `std::function` that returns `true` if the given face is colored, `false` otherwise.
|
||||
/// For non colored faces, this is the role of the user of a graphic scene to decide which color must be used (cf. for example `Basic_viewer`, `faces_mono_color`).
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, face_descriptor)> is_face_colored;
|
||||
|
||||
/// `std::function` that returns `true` if the given face is in wireframe, `false` otherwise.
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, face_descriptor)> is_face_wireframe;
|
||||
|
||||
/// `std::function` that returns the color of the given vertex.
|
||||
/// `nullptr` by default.
|
||||
std::function<CGAL::IO::Color(const DS &, vertex_descriptor)> vertex_color;
|
||||
|
||||
/// `std::function` that returns the color of the given edge.
|
||||
/// `nullptr` by default.
|
||||
std::function<CGAL::IO::Color(const DS &, edge_descriptor)> edge_color;
|
||||
|
||||
/// `std::function` that returns the color of the given face.
|
||||
/// `nullptr` by default.
|
||||
std::function<CGAL::IO::Color(const DS &, face_descriptor)> face_color;
|
||||
|
||||
/// ignores all vertices when `b` is `true`; otherwise ignores only vertices for which `ignore_vertex()` returns `true`.
|
||||
void ignore_all_vertices(bool b);
|
||||
|
||||
/// ignores all edges when `b` is `true`; otherwise ignores only edges for which `ignore_edge()` returns `true`.
|
||||
void ignore_all_edges(bool b);
|
||||
|
||||
/// ignores all faces when `b` is `true`; otherwise ignores only faces for which `ignore_face()` returns `true`.
|
||||
void ignore_all_faces(bool b);
|
||||
};
|
||||
|
||||
/*!
|
||||
\ingroup PkgBasicViewerConcepts
|
||||
\cgalConcept
|
||||
|
||||
The concept `GraphicsSceneOptionsWithVolumes` extends the concept `GraphicsSceneOptions` to deal with data structures that represent volumes.
|
||||
|
||||
\cgalRefines{GraphicsSceneOptions}
|
||||
|
||||
\cgalHasModelsBegin
|
||||
\cgalHasModelsBare{\link CGAL::Graphics_scene_options `CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor, VolumeDescriptor>`\endlink}
|
||||
\cgalHasModelsEnd
|
||||
|
||||
*/
|
||||
class GraphicsSceneOptionsWithVolumes
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
%A descriptor of volumes of `DS`.
|
||||
*/
|
||||
typedef unspecified_type volume_descriptor;
|
||||
|
||||
/// `std::function` that returns `true` if the given volume must be ignored, `false` otherwise.
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, volume_descriptor)> ignore_volume;
|
||||
|
||||
/// `std::function` that returns `true` if the given volume is colored, `false` otherwise.
|
||||
/// For non colored volumes, this is the role of the user of a graphic scene to decide which color must be used (cf. for example `Basic_viewer`, `faces_mono_color`).
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, volume_descriptor)> is_volume_colored;
|
||||
|
||||
/// `std::function` that returns `true` if the given volume is in wireframe, `false` otherwise.
|
||||
/// Returns `false` by default.
|
||||
std::function<bool(const DS &, volume_descriptor)> is_volume_wireframe;
|
||||
|
||||
/// `std::function` that returns the color of the given volume, i.e. the color of all the faces of this volume.
|
||||
/// `nullptr` by default.
|
||||
std::function<CGAL::IO::Color(const DS &, volume_descriptor)> volume_color;
|
||||
|
||||
/// ignores all volumes when `b` is `true`; otherwise ignore only volumes for which `ignore_volume()` returns `true`.
|
||||
void ignore_all_volumes(bool b);
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}
|
||||
|
||||
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - CGAL Basic Viewer"
|
||||
|
||||
EXAMPLE_PATH += ${CGAL_Surface_mesh_EXAMPLE_DIR}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/// \defgroup PkgBasicViewerRef Basic Viewer Reference
|
||||
|
||||
/// \defgroup PkgBasicViewerConcepts Concepts
|
||||
/// \ingroup PkgBasicViewerRef
|
||||
|
||||
/// \defgroup PkgBasicViewerClasses Classes
|
||||
/// \ingroup PkgBasicViewerRef
|
||||
|
||||
/*!
|
||||
\addtogroup PkgBasicViewerRef
|
||||
\cgalPkgDescriptionBegin{Basic Viewer,PkgBasicViewer}
|
||||
\cgalPkgPicture{basic_viewer_logo.png}
|
||||
\cgalPkgSummaryBegin
|
||||
\cgalPkgAuthor{Guillaume Damiand and Mostafa Ashraf}
|
||||
\cgalPkgDesc{This package provides interactive visualization for most \cgal packages.
|
||||
First, the function `draw()` is provided for each data structure.
|
||||
Several data structures can be added to a same graphics scene and visualized simultaneously.
|
||||
Rendering can be controlled (color, point size, etc.).
|
||||
Finally a \qt widget is provided that can be integrated in the GUI of a user application.}
|
||||
\cgalPkgManuals{Chapter_Basic_viewer,PkgBasicViewerRef}
|
||||
\cgalPkgSummaryEnd
|
||||
\cgalPkgShortInfoBegin
|
||||
\cgalPkgSince{6.0}
|
||||
\cgalPkgBib{cgal:d-bv}
|
||||
\cgalPkgLicense{\ref licensesLGPL "LGPL"}
|
||||
\cgalPkgShortInfoEnd
|
||||
\cgalPkgDescriptionEnd
|
||||
|
||||
\cgalClassifedRefPages
|
||||
|
||||
\cgalCRPSection{Concepts}
|
||||
- `GraphicsSceneOptions`
|
||||
- `GraphicsSceneOptionsWithVolumes`
|
||||
|
||||
\cgalCRPSection{Classes}
|
||||
- `CGAL::Qt::Basic_viewer`
|
||||
- `CGAL::Graphics_scene`
|
||||
- `CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor, VolumeDescriptor>`
|
||||
- `CGAL::Qt::QApplication_and_basic_viewer`
|
||||
|
||||
\cgalCRPSubsection{Draw a Graphics Scene}
|
||||
|
||||
- `CGAL::draw_graphics_scene()`
|
||||
|
||||
\cgalCRPSubsection{Draw for Different Packages}
|
||||
|
||||
- `CGAL::Arrangement_2` \link PkgArrangementOnSurface2Draw CGAL::draw<ARR>() \endlink
|
||||
- `CGAL::Constrained_triangulation_2` \link PkgDrawTriangulation2 CGAL::draw<CT2>() \endlink
|
||||
- `CGAL::Linear_cell_complex_for_combinatorial_map` \link PkgDrawLinearCellComplex CGAL::draw<LCC>() \endlink
|
||||
- `CGAL::Linear_cell_complex_for_generalized_map` \link PkgDrawLinearCellComplex CGAL::draw<LCC>() \endlink
|
||||
- `CGAL::Nef_polyhedron_3` \link PkgDrawNef3 CGAL::draw<Nef3>() \endlink
|
||||
- `CGAL::Periodic_2_triangulation_2` \link PkgDrawPeriodic2Triangulation2 CGAL::draw<P2T2>() \endlink
|
||||
- `CGAL::Point_set_3` \link PkgDrawPointSet3D CGAL::draw<PS>() \endlink
|
||||
- `CGAL::Polygon_2` \link PkgDrawPolygon2 CGAL::draw<P2>() \endlink
|
||||
- `CGAL::Polygon_set_2` \link PkgDrawPolygonSet2 CGAL::draw<PS>() \endlink
|
||||
- `CGAL::Polygon_with_holes_2` \link PkgDrawPolygonWithHoles2 CGAL::draw<PH2>() \endlink
|
||||
- `CGAL::Polyhedron_3` \link PkgDrawPolyhedron CGAL::draw<POLY>() \endlink
|
||||
- `CGAL::Surface_mesh` \link PkgDrawSurfaceMesh CGAL::draw<SM>() \endlink
|
||||
- `CGAL::Surface_mesh_topology` \link PkgDrawFaceGraphWithPaths CGAL::draw<SMT>() \endlink
|
||||
- `CGAL::Triangulation_2` \link PkgDrawTriangulation2 CGAL::draw<T2>() \endlink
|
||||
- `CGAL::Triangulation_3` \link PkgDrawTriangulation3 CGAL::draw<T3>() \endlink
|
||||
- `CGAL::Voronoi_diagram_2` \link PkgDrawVoronoiDiagram2 CGAL::draw<V2>() \endlink
|
||||
|
||||
\cgalCRPSubsection{Fill Graphics Scene for Different Packages}
|
||||
|
||||
- `CGAL::Arrangement_2` \link PkgArrangementOnSurface2Draw CGAL::add_to_graphics_scene<ARR>() \endlink
|
||||
- `CGAL::Constrained_triangulation_2` \link PkgDrawTriangulation2 CGAL::add_to_graphics_scene<CT2>() \endlink
|
||||
- `CGAL::Linear_cell_complex_for_combinatorial_map` \link PkgDrawLinearCellComplex CGAL::add_to_graphics_scene<LCC>() \endlink
|
||||
- `CGAL::Linear_cell_complex_for_generalized_map` \link PkgDrawLinearCellComplex CGAL::add_to_graphics_scene<LCC>() \endlink
|
||||
- `CGAL::Nef_polyhedron_3` \link PkgDrawNef3 CGAL::add_to_graphics_scene<Nef3>() \endlink
|
||||
- `CGAL::Periodic_2_triangulation_2` \link PkgDrawPeriodic2Triangulation2 CGAL::add_to_graphics_scene<P2T2>() \endlink
|
||||
- `CGAL::Point_set_3` \link PkgDrawPointSet3D CGAL::add_to_graphics_scene<PS>() \endlink
|
||||
- `CGAL::Polygon_2` \link PkgDrawPolygon2 CGAL::add_to_graphics_scene<P2>() \endlink
|
||||
- `CGAL::Polygon_set_2` \link PkgDrawPolygonSet2 CGAL::add_to_graphics_scene<PS>() \endlink
|
||||
- `CGAL::Polygon_with_holes_2` \link PkgDrawPolygonWithHoles2 CGAL::add_to_graphics_scene<PH2>() \endlink
|
||||
- `CGAL::Polyhedron_3` \link PkgDrawPolyhedron CGAL::add_to_graphics_scene<POLY>() \endlink
|
||||
- `CGAL::Surface_mesh` \link PkgDrawSurfaceMesh CGAL::add_to_graphics_scene<SM>() \endlink
|
||||
- `CGAL::Surface_mesh_topology` \link PkgDrawFaceGraphWithPaths CGAL::add_to_graphics_scene<SMT>() \endlink
|
||||
- `CGAL::Triangulation_2` \link PkgDrawTriangulation2 CGAL::add_to_graphics_scene<T2>() \endlink
|
||||
- `CGAL::Triangulation_3` \link PkgDrawTriangulation3 CGAL::add_to_graphics_scene<T3>() \endlink
|
||||
- `CGAL::Voronoi_diagram_2` \link PkgDrawVoronoiDiagram2 CGAL::add_to_graphics_scene<V2>() \endlink
|
||||
|
||||
*/
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Manual
|
||||
Boolean_set_operations_2
|
||||
Linear_cell_complex
|
||||
Nef_3
|
||||
Periodic_2_triangulation_2
|
||||
Point_set_3
|
||||
Polygon
|
||||
Polyhedron
|
||||
Straight_skeleton_2
|
||||
Surface_mesh
|
||||
Surface_mesh_topology
|
||||
Triangulation_2
|
||||
Triangulation_3
|
||||
Voronoi_diagram_2
|
||||
Kernel_23
|
||||
Arrangement_on_surface_2
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/*!
|
||||
\example Basic_viewer/draw_lcc.cpp
|
||||
\example Basic_viewer/draw_mesh_and_points.cpp
|
||||
\example Basic_viewer/draw_several_windows.cpp
|
||||
\example Basic_viewer/draw_surface_mesh_small_faces.cpp
|
||||
\example Basic_viewer/draw_surface_mesh_height.cpp
|
||||
\example Basic_viewer/draw_surface_mesh_vcolor.cpp
|
||||
*/
|
||||
|
|
@ -0,0 +1,530 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Creator: fig2dev Version 3.2.8 -->
|
||||
|
||||
<!-- CreationDate: 2022-05-05 19:05:07 -->
|
||||
|
||||
<!-- Magnification: 1.05 -->
|
||||
|
||||
<svg
|
||||
width="541.81927pt"
|
||||
height="360.14355pt"
|
||||
viewBox="3588 5001 8596.4836 5695.9546"
|
||||
version="1.1"
|
||||
id="svg58"
|
||||
sodipodi:docname="basic_viewer_diagramme_class.svg"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs62" />
|
||||
<sodipodi:namedview
|
||||
id="namedview60"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:document-units="pt"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.62947469"
|
||||
inkscape:cx="453.55278"
|
||||
inkscape:cy="92.934633"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1016"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g56"
|
||||
fit-margin-top="2"
|
||||
fit-margin-left="2"
|
||||
fit-margin-right="2"
|
||||
fit-margin-bottom="2" />
|
||||
<g
|
||||
fill="none"
|
||||
id="g56"
|
||||
transform="translate(-78.839594,-95.293061)">
|
||||
<!-- Line -->
|
||||
<polyline
|
||||
points=" 8767,8032 11121,8032"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline2"
|
||||
transform="matrix(1.2650893,0,0,1,-7207.9957,-2499.9188)" />
|
||||
<!-- Line -->
|
||||
<polyline
|
||||
points=" 8767,8442 11121,8442"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline4"
|
||||
transform="matrix(1.2650893,0,0,1,-7207.9957,-2833.1034)" />
|
||||
<!-- Line -->
|
||||
<rect
|
||||
x="3884.8591"
|
||||
y="5124.895"
|
||||
width="2985.0176"
|
||||
height="1619.5436"
|
||||
stroke="#000000"
|
||||
stroke-width="11.6285px"
|
||||
id="rect6" />
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<polyline
|
||||
points=" 3600,7623 7539,7623"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline14"
|
||||
transform="matrix(0.85616562,0,0,1,620.19716,800.9418)" />
|
||||
<!-- Line -->
|
||||
<polyline
|
||||
points=" 3600,8288 7539,8288"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline16"
|
||||
transform="matrix(0.85616562,0,0,1,620.19716,205.96854)" />
|
||||
<!-- Line -->
|
||||
<rect
|
||||
x="3703.8889"
|
||||
y="8016.6836"
|
||||
width="3369.4456"
|
||||
height="2747.6394"
|
||||
stroke="#000000"
|
||||
stroke-width="10.6348px"
|
||||
id="rect18" />
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<!-- Text -->
|
||||
<!-- Text -->
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="4156.0391"
|
||||
y="5409.6846"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="216px"
|
||||
text-anchor="start"
|
||||
id="text30">Basic_viewer</text>
|
||||
<!-- Text -->
|
||||
<!-- Text -->
|
||||
<!-- Text -->
|
||||
<!-- Text -->
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="4009.3933"
|
||||
y="8321.9365"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="216px"
|
||||
text-anchor="start"
|
||||
id="text38"
|
||||
style="font-style:normal;font-weight:bold;font-size:216px;font-family:Times;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan2148"
|
||||
x="4009.3933"
|
||||
y="8321.9365">Graphics_scene</tspan></text>
|
||||
<!-- Text -->
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="8751.333"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text40"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7344"
|
||||
x="3768.7371"
|
||||
y="8751.333">+ void add_point(apoint)</tspan></text>
|
||||
<!-- Text -->
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="8989.0332"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324"
|
||||
x="3768.7371"
|
||||
y="8989.0332">+ void add_point(apoint, acolor)</tspan></text>
|
||||
<!-- Text -->
|
||||
<!-- Text -->
|
||||
<!-- Line -->
|
||||
<!-- Line -->
|
||||
<!-- Text -->
|
||||
<!-- Text -->
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="9464.3486"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-5"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-2"
|
||||
x="3768.7371"
|
||||
y="9464.3486">+ void add_segment(apoint1, apoint2, acolor)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="9226.6484"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text9538-6"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan9536-5"
|
||||
x="3768.7371"
|
||||
y="9226.6484">+ void add_segment(apoint1, apoint2)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="9939.749"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-8"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-7"
|
||||
x="3768.7371"
|
||||
y="9939.749">+ void face_begin(acolor)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="10177.532"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text9538-9"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan9536-6"
|
||||
x="3768.7371"
|
||||
y="10177.532">+ void add_point_in_face(apoint)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="9702.0488"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-8-0"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-7-4"
|
||||
x="3768.7371"
|
||||
y="9702.0488">+ void face_begin()</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3768.7371"
|
||||
y="10418.341"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-8-0-1"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-7-4-0"
|
||||
x="3768.7371"
|
||||
y="10418.341">+ void face_end()</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3767.3931"
|
||||
y="10623.868"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-8-0-1-4"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-7-4-0-8"
|
||||
x="3767.3931"
|
||||
y="10623.868">...</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="3956.3384"
|
||||
y="5791.0234"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text40-5"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
x="3956.3384"
|
||||
y="5791.0234"
|
||||
id="tspan47993">+ Basic_viewer (QWidget *parent, </tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="3956.3384"
|
||||
y="6001.0234"
|
||||
id="tspan52579"> const Graphics_scene &scene)</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="3956.3384"
|
||||
y="6211.0234"
|
||||
id="tspan47991">+ void draw()</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="3956.3384"
|
||||
y="6421.0234"
|
||||
id="tspan57880">+ void redraw()</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="3956.3384"
|
||||
y="6631.0234"
|
||||
id="tspan33081">...</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="3956.3384"
|
||||
y="6841.0234"
|
||||
id="tspan57882" /></text>
|
||||
<polyline
|
||||
points=" 7949,8186 8767,8186"
|
||||
stroke="#000000"
|
||||
stroke-width="15px"
|
||||
id="polyline22-9"
|
||||
transform="rotate(90,7123.8213,6350.0005)" />
|
||||
<polyline
|
||||
points=" 7538,8183 7770,8083 7962,8175 7759,8283"
|
||||
fill="#000000"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline24-2"
|
||||
transform="rotate(90,7124.8213,6338.0005)" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="5433.3027"
|
||||
y="7344.6426"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="normal"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text44-9">1</text>
|
||||
<polyline
|
||||
points=" 8767,8032 11121,8032"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline2-8"
|
||||
transform="matrix(1.3689538,0,0,1,-3024.9589,-2462.3583)" />
|
||||
<polyline
|
||||
points=" 8767,8442 11121,8442"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline4-3"
|
||||
transform="matrix(1.3689538,0,0,1,-3024.9589,-2795.5429)" />
|
||||
<rect
|
||||
x="8978.1094"
|
||||
y="5161.9849"
|
||||
width="3231.1121"
|
||||
height="1366.4115"
|
||||
stroke="#000000"
|
||||
stroke-width="11.1127px"
|
||||
id="rect6-8" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="9106.8584"
|
||||
y="5447.2471"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="216px"
|
||||
text-anchor="start"
|
||||
id="text30-0">QApplication_and_basic_viewer</text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="9049.9512"
|
||||
y="5828.5859"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text40-5-4"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
x="9049.9512"
|
||||
y="5828.5859"
|
||||
id="tspan47993-0">+ QApplication_and_basic_viewer </tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="9049.9512"
|
||||
y="6038.5859"
|
||||
id="tspan52579-9"> (const Graphics_scene &scene)</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="9049.9512"
|
||||
y="6248.5859"
|
||||
id="tspan47991-1">+ void run()</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="9049.9512"
|
||||
y="6458.5859"
|
||||
id="tspan57880-9">+ Basic_viewer & basic_viewer ()</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="9049.9512"
|
||||
y="6668.5859"
|
||||
id="tspan57882-6" /></text>
|
||||
<polyline
|
||||
points=" 7538,8183 7770,8083 7962,8175 7759,8283"
|
||||
fill="#000000"
|
||||
stroke="#000000"
|
||||
stroke-width="8px"
|
||||
id="polyline24-5"
|
||||
transform="translate(1014.6591,-2528.5429)" />
|
||||
<polyline
|
||||
points=" 7949,8186 8767,8186"
|
||||
stroke="#000000"
|
||||
stroke-width="15px"
|
||||
id="polyline22-2"
|
||||
transform="matrix(2.0441703,0,0,1,-9368.5817,-2531.5429)" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="8708.2236"
|
||||
y="5420.084"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="normal"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text44-9-9">1</text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="7613.1177"
|
||||
y="8591.8506"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-7"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-4"
|
||||
x="7613.1177"
|
||||
y="8591.8506">void draw_graphics_scene(const Graphics_scene& gs)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="7613.1177"
|
||||
y="7146.8569"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-3"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-1"
|
||||
x="7613.1177"
|
||||
y="7146.8569">void draw(const DS& ds)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:475.979px;line-height:125%;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:11.8995px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="9215.251"
|
||||
y="8059.1812"
|
||||
id="text63405"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan63403"
|
||||
style="stroke-width:11.8995px"
|
||||
x="9215.251"
|
||||
y="8059.1812"></tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="7613.1177"
|
||||
y="7505.7114"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-3-2"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-1-6"
|
||||
x="7613.1177"
|
||||
y="7505.7114">void draw(const DS& ds, const Graphics_scene_option& gso)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="7613.1177"
|
||||
y="7867.7578"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-3-1"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-1-2"
|
||||
x="7613.1177"
|
||||
y="7867.7578">void add_to_graphics_scene(const DS& ds, Graphics_scene& gs)</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
x="7616.6455"
|
||||
y="8124.8047"
|
||||
fill="#000000"
|
||||
font-family="Times"
|
||||
font-style="normal"
|
||||
font-weight="bold"
|
||||
font-size="168px"
|
||||
text-anchor="start"
|
||||
id="text42-3-1-8"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:168px;font-family:Times;-inkscape-font-specification:'Times, Bold';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-anchor:start;fill:#000000"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7324-1-2-8"
|
||||
x="7616.6455"
|
||||
y="8124.8047">void add_to_graphics_scene(const DS& ds, Graphics_scene& gs, </tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="7616.6455"
|
||||
y="8334.8047"
|
||||
id="tspan92018"> const Graphics_scene_option& gso)</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
|
@ -0,0 +1,41 @@
|
|||
# Created by the script cgal_create_cmake_script
|
||||
# This is the CMake script for compiling a CGAL application.
|
||||
|
||||
#/!\ /!\
|
||||
#/!\ /!\
|
||||
# Used in /CGAL/Documentation/doc/Documentation/Developer_manual/create_and_use_a_cmakelist.txt.
|
||||
# Careful when modifying
|
||||
|
||||
cmake_minimum_required(VERSION 3.1...3.23)
|
||||
project(Basic_viewer_Examples)
|
||||
|
||||
#CGAL_Qt6 is needed for the drawing.
|
||||
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt6)
|
||||
find_package(Eigen3 3.1.0)
|
||||
include(CGAL_Eigen3_support)
|
||||
|
||||
create_single_source_cgal_program("draw_lcc.cpp")
|
||||
create_single_source_cgal_program("draw_mesh_and_points.cpp")
|
||||
create_single_source_cgal_program("draw_several_windows.cpp")
|
||||
create_single_source_cgal_program("draw_surface_mesh_height.cpp")
|
||||
create_single_source_cgal_program("draw_surface_mesh_small_faces.cpp")
|
||||
create_single_source_cgal_program("draw_surface_mesh_vcolor.cpp")
|
||||
|
||||
if(CGAL_Qt6_FOUND)
|
||||
#link it with the required CGAL libraries
|
||||
target_link_libraries(draw_lcc PUBLIC CGAL::CGAL_Basic_viewer)
|
||||
target_link_libraries(draw_mesh_and_points PUBLIC CGAL::CGAL_Basic_viewer)
|
||||
target_link_libraries(draw_several_windows PUBLIC CGAL::CGAL_Basic_viewer)
|
||||
target_link_libraries(draw_surface_mesh_height PUBLIC CGAL::CGAL_Basic_viewer)
|
||||
target_link_libraries(draw_surface_mesh_small_faces PUBLIC CGAL::CGAL_Basic_viewer)
|
||||
target_link_libraries(draw_surface_mesh_vcolor PUBLIC CGAL::CGAL_Basic_viewer)
|
||||
else()
|
||||
message("CGAL_Qt6 not configured: examples that require Qt will not be compiled.")
|
||||
endif()
|
||||
|
||||
if(TARGET CGAL::Eigen3_support)
|
||||
target_link_libraries(draw_mesh_and_points PUBLIC CGAL::Eigen3_support)
|
||||
target_link_libraries(draw_several_windows PUBLIC CGAL::Eigen3_support)
|
||||
endif()
|
||||
|
||||
#end of the file
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
|
||||
#include <CGAL/draw_linear_cell_complex.h>
|
||||
|
||||
using LCC=CGAL::Linear_cell_complex_for_combinatorial_map<3>;
|
||||
using Point=LCC::Point;
|
||||
|
||||
int main()
|
||||
{
|
||||
LCC lcc;
|
||||
lcc.make_hexahedron(Point(0,0,0), Point(5,0,0),
|
||||
Point(5,5,0), Point(0,5,0),
|
||||
Point(0,5,4), Point(0,0,4),
|
||||
Point(5,0,4), Point(5,5,4));
|
||||
CGAL::draw(lcc);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/poisson_surface_reconstruction.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/draw_polyhedron.h>
|
||||
#include <CGAL/draw_point_set_3.h>
|
||||
#include <CGAL/Graphics_scene_options.h>
|
||||
#include <CGAL/Qt/Basic_viewer.h>
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
using Kernel=CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Point=Kernel::Point_3;
|
||||
using Vector=Kernel::Vector_3;
|
||||
using Pwn=std::pair<Point, Vector>;
|
||||
using Polyhedron=CGAL::Polyhedron_3<Kernel>;
|
||||
using PS3=CGAL::Point_set_3<Point>;
|
||||
|
||||
struct Graphics_scene_options_green_points:
|
||||
public CGAL::Graphics_scene_options<PS3, typename PS3::const_iterator,
|
||||
typename PS3::const_iterator,
|
||||
typename PS3::const_iterator>
|
||||
{
|
||||
bool colored_vertex(const PS3&, typename PS3::const_iterator) const
|
||||
{ return true; }
|
||||
CGAL::IO::Color vertex_color(const PS3&, typename PS3::const_iterator) const
|
||||
{ return CGAL::IO::Color(0,220,0); }
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::vector<Pwn> points;
|
||||
|
||||
if(!CGAL::IO::read_points(CGAL::data_file_path("points_3/kitten.xyz"), std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read input file " << CGAL::data_file_path("points_3/kitten.xyz") << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Polyhedron output_mesh;
|
||||
|
||||
double average_spacing = CGAL::compute_average_spacing<CGAL::Sequential_tag>
|
||||
(points, 6, CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()));
|
||||
|
||||
if (CGAL::poisson_surface_reconstruction_delaunay
|
||||
(points.begin(), points.end(),
|
||||
CGAL::First_of_pair_property_map<Pwn>(),
|
||||
CGAL::Second_of_pair_property_map<Pwn>(),
|
||||
output_mesh, average_spacing))
|
||||
{
|
||||
PS3 point_set;
|
||||
for(Pwn& it: points)
|
||||
{ point_set.insert(it.first); }
|
||||
|
||||
CGAL::Graphics_scene scene;
|
||||
CGAL::add_to_graphics_scene(point_set, scene, Graphics_scene_options_green_points());
|
||||
CGAL::add_to_graphics_scene(output_mesh, scene);
|
||||
CGAL::draw_graphics_scene(scene);
|
||||
}
|
||||
else
|
||||
{ return EXIT_FAILURE; }
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/poisson_surface_reconstruction.h>
|
||||
#include <CGAL/IO/read_points.h>
|
||||
#include <CGAL/draw_polyhedron.h>
|
||||
#include <CGAL/draw_point_set_3.h>
|
||||
#include <CGAL/Graphics_scene_options.h>
|
||||
#include <CGAL/Qt/Basic_viewer.h>
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
#include <QMainWindow>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
using Kernel=CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Point=Kernel::Point_3;
|
||||
using Vector=Kernel::Vector_3;
|
||||
using Pwn=std::pair<Point, Vector>;
|
||||
using Polyhedron=CGAL::Polyhedron_3<Kernel>;
|
||||
using PS3=CGAL::Point_set_3<Point>;
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/// (1) Some CGAL code that create data structures and fill two Graphics_scene.
|
||||
std::vector<Pwn> points;
|
||||
|
||||
if(!CGAL::IO::read_points(CGAL::data_file_path("points_3/kitten.xyz"), std::back_inserter(points),
|
||||
CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>())
|
||||
.normal_map(CGAL::Second_of_pair_property_map<Pwn>())))
|
||||
{
|
||||
std::cerr << "Error: cannot read input file " << CGAL::data_file_path("points_3/kitten.xyz") << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Polyhedron output_mesh;
|
||||
|
||||
double average_spacing = CGAL::compute_average_spacing<CGAL::Sequential_tag>
|
||||
(points, 6, CGAL::parameters::point_map(CGAL::First_of_pair_property_map<Pwn>()));
|
||||
|
||||
if (!CGAL::poisson_surface_reconstruction_delaunay
|
||||
(points.begin(), points.end(),
|
||||
CGAL::First_of_pair_property_map<Pwn>(),
|
||||
CGAL::Second_of_pair_property_map<Pwn>(),
|
||||
output_mesh, average_spacing))
|
||||
{ return EXIT_FAILURE; }
|
||||
|
||||
PS3 point_set;
|
||||
for(Pwn& it: points)
|
||||
{ point_set.insert(it.first); }
|
||||
|
||||
CGAL::Graphics_scene scene1, scene2;
|
||||
CGAL::add_to_graphics_scene(point_set, scene1);
|
||||
CGAL::add_to_graphics_scene(output_mesh, scene2);
|
||||
|
||||
/// (2) Qt code that create windows, add them in a layout, and create app.
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite=true;
|
||||
#else
|
||||
bool cgal_test_suite=qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (cgal_test_suite) { return EXIT_SUCCESS; }
|
||||
|
||||
int argc=1;
|
||||
const char* argv[2]={"Draw several windows example","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
||||
QMainWindow* mainWindow=new QMainWindow;
|
||||
QWidget *centralWidget = new QWidget(mainWindow);
|
||||
QHBoxLayout* layout = new QHBoxLayout(mainWindow);
|
||||
|
||||
CGAL::Qt::Basic_viewer bv1(mainWindow, scene1);
|
||||
CGAL::Qt::Basic_viewer bv2(mainWindow, scene2);
|
||||
bv1.draw_vertices(true);
|
||||
|
||||
layout->addWidget(&bv1);
|
||||
layout->addWidget(&bv2);
|
||||
|
||||
centralWidget->setLayout(layout);
|
||||
mainWindow->setCentralWidget(centralWidget);
|
||||
|
||||
mainWindow->show();
|
||||
app.exec();
|
||||
#endif
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/draw_surface_mesh.h>
|
||||
#include <CGAL/Graphics_scene_options.h>
|
||||
#include <iostream>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
typedef CGAL::Surface_mesh<Point> Mesh;
|
||||
|
||||
struct Colored_faces_given_height:
|
||||
public CGAL::Graphics_scene_options<Mesh,
|
||||
typename Mesh::Vertex_index,
|
||||
typename Mesh::Edge_index,
|
||||
typename Mesh::Face_index>
|
||||
{
|
||||
Colored_faces_given_height(const Mesh& sm)
|
||||
{
|
||||
if(sm.is_empty()) return;
|
||||
|
||||
double m_min_y=0., m_max_y=0.;
|
||||
bool first=true;
|
||||
for(typename Mesh::Vertex_index vi: sm.vertices())
|
||||
{
|
||||
if(first)
|
||||
{ m_min_y=sm.point(vi).y(); m_max_y=m_min_y; first=false; }
|
||||
else
|
||||
{
|
||||
m_min_y=(std::min)(m_min_y, sm.point(vi).y());
|
||||
m_max_y=(std::max)(m_max_y, sm.point(vi).y());
|
||||
}
|
||||
}
|
||||
|
||||
this->colored_face=[](const Mesh &, typename Mesh::Face_index)->bool { return true; };
|
||||
|
||||
this->face_color=[m_min_y, m_max_y]
|
||||
(const Mesh& sm, typename Mesh::Face_index fi)->CGAL::IO::Color
|
||||
{
|
||||
double res=0.;
|
||||
std::size_t n=0;
|
||||
for(typename Mesh::Vertex_index vi: vertices_around_face(sm.halfedge(fi), sm))
|
||||
{
|
||||
res+=sm.point(vi).y();
|
||||
++n;
|
||||
}
|
||||
// Random color depending on the "height" of the facet
|
||||
CGAL::Random random(static_cast<unsigned int>(30*((res/n)-m_min_y)/(m_max_y-m_min_y)));
|
||||
return CGAL::get_random_color(random);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/elephant.off");
|
||||
|
||||
Mesh sm;
|
||||
if(!CGAL::IO::read_polygon_mesh(filename, sm))
|
||||
{
|
||||
std::cerr << "Invalid input file: " << filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL::draw(sm, Colored_faces_given_height(sm));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <CGAL/draw_surface_mesh.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
|
||||
typedef Mesh::Vertex_index vertex_descriptor;
|
||||
typedef Mesh::Face_index face_descriptor;
|
||||
typedef K::FT FT;
|
||||
|
||||
template<class SM>
|
||||
struct Graphics_scene_options_small_faces:
|
||||
public CGAL::Graphics_scene_options<SM,
|
||||
typename boost::graph_traits<SM>::vertex_descriptor,
|
||||
typename boost::graph_traits<SM>::edge_descriptor,
|
||||
typename boost::graph_traits<SM>::face_descriptor>
|
||||
{
|
||||
using Base=CGAL::Graphics_scene_options<SM,
|
||||
typename boost::graph_traits<SM>::vertex_descriptor,
|
||||
typename boost::graph_traits<SM>::edge_descriptor,
|
||||
typename boost::graph_traits<SM>::face_descriptor>;
|
||||
|
||||
Graphics_scene_options_small_faces(const SM& sm): Base(), m_sm(sm)
|
||||
{
|
||||
typename SM::template Property_map<face_descriptor, FT> faces_size;
|
||||
boost::tie(faces_size, m_with_size)=sm.template property_map<face_descriptor, FT>("f:size");
|
||||
if(!m_with_size)
|
||||
{ return; }
|
||||
|
||||
m_min_size=faces_size[*(sm.faces().begin())];
|
||||
m_max_size=m_min_size;
|
||||
FT cur_size;
|
||||
for (typename SM::Face_range::iterator f=sm.faces().begin(); f!=sm.faces().end(); ++f)
|
||||
{
|
||||
cur_size=faces_size[*f];
|
||||
if (cur_size<m_min_size) m_min_size=cur_size;
|
||||
if (cur_size>m_max_size) m_max_size=cur_size;
|
||||
}
|
||||
|
||||
this->face_color=[=](const SM& sm,
|
||||
typename boost::graph_traits<SM>::face_descriptor fh) -> CGAL::IO::Color
|
||||
{ return this->get_face_color(sm, fh); };
|
||||
|
||||
this->colored_face = [](const SM&,
|
||||
typename boost::graph_traits<SM>::face_descriptor) -> bool
|
||||
{ return true; };
|
||||
}
|
||||
|
||||
CGAL::IO::Color get_face_color(const SM& sm,
|
||||
typename boost::graph_traits<SM>::face_descriptor fh)
|
||||
{
|
||||
// Default color of faces
|
||||
CGAL::IO::Color c(75,160,255);
|
||||
if(!m_with_size) { return c; }
|
||||
|
||||
// Compare the size of the face with the % m_threshold
|
||||
bool exist;
|
||||
typename SM::template Property_map<face_descriptor, FT> faces_size;
|
||||
boost::tie(faces_size, exist)=sm.template property_map<face_descriptor, FT>("f:size");
|
||||
assert(exist);
|
||||
|
||||
// If the face is small, color it in red.
|
||||
if (get(faces_size, fh)<m_min_size+((m_max_size-m_min_size)/(100-m_threshold)))
|
||||
{ return CGAL::IO::Color(255,20,20); }
|
||||
|
||||
return c; // Default color
|
||||
}
|
||||
|
||||
const SM& m_sm;
|
||||
bool m_with_size;
|
||||
FT m_min_size, m_max_size;
|
||||
unsigned int m_threshold=85; // 85%
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/elephant.off");
|
||||
|
||||
Mesh sm;
|
||||
if(!CGAL::IO::read_polygon_mesh(filename, sm))
|
||||
{
|
||||
std::cerr << "Invalid input file: " << filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CGAL::Polygon_mesh_processing::triangulate_faces(sm);
|
||||
|
||||
Mesh::Property_map<face_descriptor, FT> faces_size;
|
||||
bool created;
|
||||
boost::tie(faces_size, created)=sm.add_property_map<face_descriptor, FT>("f:size",0.);
|
||||
assert(created);
|
||||
|
||||
for(face_descriptor fd : sm.faces())
|
||||
{ faces_size[fd]=CGAL::Polygon_mesh_processing::face_area(fd, sm); }
|
||||
|
||||
Graphics_scene_options_small_faces gsosm(sm);
|
||||
CGAL::Graphics_scene gs;
|
||||
|
||||
add_to_graphics_scene(sm, gs, gsosm);
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
CGAL::Qt::QApplication_and_basic_viewer app(gs, "Small faces");
|
||||
if(app)
|
||||
{
|
||||
app.basic_viewer().on_key_pressed=
|
||||
[&sm, &gsosm, &gs] (QKeyEvent* e, CGAL::Qt::Basic_viewer* basic_viewer) -> bool
|
||||
{
|
||||
const ::Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||
if ((e->key() == ::Qt::Key_I) && (modifiers == ::Qt::NoButton))
|
||||
{
|
||||
gsosm.m_threshold+=5;
|
||||
if(gsosm.m_threshold>100) { gsosm.m_threshold=100; }
|
||||
basic_viewer->displayMessage
|
||||
(QString("Small faces threshold=%1.").arg(gsosm.m_threshold));
|
||||
|
||||
gs.clear();
|
||||
add_to_graphics_scene(sm, gs, gsosm);
|
||||
basic_viewer->redraw();
|
||||
}
|
||||
else if ((e->key() == ::Qt::Key_D) && (modifiers == ::Qt::NoButton))
|
||||
{
|
||||
if(gsosm.m_threshold<5) { gsosm.m_threshold=0; }
|
||||
else { gsosm.m_threshold-=5; }
|
||||
basic_viewer->displayMessage
|
||||
(QString("Small faces threshold=%1.").arg(gsosm.m_threshold));
|
||||
|
||||
gs.clear();
|
||||
add_to_graphics_scene(sm, gs, gsosm);
|
||||
basic_viewer->redraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return false will call the base method to process others/classicals key
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// Here we add shortcut descriptions
|
||||
app.basic_viewer().setKeyDescription(::Qt::Key_I, "Increase threshold for small faces");
|
||||
app.basic_viewer().setKeyDescription(::Qt::Key_D, "Decrease threshold for small faces");
|
||||
|
||||
// Then we run the app
|
||||
app.run();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sm.remove_property_map(faces_size);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/draw_surface_mesh.h>
|
||||
#include <CGAL/Graphics_scene_options.h>
|
||||
#include <fstream>
|
||||
|
||||
using Kernel=CGAL::Simple_cartesian<double>;
|
||||
using Point=Kernel::Point_3;
|
||||
using Mesh=CGAL::Surface_mesh<Point>;
|
||||
|
||||
// Inherit from CGAL::Graphics_scene_options to get all the default values.
|
||||
struct My_graphics_scene_options:
|
||||
public CGAL::Graphics_scene_options<Mesh,
|
||||
typename boost::graph_traits<Mesh>::vertex_descriptor,
|
||||
typename boost::graph_traits<Mesh>::edge_descriptor,
|
||||
typename boost::graph_traits<Mesh>::face_descriptor>
|
||||
{
|
||||
// All vertices are colored.
|
||||
bool colored_vertex(const Mesh&,
|
||||
typename boost::graph_traits<Mesh>::vertex_descriptor) const
|
||||
{ return true; }
|
||||
|
||||
// Change the color of vertices randomly.
|
||||
CGAL::IO::Color vertex_color(const Mesh&,
|
||||
typename boost::graph_traits<Mesh>::vertex_descriptor) const
|
||||
{
|
||||
static bool v_green=true;
|
||||
v_green=!v_green;
|
||||
if(v_green) // 1 vertex out of two green (randomly)
|
||||
{ return CGAL::IO::Color(0,220,0); }
|
||||
else // the others are blue
|
||||
{ return CGAL::IO::Color(0,0,220); }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/elephant.off");
|
||||
|
||||
Mesh sm;
|
||||
if(!CGAL::IO::read_polygon_mesh(filename, sm))
|
||||
{
|
||||
std::cerr << "Invalid input file: " << filename << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Draw the mesh using the new graphics scene option.
|
||||
CGAL::draw(sm, My_graphics_scene_options());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@
|
|||
//
|
||||
// Author(s) : Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
|
||||
#ifndef CGAL_VBO_BUFFER_FILLER_H
|
||||
#define CGAL_VBO_BUFFER_FILLER_H
|
||||
#ifndef CGAL_BUFFER_FOR_VAO_H
|
||||
#define CGAL_BUFFER_FOR_VAO_H
|
||||
|
||||
#include <CGAL/license/GraphicsView.h>
|
||||
|
||||
|
|
@ -125,13 +125,43 @@ namespace internal
|
|||
static const typename Local_kernel::Ray_2& get_local_ray(const typename Local_kernel::Ray_2& r)
|
||||
{ return r; }
|
||||
};
|
||||
|
||||
template<typename CDT>
|
||||
void mark_domains(CDT& tri,
|
||||
typename CDT::Face_handle start, int index,
|
||||
std::queue<typename CDT::Edge>& border)
|
||||
{
|
||||
if (start->info().m_nesting_level!=-1) return;
|
||||
std::queue<typename CDT::Face_handle> queue;
|
||||
queue.push(start);
|
||||
while (!queue.empty())
|
||||
{
|
||||
auto fh=queue.front();
|
||||
queue.pop();
|
||||
if (fh->info().m_nesting_level==-1)
|
||||
{
|
||||
fh->info().m_nesting_level=index;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
typename CDT::Edge e(fh,i);
|
||||
auto n = fh->neighbor(i);
|
||||
if (n->info().m_nesting_level==-1)
|
||||
{
|
||||
if (tri.is_constrained(e)) { border.push(e); }
|
||||
else { queue.push(n); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // End namespace internal
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
template<typename BufferType=float, typename IndexType=std::size_t>
|
||||
class Buffer_for_vao
|
||||
{
|
||||
public:
|
||||
using BufferType=float;
|
||||
using IndexType=std::size_t;
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel;
|
||||
typedef Local_kernel::Point_3 Local_point;
|
||||
typedef Local_kernel::Vector_3 Local_vector;
|
||||
|
|
@ -163,6 +193,7 @@ public:
|
|||
if (m_index_buffer!=nullptr) { m_index_buffer->clear(); }
|
||||
if (m_flat_normal_buffer!=nullptr) { m_flat_normal_buffer->clear(); }
|
||||
if (m_gouraud_normal_buffer!=nullptr) { m_gouraud_normal_buffer->clear(); }
|
||||
if (m_bb!=nullptr) { (*m_bb)=CGAL::Bbox_3(); }
|
||||
|
||||
m_zero_x=true;
|
||||
m_zero_y=true;
|
||||
|
|
@ -203,11 +234,10 @@ public:
|
|||
bool has_zero_z() const
|
||||
{ return m_zero_z; }
|
||||
|
||||
void negate_normals()
|
||||
void negate_normals() const
|
||||
{
|
||||
m_inverse_normal=!m_inverse_normal;
|
||||
for (std::vector<BufferType>*array=m_flat_normal_buffer; array!=nullptr;
|
||||
array=(array==m_gouraud_normal_buffer?nullptr:m_gouraud_normal_buffer))
|
||||
for (std::vector<BufferType>*array: {m_flat_normal_buffer, m_gouraud_normal_buffer})
|
||||
{
|
||||
for (std::size_t i=0; i<array->size(); ++i)
|
||||
{ (*array)[i]=-(*array)[i]; }
|
||||
|
|
@ -458,31 +488,31 @@ public:
|
|||
|
||||
/// adds `kp` coordinates to `buffer`
|
||||
template<typename KPoint>
|
||||
static void add_point_in_buffer(const KPoint& kp, std::vector<float>& buffer)
|
||||
static void add_point_in_buffer(const KPoint& kp, std::vector<BufferType>& buffer)
|
||||
{
|
||||
Local_point p=get_local_point(kp);
|
||||
buffer.push_back(static_cast<float>(p.x()));
|
||||
buffer.push_back(static_cast<float>(p.y()));
|
||||
buffer.push_back(static_cast<float>(p.z()));
|
||||
buffer.push_back(static_cast<BufferType>(p.x()));
|
||||
buffer.push_back(static_cast<BufferType>(p.y()));
|
||||
buffer.push_back(static_cast<BufferType>(p.z()));
|
||||
}
|
||||
|
||||
/// adds `kv` coordinates to `buffer`
|
||||
template<typename KVector>
|
||||
static void add_normal_in_buffer(const KVector& kv, std::vector<float>& buffer,
|
||||
static void add_normal_in_buffer(const KVector& kv, std::vector<BufferType>& buffer,
|
||||
bool inverse_normal=false)
|
||||
{
|
||||
Local_vector n=(inverse_normal?-get_local_vector(kv):get_local_vector(kv));
|
||||
buffer.push_back(static_cast<float>(n.x()));
|
||||
buffer.push_back(static_cast<float>(n.y()));
|
||||
buffer.push_back(static_cast<float>(n.z()));
|
||||
buffer.push_back(static_cast<BufferType>(n.x()));
|
||||
buffer.push_back(static_cast<BufferType>(n.y()));
|
||||
buffer.push_back(static_cast<BufferType>(n.z()));
|
||||
}
|
||||
|
||||
///adds `acolor` RGB components to `buffer`
|
||||
static void add_color_in_buffer(const CGAL::IO::Color& acolor, std::vector<float>& buffer)
|
||||
static void add_color_in_buffer(const CGAL::IO::Color& acolor, std::vector<BufferType>& buffer)
|
||||
{
|
||||
buffer.push_back((float)acolor.red()/(float)255);
|
||||
buffer.push_back((float)acolor.green()/(float)255);
|
||||
buffer.push_back((float)acolor.blue()/(float)255);
|
||||
buffer.push_back((BufferType)acolor.red()/(BufferType)255);
|
||||
buffer.push_back((BufferType)acolor.green()/(BufferType)255);
|
||||
buffer.push_back((BufferType)acolor.blue()/(BufferType)255);
|
||||
}
|
||||
|
||||
/// @return true iff the points of 'facet' form a convex face
|
||||
|
|
@ -737,62 +767,20 @@ protected:
|
|||
{ cdt.insert_constraint(previous, first); }
|
||||
}
|
||||
|
||||
// (2) We mark all external triangles
|
||||
// (2.1) We initialize is_external and is_process values
|
||||
// (2.1) We initialize nesting_level
|
||||
for(typename CDT::All_faces_iterator fit = cdt.all_faces_begin(),
|
||||
fitend = cdt.all_faces_end(); fit!=fitend; ++fit)
|
||||
{
|
||||
fit->info().is_external = true;
|
||||
fit->info().is_process = false;
|
||||
}
|
||||
// (2.2) We check if the facet is external or internal
|
||||
std::queue<typename CDT::Face_handle> face_queue, faces_internal;
|
||||
if (cdt.infinite_vertex()->face()!=nullptr)
|
||||
{
|
||||
typename CDT::Face_circulator
|
||||
incident_faces(cdt.infinite_vertex()), end_incident_faces(incident_faces);
|
||||
do
|
||||
{ face_queue.push(incident_faces); }
|
||||
while(++incident_faces!=end_incident_faces);
|
||||
}
|
||||
// std::cout<<"# faces PUSHED "<<face_queue.size()<<std::endl;
|
||||
while(!face_queue.empty())
|
||||
{
|
||||
typename CDT::Face_handle fh=face_queue.front();
|
||||
face_queue.pop();
|
||||
if(!fh->info().is_process)
|
||||
{
|
||||
fh->info().is_process=true;
|
||||
for(int i=0; i<3; ++i)
|
||||
{
|
||||
if(!cdt.is_constrained(std::make_pair(fh, i)))
|
||||
{
|
||||
if (fh->neighbor(i)!=nullptr)
|
||||
{ face_queue.push(fh->neighbor(i)); }
|
||||
}
|
||||
else
|
||||
{ faces_internal.push(fh->neighbor(i)); }
|
||||
}
|
||||
}
|
||||
}
|
||||
{ fit->info().m_nesting_level=-1; }
|
||||
|
||||
while(!faces_internal.empty())
|
||||
std::queue<typename CDT::Edge> border;
|
||||
internal::mark_domains(cdt, cdt.infinite_face(), 0, border);
|
||||
while(!border.empty())
|
||||
{
|
||||
typename CDT::Face_handle fh=faces_internal.front();
|
||||
faces_internal.pop();
|
||||
if(!fh->info().is_process)
|
||||
{
|
||||
fh->info().is_process = true;
|
||||
fh->info().is_external = false;
|
||||
for(unsigned int i=0; i<3; ++i)
|
||||
{
|
||||
if(!cdt.is_constrained(std::make_pair(fh, i)))
|
||||
{
|
||||
if (fh->neighbor(i)!=nullptr)
|
||||
{ faces_internal.push(fh->neighbor(i)); }
|
||||
}
|
||||
}
|
||||
}
|
||||
auto e=border.front();
|
||||
border.pop();
|
||||
auto n=e.first->neighbor(e.second);
|
||||
if (n->info().m_nesting_level==-1)
|
||||
{ internal::mark_domains(cdt, n, e.first->info().m_nesting_level+1, border); }
|
||||
}
|
||||
|
||||
// (3) Now we iterates on the internal faces to add the vertices
|
||||
|
|
@ -800,7 +788,7 @@ protected:
|
|||
for(typename CDT::Finite_faces_iterator ffit=cdt.finite_faces_begin(),
|
||||
ffitend = cdt.finite_faces_end(); ffit!=ffitend; ++ffit)
|
||||
{
|
||||
if(!ffit->info().is_external)
|
||||
if(ffit->info().in_domain())
|
||||
{
|
||||
for(unsigned int i=0; i<3; ++i)
|
||||
{
|
||||
|
|
@ -882,9 +870,8 @@ protected:
|
|||
|
||||
struct Face_info
|
||||
{
|
||||
bool exist_edge[3];
|
||||
bool is_external;
|
||||
bool is_process;
|
||||
int m_nesting_level=-1;
|
||||
bool in_domain() { return m_nesting_level%2==1; }
|
||||
};
|
||||
|
||||
typedef CGAL::Projection_traits_3<CGAL::Exact_predicates_inexact_constructions_kernel> P_traits;
|
||||
|
|
@ -899,8 +886,8 @@ protected:
|
|||
std::vector<BufferType>* m_pos_buffer;
|
||||
std::vector<IndexType>* m_index_buffer;
|
||||
std::vector<BufferType>* m_color_buffer;
|
||||
std::vector<BufferType>* m_flat_normal_buffer;
|
||||
std::vector<BufferType>* m_gouraud_normal_buffer;
|
||||
mutable std::vector<BufferType>* m_flat_normal_buffer;
|
||||
mutable std::vector<BufferType>* m_gouraud_normal_buffer;
|
||||
|
||||
CGAL::Bbox_3* m_bb;
|
||||
|
||||
|
|
@ -908,7 +895,7 @@ protected:
|
|||
bool m_zero_y; /// True iff all points have y==0
|
||||
bool m_zero_z; /// True iff all points have z==0
|
||||
|
||||
bool m_inverse_normal;
|
||||
mutable bool m_inverse_normal;
|
||||
|
||||
// Local variables, used when we started a new face.g
|
||||
bool m_face_started;
|
||||
|
|
@ -923,4 +910,4 @@ protected:
|
|||
|
||||
} // End namespace CGAL
|
||||
|
||||
#endif // CGAL_VBO_BUFFER_FILLER_H
|
||||
#endif // CGAL_BUFFER_FOR_VAO_H
|
||||
|
|
@ -0,0 +1,436 @@
|
|||
// Copyright (c) 2022 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): Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||
|
||||
#ifndef CGAL_GRAPHICS_SCENE_H
|
||||
#define CGAL_GRAPHICS_SCENE_H
|
||||
|
||||
// TODO #include <CGAL/license/GraphicsView.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <CGAL/Cartesian_converter.h>
|
||||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Constrained_triangulation_plus_2.h>
|
||||
#include <CGAL/IO/Color.h>
|
||||
#include <CGAL/Projection_traits_3.h>
|
||||
#include <CGAL/Triangulation_face_base_with_info_2.h>
|
||||
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
|
||||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <CGAL/Buffer_for_vao.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
inline CGAL::IO::Color get_random_color(CGAL::Random& random)
|
||||
{
|
||||
CGAL::IO::Color res;
|
||||
do
|
||||
{
|
||||
res=CGAL::IO::Color(random.get_int(0,256),
|
||||
random.get_int(0,256),
|
||||
random.get_int(0,256));
|
||||
}
|
||||
while(res.red()==255 && res.green()==255 && res.blue()==255);
|
||||
return res;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// This class is responsible for dealing with available CGAL data structures and
|
||||
// handling buffers.
|
||||
class Graphics_scene
|
||||
{
|
||||
public:
|
||||
using BufferType=float;
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Local_kernel;
|
||||
typedef Local_kernel::Point_3 Local_point;
|
||||
typedef Local_kernel::Vector_3 Local_vector;
|
||||
|
||||
Graphics_scene()
|
||||
: m_buffer_for_mono_points(&arrays[POS_MONO_POINTS], nullptr,
|
||||
&m_bounding_box, nullptr, nullptr, nullptr),
|
||||
m_buffer_for_colored_points(&arrays[POS_COLORED_POINTS], nullptr,
|
||||
&m_bounding_box, &arrays[COLOR_POINTS],
|
||||
nullptr, nullptr),
|
||||
m_buffer_for_mono_segments(&arrays[POS_MONO_SEGMENTS], nullptr,
|
||||
&m_bounding_box, nullptr, nullptr, nullptr),
|
||||
m_buffer_for_colored_segments(&arrays[POS_COLORED_SEGMENTS], nullptr,
|
||||
&m_bounding_box, &arrays[COLOR_SEGMENTS],
|
||||
nullptr, nullptr),
|
||||
m_buffer_for_mono_rays(&arrays[POS_MONO_RAYS], nullptr, &m_bounding_box,
|
||||
nullptr, nullptr),
|
||||
m_buffer_for_colored_rays(&arrays[POS_COLORED_RAYS], nullptr,
|
||||
&m_bounding_box, &arrays[COLOR_RAYS], nullptr,
|
||||
nullptr),
|
||||
m_buffer_for_mono_lines(&arrays[POS_MONO_RAYS], nullptr,
|
||||
&m_bounding_box, nullptr, nullptr),
|
||||
m_buffer_for_colored_lines(&arrays[POS_COLORED_LINES], nullptr,
|
||||
&m_bounding_box, &arrays[COLOR_LINES],
|
||||
nullptr, nullptr),
|
||||
m_buffer_for_mono_faces(
|
||||
&arrays[POS_MONO_FACES], nullptr, &m_bounding_box, nullptr,
|
||||
&arrays[FLAT_NORMAL_MONO_FACES], &arrays[SMOOTH_NORMAL_MONO_FACES]),
|
||||
m_buffer_for_colored_faces(&arrays[POS_COLORED_FACES], nullptr,
|
||||
&m_bounding_box, &arrays[COLOR_FACES],
|
||||
&arrays[FLAT_NORMAL_COLORED_FACES],
|
||||
&arrays[SMOOTH_NORMAL_COLORED_FACES])
|
||||
{}
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_mono_points() const
|
||||
{ return m_buffer_for_mono_points; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_colored_points() const
|
||||
{ return m_buffer_for_colored_points; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_mono_segments() const
|
||||
{ return m_buffer_for_mono_segments; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_colored_segments() const
|
||||
{ return m_buffer_for_colored_segments; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_mono_rays() const
|
||||
{ return m_buffer_for_mono_rays; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_colored_rays() const
|
||||
{ return m_buffer_for_colored_rays; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_mono_lines() const
|
||||
{ return m_buffer_for_mono_lines; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_colored_lines() const
|
||||
{ return m_buffer_for_colored_lines; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_mono_faces() const
|
||||
{ return m_buffer_for_mono_faces; }
|
||||
|
||||
const Buffer_for_vao &get_buffer_for_colored_faces() const
|
||||
{ return m_buffer_for_colored_faces; }
|
||||
|
||||
const CGAL::Bbox_3 &bounding_box() const { return m_bounding_box; }
|
||||
|
||||
const std::vector<BufferType> &get_array_of_index(int index) const
|
||||
{ assert(index<LAST_INDEX); return arrays[index]; }
|
||||
|
||||
int get_size_of_index(int index) const
|
||||
{ return static_cast<int>(arrays[index].size()*sizeof(BufferType)); }
|
||||
|
||||
unsigned int number_of_elements(int index) const
|
||||
{ return static_cast<unsigned int>(arrays[index].size()/3); }
|
||||
|
||||
void initiate_bounding_box(const CGAL::Bbox_3& new_bounding_box)
|
||||
{ m_bounding_box = new_bounding_box; }
|
||||
|
||||
void update_bounding_box(const CGAL::Bbox_3 &box) { m_bounding_box+=box; }
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
void update_bounding_box_for_ray(const KPoint &p, const KVector &v)
|
||||
{
|
||||
Local_point lp = get_local_point(p);
|
||||
Local_vector lv = get_local_vector(v);
|
||||
update_bounding_box((lp + lv).bbox());
|
||||
}
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
void update_bounding_box_for_line(const KPoint &p, const KVector &v,
|
||||
const KVector &pv)
|
||||
{
|
||||
Local_point lp = get_local_point(p);
|
||||
Local_vector lv = get_local_vector(v);
|
||||
Local_vector lpv = get_local_vector(pv);
|
||||
update_bounding_box(lp.bbox() + (lp + lv).bbox() + (lp + lpv).bbox());
|
||||
}
|
||||
|
||||
void reverse_all_normals() const
|
||||
{
|
||||
m_buffer_for_mono_faces.negate_normals();
|
||||
m_buffer_for_colored_faces.negate_normals();
|
||||
}
|
||||
|
||||
template <typename KPoint> void add_point(const KPoint &p)
|
||||
{ m_buffer_for_mono_points.add_point(p); }
|
||||
|
||||
template <typename KPoint>
|
||||
void add_point(const KPoint &p, const CGAL::IO::Color &acolor)
|
||||
{ m_buffer_for_colored_points.add_point(p, acolor); }
|
||||
|
||||
template <typename KPoint>
|
||||
void add_segment(const KPoint &p1, const KPoint &p2)
|
||||
{ m_buffer_for_mono_segments.add_segment(p1, p2); }
|
||||
|
||||
template <typename KPoint>
|
||||
void add_segment(const KPoint &p1, const KPoint &p2,
|
||||
const CGAL::IO::Color &acolor)
|
||||
{ m_buffer_for_colored_segments.add_segment(p1, p2, acolor); }
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_ray(const KPoint &p, const KVector &v)
|
||||
{
|
||||
double bigNumber = 1e30;
|
||||
m_buffer_for_mono_rays.add_ray_segment(p, (p + (bigNumber)*v));
|
||||
}
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_ray(const KPoint &p, const KVector &v,
|
||||
const CGAL::IO::Color &acolor)
|
||||
{
|
||||
double bigNumber = 1e30;
|
||||
m_buffer_for_colored_rays.add_ray_segment(p, (p + (bigNumber)*v), acolor);
|
||||
}
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_line(const KPoint &p, const KVector &v)
|
||||
{
|
||||
double bigNumber = 1e30;
|
||||
m_buffer_for_mono_lines.add_line_segment((p - (bigNumber)*v),
|
||||
(p + (bigNumber)*v));
|
||||
}
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
void add_line(const KPoint &p, const KVector &v,
|
||||
const CGAL::IO::Color &acolor)
|
||||
{
|
||||
double bigNumber = 1e30;
|
||||
m_buffer_for_colored_lines.add_line_segment((p - (bigNumber)*v),
|
||||
(p + (bigNumber)*v), acolor);
|
||||
}
|
||||
|
||||
template <typename KPoint> bool add_point_in_face(const KPoint &kp)
|
||||
{
|
||||
if (m_buffer_for_mono_faces.is_a_face_started())
|
||||
{ return m_buffer_for_mono_faces.add_point_in_face(kp); }
|
||||
else if (m_buffer_for_colored_faces.is_a_face_started())
|
||||
{ return m_buffer_for_colored_faces.add_point_in_face(kp); }
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename KPoint, typename KVector>
|
||||
bool add_point_in_face(const KPoint &kp, const KVector &p_normal)
|
||||
{
|
||||
if (m_buffer_for_mono_faces.is_a_face_started())
|
||||
{ return m_buffer_for_mono_faces.add_point_in_face(kp, p_normal); }
|
||||
else if (m_buffer_for_colored_faces.is_a_face_started())
|
||||
{ return m_buffer_for_colored_faces.add_point_in_face(kp, p_normal); }
|
||||
return false;
|
||||
}
|
||||
|
||||
bool a_face_started() const
|
||||
{
|
||||
return m_buffer_for_mono_faces.is_a_face_started() ||
|
||||
m_buffer_for_colored_faces.is_a_face_started();
|
||||
}
|
||||
|
||||
void face_begin()
|
||||
{
|
||||
if (a_face_started())
|
||||
{
|
||||
std::cerr
|
||||
<< "You cannot start a new face before to finish the previous one."
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{ m_buffer_for_mono_faces.face_begin(); }
|
||||
}
|
||||
|
||||
void face_begin(const CGAL::IO::Color &acolor)
|
||||
{
|
||||
if (a_face_started())
|
||||
{
|
||||
std::cerr
|
||||
<< "You cannot start a new face before to finish the previous one."
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{ m_buffer_for_colored_faces.face_begin(acolor); }
|
||||
}
|
||||
|
||||
void face_end()
|
||||
{
|
||||
if (m_buffer_for_mono_faces.is_a_face_started())
|
||||
{ m_buffer_for_mono_faces.face_end(); }
|
||||
else if (m_buffer_for_colored_faces.is_a_face_started())
|
||||
{ m_buffer_for_colored_faces.face_end(); }
|
||||
}
|
||||
|
||||
template <typename KPoint>
|
||||
void add_text(const KPoint &kp, const std::string &txt)
|
||||
{
|
||||
Local_point p = get_local_point(kp);
|
||||
m_texts.push_back(std::make_tuple(p, txt));
|
||||
}
|
||||
|
||||
template <typename KPoint>
|
||||
void add_text(const KPoint &kp, const char *txt)
|
||||
{ add_text(kp, std::string(txt)); }
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return (m_buffer_for_mono_points.is_empty() &&
|
||||
m_buffer_for_colored_points.is_empty() &&
|
||||
m_buffer_for_mono_segments.is_empty() &&
|
||||
m_buffer_for_colored_segments.is_empty() &&
|
||||
m_buffer_for_mono_rays.is_empty() &&
|
||||
m_buffer_for_colored_rays.is_empty() &&
|
||||
m_buffer_for_mono_lines.is_empty() &&
|
||||
m_buffer_for_colored_lines.is_empty() &&
|
||||
m_buffer_for_mono_faces.is_empty() &&
|
||||
m_buffer_for_colored_faces.is_empty());
|
||||
}
|
||||
|
||||
bool has_zero_x() const
|
||||
{
|
||||
return m_buffer_for_mono_points.has_zero_x() &&
|
||||
m_buffer_for_colored_points.has_zero_x() &&
|
||||
m_buffer_for_mono_segments.has_zero_x() &&
|
||||
m_buffer_for_colored_segments.has_zero_x() &&
|
||||
m_buffer_for_mono_faces.has_zero_x() &&
|
||||
m_buffer_for_colored_faces.has_zero_x() &&
|
||||
m_buffer_for_mono_rays.has_zero_x() &&
|
||||
m_buffer_for_colored_rays.has_zero_x() &&
|
||||
m_buffer_for_mono_lines.has_zero_x() &&
|
||||
m_buffer_for_colored_lines.has_zero_x();
|
||||
}
|
||||
|
||||
bool has_zero_y() const
|
||||
{
|
||||
return m_buffer_for_mono_points.has_zero_y() &&
|
||||
m_buffer_for_colored_points.has_zero_y() &&
|
||||
m_buffer_for_mono_segments.has_zero_y() &&
|
||||
m_buffer_for_colored_segments.has_zero_y() &&
|
||||
m_buffer_for_mono_faces.has_zero_y() &&
|
||||
m_buffer_for_colored_faces.has_zero_y() &&
|
||||
m_buffer_for_mono_rays.has_zero_y() &&
|
||||
m_buffer_for_colored_rays.has_zero_y() &&
|
||||
m_buffer_for_mono_lines.has_zero_y() &&
|
||||
m_buffer_for_colored_lines.has_zero_y();
|
||||
}
|
||||
|
||||
bool has_zero_z() const
|
||||
{
|
||||
return m_buffer_for_mono_points.has_zero_z() &&
|
||||
m_buffer_for_colored_points.has_zero_z() &&
|
||||
m_buffer_for_mono_segments.has_zero_z() &&
|
||||
m_buffer_for_colored_segments.has_zero_z() &&
|
||||
m_buffer_for_mono_faces.has_zero_z() &&
|
||||
m_buffer_for_colored_faces.has_zero_z() &&
|
||||
m_buffer_for_mono_rays.has_zero_z() &&
|
||||
m_buffer_for_colored_rays.has_zero_z() &&
|
||||
m_buffer_for_mono_lines.has_zero_z() &&
|
||||
m_buffer_for_colored_lines.has_zero_z();
|
||||
}
|
||||
|
||||
// Returns true if the data structure lies on a XY or XZ or YZ plane
|
||||
bool is_two_dimensional() const
|
||||
{
|
||||
return (!empty() && (has_zero_x() || has_zero_y() || has_zero_z()));
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_buffer_for_mono_points.clear();
|
||||
m_buffer_for_colored_points.clear();
|
||||
m_buffer_for_mono_segments.clear();
|
||||
m_buffer_for_colored_segments.clear();
|
||||
m_buffer_for_mono_rays.clear();
|
||||
m_buffer_for_colored_rays.clear();
|
||||
m_buffer_for_mono_lines.clear();
|
||||
m_buffer_for_colored_lines.clear();
|
||||
m_buffer_for_mono_faces.clear();
|
||||
m_buffer_for_colored_faces.clear();
|
||||
m_texts.clear();
|
||||
m_bounding_box=CGAL::Bbox_3();
|
||||
}
|
||||
|
||||
template <typename KPoint>
|
||||
static Local_point get_local_point(const KPoint &p)
|
||||
{
|
||||
return internal::Geom_utils<typename CGAL::Kernel_traits<KPoint>::Kernel,
|
||||
Local_kernel>::get_local_point(p);
|
||||
}
|
||||
|
||||
template <typename KVector>
|
||||
static Local_vector get_local_vector(const KVector &v)
|
||||
{
|
||||
return internal::Geom_utils<typename CGAL::Kernel_traits<KVector>::Kernel,
|
||||
Local_kernel>::get_local_vector(v);
|
||||
}
|
||||
|
||||
void m_texts_clear()
|
||||
{ m_texts.clear(); }
|
||||
|
||||
std::size_t m_texts_size() const
|
||||
{ return m_texts.size(); }
|
||||
|
||||
const std::vector<std::tuple<Local_point, std::string>>& get_m_texts() const
|
||||
{ return m_texts; }
|
||||
|
||||
public:
|
||||
// The following enum gives the indices of different elements of arrays
|
||||
// vectors.
|
||||
enum Buffers {
|
||||
BEGIN_POS = 0,
|
||||
POS_MONO_POINTS = BEGIN_POS,
|
||||
POS_COLORED_POINTS,
|
||||
POS_MONO_SEGMENTS,
|
||||
POS_COLORED_SEGMENTS,
|
||||
POS_MONO_RAYS,
|
||||
POS_COLORED_RAYS,
|
||||
POS_MONO_LINES,
|
||||
POS_COLORED_LINES,
|
||||
POS_MONO_FACES,
|
||||
POS_COLORED_FACES,
|
||||
END_POS,
|
||||
BEGIN_COLOR = END_POS,
|
||||
COLOR_POINTS = BEGIN_COLOR,
|
||||
COLOR_SEGMENTS,
|
||||
COLOR_RAYS,
|
||||
COLOR_LINES,
|
||||
COLOR_FACES,
|
||||
END_COLOR,
|
||||
BEGIN_NORMAL = END_COLOR,
|
||||
SMOOTH_NORMAL_MONO_FACES = BEGIN_NORMAL,
|
||||
FLAT_NORMAL_MONO_FACES,
|
||||
SMOOTH_NORMAL_COLORED_FACES,
|
||||
FLAT_NORMAL_COLORED_FACES,
|
||||
END_NORMAL,
|
||||
LAST_INDEX = END_NORMAL
|
||||
};
|
||||
|
||||
protected:
|
||||
Buffer_for_vao m_buffer_for_mono_points;
|
||||
Buffer_for_vao m_buffer_for_colored_points;
|
||||
Buffer_for_vao m_buffer_for_mono_segments;
|
||||
Buffer_for_vao m_buffer_for_colored_segments;
|
||||
Buffer_for_vao m_buffer_for_mono_rays;
|
||||
Buffer_for_vao m_buffer_for_colored_rays;
|
||||
Buffer_for_vao m_buffer_for_mono_lines;
|
||||
Buffer_for_vao m_buffer_for_colored_lines;
|
||||
Buffer_for_vao m_buffer_for_mono_faces;
|
||||
Buffer_for_vao m_buffer_for_colored_faces;
|
||||
|
||||
std::vector<std::tuple<Local_point, std::string>> m_texts;
|
||||
|
||||
std::vector<BufferType> arrays[LAST_INDEX];
|
||||
|
||||
CGAL::Bbox_3 m_bounding_box;
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_GRAPHICS_SCENE_H
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
// Copyright (c) 2022 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): Guillaume Damiand <guillaume.damiand@liris.cnrs.fr>
|
||||
// Mostafa Ashraf <mostaphaashraf1996@gmail.com>
|
||||
|
||||
#ifndef CGAL_GRAPHICS_SCENE_OPTIONS_H
|
||||
#define CGAL_GRAPHICS_SCENE_OPTIONS_H
|
||||
|
||||
#include <CGAL/license/GraphicsView.h>
|
||||
#include <CGAL/IO/Color.h>
|
||||
#include <functional>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor,
|
||||
typename VolumeDescriptor=void>
|
||||
struct Graphics_scene_options;
|
||||
|
||||
// Drawing functor for a 2D combinatorial data structure
|
||||
// (with vertices, edges and faces)
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor>
|
||||
struct Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor, void>
|
||||
{
|
||||
|
||||
typedef VertexDescriptor vertex_descriptor;
|
||||
typedef EdgeDescriptor edge_descriptor;
|
||||
typedef FaceDescriptor face_descriptor;
|
||||
|
||||
Graphics_scene_options(): m_enabled_vertices(true),
|
||||
m_enabled_edges(true),
|
||||
m_enabled_faces(true)
|
||||
{
|
||||
draw_vertex=[](const DS &, vertex_descriptor)->bool { return true; };
|
||||
draw_edge=[](const DS &, edge_descriptor)->bool { return true; };
|
||||
draw_face=[](const DS &, face_descriptor)->bool { return true; };
|
||||
|
||||
colored_vertex=[](const DS &, vertex_descriptor)->bool { return false; };
|
||||
colored_edge=[](const DS &, edge_descriptor)->bool { return false; };
|
||||
colored_face=[](const DS &, face_descriptor)->bool { return false; };
|
||||
|
||||
face_wireframe=[](const DS &, face_descriptor)->bool { return false; };
|
||||
}
|
||||
|
||||
// The seven following functions should not be null
|
||||
std::function<bool(const DS &, vertex_descriptor)> draw_vertex;
|
||||
std::function<bool(const DS &, edge_descriptor)> draw_edge;
|
||||
std::function<bool(const DS &, face_descriptor)> draw_face;
|
||||
|
||||
std::function<bool(const DS &, vertex_descriptor)> colored_vertex;
|
||||
std::function<bool(const DS &, edge_descriptor)> colored_edge;
|
||||
std::function<bool(const DS &, face_descriptor)> colored_face;
|
||||
|
||||
std::function<bool(const DS &, face_descriptor)> face_wireframe;
|
||||
|
||||
// These functions must be non null if the corresponding colored_XXX function
|
||||
// returns true.
|
||||
std::function<CGAL::IO::Color(const DS &, vertex_descriptor)> vertex_color;
|
||||
std::function<CGAL::IO::Color(const DS &, edge_descriptor)> edge_color;
|
||||
std::function<CGAL::IO::Color(const DS &, face_descriptor)> face_color;
|
||||
|
||||
void disable_vertices() { m_enabled_vertices=false; }
|
||||
void enable_vertices() { m_enabled_vertices=true; }
|
||||
bool are_vertices_enabled() const { return m_enabled_vertices; }
|
||||
|
||||
void disable_edges() { m_enabled_edges=false; }
|
||||
void enable_edges() { m_enabled_edges=true; }
|
||||
bool are_edges_enabled() const { return m_enabled_edges; }
|
||||
|
||||
void disable_faces() { m_enabled_faces=false; }
|
||||
void enable_faces() { m_enabled_faces=true; }
|
||||
bool are_faces_enabled() const { return m_enabled_faces; }
|
||||
|
||||
protected:
|
||||
bool m_enabled_vertices, m_enabled_edges, m_enabled_faces;
|
||||
};
|
||||
|
||||
// Drawing functor for a 3D combinatorial data structure
|
||||
// (with vertices, edges, faces and volumes)
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor,
|
||||
typename VolumeDescriptor>
|
||||
struct Graphics_scene_options:
|
||||
public Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>
|
||||
{
|
||||
typedef VertexDescriptor vertex_descriptor;
|
||||
typedef EdgeDescriptor edge_descriptor;
|
||||
typedef FaceDescriptor face_descriptor;
|
||||
typedef VolumeDescriptor volume_descriptor;
|
||||
|
||||
Graphics_scene_options() : m_enabled_volumes(true)
|
||||
{
|
||||
draw_volume=[](const DS &, volume_descriptor)->bool { return true; };
|
||||
colored_volume=[](const DS &, volume_descriptor)->bool { return false; };
|
||||
volume_wireframe=[](const DS &, volume_descriptor)->bool { return false; };
|
||||
}
|
||||
|
||||
std::function<bool(const DS &, volume_descriptor)> draw_volume;
|
||||
std::function<bool(const DS &, volume_descriptor)> colored_volume;
|
||||
std::function<bool(const DS &, volume_descriptor)> volume_wireframe;
|
||||
std::function<CGAL::IO::Color(const DS &, volume_descriptor)> volume_color;
|
||||
|
||||
void disable_volumes() { m_enabled_volumes=false; }
|
||||
void enable_volumes() { m_enabled_volumes=true; }
|
||||
bool are_volumes_enabled() const { return m_enabled_volumes; }
|
||||
|
||||
protected:
|
||||
bool m_enabled_volumes;
|
||||
};
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
#endif // CGAL_GRAPHICS_SCENE_OPTIONS_H
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Algebraic_foundations
|
||||
Arithmetic_kernel
|
||||
BGL
|
||||
Basic_viewer
|
||||
Cartesian_kernel
|
||||
Circulator
|
||||
Distance_2
|
||||
Distance_3
|
||||
Filtered_kernel
|
||||
Hash_map
|
||||
Homogeneous_kernel
|
||||
Installation
|
||||
Intersections_2
|
||||
Intersections_3
|
||||
Interval_support
|
||||
Kernel_23
|
||||
Kernel_d
|
||||
Modular_arithmetic
|
||||
Number_types
|
||||
Polygon
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Spatial_sorting
|
||||
Stream_support
|
||||
TDS_2
|
||||
Triangulation_2
|
||||
CGAL_Core
|
||||
|
|
@ -0,0 +1 @@
|
|||
Basic viewer
|
||||
|
|
@ -0,0 +1 @@
|
|||
GPL (v3 or later)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
Implementation of basic viewers.
|
||||
|
||||
A basic viewer allows to visualize a data structure of CGAL.
|
||||
|
|
@ -0,0 +1 @@
|
|||
Guillaume Damiand
|
||||
|
|
@ -3,13 +3,94 @@ namespace CGAL {
|
|||
/*!
|
||||
\ingroup PkgDrawPolygonSet2
|
||||
|
||||
opens a new window and draws `aps`, an instance of the `CGAL::Polygon_set_2` class. A call to this function is blocking, that is the program continues as soon as the user closes the window. This function requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined.
|
||||
Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
\tparam PS an instance of the `CGAL::Polygon_set_2` class.
|
||||
\param aps the polygon set to draw.
|
||||
The class `Graphics_scene_options_polygon_set_2` defines data and methods used to tune the way that the cells of a `Polygon_set_2` are considered for drawing or to be added into a graphics scene.
|
||||
|
||||
This class is a model of `GraphicsSceneOptionsPolygonSet2`.
|
||||
|
||||
\tparam DS a `CGAL::Polygon_set_2`.
|
||||
\tparam VertexDescriptor a descriptor of vertices of `DS`.
|
||||
\tparam EdgeDescriptor a descriptor of edges of `DS`.
|
||||
\tparam FaceDescriptor a descriptor of faces of `DS`.
|
||||
|
||||
\cgalModels{GraphicsSceneOptionsPolygonSet2}
|
||||
*/
|
||||
template<class PS>
|
||||
void draw(const PS& aps);
|
||||
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor>
|
||||
struct Graphics_scene_options_polygon_set_2: public CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>
|
||||
{};
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPolygonSet2
|
||||
|
||||
opens a new window and draws a 2D polygon set. Parameters of the drawing are taken from the optional graphics scene options parameter.
|
||||
|
||||
A call to this function blocks the execution of the program until the drawing window is closed. This function requires `CGAL_Qt6`, and is only available if the macro `CGAL_USE_BASIC_VIEWER` is defined.
|
||||
Linking with the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
|
||||
\tparam PS2 which must be an instanciation of a `CGAL::Polygon_set_2<...>`.
|
||||
\tparam GSOptions a model of `GraphicsSceneOptionsPolygonSet2` concept.
|
||||
|
||||
\param ps2 the polygon set to draw.
|
||||
\param gso the graphics scene options parameter.
|
||||
|
||||
\cgalAdvancedBegin
|
||||
The real declaration of this function template is:
|
||||
|
||||
<code>
|
||||
template<class T, class C, class D, class GSOptions>
|
||||
|
||||
void CGAL::draw(const CGAL::Polygon_set_2<T, C, D>& ps2, const GSOptions& gso);
|
||||
</code>
|
||||
\cgalAdvancedEnd
|
||||
*/
|
||||
template<class PS2, class GSOptions>
|
||||
void draw(const PS2& ps2, const GSOptions& gso);
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPolygonSet2
|
||||
|
||||
A shortcut to `CGAL::draw(ps2, Graphics_scene_options_polygon_set_2{})`.
|
||||
*/
|
||||
template<class PS2>
|
||||
void draw(const PS2& ps2);
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPolygonSet2
|
||||
|
||||
adds the vertices, edges and faces of `ps2` into the given graphic scene `gs`. Parameters of the cells are taken from the optional graphics scene options parameter `gso`. Note that `gs` is not cleared before being filled (to enable to draw several data structures in the same basic viewer).
|
||||
|
||||
\tparam PS2 which must be an instanciation of a `CGAL::Polygon_set_2<...>`.
|
||||
\tparam GSOptions a model of `GraphicsSceneOptionsPolygonSet2` concept.
|
||||
|
||||
\param ps2 the polygon set to draw.
|
||||
\param gs the graphic scene to fill.
|
||||
\param gso the graphics scene options parameter.
|
||||
|
||||
\cgalAdvancedBegin
|
||||
The real declaration of this function template is:
|
||||
|
||||
<code>
|
||||
template<class T, class C, class D, class GSOptions>
|
||||
|
||||
void CGAL::add_to_graphics_scene(const CGAL::Polygon_set_2<T, C, D>& ps2, CGAL::Graphics_scene& gs, const GSOptions& gso);
|
||||
</code>
|
||||
\cgalAdvancedEnd
|
||||
*/
|
||||
template<class PS2, class GSOptions>
|
||||
void add_to_graphics_scene(const PS2& ps2,
|
||||
CGAL::Graphics_scene& gs,
|
||||
const GSOptions& gso);
|
||||
|
||||
/*!
|
||||
\ingroup PkgDrawPolygonSet2
|
||||
|
||||
A shortcut to `CGAL::add_to_graphics_scene(ps2, gs, Graphics_scene_options_polygon_set_2{})`.
|
||||
*/
|
||||
template<class PS2>
|
||||
void add_to_graphics_scene(const PS2& ps2,
|
||||
CGAL::Graphics_scene& gs);
|
||||
|
||||
} /* end namespace CGAL */
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
/*!
|
||||
\ingroup PkgBooleanSetOperations2Concepts
|
||||
|
||||
The concept `GraphicsSceneOptionsPolygonSet2` defines data and methods used to tune the way that the cells of a `Polygon_set_2` are considered for drawing or to be added into a graphics scene.
|
||||
|
||||
\cgalRefines{GraphicsSceneOptions}
|
||||
|
||||
\cgalHasModelsBegin
|
||||
\cgalHasModelsBare{\link CGAL::Graphics_scene_options_polygon_set_2 `CGAL::Graphics_scene_options_polygon_set_2<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>`\endlink}
|
||||
\cgalHasModelsEnd
|
||||
|
||||
*/
|
||||
class GraphicsSceneOptionsPolygonSet2
|
||||
{
|
||||
public:
|
||||
/// returns the color of the unbounded face.
|
||||
const CGAL::IO::Color& unbounded_face_color() const;
|
||||
/// sets the color of the unbounded face to `c`.
|
||||
void unbounded_face_color(const CGAL::IO::Color& c);
|
||||
|
||||
/// returns `true` if the unbounded face must be drawn, `false` otherwise.
|
||||
/// Returns `false` by default.
|
||||
bool draw_unbounded() const;
|
||||
/// sets the draw of unbounded face to `b`.
|
||||
void draw_unbounded(bool b);
|
||||
/// toggles the draw unbounded face value.
|
||||
void toggle_draw_unbounded();
|
||||
|
||||
/// returns the height of the box used to draw the unbounded face.
|
||||
int height() const;
|
||||
/// returns the width of the box used to draw the unbounded face.
|
||||
int width() const;
|
||||
|
||||
/// sets the height of the box used to draw the unbounded face to `i`.
|
||||
void height(int i);
|
||||
/// sets the width of the box used to draw the unbounded face to `i`.
|
||||
void width(int i);
|
||||
};
|
||||
|
|
@ -69,6 +69,8 @@ containment predicates.
|
|||
- \link boolean_connect_holes `CGAL::connect_holes()` \endlink
|
||||
|
||||
\cgalCRPSection{Draw a Polygon_set_2}
|
||||
- \link PkgDrawPolygonSet2 CGAL::draw<PS>() \endlink
|
||||
- \link PkgDrawPolygonSet2 CGAL::draw<PS>() \endlink
|
||||
- `GraphicsSceneOptionsPolygonSet2`
|
||||
- `CGAL::Graphics_scene_options_polygon_set_2`
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,40 +19,159 @@
|
|||
|
||||
#include <CGAL/license/Boolean_set_operations_2.h>
|
||||
|
||||
|
||||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
#ifdef DOXYGEN_RUNNING
|
||||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
* \ingroup PkgDrawPolygonSet2
|
||||
*
|
||||
* opens a new window and draws `aps`, an instance of the `CGAL::Polygon_set_2`
|
||||
* class. A call to this function is blocking, that is the program continues as
|
||||
* soon as the user closes the window. This function requires `CGAL_Qt6`, and is
|
||||
* only available if the macro `CGAL_USE_BASIC_VIEWER` is defined. Linking with
|
||||
* the cmake target `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add
|
||||
* the definition `CGAL_USE_BASIC_VIEWER`.
|
||||
* \tparam PS an instance of the `CGAL::Polygon_set_2` class.
|
||||
* \param aps the polygon set to draw.
|
||||
*/
|
||||
template<class PS>
|
||||
void draw(const PS& aps);
|
||||
|
||||
} /* namespace CGAL */
|
||||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Qt/Basic_viewer.h>
|
||||
#include <CGAL/Graphics_scene.h>
|
||||
#include <CGAL/Graphics_scene_options.h>
|
||||
#include <CGAL/Polygon_set_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
template <typename PolygonSet_2>
|
||||
class Polygon_set_2_basic_viewer_qt : public Basic_viewer_qt {
|
||||
using Base = Basic_viewer_qt;
|
||||
template <typename DS,
|
||||
typename VertexDescriptor,
|
||||
typename EdgeDescriptor,
|
||||
typename FaceDescriptor>
|
||||
struct Graphics_scene_options_polygon_set_2 :
|
||||
public CGAL::Graphics_scene_options<DS, VertexDescriptor, EdgeDescriptor, FaceDescriptor>
|
||||
{
|
||||
void unbounded_face_color(const CGAL::IO::Color& c)
|
||||
{ m_unbounded_face_color=c; }
|
||||
const CGAL::IO::Color& unbounded_face_color() const
|
||||
{ return m_unbounded_face_color; }
|
||||
|
||||
bool draw_unbounded() const
|
||||
{ return m_draw_unbounded; }
|
||||
void draw_unbounded(bool b)
|
||||
{ m_draw_unbounded=b; }
|
||||
void toggle_draw_unbounded()
|
||||
{ m_draw_unbounded=!m_draw_unbounded; }
|
||||
|
||||
int height() const
|
||||
{ return m_height; }
|
||||
int width() const
|
||||
{ return m_width; }
|
||||
|
||||
void height(int i)
|
||||
{ m_height=i; }
|
||||
void width(int i)
|
||||
{ m_width=i; }
|
||||
|
||||
protected:
|
||||
bool m_draw_unbounded=true;
|
||||
CGAL::IO::Color m_unbounded_face_color=CGAL::IO::Color(75,160,255);
|
||||
int m_width=0, m_height=0;
|
||||
};
|
||||
|
||||
namespace draw_function_for_boolean_set_2 {
|
||||
|
||||
template <typename PS2, class GSOptions>
|
||||
void compute_loop(const typename PS2::Polygon_2& p, bool hole,
|
||||
CGAL::Graphics_scene& gs,
|
||||
const GSOptions& gso)
|
||||
{
|
||||
if (gso.are_faces_enabled() && hole)
|
||||
{ gs.add_point_in_face(p.vertex(p.size()-1)); }
|
||||
|
||||
auto prev = p.vertices_begin();
|
||||
auto it = prev;
|
||||
|
||||
// First vertex
|
||||
if (gso.are_vertices_enabled() && gso.draw_vertex(p, it))
|
||||
{
|
||||
if(gso.colored_vertex(p, it))
|
||||
{ gs.add_point(*it, gso.vertex_color(p, it)); }
|
||||
else
|
||||
{ gs.add_point(*it); }
|
||||
}
|
||||
|
||||
if (gso.are_faces_enabled())
|
||||
{ gs.add_point_in_face(*it); }
|
||||
|
||||
// Other vertices
|
||||
for (++it; it!=p.vertices_end(); ++it)
|
||||
{
|
||||
if (gso.are_vertices_enabled() && gso.draw_vertex(p, it))
|
||||
{ // Add point
|
||||
if(gso.colored_vertex(p, it))
|
||||
{ gs.add_point(*it, gso.vertex_color(p, it)); }
|
||||
else
|
||||
{ gs.add_point(*it); }
|
||||
}
|
||||
|
||||
if (gso.are_edges_enabled() && gso.draw_edge(p, prev))
|
||||
{ // Add segment with previous point
|
||||
if(gso.colored_edge(p, prev))
|
||||
{ gs.add_segment(*prev, *it, gso.edge_color(p, prev)); }
|
||||
else
|
||||
{ gs.add_segment(*prev, *it); }
|
||||
}
|
||||
|
||||
if (gso.are_faces_enabled())
|
||||
{ gs.add_point_in_face(*it); } // add point in face
|
||||
prev = it;
|
||||
}
|
||||
|
||||
// Last segment (between last and first point)
|
||||
if (gso.are_edges_enabled() && gso.draw_edge(p, prev))
|
||||
{
|
||||
if(gso.colored_edge(p, prev))
|
||||
{ gs.add_segment(*prev, *(p.vertices_begin()), gso.edge_color(p, prev)); }
|
||||
else
|
||||
{ gs.add_segment(*prev, *(p.vertices_begin())); }
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute the elements of a polygon with holes.
|
||||
template <typename PWH, class GSOptions>
|
||||
void compute_elements(const PWH& pwh,
|
||||
CGAL::Graphics_scene& gs,
|
||||
const GSOptions& gso)
|
||||
{
|
||||
if (!gso.draw_unbounded() && pwh.outer_boundary().is_empty()) return;
|
||||
|
||||
if (gso.are_faces_enabled())
|
||||
{ gs.face_begin(gso.unbounded_face_color()); }
|
||||
|
||||
using Pnt=typename PWH::Polygon_2::Point_2;
|
||||
const Pnt* point_in_face=nullptr;
|
||||
if (pwh.outer_boundary().is_empty())
|
||||
{
|
||||
if(gso.width()!=0 && gso.height()!=0)
|
||||
{
|
||||
typename PWH::Polygon_2 pgn;
|
||||
pgn.push_back(Pnt(-gso.width(), -gso.height()));
|
||||
pgn.push_back(Pnt(gso.width(), -gso.height()));
|
||||
pgn.push_back(Pnt(gso.width(), gso.height()));
|
||||
pgn.push_back(Pnt(-gso.width(), gso.height()));
|
||||
draw_function_for_boolean_set_2::compute_loop<PWH>(pgn, false, gs, gso);
|
||||
point_in_face = &(pgn.vertex(pgn.size()-1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto& outer_boundary = pwh.outer_boundary();
|
||||
draw_function_for_boolean_set_2::compute_loop<PWH>(outer_boundary, false, gs, gso);
|
||||
point_in_face = &(outer_boundary.vertex(outer_boundary.size()-1));
|
||||
}
|
||||
|
||||
for (auto it = pwh.holes_begin(); it != pwh.holes_end(); ++it)
|
||||
{
|
||||
draw_function_for_boolean_set_2::compute_loop<PWH>(*it, true, gs, gso);
|
||||
if (gso.are_faces_enabled() && point_in_face && point_in_face!=nullptr)
|
||||
{ gs.add_point_in_face(*point_in_face); }
|
||||
}
|
||||
|
||||
if (gso.are_faces_enabled())
|
||||
{ gs.face_end(); }
|
||||
}
|
||||
|
||||
} // End namespace draw_function_for_boolean_set_2
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
template <typename PolygonSet_2, typename GSOptions>
|
||||
class Polygon_set_2_basic_viewer_qt : public Basic_viewer
|
||||
{
|
||||
using Base = Basic_viewer;
|
||||
using Ps = PolygonSet_2;
|
||||
using Pwh = typename Ps::Polygon_with_holes_2;
|
||||
using Pgn = typename Ps::Polygon_2;
|
||||
|
|
@ -60,13 +179,15 @@ class Polygon_set_2_basic_viewer_qt : public Basic_viewer_qt {
|
|||
|
||||
public:
|
||||
Polygon_set_2_basic_viewer_qt(QWidget* parent, const Ps& ps,
|
||||
const char* title = "Basic Polygon_set_2 Viewer",
|
||||
bool draw_unbounded = false,
|
||||
bool draw_vertices = false) :
|
||||
Base(parent, title, draw_vertices),
|
||||
GSOptions& gs_options,
|
||||
const char* title = "Basic Polygon_set_2 Viewer") :
|
||||
Base(parent, graphics_scene, title),
|
||||
m_ps(ps),
|
||||
m_draw_unbounded(draw_unbounded)
|
||||
gso(gs_options)
|
||||
{
|
||||
gso.width(CGAL_BASIC_VIEWER_INIT_SIZE_X);
|
||||
gso.height(CGAL_BASIC_VIEWER_INIT_SIZE_Y);
|
||||
|
||||
if (ps.is_empty()) return;
|
||||
|
||||
// mimic the computation of Camera::pixelGLRatio()
|
||||
|
|
@ -74,37 +195,39 @@ public:
|
|||
CGAL::qglviewer::Vec minv(bbox.xmin(), bbox.ymin(), 0);
|
||||
CGAL::qglviewer::Vec maxv(bbox.xmax(), bbox.ymax(), 0);
|
||||
auto diameter = (maxv - minv).norm();
|
||||
m_pixel_ratio = diameter / m_height;
|
||||
m_pixel_ratio = diameter / gso.height();
|
||||
}
|
||||
|
||||
/*! Intercept the resizing of the window.
|
||||
*/
|
||||
virtual void resizeGL(int width, int height) {
|
||||
CGAL::QGLViewer::resizeGL(width, height);
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
gso.width(width);
|
||||
gso.height(height);
|
||||
CGAL::qglviewer::Vec p;
|
||||
auto ratio = camera()->pixelGLRatio(p);
|
||||
if (ratio != m_pixel_ratio) {
|
||||
auto ratio = this->camera()->pixelGLRatio(p);
|
||||
if (ratio != m_pixel_ratio)
|
||||
{
|
||||
m_pixel_ratio = ratio;
|
||||
add_elements();
|
||||
}
|
||||
}
|
||||
|
||||
/*! Compute the elements of a polygon set.
|
||||
*/
|
||||
virtual void add_elements() {
|
||||
clear();
|
||||
|
||||
std::vector<Pwh> pwhs;
|
||||
m_ps.polygons_with_holes(std::back_inserter(pwhs));
|
||||
for (const auto& pwh : pwhs) add_elements(pwh);
|
||||
}
|
||||
|
||||
/*! Obtain the pixel ratio.
|
||||
*/
|
||||
double pixel_ratio() const { return m_pixel_ratio; }
|
||||
|
||||
/*! Compute the elements of a polygon set.
|
||||
*/
|
||||
virtual void add_elements()
|
||||
{
|
||||
graphics_scene.clear();
|
||||
std::vector<Pwh> pwhs;
|
||||
m_ps.polygons_with_holes(std::back_inserter(pwhs));
|
||||
for (const auto& pwh : pwhs)
|
||||
{ draw_function_for_boolean_set_2::compute_elements(pwh, graphics_scene, gso); }
|
||||
}
|
||||
|
||||
/*! Compute the bounding box.
|
||||
*/
|
||||
CGAL::Bbox_2 bounding_box() {
|
||||
|
|
@ -122,64 +245,7 @@ public:
|
|||
return bbox;
|
||||
}
|
||||
|
||||
protected:
|
||||
/*! Compute the elements of a polygon with holes.
|
||||
*/
|
||||
void add_elements(const Pwh& pwh) {
|
||||
if (! m_draw_unbounded && pwh.outer_boundary().is_empty()) return;
|
||||
|
||||
CGAL::IO::Color c(75,160,255);
|
||||
face_begin(c);
|
||||
|
||||
const Pnt* point_in_face;
|
||||
if (pwh.outer_boundary().is_empty()) {
|
||||
Pgn pgn;
|
||||
pgn.push_back(Pnt(-m_width, -m_height));
|
||||
pgn.push_back(Pnt(m_width, -m_height));
|
||||
pgn.push_back(Pnt(m_width, m_height));
|
||||
pgn.push_back(Pnt(-m_width, m_height));
|
||||
compute_loop(pgn, false);
|
||||
point_in_face = &(pgn.vertex(pgn.size()-1));
|
||||
}
|
||||
else {
|
||||
const auto& outer_boundary = pwh.outer_boundary();
|
||||
compute_loop(outer_boundary, false);
|
||||
point_in_face = &(outer_boundary.vertex(outer_boundary.size()-1));
|
||||
}
|
||||
|
||||
for (auto it = pwh.holes_begin(); it != pwh.holes_end(); ++it) {
|
||||
compute_loop(*it, true);
|
||||
add_point_in_face(*point_in_face);
|
||||
}
|
||||
|
||||
face_end();
|
||||
}
|
||||
|
||||
void compute_loop(const Pgn& p, bool hole) {
|
||||
if (hole) add_point_in_face(p.vertex(p.size()-1));
|
||||
|
||||
auto prev = p.vertices_begin();
|
||||
auto it = prev;
|
||||
add_point(*it);
|
||||
add_point_in_face(*it);
|
||||
for (++it; it != p.vertices_end(); ++it) {
|
||||
add_point(*it); // add vertex
|
||||
add_segment(*prev, *it); // add segment with previous point
|
||||
add_point_in_face(*it); // add point in face
|
||||
prev = it;
|
||||
}
|
||||
|
||||
// Add the last segment between the last point and the first one
|
||||
add_segment(*prev, *(p.vertices_begin()));
|
||||
}
|
||||
|
||||
private:
|
||||
//! The window width in pixels.
|
||||
int m_width = CGAL_BASIC_VIEWER_INIT_SIZE_X;
|
||||
|
||||
//! The window height in pixels.
|
||||
int m_height = CGAL_BASIC_VIEWER_INIT_SIZE_Y;
|
||||
|
||||
//! The ratio between pixel and opengl units (in world coordinate system).
|
||||
double m_pixel_ratio = 1;
|
||||
|
||||
|
|
@ -188,14 +254,39 @@ private:
|
|||
|
||||
//! Indicates whether to draw unbounded polygons with holes.
|
||||
bool m_draw_unbounded = false;
|
||||
|
||||
Graphics_scene graphics_scene;
|
||||
GSOptions& gso;
|
||||
};
|
||||
|
||||
// Specialization of draw function.
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#define CGAL_PS2_TYPE CGAL::Polygon_set_2<T, C, D>
|
||||
|
||||
// Specializations of add_to_graphics_scene function
|
||||
template<class T, class C, class D, class GSOptions>
|
||||
void add_to_graphics_scene(const CGAL_PS2_TYPE& ap2,
|
||||
CGAL::Graphics_scene& graphics_scene,
|
||||
const GSOptions& gso)
|
||||
{ draw_function_for_boolean_set_2::compute_elements(ap2, graphics_scene, gso); }
|
||||
|
||||
template<class T, class C, class D>
|
||||
void draw(const CGAL::Polygon_set_2<T, C, D>& ps,
|
||||
const char* title = "Polygon_set_2 Basic Viewer",
|
||||
bool draw_vertices = false,
|
||||
bool draw_unbounded = false)
|
||||
void add_to_graphics_scene(const CGAL_PS2_TYPE& ap2,
|
||||
CGAL::Graphics_scene &graphics_scene)
|
||||
{
|
||||
CGAL::Graphics_scene_options_polygon_set_2<typename CGAL_PS2_TYPE::Polygon_2,
|
||||
typename CGAL_PS2_TYPE::Vertex_const_iterator,
|
||||
typename CGAL_PS2_TYPE::Vertex_const_iterator,
|
||||
void*> gso;
|
||||
draw_function_for_boolean_set_2::compute_elements(ap2, graphics_scene, gso);
|
||||
}
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
// Specialization of draw function.
|
||||
template<class T, class C, class D, class GSOptions>
|
||||
void draw(const CGAL_PS2_TYPE& ps, GSOptions& gso,
|
||||
const char* title = "Polygon_set_2 Basic Viewer")
|
||||
{
|
||||
#if defined(CGAL_TEST_SUITE)
|
||||
bool cgal_test_suite = true;
|
||||
|
|
@ -203,22 +294,35 @@ void draw(const CGAL::Polygon_set_2<T, C, D>& ps,
|
|||
bool cgal_test_suite = qEnvironmentVariableIsSet("CGAL_TEST_SUITE");
|
||||
#endif
|
||||
|
||||
if (! cgal_test_suite) {
|
||||
if (! cgal_test_suite)
|
||||
{
|
||||
using Ps = CGAL::Polygon_set_2<T, C, D>;
|
||||
using Viewer = Polygon_set_2_basic_viewer_qt<Ps>;
|
||||
using Viewer = Polygon_set_2_basic_viewer_qt<Ps, GSOptions>;
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc = 1;
|
||||
const char* argv[2] = {"t2_viewer", nullptr};
|
||||
QApplication app(argc, const_cast<char**>(argv));
|
||||
Viewer mainwindow(app.activeWindow(), ps, title, draw_unbounded, draw_vertices);
|
||||
mainwindow.add_elements();
|
||||
mainwindow.show();
|
||||
Viewer basic_viewer(app.activeWindow(), ps, gso, title);
|
||||
basic_viewer.show();
|
||||
app.exec();
|
||||
}
|
||||
}
|
||||
|
||||
} // End namespace CGAL
|
||||
template<class T, class C, class D>
|
||||
void draw(const CGAL_PS2_TYPE& ps,
|
||||
const char* title = "Polygon_set_2 Basic Viewer")
|
||||
{
|
||||
CGAL::Graphics_scene_options_polygon_set_2<typename CGAL_PS2_TYPE::Polygon_2,
|
||||
typename CGAL_PS2_TYPE::Polygon_2::Vertex_const_iterator,
|
||||
typename CGAL_PS2_TYPE::Polygon_2::Vertex_const_iterator,
|
||||
void*> gso;
|
||||
draw(ps, gso, title);
|
||||
}
|
||||
|
||||
#endif // CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#undef CGAL_PS2_TYPE
|
||||
|
||||
} // End namespace CGAL
|
||||
|
||||
#endif // CGAL_DRAW_POLYGON_SET_2_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
Algebraic_foundations
|
||||
Arithmetic_kernel
|
||||
Arrangement_on_surface_2
|
||||
BGL
|
||||
Basic_viewer
|
||||
Boolean_set_operations_2
|
||||
CGAL_Core
|
||||
Cartesian_kernel
|
||||
|
|
@ -9,7 +11,6 @@ Circulator
|
|||
Distance_2
|
||||
Distance_3
|
||||
Filtered_kernel
|
||||
GraphicsView
|
||||
HalfedgeDS
|
||||
Hash_map
|
||||
Homogeneous_kernel
|
||||
|
|
@ -23,7 +24,12 @@ Modular_arithmetic
|
|||
Number_types
|
||||
Polygon
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Spatial_sorting
|
||||
Stream_support
|
||||
Surface_sweep_2
|
||||
TDS_2
|
||||
Triangulation_2
|
||||
Union_find
|
||||
|
|
|
|||
|
|
@ -20,6 +20,5 @@ Modular_arithmetic
|
|||
Number_types
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Stream_support
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ Polygon
|
|||
Polyhedron
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Spatial_sorting
|
||||
Stream_support
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <CGAL/Number_types/internal/Exact_type_selector.h>
|
||||
#include <CGAL/boost/graph/copy_face_graph.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
#include <CGAL/Named_function_parameters.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h>
|
||||
#include <CGAL/boost/graph/properties_Triangulation_data_structure_2.h>
|
||||
|
|
|
|||
|
|
@ -354,6 +354,10 @@ configure_file(${CGAL_DOC_RESOURCE_DIR}/BaseDoxyfile.in
|
|||
|
||||
set(CGAL_DOC_DOXY_DEFAULT "${CGAL_DOC_DXY_DIR}/BaseDoxyfile")
|
||||
|
||||
if (BE_QUIET)
|
||||
file(APPEND ${CGAL_DOC_DOXY_DEFAULT} "WARN_LOGFILE=doxygen.log\n")
|
||||
endif()
|
||||
|
||||
# pkglist_filter gets the path to the pkglist_filter of this source
|
||||
# directory.
|
||||
if(WIN32)
|
||||
|
|
|
|||
|
|
@ -168,5 +168,6 @@
|
|||
|
||||
\package_listing{GraphicsView}
|
||||
\package_listing{CGAL_ipelets}
|
||||
\package_listing{Basic_viewer}
|
||||
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <CGAL/Bbox_2.h>
|
||||
#include <CGAL/Polygon_with_holes_2.h>
|
||||
#include <CGAL/apply_to_range.h>
|
||||
#include <CGAL/Qt/PainterOstream.h>
|
||||
#include <CGAL/Qt/GraphicsItem.h>
|
||||
#include <CGAL/Qt/Converter.h>
|
||||
|
|
|
|||
|
|
@ -11,4 +11,3 @@ Number_types
|
|||
Profiling_tools
|
||||
STL_Extension
|
||||
Stream_support
|
||||
Triangulation_2
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <memory>
|
||||
#include <CGAL/boost/graph/internal/Has_member_id.h>
|
||||
#include <CGAL/Distance_3/Point_3_Point_3.h>
|
||||
#include <CGAL/Dynamic_property_map.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
|
|
@ -126,11 +127,20 @@ typename boost::property_map<CGAL_HDS_CLASS, PropertyTag >::type
|
|||
get(PropertyTag,CGAL_HDS_CLASS&)
|
||||
{ return typename boost::property_map<CGAL_HDS_CLASS, PropertyTag >::type(); }
|
||||
|
||||
|
||||
// generalized 3-ary get functions
|
||||
template<class CGAL_HDS_TMPLT, class PropertyTag, class Key>
|
||||
template<class CGAL_HDS_TMPLT, class PropertyTag, class Key,
|
||||
class F = std::enable_if_t<!std::is_same_v<PropertyTag, dynamic_vertex_property_t<Key>> &&
|
||||
!std::is_same_v<PropertyTag, dynamic_halfedge_property_t<Key>> &&
|
||||
!std::is_same_v<PropertyTag, dynamic_edge_property_t<Key>> &&
|
||||
!std::is_same_v<PropertyTag, dynamic_face_property_t<Key>>
|
||||
>
|
||||
>
|
||||
typename boost::property_traits< typename boost::property_map<CGAL_HDS_CLASS, PropertyTag >::type >::reference
|
||||
get(PropertyTag p,CGAL_HDS_CLASS& g, const Key& key)
|
||||
{ return get(get(p, g), key); }
|
||||
{
|
||||
return get(get(p, g), key);
|
||||
}
|
||||
|
||||
template<class CGAL_HDS_TMPLT, class PropertyTag, class Key>
|
||||
typename boost::property_traits< typename boost::property_map<CGAL_HDS_CLASS, PropertyTag >::const_type >::reference
|
||||
|
|
@ -139,13 +149,13 @@ get(PropertyTag p,CGAL_HDS_CLASS const& g, const Key& key)
|
|||
|
||||
|
||||
|
||||
#define DECLARE_HDS_DYNAMIC_PM(TAG, DESCRIPTOR) \
|
||||
#define DECLARE_HDS_DYNAMIC_PM(TAG, DESCRIPTOR) \
|
||||
template <typename CGAL_HDS_TMPLT, class T> \
|
||||
typename boost::property_map<CGAL_HDS_CLASS, TAG >::const_type \
|
||||
get(const TAG&, const CGAL_HDS_CLASS&) \
|
||||
{ \
|
||||
get(const TAG&, const CGAL_HDS_CLASS&, const T& dv = T()) \
|
||||
{ \
|
||||
typedef typename boost::graph_traits< CGAL_HDS_CLASS >::DESCRIPTOR descriptor; \
|
||||
return internal::Dynamic_property_map<descriptor,T>(); \
|
||||
return internal::Dynamic_property_map<descriptor,T>(dv); \
|
||||
}
|
||||
|
||||
DECLARE_HDS_DYNAMIC_PM(dynamic_vertex_property_t<T>, vertex_descriptor)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
#include <CGAL/Linear_cell_complex_for_generalized_map.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Arrangement_2.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
|
||||
#include <CGAL/boost/graph/generators.h>
|
||||
#include <map>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <CGAL/boost/graph/helpers.h>
|
||||
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ Modular_arithmetic
|
|||
Number_types
|
||||
Profiling_tools
|
||||
Property_map
|
||||
Random_numbers
|
||||
STL_Extension
|
||||
Solver_interface
|
||||
Stream_support
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ Release date: October 2023
|
|||
|
||||
- **Breaking change**: C++17 is now required
|
||||
- Support for Visual `C++` 14.0 (Visual studio 2015) is dropped.
|
||||
- The demos as well as the `draw()` functions using the `Basic_viewer` are based on Qt6
|
||||
- The demos as well as the `Basic_viewer` are based on Qt6.
|
||||
- The `Basic_viewer` is improved and documented.
|
||||
- **Breaking change**: The usage of `boost::shared_ptr` has been replaced by `std::shared_ptr`. Packages affected are 2D Straight Line Skeleton and Shape Detection.
|
||||
- **Breaking change**: The usage of `boost::optional` has been replaced by `std::optional`. Packages affected are 2D Straight Line Skeleton, 3D Fast Intersection and Distance Computation (AABB Tree), and the Kernel intersection.
|
||||
- **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection.
|
||||
|
|
@ -72,6 +73,8 @@ Release date: October 2023
|
|||
`CGAL::Polygon_mesh_processing::autorefine_triangle_soup()` that refines a soup of triangles so that no pair of triangles intersects
|
||||
in their interiors. Also added, the function `autorefine()` operating directly on a triangle mesh and updating it
|
||||
using the aforementioned function on a triangle soup.
|
||||
- Added the function `CGAL::Polygon_mesh_processing::add_bbox()` that enables to add a tight or extended, triangulated or not,
|
||||
bounding box to a face graph.
|
||||
|
||||
### [2D Arrangements](https://doc.cgal.org/6.0/Manual/packages.html#PkgArrangementOnSurface2)
|
||||
- Fixed a bug in the zone construction code applied to arrangements of geodesic arcs on a sphere,
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ if(CGAL_BRANCH_BUILD)
|
|||
set(CGAL_GRAPHICSVIEW_PACKAGE_DIR
|
||||
"${CGAL_SOURCE_DIR}/GraphicsView"
|
||||
CACHE INTERNAL "Directory containing the GraphicsView package")
|
||||
file(GLOB INCLUDE_CGAL_QT_DIRECTORIES "${CGAL_SOURCE_DIR}/*/include/CGAL/Qt")
|
||||
message(STATUS "Include CGAL/Qt directories: ${INCLUDE_CGAL_QT_DIRECTORIES}")
|
||||
|
||||
message(STATUS "Installation package directory: ${CGAL_INSTALLATION_PACKAGE_DIR}")
|
||||
message(STATUS "Maintenance package directory: ${CGAL_MAINTENANCE_PACKAGE_DIR}")
|
||||
|
|
@ -104,6 +106,7 @@ else(CGAL_BRANCH_BUILD)
|
|||
set(CGAL_GRAPHICSVIEW_PACKAGE_DIR
|
||||
"${CGAL_SOURCE_DIR}"
|
||||
CACHE INTERNAL "Directory containing the GraphicsView package")
|
||||
set(INCLUDE_CGAL_QT_DIRECTORIES "${CGAL_SOURCE_DIR}/include/CGAL/Qt")
|
||||
|
||||
# Enable testing with CGAL_ENABLE_TESTING. Before CGAL-6.0, users would enable
|
||||
# the tests by specifying BUILD_TESTING. For compatibility, If BUILD_TESTING is
|
||||
|
|
@ -652,7 +655,7 @@ cache_get(CGAL_3RD_PARTY_INCLUDE_DIRS )
|
|||
cache_get(CGAL_3RD_PARTY_LIBRARIES )
|
||||
cache_get(CGAL_3RD_PARTY_LIBRARIES_DIRS)
|
||||
|
||||
install(DIRECTORY "${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/include/CGAL/Qt/" DESTINATION "${CGAL_INSTALL_INC_DIR}/CGAL/Qt" COMPONENT CGAL_Qt6)
|
||||
install(DIRECTORY ${INCLUDE_CGAL_QT_DIRECTORIES} DESTINATION "${CGAL_INSTALL_INC_DIR}/CGAL/" COMPONENT CGAL_Qt6)
|
||||
if(CGAL_BRANCH_BUILD)
|
||||
install(DIRECTORY "${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/demo/resources/" DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/demo/resources" COMPONENT CGAL_Qt6)
|
||||
install(DIRECTORY "${CGAL_GRAPHICSVIEW_PACKAGE_DIR}/demo/icons/" DESTINATION "${CGAL_INSTALL_CMAKE_DIR}/demo/icons" COMPONENT CGAL_Qt6)
|
||||
|
|
@ -1052,7 +1055,7 @@ You must disable CGAL_ENABLE_CHECK_HEADERS.")
|
|||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -DCGAL_BUILD_THREE_DOC=TRUE
|
||||
-DDOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE}
|
||||
-DDOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE} -DBE_QUIET=TRUE
|
||||
"${CGAL_SOURCE_DIR}/Documentation/doc"
|
||||
WORKING_DIRECTORY "${DOC_DIR}")
|
||||
execute_process(
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ set(CGAL_SetupCGAL_Qt6Dependencies_included TRUE)
|
|||
# ^^^^^^^^^^^^
|
||||
# - :module:`Qt6Config`
|
||||
|
||||
find_package(Qt6 QUIET COMPONENTS Widgets OpenGL OpenGLWidgets OPTIONAL_COMPONENTS Svg)
|
||||
find_package(Qt6 QUIET COMPONENTS OpenGL OpenGLWidgets Widgets OPTIONAL_COMPONENTS Svg)
|
||||
|
||||
set(CGAL_Qt6_MISSING_DEPS "")
|
||||
if(NOT Qt6OpenGLWidgets_FOUND)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ set(list_of_whitelisted_headers_txt [=[
|
|||
CGAL/Three/Edge_container.h
|
||||
CGAL/Three/exceptions.h
|
||||
CGAL/Three/Point_container.h
|
||||
CGAL/Three/Polyhedron_demo_io_plugin_interface.h
|
||||
CGAL/Three/Polyhedron_demo_plugin_helper.h
|
||||
CGAL/Three/Polyhedron_demo_plugin_interface.h
|
||||
CGAL/Three/CGAL_Lab_io_plugin_interface.h
|
||||
CGAL/Three/CGAL_Lab_plugin_helper.h
|
||||
CGAL/Three/CGAL_Lab_plugin_interface.h
|
||||
CGAL/Three/Primitive_container.h
|
||||
CGAL/Three/Scene_draw_interface.h
|
||||
CGAL/Three/Scene_group_item.h
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ dilates the bounding box by a specified number of ULP.
|
|||
*/
|
||||
void dilate(int dist);
|
||||
|
||||
/*!
|
||||
scales the bounding box by `factor`, while keeping its center fixed.
|
||||
\pre `factor > 0`
|
||||
*/
|
||||
void scale(double factor);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Bbox_2 */
|
||||
|
|
|
|||
|
|
@ -115,6 +115,13 @@ Bbox_3& operator+=(const Bbox_3 &c);
|
|||
dilates the bounding box by a specified number of ULP.
|
||||
*/
|
||||
void dilate(int dist);
|
||||
|
||||
/*!
|
||||
scales the bounding box by `factor`, while keeping its center fixed.
|
||||
\pre `factor > 0`
|
||||
*/
|
||||
void scale(double factor);
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Bbox_3 */
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ public:
|
|||
inline Bbox_2& operator+=(const Bbox_2 &b);
|
||||
|
||||
inline void dilate(int dist);
|
||||
inline void scale(double factor);
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
@ -170,6 +171,25 @@ Bbox_2::dilate(int dist)
|
|||
rep[3] = float_advance(rep[3],dist);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
Bbox_2::scale(double factor)
|
||||
{
|
||||
CGAL_precondition(factor > 0);
|
||||
|
||||
if(factor == 1.)
|
||||
return;
|
||||
|
||||
std::array<double, 2> half_width = { (xmax() - xmin()) * 0.5,
|
||||
(ymax() - ymin()) * 0.5 };
|
||||
std::array<double, 2> center = { xmin() + half_width[0],
|
||||
ymin() + half_width[1] };
|
||||
rep[0] = center[0] - factor * half_width[0];
|
||||
rep[1] = center[1] - factor * half_width[1];
|
||||
rep[2] = center[0] + factor * half_width[0];
|
||||
rep[3] = center[1] + factor * half_width[1];
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
do_overlap(const Bbox_2 &bb1, const Bbox_2 &bb2)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ public:
|
|||
Bbox_3 operator+(const Bbox_3& b) const;
|
||||
Bbox_3& operator+=(const Bbox_3& b);
|
||||
|
||||
void dilate(int dist);
|
||||
inline void dilate(int dist);
|
||||
inline void scale(double factor);
|
||||
};
|
||||
|
||||
inline
|
||||
|
|
@ -200,6 +201,28 @@ Bbox_3::dilate(int dist)
|
|||
rep[5] = float_advance(rep[5],dist);
|
||||
}
|
||||
|
||||
inline
|
||||
void
|
||||
Bbox_3::scale(double factor)
|
||||
{
|
||||
CGAL_precondition(factor > 0);
|
||||
|
||||
if (factor == 1.)
|
||||
return;
|
||||
|
||||
std::array<double, 3> half_width = { (xmax() - xmin()) * 0.5,
|
||||
(ymax() - ymin()) * 0.5,
|
||||
(zmax() - zmin()) * 0.5 };
|
||||
std::array<double, 3> center = { xmin() + half_width[0],
|
||||
ymin() + half_width[1],
|
||||
zmin() + half_width[2] };
|
||||
rep[0] = center[0] - factor * half_width[0];
|
||||
rep[1] = center[1] - factor * half_width[1];
|
||||
rep[2] = center[2] - factor * half_width[2];
|
||||
rep[3] = center[0] + factor * half_width[0];
|
||||
rep[4] = center[1] + factor * half_width[1];
|
||||
rep[5] = center[2] + factor * half_width[2];
|
||||
}
|
||||
|
||||
inline
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "Plugins/Mesh_3/config_mesh_3.h"
|
||||
// as otherwise it gets set via inclusion of Polyhedron_3.h
|
||||
// as otherwise it gets set via inclusion of cgallab.h
|
||||
#include <CGAL/Default.h>
|
||||
|
||||
#include "SMesh_type.h"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "Polyhedron_demo.h"
|
||||
#include "cgallab.h"
|
||||
#include "MainWindow.h"
|
||||
#include <QMessageBox>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
|
|
@ -11,12 +11,12 @@
|
|||
#include <clocale>
|
||||
|
||||
|
||||
struct Polyhedron_demo_impl {
|
||||
struct CGAL_Lab_impl {
|
||||
bool catch_exceptions;
|
||||
QScopedPointer<MainWindow> mainWindow;
|
||||
|
||||
Polyhedron_demo_impl() : catch_exceptions(true) {}
|
||||
}; // end struct Polyhedron_demo_impl
|
||||
CGAL_Lab_impl() : catch_exceptions(true) {}
|
||||
}; // end struct CGAL_Lab_impl
|
||||
|
||||
int& code_to_call_before_creation_of_QCoreApplication(int& i) {
|
||||
QSurfaceFormat fmt;
|
||||
|
|
@ -35,7 +35,7 @@ int& code_to_call_before_creation_of_QCoreApplication(int& i) {
|
|||
return i;
|
||||
}
|
||||
|
||||
Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
|
||||
CGAL_Lab::CGAL_Lab(int& argc, char **argv,
|
||||
QString application_name,
|
||||
QString main_window_title,
|
||||
QStringList input_keywords)
|
||||
|
|
@ -45,7 +45,7 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
|
|||
// object.
|
||||
argv)
|
||||
, d_ptr_is_initialized(false)
|
||||
, d_ptr(new Polyhedron_demo_impl)
|
||||
, d_ptr(new CGAL_Lab_impl)
|
||||
{
|
||||
//We set the locale to avoid any trouble with VTK
|
||||
std::setlocale(LC_ALL, "C");
|
||||
|
|
@ -129,7 +129,7 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
|
|||
}
|
||||
#endif
|
||||
|
||||
mainWindow.loadScript(":/cgal/Polyhedron_3/javascript/lib.js");
|
||||
mainWindow.loadScript(":/cgal/Lab/javascript/lib.js");
|
||||
QFileInfo autostart_js("autostart.js");
|
||||
if(!parser.isSet(no_autostart) && autostart_js.exists()) {
|
||||
mainWindow.loadScript(autostart_js);
|
||||
|
|
@ -140,14 +140,14 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
|
|||
|
||||
}
|
||||
|
||||
Polyhedron_demo::~Polyhedron_demo() {}
|
||||
CGAL_Lab::~CGAL_Lab() {}
|
||||
|
||||
void Polyhedron_demo::do_not_catch_exceptions() {
|
||||
void CGAL_Lab::do_not_catch_exceptions() {
|
||||
d_ptr->catch_exceptions = false;
|
||||
setProperty("no-try-catch", true);
|
||||
}
|
||||
|
||||
bool Polyhedron_demo::notify(QObject* receiver, QEvent* event)
|
||||
bool CGAL_Lab::notify(QObject* receiver, QEvent* event)
|
||||
{
|
||||
if(!d_ptr_is_initialized || !d_ptr->catch_exceptions)
|
||||
return QApplication::notify(receiver, event);
|
||||
|
|
@ -171,7 +171,7 @@ bool Polyhedron_demo::notify(QObject* receiver, QEvent* event)
|
|||
return false;
|
||||
}
|
||||
|
||||
int Polyhedron_demo::try_exec()
|
||||
int CGAL_Lab::try_exec()
|
||||
{
|
||||
// A Qt Script may have closed the main window.
|
||||
// The following loop launch app.exec() only if the main window is visible.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
#ifndef POLYHEDRON_DEMO_DETECT_SHARP_EDGES_H
|
||||
#define POLYHEDRON_DEMO_DETECT_SHARP_EDGES_H
|
||||
#ifndef LAB_DEMO_DETECT_SHARP_EDGES_H
|
||||
#define LAB_DEMO_DETECT_SHARP_EDGES_H
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/detect_features.h>
|
||||
|
||||
|
|
@ -29,4 +29,4 @@ namespace CGAL
|
|||
|
||||
}//end namespace CGAL
|
||||
|
||||
#endif //POLYHEDRON_DEMO_DETECT_SHARP_EDGES_H
|
||||
#endif //LAB_DEMO_DETECT_SHARP_EDGES_H
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.1...3.23)
|
||||
project(Polyhedron_Demo)
|
||||
project(Lab_Demo)
|
||||
include(FeatureSummary)
|
||||
|
||||
|
||||
|
|
@ -32,9 +32,6 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
|||
include_directories(BEFORE ./ ./include ./CGAL_demo)
|
||||
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
option(POLYHEDRON_QTSCRIPT_DEBUGGER
|
||||
"Activate the use of Qt Script Debugger in Polyhedron_3 demo" OFF)
|
||||
|
||||
# Find CGAL
|
||||
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt6 ImageIO)
|
||||
set_package_properties(CGAL PROPERTIES TYPE REQUIRED)
|
||||
|
|
@ -73,8 +70,8 @@ set_package_properties(
|
|||
PURPOSE "Required for the partition plugin.")
|
||||
|
||||
# Activate concurrency?
|
||||
option(POLYHEDRON_DEMO_ACTIVATE_CONCURRENCY "Enable concurrency" ON)
|
||||
if(POLYHEDRON_DEMO_ACTIVATE_CONCURRENCY)
|
||||
option(LAB_DEMO_ACTIVATE_CONCURRENCY "Enable concurrency" ON)
|
||||
if(LAB_DEMO_ACTIVATE_CONCURRENCY)
|
||||
find_package(TBB QUIET)
|
||||
include(CGAL_TBB_support)
|
||||
if(NOT TARGET CGAL::TBB_support)
|
||||
|
|
@ -130,9 +127,9 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
qt6_generate_moc("File_loader_dialog.h"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/File_loader_dialog_moc.cpp")
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/polyhedron_demo_macros.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cgallab_macros.cmake)
|
||||
|
||||
qt6_add_resources(CGAL_Qt6_RESOURCE_FILES Polyhedron_3.qrc)
|
||||
qt6_add_resources(CGAL_Qt6_RESOURCE_FILES cgallab.qrc)
|
||||
find_path(
|
||||
CGAL_THREE_HEADERS_PATH
|
||||
NAMES CGAL/Three/Scene_item.h
|
||||
|
|
@ -162,8 +159,8 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
|
||||
# put plugins (which are shared libraries) at the same location as
|
||||
# executable files
|
||||
set(CGAL_POLYHEDRON_DEMO_PLUGINS_DIR "${RUNTIME_OUTPUT_PATH}")
|
||||
set(LIBRARY_OUTPUT_PATH "${CGAL_POLYHEDRON_DEMO_PLUGINS_DIR}")
|
||||
set(CGAL_LAB_DEMO_PLUGINS_DIR "${RUNTIME_OUTPUT_PATH}")
|
||||
set(LIBRARY_OUTPUT_PATH "${CGAL_LAB_DEMO_PLUGINS_DIR}")
|
||||
|
||||
add_library(
|
||||
demo_framework SHARED
|
||||
|
|
@ -187,7 +184,7 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
Scene_item_rendering_helper.cpp
|
||||
Scene_item_rendering_helper_moc.cpp
|
||||
Primitive_container.cpp
|
||||
Polyhedron_demo_plugin_helper.cpp
|
||||
cgallab_plugin_helper.cpp
|
||||
CGAL_double_edit.cpp)
|
||||
target_link_libraries(demo_framework PUBLIC Qt6::OpenGLWidgets Qt6::Widgets Qt6::Gui Qt6::Qml
|
||||
CGAL::CGAL_Qt6)
|
||||
|
|
@ -350,9 +347,9 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
|
||||
add_definitions(-DUSE_FORWARD_DECL)
|
||||
add_library(
|
||||
polyhedron_demo SHARED
|
||||
cgal_lab SHARED
|
||||
MainWindow.cpp
|
||||
Polyhedron_demo.cpp
|
||||
CGAL_Lab.cpp
|
||||
File_loader_dialog_moc.cpp
|
||||
Use_ssh.cpp
|
||||
${CGAL_Qt6_RESOURCE_FILES}
|
||||
|
|
@ -363,30 +360,30 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
${statisticsUI_FILES}
|
||||
${SubViewerUI_files})
|
||||
target_link_libraries(
|
||||
polyhedron_demo PUBLIC demo_framework point_dialog Qt6::Gui Qt6::OpenGLWidgets
|
||||
cgal_lab PUBLIC demo_framework point_dialog Qt6::Gui Qt6::OpenGLWidgets
|
||||
Qt6::Widgets )
|
||||
if(LIBSSH_FOUND)
|
||||
target_compile_definitions(polyhedron_demo PRIVATE -DCGAL_USE_SSH)
|
||||
target_link_libraries(polyhedron_demo PRIVATE ${LIBSSH_LIBRARIES})
|
||||
target_include_directories(polyhedron_demo SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIR})
|
||||
target_compile_definitions(cgal_lab PRIVATE -DCGAL_USE_SSH)
|
||||
target_link_libraries(cgal_lab PRIVATE ${LIBSSH_LIBRARIES})
|
||||
target_include_directories(cgal_lab SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIR})
|
||||
endif() #libssh
|
||||
if(TARGET Qt6::WebSockets)
|
||||
target_compile_definitions(polyhedron_demo PRIVATE -DCGAL_USE_WEBSOCKETS)
|
||||
target_compile_definitions(cgal_lab PRIVATE -DCGAL_USE_WEBSOCKETS)
|
||||
target_compile_definitions(demo_framework PRIVATE -DCGAL_USE_WEBSOCKETS)
|
||||
target_link_libraries(polyhedron_demo PRIVATE Qt6::WebSockets)
|
||||
target_link_libraries(cgal_lab PRIVATE Qt6::WebSockets)
|
||||
endif()
|
||||
cgal_add_compilation_test(polyhedron_demo)
|
||||
add_executable(Polyhedron_3 Polyhedron_3.cpp)
|
||||
target_link_libraries(Polyhedron_3 PRIVATE polyhedron_demo)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS Polyhedron_3)
|
||||
cgal_add_compilation_test(Polyhedron_3)
|
||||
cgal_add_compilation_test(cgal_lab)
|
||||
add_executable(cgallab cgallab.cpp)
|
||||
target_link_libraries(cgallab PRIVATE cgal_lab)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS cgallab)
|
||||
cgal_add_compilation_test(cgallab)
|
||||
|
||||
target_link_libraries(Polyhedron_3 PRIVATE demo_framework)
|
||||
target_link_libraries(cgallab PRIVATE demo_framework)
|
||||
|
||||
# Link with CGAL
|
||||
target_link_libraries(Polyhedron_3 PUBLIC CGAL::CGAL_Qt6)
|
||||
target_link_libraries(cgallab PUBLIC CGAL::CGAL_Qt6)
|
||||
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS Polyhedron_3)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS cgallab)
|
||||
|
||||
###########
|
||||
# PLUGINS #
|
||||
|
|
@ -407,17 +404,17 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
#
|
||||
add_executable(CGAL_Mesh_3 Mesh_3.cpp)
|
||||
add_dependencies(CGAL_Mesh_3 Mesh_3)
|
||||
target_link_libraries(CGAL_Mesh_3 PRIVATE polyhedron_demo)
|
||||
target_link_libraries(CGAL_Mesh_3 PRIVATE cgal_lab)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_Mesh_3)
|
||||
|
||||
add_executable(CGAL_Classification Classification.cpp)
|
||||
add_dependencies(CGAL_Classification Classification)
|
||||
target_link_libraries(CGAL_Classification PRIVATE polyhedron_demo)
|
||||
target_link_libraries(CGAL_Classification PRIVATE cgal_lab)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_Classification)
|
||||
|
||||
add_executable(CGAL_PMP PMP.cpp)
|
||||
add_dependencies(CGAL_PMP PMP)
|
||||
target_link_libraries(CGAL_PMP PRIVATE polyhedron_demo)
|
||||
target_link_libraries(CGAL_PMP PRIVATE cgal_lab)
|
||||
add_to_cached_list(CGAL_EXECUTABLE_TARGETS CGAL_PMP)
|
||||
|
||||
#WS Server
|
||||
|
|
@ -432,14 +429,14 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
if(TARGET CGAL_Qt6)
|
||||
export(
|
||||
TARGETS CGAL CGAL_Qt6 CGAL_ImageIO
|
||||
FILE polyhedron_demo_targets.cmake
|
||||
NAMESPACE Polyhedron_)
|
||||
FILE cgal_lab_targets.cmake
|
||||
NAMESPACE Lab_)
|
||||
endif()
|
||||
if(TARGET CGAL_Qt6_moc_and_resources)
|
||||
export(
|
||||
TARGETS CGAL_Qt6_moc_and_resources
|
||||
NAMESPACE Polyhedron_ APPEND
|
||||
FILE polyhedron_demo_targets.cmake)
|
||||
NAMESPACE Lab_ APPEND
|
||||
FILE cgal_lab_targets.cmake)
|
||||
endif()
|
||||
export(
|
||||
TARGETS demo_framework
|
||||
|
|
@ -452,26 +449,26 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
|||
scene_selection_item
|
||||
scene_item_decorator
|
||||
scene_k_ring_selection
|
||||
NAMESPACE Polyhedron_ APPEND
|
||||
FILE polyhedron_demo_targets.cmake)
|
||||
NAMESPACE Lab_ APPEND
|
||||
FILE cgal_lab_targets.cmake)
|
||||
|
||||
configure_file(CGAL_polyhedron_demoConfig.cmake.in
|
||||
CGAL_polyhedron_demoConfig.cmake)
|
||||
configure_file(cgallabConfig.cmake.in
|
||||
cgallabConfig.cmake)
|
||||
#TO DO script the activation of all the plugins.
|
||||
|
||||
else(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
||||
|
||||
set(POLYHEDRON_MISSING_DEPS "")
|
||||
set(Lab_MISSING_DEPS "")
|
||||
|
||||
if(NOT CGAL_Qt6_FOUND)
|
||||
set(POLYHEDRON_MISSING_DEPS "the CGAL Qt6 library, ${POLYHEDRON_MISSING_DEPS}")
|
||||
set(Lab_MISSING_DEPS "the CGAL Qt6 library, ${Lab_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
if(NOT Qt6_FOUND)
|
||||
set(POLYHEDRON_MISSING_DEPS "Qt6, ${POLYHEDRON_MISSING_DEPS}")
|
||||
set(Lab_MISSING_DEPS "Qt6, ${Lab_MISSING_DEPS}")
|
||||
endif()
|
||||
|
||||
message("NOTICE: XX This demo requires ${POLYHEDRON_MISSING_DEPS} and will not be compiled.")
|
||||
message("NOTICE: XX This demo requires ${Lab_MISSING_DEPS} and will not be compiled.")
|
||||
|
||||
endif(CGAL_Qt6_FOUND AND Qt6_FOUND)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#include "Polyhedron_demo.h"
|
||||
#include "cgallab.h"
|
||||
#include <clocale>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <QSurfaceFormat>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
*/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Polyhedron_demo app(argc, argv,
|
||||
CGAL_Lab app(argc, argv,
|
||||
"Classification demo",
|
||||
"CGAL Classification Demo",
|
||||
QStringList() << "Classification");
|
||||