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

Making the Spherical Guassian-map polyhedron a proper model of FaceGraph #8153

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1129,13 +1129,16 @@ bool do_intersect(Arrangement_on_surface_2<GeometryTraits, TopologyTraits>& arr,
/*! \ingroup PkgArrangementOnSurface2Funcs
*
* Inserts a given \f$ x\f$-monotone curve into a given arrangement, where the
* interior of the given curve is disjoint from all existing arrangement
* vertices and edges. Under this assumption, it is possible to locate the
* endpoints of the given curve in the arrangement, and use one of the
* specialized insertion member-functions of the arrangement according to the
* results. The insertion operations creates a single new edge, that is, two
* twin halfedges, and the function returns a handle for the one directed
* lexicographically in increasing order (from left to right).
* given curve and the existing arrangement edges (more precisely, the curves
* geometric mappings of the edges) must be pairwise disjoint in their
* interiors, and the interior of the input curve must not contain existing
* arrangement vertices (more precisely, the points geometric mappings of the
* vertices). Under this condition, it is possible to locate the endpoints of
* the given curve in the arrangement, and use one of the specialized insertion
* member-functions of the arrangement according to the results. The insertion
* operations creates a single new edge, that is, two twin halfedges. The
* function returns a handle to the one directed lexicographically in
* increasing order (from left to right).
*
* A given point-location object is used for answering the two point-location
* queries on the given curve endpoints. By default, the function uses the "walk
Expand Down Expand Up @@ -1165,10 +1168,13 @@ insert_non_intersecting_curve
/*! \ingroup PkgArrangementOnSurface2Funcs
*
* Inserts a set of \f$ x\f$-monotone curves in a given range into a given
* arrangement. The insertion is performed in an aggregated manner, using the
* sweep-line algorithm. The input curves should be pairwise disjoint in their
* interior and pairwise interior-disjoint from all existing arrangement
* vertices and edges.
* arrangement. The insertion is performed in an aggregated manner using the
* sweep-line algorithm. The input curves and the existing arrangement edges
* (more precisely, the curves geometric mappings of the edges) must be pairwise
* disjoint in their interiors, and the interiors of the input curves must not
* contain existing arrangement vertices (more precisely, the points geometric
* mappings of the vertices). The insertion operations creates exactly one new
* edge, that is, two twin halfedges, for every input curve.
*
* \cgalHeading{Requirements}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_traits.h>
#include <CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm.h>
#include <CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_polyhedron_3.h>

Expand All @@ -16,14 +15,13 @@

using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
using Point_3 = Kernel::Point_3;
using Direction_3 = Kernel::Direction_3;

#if 0
using Gm_traits = CGAL::Arr_polyhedral_sgm_traits<Kernel, -8, 6>;
using Gm_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -8, 6>;
#elif 0
using Gm_traits = CGAL::Arr_polyhedral_sgm_traits<Kernel, -11, 7>;
using Gm_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -11, 7>;
#else
using Gm_traits = CGAL::Arr_polyhedral_sgm_traits<Kernel, -1, 0>;
using Gm_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -1, 0>;
#endif

using Gm = CGAL::Arr_polyhedral_sgm<Gm_traits>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ class Arr_geodesic_arc_on_sphere_traits_2 : public Kernel_ {
/*! Default constructor */
Arr_geodesic_arc_on_sphere_traits_2() {}

protected:
using FT = typename Kernel::FT;

using Direction_3 = typename Kernel::Direction_3;
using Vector_3 = typename Kernel::Vector_3;
using Direction_2 = typename Kernel::Direction_2;
using Vector_2 = typename Kernel::Vector_2;

protected:
/*! Obtain the intersection of the identification arc and the xy plane.
* By default, it is the vector directed along the negative x axis
* (x = -infinity).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s) : Efi Fogel <[email protected]>
// Author(s) : Efi Fogel <[email protected]>

#ifndef CGAL_ARR_POLYHEDRAL_SGM_POLYHEDRON_3_H
#define CGAL_ARR_POLYHEDRAL_SGM_POLYHEDRON_3_H

#include <CGAL/license/Arrangement_on_surface_2.h>


/*! \file
* Related definition of a Polyhedron_3 data structure, an instance of which
* can be used to initialize a Arr_polyhedral_sgm data structure.
Expand Down Expand Up @@ -49,10 +48,10 @@ namespace CGAL {
/*! The extended Polyhedron vertex type */
template <class T_Refs, class T_Point>
class Arr_polyhedral_sgm_polyhedron_3_vertex :
public HalfedgeDS_vertex_base<T_Refs, CGAL::Tag_true, T_Point>
{
public HalfedgeDS_vertex_base<T_Refs, CGAL::Tag_true, T_Point> {

private:
typedef HalfedgeDS_vertex_base<T_Refs, CGAL::Tag_true, T_Point> Base;
using Base = HalfedgeDS_vertex_base<T_Refs, CGAL::Tag_true, T_Point>;

/*! Indicates that the vertex has been processed already */
bool m_processed;
Expand All @@ -61,7 +60,7 @@ class Arr_polyhedral_sgm_polyhedron_3_vertex :
bool m_marked;

public:
typedef typename Base::Point Point;
using Point = typename Base::Point;

/*! Constructor */
Arr_polyhedral_sgm_polyhedron_3_vertex() :
Expand All @@ -72,10 +71,10 @@ class Arr_polyhedral_sgm_polyhedron_3_vertex :
Base(p), m_processed(false), m_marked(false) {}

/*! Obtain the mutable (geometrical) point. Delegate */
Point & point() { return Base::point(); }
Point& point() { return Base::point(); }

/*! Obtain the constant (geometrical) point. Delegate */
const Point & point () const { return Base::point(); }
const Point& point () const { return Base::point(); }

/*! Set the flag */
void set_processed(bool processed) { m_processed = processed; }
Expand All @@ -93,8 +92,7 @@ class Arr_polyhedral_sgm_polyhedron_3_vertex :
/*! The extended Polyhedron halfedge type */
template <class T_Refs>
class Arr_polyhedral_sgm_polyhedron_3_halfedge :
public HalfedgeDS_halfedge_base<T_Refs>
{
public HalfedgeDS_halfedge_base<T_Refs> {
private:
/*! Indicates that the halfedge has been processed already */
bool m_processed;
Expand Down Expand Up @@ -123,12 +121,11 @@ class Arr_polyhedral_sgm_polyhedron_3_halfedge :
/*! The extended Polyhedron face type */
template <class T_Refs, class T_Plane, class Sgm>
class Arr_polyhedral_sgm_polyhedron_3_face :
public HalfedgeDS_face_base<T_Refs, CGAL::Tag_true, T_Plane>
{
public HalfedgeDS_face_base<T_Refs, CGAL::Tag_true, T_Plane> {

private:
typedef HalfedgeDS_face_base<T_Refs, CGAL::Tag_true, T_Plane>
Base;
typedef typename Sgm::Vertex_handle Arr_vertex_handle;
using Base = HalfedgeDS_face_base<T_Refs, CGAL::Tag_true, T_Plane>;
using Arr_vertex_handle = typename Sgm::Vertex_handle;

/*! The arrangement vertex handle of the projected normal. */
Arr_vertex_handle m_vertex;
Expand All @@ -137,16 +134,16 @@ class Arr_polyhedral_sgm_polyhedron_3_face :
bool m_marked;

public:
typedef typename Base::Plane Plane;
using Plane = typename Base::Plane;

/*! Constructor */
Arr_polyhedral_sgm_polyhedron_3_face() : m_vertex(nullptr), m_marked(false) {}

/*! Obtain the mutable plane. Delegate */
Plane & plane() { return Base::plane(); }
Plane& plane() { return Base::plane(); }

/*! Obtain the constant plane. Delegate */
const Plane & plane() const { return Base::plane(); }
const Plane& plane() const { return Base::plane(); }

/*! Obtain the vertex */
Arr_vertex_handle vertex() { return m_vertex; }
Expand Down Expand Up @@ -174,59 +171,48 @@ template <class Sgm>
struct Arr_polyhedral_sgm_polyhedron_items : public Polyhedron_items_3 {
template <class T_Refs, class T_Traits>
struct Vertex_wrapper {
typedef typename T_Traits::Point_3 Point_3;
typedef Arr_polyhedral_sgm_polyhedron_3_vertex<T_Refs, Point_3> Vertex;
using Point_3 = typename T_Traits::Point_3;
using Vertex = Arr_polyhedral_sgm_polyhedron_3_vertex<T_Refs, Point_3>;
};
template <class T_Refs, class T_Traits>
struct Halfedge_wrapper {
typedef Arr_polyhedral_sgm_polyhedron_3_halfedge<T_Refs> Halfedge;
using Halfedge = Arr_polyhedral_sgm_polyhedron_3_halfedge<T_Refs>;
};
template <class T_Refs, class T_Traits>
struct Face_wrapper {
typedef typename T_Traits::Plane_3 Plane_3;
typedef Arr_polyhedral_sgm_polyhedron_3_face<T_Refs, Plane_3, Sgm> Face;
using Plane_3 = typename T_Traits::Plane_3;
using Face = Arr_polyhedral_sgm_polyhedron_3_face<T_Refs, Plane_3, Sgm>;
};
};

/*! The default polyhedron type. If the Arr_polyhedral_sgm object is indirectly
* constructed from the points and the facets provided as indices, then a
* temporary object of type Arr_polyhedral_sgm_default_polyhedron_3 is constructed
* internally, and used to represent the polyhedron. Similarly, if the user
* provides a reference to a polyhedron object as input for the construction
* of the Arr_polyhedral_sgm object, and she/he has no need to extend the
* polyhedron features, this type should be used to represent the polyhedron.
* However, if the user need to extend the vertex, halfedge, or face of the
* polyhedron, she/he must extend the appropriate type(s), define a new items
* type that is based on the extended types, and define a new polyhedron type
* based on the new items type.
* temporary object of type Arr_polyhedral_sgm_default_polyhedron_3 is
* constructed internally, and used to represent the polyhedron. Similarly, if
* the user provides a reference to a polyhedron object as input for the
* construction of the Arr_polyhedral_sgm object, and she/he has no need to
* extend the polyhedron features, this type should be used to represent the
* polyhedron. However, if the user need to extend the vertex, halfedge, or
* face of the polyhedron, she/he must extend the appropriate type(s), define a
* new items type that is based on the extended types, and define a new
* polyhedron type based on the new items type.
*/
template <class Sgm, class Traits>
struct Arr_polyhedral_sgm_polyhedron_3 :
public Polyhedron_3<Traits,
Arr_polyhedral_sgm_polyhedron_items<Sgm> >
{
public Polyhedron_3<Traits, Arr_polyhedral_sgm_polyhedron_items<Sgm>> {
/*! Constructor */
Arr_polyhedral_sgm_polyhedron_3() {}
};

} //namespace CGAL

//! Make the polyhedron a model of FaceGraph
namespace boost {

template <typename Sgm, typename Traits>
struct graph_traits<CGAL::Arr_polyhedral_sgm_polyhedron_3<Sgm, Traits> > :
public graph_traits<CGAL::Polyhedron_3
<Traits, CGAL::Arr_polyhedral_sgm_polyhedron_items<Sgm> > >
{};

template <typename Sgm, typename Traits, typename Tag>
struct property_map<CGAL::Arr_polyhedral_sgm_polyhedron_3<Sgm, Traits>, Tag> :
public property_map<CGAL::Polyhedron_3
<Traits, CGAL::Arr_polyhedral_sgm_polyhedron_items<Sgm> >,
Tag>
{};

}
#define CGAL_GRAPH_TRAITS_INHERITANCE_TEMPLATE_PARAMS \
typename Sgm, typename Traits
#define CGAL_GRAPH_TRAITS_INHERITANCE_CLASS_NAME \
CGAL::Arr_polyhedral_sgm_polyhedron_3<Sgm, Traits>
#define CGAL_GRAPH_TRAITS_INHERITANCE_BASE_CLASS_NAME \
CGAL::Polyhedron_3<Traits, CGAL::Arr_polyhedral_sgm_polyhedron_items<Sgm>>
#include <CGAL/boost/graph/graph_traits_inheritance_macros.h>

#endif
48 changes: 34 additions & 14 deletions Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_sgm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,41 @@

// Testing the spherical gaussian map
#include <iostream>

#include <boost/iterator/iterator_facade.hpp>

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_traits.h>
#include <CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm.h>
#include <CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_polyhedron_3.h>
#include <CGAL/convex_hull_3.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
using Kernel = CGAL::Exact_predicates_exact_constructions_kernel;
using Point_3 = Kernel::Point_3;

#if 1
typedef CGAL::Arr_polyhedral_sgm_traits<Kernel, -1, 0> Gm_traits;
using Gm_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -1, 0>;
#elif 0
typedef CGAL::Arr_polyhedral_sgm_traits<Kernel, -8, 6> Gm_traits;
using Gm_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -8, 6>;
#else
typedef CGAL::Arr_polyhedral_sgm_traits<Kernel, -11, 7> Gm_traits;
using Gm_traits = CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -11, 7>;
#endif

typedef CGAL::Arr_polyhedral_sgm<Gm_traits> Gm;
typedef CGAL::Arr_polyhedral_sgm_polyhedron_3<Gm, Kernel> Gm_polyhedron;
typedef CGAL::Arr_polyhedral_sgm_initializer<Gm, Gm_polyhedron> Gm_initializer;
using Gm = CGAL::Arr_polyhedral_sgm<Gm_traits>;
using Gm_polyhedron = CGAL::Arr_polyhedral_sgm_polyhedron_3<Gm, Kernel>;
using Gm_initializer = CGAL::Arr_polyhedral_sgm_initializer<Gm, Gm_polyhedron>;

struct Point_iterator :
boost::iterator_facade<Point_iterator, Point_3,
std::forward_iterator_tag, Point_3> {
Point_iterator(Gm::Face_const_iterator it) : m_it(it) {}
void increment() { ++m_it; }
const Point_3& dereference() const { return m_it->point(); }
bool equal(Point_iterator const& o) const { return m_it == o.m_it; }
Gm::Face_const_iterator m_it;
};

int main()
{
int main() {
// Construct the Gaussian map of a tetrahedron
Point_3 points[] = {
Point_3(1.0, 0.0, 0.0),
Expand Down Expand Up @@ -61,9 +73,9 @@ int main()

Kernel::FT sw(16);
Gm::Vertex_const_handle it;
for (it = gm.vertices_begin(); it != gm.vertices_end(); ++it) {
if (it->degree() < 3) continue;
Gm::Halfedge_around_vertex_const_circulator hec3(it->incident_halfedges());
for (auto vh : gm.vertex_handles()) {
if (vh->degree() < 3) continue;
Gm::Halfedge_around_vertex_const_circulator hec3(vh->incident_halfedges());
Gm::Halfedge_around_vertex_const_circulator hec1 = hec3++;
Gm::Halfedge_around_vertex_const_circulator hec2 = hec3++;
std::cout << (*hec1).face()->point() << ", "
Expand All @@ -77,5 +89,13 @@ int main()
}
// std::cout << sw << std::endl;
if ((3 * sw) != 1) return -1;

// The following tests the code Arr_polyhedral_sgm_polyhedron_3 that
// make the polyhedron a model of the FaceGraph concepts
Gm_polyhedron P;
Point_iterator begin(gm.faces_begin());
Point_iterator end(gm.faces_end());
CGAL::convex_hull_3(begin, end, P);

return 0;
}