Skip to content

Commit

Permalink
Merge branch 'master' into CGAL_Lab
Browse files Browse the repository at this point in the history
  • Loading branch information
lrineau committed Apr 10, 2024
2 parents 76500ba + 32e3496 commit f7d4f10
Show file tree
Hide file tree
Showing 224 changed files with 8,605 additions and 6,472 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Number_types
Polyhedron
Profiling_tools
Property_map
Random_numbers
STL_Extension
Spatial_sorting
Stream_support
Expand Down
27 changes: 12 additions & 15 deletions Algebraic_kernel_d/include/CGAL/Algebraic_kernel_d/Descartes.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class Descartes {

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;
Expand All @@ -91,9 +91,9 @@ class Descartes {
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)
{
Expand All @@ -116,9 +116,9 @@ class Descartes {
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)
{
Expand Down Expand Up @@ -153,9 +153,9 @@ class Descartes {
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];
Expand All @@ -166,9 +166,6 @@ class Descartes {

// destructor
~Descartes() {
delete[] numerator;
delete[] denominator_exponent;
delete[] is_exact;
}

public: // functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,15 +1153,17 @@ class Alpha_wrapper_3
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading

0 comments on commit f7d4f10

Please sign in to comment.