Skip to content

Commit 56e1281

Browse files
committed
Add test (which does not compile yet)
1 parent f7d362d commit 56e1281

File tree

5 files changed

+165
-97
lines changed

5 files changed

+165
-97
lines changed

BGL/include/CGAL/boost/graph/graph_traits_SurfaceMesh.h

+37-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// include this to avoid a VC15 warning
2020
#include <CGAL/boost/graph/Named_function_parameters.h>
21-
21+
#include <CGAL/boost/graph/properties.h>
2222
#include <boost/graph/graph_traits.hpp>
2323
#include <boost/graph/properties.hpp>
2424

@@ -29,6 +29,42 @@
2929
#include <pmp/SurfaceMesh.h>
3030
#include <CGAL/assertions.h>
3131

32+
namespace std {
33+
34+
template<>
35+
struct iterator_traits<pmp::SurfaceMesh::VertexIterator> {
36+
typedef int difference_type;
37+
typedef pmp::Vertex value_type;
38+
typedef const pmp::Vertex& reference;
39+
typedef pmp::Vertex* pointer;
40+
typedef std::random_access_iterator_tag iterator_category;
41+
};
42+
43+
template<>
44+
struct iterator_traits<pmp::SurfaceMesh::EdgeIterator> {
45+
typedef int difference_type;
46+
typedef pmp::Edge value_type;
47+
typedef const pmp::Edge& reference;
48+
typedef pmp::Edge* pointer;
49+
typedef std::random_access_iterator_tag iterator_category;
50+
};
51+
template<>
52+
struct iterator_traits<pmp::SurfaceMesh::HalfedgeIterator> {
53+
typedef int difference_type;
54+
typedef pmp::Halfedge value_type;
55+
typedef const pmp::Halfedge& reference;
56+
typedef pmp::Halfedge* pointer;
57+
typedef std::random_access_iterator_tag iterator_category;
58+
};
59+
template<>
60+
struct iterator_traits<pmp::SurfaceMesh::FaceIterator> {
61+
typedef int difference_type;
62+
typedef pmp::Face value_type;
63+
typedef const pmp::Face& reference;
64+
typedef pmp::Face* pointer;
65+
typedef std::random_access_iterator_tag iterator_category;
66+
};
67+
}
3268

3369

3470
namespace CGAL { namespace internal {

BGL/include/CGAL/boost/graph/properties_SurfaceMesh.h

+33-22
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@
1818

1919
#include <CGAL/license/Surface_mesh.h>
2020

21-
#include <CGAL/assertions.h>
2221
#include <pmp/SurfaceMesh.h>
23-
#include <CGAL/Kernel_traits.h>
24-
#include <CGAL/squared_distance_3.h>
25-
#include <CGAL/number_utils.h>
2622

23+
#include <CGAL/assertions.h>
24+
#include <CGAL/number_utils.h>
2725
#include <CGAL/boost/graph/properties.h>
28-
2926
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
3027

3128
#include <boost/cstdint.hpp>
@@ -39,7 +36,7 @@ class pmp_edge_weight_pmap
3936
typedef pmp::SurfaceMesh SM;
4037
public:
4138
typedef boost::readable_property_map_tag category;
42-
typedef double value_type;
39+
typedef double value_type;
4340
typedef value_type reference;
4441
typedef typename boost::graph_traits<pmp::SurfaceMesh>::edge_descriptor key_type;
4542

@@ -101,15 +98,12 @@ get(boost::edge_weight_t, const SurfaceMesh& sm)
10198
}
10299

103100

104-
105101
Scalar
106102
get(boost::edge_weight_t, const SurfaceMesh& sm,
107103
const boost::graph_traits<SurfaceMesh>::edge_descriptor& e)
108104
{
109105
return CGAL::pmp_edge_weight_pmap(sm)[e];
110106
}
111-
112-
113107

114108
}
115109
//
@@ -125,48 +119,54 @@ struct property_map<pmp::SurfaceMesh, boost::vertex_index_t >
125119
};
126120
}
127121

128-
namespace pmp{
129122

123+
namespace pmp{
130124

131125
CGAL::SM_index_pmap<Vertex>
132126
get(const boost::vertex_index_t&, const SurfaceMesh&)
133127
{
134128
return CGAL::SM_index_pmap<Vertex>();
135129
}
130+
136131
}
132+
137133
//
138134
// face_index
139135
//
140136
namespace boost{
141137

142-
template<>
138+
template<>
143139
struct property_map<pmp::SurfaceMesh, boost::face_index_t >
144140
{
145141
typedef CGAL::SM_index_pmap<pmp::Face> type;
146142
typedef CGAL::SM_index_pmap<pmp::Face> const_type;
147143
};
144+
148145
}
149146

150147
namespace pmp{
151148

152-
153149
CGAL::SM_index_pmap<Face>
154150
get(const boost::face_index_t&, const SurfaceMesh&)
155151
{
156152
return CGAL::SM_index_pmap<pmp::Face>();
157153
}
158154
}
155+
159156
//
160157
// edge_index
161158
//
162159
namespace boost{
160+
163161
template <>
164162
struct property_map<pmp::SurfaceMesh, boost::edge_index_t >
165163
{
166164
typedef CGAL::SM_index_pmap<CGAL::internal::PMP_edge> type;
167165
typedef CGAL::SM_index_pmap<CGAL::internal::PMP_edge> const_type;
168166
};
167+
169168
}
169+
170170
namespace pmp{
171171

172172
CGAL::SM_index_pmap<CGAL::internal::PMP_edge>
@@ -175,33 +175,37 @@ get(const boost::edge_index_t&, const SurfaceMesh&)
175175
return CGAL::SM_index_pmap<CGAL::internal::PMP_edge>();
176176
}
177177
}
178+
178179
//
179180
// halfedge_index
180181
//
181182
namespace boost{
183+
182184
template <>
183185
struct property_map<pmp::SurfaceMesh, boost::halfedge_index_t >
184186
{
185187
typedef CGAL::SM_index_pmap<pmp::Halfedge> type;
186188
typedef CGAL::SM_index_pmap<pmp::Halfedge> const_type;
187189
};
190+
188191
}
189-
namespace pmp{
190192

193+
namespace pmp{
191194

192195
CGAL::SM_index_pmap<Halfedge>
193196
get(const boost::halfedge_index_t&, const SurfaceMesh&)
194197
{
195198
return CGAL::SM_index_pmap<Halfedge>();
196199
}
200+
197201
}
202+
198203
//
199204
// vertex_point
200205
//
201-
202206
namespace pmp {
203207

204-
template <typename P>
208+
template <typename P>
205209
struct VertexPointMap {
206210
typedef P value_type;
207211
typedef P reference;
@@ -214,8 +218,7 @@ struct VertexPointMap {
214218
inline friend value_type get(const VertexPointMap& pm, key_type v)
215219
{
216220
const Point& p = pm.sm->position(v);
217-
return P(p[0],p[1],p[2]);
218-
221+
return P(p[0],p[1],p[2]);
219222
}
220223

221224
inline friend void put(const VertexPointMap& pm, key_type v, const value_type& p)
@@ -225,10 +228,12 @@ struct VertexPointMap {
225228

226229
SurfaceMesh* sm;
227230
};
231+
228232
}
229233

230234

231235
namespace boost{
236+
232237
template <>
233238
struct property_map<pmp::SurfaceMesh, CGAL::vertex_point_t >
234239
{
@@ -237,6 +242,7 @@ struct property_map<pmp::SurfaceMesh, CGAL::vertex_point_t >
237242
typedef pmp::VertexPointMap<P> type;
238243
typedef type const_type;
239244
};
245+
240246
}
241247

242248

@@ -247,8 +253,6 @@ get(CGAL::vertex_point_t, const SurfaceMesh& g) {
247253
return boost::property_map<SurfaceMesh, CGAL::vertex_point_t >::type(g);
248254
}
249255

250-
251-
252256

253257
// get for intrinsic properties
254258
#define CGAL_SM_INTRINSIC_PROPERTY(RET, PROP, TYPE) \
@@ -273,7 +277,6 @@ CGAL_SM_INTRINSIC_PROPERTY(CGAL::Exact_predicates_inexact_constructions_kernel::
273277
// only available for vertex_point
274278

275279

276-
277280
void
278281
put(CGAL::vertex_point_t p, pmp::SurfaceMesh& sm,
279282
typename boost::graph_traits< pmp::SurfaceMesh >::vertex_descriptor v,
@@ -284,6 +287,15 @@ put(CGAL::vertex_point_t p, pmp::SurfaceMesh& sm,
284287

285288
} // namespace pmp
286289

290+
namespace boost {
291+
292+
struct edge_property_type<pmp::SurfaceMesh>
293+
{
294+
typedef boost::edge_weight_t type;
295+
};
296+
297+
}
298+
287299
namespace CGAL {
288300

289301
template <>
@@ -315,8 +327,7 @@ struct graph_has_property<pmp::SurfaceMesh, boost::edge_weight_t>
315327

316328

317329
// dynamic properties
318-
namespace boost
319-
{
330+
namespace boost {
320331

321332
template <typename T>
322333
struct property_map<pmp::SurfaceMesh, CGAL::dynamic_vertex_property_t<T> >

BGL/test/BGL/CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ project( BGL_Tests )
66

77

88

9-
10-
119
# CGAL and its components
1210
find_package( CGAL QUIET COMPONENTS )
1311

@@ -37,6 +35,11 @@ endif()
3735

3836

3937

38+
find_package(pmp QUIET)
39+
40+
41+
42+
4043
# include for local package
4144

4245
# Creating entries for all .cpp/.C files with "main" routine
@@ -108,3 +111,8 @@ if(OpenMesh_FOUND)
108111
target_link_libraries( test_Properties PRIVATE ${OPENMESH_LIBRARIES})
109112
target_link_libraries( test_bgl_read_write PRIVATE ${OPENMESH_LIBRARIES})
110113
endif()
114+
115+
# if(PMP_FOUND)
116+
create_single_source_cgal_program( "graph_concept_PMP.cpp" )
117+
target_link_libraries (graph_concept_PMP PRIVATE pmp )
118+
# endif()

BGL/test/BGL/graph_concept_PMP.cpp

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#include <CGAL/basic.h>
2+
#include <pmp/SurfaceMesh.h>
3+
#include <CGAL/boost/graph/graph_traits_SurfaceMesh.h>
4+
5+
#include <CGAL/boost/graph/graph_concepts.h>
6+
7+
8+
typedef pmp::SurfaceMesh Sm;
9+
typedef boost::graph_traits< Sm > Traits;
10+
typedef Traits::edge_descriptor edge_descriptor;
11+
typedef Traits::halfedge_descriptor halfedge_descriptor;
12+
typedef Traits::vertex_descriptor vertex_descriptor;
13+
typedef Traits::face_descriptor face_descriptor;
14+
//typedef Kernel::Point_3 Point_3;
15+
16+
template<typename Graph>
17+
void concept_check_polyhedron() {
18+
boost::function_requires< boost::GraphConcept<Sm> >();
19+
20+
// Those have to be disabled due to OpenMesh's broken iterators.
21+
// boost::function_requires< boost::VertexListGraphConcept<Sm> >();
22+
// boost::function_requires< boost::EdgeListGraphConcept<Sm> >();
23+
24+
boost::function_requires< boost::IncidenceGraphConcept<Sm> >();
25+
boost::function_requires< boost::AdjacencyMatrixConcept<Sm> >();
26+
boost::function_requires< boost::BidirectionalGraphConcept<Sm> >();
27+
// boost::function_requires< boost::MutableGraphConcept<Sm> >();
28+
29+
boost::function_requires< CGAL::HalfedgeGraphConcept<Sm> >();
30+
boost::function_requires< CGAL::HalfedgeListGraphConcept<Sm> >();
31+
boost::function_requires< CGAL::FaceGraphConcept<Sm> >();
32+
boost::function_requires< CGAL::FaceListGraphConcept<Sm> >();
33+
34+
boost::function_requires< CGAL::MutableHalfedgeGraphConcept<Sm> >();
35+
boost::function_requires< CGAL::MutableFaceGraphConcept<Sm> >();
36+
37+
// this uses some internal boost concepts, better than nothing
38+
boost::function_requires< boost::concepts::ReadablePropertyGraph<Sm, edge_descriptor, boost::edge_weight_t> >();
39+
boost::function_requires< boost::concepts::ReadablePropertyGraph<Sm, vertex_descriptor, boost::vertex_index_t> >();
40+
boost::function_requires< boost::concepts::ReadablePropertyGraph<Sm, edge_descriptor, boost::edge_index_t> >();
41+
//boost::function_requires< boost::concepts::PropertyGraphConcept <Sm, vertex_descriptor, boost::vertex_point_t> >();
42+
boost::function_requires< boost::concepts::ReadablePropertyGraph<Sm, face_descriptor, CGAL::face_index_t> >();
43+
boost::function_requires< boost::concepts::ReadablePropertyGraph<Sm, halfedge_descriptor, CGAL::halfedge_index_t> >();
44+
// boost::function_requires< boost::concepts::ReadablePropertyGraph<Sm, vertex_descriptor, CGAL::vertex_is_border_t> >();
45+
46+
// null
47+
boost::graph_traits<Sm>::null_vertex();
48+
boost::graph_traits<Sm>::null_halfedge();
49+
boost::graph_traits<Sm>::null_face();
50+
}
51+
52+
int main()
53+
{
54+
concept_check_polyhedron<Sm>();
55+
return 0;
56+
}

0 commit comments

Comments
 (0)