mirror of https://github.com/CGAL/cgal
Update graph traits and properties for lcc.
This commit is contained in:
parent
b8b419f3b9
commit
04d10f13e9
|
|
@ -71,19 +71,23 @@ template <typename Dart_handle>
|
|||
struct EdgeHandle : Dart_handle
|
||||
{
|
||||
EdgeHandle() : Dart_handle(NULL){}
|
||||
EdgeHandle(Dart_handle& h): Dart_handle(h)
|
||||
{}
|
||||
EdgeHandle(const Dart_handle& h): Dart_handle(h)
|
||||
EdgeHandle(Dart_handle h): Dart_handle(h)
|
||||
{}
|
||||
|
||||
Dart_handle first_halfedge()
|
||||
Dart_handle first_halfedge() const
|
||||
{ return *this; }
|
||||
|
||||
Dart_handle second_halfedge()
|
||||
{ return this->beta(2); }
|
||||
Dart_handle second_halfedge() const
|
||||
{
|
||||
assert(*this!=NULL);
|
||||
return (*this)->get_f(2);
|
||||
}
|
||||
|
||||
bool operator==(const EdgeHandle& h)
|
||||
{ return (*this)==h || h->get_f(2)==*this; }
|
||||
bool operator==(const EdgeHandle& h) const
|
||||
{
|
||||
return first_halfedge()==h.first_halfedge() ||
|
||||
first_halfedge()==h.second_halfedge();
|
||||
}
|
||||
};
|
||||
|
||||
template <class CMap, typename Dart_Iterator>
|
||||
|
|
@ -100,7 +104,7 @@ public:
|
|||
|
||||
typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
|
||||
typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
|
||||
typedef Dart_handle value_type;
|
||||
typedef EdgeHandle<Dart_handle> value_type;
|
||||
typedef value_type reference;
|
||||
typedef value_type pointer;
|
||||
|
||||
|
|
@ -221,18 +225,12 @@ target(typename boost::graph_traits<CGAL_LCC_TYPE >::edge_descriptor e,
|
|||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
std::pair<typename boost::graph_traits<CGAL_LCC_TYPE >::out_edge_iterator,
|
||||
typename boost::graph_traits<CGAL_LCC_TYPE >::out_edge_iterator>
|
||||
out_edges(typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_descriptor u,
|
||||
Iterator_range<typename boost::graph_traits<CGAL_LCC_TYPE>::out_edge_iterator>
|
||||
out_edges(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor v,
|
||||
const CGAL_LCC_TYPE& cm)
|
||||
{
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::out_edge_iterator
|
||||
iter_type;
|
||||
|
||||
// CGAL_LCC_TYPE& cmap = const_cast<CGAL_LCC_TYPE&>(cm);
|
||||
|
||||
return std::make_pair<iter_type, iter_type>(iter_type(u->dart(), cm),
|
||||
iter_type(u->dart(), cm, 1));
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE>::out_edge_iterator Iter;
|
||||
return make_range(Iter(halfedge(v, cm), cm), Iter(halfedge(v, cm), cm, 1));
|
||||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
|
|
@ -244,18 +242,12 @@ out_degree(typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_descriptor u,
|
|||
// Expression required by the boost::BidirectionalGraph concept.
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
std::pair<typename boost::graph_traits<CGAL_LCC_TYPE >::in_edge_iterator,
|
||||
typename boost::graph_traits<CGAL_LCC_TYPE >::in_edge_iterator>
|
||||
Iterator_range<typename boost::graph_traits<CGAL_LCC_TYPE>::in_edge_iterator>
|
||||
in_edges(typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_descriptor v,
|
||||
const CGAL_LCC_TYPE& cm)
|
||||
{
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::in_edge_iterator
|
||||
iter_type;
|
||||
|
||||
// CGAL_LCC_TYPE& cmap = const_cast<CGAL_LCC_TYPE&>(cm);
|
||||
|
||||
return std::make_pair<iter_type, iter_type>(iter_type(v->dart(), cm),
|
||||
iter_type(v->dart(), cm, 1));
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::in_edge_iterator Iter;
|
||||
return make_range(Iter(halfedge(v, cm), cm), Iter(halfedge(v, cm), cm, 1));
|
||||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
|
|
@ -290,13 +282,10 @@ CGAL_LCC_TEMPLATE_ARGS
|
|||
CGAL::Iterator_range<typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_iterator>
|
||||
vertices(const CGAL_LCC_TYPE& cm)
|
||||
{
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_iterator
|
||||
iter_type;
|
||||
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::vertex_iterator Iter;
|
||||
CGAL_LCC_TYPE& cmap = const_cast<CGAL_LCC_TYPE&>(cm);
|
||||
|
||||
return CGAL::make_range(iter_type(cmap.template attributes<0>().begin()),
|
||||
iter_type(cmap.template attributes<0>().end()));
|
||||
return CGAL::make_range(Iter(cmap.template attributes<0>().begin()),
|
||||
Iter(cmap.template attributes<0>().end()));
|
||||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
|
|
@ -310,15 +299,13 @@ num_vertices(const CGAL_LCC_TYPE& cm)
|
|||
// Expression required by the boost::EdgeListGraph concept.
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
std::pair<typename boost::graph_traits<CGAL_LCC_TYPE >::edge_iterator,
|
||||
typename boost::graph_traits<CGAL_LCC_TYPE >::edge_iterator>
|
||||
Iterator_range<typename boost::graph_traits<CGAL_LCC_TYPE>::edge_iterator>
|
||||
edges(const CGAL_LCC_TYPE& cm)
|
||||
{
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::edge_iterator iter_type;
|
||||
typedef typename boost::graph_traits<CGAL_LCC_TYPE >::edge_iterator Iter;
|
||||
CGAL_LCC_TYPE& cmap = const_cast<CGAL_LCC_TYPE&>(cm);
|
||||
|
||||
return std::make_pair(iter_type(cmap.darts().begin()),
|
||||
iter_type(cmap.darts().end()));
|
||||
return CGAL::make_range(Iter(cmap.darts().begin()),
|
||||
Iter(cmap.darts().end()));
|
||||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
|
|
@ -332,7 +319,7 @@ edge(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor u,
|
|||
typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor v,
|
||||
const CGAL_LCC_TYPE& cm)
|
||||
{
|
||||
std::pair<typename boost::graph_traits<CGAL_LCC_TYPE>::edge_descriptor,
|
||||
std::pair<typename boost::graph_traits<CGAL_LCC_TYPE>::halfedge_descriptor,
|
||||
bool> res=halfedge(u,v,cm);
|
||||
return std::make_pair(EdgeHandle<typename CGAL_LCC_TYPE::Dart_handle>(res.first),
|
||||
res.second);
|
||||
|
|
@ -425,7 +412,10 @@ CGAL_LCC_TEMPLATE_ARGS
|
|||
typename boost::graph_traits<CGAL_LCC_TYPE>::halfedge_descriptor
|
||||
halfedge(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor v,
|
||||
const CGAL_LCC_TYPE& cmap)
|
||||
{ return const_cast<CGAL_LCC_TYPE&>(cmap).template beta<2>(v->dart()); }
|
||||
{
|
||||
if (v->dart()==NULL) return NULL;
|
||||
return const_cast<CGAL_LCC_TYPE&>(cmap).template beta<2>(v->dart());
|
||||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
std::pair<
|
||||
|
|
@ -553,7 +543,10 @@ void set_halfedge(typename boost::graph_traits<CGAL_LCC_TYPE>::vertex_descriptor
|
|||
CGAL_LCC_TYPE& cm)
|
||||
{
|
||||
//cm.template set_dart_of_attribute<0>(v, h);
|
||||
if (h!=NULL)
|
||||
cm.template set_dart_of_attribute<0>(v, cm.template beta<2>(h));
|
||||
else
|
||||
cm.template set_dart_of_attribute<0>(v, h);
|
||||
}
|
||||
|
||||
CGAL_LCC_TEMPLATE_ARGS
|
||||
|
|
|
|||
|
|
@ -63,18 +63,17 @@ template <class CMap>
|
|||
class CMap_dart_index_map_external :
|
||||
public boost::put_get_helper<std::size_t&, CMap_dart_index_map_external<CMap> >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
typedef boost::read_write_property_map_tag category;
|
||||
typedef std::size_t value_type;
|
||||
typedef std::size_t& reference;
|
||||
typedef typename boost::graph_traits<CMap>::edge_descriptor key_type;
|
||||
typedef CGAL::Unique_hash_map<key_type,std::size_t> Map;
|
||||
|
||||
CMap_dart_index_map_external()
|
||||
CMap_dart_index_map_external(): map(new Map)
|
||||
{}
|
||||
|
||||
CMap_dart_index_map_external(CMap const& cm)
|
||||
CMap_dart_index_map_external(CMap const& cm): map(new Map)
|
||||
{
|
||||
CMap &cmap = const_cast<CMap&>(cm);
|
||||
typedef typename CMap::Dart_range::iterator Iter;
|
||||
|
|
@ -82,22 +81,22 @@ public:
|
|||
Iter e=cmap.template darts().end();
|
||||
for(value_type i=0; b != e; ++b, ++i)
|
||||
{
|
||||
map[b] = i;
|
||||
(*map)[b] = i;
|
||||
}
|
||||
b=cmap.template darts().begin();
|
||||
for(; b != e; ++b)
|
||||
{
|
||||
value_type v1 = map[b];
|
||||
value_type v2 = map[cmap.template beta<2>(b)];
|
||||
value_type v1 = (*map)[b];
|
||||
value_type v2 = (*map)[cmap.template beta<2>(b)];
|
||||
CGAL_assertion(v1==v2+1 || v2==v1+1);
|
||||
}
|
||||
}
|
||||
|
||||
reference operator[](key_type const& e) const
|
||||
{ return const_cast<CGAL::Unique_hash_map<key_type,std::size_t>&>(map)[e]; }
|
||||
{ return const_cast<Map&>(*map)[e]; }
|
||||
|
||||
private:
|
||||
CGAL::Unique_hash_map<key_type,std::size_t> map ;
|
||||
boost::shared_ptr<Map> map;
|
||||
};
|
||||
|
||||
template <class CMap>
|
||||
|
|
@ -109,11 +108,13 @@ public:
|
|||
typedef std::size_t value_type;
|
||||
typedef std::size_t& reference;
|
||||
typedef typename boost::graph_traits<CMap>::vertex_descriptor key_type;
|
||||
typedef CGAL::Unique_hash_map<key_type,std::size_t> Map;
|
||||
|
||||
CMap_vertex_index()
|
||||
|
||||
CMap_vertex_index(): map(new Map)
|
||||
{}
|
||||
|
||||
CMap_vertex_index(CMap const& cm)
|
||||
CMap_vertex_index(CMap const& cm): map(new Map)
|
||||
{
|
||||
CMap &cmap = const_cast<CMap&>(cm);
|
||||
typedef typename CMap::template Attribute_range<0>::type::iterator Iter;
|
||||
|
|
@ -121,15 +122,15 @@ public:
|
|||
Iter e=cmap.template attributes<0>().end();
|
||||
for(value_type i=0; b != e; ++b, ++i)
|
||||
{
|
||||
map[b] = i;
|
||||
(*map)[b] = i;
|
||||
}
|
||||
}
|
||||
|
||||
reference operator[](key_type const& e) const
|
||||
{ return const_cast<CGAL::Unique_hash_map<key_type,std::size_t>&>(map)[e]; }
|
||||
{ return const_cast<Map&>(*map)[e]; }
|
||||
|
||||
private:
|
||||
CGAL::Unique_hash_map<key_type,std::size_t> map ;
|
||||
boost::shared_ptr<Map> map;
|
||||
};
|
||||
|
||||
template <class CMap>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ create_single_source_cgal_program( "graph_concept_Surface_mesh.cpp" )
|
|||
|
||||
create_single_source_cgal_program( "graph_concept_Gwdwg_Surface_mesh.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "graph_concept_Linear_cell_complex.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "test_clear.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "test_helpers.cpp" )
|
||||
|
|
@ -87,8 +89,6 @@ create_single_source_cgal_program( "test_Has_member_id.cpp" )
|
|||
|
||||
create_single_source_cgal_program( "test_cgal_bgl_named_params.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "graph_concept_Linear_cell_complex.cpp" )
|
||||
|
||||
if(OpenMesh_FOUND)
|
||||
target_link_libraries( test_graph_geometry ${OPENMESH_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ void runtime_check_halfedgegraph()
|
|||
|
||||
assert(num_edges(p) == 8);
|
||||
assert(num_halfedges(p) == 16);
|
||||
// WRONG ASSERT assert(num_faces(p) == 4);
|
||||
assert(num_faces(p) == 4);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -177,6 +177,9 @@ std::vector<OMesh> omesh_data()
|
|||
{ return t_data<OMesh>(); }
|
||||
#endif
|
||||
|
||||
std::vector<LCC> lcc_data()
|
||||
{ return t_data<LCC>(); }
|
||||
|
||||
template <typename Graph>
|
||||
struct Surface_fixture_1 {
|
||||
Surface_fixture_1() {
|
||||
|
|
@ -319,7 +322,7 @@ struct Surface_fixture_3 {
|
|||
assert(z != boost::graph_traits<Graph>::null_vertex());
|
||||
|
||||
f1 = CGAL::is_border(halfedge(u, m),m) ? face(opposite(halfedge(u, m), m), m) : face(halfedge(u, m), m);
|
||||
f2 = CGAL::is_border(halfedge(u, m),m) ? face(opposite(halfedge(z, m), m), m) : face(halfedge(z, m), m);
|
||||
f2 = CGAL::is_border(halfedge(z, m),m) ? face(opposite(halfedge(z, m), m), m) : face(halfedge(z, m), m);
|
||||
|
||||
assert(f1 != boost::graph_traits<Graph>::null_face());
|
||||
assert(f2 != boost::graph_traits<Graph>::null_face());
|
||||
|
|
|
|||
|
|
@ -283,6 +283,8 @@ main()
|
|||
{
|
||||
test(poly_data());
|
||||
|
||||
test(lcc_data());
|
||||
|
||||
#if defined(CGAL_USE_SURFACE_MESH)
|
||||
test(sm_data());
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -65,13 +65,10 @@ create_single_source_cgal_program( "edge_collapse_constrained_border_polyhedron.
|
|||
create_single_source_cgal_program( "edge_collapse_enriched_polyhedron.cpp" )
|
||||
create_single_source_cgal_program( "edge_collapse_polyhedron.cpp" )
|
||||
create_single_source_cgal_program( "edge_collapse_surface_mesh.cpp" )
|
||||
create_single_source_cgal_program( "edge_collapse_linear_cell_complex.cpp" )
|
||||
create_single_source_cgal_program( "edge_collapse_constrained_border_surface_mesh.cpp" )
|
||||
create_single_source_cgal_program( "edge_collapse_all_short_edges.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "edge_collapse_linear_cell_complex.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "edge_collapse_linear_cell_complex.cpp" )
|
||||
|
||||
if(OpenMesh_FOUND)
|
||||
create_single_source_cgal_program( "edge_collapse_OpenMesh.cpp" )
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue