mirror of https://github.com/CGAL/cgal
Bug fix in dual for lcc
This commit is contained in:
parent
836ac4ac72
commit
2c4c73c6b9
|
|
@ -3381,22 +3381,23 @@ namespace CGAL {
|
|||
{
|
||||
CGAL_assertion( is_without_boundary(dimension) );
|
||||
|
||||
CGAL::Unique_hash_map< Dart_handle, Dart_handle,
|
||||
typename Self::Hash_function > dual(Dart_handle(), darts().size());
|
||||
CGAL::Unique_hash_map<Dart_handle, Dart_handle,
|
||||
typename Self::Hash_function>
|
||||
dual(Dart_handle(), darts().size());
|
||||
Dart_handle d, d2, res = amap.null_handle;
|
||||
|
||||
// We clear amap. TODO return a new amap ?
|
||||
amap.clear();
|
||||
|
||||
// We create a copy of all the dart of the map.
|
||||
for ( typename Dart_range::iterator it=darts().begin();
|
||||
it!=darts().end(); ++it)
|
||||
for (typename Dart_range::iterator it=darts().begin();
|
||||
it!=darts().end(); ++it)
|
||||
{
|
||||
dual[it] = amap.create_dart();
|
||||
dual[it]=amap.create_dart();
|
||||
internal::Copy_dart_info_functor<Refs, Refs>::
|
||||
run(static_cast<Refs&>(amap), static_cast<Refs&>(*this),
|
||||
it, dual[it]);
|
||||
if ( it==adart && res==amap.null_handle ) res = dual[it];
|
||||
if (it==adart && res==amap.null_handle) { res=dual[it]; }
|
||||
}
|
||||
|
||||
// Then we link the darts by using the dual formula :
|
||||
|
|
@ -3407,20 +3408,20 @@ namespace CGAL {
|
|||
for ( typename Dart_range::iterator it=darts().begin();
|
||||
it!=darts().end(); ++it, ++it2)
|
||||
{
|
||||
d = it2; // The supposition on the order allows to avoid d=dual[it];
|
||||
d=it2; // The supposition on the order allows to avoid d=dual[it];
|
||||
CGAL_assertion( it2==dual[it] );
|
||||
|
||||
// First case outside the loop since we need to use link_beta1
|
||||
if ( amap.template is_free<1>(d) &&
|
||||
beta<dimension, dimension-1>(it)!=null_dart_handle )
|
||||
amap.basic_link_beta_1(d, dual[beta<dimension, dimension-1>(it)]);
|
||||
{ amap.basic_link_beta_1(d, dual[beta<dimension, dimension-1>(it)]); }
|
||||
|
||||
// and during the loop we use link_beta(d1,d2,i)
|
||||
for ( unsigned int i=dimension-2; i>=1; --i)
|
||||
{
|
||||
if ( amap.is_free(d,dimension-i) &&
|
||||
beta(it, dimension, i)!=null_dart_handle )
|
||||
amap.basic_link_beta(d, dual[beta(it, dimension, i)], dimension-i);
|
||||
{ amap.basic_link_beta(d, dual[beta(it, dimension, i)], dimension-i); }
|
||||
}
|
||||
if ( amap.template is_free<dimension>(d) )
|
||||
{
|
||||
|
|
@ -3429,7 +3430,7 @@ namespace CGAL {
|
|||
}
|
||||
}
|
||||
|
||||
if ( res==amap.null_handle ) res = amap.darts().begin();
|
||||
if ( res==amap.null_handle ) { res=amap.darts().begin(); }
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -117,15 +117,19 @@ namespace CGAL {
|
|||
Dart_range(Self &amap) : mmap(amap)
|
||||
{}
|
||||
iterator begin()
|
||||
{ iterator res=mmap.mdarts.begin(); ++res; return res; }
|
||||
{
|
||||
CGAL_assertion(!mmap.mdarts.empty()); // The container mdarts is not empty
|
||||
// it has at least the null_dart
|
||||
iterator res=mmap.mdarts.begin(); ++res; return res;
|
||||
}
|
||||
iterator end() { return mmap.mdarts.end(); }
|
||||
const_iterator begin() const
|
||||
{ const_iterator res=mmap.mdarts.begin(); ++res; return res; }
|
||||
const_iterator end() const { return mmap.mdarts.end(); }
|
||||
size_type size()
|
||||
size_type size() const
|
||||
{ return mmap.mdarts.size()-1; }
|
||||
bool empty() const
|
||||
{ return size()==0; } // is_empty(); }
|
||||
{ return size()==0; } // mmap.is_empty(); }
|
||||
size_type index(Dart_index idx) const
|
||||
{ return idx; }
|
||||
size_type index(const_iterator cit) const
|
||||
|
|
@ -146,7 +150,7 @@ namespace CGAL {
|
|||
void init_storage()
|
||||
{
|
||||
// Allocate a dart for null_dart_handle
|
||||
assert(mdarts.empty());
|
||||
assert(mdarts.empty()); // the compact container is empty
|
||||
Dart_index local_null_dart_handle = mdarts.emplace();
|
||||
if(local_null_dart_handle!=0)
|
||||
{
|
||||
|
|
@ -163,11 +167,11 @@ namespace CGAL {
|
|||
* @return true iff the map is empty.
|
||||
*/
|
||||
bool is_empty() const
|
||||
{ return this->mdarts.size()==1; }
|
||||
{ return darts().empty(); }
|
||||
|
||||
/// @return the number of darts.
|
||||
size_type number_of_darts() const
|
||||
{ return mdarts.size()-1; }
|
||||
{ return darts().size(); }
|
||||
|
||||
/** Return if this dart is free for adimension.
|
||||
* @param dh a dart handle
|
||||
|
|
|
|||
|
|
@ -136,12 +136,16 @@ namespace CGAL {
|
|||
Dart_range(Self &amap) : mmap(amap)
|
||||
{}
|
||||
iterator begin()
|
||||
{ iterator res=mmap.mdarts.begin(); ++res; return res; }
|
||||
{
|
||||
CGAL_assertion(!mmap.mdarts.empty()); // The container mdarts is not empty
|
||||
// it has at least the null_dart
|
||||
iterator res=mmap.mdarts.begin(); ++res; return res;
|
||||
}
|
||||
iterator end() { return mmap.mdarts.end(); }
|
||||
const_iterator begin() const
|
||||
{ const_iterator res=mmap.mdarts.begin(); ++res; return res; }
|
||||
const_iterator end() const { return mmap.mdarts.end(); }
|
||||
size_type size()
|
||||
size_type size() const
|
||||
{ return mmap.mdarts.size()-1; }
|
||||
bool empty() const
|
||||
{ return size()==0; } // mmap.is_empty(); }
|
||||
|
|
@ -165,7 +169,7 @@ namespace CGAL {
|
|||
void init_storage()
|
||||
{
|
||||
// Allocate a dart for null_dart_handle
|
||||
assert(mdarts.empty());
|
||||
assert(mdarts.empty()); // the compact container is empty
|
||||
Dart_index local_null_dart_handle = mdarts.emplace();
|
||||
if(local_null_dart_handle!=0)
|
||||
{
|
||||
|
|
@ -182,11 +186,11 @@ namespace CGAL {
|
|||
* @return true iff the map is empty.
|
||||
*/
|
||||
bool is_empty() const
|
||||
{ return this->mdarts.size()==1; }
|
||||
{ return darts().empty(); }
|
||||
|
||||
/// @return the number of darts.
|
||||
size_type number_of_darts() const
|
||||
{ return mdarts.size()-1; }
|
||||
{ return darts().size(); }
|
||||
|
||||
/** Return if this dart is free for adimension.
|
||||
* @param dh a dart handle
|
||||
|
|
|
|||
|
|
@ -815,22 +815,22 @@ namespace CGAL {
|
|||
*/
|
||||
Dart_handle dual_points_at_barycenter(Self & alcc, Dart_handle adart=null_handle)
|
||||
{
|
||||
Dart_handle res = Base::dual(alcc, adart);
|
||||
Dart_handle res=Base::dual(alcc, adart);
|
||||
|
||||
// Now the lcc alcc is topologically correct, we just need to add
|
||||
// its geometry to each vertex (the barycenter of the corresponding
|
||||
// dim-cell in the initial map).
|
||||
typename Dart_range::iterator it2 = alcc.darts().begin();
|
||||
typename Dart_range::iterator it2=alcc.darts().begin();
|
||||
for (typename Dart_range::iterator it(darts().begin());
|
||||
it!=darts().end(); ++it, ++it2)
|
||||
{
|
||||
if (vertex_attribute(it2)==null_handle)
|
||||
if (alcc.vertex_attribute(it2)==null_handle)
|
||||
{
|
||||
alcc.set_vertex_attribute(it2, alcc.create_vertex_attribute
|
||||
(barycenter<dimension>(it)));
|
||||
}
|
||||
}
|
||||
CGAL_assertion( is_valid() );
|
||||
CGAL_expensive_assertion(alcc.is_valid());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue