Merge remote-tracking branch 'cgal/master' into gsoc2019-add_basic_viewer-jasmeet

This commit is contained in:
Jasmeet Singh 2019-07-23 12:27:41 -07:00
commit 63d1838b60
478 changed files with 230411 additions and 6208 deletions

3
.gitignore vendored
View File

@ -1206,3 +1206,6 @@ gmon.*
/Stream_support/test/Stream_support/cgal_test_with_cmake
/*.html
/Snap_rounding_2/test/Snap_rounding_2/data/out
Polygonal_surface_reconstruction/examples/build*
Polygonal_surface_reconstruction/test/build*
Solver_interface/examples/build*

View File

@ -34,24 +34,24 @@ env:
- PACKAGE='Partition_2 Periodic_2_triangulation_2 Periodic_3_mesh_3 '
- PACKAGE='Periodic_3_triangulation_3 Periodic_4_hyperbolic_triangulation_2 Point_set_2 '
- PACKAGE='Point_set_3 Point_set_processing_3 Poisson_surface_reconstruction_3 '
- PACKAGE='Polygon Polygon_mesh_processing Polyhedron '
- PACKAGE='Polyhedron_IO Polyline_simplification_2 Polynomial '
- PACKAGE='Polytope_distance_d Principal_component_analysis Principal_component_analysis_LGPL '
- PACKAGE='Profiling_tools Property_map QP_solver '
- PACKAGE='Random_numbers Ridges_3 STL_Extension '
- PACKAGE='Scale_space_reconstruction_3 Scripts SearchStructures '
- PACKAGE='Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 Set_movable_separability_2 '
- PACKAGE='Shape_detection Skin_surface_3 Snap_rounding_2 '
- PACKAGE='Solver_interface Spatial_searching Spatial_sorting '
- PACKAGE='Straight_skeleton_2 Stream_lines_2 Stream_support '
- PACKAGE='Subdivision_method_3 Surface_mesh Surface_mesh_approximation '
- PACKAGE='Surface_mesh_deformation Surface_mesh_parameterization Surface_mesh_segmentation '
- PACKAGE='Surface_mesh_shortest_path Surface_mesh_simplification Surface_mesh_skeletonization '
- PACKAGE='Surface_mesher Surface_sweep_2 TDS_2 '
- PACKAGE='TDS_3 Testsuite Three '
- PACKAGE='Triangulation Triangulation_2 Triangulation_3 '
- PACKAGE='Union_find Visibility_2 Voronoi_diagram_2 '
- PACKAGE='wininst '
- PACKAGE='Polygon Polygon_mesh_processing Polygonal_surface_reconstruction '
- PACKAGE='Polyhedron Polyhedron_IO Polyline_simplification_2 '
- PACKAGE='Polynomial Polytope_distance_d Principal_component_analysis '
- PACKAGE='Principal_component_analysis_LGPL Profiling_tools Property_map '
- PACKAGE='QP_solver Random_numbers Ridges_3 '
- PACKAGE='STL_Extension Scale_space_reconstruction_3 Scripts '
- PACKAGE='SearchStructures Segment_Delaunay_graph_2 Segment_Delaunay_graph_Linf_2 '
- PACKAGE='Set_movable_separability_2 Shape_detection Skin_surface_3 '
- PACKAGE='Snap_rounding_2 Solver_interface Spatial_searching '
- PACKAGE='Spatial_sorting Straight_skeleton_2 Stream_lines_2 '
- PACKAGE='Stream_support Subdivision_method_3 Surface_mesh '
- PACKAGE='Surface_mesh_approximation Surface_mesh_deformation Surface_mesh_parameterization '
- PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification '
- PACKAGE='Surface_mesh_skeletonization Surface_mesher Surface_sweep_2 '
- PACKAGE='TDS_2 TDS_3 Testsuite '
- PACKAGE='Three Triangulation Triangulation_2 '
- PACKAGE='Triangulation_3 Union_find Visibility_2 '
- PACKAGE='Voronoi_diagram_2 wininst '
compiler: clang
install:
- echo "$PWD"

View File

@ -84,6 +84,7 @@ Point_set_processing_3
Poisson_surface_reconstruction_3
Polygon
Polygon_mesh_processing
Polygonal_surface_reconstruction
Polyhedron
Polyhedron_IO
Polyline_simplification_2

View File

@ -23,7 +23,7 @@ MainWindow::MainWindow(QWidget* parent)
m_pViewer = ui->viewer;
// does not save the state of the viewer
m_pViewer->setStateFileName(QString::null);
m_pViewer->setStateFileName(QString());
// accepts drop events
setAcceptDrops(true);

View File

@ -126,6 +126,8 @@ Before the release 4.3 of \cgal, the return type of this function used to be `bo
*/
typedef unspecified_type Intersection;
/// @}
/// \name Distance Queries
/// The following predicates are required for each
/// type `Query` for which the class `CGAL::AABB_tree<AABBTraits>` may receive a

View File

@ -13,7 +13,5 @@ template< typename T >
class Fraction_traits {
public:
/// @}
}; /* end Fraction_traits */
} /* end namespace CGAL */

View File

@ -42,7 +42,5 @@ the smallest positive remainder \f$ r\f$.
class EuclideanRing {
public:
/// @}
}; /* end EuclideanRing */

View File

@ -26,7 +26,5 @@ This is also the case for the respective global functions.
class ExplicitInteroperable {
public:
/// @}
}; /* end ExplicitInteroperable */

View File

@ -28,7 +28,5 @@ Moreover, `CGAL::Algebraic_structure_traits< FieldWithRootOf >` is a model of `A
class FieldWithRootOf {
public:
/// @}
}; /* end FieldWithRootOf */

View File

@ -27,7 +27,5 @@ Moreover, `CGAL::Algebraic_structure_traits< FieldWithSqrt >` is a model of `Alg
class FieldWithSqrt {
public:
/// @}
}; /* end FieldWithSqrt */

View File

@ -16,7 +16,5 @@ denominator type are provided by `CGAL::Fraction_traits`.
class Fraction {
public:
/// @}
}; /* end Fraction */

View File

@ -28,7 +28,5 @@ is `CGAL::Tag_true`.
class ImplicitInteroperable {
public:
/// @}
}; /* end ImplicitInteroperable */

View File

@ -33,7 +33,5 @@ Moreover, `CGAL::Algebraic_structure_traits< IntegralDomain >` is a model of
class IntegralDomain {
public:
/// @}
}; /* end IntegralDomain */

View File

@ -32,7 +32,5 @@ for Homogeneous kernels.
class RingNumberType {
public:
/// @}
}; /* end RingNumberType */

View File

@ -40,7 +40,5 @@ derived from `CGAL::Unique_factorization_domain_tag`
class UniqueFactorizationDomain {
public:
/// @}
}; /* end UniqueFactorizationDomain */

View File

@ -1435,13 +1435,9 @@ compute_event_x_coordinates_with_event_indices() const {
CGAL_ACK_DEBUG_PRINT << " one curve event" << std::endl;
#endif
*/
#if CGAL_CXX11
// Fix a warning by using `emplace_back()` instead of
// copying a non-initialized `optional
this->ptr()->event_slices.emplace_back();
#else
this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1());
#endif
switch(*(one_curve_it++)) {
case(CGAL::internal::ROOT_OF_FIRST_SET): {
event_indices.push_back(Event_indices(-1,f_count,-1));
@ -1468,11 +1464,7 @@ compute_event_x_coordinates_with_event_indices() const {
CGAL_ACK_DEBUG_PRINT << " two curve event" << std::endl;
#endif
*/
#if CGAL_CXX11
this->ptr()->event_slices.emplace_back();
#else
this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1());
#endif
event_indices.push_back
(Event_indices(inter_count,-1,-1));
@ -1486,12 +1478,7 @@ compute_event_x_coordinates_with_event_indices() const {
<< std::endl;
#endif
*/
#if CGAL_CXX11
this->ptr()->event_slices.emplace_back();
#else
this->ptr()->event_slices.push_back(Lazy_status_line_CPA_1());
#endif
switch(*(one_curve_it++)) {
case(CGAL::internal::ROOT_OF_FIRST_SET): {

View File

@ -283,9 +283,6 @@ public:
protected:
//!\name private members
//!@{
Algebraic_kernel_with_analysis_2* _m_kernel;
@ -309,6 +306,7 @@ public:
//! specified key was found
typedef typename Base::Find_result Find_result;
//!@}
//!\name constructors and access functions
//!@{
@ -343,6 +341,8 @@ public:
return (p.first)->second;
}
//!@}
}; // class LRU_hashed_map_with_kernel
/*! \brief

View File

@ -678,8 +678,6 @@ public:
return static_cast<std::size_t>(x.id());
}
//!@}
}; // class Xy_coordinate_2
template < class AlgebraicCurveKernel_2, class Rep>

View File

@ -160,7 +160,7 @@ struct Solve_1{
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
bool known_to_be_square_free,
bool,
OutputIterator res)const{
Isolator isol(p);
for(int l=0;l<isol.number_of_real_roots();++l)

View File

@ -182,7 +182,7 @@ struct Solve_z_1{
template <class OutputIterator>
OutputIterator operator()(const Polynomial_1 &p,
bool known_to_be_square_free,
bool,
OutputIterator res)const{
ZPolynomial_1 zp=PolConverter()(p);
Isolator isol(zp);

View File

@ -56,7 +56,7 @@ class RS23_k_isolator_1{
template <class Polynomial_,class Bound_>
RS23_k_isolator_1<Polynomial_,Bound_>::
RS23_k_isolator_1(const Polynomial_ &p){
RS23_k_isolator_1(const Polynomial_ &){
CGAL_error_msg("not implemented for these polynomial/bound types");
}

View File

@ -51,7 +51,7 @@ class RS2_isolator_1{
template <class Polynomial_,class Bound_>
RS2_isolator_1<Polynomial_,Bound_>::
RS2_isolator_1(const Polynomial_ &p){
RS2_isolator_1(const Polynomial_ &){
CGAL_error_msg("not implemented for these polynomial/bound types");
}

View File

@ -26,7 +26,5 @@ template< typename Traits, typename Fb, typename ExactAlphaComparisonTag >
class Alpha_shape_face_base_2 : public Fb {
public:
/// @}
}; /* end Alpha_shape_face_base_2 */
} /* end namespace CGAL */

View File

@ -27,7 +27,5 @@ template< typename Traits, typename Vb, typename ExactAlphaComparisonTag >
class Alpha_shape_vertex_base_2 : public Vb {
public:
/// @}
}; /* end Alpha_shape_vertex_base_2 */
} /* end namespace CGAL */

View File

@ -319,7 +319,7 @@ public:
return n;
}
private :
protected :
//--------------------- INITIALIZATION OF PRIVATE MEMBERS -----------

View File

@ -29,8 +29,6 @@ template< typename Traits, typename Cb, typename ExactAlphaComparisonTag, typena
class Alpha_shape_cell_base_3 : public Cb {
public:
/// @}
}; /* end Alpha_shape_cell_base_3 */
} /* end namespace CGAL */

View File

@ -29,7 +29,6 @@ template< typename Traits, typename Vb, typename ExactAlphaComparisonTag, typena
class Alpha_shape_vertex_base_3 : public Vb {
public:
/// @}
}; /* end Alpha_shape_vertex_base_3 */
} /* end namespace CGAL */

View File

@ -24,7 +24,5 @@ template< typename Traits, typename Cb >
class Fixed_alpha_shape_cell_base_3 : public Cb {
public:
/// @}
}; /* end Fixed_alpha_shape_cell_base_3 */
} /* end namespace CGAL */

View File

@ -24,7 +24,5 @@ template< typename Traits, typename Vb >
class Fixed_alpha_shape_vertex_base_3 : public Vb {
public:
/// @}
}; /* end Fixed_alpha_shape_vertex_base_3 */
} /* end namespace CGAL */

View File

@ -414,6 +414,7 @@ public:
return Intersect_2();
}
//@}
};
} //namespace CGAL

View File

@ -282,7 +282,7 @@ std::pair<double, double> parameter_range () const;
}; /* end Arr_Bezier_curve_traits_2::X_monotone_curve_2 */
Class Trim_2{
class Trim_2{
public:
/// \name Creation
/// @{
@ -295,6 +295,9 @@ Trims the given x-monotone curve to an from src to tgt.
X_monotone_curve_2(const X_monotone_curve_2& xcv,
const Point_2& src,
const Point_2& tgt)const
/// @}
}/* end Arr_Bezier_curve_traits_2::Trim_2 */
}; /* end Arr_Bezier_curve_traits_2 */

View File

@ -354,7 +354,7 @@ Bbox_2 bbox() const;
}; /* end Arr_circle_segment_traits_2::X_monotone_curve_2 */
Class Trim_2{
class Trim_2{
public:
/// \name Creation
/// @{
@ -367,6 +367,7 @@ Trims the given x-monotone curve to an from src to tgt.
X_monotone_curve_2(const X_monotone_curve_2& xcv,
const Point_2& src,
const Point_2& tgt)const
/// @}
}/* end Arr_circle_segment_traits_2::Trim_2 */
}; /* end Arr_circle_segment_traits_2 */

View File

@ -15,7 +15,5 @@ template< typename CircularKernel >
class Arr_circular_arc_traits_2 {
public:
/// @}
}; /* end Arr_circular_arc_traits_2 */
} /* end namespace CGAL */

View File

@ -19,7 +19,5 @@ template< typename CircularKernel >
class Arr_circular_line_arc_traits_2 {
public:
/// @}
}; /* end Arr_circular_line_arc_traits_2 */
} /* end namespace CGAL */

View File

@ -385,7 +385,7 @@ const Point_2& right() const;
}; /* end Arr_conic_traits_2::X_monotone_curve_2 */
Class Trim_2{
class Trim_2{
public:
/// \name Creation
/// @{
@ -398,6 +398,9 @@ Trims the given x-monotone curve to an from src to tgt.
X_monotone_curve_2(const X_monotone_curve_2& xcv,
const Point_2& src,
const Point_2& tgt)const
/// @}
}/* end Arr_conic_traits_2::Trim_2 */

View File

@ -19,8 +19,6 @@ template< typename Arrangement >
class Arr_default_overlay_traits {
public:
/// @}
}; /* end Arr_default_overlay_traits */
} /* end namespace CGAL */
@ -55,7 +53,5 @@ template< typename Arr_A, typename Arr_B, typename Arr_R, typename OvlFaceData >
class Arr_face_overlay_traits {
public:
/// @}
}; /* end Arr_face_overlay_traits */
} /* end namespace CGAL */

View File

@ -60,7 +60,5 @@ template< typename Arrangement, typename Generator >
class Arr_landmarks_point_location {
public:
/// @}
}; /* end Arr_landmarks_point_location */
} /* end namespace CGAL */

View File

@ -15,7 +15,5 @@ template< typename CircularKernel >
class Arr_line_arc_traits_2 {
public:
/// @}
}; /* end Arr_line_arc_traits_2 */
} /* end namespace CGAL */

View File

@ -145,7 +145,7 @@ public:
}; /* end Arr_linear_traits_2::Curve_2 */
Class Trim_2{
class Trim_2{
public:
/// \name Creation
/// @{
@ -158,6 +158,7 @@ Trims the given x-monotone curve to an from src to tgt.
X_monotone_curve_2(const X_monotone_curve_2& xcv,
const Point_2& src,
const Point_2& tgt)const
/// @}
}/* end Arr_linear_traits_2::Trim_2 */
}; /* end Arr_linear_traits_2 */

View File

@ -26,7 +26,5 @@ template< typename Arrangement >
class Arr_naive_point_location {
public:
/// @}
}; /* end Arr_naive_point_location */
} /* end namespace CGAL */

View File

@ -28,7 +28,5 @@ template< typename Kernel >
class Arr_non_caching_segment_basic_traits_2 {
public:
/// @}
}; /* end Arr_non_caching_segment_basic_traits_2 */
} /* end namespace CGAL */

View File

@ -45,7 +45,5 @@ class Arr_non_caching_segment_traits_2
{
public:
/// @}
}; /* end Arr_non_caching_segment_traits_2 */
} /* end namespace CGAL */

View File

@ -64,8 +64,6 @@ template< typename Kernel >
class Arr_segment_traits_2 {
public:
/// @}
Class Trim_2{
public:
/// \name Creation

View File

@ -18,8 +18,6 @@ arrangement.
struct Arr_oblivious_side_tag {
/// @}
}; /* end Arr_oblivious_side_tag */
} /* end namespace CGAL */
@ -45,7 +43,5 @@ functions based on type of curves that induce the arrangement.
struct Arr_open_side_tag {
/// @}
}; /* end Arr_open_side_tag */
} /* end namespace CGAL */

View File

@ -36,7 +36,5 @@ template< typename Arrangement >
class Arr_walk_along_line_point_location {
public:
/// @}
}; /* end Arr_walk_along_line_point_location */
} /* end namespace CGAL */

View File

@ -30,8 +30,6 @@ template< typename Arrangement >
class Arr_extended_dcel_text_formatter {
public:
/// @}
}; /* end Arr_extended_dcel_text_formatter */
} /* end namespace CGAL */
@ -64,8 +62,6 @@ template< typename Arrangement >
class Arr_face_extended_text_formatter {
public:
/// @}
}; /* end Arr_face_extended_text_formatter */
} /* end namespace CGAL */
@ -96,7 +92,5 @@ template< typename Arrangement >
class Arr_text_formatter {
public:
/// @}
}; /* end Arr_text_formatter */
} /* end namespace CGAL */

View File

@ -26,7 +26,5 @@ template< typename ArrFormatter >
class Arr_with_history_text_formatter {
public:
/// @}
}; /* end Arr_with_history_text_formatter */
} /* end namespace CGAL */

View File

@ -15,8 +15,6 @@ represents a general planar curve.
class Curve_2 {
public:
/// @}
}; /* end ArrTraits::Curve_2 */
}

View File

@ -16,8 +16,6 @@ Represents a point in the plane.
class Point_2 {
public:
/// @}
}; /* end ArrTraits::Point_2 */
}

View File

@ -16,8 +16,6 @@ Represents a planar (weakly) \f$ x\f$-monotone curve.
class XMonotoneCurve_2 {
public:
/// @}
}; /* end ArrTraits::XMonotoneCurve_2 */
}

View File

@ -40,7 +40,7 @@ public:
* models the concept `ArrTraits::Approximate_2`.
*/
typedef unspecified_type Approximate_2;
/// @}
/// \name Accessing Functor Objects
/// @{

View File

@ -161,7 +161,7 @@ inside the face `f1`.
void create_edge (Face_handle_A f1,
Halfedge_handle_B e2,
Halfedge_handle_R e) const;
/// @}
/// \name Face Creation
/// The following function is invoked whenever a new face is
/// created. It is guaranteed that all halfedges along the face

View File

@ -751,6 +751,9 @@ public:
/*! Obtain a Trim_2 functor object. */
Trim_2 trim_2_object() const { return Trim_2(*this); }
// @}
};
} //namespace CGAL

View File

@ -908,7 +908,6 @@ protected:
typedef In_place_list<Inner_ccb, false> Inner_ccb_list;
typedef In_place_list<Isolated_vertex, false> Iso_vert_list;
#ifdef CGAL_CXX11
typedef std::allocator_traits<Allocator> Allocator_traits;
typedef typename Allocator_traits::template rebind_alloc<Vertex> Vertex_allocator;
typedef typename Allocator_traits::template rebind_alloc<Halfedge> Halfedge_allocator;
@ -916,32 +915,6 @@ protected:
typedef typename Allocator_traits::template rebind_alloc<Outer_ccb> Outer_ccb_allocator;
typedef typename Allocator_traits::template rebind_alloc<Inner_ccb> Inner_ccb_allocator;
typedef typename Allocator_traits::template rebind_alloc<Isolated_vertex> Iso_vert_allocator;
#else // not CGAL_CXX11
// Vertex allocator.
typedef typename Allocator::template rebind<Vertex> Vertex_alloc_rebind;
typedef typename Vertex_alloc_rebind::other Vertex_allocator;
// Halfedge allocator.
typedef typename Allocator::template rebind<Halfedge> Halfedge_alloc_rebind;
typedef typename Halfedge_alloc_rebind::other Halfedge_allocator;
// Face allocator.
typedef typename Allocator::template rebind<Face> Face_alloc_rebind;
typedef typename Face_alloc_rebind::other Face_allocator;
// Outer CCB allocator.
typedef typename Allocator::template rebind<Outer_ccb> Out_ccb_alloc_rebind;
typedef typename Out_ccb_alloc_rebind::other Outer_ccb_allocator;
// Inner CCB allocator.
typedef typename Allocator::template rebind<Inner_ccb> In_ccb_alloc_rebind;
typedef typename In_ccb_alloc_rebind::other Inner_ccb_allocator;
// Isolated vertex allocator.
typedef typename Allocator::template rebind<Isolated_vertex>
Iso_vert_alloc_rebind;
typedef typename Iso_vert_alloc_rebind::other Iso_vert_allocator;
#endif // not CGAL_CXX11
public:
typedef typename Halfedge_list::size_type Size;
@ -1089,11 +1062,7 @@ public:
Vertex* new_vertex()
{
Vertex* v = vertex_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Vertex_allocator>::construct(vertex_alloc,v);
#else
vertex_alloc.construct(v, Vertex());
#endif
vertices.push_back(*v);
return v;
}
@ -1116,11 +1085,7 @@ public:
Face* new_face()
{
Face* f = face_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Face_allocator>::construct(face_alloc, f);
#else
face_alloc.construct(f, Face());
#endif
faces.push_back (*f);
return(f);
}
@ -1129,11 +1094,7 @@ public:
Outer_ccb* new_outer_ccb()
{
Outer_ccb* oc = out_ccb_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Outer_ccb_allocator>::construct(out_ccb_alloc, oc);
#else
out_ccb_alloc.construct(oc, Outer_ccb());
#endif
out_ccbs.push_back(*oc);
return (oc);
}
@ -1142,11 +1103,7 @@ public:
Inner_ccb* new_inner_ccb()
{
Inner_ccb* ic = in_ccb_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Inner_ccb_allocator>::construct(in_ccb_alloc, ic);
#else
in_ccb_alloc.construct(ic, Inner_ccb());
#endif
in_ccbs.push_back(*ic);
return (ic);
}
@ -1155,11 +1112,7 @@ public:
Isolated_vertex* new_isolated_vertex()
{
Isolated_vertex* iv = iso_vert_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Iso_vert_allocator>::construct(iso_vert_alloc, iv);
#else
iso_vert_alloc.construct(iv, Isolated_vertex());
#endif
iso_verts.push_back(*iv);
return (iv);
}
@ -1171,11 +1124,7 @@ public:
void delete_vertex(Vertex* v)
{
vertices.erase(v);
#ifdef CGAL_CXX11
std::allocator_traits<Vertex_allocator>::destroy(vertex_alloc, v);
#else
vertex_alloc.destroy(v);
#endif
vertex_alloc.deallocate(v,1);
}
@ -1191,11 +1140,7 @@ public:
void delete_face(Face* f)
{
faces.erase(f);
#ifdef CGAL_CXX11
std::allocator_traits<Face_allocator>::destroy(face_alloc, f);
#else
face_alloc.destroy(f);
#endif
face_alloc.deallocate(f, 1);
}
@ -1203,11 +1148,7 @@ public:
void delete_outer_ccb(Outer_ccb* oc)
{
out_ccbs.erase(oc);
#ifdef CGAL_CXX11
std::allocator_traits<Outer_ccb_allocator>::destroy(out_ccb_alloc, oc);
#else
out_ccb_alloc.destroy(oc);
#endif
out_ccb_alloc.deallocate(oc, 1);
}
@ -1215,11 +1156,7 @@ public:
void delete_inner_ccb(Inner_ccb* ic)
{
in_ccbs.erase(ic);
#ifdef CGAL_CXX11
std::allocator_traits<Inner_ccb_allocator>::destroy(in_ccb_alloc, ic);
#else
in_ccb_alloc.destroy(ic);
#endif
in_ccb_alloc.deallocate(ic, 1);
}
@ -1227,11 +1164,7 @@ public:
void delete_isolated_vertex(Isolated_vertex* iv)
{
iso_verts.erase(iv);
#ifdef CGAL_CXX11
std::allocator_traits<Iso_vert_allocator>::destroy(iso_vert_alloc, iv);
#else
iso_vert_alloc.destroy(iv);
#endif
iso_vert_alloc.deallocate(iv, 1);
}
@ -1492,11 +1425,7 @@ protected:
Halfedge* _new_halfedge()
{
Halfedge* h = halfedge_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Halfedge_allocator>::construct(halfedge_alloc, h);
#else
halfedge_alloc.construct(h, Halfedge());
#endif
halfedges.push_back(*h);
return (h);
}
@ -1505,11 +1434,7 @@ protected:
void _delete_halfedge(Halfedge* h)
{
halfedges.erase(h);
#ifdef CGAL_CXX11
std::allocator_traits<Halfedge_allocator>::destroy(halfedge_alloc,h);
#else
halfedge_alloc.destroy(h);
#endif
halfedge_alloc.deallocate(h, 1);
}
};

View File

@ -86,6 +86,8 @@ public:
typedef
typename Intersection_list::const_iterator Intersection_iter;
//@}
private:
typedef std::map<Curve_id,

View File

@ -136,7 +136,6 @@ public:
{}
/// \name Types and functors defined here.
//@{
/* Functor to augment a polyline by either adding a vertex or a segment
* at the back.

View File

@ -984,8 +984,6 @@ public:
return Merge_2(this);
}
//@}
/// \name Functor definitions to handle boundaries
//@{

View File

@ -96,6 +96,8 @@ public:
*/
virtual void before_handle_event(Event* event);
//@}
/*! A notification invoked when a new subcurve is created. */
virtual void add_subcurve(Halfedge_handle he, Subcurve* sc);

View File

@ -372,6 +372,8 @@ public:
}
}
// @}
protected:
/*! Locate the arrangement feature containing the given point in the
* unbounded face(s).

View File

@ -113,11 +113,7 @@ assign(const Self& arr)
dup_c = m_curves_alloc.allocate (1);
p_cv = &(*ocit);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, dup_c, *p_cv);
#else
m_curves_alloc.construct(dup_c, *p_cv);
#endif
m_curves.push_back (*dup_c);
// Assign a map entry.
@ -185,11 +181,7 @@ void Arrangement_on_surface_with_history_2<GeomTr,TopTr>::clear ()
++cit;
m_curves.erase (p_cv);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::destroy(m_curves_alloc,p_cv);
#else
m_curves_alloc.destroy (p_cv);
#endif
m_curves_alloc.deallocate (p_cv, 1);
}
m_curves.destroy();

View File

@ -131,12 +131,8 @@ public:
// and store it in the curves' list.
typename Arrangement_with_history_2::Curve_halfedges *p_cv =
p_arr->m_curves_alloc.allocate (1);
#ifdef CGAL_CXX11
typedef decltype(p_arr->m_curves_alloc) M_Curves_alloc;
std::allocator_traits<M_Curves_alloc>::construct(p_arr->m_curves_alloc, p_cv, cv);
#else
p_arr->m_curves_alloc.construct (p_cv, cv);
#endif
p_arr->m_curves.push_back (*p_cv);
// Return a handle to the inserted curve (the last in the list).
@ -160,6 +156,9 @@ public:
return;
}
//@}
};
} //namespace CGAL

View File

@ -1556,11 +1556,7 @@ protected:
Point_2*_new_point(const Point_2& pt)
{
Point_2* p_pt = m_points_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Points_alloc>::construct(m_points_alloc, p_pt, pt);
#else
m_points_alloc.construct(p_pt, pt);
#endif
return (p_pt);
}
@ -1568,11 +1564,7 @@ protected:
void _delete_point(Point_2& pt)
{
Point_2* p_pt = &pt;
#ifdef CGAL_CXX11
std::allocator_traits<Points_alloc>::destroy(m_points_alloc, p_pt);
#else
m_points_alloc.destroy(p_pt);
#endif
m_points_alloc.deallocate(p_pt, 1);
}
@ -1580,11 +1572,7 @@ protected:
X_monotone_curve_2* _new_curve(const X_monotone_curve_2& cv)
{
X_monotone_curve_2* p_cv = m_curves_alloc.allocate(1);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, p_cv, cv);
#else
m_curves_alloc.construct(p_cv, cv);
#endif
return (p_cv);
}
@ -1592,11 +1580,7 @@ protected:
void _delete_curve(X_monotone_curve_2& cv)
{
X_monotone_curve_2* p_cv = &cv;
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::destroy(m_curves_alloc, p_cv);
#else
m_curves_alloc.destroy(p_cv);
#endif
m_curves_alloc.deallocate(p_cv, 1);
}
//@}

View File

@ -588,6 +588,7 @@ public:
* \return true iff e1 and e2 are mergeable.
*/
bool are_mergeable (Halfedge_const_handle e1, Halfedge_const_handle e2) const;
//@}
protected:
@ -623,11 +624,7 @@ protected:
// Allocate an extended curve (with an initially empty set of edges)
// and store it in the curves' list.
Curve_halfedges *p_cv = m_curves_alloc.allocate (1);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, p_cv, cv);
#else
m_curves_alloc.construct (p_cv, cv);
#endif
m_curves.push_back (*p_cv);
// Create a data-traits Curve_2 object, which is comprised of cv and
@ -656,11 +653,7 @@ protected:
// and store it in the curves' list.
Curve_halfedges *p_cv = m_curves_alloc.allocate (1);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, p_cv, cv);
#else
m_curves_alloc.construct (p_cv, cv);
#endif
m_curves.push_back (*p_cv);
// Create a data-traits Curve_2 object, which is comprised of cv and
@ -691,11 +684,7 @@ protected:
while (begin != end) {
Curve_halfedges *p_cv = m_curves_alloc.allocate (1);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, p_cv, *begin);
#else
m_curves_alloc.construct (p_cv, *begin);
#endif
m_curves.push_back (*p_cv);
data_curves.push_back (Data_curve_2 (*begin, p_cv));
@ -744,11 +733,7 @@ protected:
// Remove the extended curve object from the list and de-allocate it.
m_curves.erase (p_cv);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::destroy(m_curves_alloc, p_cv);
#else
m_curves_alloc.destroy (p_cv);
#endif
m_curves_alloc.deallocate (p_cv, 1);
return (n_removed);
@ -811,11 +796,7 @@ public:
p_cv = &(*ocit1);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, dup_c, *p_cv);
#else
m_curves_alloc.construct (dup_c, *p_cv);
#endif
m_curves.push_back (*dup_c);
// Assign a map entry.
@ -830,11 +811,7 @@ public:
dup_c = m_curves_alloc.allocate (1);
p_cv = &(*ocit2);
#ifdef CGAL_CXX11
std::allocator_traits<Curves_alloc>::construct(m_curves_alloc, dup_c, *p_cv);
#else
m_curves_alloc.construct (dup_c, *p_cv);
#endif
m_curves.push_back (*dup_c);
// Assign a map entry.

View File

@ -1588,6 +1588,8 @@ public:
return false;
}
//!@}
protected:
//!\name Trimming
//!@{
@ -3152,7 +3154,7 @@ public:
return *(this->ptr()->_m_bbox);
}
//!}
//!@}
public:

View File

@ -458,6 +458,8 @@ public:
Arc_2 arc(x, c);
return arc;
}
//!@}
};
/*!\brief
@ -2668,7 +2670,7 @@ public:
//! this instance's first template parameter
typedef CurvedKernelViaAnalysis_2 Curved_kernel_via_analysis_2;
//!@}
// typedef Curved_kernel_via_analysis_2_functors<
// CurvedKernelViaAnalysis_2 > Functor_base;

View File

@ -713,6 +713,8 @@ public:
//! type of curve analysis
typedef typename Curve_kernel_2::Curve_analysis_2 Curve_analysis_2;
//!@}
public:
//!\name embedded types for \c Arrangement_2 package
//!@{

View File

@ -242,6 +242,8 @@ public:
}
};
//!@}
public:
//!\name Standard constructors
//!@{
@ -610,7 +612,7 @@ public:
return *(this->ptr()->_m_doubles);
}
//!}
//!@}
public:
@ -783,8 +785,7 @@ public:
*this = Point_2< Curved_kernel_via_analysis_2, Rep >(rep);
}
//!@}
//! @}
// friends ////////////////////////////////////////////////////////////////
//! befriending arc classes

View File

@ -487,6 +487,8 @@ public:
Base(rep) {
}
//!@}
Algebraic_real_1 x() const {
return Algebraic_real_1();
}
@ -1019,6 +1021,8 @@ public:
//! type of Coordinate_2
typedef Algebraic_real_2 Coordinate_2;
//!@}
public:
//! \name types and functors for \c GPA_2< both >
//!@{
@ -1031,7 +1035,6 @@ public:
//!@}
//!@}
//! \name public functors and predicates
//!@{

View File

@ -386,6 +386,7 @@ public:
virtual void read_halfedge_data(Halfedge_handle)
{}
//@}
/// \name Reading a face.
//@{
void read_face_begin()

View File

@ -174,7 +174,6 @@ public:
*/
virtual Vertex_handle insert_isolated_vertex(const Point_2& pt,
Status_line_iterator iter);
//@}
/// \name Edge-split functions (to be overridden by the child visitor).
//@{

View File

@ -349,6 +349,8 @@ protected:
*/
void _create_edge(Subcurve* sc, Halfedge_handle res_he);
//@}
/*! A visitor class to facilitate the call to create_vertex(). */
class Create_vertex_visitor : public boost::static_visitor<> {
private:

View File

@ -254,15 +254,9 @@ The main function illustrates the access to the `id()` field.
\section BGLTriangulations Triangulations as Models of the Boost Graph Concept
Triangulations have vertices and faces, allowing for a direct translation
as a graph. An edge is defined as a pair of a face handle and the
index of the edge.
Particular care has to be taken with the infinite vertex and its incident
edges. One can either use a
<a href="https://www.boost.org/libs/graph/doc/filtered_graph.html">boost::filtered_graph</a>
in order to make the infinite edges
invisible, or one can have a property map that returns an infinite length
for these edges.
A complete list can be found in the documentation of \link BGLT2GT boost::graph_traits \endlink.
as a graph. A halfedge is defined as a pair of a face handle and the
index of the edge. A complete list can be found in the documentation
of \link BGLT2GT boost::graph_traits \endlink.
A classical example for an algorithm that is a combination of
computational geometry and graph theory is the <I>Euclidean Minimum
@ -291,7 +285,7 @@ use the property map returned by the call `get(boost::vertex_index,ft)`.
This property map assumes that the vertex has a
member function `id()` that returns a reference to an int.
Therefore \cgal offers a class `Triangulation_vertex_base_with_id_2`.
It is in the users responsibility to set the indices properly.
It is in the user's responsibility to set the indices properly.
The example further illustrates that the graph traits also works
for the Delaunay triangulation.

View File

@ -33,8 +33,6 @@ struct Linear_cell_complex_bgl_min_items
*/
struct Linear_cell_complex_bgl_min_items {
/// @}
}; /* end Linear_cell_complex_bgl_min_items */
} /* end namespace CGAL */

View File

@ -0,0 +1,45 @@
namespace CGAL {
/*!
\ingroup PkgBGLHelper
The class `Triangulation_face_base_with_id_2` is a model of the
concept `TriangulationFaceBase_2`, the base face of a
2D-triangulation. It provides an integer field that can be used to
index faces for \sc{Bgl} algorithms.
Note that the user is in charge of setting indices correctly before
running a graph algorithm.
\tparam TriangulationTraits_2 is the geometric traits class
and must be a model of `TriangulationTraits_2`.
\tparam TriangulationFaceBase_2 must be a face base class from which
`Triangulation_face_base_with_id_2` derives. It has the default
value `Triangulation_face_base_2<TriangulationTraits_2>`.
\cgalModels `TriangulationFaceBase_2`
\sa `CGAL::Triangulation_face_base_2`
*/
template< typename TriangulationTraits_2, typename TriangulationFaceBase_2 >
class Triangulation_face_base_with_id_2 : public TriangulationFaceBase_2 {
public:
/// \name Access Functions
/// @{
/*!
Returns the index.
*/
int id() const;
/*!
Returns a reference to the index stored in the face.
*/
int& id();
/// @}
}; /* end Triangulation_face_base_with_id_2 */
} /* end namespace CGAL */

View File

@ -4,6 +4,7 @@ PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - CGAL and the Boost Graph Library"
INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Euler_operations.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/iterator.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/helpers.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/generators.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/selection.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/split_graph_into_polylines.h \
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/copy_face_graph.h \

View File

@ -546,7 +546,12 @@ Methods to read and write graphs.
\cgalPkgPicture{emst-detail.png}
\cgalPkgSummaryBegin
\cgalPkgAuthors{Andreas Fabri, Fernando Cacciola, Philipp Moeller, and Ron Wein}
\cgalPkgDesc{This package provides a framework for interfacing \cgal data structures with the algorithms of the Boost Graph Library, or \sc{BGL} for short. It allows to run graph algorithms directly on \cgal data structures which are model of the \sc{BGL} graph concepts, for example the shortest path algorithm on a Delaunay triangulation in order to compute the Euclidean minimum spanning tree. Furthermore, it introduces several new graph concepts describing halfedge data structures.}
\cgalPkgDesc{This package provides a framework for interfacing \cgal data structures
with the algorithms of the Boost Graph Library, or \sc{BGL} for short.
It allows to run graph algorithms directly on \cgal data structures which are model
of the \sc{BGL} graph concepts, for example the shortest path algorithm
on a Delaunay triangulation in order to compute the Euclidean minimum spanning tree.
Furthermore, it introduces several new graph concepts describing halfedge data structures.}
\cgalPkgManuals{Chapter_CGAL_and_the_Boost_Graph_Library,PkgBGLRef}
\cgalPkgSummaryEnd
\cgalPkgShortInfoBegin
@ -593,6 +598,7 @@ user might encounter.
\cgalCRPSection{Helper Classes}
- `CGAL::Triangulation_vertex_base_with_id_2`
- `CGAL::Triangulation_face_base_with_id_2`
- `CGAL::Arr_vertex_index_map`
- `CGAL::Arr_face_index_map`
- `CGAL::HalfedgeDS_vertex_max_base_with_id`

View File

@ -150,30 +150,29 @@ and `CGAL::Triangulation_hierarchy_2`
so that they are model of the graph concepts
`BidirectionalGraph`, `VertexAndEdgeListGraph`, and `FaceListGraph`.
The mapping between vertices and edges of the triangulation and the
Only finite simplices exist when viewed through the scope of these graph traits classes.
The infinite vertex, halfedges, edges, and faces will thus not appear when looping around a border
vertex, or walking through the faces container.
The mapping between vertices, edges, and faces of the triangulation and the
graph is rather straightforward, but there are some subtleties. The
value type of the \sc{Bgl} iterators is the vertex or edge descriptor,
whereas in \cgal all iterators and circulators are also handles and
hence have as value type Vertex or Edge.
The graph traits class for triangulations does not distinguish between
finite and infinite vertices and edges. As the edge weight computed
with the default property map of \sc{Bgl} algorithms (obtained with
`get(t, boost::edge_weight)`) is the length of the edge,
the edge weight is not well defined for infinite edges. For algorithms
that make use of the edge weight, the user must therefore
define a <A HREF="https://www.boost.org/libs/graph/doc/filtered_graph.html">`boost::filtered_graph`</A> or pass a property map to the
algorithm that returns "infinity" for infinite edges.
| Member | Value | Description |
| :----------------------- | :----: | :---------- |
| `vertex_descriptor` | `Triangulation::Vertex_handle` | Identify vertices in the graph. |
| `edge_descriptor` | `unspecified_type` | Identify edges in the graph. It is constructible from and convertible to `Triangulation::Edge`. It is not a simple typedef, but a proper class, because in an undirected graph the edges `(u,v)` and `(v,u)` must be equal. This is not the case for the Edge type of the triangulation. |
| `vertex_descriptor` | `unspecified_type` | Identify vertices in the graph. |
| `halfedge_descriptor` | `unspecified_type` | Identify halfedges in the graph. It is constructible from and convertible to `Triangulation::Edge`. It is not a simple typedef, but a proper class, because there is no representation for halfedges in the 2D triangulation data structure. |
| `edge_descriptor` | `unspecified_type` | Identify edges in the graph. It is constructible from and convertible to `Triangulation::Edge`. It is not a simple typedef, but a proper class, because in an undirected graph the edges `(u,v)` and `(v,u)` must be equal. This is not the case for the Edge type of the triangulation. |
| `face_descriptor` | `unspecified_type` | Identify faces in the graph. |
| `adjacency_iterator` | `unspecified_type` | An iterator to traverse through the vertices adjacent to a vertex. Its value type is `vertex_descriptor`. |
| `out_edge_iterator` | `unspecified_type` | An iterator to traverse through the outgoing edges incident to a vertex. Its value type is `edge_descriptor`. |
| `in_edge_iterator` | `unspecified_type` | An iterator to traverse through the incoming edges incident to a vertex. Its value type is `edge_descriptor`. |
| `vertex_iterator` | `unspecified_type` | An iterator to traverse through the vertices of the graph. Its value type is `vertex_descriptor`. |
| `edge_iterator` | `unspecified_type` | An iterator to traverse through the edges of the graph. Its value type is `edge_descriptor`. |
| `vertex_iterator` | `unspecified_type` | An iterator to traverse through the vertices of the graph. Its value type is `vertex_descriptor`. |
| `halfedge_iterator` | `unspecified_type` | An iterator to traverse through the halfedges of the graph. Its value type is `halfedge_descriptor`. |
| `edge_iterator` | `unspecified_type` | An iterator to traverse through the edges of the graph. Its value type is `edge_descriptor`. |
| `face_iterator` | `unspecified_type` | An iterator to traverse through the faces of the graph. Its value type is `face_descriptor`. |
| `directed_category` | `boost::undirected_tag` | This graph is not directed. |
| `edge_parallel_category` | `boost::disallow_parallel_edge_tag` | This graph does not support multiedges. |
| `traversal_category` | Inherits from `boost::bidirectional_graph_tag`, `boost::adjacency_graph_tag`, `boost::vertex_list_graph_tag`, and `boost::edge_list_graph_tag` | The ways in which the vertices in the graph can be traversed.. |

View File

@ -1,103 +1,70 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
#include <CGAL/boost/graph/dijkstra_shortest_paths.h>
#include <boost/graph/filtered_graph.hpp>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Triangulation_2<K> Triangulation;
typedef CGAL::Triangulation_2<K> Triangulation;
// As we want to run Dijskra's shortest path algorithm we only
// consider finite vertices and edges.
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
template <typename T>
struct Is_finite {
typedef std::map<vertex_descriptor, int> VertexIndexMap;
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
const T* t_;
Is_finite()
: t_(NULL)
{}
Is_finite(const T& t)
: t_(&t)
{ }
template <typename VertexOrEdge>
bool operator()(const VertexOrEdge& voe) const {
return ! t_->is_infinite(voe);
}
};
typedef Is_finite<Triangulation> Filter;
typedef boost::filtered_graph<Triangulation,Filter,Filter> Finite_triangulation;
typedef boost::graph_traits<Finite_triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Finite_triangulation>::vertex_iterator vertex_iterator;
typedef std::map<vertex_descriptor,int> VertexIndexMap;
VertexIndexMap vertex_id_map;
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int
main(int argc,char* argv[])
int main(int argc,char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t;
Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite);
Triangulation tr;
Point p ;
while(input >> p){
t.insert(p);
}
while(input >> p)
tr.insert(p);
vertex_iterator vit, ve;
// Associate indices to the vertices
VertexIndexMap vertex_id_map;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int index = 0;
// boost::tie assigns the first and second element of the std::pair
// returned by boost::vertices to the variables vit and ve
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
vertex_id_map[vd]= index++;
}
for(vertex_descriptor vd : vertices(tr))
vertex_id_map[vd] = index++;
// Dijkstra's shortest path needs property maps for the predecessor and distance
// We first declare a vector
std::vector<vertex_descriptor> predecessor(boost::num_vertices(ft));
// and then turn it into a property map
boost::iterator_property_map<std::vector<vertex_descriptor>::iterator,
VertexIdPropertyMap>
predecessor_pmap(predecessor.begin(), vertex_index_pmap);
std::vector<vertex_descriptor> predecessor(num_vertices(tr));
std::vector<double> distance(boost::num_vertices(ft));
boost::iterator_property_map<std::vector<double>::iterator,
VertexIdPropertyMap>
// and then turn it into a property map
boost::iterator_property_map<std::vector<vertex_descriptor>::iterator, VertexIdPropertyMap>
predecessor_pmap(predecessor.begin(), vertex_index_pmap);
std::vector<double> distance(num_vertices(tr));
boost::iterator_property_map<std::vector<double>::iterator, VertexIdPropertyMap>
distance_pmap(distance.begin(), vertex_index_pmap);
// start at an arbitrary vertex
vertex_descriptor source = *boost::vertices(ft).first;
vertex_descriptor source = *vertices(tr).first;
std::cout << "\nStart dijkstra_shortest_paths at " << source->point() <<"\n";
boost::dijkstra_shortest_paths(ft, source,
distance_map(distance_pmap)
.predecessor_map(predecessor_pmap)
.vertex_index_map(vertex_index_pmap));
boost::dijkstra_shortest_paths(tr, source,
distance_map(distance_pmap)
.predecessor_map(predecessor_pmap)
.vertex_index_map(vertex_index_pmap));
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
for(vertex_descriptor vd : vertices(tr))
{
std::cout << vd->point() << " [" << vertex_id_map[vd] << "] ";
std::cout << " has distance = " << boost::get(distance_pmap,vd)
<< " and predecessor ";
vd = boost::get(predecessor_pmap,vd);
std::cout << " has distance = " << boost::get(distance_pmap,vd)
<< " and predecessor ";
vd = boost::get(predecessor_pmap,vd);
std::cout << vd->point() << " [" << vertex_id_map[vd] << "]\n ";
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,94 +1,66 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_id_2.h>
#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/dijkstra_shortest_paths.h>
#include <boost/graph/filtered_graph.hpp>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Triangulation_vertex_base_with_id_2<K> Tvb;
typedef CGAL::Triangulation_face_base_2<K> Tfb;
typedef CGAL::Triangulation_data_structure_2<Tvb,Tfb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Triangulation;
typedef CGAL::Triangulation_vertex_base_with_id_2<K> Tvb;
typedef CGAL::Triangulation_face_base_2<K> Tfb;
typedef CGAL::Triangulation_data_structure_2<Tvb, Tfb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Triangulation;
// consider finite vertices and edges.
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
template <typename T>
struct Is_finite {
typedef boost::property_map<Triangulation, boost::vertex_index_t>::type VertexIdPropertyMap;
const T* t_;
Is_finite()
: t_(NULL)
{}
Is_finite(const T& t)
: t_(&t)
{ }
template <typename VertexOrEdge>
bool operator()(const VertexOrEdge& voe) const {
return ! t_->is_infinite(voe);
}
};
typedef Is_finite<Triangulation> Filter;
typedef boost::filtered_graph<Triangulation,Filter,Filter> Finite_triangulation;
typedef boost::graph_traits<Finite_triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Finite_triangulation>::vertex_iterator vertex_iterator;
int
main(int argc,char* argv[])
int main(int argc,char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t;
Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite);
Triangulation tr;
Point p ;
while(input >> p){
t.insert(p);
}
Point p;
while(input >> p)
tr.insert(p);
vertex_iterator vit, ve;
// associate indices to the vertices
int index = 0;
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
for(vertex_descriptor vd : vertices(tr))
vd->id()= index++;
}
typedef boost::property_map<Triangulation, boost::vertex_index_t>::type VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap = get(boost::vertex_index, ft);
VertexIdPropertyMap vertex_index_pmap = get(boost::vertex_index, tr);
// Dijkstra's shortest path needs property maps for the predecessor and distance
std::vector<vertex_descriptor> predecessor(boost::num_vertices(ft));
std::vector<vertex_descriptor> predecessor(num_vertices(tr));
boost::iterator_property_map<std::vector<vertex_descriptor>::iterator, VertexIdPropertyMap>
predecessor_pmap(predecessor.begin(), vertex_index_pmap);
std::vector<double> distance(boost::num_vertices(ft));
std::vector<double> distance(num_vertices(tr));
boost::iterator_property_map<std::vector<double>::iterator, VertexIdPropertyMap>
distance_pmap(distance.begin(), vertex_index_pmap);
vertex_descriptor source = *boost::vertices(ft).first;
vertex_descriptor source = *vertices(tr).first;
std::cout << "\nStart dijkstra_shortest_paths at " << source->point() << std::endl;
boost::dijkstra_shortest_paths(ft, source ,
distance_map(distance_pmap)
.predecessor_map(predecessor_pmap));
boost::dijkstra_shortest_paths(tr, source, distance_map(distance_pmap)
.predecessor_map(predecessor_pmap));
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
for(vertex_descriptor vd : vertices(tr))
{
std::cout << vd->point() << " [" << vd->id() << "] ";
std::cout << " has distance = " << get(distance_pmap,vd) << " and predecessor ";
vd = get(predecessor_pmap,vd);
std::cout << vd->point() << " [" << vd->id() << "]\n";
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,98 +1,65 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/filtered_graph.hpp>
#include <fstream>
#include <iostream>
#include <map>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
// As we only consider finite vertices and edges
// we need the following filter
template <typename T>
struct Is_finite {
const T* t_;
Is_finite()
: t_(NULL)
{}
Is_finite(const T& t)
: t_(&t)
{ }
template <typename VertexOrEdge>
bool operator()(const VertexOrEdge& voe) const {
return ! t_->is_infinite(voe);
}
};
typedef Is_finite<Triangulation> Filter;
typedef boost::filtered_graph<Triangulation,Filter,Filter> Finite_triangulation;
typedef boost::graph_traits<Finite_triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Finite_triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Finite_triangulation>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Triangulation>::edge_descriptor edge_descriptor;
// The BGL makes use of indices associated to the vertices
// We use a std::map to store the index
typedef std::map<vertex_descriptor,int> VertexIndexMap;
VertexIndexMap vertex_id_map;
typedef std::map<vertex_descriptor,int> VertexIndexMap;
// A std::map is not a property map, because it is not lightweight
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
int
main(int argc,char* argv[])
int main(int argc,char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t;
Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite);
Triangulation tr;
Point p ;
while(input >> p){
t.insert(p);
}
Point p;
while(input >> p)
tr.insert(p);
vertex_iterator vit, ve;
// Associate indices to the vertices
VertexIndexMap vertex_id_map;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int index = 0;
// boost::tie assigns the first and second element of the std::pair
// returned by boost::vertices to the variables vit and ve
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
vertex_id_map[vd]= index++;
}
for(vertex_descriptor vd : vertices(tr))
vertex_id_map[vd] = index++;
// We use the default edge weight which is the squared length of the edge
// This property map is defined in graph_traits_Triangulation_2.h
// In the function call you can see a named parameter: vertex_index_map
std::list<edge_descriptor> mst;
boost::kruskal_minimum_spanning_tree(ft,
std::back_inserter(mst),
vertex_index_map(vertex_index_pmap));
std::list<edge_descriptor> mst;
boost::kruskal_minimum_spanning_tree(tr, std::back_inserter(mst),
vertex_index_map(vertex_index_pmap));
std::cout << "The edges of the Euclidean mimimum spanning tree:" << std::endl;
for(edge_descriptor ed : mst)
{
vertex_descriptor svd = source(ed, tr);
vertex_descriptor tvd = target(ed, tr);
Triangulation::Vertex_handle sv = svd;
Triangulation::Vertex_handle tv = tvd;
std::cout << "[ " << sv->point() << " | " << tv->point() << " ] " << std::endl;
}
std::cout << "The edges of the Euclidean mimimum spanning tree:" << std::endl;
for(std::list<edge_descriptor>::iterator it = mst.begin(); it != mst.end(); ++it){
edge_descriptor ed = *it;
vertex_descriptor svd = source(ed,t);
vertex_descriptor tvd = target(ed,t);
Triangulation::Vertex_handle sv = svd;
Triangulation::Vertex_handle tv = tvd;
std::cout << "[ " << sv->point() << " | " << tv->point() << " ] " << std::endl;
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,4 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_hierarchy_2.h>
@ -9,104 +10,71 @@
#include <CGAL/boost/graph/graph_traits_Triangulation_hierarchy_2.h>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/filtered_graph.hpp>
#include <fstream>
#include <iostream>
#include <map>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_2 Point;
typedef CGAL::Triangulation_vertex_base_2<K> Vbb;
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
typedef CGAL::Exact_predicates_tag Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K,TDS,Itag> CDT;
typedef CGAL::Triangulation_hierarchy_2<CDT> CDTH;
typedef CGAL::Constrained_triangulation_plus_2<CDTH> Triangulation;
typedef CGAL::Triangulation_vertex_base_2<K> Vbb;
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
typedef CGAL::Exact_predicates_tag Itag;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag> CDT;
typedef CGAL::Triangulation_hierarchy_2<CDT> CDTH;
typedef CGAL::Constrained_triangulation_plus_2<CDTH> Triangulation;
// As we only consider finite vertices and edges
// we need the following filter
template <typename T>
struct Is_finite {
const T* t_;
Is_finite()
: t_(NULL)
{}
Is_finite(const T& t)
: t_(&t)
{ }
template <typename VertexOrEdge>
bool operator()(const VertexOrEdge& voe) const {
return ! t_->is_infinite(voe);
}
};
typedef Is_finite<Triangulation> Filter;
typedef boost::filtered_graph<Triangulation,Filter,Filter> Finite_triangulation;
typedef boost::graph_traits<Finite_triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Finite_triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Finite_triangulation>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Triangulation>::edge_descriptor edge_descriptor;
// The BGL makes use of indices associated to the vertices
// We use a std::map to store the index
typedef std::map<vertex_descriptor,int> VertexIndexMap;
VertexIndexMap vertex_id_map;
typedef std::map<vertex_descriptor,int> VertexIndexMap;
// A std::map is not a property map, because it is not lightweight
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
int
main(int argc,char* argv[])
int main(int argc,char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/points.xy";
std::ifstream input(filename);
Triangulation t;
Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite);
Triangulation tr;
Point p ;
while(input >> p){
t.insert(p);
}
Point p;
while(input >> p)
tr.insert(p);
vertex_iterator vit, ve;
// Associate indices to the vertices
VertexIndexMap vertex_id_map;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int index = 0;
// boost::tie assigns the first and second element of the std::pair
// returned by boost::vertices to the variables vit and ve
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
vertex_id_map[vd]= index++;
}
for(vertex_descriptor vd : vertices(tr))
vertex_id_map[vd] = index++;
// We use the default edge weight which is the squared length of the edge
// This property map is defined in graph_traits_Triangulation_2.h
// In the function call you can see a named parameter: vertex_index_map
std::list<edge_descriptor> mst;
boost::kruskal_minimum_spanning_tree(ft,
std::back_inserter(mst),
vertex_index_map(vertex_index_pmap));
std::list<edge_descriptor> mst;
boost::kruskal_minimum_spanning_tree(tr,
std::back_inserter(mst),
vertex_index_map(vertex_index_pmap));
std::cout << "The edges of the Euclidean mimimum spanning tree:" << std::endl;
std::cout << "The edges of the Euclidean mimimum spanning tree:" << std::endl;
for(edge_descriptor ed : mst)
{
vertex_descriptor svd = source(ed, tr);
vertex_descriptor tvd = target(ed, tr);
Triangulation::Vertex_handle sv = svd;
Triangulation::Vertex_handle tv = tvd;
std::cout << "[ " << sv->point() << " | " << tv->point() << " ] " << std::endl;
}
for(std::list<edge_descriptor>::iterator it = mst.begin(); it != mst.end(); ++it){
edge_descriptor ed = *it;
vertex_descriptor svd = source(ed,t);
vertex_descriptor tvd = target(ed,t);
Triangulation::Vertex_handle sv = svd;
Triangulation::Vertex_handle tv = tvd;
std::cout << "[ " << sv->point() << " | " << tv->point() << " ] " << std::endl;
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,38 +1,24 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Kernel/global_functions_2.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Regular_triangulation_2.h>
#include <CGAL/internal/boost/function_property_map.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/filtered_graph.hpp>
#include <fstream>
#include <iostream>
#include <map>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Weighted_point_2 Weighted_point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::FT FT;
typedef K::Weighted_point_2 Weighted_point;
typedef CGAL::Regular_triangulation_2<K> Triangulation;
typedef CGAL::Regular_triangulation_2<K> Triangulation;
// As we only consider finite vertices and edges
// we need the following filter
template <typename T>
struct Is_finite {
const T* t_;
Is_finite() : t_(NULL) { }
Is_finite(const T& t) : t_(&t) { }
template <typename VertexOrEdge>
bool operator()(const VertexOrEdge& voe) const {
return ! t_->is_infinite(voe);
}
};
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Triangulation>::edge_descriptor edge_descriptor;
template <typename T>
struct Compute_edge_weight
@ -42,7 +28,7 @@ struct Compute_edge_weight
Compute_edge_weight(const T& t) : t_(t) { }
typedef typename boost::graph_traits<T>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<T>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<T>::edge_descriptor edge_descriptor;
FT operator()(const edge_descriptor ed) const {
vertex_descriptor svd = source(ed, t_);
@ -53,69 +39,54 @@ struct Compute_edge_weight
}
};
typedef Is_finite<Triangulation> Filter;
typedef boost::filtered_graph<Triangulation,Filter,Filter> Finite_triangulation;
typedef boost::graph_traits<Finite_triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Finite_triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Finite_triangulation>::edge_descriptor edge_descriptor;
// The BGL makes use of indices associated to the vertices
// We use a std::map to store the index
typedef std::map<vertex_descriptor,int> VertexIndexMap;
VertexIndexMap vertex_id_map;
// A std::map is not a property map, because it is not lightweight
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int
main(int argc,char* argv[])
int main(int argc,char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/weighted_points.xyw";
std::ifstream input(filename);
Triangulation t;
Filter is_finite(t);
Finite_triangulation ft(t, is_finite, is_finite);
Triangulation tr;
Weighted_point wp ;
while(input >> wp){
t.insert(wp);
}
Weighted_point wp;
while(input >> wp)
tr.insert(wp);
// Note that with the input "data/weighted_points.xyw", there is one hidden vertex
std::cout << "number of hidden vertices: " << t.number_of_hidden_vertices() << std::endl;
std::cout << "number of hidden vertices: " << tr.number_of_hidden_vertices() << std::endl;
vertex_iterator vit, ve;
// Associate indices to the vertices
VertexIndexMap vertex_id_map;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int index = 0;
// boost::tie assigns the first and second element of the std::pair
// returned by boost::vertices to the variables vit and ve
for(boost::tie(vit,ve)=boost::vertices(ft); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
for(vertex_descriptor vd : vertices(tr))
vertex_id_map[vd]= index++;
}
// We use a custom edge length property map that computes the power distance
// between the extremities of an edge of the regular triangulation
typedef Compute_edge_weight<Triangulation> Edge_weight_functor;
// In the function call you can see a named parameter: vertex_index_map
std::list<edge_descriptor> mst;
boost::kruskal_minimum_spanning_tree(
ft, std::back_inserter(mst),
vertex_index_map(vertex_index_pmap).
weight_map(CGAL::internal::boost_::make_function_property_map<
edge_descriptor, FT, Edge_weight_functor>(Edge_weight_functor(t))));
std::list<edge_descriptor> mst;
boost::kruskal_minimum_spanning_tree(tr, std::back_inserter(mst),
vertex_index_map(vertex_index_pmap)
.weight_map(CGAL::internal::boost_::make_function_property_map<
edge_descriptor, FT, Edge_weight_functor>(Edge_weight_functor(tr))));
std::cout << "The edges of the Euclidean mimimum spanning tree:" << std::endl;
for(std::list<edge_descriptor>::iterator it = mst.begin(); it != mst.end(); ++it){
edge_descriptor ed = *it;
vertex_descriptor svd = source(ed,t);
vertex_descriptor tvd = target(ed,t);
Triangulation::Vertex_handle sv = svd;
Triangulation::Vertex_handle tv = tvd;
std::cout << "[ " << sv->point() << " | " << tv->point() << " ] " << std::endl;
}
std::cout << "The edges of the Euclidean mimimum spanning tree:" << std::endl;
for(edge_descriptor ed : mst)
{
vertex_descriptor svd = source(ed, tr);
vertex_descriptor tvd = target(ed, tr);
Triangulation::Vertex_handle sv = svd;
Triangulation::Vertex_handle tv = tvd;
std::cout << "[ " << sv->point() << " | " << tv->point() << " ] " << std::endl;
}
return 0;
return EXIT_SUCCESS;
}

View File

@ -1,4 +1,5 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/Projection_traits_xy_3.h>
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
@ -6,110 +7,81 @@
#include <boost/graph/filtered_graph.hpp>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic;
typedef CGAL::Projection_traits_xy_3<Epic> K;
typedef K::Point_2 Point;
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic;
typedef CGAL::Projection_traits_xy_3<Epic> K;
typedef K::Point_2 Point;
typedef CGAL::Triangulation_2<K> Triangulation;
typedef CGAL::Triangulation_2<K> Triangulation;
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Triangulation>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Triangulation>::halfedge_iterator halfedge_iterator;
typedef boost::graph_traits<Triangulation>::edge_iterator edge_iterator;
typedef boost::graph_traits<Triangulation>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Triangulation>::face_descriptor face_descriptor;
typedef boost::graph_traits<Triangulation>::face_iterator face_iterator;
typedef std::map<vertex_descriptor, int> VertexIndexMap;
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
typedef boost::graph_traits<Triangulation>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Triangulation>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Triangulation>::halfedge_iterator halfedge_iterator;
typedef boost::graph_traits<Triangulation>::face_descriptor face_descriptor;
typedef boost::graph_traits<Triangulation>::vertex_iterator vertex_iterator;
typedef boost::graph_traits<Triangulation>::face_iterator face_iterator;
typedef boost::graph_traits<Triangulation>::edge_iterator edge_iterator;
typedef boost::graph_traits<Triangulation>::edge_descriptor edge_descriptor;
typedef boost::property_map<Triangulation, boost::vertex_point_t>::type Ppmap;
typedef std::map<vertex_descriptor,int> VertexIndexMap;
VertexIndexMap vertex_id_map;
typedef boost::associative_property_map<VertexIndexMap> VertexIdPropertyMap;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
typedef std::map<halfedge_descriptor,int> HalfedgeIndexMap;
HalfedgeIndexMap halfedge_id_map;
typedef boost::associative_property_map<HalfedgeIndexMap> HalfedgeIdPropertyMap;
HalfedgeIdPropertyMap halfedge_index_pmap(halfedge_id_map);
int
main(int,char*[])
int main(int /*argc*/, char** /*argc*/)
{
Triangulation t;
Triangulation tr;
t.insert(Point(0.1,0,1));
t.insert(Point(1,0,1));
t.insert(Point(0.2,0.2, 2));
t.insert(Point(0,1,2));
t.insert(Point(0,2,3));
tr.insert(Point(0.1,0,1));
tr.insert(Point(1,0,1));
tr.insert(Point(0.2,0.2, 2));
tr.insert(Point(0,1,2));
tr.insert(Point(0,2,3));
vertex_iterator vit, ve;
// Associate indices to the vertices
VertexIndexMap vertex_id_map;
VertexIdPropertyMap vertex_index_pmap(vertex_id_map);
int index = 0;
// boost::tie assigns the first and second element of the std::pair
// returned by boost::vertices to the variables vit and ve
for(boost::tie(vit,ve) = vertices(t); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
if(! t.is_infinite(vd)){
vertex_id_map[vd]= index++;
}
}
for(vertex_descriptor vd : vertices(tr))
vertex_id_map[vd] = index++;
std::cerr << index << " vertices" << std::endl;
index = 0;
face_iterator fit,fe;
for(boost::tie(fit,fe) = faces(t); fit!= fe; ++fit){
face_descriptor fd = *fit;
halfedge_descriptor hd = halfedge(fd,t);
halfedge_descriptor n = next(hd,t);
halfedge_descriptor nn = next(n,t);
if(next(nn,t) != hd){
std::cerr << "the face is not a triangle" << std::endl;
}
++index;
}
std::cerr << index << " faces" << std::endl;
index = 0;
edge_iterator eit,ee;
for(boost::tie(eit,ee) = edges(t); eit!= ee; ++eit){
edge_descriptor ed = *eit;
vertex_descriptor vd = source(ed,t);
CGAL_USE(vd);
++index;
}
std::cerr << index << " edges" << std::endl;
index = 0;
halfedge_iterator hit,he;
for(boost::tie(hit,he) = halfedges(t); hit!= he; ++hit){
halfedge_descriptor hd = *hit;
vertex_descriptor vd = source(hd,t);
for(halfedge_descriptor hd : halfedges(tr))
{
vertex_descriptor vd = source(hd, tr);
CGAL_USE(vd);
++index;
}
std::cerr << index << " halfedges" << std::endl;
std::cerr << num_vertices(t) << " " << num_edges(t) << " " << num_halfedges(t) << " " << num_faces(t) << std::endl;
typedef boost::property_map<Triangulation, boost::vertex_point_t>::type Ppmap;
Ppmap ppmap = get(boost::vertex_point, t);
for(vertex_descriptor vd : vertices_around_target(*vertices(t).first, t)){
std::cout << ppmap[vd] << std::endl;
index = 0;
for(edge_descriptor ed : edges(tr))
{
vertex_descriptor vd = source(ed, tr);
CGAL_USE(vd);
++index;
}
std::cerr << index << " edges" << std::endl;
index = 0;
for(face_descriptor fd : faces(tr))
{
halfedge_descriptor hd = halfedge(fd, tr);
CGAL_USE(hd);
++index;
}
std::cerr << index << " faces" << std::endl;
ppmap[*(++vertices(t).first)] = Point(78,1,2);
std::cout << " changed point of vertex " << ppmap[*(++vertices(t).first)] << std::endl;
std::cerr << num_vertices(tr) << " " << num_halfedges(tr) << " " << num_edges(tr) << " " << num_faces(tr) << std::endl;
return 0;
std::cout << "vertices incident to the first vertex:" << std::endl;
Ppmap ppmap = get(boost::vertex_point, tr);
for(vertex_descriptor vd : vertices_around_target(*vertices(tr).first, tr))
std::cout << ppmap[vd] << std::endl;
ppmap[*(++vertices(tr).first)] = Point(78, 1, 2);
std::cout << "changed point of vertex " << ppmap[*(++vertices(tr).first)] << std::endl;
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,829 @@
// Copyright (c) 2014, 2017 GeometryFactory (France). All rights reserved.
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0+
//
// Author(s) : Maxime Gimeno,
// Mael Rouxel-Labbé
#ifndef CGAL_BOOST_GRAPH_GENERATORS_H
#define CGAL_BOOST_GRAPH_GENERATORS_H
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/properties.h>
#include <CGAL/Random.h>
#include <CGAL/function_objects.h>
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 {
template <class FaceGraph>
void swap_vertices(typename boost::graph_traits<FaceGraph>::vertex_descriptor& p,
typename boost::graph_traits<FaceGraph>::vertex_descriptor& q,
FaceGraph& g);
template<typename InputIterator>
typename std::iterator_traits<InputIterator>::value_type
random_entity_in_range(InputIterator first, InputIterator beyond,
CGAL::Random& rnd = get_default_random())
{
typedef typename std::iterator_traits<InputIterator>::difference_type size_type;
size_type zero = 0, ne = std::distance(first, beyond);
std::advance(first, rnd.uniform_int(zero, ne - 1));
return *first;
}
template<typename InputIterator>
typename std::iterator_traits<InputIterator>::value_type
random_entity_in_range(const CGAL::Iterator_range<InputIterator>& range,
CGAL::Random& rnd = get_default_random())
{
return random_entity_in_range(range.begin(), range.end(), rnd);
}
// \brief returns a random non-null vertex incident to the face `fd` of the polygon mesh `g`.
// \tparam Graph a model of `HalfedgeGraph`
template<typename Graph>
typename boost::graph_traits<Graph>::vertex_descriptor
random_vertex_in_face(typename boost::graph_traits<Graph>::face_descriptor fd,
const Graph& g,
CGAL::Random& rnd = get_default_random())
{
return internal::random_entity_in_range(vertices_around_face(halfedge(fd, g), g), rnd);
}
// \brief returns a random non-null halfedge incident to the face `fd` of the polygon mesh `g`.
// \tparam Graph a model of `HalfedgeGraph`
template<typename Graph>
typename boost::graph_traits<Graph>::halfedge_descriptor
random_halfedge_in_face(typename boost::graph_traits<Graph>::face_descriptor fd,
const Graph& g,
CGAL::Random& rnd = get_default_random())
{
return internal::random_entity_in_range(halfedges_around_face(halfedge(fd, g), g), rnd);
}
// \brief returns a random non-null vertex of the polygon mesh `g`.
// \tparam Graph a model of `VertexListGraph`
template<typename Graph>
typename boost::graph_traits<Graph>::vertex_descriptor
random_vertex_in_mesh(const Graph& g, CGAL::Random& rnd = get_default_random())
{
return internal::random_entity_in_range(vertices(g), rnd);
}
// \brief returns a random non-null halfedge of the polygon mesh `g`.
// \tparam Graph a model of `HalfedgeListGraph`
template<typename Graph>
typename boost::graph_traits<Graph>::halfedge_descriptor
random_halfedge_in_mesh(const Graph& g, CGAL::Random& rnd = get_default_random())
{
return internal::random_entity_in_range(halfedges(g), rnd);
}
// \brief returns a random non-null edge of the polygon mesh `g`.
// \tparam Graph a model of `EdgeListGraph`
template<typename Graph>
typename boost::graph_traits<Graph>::edge_descriptor
random_edge_in_mesh(const Graph& g, CGAL::Random& rnd = get_default_random())
{
return internal::random_entity_in_range(edges(g), rnd);
}
// \brief returns a random non-null face of the polygon mesh `g`.
// \tparam Graph a model of `FaceListGraph`
template<typename Graph>
typename boost::graph_traits<Graph>::face_descriptor
random_face_in_mesh(const Graph& g, CGAL::Random& rnd = get_default_random())
{
return internal::random_entity_in_range(faces(g), rnd);
}
} // namespace internal
/**
* \ingroup PkgBGLHelperFct
*
* \brief Creates an isolated triangle
* with its vertices initialized to `p0`, `p1` and `p2`, and adds it to the graph `g`.
*
* \returns the non-border halfedge that has the target vertex associated with `p0`.
**/
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_triangle(const P& p0, const P& p1, const P& p2, Graph& g)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::face_descriptor face_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
halfedge_descriptor h0 = halfedge(add_edge(g), g);
halfedge_descriptor h1 = halfedge(add_edge(g), g);
halfedge_descriptor h2 = halfedge(add_edge(g), g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v0, h2, g);
face_descriptor f = add_face(g);
set_face(h0, f, g);
set_face(h1, f, g);
set_face(h2, f, g);
set_halfedge(f, h0, g);
h0 = opposite(h0, g);
h1 = opposite(h1, g);
h2 = opposite(h2, g);
set_next(h0, h2, g);
set_next(h2, h1, g);
set_next(h1, h0, g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
set_face(h0, boost::graph_traits<Graph>::null_face(), g);
set_face(h1, boost::graph_traits<Graph>::null_face(), g);
set_face(h2, boost::graph_traits<Graph>::null_face(), g);
return opposite(h2, g);
}
namespace internal {
template<typename Graph>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_quad(typename boost::graph_traits<Graph>::vertex_descriptor v0,
typename boost::graph_traits<Graph>::vertex_descriptor v1,
typename boost::graph_traits<Graph>::vertex_descriptor v2,
typename boost::graph_traits<Graph>::vertex_descriptor v3,
Graph& g)
{
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
halfedge_descriptor h0 = halfedge(add_edge(g), g);
halfedge_descriptor h1 = halfedge(add_edge(g), g);
halfedge_descriptor h2 = halfedge(add_edge(g), g);
halfedge_descriptor h3 = halfedge(add_edge(g), g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h3, g);
set_next(h3, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v3, g);
set_target(h3, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v3, h2, g);
set_halfedge(v0, h3, g);
face_descriptor f = add_face(g);
set_face(h0, f, g);
set_face(h1, f, g);
set_face(h2, f, g);
set_face(h3, f, g);
set_halfedge(f, h0, g);
h0 = opposite(h0, g);
h1 = opposite(h1, g);
h2 = opposite(h2, g);
h3 = opposite(h3, g);
set_next(h0, h3, g);
set_next(h3, h2, g);
set_next(h2, h1, g);
set_next(h1, h0, g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
set_target(h3, v3, g);
set_face(h0, boost::graph_traits<Graph>::null_face(), g);
set_face(h1, boost::graph_traits<Graph>::null_face(), g);
set_face(h2, boost::graph_traits<Graph>::null_face(), g);
set_face(h3, boost::graph_traits<Graph>::null_face(), g);
return opposite(h3, g);
}
// default Functor for make_grid
template<typename Size_type, typename Point>
struct Default_grid_maker
: public CGAL::Creator_uniform_3<Size_type, Point>
{
Point operator()(const Size_type& i, const Size_type& j) const {
return CGAL::Creator_uniform_3<Size_type, Point>::operator ()(i,j,0);
}
};
} // namespace internal
/**
* \ingroup PkgBGLHelperFct
*
* \brief Creates an isolated quad with
* its vertices initialized to `p0`, `p1`, `p2`, and `p3`, and adds it to the graph `g`.
*
* \returns the non-border halfedge that has the target vertex associated with `p0`.
**/
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_quad(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
v3 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
ppmap[v3] = p3;
return internal::make_quad(v0, v1, v2, v3, g);
}
/**
* \ingroup PkgBGLHelperFct
* \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`.
**/
template<typename Graph, typename P>
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)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3, v4, v5, v6, v7;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
v3 = add_vertex(g);
v4 = add_vertex(g);
v5 = add_vertex(g);
v6 = add_vertex(g);
v7 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
ppmap[v3] = p3;
ppmap[v4] = p4;
ppmap[v5] = p5;
ppmap[v6] = p6;
ppmap[v7] = p7;
halfedge_descriptor ht = internal::make_quad(v4, v5, v6, v7, g);
halfedge_descriptor hb = prev(internal::make_quad(v0, v3, v2, v1, g), g);
for(int i=0; i <4; ++i)
{
halfedge_descriptor h = halfedge(add_edge(g), g);
set_target(h,target(hb, g), g);
set_next(h, opposite(hb, g), g);
set_next(opposite(prev(ht, g), g), h, g);
h = opposite(h, g);
set_target(h, source(prev(ht, g), g), g);
set_next(h, opposite(next(next(ht, g), g), g), g);
set_next(opposite(next(hb, g), g), h, g);
hb = next(hb, g);
ht = prev(ht, g);
}
for(int i=0; i <4; ++i)
{
Euler::fill_hole(opposite(hb, g), g);
hb = next(hb, g);
}
return next(next(hb, g), g);
}
/**
* \ingroup PkgBGLHelperFct
* \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
* \image latex tetrahedron.png
* \returns the halfedge that has the target vertex associated with `p0`, in the face with the vertices with the points `p0`, `p1`, and `p2`.
**/
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_tetrahedron(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename Traits::face_descriptor face_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3;
v0 = add_vertex(g);
v2 = add_vertex(g); // this and the next line are switched to keep points in order
v1 = add_vertex(g);
v3 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p2;// this and the next line are switched to reorient the surface
ppmap[v2] = p1;
ppmap[v3] = p3;
halfedge_descriptor h0 = halfedge(add_edge(g), g);
halfedge_descriptor h1 = halfedge(add_edge(g), g);
halfedge_descriptor h2 = halfedge(add_edge(g), g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v0, h2, g);
face_descriptor f = add_face(g);
set_face(h0, f, g);
set_face(h1, f, g);
set_face(h2, f, g);
set_halfedge(f, h0, g);
h0 = opposite(h0, g);
h1 = opposite(h1, g);
h2 = opposite(h2, g);
set_next(h0, h2, g);
set_next(h2, h1, g);
set_next(h1, h0, g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
halfedge_descriptor h3 = halfedge(add_edge(g), g);
halfedge_descriptor h4 = halfedge(add_edge(g), g);
halfedge_descriptor h5 = halfedge(add_edge(g), g);
set_target(h3, v3, g);
set_target(h4, v3, g);
set_target(h5, v3, g);
set_halfedge(v3, h3, g);
set_next(h0, h3, g);
set_next(h1, h4, g);
set_next(h2, h5, g);
set_next(h3, opposite(h4, g), g);
set_next(h4, opposite(h5, g), g);
set_next(h5, opposite(h3, g), g);
set_next(opposite(h4, g), h0, g);
set_next(opposite(h5, g), h1, g);
set_next(opposite(h3, g), h2, g);
set_target(opposite(h3, g), v0, g);
set_target(opposite(h4, g), v1, g);
set_target(opposite(h5, g), v2, g);
f = add_face(g);
set_halfedge(f, h0, g);
set_face(h0, f, g);
set_face(h3, f, g);
set_face(opposite(h4, g), f, g);
f = add_face(g);
set_halfedge(f, h1, g);
set_face(h1, f, g);
set_face(h4, f, g);
set_face(opposite(h5, g), f, g);
f = add_face(g);
set_halfedge(f, h2, g);
set_face(h2, f, g);
set_face(h5, f, g);
set_face(opposite(h3, g), f, g);
return opposite(h2, g);
}
/**
* \ingroup PkgBGLHelperFct
*
* \brief Creates a triangulated regular prism, outward oriented,
* having `nb_vertices` vertices in each of its bases and adds it to the graph `g`.
* If `center` is (0, 0, 0), then the first point of the prism is (`radius`, `height`, 0)
*
* \param nb_vertices the number of vertices per base. It must be greater than or equal to 3.
* \param g the graph in which the regular prism will be created.
* \param base_center the center of the circle in which the lower base is inscribed.
* \param height the distance between the two bases.
* \param radius the radius of the circles in which the bases are inscribed.
* \param is_closed determines if the bases must be created or not. If `is_closed` is `true`, `center` is a vertex.
*
* \returns the halfedge that has the target vertex associated with the first point in the first face.
*/
template<class Graph, class P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_regular_prism(typename boost::graph_traits<Graph>::vertices_size_type nb_vertices,
Graph& g,
const P& base_center = P(0,0,0),
typename CGAL::Kernel_traits<P>::Kernel::FT height = 1.0,
typename CGAL::Kernel_traits<P>::Kernel::FT radius = 1.0,
bool is_closed = true)
{
CGAL_assertion(nb_vertices >= 3);
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename CGAL::Kernel_traits<P>::Kernel::FT FT;
typedef typename boost::property_map<Graph, vertex_point_t>::type Point_property_map;
Point_property_map vpmap = get(CGAL::vertex_point, g);
const FT to_rad = CGAL_PI / 180.0;
const FT precision = 360.0 / nb_vertices;
const FT diameter = 2 * radius;
std::vector<vertex_descriptor> vertices;
vertices.resize(nb_vertices*2);
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices*2; ++i)
vertices[i] = add_vertex(g);
//fill vertices
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i < nb_vertices; ++i)
{
put(vpmap, vertices[i],
P(0.5*diameter * cos(i*precision*to_rad) + base_center.x(),
height+base_center.y(),
-0.5*diameter * sin(i*precision*to_rad) + base_center.z()));
put(vpmap,
vertices[i+nb_vertices],
P(0.5*diameter * cos(i*precision*to_rad) + base_center.x(),
base_center.y(),
-0.5*diameter * sin(i*precision*to_rad) + base_center.z()));
}
//fill faces
std::vector<vertex_descriptor> face;
face.resize(3);
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
face[0] = vertices[(i+1)%(nb_vertices)];
face[1] = vertices[i];
face[2] = vertices[(i+1)%(nb_vertices) + nb_vertices];
Euler::add_face(face, g);
face[0] = vertices[(i+1)%(nb_vertices) + nb_vertices];
face[1] = vertices[i];
face[2] = vertices[i + nb_vertices];
Euler::add_face(face, g);
}
//close
if(is_closed)
{
//add the base_center of the fans
vertex_descriptor top = add_vertex(g);
vertex_descriptor bot = add_vertex(g);
put(vpmap, top, P(base_center.x(), height+base_center.y(),base_center.z()));
put(vpmap, bot, P(base_center.x(),base_center.y(),base_center.z()));
//add the faces
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
face[0] = vertices[i];
face[1] = vertices[(i+1)%(nb_vertices)];
face[2] = top;
Euler::add_face(face, g);
face[0] = bot;
face[1] = vertices[(i+1)%(nb_vertices) + nb_vertices];
face[2] = vertices[i + nb_vertices];
Euler::add_face(face, g);
}
}
return halfedge(vertices[0], vertices[1], g).first;
}
/**
* \ingroup PkgBGLHelperFct
* \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)`
*
* \param nb_vertices the number of vertices in the base. It must be greater than or equal to 3.
* \param g the graph in which the pyramid will be created
* \param base_center the center of the circle in which the base is inscribed.
* \param height the distance between the base and the apex.
* \param radius the radius of the circle in which the base is inscribed.
* \param is_closed determines if the base must be created or not. If `is_closed` is `true`, `center` is a vertex.
*
* \returns the halfedge that has the target vertex associated with the apex point in the first face.
*/
template<class Graph, class P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_pyramid(typename boost::graph_traits<Graph>::vertices_size_type nb_vertices,
Graph& g,
const P& base_center = P(0,0,0),
typename CGAL::Kernel_traits<P>::Kernel::FT height = 1.0,
typename CGAL::Kernel_traits<P>::Kernel::FT radius = 1.0,
bool is_closed = true)
{
CGAL_assertion(nb_vertices >= 3);
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename CGAL::Kernel_traits<P>::Kernel::FT FT;
const FT to_rad = CGAL_PI / 180.0;
const FT precision = 360.0/nb_vertices;
const FT diameter = 2*radius;
Point_property_map vpmap = get(CGAL::vertex_point, g);
std::vector<vertex_descriptor> vertices;
vertices.resize(nb_vertices);
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
vertices[i] = add_vertex(g);
vertex_descriptor apex = add_vertex(g);
//fill vertices
put(vpmap, apex,
P(base_center.x(),
base_center.y() + height,
base_center.z()));
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
put(vpmap, vertices[i],
P(0.5*diameter*cos(i*precision*to_rad)+base_center.x(),
base_center.y(),
-0.5*diameter*sin(i*precision*to_rad)+base_center.z()));
}
//fill faces
std::vector<vertex_descriptor> face;
face.resize(3);
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
face[0] = apex;
face[1] = vertices[i];
face[2] = vertices[(i+1)%(nb_vertices)];
Euler::add_face(face, g);
}
//close
if(is_closed)
{
//add the center of the fan
vertex_descriptor bot = add_vertex(g);
put(vpmap, bot, P(base_center.x(),base_center.y(),base_center.z()));
//add the faces
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
face[0] = bot;
face[1] = vertices[(i+1)%(nb_vertices)];
face[2] = vertices[i];
Euler::add_face(face, g);
}
}
return halfedge(vertices[0], apex, g).first;
}
/**
* \ingroup PkgBGLHelperFct
*
* \brief Creates an icosahedron, outward oriented, centered in `center` and adds it to the graph `g`.
*
* \param g the graph in which the icosahedron will be created.
* \param center the center of the sphere in which the icosahedron is inscribed.
* \param radius the radius of the sphere in which the icosahedron is inscribed.
*
* \returns the halfedge that has the target vertex associated with the first point in the first face.
*/
template<class Graph, class P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_icosahedron(Graph& g,
const P& center = P(0,0,0),
typename CGAL::Kernel_traits<P>::Kernel::FT radius = 1.0)
{
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
Point_property_map vpmap = get(CGAL::vertex_point, g);
// create the initial icosahedron
std::vector<vertex_descriptor> v_vertices;
v_vertices.resize(12);
for(int i=0; i<12; ++i)
v_vertices[i] = add_vertex(g);
typename CGAL::Kernel_traits<P>::Kernel::FT t = radius * (1.0 + CGAL::approximate_sqrt(5.0)) / 2.0;
put(vpmap, v_vertices[0], P(-radius + center.x(), t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[1], P( radius + center.x(), t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[2], P(-radius + center.x(), -t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[3], P( radius + center.x(), -t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[4], P( 0.0 + center.x(), -radius + center.y(), t + center.z()));
put(vpmap, v_vertices[5], P( 0.0 + center.x(), radius + center.y(), t + center.z()));
put(vpmap, v_vertices[6], P( 0.0 + center.x(), -radius + center.y(), -t + center.z()));
put(vpmap, v_vertices[7], P( 0.0 + center.x(), radius + center.y(), -t + center.z()));
put(vpmap, v_vertices[8], P( t + center.x(), 0.0 + center.y(), -radius + center.z()));
put(vpmap, v_vertices[9], P( t + center.x(), 0.0 + center.y(), radius + center.z()));
put(vpmap, v_vertices[10], P(-t + center.x(), 0.0 + center.y(), -radius + center.z()));
put(vpmap, v_vertices[11], P(-t + center.x(), 0.0 + center.y(), radius + center.z()));
std::vector<vertex_descriptor> face;
face.resize(3);
face[1] = v_vertices[0]; face[0] = v_vertices[5]; face[2] = v_vertices[11];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[1]; face[2] = v_vertices[5];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[7]; face[2] = v_vertices[1];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[10]; face[2] = v_vertices[7];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[11]; face[2] = v_vertices[10];
Euler::add_face(face, g);
face[1] = v_vertices[1]; face[0] = v_vertices[9]; face[2] = v_vertices[5];
Euler::add_face(face, g);
face[1] = v_vertices[5]; face[0] = v_vertices[4]; face[2] = v_vertices[11];
Euler::add_face(face, g);
face[1] = v_vertices[11]; face[0] = v_vertices[2]; face[2] = v_vertices[10];
Euler::add_face(face, g);
face[1] = v_vertices[10]; face[0] = v_vertices[6]; face[2] = v_vertices[7];
Euler::add_face(face, g);
face[1] = v_vertices[7]; face[0] = v_vertices[8]; face[2] = v_vertices[1];
Euler::add_face(face, g);
face[1] = v_vertices[3]; face[0] = v_vertices[4]; face[2] = v_vertices[9];
Euler::add_face(face, g);
face[1] = v_vertices[3]; face[0] = v_vertices[2]; face[2] = v_vertices[4];
Euler::add_face(face, g);
face[1] = v_vertices[3]; face[0] = v_vertices[6]; face[2] = v_vertices[2];
Euler::add_face(face, g);
face[1] = v_vertices[3]; face[0] = v_vertices[8]; face[2] = v_vertices[6];
Euler::add_face(face, g);
face[1] = v_vertices[3]; face[0] = v_vertices[9]; face[2] = v_vertices[8];
Euler::add_face(face, g);
face[1] = v_vertices[4]; face[0] = v_vertices[5]; face[2] = v_vertices[9];
Euler::add_face(face, g);
face[1] = v_vertices[2]; face[0] = v_vertices[11]; face[2] = v_vertices[4];
Euler::add_face(face, g);
face[1] = v_vertices[6]; face[0] = v_vertices[10]; face[2] = v_vertices[2];
Euler::add_face(face, g);
face[1] = v_vertices[8]; face[0] = v_vertices[7]; face[2] = v_vertices[6];
Euler::add_face(face, g);
face[1] = v_vertices[9]; face[0] = v_vertices[1]; face[2] = v_vertices[8];
Euler::add_face(face, g);
return halfedge(v_vertices[1], v_vertices[0], g).first;
}
/*!
* \ingroup PkgBGLHelperFct
*
* \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`.
* An internal property map for `CGAL::vertex_point_t` must be available in `Graph`.
*
* \param i the number of cells along the width.
* \param j the number of cells along the height.
* \param g the graph in which the grid will be created.
* \param calculator the functor that will assign coordinates to the grid vertices.
* \param triangulated decides if a cell is composed of one quad or two triangles.
* If `triangulated` is `true`, the diagonal of each cell is oriented from (0,0) to (1,1)
* in the cell coordinates.
*
*\tparam CoordinateFunctor a function object providing `Point_3 operator()(size_type I, size_type J)` with `Point_3` being
* the value_type of the internal property_map for `CGAL::vertex_point_t`.
* and outputs a `boost::property_traits<boost::property_map<Graph,CGAL::vertex_point_t>::%type>::%value_type`.
* It will be called with arguments (`w`, `h`), with `w` in [0..`i`] and `h` in [0..`j`].
* <p>%Default: a point with positive integer coordinates (`w`, `h`, 0), with `w` in [0..`i`] and `h` in [0..`j`]
*
* \returns the non-border non-diagonal halfedge that has the target vertex associated with the first point of the grid (default is (0,0,0) ).
*/
template<class Graph, class CoordinateFunctor>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_grid(typename boost::graph_traits<Graph>::vertices_size_type i,
typename boost::graph_traits<Graph>::vertices_size_type j,
Graph& g,
const CoordinateFunctor& calculator,
bool triangulated = false)
{
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typename boost::graph_traits<Graph>::vertices_size_type w(i+1), h(j+1);
Point_property_map vpmap = get(CGAL::vertex_point, g);
//create the vertices
std::vector<vertex_descriptor> v_vertices;
v_vertices.resize(static_cast<std::size_t>(w*h));
for(std::size_t k = 0; k < v_vertices.size(); ++k)
v_vertices[k] = add_vertex(g);
//assign the coordinates
for(typename boost::graph_traits<Graph>::vertices_size_type a=0; a<w; ++a)
for(typename boost::graph_traits<Graph>::vertices_size_type b=0; b<h; ++b)
put(vpmap, v_vertices[a+w*b], calculator(a,b));
//create the faces
std::vector<vertex_descriptor> face;
if(triangulated)
face.resize(3);
else
face.resize(4);
for(typename boost::graph_traits<Graph>::vertices_size_type a = 0; a<w-1; ++a)
{
for(typename boost::graph_traits<Graph>::vertices_size_type b = 0; b<h-1; ++b)
{
if(triangulated)
{
face[0] = v_vertices[w*b+a];
face[1] = v_vertices[w*b+a+1];
face[2] = v_vertices[w*(b+1)+a];
Euler::add_face(face, g);
face[0] = v_vertices[w*b+a+1];
face[1] = v_vertices[w*(b+1)+a+1];
face[2] = v_vertices[w*(b+1)+a];
Euler::add_face(face, g);
}
else
{
face[0] = v_vertices[w*b+ a];
face[1] = v_vertices[w*b+ a+1];
face[2] = v_vertices[w*(b+1)+ a+1];
face[3] = v_vertices[w*(b+1)+ a];
Euler::add_face(face, g);
}
}
}
return halfedge(v_vertices[1], v_vertices[0], g).first;
}
template<class Graph>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_grid(typename boost::graph_traits<Graph>::vertices_size_type w,
typename boost::graph_traits<Graph>::vertices_size_type h,
Graph& g,
bool triangulated = false)
{
typedef typename boost::graph_traits<Graph>::vertices_size_type Size_type;
typedef typename boost::property_traits<typename boost::property_map<Graph, vertex_point_t>::type>::value_type Point;
return make_grid(w, h, g, internal::Default_grid_maker<Size_type, Point>(), triangulated);
}
} // 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/Euler_operations.h>
#endif // CGAL_BOOST_GRAPH_GENERATORS_H

View File

@ -21,29 +21,16 @@
#ifndef CGAL_BOOST_GRAPH_HELPERS_H
#define CGAL_BOOST_GRAPH_HELPERS_H
#include <boost/range/empty.hpp>
#include <CGAL/boost/graph/iterator.h>
#include <CGAL/boost/graph/properties.h>
#include <CGAL/boost/graph/internal/Has_member_clear.h>
#include <CGAL/function_objects.h>
#include <boost/unordered_set.hpp>
#include <CGAL/IO/Verbose_ostream.h>
#include <boost/range/empty.hpp>
namespace CGAL {
namespace Euler {
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);
}//Euler
/*!
\ingroup PkgBGLHelperFct
returns `true` if the halfedge `hd` is on a border.
@ -756,674 +743,6 @@ bool is_hexahedron( typename boost::graph_traits<FaceGraph>::halfedge_descriptor
return true;
}
/**
* \ingroup PkgBGLHelperFct
* \brief Creates an isolated triangle
* with its vertices initialized to `p0`, `p1` and `p2`, and adds it to the graph `g`.
* \returns the non-border halfedge that has the target vertex associated with `p0`.
**/
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_triangle(const P& p0, const P& p1, const P& p2, Graph& g)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename Traits::face_descriptor face_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
halfedge_descriptor h0 = halfedge(add_edge(g),g);
halfedge_descriptor h1 = halfedge(add_edge(g),g);
halfedge_descriptor h2 = halfedge(add_edge(g),g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v0, h2, g);
face_descriptor f = add_face(g);
set_face(h0,f,g);
set_face(h1,f,g);
set_face(h2,f,g);
set_halfedge(f,h0,g);
h0 = opposite(h0,g);
h1 = opposite(h1,g);
h2 = opposite(h2,g);
set_next(h0, h2, g);
set_next(h2, h1, g);
set_next(h1, h0, g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
set_face(h0, boost::graph_traits<Graph>::null_face(),g);
set_face(h1, boost::graph_traits<Graph>::null_face(),g);
set_face(h2, boost::graph_traits<Graph>::null_face(),g);
return opposite(h2,g);
}
namespace internal {
template<typename Graph>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_quad(typename boost::graph_traits<Graph>::vertex_descriptor v0,
typename boost::graph_traits<Graph>::vertex_descriptor v1,
typename boost::graph_traits<Graph>::vertex_descriptor v2,
typename boost::graph_traits<Graph>::vertex_descriptor v3, Graph& g)
{
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
halfedge_descriptor h0 = halfedge(add_edge(g),g);
halfedge_descriptor h1 = halfedge(add_edge(g),g);
halfedge_descriptor h2 = halfedge(add_edge(g),g);
halfedge_descriptor h3 = halfedge(add_edge(g),g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h3, g);
set_next(h3, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v3, g);
set_target(h3, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v3, h2, g);
set_halfedge(v0, h3, g);
face_descriptor f = add_face(g);
set_face(h0,f,g);
set_face(h1,f,g);
set_face(h2,f,g);
set_face(h3,f,g);
set_halfedge(f,h0,g);
h0 = opposite(h0,g);
h1 = opposite(h1,g);
h2 = opposite(h2,g);
h3 = opposite(h3,g);
set_next(h0, h3, g);
set_next(h3, h2, g);
set_next(h2, h1, g);
set_next(h1, h0, g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
set_target(h3, v3, g);
set_face(h0, boost::graph_traits<Graph>::null_face(),g);
set_face(h1, boost::graph_traits<Graph>::null_face(),g);
set_face(h2, boost::graph_traits<Graph>::null_face(),g);
set_face(h3, boost::graph_traits<Graph>::null_face(),g);
return opposite(h3,g);
}
//default Functor for make_grid
template<typename Size_type, typename Point>
struct Default_grid_maker
: public CGAL::Creator_uniform_3<Size_type, Point>
{
Point operator()(const Size_type& i, const Size_type& j)const
{
return CGAL::Creator_uniform_3<Size_type, Point>::operator ()(i,j,0);
}
};
} // namespace internal
/**
* \ingroup PkgBGLHelperFct
* \brief Creates an isolated quad with
* its vertices initialized to `p0`, `p1`, `p2`, and `p3`, and adds it to the graph `g`.
* \returns the non-border halfedge that has the target vertex associated with `p0`.
**/
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_quad(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
v3 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
ppmap[v3] = p3;
return internal::make_quad(v0, v1, v2, v3, g);
}
/**
* \ingroup PkgBGLHelperFct
* \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`.
**/
template<typename Graph, typename P>
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)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3, v4, v5, v6, v7;
v0 = add_vertex(g);
v1 = add_vertex(g);
v2 = add_vertex(g);
v3 = add_vertex(g);
v4 = add_vertex(g);
v5 = add_vertex(g);
v6 = add_vertex(g);
v7 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p1;
ppmap[v2] = p2;
ppmap[v3] = p3;
ppmap[v4] = p4;
ppmap[v5] = p5;
ppmap[v6] = p6;
ppmap[v7] = p7;
halfedge_descriptor ht = internal::make_quad(v4, v5, v6, v7, g);
halfedge_descriptor hb = prev(internal::make_quad(v0, v3, v2, v1, g),g);
for(int i=0; i <4; i++){
halfedge_descriptor h = halfedge(add_edge(g),g);
set_target(h,target(hb,g),g);
set_next(h,opposite(hb,g),g);
set_next(opposite(prev(ht,g),g),h,g);
h = opposite(h,g);
set_target(h,source(prev(ht,g),g),g);
set_next(h,opposite(next(next(ht,g),g),g),g);
set_next(opposite(next(hb,g),g),h,g);
hb = next(hb,g);
ht = prev(ht,g);
}
for(int i=0; i <4; i++){
Euler::fill_hole(opposite(hb,g),g);
hb = next(hb,g);
}
return next(next(hb,g),g);
}
/**
* \ingroup PkgBGLHelperFct
* \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
* \image latex tetrahedron.png
* \returns the halfedge that has the target vertex associated with `p0`, in the face with the vertices with the points `p0`, `p1`, and `p2`.
**/
template<typename Graph, typename P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_tetrahedron(const P& p0, const P& p1, const P& p2, const P& p3, Graph& g)
{
typedef typename boost::graph_traits<Graph> Traits;
typedef typename Traits::halfedge_descriptor halfedge_descriptor;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename Traits::face_descriptor face_descriptor;
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
Point_property_map ppmap = get(CGAL::vertex_point, g);
vertex_descriptor v0, v1, v2, v3;
v0 = add_vertex(g);
v2 = add_vertex(g); // this and the next line are switched to keep points in order
v1 = add_vertex(g);
v3 = add_vertex(g);
ppmap[v0] = p0;
ppmap[v1] = p2;// this and the next line are switched to reorient the surface
ppmap[v2] = p1;
ppmap[v3] = p3;
halfedge_descriptor h0 = halfedge(add_edge(g),g);
halfedge_descriptor h1 = halfedge(add_edge(g),g);
halfedge_descriptor h2 = halfedge(add_edge(g),g);
set_next(h0, h1, g);
set_next(h1, h2, g);
set_next(h2, h0, g);
set_target(h0, v1, g);
set_target(h1, v2, g);
set_target(h2, v0, g);
set_halfedge(v1, h0, g);
set_halfedge(v2, h1, g);
set_halfedge(v0, h2, g);
face_descriptor f = add_face(g);
set_face(h0,f,g);
set_face(h1,f,g);
set_face(h2,f,g);
set_halfedge(f,h0,g);
h0 = opposite(h0,g);
h1 = opposite(h1,g);
h2 = opposite(h2,g);
set_next(h0, h2, g);
set_next(h2, h1, g);
set_next(h1, h0, g);
set_target(h0, v0, g);
set_target(h1, v1, g);
set_target(h2, v2, g);
halfedge_descriptor h3 = halfedge(add_edge(g),g);
halfedge_descriptor h4 = halfedge(add_edge(g),g);
halfedge_descriptor h5 = halfedge(add_edge(g),g);
set_target(h3, v3, g);
set_target(h4, v3, g);
set_target(h5, v3, g);
set_halfedge(v3, h3, g);
set_next(h0, h3, g);
set_next(h1, h4, g);
set_next(h2, h5, g);
set_next(h3, opposite(h4,g), g);
set_next(h4, opposite(h5,g), g);
set_next(h5, opposite(h3,g), g);
set_next(opposite(h4,g), h0, g);
set_next(opposite(h5,g), h1, g);
set_next(opposite(h3,g), h2, g);
set_target(opposite(h3,g), v0, g);
set_target(opposite(h4,g), v1, g);
set_target(opposite(h5,g), v2, g);
f = add_face(g);
set_halfedge(f,h0,g);
set_face(h0, f, g);
set_face(h3, f, g);
set_face(opposite(h4,g), f, g);
f = add_face(g);
set_halfedge(f,h1,g);
set_face(h1, f, g);
set_face(h4, f, g);
set_face(opposite(h5,g), f, g);
f = add_face(g);
set_halfedge(f,h2,g);
set_face(h2, f, g);
set_face(h5, f, g);
set_face(opposite(h3,g), f, g);
return opposite(h2,g);
}
/**
* \ingroup PkgBGLHelperFct
* \brief Creates a triangulated regular prism, outward oriented,
* having `nb_vertices` vertices in each of its bases and adds it to the graph `g`.
* If `center` is (0, 0, 0), then the first point of the prism is (`radius`, `height`, 0)
* \param nb_vertices the number of vertices per base. It must be greater than or equal to 3.
* \param g the graph in which the regular prism will be created.
* \param base_center the center of the circle in which the lower base is inscribed.
* \param height the distance between the two bases.
* \param radius the radius of the circles in which the bases are inscribed.
* \param is_closed determines if the bases must be created or not. If `is_closed` is `true`, `center` is a vertex.
* \returns the halfedge that has the target vertex associated with the first point in the first face.
*/
template<class Graph, class P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_regular_prism(
typename boost::graph_traits<Graph>::vertices_size_type nb_vertices,
Graph& g,
const P& base_center = P(0,0,0),
typename CGAL::Kernel_traits<P>::Kernel::FT height = 1.0,
typename CGAL::Kernel_traits<P>::Kernel::FT radius = 1.0,
bool is_closed = true)
{
CGAL_assertion(nb_vertices >= 3);
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename CGAL::Kernel_traits<P>::Kernel::FT FT;
const FT to_rad = CGAL_PI / 180.0;
const FT precision = 360.0/nb_vertices;
const FT diameter = 2*radius;
Point_property_map vpmap = get(CGAL::vertex_point, g);
std::vector<vertex_descriptor> vertices;
vertices.resize(nb_vertices*2);
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices*2; ++i)
vertices[i] = add_vertex(g);
//fill vertices
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i < nb_vertices; ++i)
{
put(vpmap,
vertices[i],
P(0.5*diameter*cos(i*precision*to_rad)+base_center.x(),
height+base_center.y(),
-0.5*diameter*sin(i*precision*to_rad) + base_center.z()));
put(vpmap,
vertices[i+nb_vertices],
P(0.5*diameter*cos(i*precision*to_rad)+base_center.x(),
base_center.y(),
-0.5*diameter*sin(i*precision*to_rad)+base_center.z()));
}
std::vector<vertex_descriptor> face;
face.resize(3);
//fill faces
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
face[0] = vertices[(i+1)%(nb_vertices)];
face[1] = vertices[i];
face[2] = vertices[(i+1)%(nb_vertices) + nb_vertices];
Euler::add_face(face, g);
face[0] = vertices[(i+1)%(nb_vertices) + nb_vertices];
face[1] = vertices[i];
face[2] = vertices[i + nb_vertices];
Euler::add_face(face, g);
}
//close
if(is_closed)
{
//add the base_center of the fans
vertex_descriptor top = add_vertex(g);
vertex_descriptor bot = add_vertex(g);
put(vpmap, top, P(base_center.x(),height+base_center.y(),base_center.z()));
put(vpmap, bot, P(base_center.x(),base_center.y(),base_center.z()));
//add the faces
for(typename boost::graph_traits<Graph>::vertices_size_type i=0; i<nb_vertices; ++i)
{
face[0] = vertices[i];
face[1] = vertices[(i+1)%(nb_vertices)];
face[2] = top;
Euler::add_face(face, g);
face[0] = bot;
face[1] = vertices[(i+1)%(nb_vertices) + nb_vertices];
face[2] = vertices[i + nb_vertices];
Euler::add_face(face, g);
}
}
return halfedge(vertices[0], vertices[1], g).first;
}
/**
* \ingroup PkgBGLHelperFct
* \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)`
* \param nb_vertices the number of vertices in the base. It must be greater than or equal to 3.
* \param g the graph in which the pyramid will be created
* \param base_center the center of the circle in which the base is inscribed.
* \param height the distance between the base and the apex.
* \param radius the radius of the circle in which the base is inscribed.
* \param is_closed determines if the base must be created or not. If `is_closed` is `true`, `center` is a vertex.
* \returns the halfedge that has the target vertex associated with the apex point in the first face.
*/
template<class Graph, class P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_pyramid(
typename boost::graph_traits<Graph>::vertices_size_type nb_vertices,
Graph& g,
const P& base_center = P(0,0,0),
typename CGAL::Kernel_traits<P>::Kernel::FT height = 1.0,
typename CGAL::Kernel_traits<P>::Kernel::FT radius = 1.0,
bool is_closed = true)
{
CGAL_assertion(nb_vertices >= 3);
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typedef typename CGAL::Kernel_traits<P>::Kernel::FT FT;
const FT to_rad = CGAL_PI / 180.0;
const FT precision = 360.0/nb_vertices;
const FT diameter = 2*radius;
Point_property_map vpmap = get(CGAL::vertex_point, g);
std::vector<vertex_descriptor> vertices;
vertices.resize(nb_vertices);
for(typename boost::graph_traits<Graph>::vertices_size_type i=0;
i<nb_vertices; ++i)
vertices[i] = add_vertex(g);
vertex_descriptor apex = add_vertex(g);
//fill vertices
put(vpmap,
apex,
P(base_center.x(),
base_center.y() + height,
base_center.z()));
for(typename boost::graph_traits<Graph>::vertices_size_type i=0;
i < nb_vertices; ++i)
{
put(vpmap,
vertices[i],
P(0.5*diameter*cos(i*precision*to_rad)+base_center.x(),
base_center.y(),
-0.5*diameter*sin(i*precision*to_rad)+base_center.z()));
}
std::vector<vertex_descriptor> face;
face.resize(3);
//fill faces
for(typename boost::graph_traits<Graph>::vertices_size_type i=0;
i<nb_vertices; ++i)
{
face[0] = apex;
face[1] = vertices[i];
face[2] = vertices[(i+1)%(nb_vertices)];
Euler::add_face(face, g);
}
//close
if(is_closed)
{
//add the center of the fan
vertex_descriptor bot = add_vertex(g);
put(vpmap, bot, P(base_center.x(),base_center.y(),base_center.z()));
//add the faces
for(typename boost::graph_traits<Graph>::vertices_size_type i=0;
i<nb_vertices; ++i)
{
face[0] = bot;
face[1] = vertices[(i+1)%(nb_vertices)];
face[2] = vertices[i];
Euler::add_face(face, g);
}
}
return halfedge(vertices[0], apex, g).first;
}
/**
* \ingroup PkgBGLHelperFct
* \brief Creates an icosahedron, outward oriented, centered in `center` and adds it to the graph `g`.
* \param g the graph in which the icosahedron will be created.
* \param center the center of the sphere in which the icosahedron is inscribed.
* \param radius the radius of the sphere in which the icosahedron is inscribed.
* \returns the halfedge that has the target vertex associated with the first point in the first face.
*/
template<class Graph, class P>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_icosahedron(
Graph& g,
const P& center = P(0,0,0),
typename CGAL::Kernel_traits<P>::Kernel::FT radius = 1.0)
{
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
Point_property_map vpmap = get(CGAL::vertex_point, g);
// create the initial icosahedron
std::vector<vertex_descriptor> v_vertices;
v_vertices.resize(12);
for(int i=0; i<12; ++i)
v_vertices[i] = add_vertex(g);
typename CGAL::Kernel_traits<P>::Kernel::FT t =
(radius + radius*CGAL::approximate_sqrt(5.0)) / 2.0;
put(vpmap, v_vertices[0],P(-radius + center.x(), t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[1],P( radius + center.x(), t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[2],P(-radius + center.x(), -t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[3],P( radius + center.x(), -t + center.y(), 0.0 + center.z()));
put(vpmap, v_vertices[4],P( 0.0 + center.x(), -radius + center.y(), t + center.z()));
put(vpmap, v_vertices[5],P( 0.0 + center.x(), radius + center.y(), t + center.z()));
put(vpmap, v_vertices[6],P( 0.0 + center.x(), -radius + center.y(), -t + center.z()));
put(vpmap, v_vertices[7],P( 0.0 + center.x(), radius + center.y(), -t + center.z()));
put(vpmap, v_vertices[8],P( t + center.x(), 0.0 + center.y(), -radius + center.z()));
put(vpmap, v_vertices[9],P( t + center.x(), 0.0 + center.y(), radius + center.z()));
put(vpmap, v_vertices[10],P(-t + center.x(), 0.0 + center.y(), -radius + center.z()));
put(vpmap, v_vertices[11],P(-t + center.x(), 0.0 + center.y(), radius + center.z()));
std::vector<vertex_descriptor> face;
face.resize(3);
face[1] = v_vertices[0]; face[0] = v_vertices[5]; face[2] = v_vertices[11];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[1]; face[2] = v_vertices[5];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[7]; face[2] = v_vertices[1];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[10]; face[2] = v_vertices[7];
Euler::add_face(face, g);
face[1] = v_vertices[0]; face[0] = v_vertices[11]; face[2] = v_vertices[10];
Euler::add_face(face, g);
face[1] = v_vertices[1] ; face[0] = v_vertices[9] ; face[2] = v_vertices[5];
Euler::add_face(face, g);
face[1] = v_vertices[5] ; face[0] = v_vertices[4]; face[2] = v_vertices[11];
Euler::add_face(face, g);
face[1] = v_vertices[11]; face[0] = v_vertices[2]; face[2] = v_vertices[10];
Euler::add_face(face, g);
face[1] = v_vertices[10]; face[0] = v_vertices[6] ; face[2] = v_vertices[7];
Euler::add_face(face, g);
face[1] = v_vertices[7] ; face[0] = v_vertices[8] ; face[2] = v_vertices[1];
Euler::add_face(face, g);
face[1] = v_vertices[3] ; face[0] = v_vertices[4] ; face[2] = v_vertices[9];
Euler::add_face(face, g);
face[1] = v_vertices[3] ; face[0] = v_vertices[2] ; face[2] = v_vertices[4];
Euler::add_face(face, g);
face[1] = v_vertices[3] ; face[0] = v_vertices[6] ; face[2] = v_vertices[2];
Euler::add_face(face, g);
face[1] = v_vertices[3] ; face[0] = v_vertices[8] ; face[2] = v_vertices[6];
Euler::add_face(face, g);
face[1] = v_vertices[3] ; face[0] = v_vertices[9] ; face[2] = v_vertices[8];
Euler::add_face(face, g);
face[1] = v_vertices[4] ; face[0] = v_vertices[5] ; face[2] = v_vertices[9] ;
Euler::add_face(face, g);
face[1] = v_vertices[2] ; face[0] = v_vertices[11] ; face[2] = v_vertices[4];
Euler::add_face(face, g);
face[1] = v_vertices[6] ; face[0] = v_vertices[10] ; face[2] = v_vertices[2];
Euler::add_face(face, g);
face[1] = v_vertices[8] ; face[0] = v_vertices[7] ; face[2] = v_vertices[6] ;
Euler::add_face(face, g);
face[1] = v_vertices[9] ; face[0] = v_vertices[1] ; face[2] = v_vertices[8] ;
Euler::add_face(face, g);
return halfedge(v_vertices[1], v_vertices[0], g).first;
}
/*!
* \ingroup PkgBGLHelperFct
*
* \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`.
* An internal property map for `CGAL::vertex_point_t` must be available in `Graph`.
*
* \param i the number of cells along the width.
* \param j the number of cells along the height.
* \param g the graph in which the grid will be created.
* \param calculator the functor that will assign coordinates to the grid vertices.
* \param triangulated decides if a cell is composed of one quad or two triangles.
* If `triangulated` is `true`, the diagonal of each cell is oriented from (0,0) to (1,1)
* in the cell coordinates.
*\tparam CoordinateFunctor a function object providing `Point_3 operator()(size_type I, size_type J)` with `Point_3` being
* the value_type of the internal property_map for `CGAL::vertex_point_t`.
* and outputs a `boost::property_traits<boost::property_map<Graph,CGAL::vertex_point_t>::%type>::%value_type`.
* It will be called with arguments (`w`, `h`), with `w` in [0..`i`] and `h` in [0..`j`].
* <p>%Default: a point with positive integer coordinates (`w`, `h`, 0), with `w` in [0..`i`] and `h` in [0..`j`]
* \returns the non-border non-diagonal halfedge that has the target vertex associated with the first point of the grid (default is (0,0,0) ).
*/
template<class Graph, class CoordinateFunctor>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_grid(typename boost::graph_traits<Graph>::vertices_size_type i,
typename boost::graph_traits<Graph>::vertices_size_type j,
Graph& g,
const CoordinateFunctor& calculator,
bool triangulated = false)
{
typedef typename boost::property_map<Graph,vertex_point_t>::type Point_property_map;
typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex_descriptor;
typename boost::graph_traits<Graph>::vertices_size_type w(i+1), h(j+1);
Point_property_map vpmap = get(CGAL::vertex_point, g);
//create the vertices
std::vector<vertex_descriptor> v_vertices;
v_vertices.resize(static_cast<std::size_t>(w*h));
for(std::size_t k = 0; k < v_vertices.size(); ++k)
v_vertices[k] = add_vertex(g);
//assign the coordinates
for(typename boost::graph_traits<Graph>::vertices_size_type a = 0; a<w; ++a)
{
for(typename boost::graph_traits<Graph>::vertices_size_type b=0; b<h; ++b)
{
put(vpmap, v_vertices[a+w*b], calculator(a,b));
}
}
//create the faces
std::vector<vertex_descriptor> face;
if(triangulated)
face.resize(3);
else
face.resize(4);
for(typename boost::graph_traits<Graph>::vertices_size_type a = 0; a<w-1; ++a)
{
for(typename boost::graph_traits<Graph>::vertices_size_type b = 0; b<h-1; ++b)
{
if(triangulated)
{
face[0] = v_vertices[w*b+a];
face[1] = v_vertices[w*b+a+1];
face[2] = v_vertices[w*(b+1)+a];
Euler::add_face(face, g);
face[0] = v_vertices[w*b+a+1];
face[1] = v_vertices[w*(b+1)+a+1];
face[2] = v_vertices[w*(b+1)+a];
Euler::add_face(face, g);
}
else
{
face[0] = v_vertices[w*b+ a];
face[1] = v_vertices[w*b+ a+1];
face[2] = v_vertices[w*(b+1)+ a+1];
face[3] = v_vertices[w*(b+1)+ a];
Euler::add_face(face, g);
}
}
}
return halfedge(v_vertices[1], v_vertices[0], g).first;
}
template<class Graph>
typename boost::graph_traits<Graph>::halfedge_descriptor
make_grid(typename boost::graph_traits<Graph>::vertices_size_type w,
typename boost::graph_traits<Graph>::vertices_size_type h,
Graph& g,
bool triangulated = false)
{
typedef typename boost::graph_traits<Graph>::vertices_size_type Size_type;
typedef typename boost::property_traits<typename boost::property_map<Graph, vertex_point_t>::type>::value_type Point;
return make_grid(w, h, g, internal::Default_grid_maker<Size_type, Point>(), triangulated);
}
namespace internal {
template<typename FaceGraph>
@ -1582,10 +901,86 @@ bool is_empty(const FaceGraph& g)
return boost::empty(vertices(g));
}
/// \ingroup PkgBGLHelperFct
///
/// \brief returns the number of calls to `next()` one has to apply to the halfedge `hd`
/// for `source(hd, mesh) == vd` to be true, starting from `hd = halfedge(fd, tm)`.
///
/// \tparam Graph a model of `FaceGraph`
///
/// \param vd a vertex of `g` whose index is sought
/// \param fd a face of `g` in which the index of `vd` is sought
/// \param g a mesh of type `Graph`
///
/// \pre `vd` is a vertex of `fd`.
template <typename Graph>
int vertex_index_in_face(const typename boost::graph_traits<Graph>::vertex_descriptor vd,
const typename boost::graph_traits<Graph>::face_descriptor fd,
const Graph& g)
{
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
halfedge_descriptor start = halfedge(fd, g);
halfedge_descriptor current = start;
int counter = 0;
do
{
if(source(current, g) == vd)
break;
++counter;
current = next(current, g);
}
while(current != start);
if(counter != 0 && current == start)
{
CGAL_assertion_msg(false, "Could not find vertex in face");
return -1;
}
return counter;
}
/// \ingroup PkgBGLHelperFct
///
/// \brief returns the number of calls to `next(hd, tm)` one has to apply to `hd` for `hd == he`
/// to be true, starting from `hd = halfedge(face(he, tm), tm)`.
///
/// \tparam Graph a model of `FaceGraph`.
///
/// \param he a halfedge of `g` whose index in `face(he, tm)` is sought
/// \param g an object of type `Graph`
///
template <typename Graph>
int halfedge_index_in_face(typename boost::graph_traits<Graph>::halfedge_descriptor he,
const Graph& g)
{
typedef typename boost::graph_traits<Graph>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<Graph>::face_descriptor face_descriptor;
CGAL_precondition(he != boost::graph_traits<Graph>::null_halfedge());
CGAL_precondition(!is_border(he, g));
face_descriptor f = face(he, g);
halfedge_descriptor start = halfedge(f, g);
halfedge_descriptor current = start;
int count = 0;
while(current != he)
{
current = next(current, g);
++count;
}
return count;
}
} // namespace CGAL
// Include "Euler_operations.h" at the end, because its implementation
// requires this header.
#include <CGAL/boost/graph/Euler_operations.h>
// 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

View File

@ -83,6 +83,12 @@ CGAL_add_named_parameter(output_iterator_t, output_iterator, output_iterator)
CGAL_add_named_parameter(erase_all_duplicates_t, erase_all_duplicates, erase_all_duplicates)
CGAL_add_named_parameter(require_same_orientation_t, require_same_orientation, require_same_orientation)
CGAL_add_named_parameter(face_size_map_t, face_size_map, face_size_map)
CGAL_add_named_parameter(snapping_tolerance_t, snapping_tolerance, snapping_tolerance)
CGAL_add_named_parameter(use_safety_constraints_t, use_safety_constraints, use_safety_constraints)
CGAL_add_named_parameter(use_angle_smoothing_t, use_angle_smoothing, use_angle_smoothing)
CGAL_add_named_parameter(use_area_smoothing_t, use_area_smoothing, use_area_smoothing)
CGAL_add_named_parameter(use_Delaunay_flips_t, use_Delaunay_flips, use_Delaunay_flips)
CGAL_add_named_parameter(do_project_t, do_project, do_project)
// List of named parameters that we use in the package 'Surface Mesh Simplification'
CGAL_add_named_parameter(get_cost_policy_t, get_cost_policy, get_cost)
@ -91,7 +97,6 @@ CGAL_add_named_parameter(get_placement_policy_t, get_placement_policy, get_place
//to be documented
CGAL_add_named_parameter(face_normal_t, face_normal, face_normal_map)
CGAL_add_named_parameter(random_seed_t, random_seed, random_seed)
CGAL_add_named_parameter(do_project_t, do_project, do_project)
CGAL_add_named_parameter(tolerance_map_t, tolerance_map, tolerance_map)
//internal

View File

@ -18,5 +18,6 @@ Modular_arithmetic
Number_types
Profiling_tools
Property_map
Random_numbers
STL_Extension
Stream_support

View File

@ -1,4 +1,5 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Constrained_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
@ -40,6 +41,8 @@ void concept_check_triangulation()
boost::function_requires< CGAL::HalfedgeListGraphConcept<T> >();
boost::function_requires< CGAL::FaceGraphConcept<T> >();
boost::function_requires< CGAL::FaceListGraphConcept<T> >();
// Triangulations are not mutable graphs
// boost::function_requires< CGAL::MutableHalfedgeGraphConcept<T> >();
// boost::function_requires< CGAL::MutableFaceGraphConcept<T> >();

View File

@ -467,7 +467,7 @@ int main()
//Make a tetrahedron and test the adapter for a patch that only contains 2 faces
typedef CGAL::Face_filtered_graph<SM> SM_Adapter;
typedef SM::Property_map<boost::graph_traits<SM>::face_descriptor , std::size_t> SM_FCCMap;
SM* sm = new SM();
auto sm = std::make_unique<SM>();
CGAL::make_tetrahedron(
Point_3(1,1,1),
Point_3(0,0,0),
@ -499,7 +499,7 @@ int main()
typedef boost::property_map<Polyhedron, CGAL::vertex_external_index_t>::type VIMap;
typedef boost::property_map<Polyhedron, CGAL::halfedge_external_index_t>::type HIMap;
typedef CGAL::Face_filtered_graph<Polyhedron, FIMap, VIMap, HIMap> Poly_Adapter;
Polyhedron *poly = new Polyhedron();
auto poly = std::make_unique<Polyhedron>();
CGAL::make_tetrahedron(
Point_3(1,1,1),
Point_3(0,0,0),

View File

@ -2,9 +2,13 @@
#include <CGAL/boost/graph/internal/Has_member_id.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Triangulation_vertex_base_with_id_2.h>
#include <CGAL/Triangulation_face_base_with_id_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::Polyhedron_3<K, CGAL::Polyhedron_items_with_id_3> Polyhedron_with_ids;
@ -32,5 +36,9 @@ int main()
CGAL_static_assertion(
(Has_member_id<Polyhedron_with_ids::Items::Face_wrapper<Polyhedron_with_ids::HDS, K>::Face>::value));
CGAL_static_assertion(!Has_member_id<CGAL::Triangulation_face_base_2<K> >::value);
CGAL_static_assertion(Has_member_id<CGAL::Triangulation_vertex_base_with_id_2<K> >::value);
CGAL_static_assertion(Has_member_id<CGAL::Triangulation_face_base_with_id_2<K> >::value);
return 0;
}

View File

@ -1,8 +1,6 @@
#ifndef CGAL_TEST_PREFIX_H
#define CGAL_TEST_PREFIX_H
#define CGAL_USE_SURFACE_MESH
#include <vector>
#include <fstream>
@ -12,14 +10,34 @@
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polyhedron_items_with_id_3.h>
#include <CGAL/Linear_cell_complex_for_bgl_combinatorial_map_helper.h>
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/properties_Linear_cell_complex_for_combinatorial_map.h>
#ifdef CGAL_USE_SURFACE_MESH
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh/IO.h>
#endif
#include <CGAL/Constrained_triangulation_face_base_2.h>
#include <CGAL/Constrained_triangulation_plus_2.h>
#include <CGAL/Triangulation_data_structure_2.h>
#include <CGAL/Triangulation_vertex_base_with_id_2.h>
#include <CGAL/Triangulation_face_base_with_id_2.h>
#include <CGAL/Triangulation_hierarchy_vertex_base_2.h>
#include <CGAL/boost/graph/graph_traits_Triangulation_2.h>
#include <CGAL/boost/graph/properties_Triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Triangulation_hierarchy_2.h>
#include <CGAL/boost/graph/properties_Triangulation_hierarchy_2.h>
#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/properties_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Regular_triangulation_2.h>
#include <CGAL/boost/graph/properties_Regular_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Constrained_triangulation_2.h>
#include <CGAL/boost/graph/properties_Constrained_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Constrained_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/properties_Constrained_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/graph_traits_Constrained_triangulation_plus_2.h>
#include <CGAL/boost/graph/properties_Constrained_triangulation_plus_2.h>
#include <CGAL/boost/graph/io.h>
@ -37,10 +55,7 @@ typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper
<2, 3, MyTraits>::type LCC;
#ifdef CGAL_USE_SURFACE_MESH
typedef CGAL::Surface_mesh<Point_3> SM;
#endif
#if defined(CGAL_USE_OPENMESH)
@ -55,6 +70,31 @@ typedef CGAL::Surface_mesh<Point_3> SM;
typedef OpenMesh::PolyMesh_ArrayKernelT</* MyTraits*/> OMesh;
#endif
typedef CGAL::Triangulation_vertex_base_with_id_2<Kernel> Vbb;
typedef CGAL::Triangulation_face_base_with_id_2<Kernel> Fbb;
typedef CGAL::Triangulation_2<Kernel,
CGAL::Triangulation_data_structure_2<Vbb, Fbb> > Triangulation_2;
typedef CGAL::Delaunay_triangulation_2<Kernel,
CGAL::Triangulation_data_structure_2<Vbb, Fbb> > Delaunay_triangulation_2;
typedef CGAL::Regular_triangulation_vertex_base_2<Kernel, Vbb> RVb;
typedef CGAL::Regular_triangulation_face_base_2<Kernel, Fbb> RFb;
typedef CGAL::Regular_triangulation_2<Kernel,
CGAL::Triangulation_data_structure_2<RVb, RFb> > Regular_triangulation_2;
typedef CGAL::Constrained_triangulation_face_base_2<Kernel, Fbb> CDFb;
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> CDVb;
typedef CGAL::Constrained_triangulation_2<Kernel,
CGAL::Triangulation_data_structure_2<CDVb, CDFb> > Constrained_triangulation_2;
typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel,
CGAL::Triangulation_data_structure_2<CDVb, CDFb> > Constrained_Delaunay_triangulation_2;
typedef CGAL::Constrained_triangulation_plus_2<
Constrained_Delaunay_triangulation_2> CDT_P2;
typedef CGAL::Triangulation_hierarchy_2<CDT_P2> Triangulation_hierarchy_2;
#include <CGAL/boost/graph/helpers.h>
// helper to easily define all graph_traits members
@ -137,21 +177,46 @@ std::vector<T> t_data()
return vs;
}
std::vector<Polyhedron> poly_data()
{ return t_data<Polyhedron>(); }
#if defined(CGAL_USE_SURFACE_MESH)
std::vector<SM> sm_data()
{ return t_data<SM>(); }
#endif
std::vector<Polyhedron> poly_data() { return t_data<Polyhedron>(); }
std::vector<SM> sm_data() { return t_data<SM>(); }
std::vector<LCC> lcc_data() { return t_data<LCC>(); }
#if defined(CGAL_USE_OPENMESH)
std::vector<OMesh> omesh_data()
{ return t_data<OMesh>(); }
std::vector<OMesh> omesh_data() { return t_data<OMesh>(); }
#endif
std::vector<LCC> lcc_data()
{ return t_data<LCC>(); }
template <typename Tr>
Tr build_dummy_triangulation()
{
typedef typename Tr::Point Point;
typedef typename boost::graph_traits<Tr>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<Tr>::face_descriptor face_descriptor;
Tr t;
t.insert(Point(0.1,0));
t.insert(Point(1,0));
t.insert(Point(0.2,0.2));
t.insert(Point(0,1));
t.insert(Point(0,2));
int id = 0;
for(vertex_descriptor vd : vertices(t))
vd->id() = id++;
id = 0;
for(face_descriptor fd : faces(t))
fd->id() = id++;
return t;
}
Triangulation_2 t2_data() { return build_dummy_triangulation<Triangulation_2>(); }
Delaunay_triangulation_2 dt2_data() { return build_dummy_triangulation<Delaunay_triangulation_2>(); }
Regular_triangulation_2 rt2_data() { return build_dummy_triangulation<Regular_triangulation_2>(); }
Constrained_triangulation_2 ct2_data() { return build_dummy_triangulation<Constrained_triangulation_2>(); }
Constrained_Delaunay_triangulation_2 cdt2_data() { return build_dummy_triangulation<Constrained_Delaunay_triangulation_2>(); }
CDT_P2 cdtp2_data() { return build_dummy_triangulation<CDT_P2>(); }
Triangulation_hierarchy_2 t2h_data() { return build_dummy_triangulation<Triangulation_hierarchy_2>(); }
template <typename Graph>
struct Surface_fixture_1 {

View File

@ -1,5 +1,5 @@
#include "test_Prefix.h"
#include <boost/unordered_set.hpp>
template< typename G,
@ -31,7 +31,6 @@ void index_uniqueness(const G&,
void index_uniqueness_poly(const Polyhedron& g)
{
std::cerr << "testing Polyhedron\n";
index_uniqueness(g, edges(g) , get(boost::edge_index, g));
index_uniqueness(g, vertices(g), get(boost::vertex_index, g));
index_uniqueness(g, faces(g), get(boost::face_index, g));
@ -45,28 +44,23 @@ void index_uniqueness_poly(const Polyhedron& g)
void index_uniqueness_lcc(const LCC& g)
{
std::cerr << "testing Linear_cell_complex\n";
index_uniqueness(g, edges(g) , get(boost::edge_index, g));
index_uniqueness(g, vertices(g), get(boost::vertex_index, g));
index_uniqueness(g, faces(g), get(boost::face_index, g));
index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g));
}
#if defined(CGAL_USE_SURFACE_MESH)
void index_uniqueness_sm(const SM& g)
{
std::cerr << "testing Surface_mesh\n";
index_uniqueness(g, edges(g) , get(boost::edge_index, g));
index_uniqueness(g, vertices(g), get(boost::vertex_index, g));
index_uniqueness(g, faces(g), get(boost::face_index, g));
index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g));
}
#endif
#if defined(CGAL_USE_OPENMESH)
void index_uniqueness_omesh(const OMesh& g)
{
std::cerr << "testing OpenMesh\n";
index_uniqueness(g, edges(g) , get(boost::edge_index, g));
index_uniqueness(g, vertices(g), get(boost::vertex_index, g));
index_uniqueness(g, faces(g), get(boost::face_index, g));
@ -74,35 +68,48 @@ void index_uniqueness_omesh(const OMesh& g)
}
#endif
int
main()
template <typename Triangulation>
void index_uniqueness_tr(const Triangulation& g)
{
index_uniqueness(g, edges(g) , get(boost::edge_index, g));
index_uniqueness(g, vertices(g), get(boost::vertex_index, g));
index_uniqueness(g, faces(g), get(boost::face_index, g));
index_uniqueness(g, halfedges(g), get(boost::halfedge_index, g));
}
int main()
{
std::cout << "testing Polyhedron\n";
std::vector<Polyhedron> polys = poly_data();
for(Polyhedron p : polys){
for(Polyhedron p : polys)
index_uniqueness_poly(p);
}
std::cout << "testing Linear_cell_complex\n";
std::vector<LCC> lccs = lcc_data();
for(LCC p : lccs){
for(LCC p : lccs)
index_uniqueness_lcc(p);
}
#if defined(CGAL_USE_SURFACE_MESH)
std::cout << "testing Surface_mesh\n";
std::vector<SM> sms = sm_data();
for(SM p : sms){
for(SM p : sms)
index_uniqueness_sm(p);
}
#endif
#if defined(CGAL_USE_OPENMESH)
std::cout << "testing OpenMesh\n";
std::vector<OMesh> omeshs = omesh_data();
for(OMesh p : omeshs){
for(OMesh p : omeshs)
index_uniqueness_omesh(p);
}
#endif
std::cout << "testing Triangulations\n";
index_uniqueness_tr(t2_data());
index_uniqueness_tr(dt2_data());
index_uniqueness_tr(rt2_data());
index_uniqueness_tr(ct2_data());
index_uniqueness_tr(cdt2_data());
index_uniqueness_tr(cdtp2_data());
index_uniqueness_tr(t2h_data());
std::cerr << "done\n";
return 0;
}

View File

@ -88,6 +88,11 @@ void test(const NamedParameters& np)
assert(get_param(np, CGAL::internal_np::require_same_orientation).v == 49);
assert(get_param(np, CGAL::internal_np::use_bool_op_to_clip_surface).v == 50);
assert(get_param(np, CGAL::internal_np::face_size_map).v == 52);
assert(get_param(np, CGAL::internal_np::snapping_tolerance).v == 57);
assert(get_param(np, CGAL::internal_np::use_angle_smoothing).v == 53);
assert(get_param(np, CGAL::internal_np::use_area_smoothing).v == 54);
assert(get_param(np, CGAL::internal_np::use_Delaunay_flips).v == 55);
assert(get_param(np, CGAL::internal_np::use_safety_constraints).v == 56);
// Named parameters that we use in the package 'Surface Mesh Simplification'
assert(get_param(np, CGAL::internal_np::get_cost_policy).v == 34);
@ -169,6 +174,11 @@ void test(const NamedParameters& np)
check_same_type<49>(get_param(np, CGAL::internal_np::require_same_orientation));
check_same_type<50>(get_param(np, CGAL::internal_np::use_bool_op_to_clip_surface));
check_same_type<52>(get_param(np, CGAL::internal_np::face_size_map));
check_same_type<57>(get_param(np, CGAL::internal_np::snapping_tolerance));
check_same_type<53>(get_param(np, CGAL::internal_np::use_angle_smoothing));
check_same_type<54>(get_param(np, CGAL::internal_np::use_area_smoothing));
check_same_type<55>(get_param(np, CGAL::internal_np::use_Delaunay_flips));
check_same_type<56>(get_param(np, CGAL::internal_np::use_safety_constraints));
// Named parameters that we use in the package 'Surface Mesh Simplification'
check_same_type<34>(get_param(np, CGAL::internal_np::get_cost_policy));
@ -243,17 +253,22 @@ int main()
.weight_calculator(A<39>(39))
.preserve_genus(A<40>(40))
.verbosity_level(A<41>(41))
.use_binary_mode(A<51>(51))
.projection_functor(A<42>(42))
.throw_on_self_intersection(A<43>(43))
.clip_volume(A<44>(44))
.use_compact_clipper(A<45>(45))
.use_bool_op_to_clip_surface(A<50>(50))
.apply_per_connected_component(A<46>(46))
.output_iterator(A<47>(47))
.erase_all_duplicates(A<48>(48))
.require_same_orientation(A<49>(49))
.use_bool_op_to_clip_surface(A<50>(50))
.use_binary_mode(A<51>(51))
.face_size_map(A<52>(52))
.snapping_tolerance(A<57>(57))
.use_angle_smoothing(A<53>(53))
.use_area_smoothing(A<54>(54))
.use_Delaunay_flips(A<55>(55))
.use_safety_constraints(A<56>(56))
);
return EXIT_SUCCESS;

View File

@ -1,11 +1,11 @@
#include "test_Prefix.h"
#include <boost/numeric/conversion/cast.hpp>
#include <boost/unordered_set.hpp>
#include <CGAL/use.h>
typedef boost::unordered_set<std::size_t> id_map;
#include <boost/numeric/conversion/cast.hpp>
#include <boost/unordered_set.hpp>
typedef boost::unordered_set<std::size_t> id_map;
template <typename Graph>
void test_isolated_vertex()
@ -58,6 +58,29 @@ void test_halfedge_around_face_iterator(const Graph& g)
}
}
template<typename G>
void test_halfedge_iterators(const G& g)
{
typedef boost::graph_traits< G > Traits;
typedef typename Traits::halfedge_iterator halfedge_iterator;
typedef typename Traits::halfedges_size_type halfedges_size_type;
// do we iterate as many as that?
halfedge_iterator hb, he;
boost::tie(hb, he) = halfedges(g);
assert(boost::numeric_cast<halfedges_size_type>(std::distance(hb, he)) == num_halfedges(g));
id_map ids;
unsigned int count = 0;
for(boost::tie(hb, he) = halfedges(g); hb != he; ++hb) {
std::pair<id_map::iterator, bool> r = ids.insert(get(boost::halfedge_index, g, *hb));
// unique?
assert(r.second);
++count;
}
assert(count == num_halfedges(g));
}
template<typename G>
void test_edge_iterators(const G& g)
{
@ -86,7 +109,7 @@ void test_edge_iterators(const G& g)
}
template<typename G>
void test_vertex_iterators(G& g)
void test_vertex_iterators(const G& g)
{
typedef boost::graph_traits< G > Traits;
typedef typename Traits::vertex_iterator vertex_iterator;
@ -203,6 +226,41 @@ void test_in_out_edges(const G& g)
}
}
template<typename G>
void test_adjacent_vertices(const G& g)
{
typedef boost::graph_traits< G > Traits;
typedef typename Traits::vertex_descriptor vertex_descriptor;
typedef typename Traits::edge_descriptor edge_descriptor;
typedef typename Traits::in_edge_iterator in_edge_iterator;
typedef typename Traits::out_edge_iterator out_edge_iterator;
typedef typename Traits::adjacency_iterator adjacency_iterator;
typedef std::pair<edge_descriptor, bool> ret;
vertex_descriptor v = *(vertices(g).begin());
adjacency_iterator vb, ve;
boost::tie(vb, ve) = adjacent_vertices(v, g);
in_edge_iterator ieb, iee;
boost::tie(ieb, iee) = in_edges(v, g);
out_edge_iterator oeb, oee;
boost::tie(oeb, oee) = out_edges(v, g);
assert(std::distance(vb, ve) == std::distance(ieb, iee));
assert(std::distance(vb, ve) == std::distance(oeb, oee));
for(; vb != ve; ++vb)
{
vertex_descriptor s = *vb;
assert(s != v);
assert(s != Traits::null_vertex());
ret found = edge(s, v, g);
assert(found.second);
}
}
// check that every edge can be found through edge(u, v, g)
template<typename G>
void test_edge_find(const G& g)
@ -256,39 +314,56 @@ void test_read(const G& g)
assert(CGAL::is_valid_polygon_mesh(g));
}
template <typename Graph>
void
test(const std::vector<Graph>& graphs)
void test_const_graph(const Graph& g)
{
for(const Graph& p : graphs){
test_edge_iterators(p);
test_read(p);
test_vertex_iterators(p);
test_out_edges(p);
test_in_edges(p);
test_in_out_edges(p);
test_edge_find(p);
test_faces(p);
test_halfedge_around_vertex_iterator(p);
test_halfedge_around_face_iterator(p);
}
test_isolated_vertex<Graph>();
test_vertex_iterators(g);
test_halfedge_iterators(g);
test_edge_iterators(g);
test_read(g);
test_out_edges(g);
test_in_edges(g);
test_in_out_edges(g);
// test_adjacent_vertices(g);
test_edge_find(g);
test_faces(g);
test_halfedge_around_vertex_iterator(g);
test_halfedge_around_face_iterator(g);
}
int
main()
template <typename Graph>
void test_graph_range(const std::vector<Graph>& graphs)
{
test(poly_data());
for(const Graph& g : graphs)
{
test_const_graph(g);
test_isolated_vertex<Graph>();
}
}
test(lcc_data());
int main()
{
std::cout << "Test polyhedron data..." << std::endl;
test_graph_range(poly_data());
#if defined(CGAL_USE_SURFACE_MESH)
test(sm_data());
#endif
std::cout << "Test LCC data..." << std::endl;
test_graph_range(lcc_data());
std::cout << "Test Surface_mesh data..." << std::endl;
test_graph_range(sm_data());
std::cout << "Test T2 data..." << std::endl;
test_const_graph(t2_data());
test_const_graph(dt2_data());
test_const_graph(rt2_data());
test_const_graph(ct2_data());
test_const_graph(cdt2_data());
test_const_graph(cdtp2_data());
test_const_graph(t2h_data());
#if defined(CGAL_USE_OPENMESH)
test(omesh_data());
std::cout << "Test OpenMesh data..." << std::endl;
test_graph_range(omesh_data());
#endif
std::cerr << "done" << std::endl;

View File

@ -1,40 +1,31 @@
#include <iostream>
#include <fstream>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/boost/graph/generators.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/boost/graph/Euler_operations.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
#include <iostream>
#include <fstream>
typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_3 Point_3;
template <typename Mesh>
void
test(const char *fname, bool triangle, bool quad, bool tetrahedron, bool hexahedron)
void test_validity()
{
typedef typename boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
std::cerr << "test(" << fname << ")"<< std::endl;
Mesh m;
std::ifstream in(fname);
in >> m;
halfedge_descriptor hd = *halfedges(m).first;
assert(CGAL::is_isolated_triangle(hd, m) == triangle);
assert(CGAL::is_isolated_quad(hd, m) == quad);
assert(CGAL::is_tetrahedron(hd, m) == tetrahedron);
assert(CGAL::is_hexahedron(hd, m) == hexahedron);
}
std::cerr << "test validity" << std::endl;
template <typename Mesh>
void
test_validity(Mesh& mesh)
{
typedef typename boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef typename boost::property_map<Mesh, CGAL::vertex_point_t>::type VPMap;
Mesh mesh;
VPMap vpmap = get(CGAL::vertex_point, mesh);
vertex_descriptor vertices[4];
edge_descriptor edges[4];
vertices[0] = add_vertex(mesh);
@ -100,11 +91,32 @@ test_validity(Mesh& mesh)
}
int main()
template <typename Mesh>
void test(const char *fname, bool triangle, bool quad, bool tetrahedron, bool hexahedron)
{
typedef CGAL::Surface_mesh<Point_3> Mesh;
Mesh mesh;
test_validity(mesh);
typedef typename boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
std::cerr << "test(" << fname << ")"<< std::endl;
Mesh m;
std::ifstream in(fname);
in >> m;
halfedge_descriptor hd = *halfedges(m).first;
assert(CGAL::is_isolated_triangle(hd, m) == triangle);
assert(CGAL::is_isolated_quad(hd, m) == quad);
assert(CGAL::is_tetrahedron(hd, m) == tetrahedron);
assert(CGAL::is_hexahedron(hd, m) == hexahedron);
}
template <typename Mesh>
void test_generators()
{
typedef typename boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef typename boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef typename boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef typename boost::graph_traits<Mesh>::face_descriptor face_descriptor;
// triangle quad tetra hexa
test<Mesh>("data/triangle.off", true, false, false, false );
test<Mesh>("data/quad.off", false, true, false, false );
@ -112,20 +124,21 @@ int main()
test<Mesh>("data/cube.off", false, false, false, false );
test<Mesh>("data/cube-quads.off", false, false, false, true );
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
Point_3 a(0,0,0), b(1,0,0), c(1,1,0), d(0,1,0);
Point_3 aa(0,0,1), bb(1,0,1), cc(1,1,1), dd(0,1,1);
Mesh m;
halfedge_descriptor hd;
hd = CGAL::make_triangle(a,b,c,m);
assert(CGAL::is_isolated_triangle(hd,m));
assert(CGAL::is_valid_polygon_mesh(m));
m.clear();
hd = CGAL::make_quad(a,b,c,d,m);
assert(CGAL::is_isolated_quad(hd,m));
assert(CGAL::is_valid_polygon_mesh(m));
assert(CGAL::is_quad_mesh(m));
m.clear();
hd = CGAL::make_tetrahedron(a,b,c,d,m);
assert(CGAL::is_tetrahedron(hd,m));
@ -136,26 +149,86 @@ int main()
assert(CGAL::is_hexahedron(hd,m));
assert(CGAL::is_quad_mesh(m));
assert(CGAL::is_valid_polygon_mesh(m));
m.clear();
CGAL::make_icosahedron<Mesh, Point_3>(m);
assert(num_faces(m) == 20);
assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid_polygon_mesh(m));
m.clear();
hd = CGAL::make_pyramid<Mesh, Point_3>(3, m);
assert(num_faces(m) == 6);
assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid_polygon_mesh(m));
m.clear();
hd = CGAL::make_regular_prism<Mesh, Point_3>(4, m);
assert(num_faces(m) == 16);
assert(CGAL::is_triangle_mesh(m));
assert(CGAL::is_valid_polygon_mesh(m));
m.clear();
CGAL::make_grid(3,3,m);
assert(num_faces(m) == 9);
assert(CGAL::is_quad_mesh(m));
assert(CGAL::is_valid_polygon_mesh(m));
std::cerr << "done" << std::endl;
return 0;
// -----------------------------------------------------------------------------------------------
std::cerr << "test random element generators" << std::endl;
vertex_descriptor v;
halfedge_descriptor h;
edge_descriptor e;
face_descriptor f;
CGAL::Random rnd;
// ---------------------------------------------------------------------------
v = CGAL::internal::random_vertex_in_mesh(m, rnd);
assert(v != boost::graph_traits<Mesh>::null_vertex());
h = CGAL::internal::random_halfedge_in_mesh(m, rnd);
assert(h != boost::graph_traits<Mesh>::null_halfedge());
e = CGAL::internal::random_edge_in_mesh(m, rnd);
f = CGAL::internal::random_face_in_mesh(m, rnd);
assert(f != boost::graph_traits<Mesh>::null_face());
// ---------------------------------------------------------------------------
h = CGAL::internal::random_halfedge_in_face(f, m, rnd);
assert(h != boost::graph_traits<Mesh>::null_halfedge());
assert(face(h, m) == f);
v = CGAL::internal::random_vertex_in_face(f, m, rnd);
assert(v != boost::graph_traits<Mesh>::null_vertex());
// could use vertices_around_face, but it's the point is not to
bool has_vertex = false;
halfedge_descriptor done = h;
do
{
if(target(h, m) == v)
{
has_vertex = true;
break;
}
h = next(h, m);
}
while(h != done);
assert(has_vertex);
}
int main()
{
typedef CGAL::Surface_mesh<Point_3> Mesh;
test_validity<Mesh>();
test_generators<Mesh>();
std::cerr << "done" << std::endl;
return EXIT_SUCCESS;
}

View File

@ -18,7 +18,5 @@ template< typename Kernel >
class Gps_circle_segment_traits_2 {
public:
/// @}
}; /* end Gps_circle_segment_traits_2 */
} /* end namespace CGAL */

View File

@ -20,7 +20,5 @@ template< typename ArrTraits, typename GeneralPolygon_t >
class Gps_traits_2 {
public:
/// @}
}; /* end Gps_traits_2 */
} /* end namespace CGAL */

View File

@ -26,7 +26,5 @@ template< typename Kernel, typename Container, typename Dcel >
class Polygon_set_2 : public General_polygon_set_2<Gps_segment_traits_2<Kernel,Container> > {
public:
/// @}
}; /* end Polygon_set_2 */
} /* end namespace CGAL */

View File

@ -20,7 +20,5 @@ A model of this concept represents a general polygon with holes.
class GpsTraitsGeneralPolygonWithHoles_2 {
public:
/// @}
}; /* end GpsTraitsGeneralPolygonWithHoles_2 */

View File

@ -21,7 +21,5 @@ A model of this concept represents a simple general polygon.
class GpsTraitsGeneralPolygon_2 {
public:
/// @}
}; /* end GpsTraitsGeneralPolygon_2 */

Some files were not shown because too many files have changed in this diff Show More