Bug fixes; improve face graph wrapper

This commit is contained in:
Guillaume Damiand 2019-09-17 11:41:45 +02:00
parent 83ea4d42ef
commit bd2a504af6
4 changed files with 77 additions and 50 deletions

View File

@ -26,6 +26,7 @@
#include <CGAL/internal/Combinatorial_map_internal_functors.h>
#include <CGAL/Polyhedron_3_fwd.h>
#include <CGAL/Surface_mesh/Surface_mesh_fwd.h>
#include <bitset>
namespace CGAL
{
@ -136,10 +137,14 @@ public:
mindex_marks[i] =i;
mnb_marked_darts[i] =0;
mnb_times_reserved_marks[i]=0;
// m_marks[i] =nullptr;
}
m_nb_darts=darts().size(); // Store locally the number of darts: the HEG must not be modified
m_all_marks=get(CGAL::dynamic_halfedge_property_t<std::bitset<NB_MARKS> >(), m_fg);
for (typename Dart_range::const_iterator it(darts().begin()),
itend(darts().end()); it!=itend; ++it)
{ put(m_all_marks, it, std::bitset<NB_MARKS>()); }
}
const HEG& get_fg() const
@ -273,15 +278,6 @@ public:
++mnb_used_marks;
CGAL_assertion(is_whole_map_unmarked(m));
// m_marks[m]=new std::vector<bool>(CGAL::num_halfedges(m_fg), mmask_marks[m]); // TODO use property map
// CGAL::num_halfedges is an upper bound; depending on the removed halfedges
m_marks_new[m]=get(CGAL::dynamic_halfedge_property_t<bool>(),
const_cast<HEG&>(m_fg)); // Strange...
for (typename Dart_range::const_iterator it(darts().begin()),
itend(darts().end()); it!=itend; ++it)
{ set_dart_mark(*it, m, mmask_marks[m]); }
return m;
}
@ -310,12 +306,11 @@ public:
bool get_dart_mark(Dart_const_handle ADart, size_type amark) const
{
// return (*(m_marks[amark]))[ADart];
return get(m_marks_new[amark], ADart);
return get(m_all_marks, ADart)[amark];
}
void set_dart_mark(Dart_const_handle ADart, size_type amark, bool avalue) const
{ // (*(m_marks[amark]))[ADart]=avalue;
put(m_marks_new[amark], ADart, avalue);
{
const_cast<std::bitset<NB_MARKS>& >(get(m_all_marks, ADart)).set(amark, avalue);
}
void flip_dart_mark(Dart_const_handle ADart, size_type amark) const
@ -403,10 +398,6 @@ public:
mindex_marks[amark] = mnb_used_marks;
mnb_times_reserved_marks[amark]=0;
// delete m_marks[amark]; m_marks[amark]=nullptr; // TODO use property map
m_marks_new[amark]=get(CGAL::dynamic_halfedge_property_t<bool>(),
const_cast<HEG&>(m_fg)); // To erase the property map ??
}
bool is_without_boundary(unsigned int i) const
@ -480,10 +471,7 @@ public:
size_type size() const
{
if (msize==0)
{
for (const_iterator it=begin(), itend=end(); it!=itend; ++it)
{ ++msize; }
}
{ msize=halfedges(mmap.get_fg()).size(); }
return msize;
}
bool empty() const
@ -608,7 +596,8 @@ public:
{
if (i==0) { return mark_cell<0>(adart, amark); }
else if (i==1) { return mark_cell<1>(adart, amark); }
return mark_cell<2>(adart, amark);
else if (i==2) { return mark_cell<2>(adart, amark); }
return mark_cell<3>(adart, amark);
}
template <unsigned int i>
@ -708,9 +697,9 @@ public:
std::vector<unsigned int> count_all_cells() const
{
std::vector<unsigned int> dim(dimension+1);
std::vector<unsigned int> dim(dimension+2);
for ( unsigned int i=0; i<=dimension; ++i)
for ( unsigned int i=0; i<=dimension+1; ++i)
{ dim[i]=i; }
return count_cells(dim);
@ -718,8 +707,8 @@ public:
std::ostream& display_characteristics(std::ostream & os) const
{
std::vector<unsigned int> cells(dimension+1);
for ( unsigned int i=0; i<=dimension; ++i)
std::vector<unsigned int> cells(dimension+2);
for ( unsigned int i=0; i<=dimension+1; ++i)
{ cells[i]=i; }
std::vector<unsigned int> res=count_cells(cells);
@ -727,7 +716,7 @@ public:
os<<"#Darts="<<number_of_darts();
for (unsigned int i=0; i<=dimension; ++i)
os<<", #"<<i<<"-cells="<<res[i];
// os<<", #ccs="<<res[dimension+1];
os<<", #ccs="<<res[dimension+1];
return os;
}
@ -759,10 +748,9 @@ protected:
mutable size_type mnb_marked_darts[NB_MARKS];
/// Array of property maps; one for each reserved mark.
// mutable std::vector<bool>* m_marks[NB_MARKS];
typedef typename boost::property_map
<HEG, CGAL::dynamic_halfedge_property_t<bool> >::type MarkPMap;
mutable MarkPMap m_marks_new[NB_MARKS];
<HEG, CGAL::dynamic_halfedge_property_t<std::bitset<NB_MARKS> > >::const_type MarkPMap;
mutable MarkPMap m_all_marks;
};
/// null_handle

View File

@ -23,6 +23,7 @@
#include <boost/graph/graph_traits.hpp>
#include <CGAL/boost/graph/helpers.h>
#include <stack>
namespace CGAL
{
@ -280,6 +281,58 @@ public:
Self operator++(int)
{ Self res=*this; operator ++(); return res; }
};
template<typename Map_>
class FGW_cell_iterator<Map_, 3>: public FGW_basis_for_cell_iterator<Map_> // CC
{
public:
typedef FGW_cell_iterator Self;
typedef FGW_basis_for_cell_iterator<Map_> Base;
typedef Map_ Map;
typedef typename Map::Dart_handle Dart_handle;
typedef typename Map::size_type size_type;
FGW_cell_iterator(const Map& amap, Dart_handle adart) : Base(amap, adart)
{ m_mark=this->mmap.get_new_mark(); }
/// Constructor with two darts in parameter (for end iterator).
FGW_cell_iterator(const Map& amap, Dart_handle adart,
Dart_handle d2): Base(amap, adart, d2)
{ m_mark=this->mmap.get_new_mark(); }
~FGW_cell_iterator()
{ this->mmap.free_mark(m_mark); }
/// Prefix ++ operator.
Self& operator++()
{
if (!this->mmap.is_marked(this->mmap.template beta<1>(this->m_curdart), m_mark))
{
m_to_treat.push(this->mmap.template beta<1>(this->m_curdart));
this->mmap.mark(this->mmap.template beta<1>(this->m_curdart), m_mark);
}
if (!this->mmap.template is_free<2>(this->m_curdart) &&
!this->mmap.is_marked(this->mmap.template beta<2>(this->m_curdart), m_mark))
{
m_to_treat.push(this->mmap.template beta<2>(this->m_curdart));
this->mmap.mark(this->mmap.template beta<2>(this->m_curdart), m_mark);
}
if (m_to_treat.empty())
{ this->m_curdart=Dart_handle(); }
else
{ this->m_curdart=m_to_treat.top(); m_to_treat.pop(); }
return *this;
}
/// Postfix ++ operator.
Self operator++(int)
{ Self res=*this; operator ++(); return res; }
protected:
typename Map_::size_type m_mark;
std::stack<Dart_handle> m_to_treat;
};
////////////////////////////////////////////////////////////////////////////////
} // namespace CGAL

View File

@ -1,8 +1,8 @@
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <CGAL/draw_face_graph_with_paths.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/draw_face_graph_with_paths.h>
#include <CGAL/Curves_on_surface_topology.h>
#include <CGAL/Path_on_surface.h>

View File

@ -23,19 +23,18 @@
// Should be defined before to include Path_on_surface_with_rle.h
// If nothing is defined, use V1
#define CGAL_PWRLE_TURN_V1 // Compute turns by turning (method of CMap)
// #define CGAL_PWRLE_TURN_V1 // Compute turns by turning (method of CMap)
// #define CGAL_PWRLE_TURN_V2 // Compute turns by using an id of darts, given by an hash-table (built and given by Curves_on_surface_topology)
// #define CGAL_PWRLE_TURN_V3 // Compute turns by using an id of darts, associated in Info of Darts (build by Curves_on_surface_topology)
#define CGAL_PWRLE_TURN_V3 // Compute turns by using an id of darts, associated in Info of Darts (build by Curves_on_surface_topology)
#include <CGAL/license/Surface_mesh_topology.h>
#include <CGAL/Union_find.h>
#include <CGAL/Random.h>
#include <CGAL/Path_on_surface.h>
#include <CGAL/Surface_mesh_topology/internal/Path_on_surface_with_rle.h>
#include <CGAL/Surface_mesh_topology/internal/Path_generators.h>
#include <CGAL/Combinatorial_map_operations.h>
#include <CGAL/Cell_attribute.h>
#include <CGAL/Random.h>
#include <CGAL/Timer.h>
#include <boost/unordered_map.hpp>
#include <queue>
@ -71,14 +70,8 @@ public:
Dart_handle;
typedef typename CMap_for_minimal_quadrangulation::Dart_const_handle
Dart_const_handle;
typedef CGAL::Union_find<Dart_handle> UFTree;
typedef typename UFTree::handle UFTree_handle;
typedef typename Get_map<Mesh, Mesh>::type Map;
typedef CGAL::Union_find<typename Map::Dart_const_handle> UFTree2;
typedef typename UFTree2::handle UFTree_handle2;
// Associate each dart of the original map, not removed, a pair of darts in the
// reduced map.
typedef boost::unordered_map<typename Map::Dart_const_handle,
@ -91,20 +84,13 @@ public:
Minimal_quadrangulation(const Mesh& amap, bool display_time=false) :
m_original_map(amap)
{
if (!get_map().is_without_boundary(1))
if (!m_original_map.is_without_boundary(1))
{
std::cerr<<"ERROR: the given amap has 1-boundaries; "
<<"such a surface is not possible to process here."
<<std::endl;
return;
}
if (!get_map().is_without_boundary(2))
{
std::cerr<<"ERROR: the given amap has 2-boundaries; "
<<"which are not yet considered (but this will be done later)."
<<std::endl;
return;
}
CGAL::Timer t, t2;
if (display_time)