Fixed pending VC8 STL iterator issues

This commit is contained in:
Fernando Cacciola 2007-02-06 14:14:16 +00:00
parent 70c736d388
commit f91efc4810
5 changed files with 88 additions and 69 deletions

View File

@ -1958,15 +1958,26 @@ public:
CGAL_NEF_TRACEN(""); CGAL_NEF_TRACEN("");
} }
std::vector<Vertex_iterator> vertices_to_delete ;
Vertex_iterator v; Vertex_iterator v;
CGAL_forall_vertices(v, *this->sncp()) CGAL_forall_vertices(v, *this->sncp())
if(erase_vertex[v]) { {
CGAL_NEF_TRACEN("erase " << v->point()); if(erase_vertex[v])
if(Infi_box::is_infibox_corner(v->point())) {
recreate.push_back(v->point()); CGAL_NEF_TRACEN("erase " << v->point());
this->sncp()->delete_vertex(v); if(Infi_box::is_infibox_corner(v->point()))
res = true; recreate.push_back(v->point());
} vertices_to_delete.push_back(v);
res = true;
}
}
for( typename std::vector<Vertex_iterator>::iterator vit = vertices_to_delete.begin()
; vit != vertices_to_delete.end()
; ++ vit
)
this->sncp()->delete_vertex(*vit);
typename std::list<Point_3>::const_iterator pi; typename std::list<Point_3>::const_iterator pi;
for(pi = recreate.begin(); pi != recreate.end(); ++pi) for(pi = recreate.begin(); pi != recreate.end(); ++pi)

View File

@ -1459,8 +1459,8 @@ class SNC_decorator : public SNC_const_decorator<Map> {
Shell_entry_iterator si; Shell_entry_iterator si;
CGAL_forall_shells_of(si,voli) { CGAL_forall_shells_of(si,voli) {
valid = valid && (si != Shell_entry_iterator() && //valid = valid && (si != Shell_entry_iterator() &&
SFace_handle(si) != SFace_handle() && valid = valid && (SFace_handle(si) != SFace_handle() &&
SFace_handle(si) != NULL); SFace_handle(si) != NULL);
valid = valid && (++count <= max); valid = valid && (++count <= max);
} }

View File

@ -1079,13 +1079,13 @@ void SNC_io_parser<EW>::read()
addInfiBox = (kernel_type == "standard" && Infi_box::extended_kernel()); addInfiBox = (kernel_type == "standard" && Infi_box::extended_kernel());
if(addInfiBox) { if(addInfiBox) {
Vertex_of.reserve(vn+8); Vertex_of.resize(vn+8);
Edge_of.reserve(en+24); Edge_of.resize(en+24);
Halffacet_of.reserve(fn+12); Halffacet_of.resize(fn+12);
Volume_of.reserve(cn+1); Volume_of.resize(cn+1);
SEdge_of.reserve(sen+48); SEdge_of.resize(sen+48);
SLoop_of.reserve(sln); SLoop_of.resize(sln);
SFace_of.reserve(sfn+16); SFace_of.resize(sfn+16);
for(i=0; i<vn+8; ++i) Vertex_of[i] = this->sncp()->new_vertex_only(); for(i=0; i<vn+8; ++i) Vertex_of[i] = this->sncp()->new_vertex_only();
for(i=0; i<en+24; ++i) Edge_of[i] = this->sncp()->new_halfedge_only(); for(i=0; i<en+24; ++i) Edge_of[i] = this->sncp()->new_halfedge_only();
for(i=0; i<fn+12; ++i) Halffacet_of[i] = this->sncp()->new_halffacet_only(); for(i=0; i<fn+12; ++i) Halffacet_of[i] = this->sncp()->new_halffacet_only();
@ -1095,13 +1095,13 @@ void SNC_io_parser<EW>::read()
for(i=0; i<sfn+16; ++i) SFace_of[i] = this->sncp()->new_sface_only(); for(i=0; i<sfn+16; ++i) SFace_of[i] = this->sncp()->new_sface_only();
} }
else { else {
Vertex_of.reserve(vn); Vertex_of.resize(vn);
Edge_of.reserve(en); Edge_of.resize(en);
Halffacet_of.reserve(fn); Halffacet_of.resize(fn);
Volume_of.reserve(cn); Volume_of.resize(cn);
SEdge_of.reserve(sen); SEdge_of.resize(sen);
SLoop_of.reserve(sln); SLoop_of.resize(sln);
SFace_of.reserve(sfn); SFace_of.resize(sfn);
for(i=0; i<vn; ++i) Vertex_of[i] = this->sncp()->new_vertex_only(); for(i=0; i<vn; ++i) Vertex_of[i] = this->sncp()->new_vertex_only();
for(i=0; i<en; ++i) Edge_of[i] = this->sncp()->new_halfedge_only(); for(i=0; i<en; ++i) Edge_of[i] = this->sncp()->new_halfedge_only();
for(i=0; i<fn; ++i) Halffacet_of[i] = this->sncp()->new_halffacet_only(); for(i=0; i<fn; ++i) Halffacet_of[i] = this->sncp()->new_halffacet_only();

View File

@ -156,29 +156,36 @@ class SNC_simplify : public SNC_decorator<SNC_structure> {
if(fc.is_shalfedge() ) { if(fc.is_shalfedge() ) {
SHalfedge_handle e(fc); SHalfedge_handle e(fc);
SHalfedge_around_facet_circulator u(e), eend(e); SHalfedge_around_facet_circulator u(e), eend(e);
CGAL_For_all(u, eend) {
SFace_handle fu = u->incident_sface(), ftu = u->twin()->incident_sface(); //CGAL_For_all(u, eend) {
CGAL_NEF_TRACEN("sfUNION of "<<IO->index(fu)<<" & "<<IO->index(ftu)); for ( bool _circ_loop_flag = ! ::CGAL::is_empty_range( u, eend);
merge_sets( fu, ftu, hash, uf); _circ_loop_flag; \
SM_decorator SD(&*u->source()->source()); _circ_loop_flag = ( u != eend )
CGAL_NEF_TRACEN("removing "<<IO->index(u)<<" & "<<IO->index(u->twin())); )
Halfedge_handle src(u->source()), tgt(u->target()); {
if ( SD.is_closed_at_source(u) ) SFace_handle fu = u->incident_sface(), ftu = u->twin()->incident_sface();
SD.set_face( src, fu); CGAL_NEF_TRACEN("sfUNION of "<<IO->index(fu)<<" & "<<IO->index(ftu));
if ( SD.is_closed_at_source( u->twin()) ) merge_sets( fu, ftu, hash, uf);
SD.set_face( tgt, fu); SM_decorator SD(&*u->source()->source());
CGAL_NEF_TRACEN("removing "<<IO->index(u)<<" & "<<IO->index(u->twin()));
Halfedge_handle src(u->source()), tgt(u->target());
if ( SD.is_closed_at_source(u) )
SD.set_face( src, fu);
if ( SD.is_closed_at_source( u->twin()) )
SD.set_face( tgt, fu);
/* TO VERIFY: does is_closed_at_source(u) imply is_isolated(src)? /* TO VERIFY: does is_closed_at_source(u) imply is_isolated(src)?
if it is true, the svertex face update is not necesary. */ if it is true, the svertex face update is not necesary. */
SD.delete_edge_pair(u); SHalfedge_around_facet_circulator next = u ;
if( SD.is_isolated(src)) ++ next ;
// SD.delete_vertex_only(src); SD.delete_edge_pair(u);
SD.set_face(src,fu); if( SD.is_isolated(src))
SM_decorator SD2(&*tgt->source()); SD.set_face(src,fu);
if( SD2.is_isolated(tgt)) SM_decorator SD2(&*tgt->source());
// SD.delete_vertex_only(tgt); if( SD2.is_isolated(tgt))
SD2.set_face(tgt,fu); SD2.set_face(tgt,fu);
u = next ;
/* TO VERIFY: can both svertices be isolated at the same time? */ /* TO VERIFY: can both svertices be isolated at the same time? */
} }
} }
else if(fc.is_shalfloop()) { else if(fc.is_shalfloop()) {
SHalfloop_handle l(fc); SHalfloop_handle l(fc);
@ -458,9 +465,10 @@ class SNC_simplify : public SNC_decorator<SNC_structure> {
CGAL_NEF_TRACEN("s2 = " << IO->index(s2)); CGAL_NEF_TRACEN("s2 = " << IO->index(s2));
if( s1 == s2) { if( s1 == s2) {
CGAL_NEF_TRACEN(IO->index(s1)<<'('<<IO->index(s2->twin())<<") to sloop"); CGAL_NEF_TRACEN(IO->index(s1)<<'('<<IO->index(s2->twin())<<") to sloop");
Halffacet_handle facet = s1->facet();
SD.convert_edge_to_loop(s1); SD.convert_edge_to_loop(s1);
CGAL_assertion(SD.shalfloop() != SHalfloop_handle()); CGAL_assertion(SD.shalfloop() != SHalfloop_handle());
D.add_sloop_to_facet( SD.shalfloop(), s1->facet()); D.add_sloop_to_facet( SD.shalfloop(), facet);
CGAL_NEF_TRACEN(IO->index(s2)<<" removed"); CGAL_NEF_TRACEN(IO->index(s2)<<" removed");
} }
else { else {

View File

@ -40,6 +40,9 @@
#include <CGAL/Nef_2/debug.h> #include <CGAL/Nef_2/debug.h>
#include <CGAL/Nef_2/Object_index.h> #include <CGAL/Nef_2/Object_index.h>
#include <boost/optional.hpp>
#include <boost/none.hpp>
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
template <typename HE> template <typename HE>
@ -691,13 +694,13 @@ public:
expensive operation.}*/ expensive operation.}*/
SNC_structure() : SNC_structure() :
boundary_item_(undef_), sm_boundary_item_(undef_), boundary_item_(boost::none), sm_boundary_item_(boost::none),
vertices_(), halfedges_(), halffacets_(), volumes_(), vertices_(), halfedges_(), halffacets_(), volumes_(),
shalfedges_(), shalfloops_(), sfaces_() {} shalfedges_(), shalfloops_(), sfaces_() {}
~SNC_structure() { CGAL_NEF_TRACEN("~SNC_structure: clearing "<<this); clear(); } ~SNC_structure() { CGAL_NEF_TRACEN("~SNC_structure: clearing "<<this); clear(); }
SNC_structure(const Self& D) : SNC_structure(const Self& D) :
boundary_item_(undef_), sm_boundary_item_(undef_), boundary_item_(boost::none), sm_boundary_item_(boost::none),
vertices_(D.vertices_), halfedges_(D.halfedges_), vertices_(D.vertices_), halfedges_(D.halfedges_),
halffacets_(D.halffacets_), volumes_(D.volumes_), halffacets_(D.halffacets_), volumes_(D.volumes_),
shalfedges_(D.shalfedges_), shalfloops_(D.shalfloops_), shalfedges_(D.shalfedges_), shalfloops_(D.shalfloops_),
@ -708,8 +711,8 @@ public:
if ( this == &D ) if ( this == &D )
return *this; return *this;
clear(); clear();
boundary_item_.clear(undef_); boundary_item_.clear(boost::none);
sm_boundary_item_.clear(undef_); sm_boundary_item_.clear(boost::none);
vertices_ = D.vertices_; vertices_ = D.vertices_;
halfedges_ = D.halfedges_; halfedges_ = D.halfedges_;
halffacets_ = D.halffacets_; halffacets_ = D.halffacets_;
@ -722,17 +725,17 @@ public:
} }
void clear_boundary() { void clear_boundary() {
boundary_item_.clear(undef_); boundary_item_.clear(boost::none);
sm_boundary_item_.clear(undef_); sm_boundary_item_.clear(boost::none);
} }
void clear_snc_boundary() { void clear_snc_boundary() {
boundary_item_.clear(undef_); boundary_item_.clear(boost::none);
} }
void clear() { void clear() {
boundary_item_.clear(undef_); boundary_item_.clear(boost::none);
sm_boundary_item_.clear(undef_); sm_boundary_item_.clear(boost::none);
vertices_.destroy(); vertices_.destroy();
halfedges_.destroy(); halfedges_.destroy();
halffacets_.destroy(); halffacets_.destroy();
@ -744,17 +747,17 @@ public:
template <typename H> template <typename H>
bool is_boundary_object(H h) bool is_boundary_object(H h)
{ return boundary_item_[h]!=undef_; } { return boundary_item_[h]!=boost::none; }
template <typename H> template <typename H>
bool is_sm_boundary_object(H h) bool is_sm_boundary_object(H h)
{ return sm_boundary_item_[h]!=undef_; } { return sm_boundary_item_[h]!=boost::none; }
template <typename H> template <typename H>
Object_iterator& boundary_item(H h) Object_iterator& boundary_item(H h)
{ return boundary_item_[h]; } { return *boundary_item_[h]; }
template <typename H> template <typename H>
Object_iterator& sm_boundary_item(H h) Object_iterator& sm_boundary_item(H h)
{ return sm_boundary_item_[h]; } { return *sm_boundary_item_[h]; }
template <typename H> template <typename H>
void store_boundary_item(H h, Object_iterator o) void store_boundary_item(H h, Object_iterator o)
@ -765,12 +768,12 @@ public:
template <typename H> template <typename H>
void undef_boundary_item(H h) void undef_boundary_item(H h)
{ CGAL_assertion(boundary_item_[h]!=undef_); { CGAL_assertion(boundary_item_[h]!=boost::none);
boundary_item_[h] = undef_; } boundary_item_[h] = boost::none; }
template <typename H> template <typename H>
void undef_sm_boundary_item(H h) void undef_sm_boundary_item(H h)
{ CGAL_assertion(sm_boundary_item_[h]!=undef_); { CGAL_assertion(sm_boundary_item_[h]!=boost::none);
sm_boundary_item_[h] = undef_; } sm_boundary_item_[h] = boost::none; }
void reset_iterator_hash(Object_iterator it) void reset_iterator_hash(Object_iterator it)
{ SVertex_handle sv; { SVertex_handle sv;
@ -1335,9 +1338,11 @@ public:
protected: protected:
void pointer_update(const Self& D); void pointer_update(const Self& D);
static Object_iterator undef_;
Generic_handle_map<Object_iterator> boundary_item_; typedef boost::optional<Object_iterator> Optional_object_iterator ;
Generic_handle_map<Object_iterator> sm_boundary_item_;
Generic_handle_map<Optional_object_iterator> boundary_item_;
Generic_handle_map<Optional_object_iterator> sm_boundary_item_;
Vertex_list vertices_; Vertex_list vertices_;
Halfedge_list halfedges_; Halfedge_list halfedges_;
@ -1483,10 +1488,5 @@ pointer_update(const SNC_structure<Kernel,Items,Mark>& D)
} }
} }
template <typename Kernel, typename Items, typename Mark>
typename SNC_structure<Kernel, Items, Mark>::Object_iterator
SNC_structure<Kernel,Items,Mark>::undef_;
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_SNC_STRUCTURE_H #endif // CGAL_SNC_STRUCTURE_H