1 // Copyright (c) 2007  Max-Planck-Institute Saarbruecken (Germany).
2 // All rights reserved.
3 //
4 // This file is part of CGAL (www.cgal.org).
5 //
6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Nef_3/include/CGAL/Nef_3/Edge_edge_overlay.h $
7 // $Id: Edge_edge_overlay.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot
8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
9 //
10 //
11 // Author(s)     : Peter Hachenberger <hachenberger@mpi-sb.mpg.de>
12 
13 #ifndef CGAL_EDGE_EDGE_OVERLAY_H
14 #define CGAL_EDGE_EDGE_OVERLAY_H
15 
16 #include <CGAL/license/Nef_3.h>
17 
18 
19 #include <CGAL/Nef_S2/Normalizing.h>
20 #include <CGAL/Nef_3/SNC_decorator.h>
21 #include <CGAL/Nef_3/SNC_constructor.h>
22 #include <CGAL/Nef_S2/SM_point_locator.h>
23 #include <CGAL/Nef_3/SNC_sphere_map.h>
24 #undef CGAL_NEF_DEBUG
25 #define CGAL_NEF_DEBUG 71
26 #include <CGAL/Nef_2/debug.h>
27 
28 namespace CGAL {
29 
30 template <typename SNC_structure_>
31 class Edge_edge_overlay
32 {
33 public:
34   typedef SNC_structure_ SNC_structure;
35   typedef typename SNC_structure::Items                      Items;
36   typedef typename SNC_structure_::Kernel                    Kernel;
37   typedef typename Kernel::RT                                RT;
38   typedef CGAL::Edge_edge_overlay<SNC_structure>             Self;
39   typedef CGAL::SNC_decorator<SNC_structure>                 SNC_decorator;
40   typedef typename CGAL::SNC_constructor<Items, SNC_structure>  SNC_constructor;
41 
42   typedef typename SNC_structure::Sphere_map             Sphere_map;
43   typedef CGAL::SM_decorator<Sphere_map>                 SM_decorator;
44   typedef CGAL::SM_const_decorator<Sphere_map>           SM_const_decorator;
45   typedef CGAL::SM_point_locator<SM_decorator>           SM_point_locator;
46 
47   typedef typename SNC_structure::Vertex_iterator Vertex_iterator;
48   typedef typename SNC_structure::Halfedge_iterator Halfedge_iterator;
49   typedef typename SNC_structure::Halffacet_iterator Halffacet_iterator;
50 
51   typedef typename SNC_structure::Vertex_handle Vertex_handle;
52   typedef typename SNC_structure::Halfedge_handle Halfedge_handle;
53   typedef typename SNC_structure::Halffacet_handle Halffacet_handle;
54 
55   typedef typename SNC_structure::Vertex_const_handle Vertex_const_handle;
56   typedef typename SNC_structure::Halfedge_const_handle Halfedge_const_handle;
57   typedef typename SNC_structure::Halffacet_const_handle Halffacet_const_handle;
58   typedef typename SNC_structure::Halffacet_const_iterator Halffacet_const_iterator;
59 
60   typedef typename SNC_structure::SVertex_iterator SVertex_iterator;
61   typedef typename SNC_structure::SHalfedge_iterator SHalfedge_iterator;
62   typedef typename SNC_structure::SFace_iterator SFace_iterator;
63   typedef typename SNC_structure::SHalfloop_iterator SHalfloop_iterator;
64 
65   typedef typename SNC_structure::SVertex_handle SVertex_handle;
66   typedef typename SNC_structure::SHalfedge_handle SHalfedge_handle;
67   typedef typename SNC_structure::SFace_handle SFace_handle;
68   typedef typename SNC_structure::SHalfloop_handle SHalfloop_handle;
69 
70   typedef typename SNC_structure::SVertex_const_handle SVertex_const_handle;
71   typedef typename SNC_structure::SHalfedge_const_handle SHalfedge_const_handle;
72   typedef typename SNC_structure::SHalfloop_const_handle SHalfloop_const_handle;
73   typedef typename SNC_structure::SFace_const_handle SFace_const_handle;
74 
75   typedef typename SNC_structure::SHalfedge_around_facet_circulator
76     SHalfedge_around_facet_circulator;
77   typedef typename SNC_structure::SHalfedge_around_facet_const_circulator
78     SHalfedge_around_facet_const_circulator;
79   typedef typename SNC_structure::SFace_cycle_iterator SFace_cycle_iterator;
80   typedef typename SNC_structure::SFace_cycle_const_iterator SFace_cycle_const_iterator;
81   typedef typename SNC_structure::Halffacet_cycle_iterator Halffacet_cycle_iterator;
82   typedef typename SNC_structure::Halffacet_cycle_const_iterator Halffacet_cycle_const_iterator;
83 
84   typedef typename SNC_structure::Point_3 Point_3;
85   typedef typename SNC_structure::Vector_3 Vector_3;
86   typedef typename SNC_structure::Segment_3 Segment_3;
87   typedef typename SNC_structure::Plane_3 Plane_3;
88   typedef typename SNC_structure::Aff_transformation_3 Aff_transformation_3;
89 
90   typedef typename SNC_structure::Sphere_point Sphere_point;
91   typedef typename SNC_structure::Sphere_segment Sphere_segment;
92   typedef typename SNC_structure::Sphere_circle Sphere_circle;
93 
94   typedef typename SNC_structure::Mark Mark;
95 
96   typedef typename SM_decorator::SHalfedge_around_svertex_circulator
97                                  SHalfedge_around_svertex_circulator;
98   typedef typename SM_decorator::SHalfedge_around_sface_circulator
99                                  SHalfedge_around_sface_circulator;
100   typedef typename SM_const_decorator::SHalfedge_around_svertex_const_circulator
101                                        SHalfedge_around_svertex_const_circulator;
102 
103   SNC_structure& snc;
104   Halfedge_const_handle e0, e1;
105   SM_decorator D;
106   SM_const_decorator E;
107 
Edge_edge_overlay(SNC_structure & snc_,Halfedge_const_handle e0_,Halfedge_const_handle e1_)108   Edge_edge_overlay( SNC_structure& snc_,
109                      Halfedge_const_handle e0_,
110                      Halfedge_const_handle e1_)
111     : snc(snc_), e0(e0_), e1(e1_) {}
112 
113   template<typename Selection>
overlay_isolated_edges(const Point_3 & p,const Selection & BOP,bool inv)114   Sphere_map* overlay_isolated_edges(const Point_3& p,
115                                      const Selection& BOP, bool inv) {
116 
117     Vertex_handle v = snc.new_vertex(p);
118     v->mark() = BOP(e0->mark(), e1->mark(), inv);
119     D = SM_decorator(&*v);
120     SFace_handle sf = D.new_sface();
121     sf->mark() = BOP(e0->incident_sface()->mark(),
122                      e1->incident_sface()->mark(), inv);
123     SVertex_handle sv = D.new_svertex(e0->point());
124     sv->mark() = BOP(e0->mark(), e1->incident_sface()->mark(), inv);
125     D.link_as_isolated_vertex(sv, sf);
126     sv = D.new_svertex(e0->twin()->point());
127     sv->mark() = BOP(e0->mark(), e1->incident_sface()->mark(), inv);
128     D.link_as_isolated_vertex(sv, sf);
129     sv = D.new_svertex(e1->point());
130     sv->mark() = BOP(e0->incident_sface()->mark(), e1->mark(), inv);
131     D.link_as_isolated_vertex(sv, sf);
132     sv = D.new_svertex(e1->twin()->point());
133     sv->mark() = BOP(e0->incident_sface()->mark(), e1->mark(), inv);
134     D.link_as_isolated_vertex(sv, sf);
135     return D.sphere_map();
136   }
137 
138   template<typename Selection, typename Association>
create_edge_edge_overlay(const Point_3 & p,const Selection & BOP,bool inv,Association &)139   Sphere_map* create_edge_edge_overlay( const Point_3& p,
140                                         const Selection& BOP, bool inv,
141                                         Association& ) {
142 
143     //    CGAL_NEF_SETDTHREAD(43*71);
144     CGAL_NEF_TRACEN(std::endl << "edge_edge " << p );
145 
146     E = SM_const_decorator(&*e1->source());
147     if(E.is_isolated(e0)) {
148       if(E.is_isolated(e1)) {
149         return overlay_isolated_edges(p, BOP, inv);
150       } else {
151         std::swap(e0, e1);
152         inv = !inv;
153         E = SM_const_decorator(&*e1->source());
154       }
155     }
156 
157     SNC_constructor C(snc);
158     Vertex_handle v(C.create_from_edge(e0,p));
159     v->mark() = BOP(v->mark(), e1->mark(), inv);
160     D = SM_decorator(&*v);
161     SVertex_handle sv[4];
162     sv[0] = sv[1] = v->svertices_begin();
163     ++sv[1];
164 
165     Vector_3 vec0 = sv[0]->point() - CGAL::ORIGIN;
166     Vector_3 vec1 = e1->source()->point() - CGAL::ORIGIN;
167     Plane_3 mid_plane(Point_3(0,0,0), cross_product(vec0, vec1));
168     Sphere_segment test_seg(sv[0]->point(),
169                             CGAL::ORIGIN + mid_plane.orthogonal_vector());
170     Oriented_side test_os =
171       test_seg.sphere_circle().oriented_side(e1->point());
172     CGAL_assertion(test_os != ON_ORIENTED_BOUNDARY);
173     if(test_os == ON_NEGATIVE_SIDE) {
174       CGAL_NEF_TRACEN("change orientation of e1 " );
175       e1 = e1->twin();
176     }
177 
178     SM_point_locator PL(&*v);
179     Object_handle o2 = PL.locate(e1->point());
180     Object_handle o3 = PL.locate(e1->twin()->point());
181     sv[2] = D.new_svertex(e1->point());
182     sv[3] = D.new_svertex(e1->twin()->point());
183 
184     for(int i=0; i<4; ++i)
185       CGAL_NEF_TRACEN("sv[" << i << "]= " << sv[i]->point());
186 
187     bool equator[4];
188     equator[0] = equator[1] = equator[2] = equator[3] = false;
189     bool on_sface[2];
190 
191     SHalfedge_handle se0, se1;
192     SHalfedge_handle previous_first, previous_last;
193     SFace_handle sf0, sf1;
194     SHalfedge_around_svertex_circulator
195       seb[2], see[2];
196     SHalfedge_around_svertex_const_circulator
197       scb[2], sce[2];
198     bool empty_e[2];
199     bool empty_c[2];
200     empty_e[0] = empty_e[1] = empty_c[0] = empty_c[1] = false;
201 
202     on_sface[0] = CGAL::assign(sf0, o2);
203     on_sface[1] = CGAL::assign(sf1, o3);
204 
205     //    set seb[0], see[1]
206     if(on_sface[0]) {
207       CGAL_NEF_TRACEN("found sf0 " );
208       sv[2]->mark() = BOP(sf0->mark(), e1->mark(), inv);
209       SFace_cycle_iterator sfci(sf0->sface_cycles_begin());
210       CGAL_assertion(sfci.is_shalfedge());
211       SHalfedge_handle se_tmp(sfci);
212       see[1] = se_tmp;
213       if(see[1]->source() != sv[0])
214         see[1] = see[1]->snext();
215       see[1] = see[1]->sprev()->twin();
216       seb[0] = see[1];
217     } else {
218       CGAL::assign(se0, o2);
219       CGAL_assertion(CGAL::assign(se0, o2));
220       CGAL_NEF_TRACEN("found se0 " << se0->source()->point()
221                 << "->" << se0->twin()->source()->point() );
222       CGAL_NEF_TRACEN("insert sv " << sv[2]->point() );
223       if(se0->source() != sv[0]) se0 = se0->twin();
224       CGAL_assertion(se0->source() == sv[0]);
225       sv[2]->mark() = BOP(se0->mark(), e1->mark(), inv);
226       SHalfedge_handle se_new = D.split_at(se0, sv[2]);
227       se_new->mark() = se_new->twin()->mark() =
228         se0->mark() = se0->twin()->mark() =
229         BOP(se0->mark(), sv[2]->mark(), inv);
230       // TODO: test mark of se0
231 
232       see[1] = seb[0]= se0;
233       ++seb[0];
234       equator[0] = equator[1] = true;
235     }
236 
237     //    set seb[1] and see[0]
238     if(on_sface[1]) {
239       CGAL_NEF_TRACEN("found sf1 " );
240       sv[3]->mark() = BOP(sf1->mark(), e1->mark(), inv);
241       SFace_cycle_iterator sfci(sf1->sface_cycles_begin());
242       CGAL_assertion(sfci.is_shalfedge());
243       SHalfedge_handle se_tmp(sfci);
244       see[0] = se_tmp;
245       if(see[0]->source() != sv[0])
246         see[0] = see[0]->snext();
247       see[0] = see[0]->sprev()->twin();
248       seb[1] = see[0];
249     } else {
250       CGAL::assign(se1, o3);
251       CGAL_assertion(CGAL::assign(se1, o3));
252       CGAL_NEF_TRACEN("found se1 " << se1->source()->point()
253                 << "->" << se1->twin()->source()->point() );
254       CGAL_NEF_TRACEN("insert sv " << sv[3]->point() );
255       if(se1->source() != sv[0]) se1 = se1->twin();
256       CGAL_assertion(se1->source() == sv[0]);
257       sv[3]->mark() = BOP(se1->mark(), e1->mark(), inv);
258       SHalfedge_handle se_new = D.split_at(se1, sv[3]);
259       se_new->mark() = se_new->twin()->mark() =
260         se1->mark() = se1->twin()->mark() =
261         BOP(se1->mark(), sv[3]->mark(), inv);
262       // TODO: test mark of se1
263 
264       see[0] = seb[1] = se1;
265       ++seb[1];
266       equator[2] = equator[3] = true;
267     }
268 
269     CGAL_assertion(seb[0]->source() == sv[0]);
270 
271     //    set empty_e if necessary
272     if(seb[0] == see[0] && seb[1] == see[1]) {
273       CGAL_NEF_TRACEN("both empty intervals");
274       Oriented_side osx = seb[0]->circle().oriented_side(sv[3]->point());
275       if(osx == ON_NEGATIVE_SIDE) {
276         CGAL_NEF_TRACEN("empty 0 " );
277         empty_e[0] = true;
278       } else if(osx == ON_POSITIVE_SIDE) {
279         empty_e[1] = true;
280       } else {
281         empty_e[0] = empty_e[1] = true;
282       }
283     } else if(seb[0] == see[0]) {
284       empty_e[0] = true;
285     } else if(seb[1] == see[1]) {
286       empty_e[1] = true;
287     }
288 
289     CGAL_NEF_TRACEN("se[01] " << (std::distance(seb[0], see[0]))
290               << ", " << (std::distance(seb[1], see[1])) );
291 
292     // finish overlay if one edge is isolated
293     if(E.is_isolated(e1)) {
294       Mark sfm = e1->incident_sface()->mark();
295       sv[0]->mark() = BOP(sv[0]->mark(), sfm, inv);
296       sv[1]->mark() = BOP(sv[1]->mark(), sfm, inv);
297       SHalfedge_around_svertex_circulator
298         svc(sv[0]->out_sedge()),
299         send(svc);
300       CGAL_For_all(svc, send) {
301         svc->incident_sface()->mark() =
302           BOP(svc->incident_sface()->mark(), sfm, inv);
303         if(svc->twin()->source() != sv[1]) continue;
304         svc->mark() = BOP(svc->mark(), sfm, inv);
305       }
306       if(on_sface[0])
307         D.link_as_isolated_vertex(sv[2], sf0);
308       if(on_sface[1])
309         D.link_as_isolated_vertex(sv[3], sf1);
310 
311       return D.sphere_map();
312     }
313 
314     SHalfedge_around_svertex_const_circulator
315       svc(e1->out_sedge()), send(svc);
316 
317     // determine scb and sce for one side
318     int i=0;
319     bool done = false;
320     Oriented_side os0 =
321       svc->circle().oriented_side(sv[0]->point());
322     Oriented_side os1 = os0;
323     while(os0 == os1 &&
324           os1 != ON_ORIENTED_BOUNDARY &&
325           ++svc != send)
326       os1 = svc->circle().oriented_side(sv[0]->point());
327 
328     CGAL_NEF_TRACEN("osi " << os0 << ", " << os1 );
329     CGAL_assertion(os1 == svc->circle().oriented_side(sv[0]->point()) ||
330                    svc == send);
331 
332     if(os1 == ON_ORIENTED_BOUNDARY) {
333 
334       CGAL_NEF_TRACEN("svc on boundary ");
335 
336       Sphere_segment seg(sv[2]->point(), sv[3]->point(),
337                          svc->circle());
338       int sv_index =
339         seg.has_on(sv[0]->point()) ? 0 : 1;
340       equator[sv_index] = equator[sv_index+2] = true;
341 
342       CGAL_NEF_TRACEN("sv " << sv[0]->point() << ", " << sv[1]->point() );
343 
344       // svc is the segment from sv[2] to sv[3] that has sv[sv_index]
345       // in its interior
346 
347       if(on_sface[0]) {
348         CGAL_NEF_TRACEN("se[01] " << (std::distance(seb[0], see[0]))
349                         << ", " << (std::distance(seb[1], see[1])) );
350 
351         // add shalfedge_pair between sv[2] and sv[sv_index]
352         SFace_cycle_iterator sfci = sf0->sface_cycles_begin();
353         CGAL_assertion(sfci.is_shalfedge());
354         SHalfedge_handle se_tgt(sfci);
355         while(se_tgt->source() != sv[sv_index]) {
356           se_tgt = se_tgt->snext();
357           CGAL_NEF_TRACEN(se_tgt->source()->point() << " " << sv[sv_index]->point() );
358           CGAL_NEF_TRACEN(&(se_tgt->source()) << " " << &sv[sv_index] );
359         }
360 
361 
362         CGAL_NEF_TRACEN("sv[sv_index] " << sv[sv_index]->point());
363         CGAL_NEF_TRACEN("after " << se_tgt->source()->point()
364                   << "->" << se_tgt->twin()->source()->point());
365 
366         SHalfedge_around_svertex_circulator se_next(se_tgt);
367         ++se_next;
368         CGAL_assertion(se_tgt->source() == sv[sv_index]);
369         CGAL_NEF_TRACEN("new_shalfedge_pair" );
370         SHalfedge_handle se_new =
371           D.new_shalfedge_pair(sv[2], se_tgt, 1);
372 
373         se_new->mark() = se_new->twin()->mark() =
374           BOP(sf0->mark(), svc->mark(), inv);
375         se_new->circle() = normalized(Sphere_circle(se_new->source()->point(),
376                                                     se_new->twin()->source()->point()));
377         se_new->twin()->circle() = se_new->circle().opposite();
378         se_new->incident_sface() = se_new->twin()->incident_sface() = sf0;
379 
380         CGAL_NEF_TRACEN("seb[0] " << seb[0]->source()->point()
381                   << "->" << seb[0]->twin()->source()->point() );
382         CGAL_NEF_TRACEN("see[0] " << see[0]->source()->point()
383                   << "->" << see[0]->twin()->source()->point() );
384 
385         CGAL_assertion(seb[0]->source() == sv[0]);
386 
387         CGAL_NEF_TRACEN("se[01] " << (std::distance(seb[0], see[0]))
388                         << ", " << (std::distance(seb[1], see[1])) );
389 
390         if(se_next == see[0] && !empty_e[0])
391           --see[0];
392         else if(se_next == see[1] && !empty_e[1])
393           --see[1];
394       }
395 
396       CGAL_NEF_TRACEN("se[01] " << (std::distance(seb[0], see[0]))
397                       << ", " << (std::distance(seb[1], see[1])) );
398 
399 
400       if(on_sface[1]) {
401         CGAL_NEF_TRACEN("sf1->mark() " << sf1->mark());
402 
403         // add shalfedge_pair between sv[3] and sv[sv_index]
404         CGAL_NEF_TRACEN("seb[0] " << seb[0]->source()->point()
405                   << "->" << seb[0]->twin()->source()->point() );
406         CGAL_NEF_TRACEN("see[0] " << see[0]->source()->point()
407                   << "->" << see[0]->twin()->source()->point() );
408 
409         SFace_cycle_iterator sfci = sf1->sface_cycles_begin();
410         CGAL_assertion(sfci.is_shalfedge());
411         SHalfedge_handle se_tgt(sfci);
412         while(se_tgt->source() != sv[sv_index]) {
413           se_tgt = se_tgt->snext();
414           CGAL_NEF_TRACEN(se_tgt->source()->point() << " " << sv[sv_index]->point() );
415           CGAL_NEF_TRACEN(&(se_tgt->source()) << " " << &sv[sv_index] );
416         }
417 
418         SHalfedge_around_svertex_circulator se_next(se_tgt);
419         ++se_next;
420 
421         CGAL_NEF_TRACEN("sv[sv_index] " << sv[sv_index]->point());
422         CGAL_NEF_TRACEN("after " << se_tgt->source()->point()
423                   << "->" << se_tgt->twin()->source()->point());
424 
425         CGAL_assertion(se_tgt->source() == sv[sv_index]);
426         CGAL_NEF_TRACEN("new_shalfedge_pair" );
427         SHalfedge_handle se_new =
428           D.new_shalfedge_pair(sv[3], se_tgt, 1);
429 
430         //        CGAL_assertion(se_new->snext() == se_tgt);
431         CGAL_NEF_TRACEN("se_new " << se_new->source()->point()
432                   << "->" << se_new->twin()->source()->point() );
433         se_new->mark() = se_new->twin()->mark() =
434           BOP(sf1->mark(), svc->mark(), inv);
435         se_new->circle() = normalized(Sphere_circle(se_new->source()->point(),
436                                                     se_new->twin()->source()->point()));
437         se_new->twin()->circle() = se_new->circle().opposite();
438         se_new->incident_sface() =
439           se_new->twin()->incident_sface() = sf1;
440 
441         CGAL_NEF_TRACEN("seb[0] " << seb[0]->source()->point()
442                   << "->" << seb[0]->twin()->source()->point() );
443         CGAL_NEF_TRACEN("see[0] " << see[0]->source()->point()
444                   << "->" << see[0]->twin()->source()->point() );
445 
446         CGAL_NEF_TRACEN("se[01] " << (std::distance(seb[0], see[0]))
447                   << ", " << (std::distance(seb[1], see[1])) );
448 
449         if(se_next == see[0] && !empty_e[0])
450           --see[0];
451         else if(se_next == see[1] && !empty_e[1])
452           --see[1];
453 
454         CGAL_NEF_TRACEN("se[01] " << (std::distance(seb[0], see[0]))
455                   << ", " << (std::distance(seb[1], see[1])) );
456       }
457 
458       CGAL_NEF_TRACEN("see[0] " << see[0]->source()->point()
459                 << "->" << see[0]->twin()->source()->point() );
460 
461       if(svc == svc->twin()->snext()) {
462         scb[0] = scb[1] = sce[0] = sce[1] = svc;
463         empty_c[0] = empty_c[1] = true;
464         done = true;
465       } else {
466         ++svc;
467         os1 = svc->circle().oriented_side(sv[0]->point());
468 
469         CGAL_NEF_TRACEN("++os1 " << os1 );
470 
471         if(os1 == ON_ORIENTED_BOUNDARY) {
472           CGAL_assertion_msg(false, "not implemented, yet"); // don't forget empty_c
473           ++svc;
474           scb[0] = scb[1] = sce[0] = sce[1] = svc;
475           if(svc != send) {
476             os1 = svc->circle().oriented_side(sv[0]->point());
477             i = os1 == ON_POSITIVE_SIDE ? 0 : 1;
478             --sce[i];
479           }
480           equator[1-sv_index] = equator[3-sv_index] = true;
481           done = true;
482         } else {
483           i = os1 == ON_POSITIVE_SIDE ? 0 : 1;
484           CGAL_NEF_TRACEN("second change found on side " << os1);
485           scb[i] = svc;
486           --svc;
487           sce[1-i] = svc;
488           --svc;
489           if(svc->circle().oriented_side(sv[0]->point()) == os1) {
490             // sedges are only on one side "
491             sce[i] = scb[1-i] = sce[1-i];
492             empty_c[1-i] = true;
493             done = true;
494           }
495         }
496       }
497     } else if(svc == send) {
498       // everything is on one side
499       CGAL_NEF_TRACEN("svc == send");
500       Vector_3
501         vec1(svc->source()->point() - CGAL::ORIGIN),
502         vec2(svc->circle().orthogonal_vector());
503       Sphere_point sp1(CGAL::ORIGIN + cross_product(vec2,vec1));
504       while(svc->sprev()->twin()->circle().oriented_side(sp1)
505             == ON_POSITIVE_SIDE) {
506         ++svc;
507         vec1 = vec2;
508         vec2 = svc->circle().orthogonal_vector();
509         sp1 = CGAL::ORIGIN + cross_product(vec2,vec1);
510       }
511       i = os1 == ON_POSITIVE_SIDE ? 0 : 1;
512       //      ++svc;
513       scb[i] = sce[i] = svc;
514       empty_c[1-i] = true;
515       done = true;
516 
517     } else {
518       CGAL_NEF_TRACEN("found sedges on both sides ");
519       //      CGAL_assertion_msg(false, "not implemented, yet");
520       // Code should work, but is not tested
521       CGAL_assertion(os0 != os1);
522       i = os1 == ON_POSITIVE_SIDE ? 0 : 1;
523       sce[1-i] = scb[i] = svc;
524     }
525     //    CGAL_assertion(scb[1-i] == svc);
526 
527     // determine scb, sce for other side if necessary
528     if(!done) {
529       CGAL_NEF_TRACEN("not done yet");
530       // both sides are not empty
531       os0 = svc->circle().oriented_side(sv[0]->point());
532       CGAL_assertion(os0 != ON_ORIENTED_BOUNDARY);
533       do {
534         ++svc;
535         os1 = svc->circle().oriented_side(sv[0]->point());
536       } while(os1 == os0);
537 
538       sce[i] = scb[1-i] = svc;
539       if(os1 == ON_ORIENTED_BOUNDARY) {
540         CGAL_assertion_msg(false, "degenerate case not implemented, yet");
541         ++scb[1-i];
542         CGAL_assertion(svc->circle().has_on(sv[0]->point()) == i);
543         equator[i] = equator[2+i] == true;
544       }
545     }
546 
547     for(int i=0; i<4; ++i)
548       CGAL_NEF_TRACEN("equator[" << i << "]= " << equator[i]);
549 
550     CGAL_NEF_TRACEN("svmark " << sv[0]->mark() << ", " << sv[1]->mark());
551 
552     // TODO: marks if sv[0] and sv[1] lie on edge
553     sv[0]->mark() =
554       BOP(sv[0]->mark(), sce[empty_c[0]]->twin()->incident_sface()->mark(), inv);
555     sv[1]->mark() =
556       BOP(sv[1]->mark(), scb[empty_c[0]]->twin()->incident_sface()->mark(), inv);
557 
558     CGAL_NEF_TRACEN("empty[0] " << empty_c[0] << ", " << empty_e[0] );
559 
560     CGAL_assertion(seb[0]->source() == sv[0]);
561 
562     CGAL_assertion_msg(!empty_c[0] || !empty_c[1],
563                        "not implemented, yet");
564     CGAL_assertion_msg(!empty_e[0] || !empty_e[1],
565                        "not implemented, yet");
566 
567     bool first_first = true;
568     bool first_last = true;
569     if(!empty_c[0] && !empty_e[0]) {
570       CGAL_NEF_TRACEN("sv[2] " << sv[2]->point());
571 
572       if(equator[0] || equator[1]) {
573         first_first = false;
574         previous_first = sv[2]->out_sedge();
575         if(equator[0] && previous_first->twin()->source() != sv[0])
576           previous_first = previous_first->twin()->snext();
577         CGAL_assertion(!equator[0] || previous_first->twin()->source() == sv[0]);
578       }
579 
580       if(equator[2] || equator[3]) {
581         first_last = false;
582         previous_last = sv[3]->out_sedge();
583         if(equator[2] && previous_last->twin()->source() != sv[0])
584           previous_last = previous_last->twin()->snext();
585         CGAL_assertion(!equator[2] || previous_last->twin()->source() == sv[0]);
586       }
587 
588       SHalfedge_around_svertex_const_circulator curr_outer(scb[0]);
589       CGAL_For_all(curr_outer, sce[0]) {
590         CGAL_NEF_TRACEN("outer " << curr_outer->incident_sface()->mark() );
591 
592         SHalfedge_handle previous_inner;
593         Sphere_segment seg1(sv[2]->point(), sv[3]->point(),
594                             curr_outer->circle());
595         SHalfedge_around_svertex_circulator curr_inner(seb[0]);
596 
597         CGAL_For_all(curr_inner, see[0]) {
598           CGAL_NEF_TRACEN("inner " << curr_inner->incident_sface()->mark() );
599           CGAL_assertion(!curr_inner->circle().has_on(sv[2]->point()));
600           CGAL_assertion(!curr_outer->circle().has_on(sv[0]->point()));
601           Sphere_segment seg0(sv[0]->point(), sv[1]->point(), curr_inner->circle());
602           Sphere_segment segX(curr_inner->source()->point(),
603                               curr_inner->twin()->source()->point(),
604                               curr_inner->circle());
605           CGAL_assertion(!seg0.is_long());
606           CGAL_assertion(!seg1.is_long());
607           Sphere_point sp = normalized(seg0.intersection(seg1));
608           CGAL_NEF_TRACEN("intersections oben " << sp );
609           CGAL_assertion(sp != sv[0]->point());
610           CGAL_assertion(sp != sv[1]->point());
611           CGAL_assertion(sp != sv[2]->point());
612           CGAL_assertion(sp != sv[3]->point());
613           CGAL_assertion(segX.has_on(sp));
614           CGAL_assertion(curr_inner == seb[0] ||
615                          Sphere_segment(sv[2]->point(), sp).has_on
616                          (previous_inner->twin()->source()->point()));
617           CGAL_assertion(seg0.source() == sv[0]->point());
618           CGAL_assertion(seg0.target() == sv[1]->point());
619           CGAL_assertion(seg1.source() == sv[2]->point());
620           CGAL_assertion(seg1.target() == sv[3]->point());
621           CGAL_assertion(seg0.has_on(sp));
622           CGAL_assertion(seg1.has_on(sp));
623           CGAL_NEF_TRACEN("seg 0 " << seg0.source() << "->" << seg0.target());
624           CGAL_NEF_TRACEN("seg 1 " << seg1.source() << "->" << seg1.target() << ":" << seg1.sphere_circle());
625 
626           SHalfedge_handle along = D.split_at(curr_inner, sp);
627           along->source()->mark() = BOP(curr_inner->mark(),
628                                         curr_outer->mark(), inv);
629 
630           CGAL_NEF_TRACEN("first_first " << first_first);
631 
632           SHalfedge_handle across;
633           if(curr_inner == seb[0])
634             across = first_first ?
635               D.new_shalfedge_pair(sv[2], along, -1) :
636               D.new_shalfedge_pair(previous_first, along, -1, -1);
637           else
638             across =
639               D.new_shalfedge_pair(previous_inner->twin(),
640                                    curr_inner->twin(), -1, 1);
641 
642           across->circle() = curr_outer->circle();
643           across->twin()->circle() = curr_outer->twin()->circle();
644           CGAL_NEF_TRACEN("across " << across->source()->point()
645                     << "->" << across->twin()->source()->point()
646                     << ":" << across->circle());
647           CGAL_NEF_TRACEN("across " << normalized(across->circle())
648                     << ", " << normalized(Sphere_circle(across->source()->point(),
649                                                         across->twin()->source()->point())));
650           CGAL_assertion(normalized(across->circle()) ==
651                          normalized(Sphere_circle(across->source()->point(),
652                                                   across->twin()->source()->point())));
653           across->mark() = across->twin()->mark() =
654             BOP(curr_inner->twin()->incident_sface()->mark(), curr_outer->mark(), inv);
655           along->mark() = along->twin()->mark() =
656             BOP(curr_inner->mark(), curr_outer->twin()->incident_sface()->mark(), inv);
657 
658           CGAL_NEF_TRACEN("across " << across->source()->point()
659                     << "->" << across->twin()->source()->point()
660                     << ":" << across->circle() );
661 
662           if(curr_inner == seb[0])
663             previous_first = across;
664 
665           if(!first_first) {
666             SFace_handle sf_new = D.new_sface();
667             D.link_as_face_cycle(across->twin(), sf_new);
668             sf_new->mark() = BOP(curr_inner->twin()->incident_sface()->mark(),
669                                  curr_outer->twin()->incident_sface()->mark(), inv);
670             CGAL_NEF_TRACEN("new sface " << sf_new->mark());
671           }
672           previous_inner = curr_inner;
673           first_first = false;
674         }
675 
676         previous_last = first_last ?
677           D.new_shalfedge_pair(sv[3], previous_inner->twin(), -1) :
678           D.new_shalfedge_pair(previous_last, previous_inner->twin(), 1, -1);
679         previous_last->circle() = curr_outer->twin()->circle();
680         previous_last->twin()->circle() = curr_outer->circle();
681         CGAL_assertion(previous_last->circle() ==
682                        normalized(Sphere_circle(previous_last->source()->point(),
683                                                 previous_last->twin()->source()->point())));
684         previous_last->mark() = previous_last->twin()->mark() =
685           BOP(previous_inner->incident_sface()->mark(), curr_outer->mark(), inv);
686 
687         if(!first_last) {
688           SFace_handle sf_new = D.new_sface();
689           D.link_as_face_cycle(previous_last, sf_new);
690           sf_new->mark() = BOP(previous_inner->incident_sface()->mark(),
691                                curr_outer->twin()->incident_sface()->mark(), inv);
692         }
693         first_last = false;
694       }
695 
696       CGAL_NEF_TRACEN("sce[0]->mark() " << sce[0]->twin()->incident_sface()->mark());
697       SHalfedge_around_svertex_circulator curr_inner(seb[0]);
698       CGAL_For_all(curr_inner, see[0]) {
699         CGAL_NEF_TRACEN("schleife oben " << curr_inner->source()->point()
700                         << "->" << curr_inner->twin()->source()->point());
701         curr_inner->mark() = curr_inner->twin()->mark() =
702           BOP(curr_inner->mark(), sce[0]->twin()->incident_sface()->mark(), inv);
703         if(!equator[0] && curr_inner == seb[0]) continue;
704         SFace_handle sf = curr_inner->twin()->incident_sface();
705         SHalfedge_around_sface_circulator hfc(curr_inner->twin()), hend(hfc);
706         CGAL_For_all(hfc,hend) hfc->incident_sface() = sf;
707         sf->mark() = BOP(curr_inner->twin()->incident_sface()->mark(),
708                          sce[0]->twin()->incident_sface()->mark(), inv);
709       }
710       CGAL_assertion(curr_inner == see[0]);
711 
712       CGAL_NEF_TRACEN("before equator[0] oben " << curr_inner->source()->point()
713                 << "->" << curr_inner->twin()->source()->point());
714 
715       if(equator[2]) {
716         SFace_handle sf = curr_inner->twin()->incident_sface();
717         SHalfedge_around_sface_circulator hfc(curr_inner->twin()), hend(hfc);
718         CGAL_For_all(hfc,hend) hfc->incident_sface() = sf;
719         sf->mark() = BOP(curr_inner->twin()->incident_sface()->mark(),
720                          sce[0]->twin()->incident_sface()->mark(), inv);
721       } else
722         --curr_inner;
723 
724       CGAL_NEF_TRACEN("final sface oben " << curr_inner->source()->point()
725                 << "->" << curr_inner->twin()->source()->point());
726 
727       SFace_handle sf = curr_inner->incident_sface();
728       SHalfedge_around_sface_circulator hfc(curr_inner), hend(hfc);
729       CGAL_For_all(hfc,hend) hfc->incident_sface() = sf;
730 
731     } else if(empty_e[0] && !empty_c[0]) {
732 
733       CGAL_assertion_msg(!equator[0] && !equator[1] &&
734                          !equator[2] && !equator[3],
735                          "not implemented, yet" );
736       CGAL_assertion_msg(empty_c[1], "not implemented, yet");
737       CGAL_assertion_msg(sv[2]->out_sedge() == SHalfedge_handle(),
738                          "not implemented, yet");
739       CGAL_assertion_msg(sv[3]->out_sedge() == SHalfedge_handle(),
740                          "not implemented, yet");
741       CGAL_assertion_msg(!empty_e[1], "not implemented, yet");
742 
743       Mark outer_sf = seb[1]->twin()->incident_sface()->mark();
744       SHalfedge_handle se_prev =
745         D.new_shalfedge_pair(sv[2], sv[3]);
746       se_prev->circle() = scb[0]->circle();
747       se_prev->twin()->circle() = scb[0]->twin()->circle();
748       se_prev->mark() = se_prev->twin()->mark() =
749         BOP(outer_sf, scb[0]->mark());
750       SHalfedge_around_svertex_const_circulator curr(scb[0]);
751       ++curr;
752       while(curr != scb[0]) {
753         se_prev = D.new_shalfedge_pair(se_prev, se_prev->twin(), 1, -1);
754         //        SM_io_parser<SM_decorator>::dump(D, std::cerr);
755         se_prev->circle() = curr->circle();
756         se_prev->twin()->circle() = curr->twin()->circle();
757         se_prev->mark() = se_prev->twin()->mark() =
758           BOP(outer_sf, curr->mark());
759         SFace_handle sf_new = D.new_sface();
760         sf_new->mark() =
761           BOP(outer_sf, curr->twin()->incident_sface()->mark(), inv);
762         D.link_as_face_cycle(se_prev->twin(), sf_new);
763         ++curr;
764       }
765       seb[1]->twin()->incident_sface()->mark() =
766         BOP(outer_sf, scb[0]->twin()->incident_sface()->mark(), inv);
767       D.link_as_face_cycle(se_prev, seb[1]->twin()->incident_sface());
768       //      SM_io_parser<SM_decorator>::dump(D, std::cerr);
769 
770     } else if(empty_c[0] && !empty_e[0]) {
771 
772       CGAL_assertion_msg(!equator[0] && !equator[1] &&
773                          !equator[2] && !equator[3],
774                          "not implemented, yet" );
775       CGAL_assertion_msg(empty_e[1], "not implemented, yet");
776       CGAL_assertion_msg(!empty_c[1], "not implemented, yet");
777 
778       Mark outer_sf = scb[1]->twin()->incident_sface()->mark();
779       SHalfedge_around_svertex_circulator curr(seb[0]);
780       CGAL_For_all(curr, see[0]) {
781         curr->mark() = curr->twin()->mark() =
782           BOP(curr->mark(), outer_sf, inv);
783         curr->incident_sface()->mark() =
784           BOP(curr->incident_sface()->mark(), outer_sf, inv);
785       }
786     }
787     // else
788     //      CGAL_assertion_msg(false, "not implemented, yet");
789 
790 
791 
792     CGAL_NEF_TRACEN("empty[1] " << empty_c[1] << ", " << empty_e[1] );
793 
794     CGAL_NEF_TRACEN("[1] " << (std::distance(scb[1], sce[1]))
795               << ", " << (std::distance(seb[1], see[1])) );
796 
797     if(!empty_c[1] && !empty_e[1]) {
798       CGAL_assertion(first_first == empty_c[0]);
799       if(first_first) { // nothing happend on the other half
800         if(equator[2] || equator[3]) {
801           first_first = false;
802           previous_first = sv[3]->out_sedge();
803           if(equator[3] && previous_first->twin()->source() != sv[1])
804             previous_first = previous_first->twin()->snext();
805           CGAL_assertion(!equator[3] || previous_first->twin()->source() == sv[1]);
806         }
807 
808         if(equator[0] || equator[1]) {
809           first_last = false;
810           previous_last = sv[2]->out_sedge();
811           if(equator[1] && previous_last->twin()->source() != sv[1])
812             previous_last = previous_last->sprev()->twin();
813           CGAL_assertion(!equator[1] || previous_last->twin()->source() == sv[1]);
814         }
815       } else { // rotate over gap on unhandled half
816         CGAL_assertion(!first_first && !first_last);
817         std::swap(previous_last, previous_first);
818         previous_first = previous_first->twin()->snext();
819         if(equator[0])
820           previous_first = previous_first->twin()->snext();
821         previous_last = previous_last->sprev()->twin();
822         if(equator[2])
823           previous_last = previous_last->sprev()->twin();
824       }
825 
826       SHalfedge_around_svertex_const_circulator curr_outer(sce[1]);
827       do {
828         --curr_outer;
829         CGAL_NEF_TRACEN("outer " << curr_outer->incident_sface()->mark());
830         CGAL_assertion(curr_outer->source()->point() == sv[2]->point());
831         SHalfedge_handle previous_inner;
832         Sphere_segment seg1(sv[2]->point(), sv[3]->point(),
833                             curr_outer->circle());
834         SHalfedge_around_svertex_circulator curr_inner(seb[1]);
835         CGAL_For_all(curr_inner, see[1]) {
836           CGAL_NEF_TRACEN("inner " << curr_inner->incident_sface()->mark());
837 
838           CGAL_assertion(curr_inner->source() == sv[0]);
839           Sphere_segment seg0(sv[0]->point(), sv[1]->point(), curr_inner->circle());
840           Sphere_segment segX(curr_inner->source()->point(),
841                               curr_inner->twin()->source()->point(),
842                               curr_inner->circle());
843           CGAL_assertion(!seg0.is_long());
844           CGAL_assertion(!segX.is_long());
845           Sphere_point sp = normalized(seg0.intersection(seg1));
846 
847           CGAL_NEF_TRACEN("first_first " << first_first);
848           CGAL_NEF_TRACEN("first_last " << first_last);
849           CGAL_NEF_TRACEN("intersections unten " << sp );
850           CGAL_assertion(segX.has_on(sp));
851           CGAL_assertion(curr_inner == seb[1] ||
852                          Sphere_segment(sv[3]->point(), sp).has_on
853                          (previous_inner->twin()->source()->point()));
854           CGAL_assertion(seg0.has_on(sp));
855           CGAL_assertion(seg1.has_on(sp));
856           CGAL_NEF_TRACEN("seg 0 " << seg0.source() << "->" << seg0.target());
857           CGAL_NEF_TRACEN("seg 1 " << seg1.source() << "->" << seg1.target() << ":" << seg1.sphere_circle());
858 
859           SHalfedge_handle along = D.split_at(curr_inner, sp);
860           along->source()->mark() = BOP(curr_inner->mark(), curr_outer->mark(), inv);
861 
862           SHalfedge_handle across;
863           if(curr_inner == seb[1])
864             across = first_first ?
865               D.new_shalfedge_pair(sv[3], along, -1) :
866               D.new_shalfedge_pair(previous_first, along, 1, -1);
867           else
868             across =
869               D.new_shalfedge_pair(previous_inner->twin(), curr_inner->twin(), -1, 1);
870 
871           across->circle() = curr_outer->twin()->circle();
872           across->twin()->circle() = curr_outer->circle();
873           CGAL_NEF_TRACEN("across " << across->source()->point()
874                     << "->" << across->twin()->source()->point()
875                     << ":" << across->circle());
876           CGAL_NEF_TRACEN("across " << normalized(across->circle())
877                     << ", " << normalized(Sphere_circle(across->source()->point(),
878                                                         across->twin()->source()->point())));
879           CGAL_assertion(normalized(across->circle()) ==
880                          normalized(Sphere_circle(across->source()->point(),
881                                                   across->twin()->source()->point())));
882           across->mark() = across->twin()->mark() =
883             BOP(curr_inner->twin()->incident_sface()->mark(),
884                 curr_outer->mark(), inv);
885           along->mark() = along->twin()->mark() =
886             BOP(curr_inner->mark(),
887                 curr_outer->incident_sface()->mark(), inv);
888 
889           if(curr_inner == seb[1])
890             previous_first = across;
891 
892           if(!first_first) {
893             SFace_handle sf_new = D.new_sface();
894             D.link_as_face_cycle(across->twin(), sf_new);
895             sf_new->mark() = BOP(curr_inner->twin()->incident_sface()->mark(),
896                                  curr_outer->incident_sface()->mark(), inv);
897             CGAL_NEF_TRACEN("new sface" << sf_new->mark() );
898           }
899           previous_inner = curr_inner;
900           first_first = false;
901         }
902 
903         previous_last = first_last ?
904           D.new_shalfedge_pair(sv[2], previous_inner->twin(), -1) :
905           D.new_shalfedge_pair(previous_last, previous_inner->twin(), -1, -1);
906         previous_last->circle() = curr_outer->circle();
907         previous_last->twin()->circle() = curr_outer->twin()->circle();
908         CGAL_assertion(normalized(previous_last->circle()) ==
909                        normalized(Sphere_circle(previous_last->source()->point(),
910                                                 previous_last->twin()->source()->point())));
911         previous_last->mark() = previous_last->twin()->mark() =
912           BOP(previous_inner->incident_sface()->mark(), curr_outer->mark(), inv);
913 
914 
915         if(!first_last) {
916           SFace_handle sf_new = D.new_sface();
917           D.link_as_face_cycle(previous_last, sf_new);
918           sf_new->mark() = BOP(previous_inner->incident_sface()->mark(),
919                                curr_outer->incident_sface()->mark(), inv);
920           CGAL_NEF_TRACEN("new sface" << sf_new->mark() );
921         }
922 
923         first_last = false;
924       } while(curr_outer != scb[1]);
925 
926       SHalfedge_around_svertex_circulator curr_inner(seb[1]);
927       CGAL_For_all(curr_inner, see[1]) {
928         CGAL_NEF_TRACEN("schleife " << curr_inner->source()->point()
929                   << "->" << curr_inner->twin()->source()->point());
930         curr_inner->mark() = curr_inner->twin()->mark() =
931           BOP(curr_inner->mark(), scb[1]->twin()->incident_sface()->mark(), inv);
932         if(!equator[0] && curr_inner == seb[1]) continue;
933         SFace_handle sf = curr_inner->twin()->incident_sface();
934         SHalfedge_around_sface_circulator hfc(curr_inner->twin()), hend(hfc);
935         CGAL_For_all(hfc,hend) hfc->incident_sface() = sf;
936         sf->mark() = BOP(curr_inner->twin()->incident_sface()->mark(),
937                          scb[1]->twin()->incident_sface()->mark(), inv);
938       }
939       CGAL_assertion(curr_inner == see[1]);
940 
941       CGAL_NEF_TRACEN("before equator[2] " << curr_inner->source()->point()
942                 << "->" << curr_inner->twin()->source()->point());
943 
944       if(equator[2] ||
945          (!empty_c[0] && !empty_e[0])) {
946         SFace_handle sf = curr_inner->twin()->incident_sface();
947         SHalfedge_around_sface_circulator hfc(curr_inner->twin()), hend(hfc);
948         CGAL_For_all(hfc,hend) hfc->incident_sface() = sf;
949         sf->mark() = BOP(curr_inner->twin()->incident_sface()->mark(),
950                          scb[1]->twin()->incident_sface()->mark(), inv);
951       } else
952         --curr_inner;
953 
954       CGAL_NEF_TRACEN("final sface " << curr_inner->source()->point()
955                 << "->" << curr_inner->twin()->source()->point());
956 
957       SFace_handle sf = curr_inner->incident_sface();
958       SHalfedge_around_sface_circulator hfc(curr_inner), hend(hfc);
959       CGAL_For_all(hfc,hend) hfc->incident_sface() = sf;
960     } else if(empty_e[1] && !empty_c[1]) {
961 
962       CGAL_assertion_msg(!equator[0] && !equator[1] &&
963                          !equator[2] && !equator[3],
964                          "not implemented, yet" );
965       CGAL_assertion_msg(empty_c[0], "not implemented, yet");
966       CGAL_assertion_msg(sv[2]->out_sedge() == SHalfedge_handle(),
967                          "not implemented, yet");
968       CGAL_assertion_msg(sv[3]->out_sedge() == SHalfedge_handle(),
969                          "not implemented, yet");
970       CGAL_assertion_msg(!empty_e[0], "not implemented, yet");
971 
972       Mark outer_sf = seb[0]->twin()->incident_sface()->mark();
973       SHalfedge_handle se_prev =
974         D.new_shalfedge_pair(sv[2], sv[3]);
975       se_prev->circle() = scb[1]->circle();
976       se_prev->twin()->circle() = scb[1]->twin()->circle();
977       se_prev->mark() = se_prev->twin()->mark() =
978         BOP(outer_sf, scb[1]->mark());
979       SHalfedge_around_svertex_const_circulator curr(scb[1]);
980       ++curr;
981       while(curr != scb[1]) {
982         se_prev = D.new_shalfedge_pair(se_prev, se_prev->twin(), 1, -1);
983         //        SM_io_parser<SM_decorator>::dump(D, std::cerr);
984         se_prev->circle() = curr->circle();
985         se_prev->twin()->circle() = curr->twin()->circle();
986         se_prev->mark() = se_prev->twin()->mark() =
987           BOP(outer_sf, curr->mark());
988         SFace_handle sf_new = D.new_sface();
989         sf_new->mark() =
990           BOP(outer_sf, curr->twin()->incident_sface()->mark(), inv);
991         D.link_as_face_cycle(se_prev->twin(), sf_new);
992         ++curr;
993       }
994 
995       seb[0]->twin()->incident_sface()->mark() =
996         BOP(outer_sf, scb[1]->twin()->incident_sface()->mark(), inv);
997       D.link_as_face_cycle(se_prev, seb[0]->twin()->incident_sface());
998 
999     } else if(empty_c[1] && !empty_e[1]) {
1000 
1001       CGAL_assertion_msg(!equator[0] && !equator[1] &&
1002                          !equator[2] && !equator[3],
1003                          "not implemented, yet" );
1004       CGAL_assertion_msg(empty_e[0], "not implemented, yet");
1005       CGAL_assertion_msg(!empty_c[0], "not implemented, yet");
1006 
1007       Mark outer_sf = scb[0]->twin()->incident_sface()->mark();
1008       SHalfedge_around_svertex_circulator curr(seb[1]);
1009       CGAL_For_all(curr, see[1]) {
1010         curr->mark() = curr->twin()->mark() =
1011           BOP(curr->mark(), outer_sf, inv);
1012         curr->incident_sface()->mark() =
1013           BOP(curr->incident_sface()->mark(), outer_sf, inv);
1014       }
1015     }
1016     //    else
1017     //      CGAL_assertion_msg(false, "not implemented, yet");
1018 
1019 //    SM_io_parser<SM_decorator>::dump(D, std::cerr);
1020 
1021     return D.sphere_map();
1022   }
1023 
1024 };
1025 
1026 } //namespace CGAL
1027 #endif //CGAL_EDGE_EDGE_OVERLAY_H
1028