BWAPI
|
00001 // Copyright (c) 1997-2000 Max-Planck-Institute Saarbruecken (Germany). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you may redistribute it under 00005 // the terms of the Q Public License version 1.0. 00006 // See the file LICENSE.QPL distributed with CGAL. 00007 // 00008 // Licensees holding a valid commercial license may use this file in 00009 // accordance with the commercial license agreement provided with the software. 00010 // 00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 // 00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Nef_S2/include/CGAL/Nef_S2/Sphere_map.h $ 00015 // $Id: Sphere_map.h 45448 2008-09-09 16:03:25Z spion $ 00016 // 00017 // 00018 // Author(s) : Michael Seel <seel@mpi-sb.mpg.de> 00019 // Peter Hachenberger <hachenberger@mpi-sb.mpg.de> 00020 00021 #ifndef CGAL_SPHERE_MAP_H 00022 #define CGAL_SPHERE_MAP_H 00023 00024 #include <CGAL/basic.h> 00025 #include <CGAL/Unique_hash_map.h> 00026 #include <CGAL/Nef_2/Object_handle.h> 00027 #include <CGAL/Nef_S2/SM_items.h> 00028 #include <CGAL/Nef_S2/SM_list.h> 00029 #include <CGAL/Nef_S2/SM_iteration.h> 00030 #include <CGAL/Nef_S2/Generic_handle_map.h> 00031 #include <CGAL/Nef_2/iterator_tools.h> 00032 #include <list> 00033 #undef CGAL_NEF_DEBUG 00034 #define CGAL_NEF_DEBUG 109 00035 #include <CGAL/Nef_2/debug.h> 00036 00037 #include<boost/optional.hpp> 00038 #include<boost/none.hpp> 00039 00040 CGAL_BEGIN_NAMESPACE 00041 00042 template <typename HE> 00043 class move_edge_around_svertex { 00044 public: 00045 void forward(HE& e) const { e = (e->sprev()->twin()); } 00046 void backward(HE& e) const { e = (e->twin()->snext()); } 00047 }; 00048 00049 template <typename HE> 00050 struct move_edge_around_sface { 00051 void forward(HE& e) const { e = (e->snext()); } 00052 void backward(HE& e) const { e = (e->sprev()); } 00053 }; 00054 00055 /*{\Manpage {Sphere_map}{Kernel}{Sphere Maps}{M}}*/ 00056 00057 template <typename Kernel_, typename Items_, typename Mark_> 00058 class Sphere_map { 00059 00060 /*{\Mdefinition selective sphere map container based on 00061 the HDS design of Kettner.}*/ 00062 00063 public: 00064 /*{\Mtypes 7}*/ 00065 typedef Sphere_map<Kernel_, Items_,Mark_> Self; 00066 typedef Kernel_ Sphere_kernel; 00067 typedef Items_ Items; 00068 typedef Mark_ Mark; 00069 00070 friend class SM_const_decorator<Self>; 00071 friend class SM_decorator<Self>; 00072 00073 typedef typename Sphere_kernel::Sphere_point Sphere_point; 00074 /*{\Mtypemember points on the unit sphere.}*/ 00075 typedef typename Sphere_kernel::Sphere_segment Sphere_segment; 00076 /*{\Mtypemember segments on the unit sphere.}*/ 00077 typedef typename Sphere_kernel::Sphere_circle Sphere_circle; 00078 /*{\Mtypemember segments on the unit sphere.}*/ 00079 typedef typename Sphere_kernel::Sphere_direction Sphere_direction; 00080 /*{\Mtypemember directions on the unit sphere.}*/ 00081 // typedef bool Mark; 00082 /*{\Mtypemember selective attributes of all objects.}*/ 00083 typedef size_t Size_type; 00084 /*{\Mtypemember size type.}*/ 00085 00086 /*{\Mtext For all objects |Vertex|, |Halfedge|, |Halfloop|, |Face| 00087 there are handle and iterator types |xxx_handle|, |xxx_iterator|. 00088 There's no type |SLoop_iterator|, as there is 00089 at most one |SLoop| pair per sphere map.}*/ 00090 00091 typedef typename Items::template SVertex<Self> SVertex_base; 00092 typedef SNC_in_place_list_svertex<SVertex_base> SVertex; 00093 typedef CGAL::In_place_list<SVertex,false> SVertex_list; 00094 typedef CGAL_ALLOCATOR(SVertex) SVertex_alloc; 00095 typedef typename SVertex_list::iterator SVertex_handle; 00096 typedef typename SVertex_list::const_iterator SVertex_const_handle; 00097 typedef typename SVertex_list::iterator SVertex_iterator; 00098 typedef typename SVertex_list::const_iterator SVertex_const_iterator; 00099 00100 typedef typename Items::template SHalfedge<Self> SHalfedge_base; 00101 typedef SNC_in_place_list_shalfedge<SHalfedge_base> SHalfedge; 00102 typedef CGAL::In_place_list<SHalfedge,false> SHalfedge_list; 00103 typedef CGAL_ALLOCATOR(SHalfedge) SHalfedge_alloc; 00104 typedef typename SHalfedge_list::iterator SHalfedge_handle; 00105 typedef typename SHalfedge_list::const_iterator SHalfedge_const_handle; 00106 typedef typename SHalfedge_list::iterator SHalfedge_iterator; 00107 typedef typename SHalfedge_list::const_iterator SHalfedge_const_iterator; 00108 00109 typedef typename Items::template SFace<Self> SFace_base; 00110 typedef SNC_in_place_list_sface<SFace_base> SFace; 00111 typedef CGAL::In_place_list<SFace,false> SFace_list; 00112 typedef CGAL_ALLOCATOR(SFace) SFace_alloc; 00113 typedef typename SFace_list::iterator SFace_handle; 00114 typedef typename SFace_list::const_iterator SFace_const_handle; 00115 typedef typename SFace_list::iterator SFace_iterator; 00116 typedef typename SFace_list::const_iterator SFace_const_iterator; 00117 00118 typedef typename Items::template SHalfloop<Self> SHalfloop; 00119 typedef SHalfloop* SHalfloop_handle; 00120 typedef const SHalfloop* SHalfloop_const_handle; 00121 typedef SHalfloop* SHalfloop_iterator; 00122 typedef const SHalfloop* SHalfloop_const_iterator; 00123 00124 typedef CGAL::Object_handle Object_handle; 00125 /*{\Mtypemember a generic handle to an object of |\Mvar|. 00126 The kind of the object can be determined and the object assigned 00127 by the function:\\ 00128 |bool assign(xxx_handle& h, Object_handle o)|\\ 00129 where the function returns |true| iff the assignment of |o| to 00130 |h| was valid.}*/ 00131 00132 typedef std::list<Object_handle> Object_list; 00133 typedef typename Object_list::iterator Object_iterator; 00134 typedef typename Object_list::const_iterator Object_const_iterator; 00135 typedef boost::optional<Object_iterator> Optional_object_iterator ; 00136 typedef Generic_handle_map<Optional_object_iterator> Handle_to_iterator_map; 00137 00138 typedef Sphere_map* Constructor_parameter; 00139 typedef const Sphere_map* Constructor_const_parameter; 00140 00141 class SFace_cycle_iterator : public Object_iterator 00142 /*{\Mtypemember a generic iterator to an object in the boundary 00143 of a facet. Convertible to |Object_handle|.}*/ 00144 { typedef Object_iterator Ibase; 00145 public: 00146 SFace_cycle_iterator() : Ibase() {} 00147 SFace_cycle_iterator(const Ibase& b) : Ibase(b) {} 00148 SFace_cycle_iterator(const SFace_cycle_iterator& i) : Ibase(i) {} 00149 bool is_svertex() const 00150 { SVertex_handle v; return CGAL::assign(v,Ibase::operator*()); } 00151 bool is_shalfedge() const 00152 { SHalfedge_handle e; return CGAL::assign(e,Ibase::operator*()); } 00153 bool is_shalfloop() const 00154 { SHalfloop_handle l; return CGAL::assign(l,Ibase::operator*()); } 00155 operator SVertex_handle() const 00156 { SVertex_handle v; CGAL::assign(v,Ibase::operator*()); return v; } 00157 operator SHalfedge_handle() const 00158 { SHalfedge_handle e; CGAL::assign(e,Ibase::operator*()); return e; } 00159 operator SHalfloop_handle() const 00160 { SHalfloop_handle l; CGAL::assign(l,Ibase::operator*()); return l; } 00161 00162 operator Object_handle() const { return Ibase::operator*(); } 00163 Object_handle& operator*() const { return Ibase::operator*(); } 00164 Object_handle operator->() const 00165 { CGAL_error_msg("not impl."); return Object_handle(); } 00166 }; 00167 00168 class SFace_cycle_const_iterator : public Object_const_iterator 00169 /*{\Mtypemember a generic iterator to an object in the boundary 00170 of a facet. Convertible to |Object_handle|.}*/ 00171 { typedef Object_const_iterator Ibase; 00172 public: 00173 SFace_cycle_const_iterator() : Ibase() {} 00174 SFace_cycle_const_iterator(const Ibase& b) : Ibase(b) {} 00175 SFace_cycle_const_iterator(const SFace_cycle_const_iterator& i) 00176 : Ibase(i) {} 00177 bool is_svertex() const 00178 { SVertex_handle v; return CGAL::assign(v,Ibase::operator*()); } 00179 bool is_shalfedge() const 00180 { SHalfedge_handle e; return CGAL::assign(e,Ibase::operator*()); } 00181 bool is_shalfloop() const 00182 { SHalfloop_handle l; return CGAL::assign(l,Ibase::operator*()); } 00183 operator SVertex_const_handle() const 00184 { SVertex_handle v; CGAL::assign(v,Ibase::operator*()); 00185 return SVertex_const_handle(v); } 00186 operator SHalfedge_const_handle() const 00187 { SHalfedge_handle e; CGAL::assign(e,Ibase::operator*()); 00188 return SHalfedge_const_handle(e); } 00189 operator SHalfloop_const_handle() const 00190 { SHalfloop_handle l; CGAL::assign(l,Ibase::operator*()); 00191 return SHalfloop_const_handle(l); } 00192 00193 operator Object_handle() const { return Ibase::operator*(); } 00194 const Object_handle& operator*() const { return Ibase::operator*(); } 00195 Object_handle operator->() const 00196 { CGAL_error_msg("not impl."); return Object_handle(); } 00197 }; 00198 00199 /*{\Mtext Local types are handles, iterators and circulators of the 00200 following kind: |SVertex_handle|, |SVertex_iterator|, |SHalfedge_handle|, 00201 |SHalfedge_iterator|, |SHalfloop_handle|, |SHalfloop_iterator|, 00202 |SFace_handle|, |SFace_iterator|. Additionally the following 00203 circulators are defined.}*/ 00204 00205 typedef CircFromIt< 00206 SHalfedge_const_iterator, 00207 move_edge_around_svertex<SHalfedge_const_iterator> > 00208 SHalfedge_around_svertex_const_circulator; 00209 /*{\Mtypemember circulating the adjacency list of an vertex |v|.}*/ 00210 00211 typedef CircFromIt< 00212 SHalfedge_const_iterator, 00213 move_edge_around_sface<SHalfedge_const_iterator> > 00214 SHalfedge_around_sface_const_circulator; 00215 /*{\Mtypemember circulating the face cycle of an face |f|.}*/ 00216 00217 typedef CircFromIt< 00218 SHalfedge_iterator, 00219 move_edge_around_svertex<SHalfedge_iterator> > 00220 SHalfedge_around_svertex_circulator; 00221 /*{\Mtypemember circulating the adjacency list of an vertex |v|.}*/ 00222 00223 typedef CircFromIt< 00224 SHalfedge_iterator, 00225 move_edge_around_sface<SHalfedge_iterator> > 00226 SHalfedge_around_sface_circulator; 00227 /*{\Mtypemember circulating the face cycle of an face |f|.}*/ 00228 00229 /*{\Mcreation 3}*/ 00230 /*{\Mtext |\Mname| is default and copy constructible. Note that copy 00231 construction means cloning an isomorphic structure and is thus an 00232 expensive operation.}*/ 00233 00234 Sphere_map(bool = false) : boundary_item_(boost::none), 00235 svertices_(), sedges_(), sfaces_(), shalfloop_() {} 00236 00237 ~Sphere_map() { clear(); } 00238 00239 Sphere_map(const Self& D) : boundary_item_(boost::none), 00240 svertices_(D.svertices_), 00241 sedges_(D.sedges_), 00242 sfaces_(D.sfaces_), 00243 shalfloop_(0) 00244 { if ( D.shalfloop_ != 0 ) new_shalfloop_pair(*(D.shalfloop_)); 00245 pointer_update(D); 00246 } 00247 00248 Self& operator=(const Self& D) 00249 { if ( this == &D ) return *this; 00250 clear(); 00251 svertices_ = D.svertices_; 00252 sfaces_ = D.sfaces_; 00253 sedges_ = D.sedges_; 00254 if ( D.shalfloop_ != 0 ) new_shalfloop_pair(*D.shalfloop_); 00255 pointer_update(D); 00256 return *this; 00257 } 00258 00259 void clear() 00260 { 00261 boundary_item_.clear(boost::none); 00262 svertices_.destroy(); 00263 sfaces_.destroy(); 00264 while ( shalfedges_begin() != shalfedges_end() ) 00265 delete_shalfedge_pair( shalfedges_begin() ); 00266 if ( shalfloop_ != 0 ) { delete_shalfloop_pair(); shalfloop_=0; } 00267 } 00268 00269 template <typename H> 00270 bool is_sm_boundary_object(H h) const 00271 { return boundary_item_[h]!=boost::none; } 00272 00273 template <typename H> 00274 Object_iterator& sm_boundary_item(H h) 00275 { return *boundary_item_[h]; } 00276 00277 template <typename H> 00278 void store_sm_boundary_item(H h, Object_iterator o) 00279 { boundary_item_[h] = o; } 00280 00281 template <typename H> 00282 void undef_sm_boundary_item(H h) 00283 { CGAL_assertion(boundary_item_[h]!=boost::none); 00284 boundary_item_[h] = boost::none; } 00285 00286 void reset_sm_iterator_hash(Object_iterator it) 00287 { SVertex_handle sv; 00288 SHalfedge_handle se; 00289 SHalfloop_handle sl; 00290 if ( CGAL::assign(se,*it) ) { undef_sm_boundary_item(se); return; } 00291 if ( CGAL::assign(sl,*it) ) { undef_sm_boundary_item(sl); return; } 00292 if ( CGAL::assign(sv,*it) ) { undef_sm_boundary_item(sv); return; } 00293 } 00294 00295 void reset_sm_object_list(Object_list& L) 00296 { Object_iterator oit; 00297 CGAL_forall_iterators(oit,L) reset_sm_iterator_hash(oit); 00298 L.clear(); 00299 } 00300 00301 /*{\Moperations 2.5 3}*/ 00302 00303 // The constant iterators and circulators. 00304 SVertex_const_iterator svertices_begin() const { return svertices_.begin();} 00305 SVertex_const_iterator svertices_end() const { return svertices_.end();} 00306 SHalfedge_const_iterator shalfedges_begin() const { return sedges_.begin();} 00307 SHalfedge_const_iterator shalfedges_end() const { return sedges_.end();} 00308 SHalfloop_const_iterator shalfloops_begin() const { return shalfloop_; } 00309 SHalfloop_const_iterator shalfloops_end() const 00310 { return shalfloop_ != 0 ? shalfloop_+2 : shalfloop_; } 00311 SFace_const_iterator sfaces_begin() const { return sfaces_.begin();} 00312 SFace_const_iterator sfaces_end() const { return sfaces_.end();} 00313 00314 SVertex_iterator svertices_begin() { return svertices_.begin();} 00315 SVertex_iterator svertices_end() { return svertices_.end();} 00316 SHalfedge_iterator shalfedges_begin() { return sedges_.begin();} 00317 SHalfedge_iterator shalfedges_end() { return sedges_.end();} 00318 SHalfloop_iterator shalfloops_begin() { return shalfloop_; } 00319 SHalfloop_iterator shalfloops_end() 00320 { return shalfloop_ != 0 ? shalfloop_+2 : shalfloop_; } 00321 SFace_iterator sfaces_begin() { return sfaces_.begin();} 00322 SFace_iterator sfaces_end() { return sfaces_.end();} 00323 00324 SFace_cycle_const_iterator sface_cycles_begin(SFace_const_handle f) const 00325 { return f->sface_cycles_begin(); } 00326 SFace_cycle_const_iterator sface_cycles_end(SFace_const_handle f) const 00327 { return f->sface_cycles_end(); } 00328 SFace_cycle_iterator sface_cycles_begin(SFace_handle f) const 00329 { return f->sface_cycles_begin(); } 00330 SFace_cycle_iterator sface_cycles_end(SFace_handle f) const 00331 { return f->sface_cycles_end(); } 00332 00333 /*{\Mtext The list of all objects can be accessed via iterator ranges. 00334 For comfortable iteration we also provide iterations macros. 00335 The iterator range access operations are of the following kind:\\ 00336 |SVertex_iterator vertices_begin()/vertices_end()|\\ 00337 |SHalfedge_iterator halfedges_begin()/halfedges_end()|\\ 00338 |SHalfloop_iterator halfloops_begin()/halfloops_end()|\\ 00339 |SFace_iterator faces_begin()/faces_end()| */ 00340 00341 Size_type number_of_svertices() const { return svertices_.size();} 00342 /*{\Mop returns the number of vertices.}*/ 00343 Size_type number_of_shalfedges() const { return sedges_.size();} 00344 /*{\Mop returns the number of (directed edges).}*/ 00345 Size_type number_of_sfaces() const { return sfaces_.size();} 00346 /*{\Mop returns the number of facets.}*/ 00347 Size_type number_of_shalfloops() const 00348 { return shalfloop_!=SHalfloop_handle() ? 2 : 0; } 00349 /*{\Mop returns the number of shalfloop.}*/ 00350 00351 bool empty() const 00352 { return number_of_svertices() == 0 && 00353 number_of_shalfedges() == 0 && 00354 number_of_shalfloops() == 0 && 00355 number_of_sfaces() == 0; 00356 } 00357 00358 bool has_shalfloop() const { 00359 return shalfloop_ != 0; 00360 } 00361 00362 SHalfloop_handle& shalfloop() { 00363 return shalfloop_; 00364 } 00365 00366 SHalfloop_const_handle shalfloop() const { 00367 return shalfloop_; 00368 } 00369 00370 SVertex_alloc vertex_allocator; 00371 SVertex* get_vertex_node( const SVertex& ) { 00372 SVertex* p = vertex_allocator.allocate(1); 00373 vertex_allocator.construct( p, SVertex()); 00374 return p; 00375 } 00376 void put_vertex_node( SVertex* p) { 00377 vertex_allocator.destroy(p); 00378 vertex_allocator.deallocate( p, 1); 00379 } 00380 00381 SHalfedge_alloc halfedge_allocator; 00382 SHalfedge* get_halfedge_node( const SHalfedge& ) { 00383 SHalfedge* p = halfedge_allocator.allocate(1); 00384 halfedge_allocator.construct( p, SHalfedge()); 00385 return p; 00386 } 00387 void put_halfedge_node( SHalfedge* p) { 00388 halfedge_allocator.destroy(p); 00389 halfedge_allocator.deallocate( p, 1); 00390 } 00391 00392 SFace_alloc face_allocator; 00393 SFace* get_face_node( const SFace& ) { 00394 SFace* p = face_allocator.allocate(1); 00395 face_allocator.construct( p, SFace()); 00396 return p; 00397 } 00398 void put_face_node( SFace* p) { 00399 face_allocator.destroy(p); 00400 face_allocator.deallocate( p, 1); 00401 } 00402 00403 SVertex_handle new_svertex(const Sphere_point& p, 00404 Mark m = Mark()) 00405 /*{\Mop returns a new vertex at point |p| marked by |m|.}*/ 00406 { SVertex_handle vh = new_svertex(); vh->point() = p; vh->mark() = m; 00407 CGAL_NEF_TRACEN("new_svertex "<<&*vh); 00408 return vh; 00409 } 00410 00411 template <typename H> 00412 void make_twins(H h1, H h2) { h1->twin() = h2; h2->twin() = h1; } 00413 00414 SVertex_handle new_svertex() { 00415 svertices_.push_back( * get_vertex_node(SVertex())); 00416 return --svertices_end(); 00417 } 00418 00419 SFace_handle new_sface() { 00420 sfaces_.push_back( * get_face_node(SFace())); 00421 return --sfaces_end(); 00422 } 00423 00424 SHalfedge_handle new_shalfedge_pair() { 00425 SHalfedge* ep2 = get_halfedge_node(SHalfedge()); 00426 SHalfedge* ep1 = get_halfedge_node(SHalfedge()); 00427 sedges_.push_back( *ep1 ); 00428 SHalfedge_handle e1 = --shalfedges_end(); 00429 sedges_.push_back( *ep2 ); 00430 SHalfedge_handle e2 = --shalfedges_end(); 00431 make_twins(e1,e2); return e1; } 00432 00433 SHalfloop_handle new_shalfloop_pair() 00434 { SHalfloop_handle ph = new SHalfloop[2]; 00435 SHalfloop* pt(ph); ++pt; 00436 make_twins(ph,pt); 00437 shalfloop_=ph; return ph; } 00438 00439 SHalfedge_handle new_shalfedge_pair(const SHalfedge& e1) 00440 { const SHalfedge& e2 = *(e1.twin()); 00441 SHalfedge* ep2 = new SHalfedge[2]; 00442 SHalfedge* ep1 = ep2++; 00443 *ep1=e1; *ep2=e2; 00444 sedges_.push_back( *ep1 ); 00445 SHalfedge_handle eh1 = --shalfedges_end(); 00446 sedges_.push_back( *ep2 ); 00447 SHalfedge_handle eh2 = --shalfedges_end(); 00448 make_twins(eh1,eh2); return eh1; } 00449 00450 SHalfloop_handle new_shalfloop_pair(const SHalfloop& l1) 00451 { const SHalfloop& l2 = *(l1.twin()); 00452 SHalfloop* ph = new SHalfloop[2]; 00453 SHalfloop* pt(ph); ++pt; 00454 *ph=l1; *pt=l2; make_twins(ph,pt); 00455 shalfloop_=ph; return ph; } 00456 00457 void delete_svertex(SVertex_handle h) { 00458 svertices_.erase(h); 00459 put_vertex_node(&*h); 00460 } 00461 00462 void delete_sface(SFace_handle h) { 00463 sfaces_.erase(h); 00464 put_face_node(&*h); 00465 } 00466 00467 void delete_shalfedge_pair(SHalfedge_handle h) { 00468 SHalfedge_handle t = h->twin(); 00469 sedges_.erase(h); sedges_.erase(t); 00470 put_halfedge_node(&*h); 00471 put_halfedge_node(&*t); 00472 } 00473 00474 void delete_shalfloop_pair() { 00475 CGAL_assertion(has_shalfloop()); 00476 SHalfloop* ph = &*shalfloop_; 00477 SHalfloop* pt = &*shalfloop_->twin(); 00478 if ( ph > pt ) std::swap(ph,pt); 00479 shalfloop_ = SHalfloop_handle(); 00480 delete [] ph; } 00481 00482 protected: 00483 void pointer_update(const Self& D); 00484 Handle_to_iterator_map boundary_item_; 00485 00486 SVertex_list svertices_; 00487 SHalfedge_list sedges_; 00488 SFace_list sfaces_; 00489 SHalfloop_iterator shalfloop_; 00490 00491 }; // Sphere_map 00492 00493 00494 template <typename K, typename I, typename M> 00495 void Sphere_map<K, I, M>:: 00496 pointer_update(const Sphere_map<K, I, M>& D) 00497 { 00498 CGAL::Unique_hash_map<SVertex_const_handle,SVertex_handle> VM; 00499 CGAL::Unique_hash_map<SHalfedge_const_handle,SHalfedge_handle> EM; 00500 CGAL::Unique_hash_map<SHalfloop_const_handle,SHalfloop_handle> LM; 00501 CGAL::Unique_hash_map<SFace_const_handle,SFace_handle> FM; 00502 00503 SVertex_const_iterator vc = D.svertices_begin(); 00504 SVertex_iterator v = svertices_begin(); 00505 for ( ; vc != D.svertices_end(); ++vc,++v) VM[vc] = v; 00506 VM[D.svertices_end()] = svertices_end(); 00507 00508 SHalfedge_const_iterator ec = D.shalfedges_begin(); 00509 SHalfedge_iterator e = shalfedges_begin(); 00510 for ( ; ec != D.shalfedges_end(); ++ec,++e) { 00511 EM[ec] = e; 00512 e->mark() = ec->mark(); 00513 } 00514 EM[D.shalfedges_end()] = shalfedges_end(); 00515 00516 SFace_const_iterator fc = D.sfaces_begin(); 00517 SFace_iterator f = sfaces_begin(); 00518 for ( ; fc != D.sfaces_end(); ++fc,++f) FM[fc] = f; 00519 FM[D.sfaces_end()] = sfaces_end(); 00520 00521 SHalfloop_iterator l; 00522 if ( D.shalfloop_ != 0 ) { 00523 LM[D.shalfloop_] = shalfloop_; 00524 LM[D.shalfloop_->twin()] = shalfloop_->twin(); 00525 l = shalfloop(); 00526 shalfloop_->mark() = D.shalfloop()->mark(); 00527 shalfloop_->twin()->mark() = D.shalfloop()->twin()->mark(); 00528 if( !l->is_twin() && D.shalfloop()->is_twin()) l->mark() = l->twin()->mark(); 00529 } 00530 00531 for (v = svertices_begin(); v != svertices_end(); ++v) { 00532 // Local Graph update: (SVertices are postponed/updated as Edges) 00533 v->out_sedge() = EM[v->out_sedge()]; 00534 v->incident_sface() = FM[v->incident_sface()]; 00535 } 00536 // Edge update: 00537 for (e = shalfedges_begin(); e != shalfedges_end(); ++e) { 00538 e->twin() = EM[e->twin()]; 00539 e->sprev() = EM[e->sprev()]; 00540 e->snext() = EM[e->snext()]; 00541 e->source() = VM[e->source()]; 00542 e->incident_sface() = FM[e->incident_sface()]; 00543 } 00544 for ( ec = D.shalfedges_begin(), e = shalfedges_begin(); 00545 ec != D.shalfedges_end(); ++ec, ++e) { 00546 if( !e->is_twin() && ec->is_twin()) e->mark() = e->twin()->mark(); 00547 } 00548 00549 for (l = shalfloops_begin(); l != shalfloops_end(); ++l) { 00550 // l->twin() = LM[l->twin()]; 00551 l->incident_sface() = FM[l->incident_sface()]; 00552 } 00553 00554 00555 for (f = sfaces_begin(); f != sfaces_end(); ++f) { 00556 SFace_cycle_iterator fci; 00557 for(fci = f->boundary_entry_objects().begin(); 00558 fci != f->boundary_entry_objects().end(); ++fci) { 00559 if ( fci.is_svertex() ) 00560 { v = SVertex_handle(fci); 00561 *fci = make_object(VM[v]); store_sm_boundary_item(v,fci); } 00562 else if ( fci.is_shalfedge() ) 00563 { e = SHalfedge_handle(fci); 00564 *fci = make_object(EM[e]); store_sm_boundary_item(e,fci); } 00565 else if ( fci.is_shalfloop() ) 00566 { l = SHalfloop_handle(fci); 00567 *fci = make_object(LM[l]); store_sm_boundary_item(l,fci); } 00568 else CGAL_error_msg("damn wrong boundary item in face."); 00569 } 00570 } 00571 } 00572 00573 00574 CGAL_END_NAMESPACE 00575 #endif // CGAL_SPHERE_MAP_H 00576 00577