Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSoC'22: New CGAL's design to handle basic viewers #6967

Merged
merged 350 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
350 commits
Select commit Hold shift + click to select a range
0db66d1
example draw sm
gdamiand Oct 14, 2022
549fe77
create examples directory for basic viewer
gdamiand Oct 14, 2022
89f7e05
some drawing functor are necessary non null; review of draw for lcc.
gdamiand Oct 14, 2022
1e8ef8f
Update LCC demo to use a 'better' color for faces.
gdamiand Oct 17, 2022
58fead2
draw nef3 review
gdamiand Oct 17, 2022
8e93b8c
spaces
gdamiand Oct 17, 2022
1b1e699
Review point set 3
gdamiand Oct 17, 2022
72c7608
review draw polygon2
gdamiand Oct 18, 2022
199499b
Review draw polygon with holes
gdamiand Oct 18, 2022
2970aa5
review draw triangulation2
gdamiand Oct 18, 2022
0d49e61
add missing include
gdamiand Oct 18, 2022
999d496
review draw triangulation3
gdamiand Oct 18, 2022
8c546ef
code review for polygon triangulation
gdamiand Oct 18, 2022
d1eed1d
start straight skeleton 2, NYF
gdamiand Oct 18, 2022
14848d4
Add a class allowing to create a qt application and a basic viewer, w…
gdamiand Oct 19, 2022
2f07ea2
review draw voronoi 2
gdamiand Oct 19, 2022
09eaba2
move functor for voronoi
gdamiand Oct 19, 2022
655b0c8
review draw periodic triangulation 2
gdamiand Oct 19, 2022
e18a573
add missing include
gdamiand Oct 19, 2022
9da6a6d
add missing include
gdamiand Oct 19, 2022
779fea4
use references
gdamiand Oct 19, 2022
fb80b2f
add missing include
gdamiand Oct 19, 2022
4377f52
add missing include
gdamiand Oct 19, 2022
534e789
replace use of get_local_point
gdamiand Oct 19, 2022
de846fc
do not use beta in lcc
gdamiand Oct 19, 2022
8550ce6
draw_surface_mesh_small_faces and draw_face_graph_with_paths NYF
gdamiand Nov 5, 2022
101ec5f
Test push
Mostafa-ashraf19 Nov 16, 2022
9fcd8f7
bugs fixed, added TODO
Mostafa-ashraf19 Dec 8, 2022
5948fc1
Initial Commit
Mostafa-ashraf19 Dec 9, 2022
803fc71
Path handled
Mostafa-ashraf19 Dec 9, 2022
d780acb
Example for basic viewer draw small faces
gdamiand Apr 25, 2023
cb2d506
Rename package basic viewer; move example
gdamiand Apr 27, 2023
5709abc
example basic viewer
gdamiand Apr 27, 2023
fe92449
doc
gdamiand Apr 27, 2023
8f29e4d
Rename class graphic buffer
gdamiand Apr 27, 2023
379b193
move basic viewer files
gdamiand Apr 27, 2023
5ef4638
start docé
gdamiand Apr 27, 2023
48cfa7a
add default value in the doc
gdamiand Apr 27, 2023
4df2edd
Replace draw_buffer by draw_graphic_storage
gdamiand Apr 28, 2023
b04d7a6
Rename
gdamiand Apr 28, 2023
519c7cc
rename add_in_graphic_buffer into add_in_graphic_storage
gdamiand Apr 28, 2023
e242890
doc
gdamiand Apr 28, 2023
43194fb
Add new example of Basic viewer allowing to view several windows
gdamiand Apr 28, 2023
e7acefd
clean
gdamiand Apr 28, 2023
bde0a52
Add new example of Basic viewer allowing to view several windows
gdamiand Apr 28, 2023
d3acc09
add one example with custom color
gdamiand Apr 28, 2023
f39254f
doc
gdamiand Apr 28, 2023
45e2d49
doc
gdamiand Jun 22, 2023
03d7c10
doc
gdamiand Jun 22, 2023
7da9812
Rename graphic_buffer into graphic_storage.
gdamiand Jun 22, 2023
7e99eac
Rename graphic_buffer into graphic_storage
gdamiand Jun 22, 2023
10a8748
Basic viewer doc (cont)
gdamiand Jun 22, 2023
1acb0e6
typo
gdamiand Jun 22, 2023
2f3d0c1
add lcc in dependencies
gdamiand Jun 22, 2023
5e420b1
doc
gdamiand Jun 22, 2023
0fe120b
add links to draw functions
gdamiand Jun 22, 2023
b9a4f86
doc
gdamiand Jun 23, 2023
980241e
author
gdamiand Jun 23, 2023
157558a
update doc
gdamiand Jun 26, 2023
11c7e44
move file
gdamiand Jun 26, 2023
fe23441
Merge master
gdamiand Jun 26, 2023
ef602d7
draw constrained triangulation can reuse draw triangulation
gdamiand Jun 26, 2023
0f6acac
draw constrained triangulation instead of triangulation
gdamiand Jun 26, 2023
6664339
Update drawing functor for surface mesh
gdamiand Jun 27, 2023
367b2d3
Update doc
gdamiand Jun 27, 2023
8b55613
split draw triangulation in two for the doc (without and with constra…
gdamiand Jun 27, 2023
44fd0bc
camel case
gdamiand Jun 27, 2023
df33c70
Update doc
gdamiand Jul 3, 2023
3e71ba9
update doc
gdamiand Aug 24, 2023
cc03d2c
verbs with s
gdamiand Aug 24, 2023
f3e3fcd
data structure
gdamiand Aug 24, 2023
b069114
more s
gdamiand Aug 24, 2023
467e55f
Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19
gdamiand Aug 28, 2023
1b651f1
Doc following Sebastien remarks
gdamiand Sep 11, 2023
0ee25cd
After Andreas review
gdamiand Sep 25, 2023
ebd13c8
Rename Drawing_functor in Graphics_scene_options (following Andreas a…
gdamiand Sep 28, 2023
5cf89da
Rename Drawing_functor in Graphics_scene_options (following Andreas a…
gdamiand Sep 28, 2023
e5a8a0d
Pmap readable
gdamiand Sep 28, 2023
fd115bd
Rename Graphic_storare into Graphics_scene (Andreas and Sebastien rev…
gdamiand Sep 28, 2023
6be7477
Camel case (Andreas review)
gdamiand Sep 28, 2023
9f22d67
Rename Graphic_storage in Graphics_scene (Andreas and Sebastien review)
gdamiand Sep 28, 2023
da7da48
Basic viewer doc
gdamiand Sep 28, 2023
c999b12
Basic viewer doc
gdamiand Sep 29, 2023
218be31
Basic viewer examples
gdamiand Sep 29, 2023
a5ee74c
Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19
gdamiand Sep 29, 2023
55509a6
GPL instead of LGPL (?)
gdamiand Sep 29, 2023
2755f2c
Basic viewer logo + move include file
gdamiand Sep 29, 2023
9f10513
lcc doc (temp)
gdamiand Oct 2, 2023
823392a
Update Basic_viewer/doc/Basic_viewer/PackageDescription.txt
gdamiand Oct 3, 2023
a8e68ca
Update Basic_viewer/doc/Basic_viewer/PackageDescription.txt
gdamiand Oct 3, 2023
5d1ae46
Update Basic_viewer/doc/Basic_viewer/PackageDescription.txt
gdamiand Oct 3, 2023
ac1c489
Update names following Andreas remarks
gdamiand Oct 6, 2023
93183fc
document draw and add_in_graphics_scene for lcc (for validation)
gdamiand Oct 6, 2023
163e8ae
Doc basic viewer
gdamiand Oct 13, 2023
40b9b10
Update Basic_viewer/doc/Basic_viewer/CGAL/Graphics_scene.h
gdamiand Oct 18, 2023
b47694c
Update Basic_viewer/doc/Basic_viewer/CGAL/Graphics_scene.h
gdamiand Oct 18, 2023
12365d7
Update Basic_viewer/doc/Basic_viewer/CGAL/Graphics_scene.h
gdamiand Oct 18, 2023
eca66e9
Update Basic_viewer/doc/Basic_viewer/CGAL/Graphics_scene.h
gdamiand Oct 18, 2023
a33b4e3
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
67b41d9
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
bfa138d
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
c551b6c
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
dfb32ba
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
46ddf99
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
66eba9f
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
cb2ab73
Update Basic_viewer/doc/Basic_viewer/CGAL/Qt/Basic_viewer_qt.h
gdamiand Oct 18, 2023
ef73057
acolor -> color
gdamiand Oct 18, 2023
d213747
nullptr must be quoted
lrineau Oct 18, 2023
31d79bd
fix a copy-paste typo
lrineau Oct 18, 2023
1369628
Update Basic_viewer/doc/Basic_viewer/PackageDescription.txt
gdamiand Oct 18, 2023
eea01ce
Replace some flot by BufferType
gdamiand Oct 18, 2023
e3f1772
Rename add_in_graphics_scene -> add_to_graphics_scene
gdamiand Oct 18, 2023
75d2b15
Start to rewrite draw_polygon_set_2.h (NYF)
gdamiand Oct 18, 2023
175166d
Remove all methods to add elements from Basic_viewer_qt.
gdamiand Oct 20, 2023
d8e190c
Basic viewer doc
gdamiand Oct 20, 2023
e1cd107
typo
gdamiand Oct 20, 2023
0c8704f
Basic viewer doc: variable name
gdamiand Oct 20, 2023
3fa4c70
Basic viewer doc typo
gdamiand Oct 20, 2023
45d9708
Basic viewer names in doc
gdamiand Oct 20, 2023
cf797a5
basic viewer does not have clear anymore
gdamiand Oct 20, 2023
d74a3db
Remove template parameter for graphics scene
gdamiand Oct 22, 2023
c9d93ba
Add GraphicsSceneOptions concept; use it to document draw(T2); waitin…
gdamiand Oct 22, 2023
cbe7ef2
Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19
gdamiand Oct 22, 2023
6daa2a0
Graphics_scene is no more templated
gdamiand Oct 22, 2023
1c6b1e4
Basic_viewer_qt is no more templated
gdamiand Oct 22, 2023
761fde0
add_in_graphics_scene -> add_to_graphics_scene; plus remove template …
gdamiand Oct 22, 2023
4332889
remove template for Buffer_for_vao
gdamiand Oct 23, 2023
e416fc8
new test for doc of draw
gdamiand Oct 23, 2023
2e955e1
The return of GSOptions template
gdamiand Oct 23, 2023
5ea9ac3
Remove _qt suffix from Basic_viewer
gdamiand Oct 23, 2023
2f07fbb
Update basic viewer doc following last remarks (Laurent and Andreas)
gdamiand Oct 23, 2023
126b936
Remove _qt from Basic viewer name
gdamiand Oct 24, 2023
2b69e29
Basic viewer is now in namespace Qt
gdamiand Oct 25, 2023
2bad25f
draw cont (nyf)
gdamiand Nov 6, 2023
97721a0
namespace fixes
afabri Nov 13, 2023
e62cb16
add_to
afabri Nov 13, 2023
1ffb64e
buffer -> scene
afabri Nov 13, 2023
525cc0f
Descriptor -> _descriptor
afabri Nov 14, 2023
4e5082b
remove _qt
afabri Nov 14, 2023
09b175b
Explain what to do for non colored cells
gdamiand Nov 17, 2023
8111fdf
color of volumes
gdamiand Nov 17, 2023
e3ac993
Doc: add a link to qglviewer
gdamiand Nov 20, 2023
db97ebb
Update code according to final doc api
gdamiand Nov 20, 2023
d2d114c
Update code to follow last api
gdamiand Nov 20, 2023
db9ca1a
reverse all normals
gdamiand Nov 20, 2023
12e7492
update draw
gdamiand Nov 20, 2023
c379872
draw polygon set
gdamiand Nov 20, 2023
28ec0e6
draw fg with paths (nyf)
gdamiand Nov 21, 2023
0655006
Merge with master: now viewers use Qt6
gdamiand Nov 29, 2023
2c77ba3
draw face graph with path
gdamiand Nov 29, 2023
9cf93aa
SMT: draw face width
gdamiand Nov 29, 2023
3c97859
SMT: draw face width and unsew edgewidth
gdamiand Nov 29, 2023
4feec0b
move end of namespace outside protected block
gdamiand Nov 29, 2023
f8a487d
update dependencies
gdamiand Nov 29, 2023
a000007
fix the install of /include/CGAL/Qt
lrineau Nov 29, 2023
b8c5b1c
A (last) verification step for all draw functions (nyf).
gdamiand Nov 30, 2023
2d25695
Graphics_scene does not uses Qt
gdamiand Nov 30, 2023
c53e24a
draw straight_skeleton_2
gdamiand Nov 30, 2023
310ad8e
remove old file
gdamiand Nov 30, 2023
f70a2d3
draw lcc
gdamiand Dec 1, 2023
2c34283
draw smt
gdamiand Dec 1, 2023
a204073
draw t3
gdamiand Dec 1, 2023
c1dd38e
draw nef3
gdamiand Dec 1, 2023
e3497d0
draw ps2
gdamiand Dec 1, 2023
3aa6ad1
Bug fix for 2D mode in basic viewer
gdamiand Nov 30, 2023
4684dc4
T2 and CDT2 draw
gdamiand Dec 1, 2023
1760fcf
draw p2t2
gdamiand Dec 4, 2023
91ecafd
draw voronoi 2
gdamiand Dec 4, 2023
046fa81
draw arrangement
gdamiand Dec 4, 2023
f836475
draw arrangement: use gs_options
gdamiand Dec 4, 2023
d97ff7b
remove duplicate doc
gdamiand Dec 4, 2023
d2f007d
doc draw t3
gdamiand Dec 5, 2023
5b7f499
doc draw polygon
gdamiand Dec 5, 2023
df2b9ad
doc draw pwh
gdamiand Dec 5, 2023
74c0894
doc draw polygon
gdamiand Dec 5, 2023
711a07d
doc draw surface mesh and polyhedron
gdamiand Dec 5, 2023
269f582
try to move advanced
gdamiand Dec 5, 2023
03ff679
doc draw: move advanced blocks
gdamiand Dec 5, 2023
029ab43
doc draw nef3
gdamiand Dec 5, 2023
3d8037d
doc draw lcc
gdamiand Dec 5, 2023
bfcb44b
doc: draw point set 3 and constrained triangulation 2
gdamiand Dec 6, 2023
b34fb26
fix doc draw ct2
gdamiand Dec 6, 2023
4d02be9
doc: draw ct2
gdamiand Dec 6, 2023
bd04b2a
Remove space in doc
gdamiand Dec 6, 2023
ac1fcde
Doc basic viewer
gdamiand Dec 7, 2023
3f3a21a
Doc draw face with graph (NYF: todo add links)
gdamiand Dec 7, 2023
973fb08
doc draw arrangement; fix to doc face graph with path
gdamiand Dec 7, 2023
2bd80f6
doc draw arrangement
gdamiand Dec 7, 2023
f3c5f53
doc add link
gdamiand Dec 7, 2023
769f615
doc: draw p2t2
gdamiand Dec 8, 2023
489317b
doc: draw p2t2 and voronoi2
gdamiand Dec 8, 2023
62b8460
doc draw boolean set op 2
gdamiand Dec 8, 2023
dcac571
Remove a warning
gdamiand Dec 14, 2023
d772007
Remove a wrong const
gdamiand Dec 14, 2023
b7ed4f2
protect min and max
gdamiand Dec 14, 2023
8710dbe
example requires qt
gdamiand Dec 14, 2023
d13b856
example requires qt
gdamiand Dec 14, 2023
0fdd175
use strncpy instead of strcpy
gdamiand Dec 26, 2023
a311285
remove warning
gdamiand Dec 26, 2023
3e16be0
remove warning
gdamiand Dec 26, 2023
01e333c
add missing include and function when basic viewer is disable
gdamiand Dec 26, 2023
88e9921
warning in draw nef3
gdamiand Dec 26, 2023
1b281f9
warning in surface mesh topology
gdamiand Dec 26, 2023
26096e9
missing include
gdamiand Dec 26, 2023
01decbb
SMT draw: Cannot use directly initializer list with variadic template.
gdamiand Dec 26, 2023
6146924
remove a windows warning about strncpy
gdamiand Dec 27, 2023
e3249bd
fix warning
sloriot Dec 27, 2023
efb946a
warnings
gdamiand Dec 27, 2023
7b483d4
warning in draw lcc
gdamiand Dec 27, 2023
ca296d5
the cast must be into std::size_t
gdamiand Dec 28, 2023
089f053
disable warning must eb defined before includes
gdamiand Dec 28, 2023
217d4c0
do not use strncpy
gdamiand Dec 28, 2023
7681644
warning
gdamiand Dec 28, 2023
d3bbe0d
cast in two steps
gdamiand Dec 28, 2023
38b03d2
warning draw smt
gdamiand Dec 28, 2023
77643b6
remove a sentence (no need to replace it)
lrineau Jan 8, 2024
1e18993
solve a todo
gdamiand Jan 8, 2024
3bc5602
Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19
gdamiand Jan 11, 2024
ca895e6
Basic Viewer Initial commit.
Mostafa-ashraf19 Jan 19, 2024
346bc63
figs for drawing LCC example.
Mostafa-ashraf19 Feb 4, 2024
ca9faa4
new for basic viewer, WIP graphic scene and class diagram.
Mostafa-ashraf19 Feb 4, 2024
369fab8
added Graphic_Scene section
Mostafa-ashraf19 Feb 5, 2024
44e5d7f
fixed errors of build doc logs.
Mostafa-ashraf19 Feb 5, 2024
f91a498
Basic_viewer UML class diagram.
Mostafa-ashraf19 Feb 5, 2024
2708185
Basic_viewer package UML class diagram.
Mostafa-ashraf19 Feb 5, 2024
ce2bb37
change order
gdamiand Feb 6, 2024
f358586
bugfix doc
gdamiand Feb 6, 2024
9a0b8eb
Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19
gdamiand Mar 26, 2024
736c182
Basic viewer user manual
gdamiand Mar 26, 2024
cc19f2b
add examples é
gdamiand Mar 26, 2024
102f159
basic viewer user manual
gdamiand Mar 27, 2024
785f301
basic viewer user manual
gdamiand Mar 27, 2024
3804cf6
basic viewer example
gdamiand Mar 27, 2024
f904090
basic viewer user manual
gdamiand Mar 27, 2024
1f04bad
Basic viewer user manual
gdamiand Mar 27, 2024
031c833
First pass on User Manual
afabri Mar 28, 2024
344ea7c
typo in manual
gdamiand Mar 28, 2024
c19e64f
Second pass
afabri Mar 28, 2024
41ebe96
change draw height color examples
gdamiand Mar 28, 2024
eb03647
Rename variable for graphics scene
gdamiand Mar 28, 2024
4d1a4b0
Basic viewer user manual: several fixes
gdamiand Mar 28, 2024
ff4a201
bibtex
gdamiand Mar 28, 2024
70d398b
add examples of drawing of polygon with holes
gdamiand Mar 28, 2024
6cf73a6
minor changes
lrineau Mar 28, 2024
57aa719
do not use white as random color
gdamiand Mar 28, 2024
da21756
Update triangulation method in buffer for vao to deal with some neste…
gdamiand Mar 28, 2024
8869ab3
dependencies for core
gdamiand Mar 28, 2024
7f6505c
update changes
gdamiand Mar 28, 2024
8fe576c
use and
sloriot Apr 4, 2024
cb8e880
delete allocated objects
sloriot Apr 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
260 changes: 111 additions & 149 deletions BGL/include/CGAL/draw_face_graph.h
Original file line number Diff line number Diff line change
@@ -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).
Expand All @@ -9,189 +9,151 @@
//
// Author(s) : Guillaume Damiand <[email protected]>
// Laurent Rineau <[email protected]>
// Mostafa Ashraf <[email protected]>

#ifndef CGAL_DRAW_FACE_GRAPH_H
#define CGAL_DRAW_FACE_GRAPH_H

#ifdef CGAL_USE_BASIC_VIEWER

#include <CGAL/Graphic_buffer.h>
#include <CGAL/Drawing_functor.h>
#include <CGAL/Dynamic_property_map.h>
#include <CGAL/Random.h>
#include <CGAL/boost/graph/helpers.h>

namespace CGAL
{
namespace CGAL {

// Default color functor; user can change it to have its own face color
struct DefaultColorFunctorFaceGraph
{
template<typename Graph>
CGAL::IO::Color operator()(const Graph&,
typename boost::graph_traits<Graph>::face_descriptor fh) const
{
if (fh==boost::graph_traits<Graph>::null_face()) // use to get the mono color
return CGAL::IO::Color(100, 125, 200); // R G B between 0-255

return get_random_color(CGAL::get_default_random());
}
};
namespace draw_function_for_FG {

class SimpleFaceGraphViewerQt : public Basic_viewer_qt
template <typename BufferType=float, typename FG, typename DrawingFunctor>
void compute_elements(const FG &fg,
CGAL::Graphic_buffer<BufferType> &graphic_buffer,
const DrawingFunctor &m_drawing_functor)
{
using Base = Basic_viewer_qt;

public:
SimpleFaceGraphViewerQt(QWidget* parent) :
Base(parent, "", false, true, true, true, false),
m_compute_elements_impl([]{})
{
}

/// Construct the viewer.
/// @param amesh the surface mesh to view
/// @param title the title of the window
/// @param anofaces if true, do not draw faces (faces are not computed; this can be
/// usefull for very big object where this time could be long)
template <typename SM>
SimpleFaceGraphViewerQt(QWidget* parent,
const SM& amesh,
const char* title="Basic Surface_mesh Viewer",
bool anofaces=false) :
SimpleFaceGraphViewerQt(parent, amesh, title, anofaces, DefaultColorFunctorFaceGraph())
{
}
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;

template <typename SM, typename ColorFunctor>
SimpleFaceGraphViewerQt(QWidget* parent,
const SM& amesh,
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(amesh, anofaces, fcolor))
auto vnormals = get(CGAL::dynamic_vertex_property_t<Vector>(), fg);
auto point_pmap = get(CGAL::vertex_point, fg);
for (auto v : vertices(fg))
{
}

void init() override {
compute_elements();
Base::init();
}

void compute_elements() {
m_compute_elements_impl();
}

template <typename SM, typename ColorFunctor>
void set_face_graph(const SM& amesh,
bool anofaces,
ColorFunctor fcolor) {
m_compute_elements_impl = compute_elements_functor(amesh, anofaces, fcolor);
}

template <typename SM, typename ColorFunctor>
void set_face_graph(const SM& amesh,
bool anofaces=false) {
set_mesh(amesh, anofaces, DefaultColorFunctorFaceGraph());
}
protected:
template <typename SM, typename ColorFunctor>
std::function<void()>
compute_elements_functor(const SM& sm,
bool anofaces,
ColorFunctor fcolor)
{
using Point =
typename boost::property_map_value<SM, 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>(), sm);
auto point_pmap = get(CGAL::vertex_point, sm);
for (auto v : vertices(sm))
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, sm), sm))
if (!is_border(h, fg))
{
if (!is_border(h, sm))
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, sm)), get(point_pmap, target(h, sm))),
Vector(get(point_pmap, target(h, sm)), get(point_pmap, target(next(h, sm), sm))));
if (ni != NULL_VECTOR)
{
n+=ni;
++i;
}
n += ni;
++i;
}
}
put(vnormals, v, n/i);
}
put(vnormals, v, n / i);
}

// This function return a lambda expression, type-erased in a
// `std::function<void()>` object.
return [this, &sm, vnormals, anofaces, fcolor, point_pmap]()
if (m_drawing_functor.are_faces_enabled())
{
for (auto fh : faces(fg))
{
this->clear();

if (!anofaces)
if (fh != boost::graph_traits<FG>::null_face() && // face exists
!m_drawing_functor.face_wireframe(fg, fh) && // face is not wireframe
m_drawing_functor.colored_face(fg, fh)) // and face is colored
{
for (auto fh: faces(sm))
graphic_buffer.face_begin(m_drawing_functor.face_color(fg, fh));
auto hd = halfedge(fh, fg);
const auto first_hd = hd;
do
{
if (fh!=boost::graph_traits<SM>::null_face())
{
CGAL::IO::Color c=fcolor(sm, fh);
face_begin(c);
auto hd=halfedge(fh, sm);
const auto first_hd = hd;
do
{
auto v = source(hd, sm);
add_point_in_face(get(point_pmap, v), get(vnormals, v));
hd=next(hd, sm);
}
while(hd!=first_hd);
face_end();
}
auto v = source(hd, fg);
graphic_buffer.add_point_in_face(get(point_pmap, v), get(vnormals, v));
hd = next(hd, fg);
}
while (hd != first_hd);
graphic_buffer.face_end();
}
}
}

for (auto e: edges(sm))
{
add_segment(get(point_pmap, source(halfedge(e, sm), sm)),
get(point_pmap, target(halfedge(e, sm), sm)));
if(m_drawing_functor.are_edges_enabled())
{
for (auto e : edges(fg))
{
if(m_drawing_functor.colored_edge(fg, e)) // edge is colored
{
graphic_buffer.add_segment(get(point_pmap, source(halfedge(e, fg), fg)),
get(point_pmap, target(halfedge(e, fg), fg)),
m_drawing_functor.edge_color(fg, e));
}

for (auto v: vertices(sm))
else
{
this->add_point(get(point_pmap, v));
graphic_buffer.add_segment(get(point_pmap, source(halfedge(e, fg), fg)),
get(point_pmap, target(halfedge(e, fg), fg)));
}
};
}
}

void keyPressEvent(QKeyEvent *e) override
if(m_drawing_functor.are_vertices_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 v : vertices(fg))
{
if(m_drawing_functor.colored_vertex(fg, v)) // vertex is colored
{
graphic_buffer.add_point(get(point_pmap, v),
m_drawing_functor.vertex_color(fg, v));
}
else
{
graphic_buffer.add_point(get(point_pmap, v));
}
}
}
}

protected:
std::function<void()> m_compute_elements_impl;
};
} // draw_function_for_FG

template <typename BufferType=float, class FG, class DrawingFunctor>
void add_in_graphic_buffer_for_fg(const FG &fg,
CGAL::Graphic_buffer<BufferType> &graphic_buffer,
const DrawingFunctor &drawing_functor)
{
draw_function_for_FG::compute_elements(fg, graphic_buffer, drawing_functor);
}

template <typename BufferType=float, class FG>
void add_in_graphic_buffer_for_fg(const FG &fg,
CGAL::Graphic_buffer<BufferType> &graphic_buffer)
{
Drawing_functor<FG,
typename boost::graph_traits<FG>::vertex_descriptor,
typename boost::graph_traits<FG>::edge_descriptor,
typename boost::graph_traits<FG>::face_descriptor>
drawing_functor;

drawing_functor.colored_face = [](const FG&,
typename boost::graph_traits<FG>::face_descriptor) -> bool
{ return true; };

} // End namespace CGAL

#endif // CGAL_USE_BASIC_VIEWER
drawing_functor.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); }

// TODO (?) use a seed given fh (cannot directly cast because FG is either a polyhedron or a surface mesh)
lrineau marked this conversation as resolved.
Show resolved Hide resolved
return get_random_color(CGAL::get_default_random());
};

add_in_graphic_buffer_for_fg(fg, graphic_buffer, drawing_functor);
}

} // End namespace CGAL

#endif // CGAL_DRAW_SURFACE_MESH_H
13 changes: 13 additions & 0 deletions CGAL_basic_viewers/doc/CGAL_basic_viewers/CGAL_basic_viewers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace CGAL {
/*!

\mainpage User Manual
\anchor Chapter_CGAL_Basic_viewers
\anchor
\cgalAutoToc
\author Guillaume Damiand, Mostafa Ashraf


*/

} /* namespace CGAL */
3 changes: 3 additions & 0 deletions CGAL_basic_viewers/doc/CGAL_basic_viewers/Doxyfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}

PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - CGAL and Basic Viewers"
Empty file.
Empty file.
Empty file.
21 changes: 21 additions & 0 deletions CGAL_basic_viewers/examples/CGAL_basic_viewers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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(CGAL_basic_viewers)

#CGAL_Qt5 is needed for the drawing.
find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5)

create_single_source_cgal_program("draw_surface_mesh_small_faces.cpp")
if(CGAL_Qt5_FOUND)
#link it with the required CGAL libraries
target_link_libraries(draw_surface_mesh_small_faces PUBLIC CGAL::CGAL_Basic_viewer)
endif()

#end of the file
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <CGAL/license/Surface_mesh.h>
#include <CGAL/Graphic_buffer.h>
#include <CGAL/Drawing_functor.h>
#include <CGAL/Qt/Basic_viewer_qt.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/draw_surface_mesh.h>
#include <fstream>

typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;

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." << std::endl;
return EXIT_FAILURE;
}

CGAL::draw(sm);

return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions Documentation/doc/Documentation/packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,6 @@

\package_listing{GraphicsView}
\package_listing{CGAL_ipelets}
\package_listing{CGAL_basic_viewers}

*/
1 change: 1 addition & 0 deletions GraphicsView/include/CGAL/Buffer_for_vao.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class Buffer_for_vao
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;
Expand Down
Loading