Added draw() overloads that accept a bounding box and fixed the Approximate_2 concept documentation

This commit is contained in:
Efi Fogel 2025-08-14 17:58:18 +03:00
parent fb9afae4ac
commit eca5afe6ee
6 changed files with 70 additions and 46 deletions

View File

@ -19,6 +19,8 @@
#include <CGAL/Qt/Basic_viewer.h> #include <CGAL/Qt/Basic_viewer.h>
#include "CGAL/Bbox_2.h"
#ifdef DOXYGEN_RUNNING #ifdef DOXYGEN_RUNNING
namespace CGAL { namespace CGAL {
@ -26,8 +28,8 @@ namespace CGAL {
/*! \ingroup PkgArrangementOnSurface2Draw /*! \ingroup PkgArrangementOnSurface2Draw
* The function opens a new window and draws `arr`, an instance of the * The function opens a new window and draws `arr`, an instance of the
* `CGAL::Arrangement_2` class template. Parameters of the drawing are taken * `CGAL::Arrangement_on_surface_2` class template. Parameters of the drawing
* from the optional graphics scene options parameter. * are taken from the optional graphics scene options parameter.
* *
* A call to this function blocks the execution of the program until the drawing * 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 * window is closed. This function requires `CGAL_Qt6`, and is only available if
@ -35,57 +37,56 @@ namespace CGAL {
* `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition * `CGAL::CGAL_Basic_viewer` will link with `CGAL_Qt6` and add the definition
* `CGAL_USE_BASIC_VIEWER`. * `CGAL_USE_BASIC_VIEWER`.
* *
* \tparam GeometryTraits_2 a geometry traits type, a model of a 2D arrangement * \tparam GeometryTraits a geometry traits type, a model of a 2D arrangement
* traits concept. At this point it must be an instance of either * geometry traits concept. Observe that not all geometery-traits models are
* `CGAL::Arr_segment_traits_2` or `CGAL::Arr_conic_traits_2`. * supported.
* \tparam Dcel the \dcel type, a model of the `AosDcel` concept. *
* \tparam TopologyTraits a topology traits type, a model of the
* `AosTopologyTraits` concept.
*
* \tparam GSOptions a model of `GraphicsSceneOptions` concept. * \tparam GSOptions a model of `GraphicsSceneOptions` concept.
* *
* \param arr the 2D arrangement to draw. * \param arr the 2D arrangement to draw.
* \param gso the graphics scene options parameter. * \param bbox a bounding box in parameter space.
* \param gso the graphics scene options.
* \param title the optional title of the window.
* *
* \sa `AosDcel`
* \sa `AosTraits_2` * \sa `AosTraits_2`
* \sa `AosTopologyTraits`
* \sa `GraphicsSceneOptions`
*/ */
template <typename GeometryTraits_2, typename Dcel, typename GSOptions>
void draw(const Arrangement_2<GeometryTraits_2, Dcel>& arr, template <typename GeometryTraits, typename TopologyTraits>
const GSOptions& gso); void draw(const Arrangement_on_surface_2<GeometryTraits, TopologyTraits>& arr, const BBox& bbox, const GSOptions& gso,
const char* title = "2D Arrangement on Surface");
/*! \ingroup PkgArrangementOnSurface2Draw /*! \ingroup PkgArrangementOnSurface2Draw
* *
* A shortcut to `CGAL::draw(arr, Graphics_scene_options{})`. * A shortcut to `CGAL::draw(arr, bbox, Graphics_scene_options<Aos, Aos::Vertex_const_handle, Aos::Halfedge_const_handle, Aos::Face_const_handle>{})`, where `Aos` is `Arrangement_on_surface_2<GeometryTraits, TopologyTraits>`.
*/ */
template <typename GeometryTraits_2, typename Dcel>
void draw(const Arrangement_2<GeometryTraits_2, Dcel>& arr); template <typename GeometryTraits, typename TopologyTraits>
void draw(const Arrangement_on_surface_2<GeometryTraits, TopologyTraits>& arr, const BBox& bbox,
const char* title = "2D Arrangement on Surface");
/*! \ingroup PkgArrangementOnSurface2Draw /*! \ingroup PkgArrangementOnSurface2Draw
* *
* adds the vertices, edges and faces of `arr` into the given graphic scene * Similar to `CGAL::draw(arr, bbox, gso)`, where the bounding box `bbox` is computed to bound all points
* `gs`. Parameters of the cells are taken from the optional graphics scene * and curves of the arrangement in parameter space.
* 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 `AosDcel` 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, template <typename GeometryTraits, typename TopologyTraits>
CGAL::Graphics_scene& gs, const GSOptions& gso); void draw(const Arrangement_on_surface_2<GeometryTraits, TopologyTraits>& arr, const GSOptions& gso,
const char* title = "2D Arrangement on Surface");
/*! \ingroup PkgArrangementOnSurface2Draw /*! \ingroup PkgArrangementOnSurface2Draw
* A shortcut to `CGAL::add_to_graphics_scene(arr, gs, *
* Graphics_scene_options{})`. * A shortcut to `CGAL::draw(arr, Graphics_scene_options<Aos, Aos::Vertex_const_handle, Aos::Halfedge_const_handle, Aos::Face_const_handle>{})`, where `Aos` is `Arrangement_on_surface_2<GeometryTraits, TopologyTraits>`.
*/ */
template <typename GeometryTraits_2, typename Dcel>
void add_to_graphics_scene(const Arrangement_2<GeometryTraits_2, Dcel>& arr, template <typename GeometryTraits, typename TopologyTraits>
CGAL::Graphics_scene& gs); void draw(const Arrangement_on_surface_2<GeometryTraits, TopologyTraits>& arr,
const char* title = "2D Arrangement on Surface");
} /* namespace CGAL */ } /* namespace CGAL */

View File

@ -18,8 +18,6 @@
* \cgalHasModels{CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1>} * \cgalHasModels{CGAL::Arr_rational_function_traits_2<AlgebraicKernel_d_1>}
* \cgalHasModelsEnd * \cgalHasModelsEnd
* *
* \sa `AosConstructXMonotoneCurveTraits_2`
* \sa `AosXMonotoneTraits_2`
* \sa `AosTraits_2` * \sa `AosTraits_2`
*/ */
class AosApproximatePointTraits_2 { class AosApproximatePointTraits_2 {
@ -35,7 +33,7 @@ public:
/// \name Functor Types /// \name Functor Types
/// @{ /// @{
/// models the concept `AosTraits::Approximate_2`. /// models the concept `AosTraits::ApproximatePoint_2`.
typedef unspecified_type Approximate_2; typedef unspecified_type Approximate_2;
/// @} /// @}

View File

@ -17,6 +17,8 @@
* \cgalHasModelsEnd * \cgalHasModelsEnd
* *
* \sa `AosApproximatePointTraits_2` * \sa `AosApproximatePointTraits_2`
* \sa `AosConstructXMonotoneCurveTraits_2`
* \sa `AosXMonotoneTraits_2`
* \sa `draw()` * \sa `draw()`
*/ */
class AosApproximateTraits_2 { class AosApproximateTraits_2 {

View File

@ -0,0 +1,28 @@
namespace AosTraits {
/*! \ingroup PkgArrangementOnSurface2ConceptsFunctionObjects
* \cgalConcept
*
* \cgalRefines{Functor}
*
* \cgalHasModelsBegin
* \cgalHasModels{AosApproximatePointTraits_2::Approximate_2}
* \cgalHasModels{AosApproximateTraits_2::Approximate_2}
* \cgalHasModelsEnd
*/
class ApproximatePoint_2 {
public:
/// \name Operations
/// A model of this concept must provide:
/// @{
/*! obtains an approximation of `p`'s \f$x\f$-coordinate (if `i == 0`), or of
* `p`'s \f$y\f$-coordinate (if `i == 1`).
* \pre `i` is either 0 or 1.
*/
CGAL::Approximate_number_type operator()(AosTraits::Point_2 p, int i);
/// @}
}; /* end AosTraits::Approximate_2 */
}

View File

@ -3,7 +3,7 @@ namespace AosTraits {
/*! \ingroup PkgArrangementOnSurface2ConceptsFunctionObjects /*! \ingroup PkgArrangementOnSurface2ConceptsFunctionObjects
* \cgalConcept * \cgalConcept
* *
* \cgalRefines{Functor} * \cgalRefines{ApproximatePoint_2}
* *
* \cgalHasModelsBegin * \cgalHasModelsBegin
* \cgalHasModels{AosApproximatePointTraits_2::Approximate_2} * \cgalHasModels{AosApproximatePointTraits_2::Approximate_2}
@ -16,12 +16,6 @@ public:
/// A model of this concept must provide: /// A model of this concept must provide:
/// @{ /// @{
/*! obtains an approximation of `p`'s \f$x\f$-coordinate (if `i == 0`), or of
* `p`'s \f$y\f$-coordinate (if `i == 1`).
* \pre `i` is either 0 or 1.
*/
CGAL::Approximate_number_type operator()(AosTraits::Point_2 p, int i);
/*! obtains an approximation of `p`. /*! obtains an approximation of `p`.
*/ */
CGAL::Approximate_point_2 operator()(AosTraits::Point_2 p); CGAL::Approximate_point_2 operator()(AosTraits::Point_2 p);

View File

@ -167,6 +167,7 @@ implemented as peripheral classes or as free (global) functions.
\cgalCRPSection{Function Object Concepts} \cgalCRPSection{Function Object Concepts}
- `AosTraits::Approximate_2` - `AosTraits::Approximate_2`
- `AosTraits::ApproximatePoint_2`
- `AosTraits::AreMergeable_2` - `AosTraits::AreMergeable_2`
- `AosTraits::CompareX_2` - `AosTraits::CompareX_2`
- `AosTraits::CompareXy_2` - `AosTraits::CompareXy_2`