mirror of https://github.com/CGAL/cgal
* Re-add set_attribute method in CMap class (was removed by error).
* Make functors Is_removable_functor and Is_contractible_functor to avoid a warning.
This commit is contained in:
parent
450a07786b
commit
481908df1f
|
|
@ -47,48 +47,48 @@ int main()
|
||||||
Dart_handle dh2 = make_combinatorial_hexahedron(cm);
|
Dart_handle dh2 = make_combinatorial_hexahedron(cm);
|
||||||
|
|
||||||
// 1) Create all 2-attributes and associated them to darts.
|
// 1) Create all 2-attributes and associated them to darts.
|
||||||
for (CMap_3::Dart_range::iterator
|
for (CMap_3::Dart_range::iterator
|
||||||
it=cm.darts().begin(), itend=cm.darts().end();
|
it=cm.darts().begin(), itend=cm.darts().end();
|
||||||
it!=itend; ++it)
|
it!=itend; ++it)
|
||||||
{
|
{
|
||||||
if ( it->attribute<2>()==NULL )
|
if ( it->attribute<2>()==NULL )
|
||||||
cm.set_attribute<2>(it, cm.create_attribute<2>());
|
cm.set_attribute<2>(it, cm.create_attribute<2>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Set the color of all facets of the first hexahedron to 7.
|
// 2) Set the color of all facets of the first hexahedron to 7.
|
||||||
for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator
|
for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator
|
||||||
it=cm.one_dart_per_incident_cell<2,3>(dh1).begin(),
|
it=cm.one_dart_per_incident_cell<2,3>(dh1).begin(),
|
||||||
itend=cm.one_dart_per_incident_cell<2,3>(dh1).end(); it!=itend; ++it)
|
itend=cm.one_dart_per_incident_cell<2,3>(dh1).end(); it!=itend; ++it)
|
||||||
{ it->attribute<2>()->info()=7; }
|
{ it->attribute<2>()->info()=7; }
|
||||||
|
|
||||||
// 3) Set the color of all facets of the second hexahedron to 13.
|
// 3) Set the color of all facets of the second hexahedron to 13.
|
||||||
for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator it=
|
for (CMap_3::One_dart_per_incident_cell_range<2, 3>::iterator it=
|
||||||
cm.one_dart_per_incident_cell<2,3>(dh2).begin(),
|
cm.one_dart_per_incident_cell<2,3>(dh2).begin(),
|
||||||
itend=cm.one_dart_per_incident_cell<2,3>(dh2).end(); it!=itend; ++it)
|
itend=cm.one_dart_per_incident_cell<2,3>(dh2).end(); it!=itend; ++it)
|
||||||
{ it->attribute<2>()->info()=13; }
|
{ it->attribute<2>()->info()=13; }
|
||||||
|
|
||||||
// 4) 3-Sew the two hexahedra along one facet.
|
// 4) 3-Sew the two hexahedra along one facet.
|
||||||
cm.sew<3>(dh1, dh2);
|
cm.sew<3>(dh1, dh2);
|
||||||
|
|
||||||
// 5) Display all the values of 2-attributes.
|
// 5) Display all the values of 2-attributes.
|
||||||
for (CMap_3::Attribute_range<2>::type::iterator
|
for (CMap_3::Attribute_range<2>::type::iterator
|
||||||
it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end();
|
it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end();
|
||||||
it!=itend; ++it)
|
it!=itend; ++it)
|
||||||
{
|
{
|
||||||
std::cout<<it->info()<<"; ";
|
std::cout<<it->info()<<"; ";
|
||||||
}
|
}
|
||||||
std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
|
|
||||||
// 6) Insert a vertex in the facet between the two hexahedra.
|
// 6) Insert a vertex in the facet between the two hexahedra.
|
||||||
CGAL::insert_cell_0_in_cell_2(cm, dh2);
|
CGAL::insert_cell_0_in_cell_2(cm, dh2);
|
||||||
|
|
||||||
// 7) Display all the values of 2-attributes.
|
// 7) Display all the values of 2-attributes.
|
||||||
for (CMap_3::Attribute_range<2>::type::iterator
|
for (CMap_3::Attribute_range<2>::type::iterator
|
||||||
it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end();
|
it=cm.attributes<2>().begin(), itend=cm.attributes<2>().end();
|
||||||
it!=itend; ++it)
|
it!=itend; ++it)
|
||||||
{
|
{
|
||||||
std::cout<<it->info()<<"; ";
|
std::cout<<it->info()<<"; ";
|
||||||
}
|
}
|
||||||
std::cout<<std::endl;
|
std::cout<<std::endl;
|
||||||
cm.display_characteristics(std::cout);
|
cm.display_characteristics(std::cout);
|
||||||
std::cout<<", valid="<<cm.is_valid()<<std::endl;
|
std::cout<<", valid="<<cm.is_valid()<<std::endl;
|
||||||
|
|
|
||||||
|
|
@ -985,6 +985,20 @@ namespace CGAL {
|
||||||
(mattribute_containers).size();
|
(mattribute_containers).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set the i th attribute of all the darts of a given i-cell.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @param ah the vertex to set.
|
||||||
|
*/
|
||||||
|
template<unsigned int i>
|
||||||
|
void set_attribute(Dart_handle adart,
|
||||||
|
typename Attribute_handle<i>::type ah)
|
||||||
|
{
|
||||||
|
CGAL_static_assertion(i<=dimension);
|
||||||
|
CGAL_static_assertion_msg(Helper::template Dimension_index<i>::value>=0,
|
||||||
|
"set_attribute<i> but i-attributes are disabled");
|
||||||
|
Set_i_attribute_functor<Self,i>::run(this, adart, ah);
|
||||||
|
}
|
||||||
|
|
||||||
/// @return a Attributes_range<i> (range through all the
|
/// @return a Attributes_range<i> (range through all the
|
||||||
/// attributes<i> of the map).
|
/// attributes<i> of the map).
|
||||||
template<unsigned int i>
|
template<unsigned int i>
|
||||||
|
|
|
||||||
|
|
@ -126,10 +126,6 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
|
||||||
while ( !first->template is_free<0>() && first->template beta<0>()!=adart )
|
while ( !first->template is_free<0>() && first->template beta<0>()!=adart )
|
||||||
first = first->template beta<0>();
|
first = first->template beta<0>();
|
||||||
|
|
||||||
// Stack of couple of dart and dimension for which
|
|
||||||
// we must call on_split functor
|
|
||||||
std::deque<typename CMap::Dart_handle> modified_darts;
|
|
||||||
|
|
||||||
// Mark used to mark darts already treated.
|
// Mark used to mark darts already treated.
|
||||||
int treated = amap.get_new_mark();
|
int treated = amap.get_new_mark();
|
||||||
|
|
||||||
|
|
@ -203,7 +199,6 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
|
||||||
(nn1, prev->beta(dim));
|
(nn1, prev->beta(dim));
|
||||||
|
|
||||||
amap.mark(cur->beta(dim), treated);
|
amap.mark(cur->beta(dim), treated);
|
||||||
tounmark.push_back(cur->beta(dim));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -240,7 +235,11 @@ insert_cell_0_in_cell_2( CMap& amap, typename CMap::Dart_handle adart,
|
||||||
itd=tounmark.begin(); itd!=tounmark.end(); ++itd )
|
itd=tounmark.begin(); itd!=tounmark.end(); ++itd )
|
||||||
{
|
{
|
||||||
amap.unmark(*itd, treated);
|
amap.unmark(*itd, treated);
|
||||||
|
for (unsigned int dim=3; dim<=CMap::dimension; ++dim)
|
||||||
|
{
|
||||||
|
if ( !(*itd)->is_free(dim) )
|
||||||
|
amap.unmark((*itd)->beta(dim), treated);
|
||||||
|
}
|
||||||
if ( *itd!=adart )
|
if ( *itd!=adart )
|
||||||
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
|
CGAL::internal::Degroup_attribute_functor_run<CMap, 2>::
|
||||||
run(&amap, adart, *itd);
|
run(&amap, adart, *itd);
|
||||||
|
|
@ -300,9 +299,9 @@ insert_dangling_cell_1_in_cell_2( CMap& amap,
|
||||||
if ( !it1->is_free(s1) )
|
if ( !it1->is_free(s1) )
|
||||||
{
|
{
|
||||||
if ( s1==0 )
|
if ( s1==0 )
|
||||||
amap.template link_beta_1(it1->template beta<0>(), d2);
|
amap.link_beta_1(it1->template beta<0>(), d2);
|
||||||
else
|
else
|
||||||
amap.template link_beta_0(it1->template beta<1>(), d2);
|
amap.link_beta_0(it1->template beta<1>(), d2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s1==0)
|
if (s1==0)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,43 @@ namespace CGAL
|
||||||
* Some operations to modify a combinatorial map.
|
* Some operations to modify a combinatorial map.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** Test if an i-cell can be removed.
|
||||||
|
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1,
|
||||||
|
* or if there are at most two (i+1)-cell incident to it.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @return true iff the i-cell can be removed.
|
||||||
|
*/
|
||||||
|
template <class CMap, unsigned int i, unsigned int nmi=CMap::dimension-i>
|
||||||
|
struct Is_removable_functor
|
||||||
|
{
|
||||||
|
static bool run(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||||
|
{
|
||||||
|
// TODO? Optimisation for dim-2, and to not test all the darts of the cell?
|
||||||
|
bool res = true;
|
||||||
|
for ( CGAL::CMap_dart_const_iterator_of_cell<CMap,i> it(amap, adart);
|
||||||
|
res && it.cont(); ++it )
|
||||||
|
{
|
||||||
|
if (it->template beta<i+2>()->template beta<i+1>()!=
|
||||||
|
it->template beta_inv<i+1>()->template beta<i+2>() )
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for i=CMap::dimension
|
||||||
|
template <class CMap, unsigned int i>
|
||||||
|
struct Is_removable_functor<CMap, i, 0>
|
||||||
|
{
|
||||||
|
static bool run(const CMap&, typename CMap::Dart_const_handle)
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
|
// Specialization for i=CMap::dimension-1
|
||||||
|
template <class CMap, unsigned int i>
|
||||||
|
struct Is_removable_functor<CMap, i, 1>
|
||||||
|
{
|
||||||
|
static bool run(const CMap&, typename CMap::Dart_const_handle)
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
/** Test if an i-cell can be removed.
|
/** Test if an i-cell can be removed.
|
||||||
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1,
|
* An i-cell can be removed if i==CMap::dimension or i==CMap::dimension-1,
|
||||||
* or if there are at most two (i+1)-cell incident to it.
|
* or if there are at most two (i+1)-cell incident to it.
|
||||||
|
|
@ -39,24 +76,7 @@ namespace CGAL
|
||||||
*/
|
*/
|
||||||
template < class CMap, unsigned int i >
|
template < class CMap, unsigned int i >
|
||||||
bool is_removable(const CMap& amap, typename CMap::Dart_const_handle adart)
|
bool is_removable(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||||
{
|
{ return CGAL::Is_removable_functor<CMap, i>::run(amap,adart); }
|
||||||
CGAL_assertion( adart!=NULL );
|
|
||||||
CGAL_static_assertion( 0<=i && i<=CMap::dimension );
|
|
||||||
|
|
||||||
if ( i==CMap::dimension ) return true;
|
|
||||||
if ( i==CMap::dimension-1 ) return true;
|
|
||||||
|
|
||||||
// TODO? Optimisation for dim-2, and to not test all the darts of the cell?
|
|
||||||
bool res = true;
|
|
||||||
for ( CGAL::CMap_dart_const_iterator_of_cell<CMap,i> it(amap, adart);
|
|
||||||
res && it.cont(); ++it )
|
|
||||||
{
|
|
||||||
if (it->template beta<i+2>()->template beta<i+1>()!=
|
|
||||||
it->template beta_inv<i+1>()->template beta<i+2>() )
|
|
||||||
res = false;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Remove an i-cell, 0<i<dimension, and merge eventually both incident
|
/** Remove an i-cell, 0<i<dimension, and merge eventually both incident
|
||||||
* (i+1)-cells.
|
* (i+1)-cells.
|
||||||
|
|
@ -425,6 +445,43 @@ namespace CGAL
|
||||||
CGAL::Remove_cell_functor<CMap,i,CMap::dimension-i>::run(amap,adart);
|
CGAL::Remove_cell_functor<CMap,i,CMap::dimension-i>::run(amap,adart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Test if an i-cell can be contracted.
|
||||||
|
* An i-cell can be contracted if i==1
|
||||||
|
* or if there are at most two (i-1)-cell incident to it.
|
||||||
|
* @param adart a dart of the i-cell.
|
||||||
|
* @return true iff the i-cell can be contracted.
|
||||||
|
*/
|
||||||
|
template <class CMap, unsigned int i>
|
||||||
|
struct Is_contractible_functor
|
||||||
|
{
|
||||||
|
static bool run(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||||
|
{
|
||||||
|
// TODO ? Optimisation possible to not test all the darts of the cell ?
|
||||||
|
bool res = true;
|
||||||
|
for ( CGAL::CMap_dart_const_iterator_of_cell<CMap,i> it(amap, adart);
|
||||||
|
res && it.cont(); ++it )
|
||||||
|
{
|
||||||
|
if ( it->template beta<i-2>()->template beta<i-1>()!=
|
||||||
|
it->template beta<i-1>()->template beta_inv<i-2>() )
|
||||||
|
res = false;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Specialization for i=0
|
||||||
|
template <class CMap>
|
||||||
|
struct Is_contractible_functor<CMap, 0>
|
||||||
|
{
|
||||||
|
static bool run(const CMap&, typename CMap::Dart_const_handle)
|
||||||
|
{ return false; }
|
||||||
|
};
|
||||||
|
// Specialization for i=1
|
||||||
|
template <class CMap>
|
||||||
|
struct Is_contractible_functor<CMap, 1>
|
||||||
|
{
|
||||||
|
static bool run(const CMap&, typename CMap::Dart_const_handle)
|
||||||
|
{ return true; }
|
||||||
|
};
|
||||||
/** Test if an i-cell can be contracted.
|
/** Test if an i-cell can be contracted.
|
||||||
* An i-cell can be contracted if i==1
|
* An i-cell can be contracted if i==1
|
||||||
* or if there are at most two (i-1)-cell incident to it.
|
* or if there are at most two (i-1)-cell incident to it.
|
||||||
|
|
@ -433,24 +490,7 @@ namespace CGAL
|
||||||
*/
|
*/
|
||||||
template < class CMap, unsigned int i >
|
template < class CMap, unsigned int i >
|
||||||
bool is_contractible(const CMap& amap, typename CMap::Dart_const_handle adart)
|
bool is_contractible(const CMap& amap, typename CMap::Dart_const_handle adart)
|
||||||
{
|
{ return CGAL::Is_contractible_functor<CMap, i>::run(amap,adart); }
|
||||||
CGAL_assertion(adart != NULL);
|
|
||||||
CGAL_static_assertion(0<=i && i<=CMap::dimension);
|
|
||||||
|
|
||||||
if ( i==0 ) return false;
|
|
||||||
if ( i==1 ) return true;
|
|
||||||
|
|
||||||
// TODO ? Optimisation possible to not test all the darts of the cell ?
|
|
||||||
bool res = true;
|
|
||||||
for ( CGAL::CMap_dart_const_iterator_of_cell<CMap,i> it(amap, adart);
|
|
||||||
res && it.cont(); ++it )
|
|
||||||
{
|
|
||||||
if ( it->template beta<i-2>()->template beta<i-1>()!=
|
|
||||||
it->template beta<i-1>()->template beta_inv<i-2>() )
|
|
||||||
res = false;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Contract an i-cell, 1<i<=dimension, and merge eventually both incident
|
/** Contract an i-cell, 1<i<=dimension, and merge eventually both incident
|
||||||
* (i-1)-cells.
|
* (i-1)-cells.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue