@@ -231,38 +231,39 @@ void Tearing::restoreSBG()
231231 mapB_ = dsbg_.mapB ();
232232 mapD_ = dsbg_.mapD ();
233233}
234-
234+ PWMap Tearing::calculateSCC ()
235+ {
236+ PWMap rmap = sccStep ();
237+ do {
238+ rmap = sccStep ();
239+ } while (Ediff () != fact_.createSet ());
240+ return rmap.compact ();
241+ }
235242PWMap Tearing::calculate ()
236243{
237244 if (debug ()) Util::SBG_LOG << " Tearing dsbg: \n " << dsbg () << " \n\n " ;
238245
239246 auto begin = std::chrono::high_resolution_clock::now ();
240- PWMap rmap = sccStep ();
241247 Set vrem = fact_.createSet ();
242- Set e_scc = fact_.createSet ();
243- do {
244- // SCC
245- do {
246- rmap = sccStep ();
247- } while (Ediff () != fact_.createSet ());
248- //
249- e_scc = E ();
250- if (E () != fact_.createSet ()) {
251- Set erem_b = mapB ().preImage (rmap.image ());
252- Set erem_d = mapD ().preImage (rmap.image ());
253- vrem = vrem.cup (mapB ().image (erem_b)).cup (mapD ().image (erem_d));
254- E_ = E ().difference (erem_b.cup (erem_d));
255- }
256- rmap_ = rmap.compact ();
257- } while (E () != fact_.createSet ());
258- restoreSBG ();
259- Set e_notscc = E ().difference (e_scc);
260- Set e_to_R = mapD ().preImage (rmap.image ());
261- PWMap mapD_notscc = mapD ().restrict (e_to_R);
262-
263- Set erem = e_scc.intersection (mapB ().preImage (vrem));
264- Set mapD_aux = mapD ().image (erem);
265-
248+ Set e_notscc = dsbg ().E ();
249+ MD_NAT maxOffset = V ().maxElem ();
250+ PWMap rmap = calculateSCC ();
251+ PWMap tearIOMap_ = fact_.createPWMap ();
252+ rmap_ = rmap;
253+
254+ while (!E ().isEmpty ()) {
255+ Set e_scc = E ();
256+ Set e_noscc = e_notscc.difference (e_scc);
257+ Set v_tear = rmap.image ();
258+ PWMap tearIOMap = fact_.createPWMap (v_tear).offsetImage (maxOffset);
259+ tearIOMap_ = tearIOMap.combine (tearIOMap_);
260+ PWMap mapB_scc = mapB ().restrict (e_scc).composition (rmap);
261+ PWMap mapB_noscc = mapB ().restrict (e_noscc).composition (rmap).composition (tearIOMap);
262+ PWMap mapD_scc = mapD ().restrict (e_scc).composition (rmap).composition (tearIOMap);
263+ PWMap mapD_noscc = mapD ().restrict (e_noscc).composition (rmap);
264+ // combine wit mapB and mapD
265+ rmap = calculateSCC ();
266+ }
266267 auto end = std::chrono::high_resolution_clock::now ();
267268
268269 auto total = std::chrono::duration_cast<std::chrono::microseconds>(end - begin);
@@ -275,7 +276,7 @@ PWMap Tearing::calculate()
275276 E ().print (std::cout);
276277 }
277278
278- return rmap. compact () ;
279+ return rmap_ ;
279280}
280281
281282const PWMapAF &Tearing::fact () const { return fact_; }
0 commit comments