00001
00002
00003
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef _CHOMP_HOMOLOGY_CUBISETS_H_
00036 #define _CHOMP_HOMOLOGY_CUBISETS_H_
00037
00038 #include "chomp/system/config.h"
00039 #include "chomp/system/textfile.h"
00040 #include "chomp/cubes/pointset.h"
00041 #include "chomp/homology/chains.h"
00042 #include "chomp/struct/bitfield.h"
00043 #include "chomp/struct/integer.h"
00044 #include "chomp/struct/hashsets.h"
00045 #include "chomp/struct/setunion.h"
00046 #include "chomp/homology/gcomplex.h"
00047 #include "chomp/cubes/pointbas.h"
00048 #include "chomp/cubes/cube.h"
00049 #include "chomp/cubes/cell.h"
00050 #include "chomp/cubes/cubmaps.h"
00051 #include "chomp/cubes/neighbor.h"
00052 #include "chomp/homology/cubacycl.h"
00053 #include "chomp/homology/tabulate.h"
00054 #include "chomp/homology/known.h"
00055
00056 #include <iostream>
00057 #include <fstream>
00058 #include <cstdlib>
00059
00060 namespace chomp {
00061 namespace homology {
00062
00063
00064
00065
00066
00069 inline int acyclic (int dim, BitField &b)
00070 {
00071
00072 const char *table = tabulated [dim];
00073 if (table)
00074 {
00075 return Tabulated::get (table,
00076 bits2int (b, getmaxneighbors (dim)));
00077 }
00078
00079
00080 SetOfBitFields *known = knownbits [dim];
00081 int answer = known ? known -> check (b) : -1;
00082
00083
00084 if (answer >= 0)
00085 return answer;
00086
00087
00088 coordinate c [Cube::MaxDim];
00089 for (int i = 0; i < dim; ++ i)
00090 c [i] = 0;
00091 Cube qzero (c, dim);
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 gcomplex<CubicalCell,integer> neighbors;
00102 addneighbors (qzero, b, neighbors, true);
00103 answer = static_cast<int> (acyclic (neighbors));
00104
00105
00106 if (known)
00107 known -> add (b, answer);
00108
00109 return answer;
00110 }
00111
00114 template <class tCube>
00115 inline bool acyclic (const hashedset<tCube> &cset)
00116 {
00117
00118 if (cset. empty ())
00119 return false;
00120
00121
00122 if (cset. size () == 1)
00123 return true;
00124
00125
00126 hashedset<tCube> emptycubes;
00127 hashedset<tCube> theset = cset;
00128 cubreducequiet (emptycubes, theset, emptycubes);
00129 if (theset. size () == 1)
00130 return true;
00131
00132
00133 gcomplex<typename tCube::CellType,integer> ccompl;
00134 int_t size = cset. size ();
00135 for (int_t i = 0; i < size; ++ i)
00136 ccompl. add (typename tCube::CellType (cset [i]));
00137
00138
00139 return acyclic (ccompl);
00140 }
00141
00152 template <class tCube, class tCubeSet1, class tCubeSet2>
00153 inline bool acyclic (const tCube &q, int dim, const tCubeSet1 &cset,
00154 BitField *b, int_t maxneighbors, tCubeSet2 *neighbors)
00155 {
00156
00157 if (dim <= MaxBddDim)
00158 return bddacyclic (q, dim, cset, *b);
00159
00160
00161 int_t n = getneighbors (q, b, cset, neighbors, 0);
00162
00163
00164 if ((n == 0) || (n == maxneighbors))
00165 return false;
00166 if (n == 1)
00167 return true;
00168
00169
00170 return acyclic (dim, *b);
00171 }
00172
00175 template <class tCube, class tCubeSet>
00176 inline bool acyclic (const tCube &q, int dim, const tCubeSet &cset,
00177 BitField *b, int_t maxneighbors)
00178 {
00179 hashedset<tCube> *neighbors = 0;
00180 return acyclic (q, dim, cset, b, maxneighbors, neighbors);
00181 }
00182
00184 template <class tCube>
00185 bool acyclic_rel (const tCube &q, int dim, const hashedset<tCube> &cset,
00186 const hashedset<tCube> &other, BitField *b, int_t maxneighbors,
00187 hashedset<tCube> *neighbors_main, hashedset<tCube> *neighbors_other)
00188 {
00189
00190 if (dim <= MaxBddDim)
00191 {
00192 if (!getneighbors (q, b, cset, 1))
00193 return true;
00194 if (!bddacyclic (q, dim, other, *b))
00195 return false;
00196 return bddacyclic (q, dim, makesetunion (cset, other), *b);
00197 }
00198
00199
00200 int_t nother = getneighbors (q, b, other, neighbors_other, 0);
00201
00202
00203 bool otheracyclic = (nother < maxneighbors) &&
00204 ((nother == 1) || (nother && acyclic (dim, *b)));
00205
00206
00207 int_t ncset = getneighbors (q, b, cset, neighbors_main, 0);
00208
00209
00210 if (!ncset)
00211 return true;
00212
00213
00214
00215 if (!otheracyclic)
00216 return false;
00217
00218
00219
00220 if ((ncset + nother > 1) && ((ncset + nother == maxneighbors) ||
00221 !acyclic (dim, *b)))
00222 {
00223 return false;
00224 }
00225 return true;
00226 }
00227
00228
00229
00230
00231
00232
00236 template <class tCube, class tCell>
00237 int_t computeimage (hashedset<tCube> &img, const tCell &face,
00238 const mvmap<tCube,tCube> &map, const hashedset<tCube> &cset,
00239 const tCube &ignore)
00240 {
00241
00242 typename tCell::CoordType left [tCell::MaxDim];
00243 face. leftcoord (left);
00244 typename tCell::CoordType right [tCell::MaxDim];
00245 face. rightcoord (right);
00246
00247
00248 int spacedim = face. spacedim ();
00249 typename tCell::CoordType leftb [tCell::MaxDim];
00250 typename tCell::CoordType rightb [tCell::MaxDim];
00251 for (int j = 0; j < spacedim; ++ j)
00252 {
00253 typename tCell::CoordType diff =
00254 (left [j] == right [j]) ? 1 : 0;
00255 leftb [j] = (left [j] - diff);
00256 rightb [j] = (right [j] + diff);
00257 }
00258 tRectangle<typename tCell::CoordType> r (leftb, rightb, spacedim);
00259 const typename tCell::CoordType *c;
00260 int_t countimages = 0;
00261 while ((c = r. get ()) != NULL)
00262 {
00263 if (!tCube::PointBase::check (c, spacedim))
00264 continue;
00265 tCube q (c, spacedim);
00266 if (q == ignore)
00267 continue;
00268 if (!cset. check (q))
00269 continue;
00270 img. add (map (q));
00271 ++ countimages;
00272 }
00273
00274 return countimages;
00275 }
00276
00281 template <class tCube>
00282 bool remainsacyclic (const mvmap<tCube,tCube> &map, const tCube &q,
00283 const hashedset<tCube> &cset1, const hashedset<tCube> *cset2 = 0)
00284 {
00285
00286 int_t maxneighbors = getmaxneighbors (q. dim ());
00287
00288
00289 static BitField b;
00290 static int_t _maxneighbors = 0;
00291 if (maxneighbors != _maxneighbors)
00292 {
00293 if (_maxneighbors > 0)
00294 b. free ();
00295 _maxneighbors = maxneighbors;
00296 b. allocate (maxneighbors);
00297 }
00298
00299
00300 b. clearall (maxneighbors);
00301
00302
00303 if (cset2)
00304 getneighbors (q, &b, makesetunion (cset1, *cset2), 0);
00305 else
00306 getneighbors (q, &b, cset1, 0);
00307
00308
00309 gcomplex<typename tCube::CellType,integer> faces;
00310 addneighbors (q, b, faces);
00311 faces. addboundaries ();
00312
00313
00314
00315 int startdim = faces. dim ();
00316 for (int d = startdim; d >= 0; -- d)
00317 {
00318 for (int_t i = 0; i < faces [d]. size (); ++ i)
00319 {
00320
00321 hashedset<tCube> img;
00322 int_t n = computeimage (img, faces [d] [i], map,
00323 cset1, q);
00324
00325
00326 if (cset2)
00327 {
00328 n += computeimage (img, faces [d] [i], map,
00329 *cset2, q);
00330 }
00331
00332
00333 if (n == 1)
00334 continue;
00335
00336
00337
00338 hashedset<tCube> imgsurplus = map (q);
00339 imgsurplus. remove (img);
00340 cubreducequiet (img, imgsurplus);
00341 if (!imgsurplus. empty ())
00342 return false;
00343 }
00344 }
00345
00346 return true;
00347 }
00348
00356 template <class tCube, class tCubeSet>
00357 inline void addcubeneighbors (const tCube &q, int dim,
00358 const tCubeSet &cubset, bitfield *b, hashedset<tCube> &neighbors,
00359 hashedset<tCube> &queue, const hashedset<tCube> ¬these)
00360 {
00361
00362 if (dim <= MaxBddDim)
00363 getneighbors (q, b, cubset, &neighbors, 0);
00364
00365
00366 for (int_t j = 0; j < neighbors. size (); ++ j)
00367 {
00368 if (!notthese. check (neighbors [j]))
00369 queue. add (neighbors [j]);
00370 }
00371
00372 return;
00373 }
00374
00378 template <class tCube>
00379 int_t cubreducequiet (const hashedset<tCube> &maincset, hashedset<tCube> &cset,
00380 bool quiet = true)
00381 {
00382
00383 int_t prev = cset. size ();
00384
00385
00386 if (!prev)
00387 return 0;
00388
00389
00390 int dim = cset [0]. dim ();
00391
00392
00393 int_t maxneighbors = getmaxneighbors (dim);
00394
00395
00396 static BitField b;
00397 static int_t _maxneighbors = 0;
00398 if (maxneighbors != _maxneighbors)
00399 {
00400 if (_maxneighbors > 0)
00401 b. free ();
00402 _maxneighbors = maxneighbors;
00403 b. allocate (maxneighbors);
00404 }
00405
00406
00407 hashedset<tCube> queue;
00408
00409
00410 int_t count = 0;
00411
00412
00413
00414 for (int_t i = 0; i < cset. size (); ++ i)
00415 {
00416
00417 ++ count;
00418 if (!quiet && !(count % 373))
00419 scon << std::setw (10) << count <<
00420 "\b\b\b\b\b\b\b\b\b\b";
00421
00422
00423 b. clearall (maxneighbors);
00424
00425
00426 hashedset<tCube> neighbors;
00427
00428
00429 if (!acyclic (cset [i], dim, makesetunion (maincset, cset),
00430 &b, maxneighbors, &neighbors))
00431 {
00432 continue;
00433 }
00434
00435
00436 queue. remove (cset [i]);
00437
00438
00439
00440 addcubeneighbors (cset [i], dim, cset, &b, neighbors,
00441 queue, maincset);
00442
00443
00444 if (!quiet)
00445 sseq << '0' << cset [i] << '\n';
00446 cset. removenum (i);
00447 -- i;
00448 }
00449
00450
00451 if (!quiet)
00452 scon << "*";
00453 count = 0;
00454
00455
00456 while (!queue. empty ())
00457 {
00458
00459 if (!quiet && !(count % 373))
00460 scon << std::setw (10) << count <<
00461 "\b\b\b\b\b\b\b\b\b\b";
00462 ++ count;
00463
00464
00465 tCube c = queue [0];
00466 queue. removenum (0);
00467
00468
00469 b. clearall (maxneighbors);
00470
00471
00472 hashedset<tCube> neighbors;
00473
00474
00475 if (!acyclic (c, dim, makesetunion (maincset, cset),
00476 &b, maxneighbors, &neighbors))
00477 {
00478 continue;
00479 }
00480
00481
00482
00483 addcubeneighbors (c, dim, cset, &b, neighbors,
00484 queue, maincset);
00485
00486
00487 if (!quiet)
00488 sseq << '0' << c << '\n';
00489 cset. remove (c);
00490 }
00491
00492
00493 if (!quiet)
00494 scon << "\b \b";
00495
00496
00497 return prev - cset. size ();
00498 }
00499
00500
00503 template <class tCube>
00504 inline int_t cubreduce (const hashedset<tCube> &maincset,
00505 hashedset<tCube> &cset)
00506 {
00507 return cubreducequiet (maincset, cset, false);
00508 }
00509
00515 template <class tCube>
00516 int_t cubreducequiet (hashedset<tCube> &cset, hashedset<tCube> &other,
00517 mvmap<tCube,tCube> &map, const hashedset<tCube> &keep,
00518 bool quiet = true)
00519 {
00520
00521 bool checkacyclic = !map. getdomain (). empty ();
00522
00523
00524 int_t prev = cset. size () + other. size ();
00525
00526
00527 if (cset. empty ())
00528 {
00529 if (!other. empty ())
00530 {
00531 hashedset<tCube> empty;
00532 other = empty;
00533 }
00534 return prev;
00535 }
00536
00537
00538 int dim = cset [0]. dim ();
00539
00540
00541 int_t maxneighbors = getmaxneighbors (dim);
00542
00543
00544 static BitField b;
00545 static int_t _maxneighbors = 0;
00546 if (maxneighbors != _maxneighbors)
00547 {
00548 if (_maxneighbors > 0)
00549 b. free ();
00550 _maxneighbors = maxneighbors;
00551 b. allocate (maxneighbors);
00552 }
00553
00554
00555 hashedset<tCube> queue;
00556
00557
00558 int_t count = 0;
00559
00560
00561
00562 for (int_t i = 0; i < other. size (); ++ i)
00563 {
00564
00565 ++ count;
00566 if (!quiet && !(count % 373))
00567 scon << std::setw (10) << count <<
00568 "\b\b\b\b\b\b\b\b\b\b";
00569
00570
00571 if (keep. check (other [i]))
00572 continue;
00573
00574
00575 b. clearall (maxneighbors);
00576
00577
00578 hashedset<tCube> neighbors, *none = 0;
00579
00580
00581 if (!acyclic_rel (other [i], dim, cset, other, &b,
00582 maxneighbors, none, &neighbors))
00583 {
00584 continue;
00585 }
00586
00587
00588 if (checkacyclic && !remainsacyclic (map, other [i], other))
00589 continue;
00590
00591
00592 if (checkacyclic && !remainsacyclic (map, other [i],
00593 other, &cset))
00594 continue;
00595
00596
00597 queue. remove (other [i]);
00598
00599
00600
00601 addcubeneighbors (other [i], dim, other, &b, neighbors,
00602 queue, keep);
00603
00604
00605 if (!quiet)
00606 sseq << '0' << other [i] << '\n';
00607 other. removenum (i);
00608 -- i;
00609 }
00610
00611
00612 if (!quiet)
00613 scon << '.';
00614 count = 0;
00615
00616
00617
00618 for (int_t i = 0; i < cset. size (); ++ i)
00619 {
00620
00621 if (!quiet && !(count % 373))
00622 scon << std::setw (10) << count <<
00623 "\b\b\b\b\b\b\b\b\b\b";
00624 ++ count;
00625
00626
00627 if (keep. check (cset [i]))
00628 continue;
00629
00630
00631 b. clearall (maxneighbors);
00632
00633
00634 hashedset<tCube> neighbors;
00635
00636
00637 if (!acyclic (cset [i], dim, makesetunion (cset, other),
00638 &b, maxneighbors, &neighbors))
00639 {
00640 continue;
00641 }
00642
00643
00644 if (checkacyclic && !remainsacyclic (map, cset [i],
00645 cset, &other))
00646 {
00647 continue;
00648 }
00649
00650
00651 queue. remove (cset [i]);
00652
00653
00654
00655 addcubeneighbors (cset [i], dim, makesetunion (cset, other),
00656 &b, neighbors, queue, keep);
00657
00658
00659 if (!quiet)
00660 sseq << '0' << cset [i] << '\n';
00661 cset. removenum (i);
00662 -- i;
00663 }
00664
00665
00666 if (!quiet)
00667 scon << "\b*";
00668 count = 0;
00669
00670
00671 while (!queue. empty ())
00672 {
00673
00674 if (!quiet && !(count % 373))
00675 scon << std::setw (10) << count <<
00676 "\b\b\b\b\b\b\b\b\b\b";
00677 ++ count;
00678
00679
00680 tCube c = queue [0];
00681 queue. removenum (0);
00682
00683
00684 b. clearall (maxneighbors);
00685
00686
00687 if (other. check (c))
00688 {
00689
00690 hashedset<tCube> neighbors;
00691
00692 if (!acyclic_rel (c, dim, cset, other, &b,
00693 maxneighbors, &cset, &other))
00694 {
00695 continue;
00696 }
00697
00698
00699 if (checkacyclic && !remainsacyclic (map, c, other))
00700 continue;
00701
00702
00703 if (checkacyclic && !remainsacyclic (map, c,
00704 other, &cset))
00705 continue;
00706
00707
00708
00709 addcubeneighbors (c, dim, makesetunion (cset, other),
00710 &b, neighbors, queue, keep);
00711
00712
00713 if (!quiet)
00714 sseq << '0' << c << '\n';
00715 other. remove (c);
00716 }
00717
00718
00719 else
00720 {
00721
00722 hashedset<tCube> neighbors;
00723
00724
00725
00726 if (!acyclic (c, dim, makesetunion (cset, other),
00727 &b, maxneighbors, &neighbors))
00728 {
00729 continue;
00730 }
00731
00732
00733 if (checkacyclic && !remainsacyclic (map, c,
00734 cset, &other))
00735 {
00736 continue;
00737 }
00738
00739
00740
00741 addcubeneighbors (c, dim, makesetunion (cset, other),
00742 &b, neighbors, queue, keep);
00743
00744
00745 if (!quiet)
00746 sseq << '0' << c << '\n';
00747 cset. remove (c);
00748 }
00749 }
00750
00751
00752 if (!quiet)
00753 scon << "\b \b";
00754
00755
00756 return prev - cset. size () - other. size ();
00757 }
00758
00763 template <class tCube>
00764 inline int_t cubreduce (hashedset<tCube> &cset, hashedset<tCube> &other,
00765 mvmap<tCube,tCube> &cubmap, const hashedset<tCube> &keep)
00766 {
00767 return cubreducequiet (cset, other, cubmap, keep, false);
00768 }
00769
00774 template <class tCube>
00775 inline int_t cubreducequiet (hashedset<tCube> &cset, hashedset<tCube> &other,
00776 const hashedset<tCube> &keep, bool quiet = true)
00777 {
00778 mvmap<tCube,tCube> emptymap;
00779 return cubreducequiet (cset, other, emptymap, keep, quiet);
00780 }
00781
00785 template <class tCube>
00786 inline int_t cubreduce (hashedset<tCube> &cset, hashedset<tCube> &other,
00787 const hashedset<tCube> &keep)
00788 {
00789 return cubreducequiet (cset, other, keep, false);
00790 }
00791
00792
00793
00794
00795
00796
00799 template <class tCube>
00800 int_t cubexpand (hashedset<tCube> &cset, hashedset<tCube> &other,
00801 bool quiet = false)
00802 {
00803
00804 if (cset. empty () || other. empty ())
00805 return 0;
00806
00807
00808 int_t prev = cset. size ();
00809
00810
00811 int dim = cset [0]. dim ();
00812
00813
00814 int_t maxneighbors = getmaxneighbors (dim);
00815
00816
00817 static BitField b;
00818 static int_t _maxneighbors = 0;
00819 if (maxneighbors != _maxneighbors)
00820 {
00821 if (_maxneighbors > 0)
00822 b. free ();
00823 _maxneighbors = maxneighbors;
00824 b. allocate (maxneighbors);
00825 }
00826
00827
00828 hashedset<tCube> queue;
00829
00830
00831 int_t count = 0;
00832
00833
00834
00835 for (int_t i = 0; i < cset. size (); ++ i)
00836 {
00837
00838 ++ count;
00839 if (!quiet && !(count % 373))
00840 scon << std::setw (10) << count <<
00841 "\b\b\b\b\b\b\b\b\b\b";
00842
00843
00844 b. clearall (maxneighbors);
00845
00846
00847 if (!acyclic (cset [i], dim, other, &b, maxneighbors))
00848 continue;
00849
00850
00851 queue. remove (cset [i]);
00852
00853
00854 b. clearall (maxneighbors);
00855 getneighbors (cset [i], &b, cset, &queue, 0);
00856
00857
00858 if (!quiet)
00859 sseq << '2' << cset [i] << '\n';
00860 other. add (cset [i]);
00861 cset. removenum (i);
00862 -- i;
00863 }
00864
00865
00866 if (!quiet)
00867 scon << '*';
00868 count = 0;
00869
00870
00871 while (queue. size ())
00872 {
00873
00874 if (!quiet && !(count % 373))
00875 scon << std::setw (10) << count <<
00876 "\b\b\b\b\b\b\b\b\b\b";
00877 ++ count;
00878
00879
00880 const tCube c = queue [0];
00881 queue. removenum (0);
00882
00883
00884 b. clearall (maxneighbors);
00885
00886
00887 if (!acyclic (c, dim, other, &b, maxneighbors))
00888 continue;
00889
00890
00891 b. clearall (maxneighbors);
00892 getneighbors (c, &b, cset, &queue, 0);
00893
00894
00895 if (!quiet)
00896 sseq << '2' << c << '\n';
00897 cset. remove (c);
00898 other. add (c);
00899 }
00900
00901
00902 if (!quiet)
00903 scon << "\b \b";
00904
00905
00906 return prev - cset. size ();
00907 }
00908
00915 template <class tCube>
00916 int_t cubexpand (hashedset<tCube> &cset, hashedset<tCube> &other,
00917 hashedset<tCube> &imgsrc, hashedset<tCube> &img,
00918 const mvmap<tCube,tCube> &map, bool indexmap,
00919 bool checkacyclic, bool quiet = false)
00920 {
00921
00922 if (cset. empty () || other. empty ())
00923 return 0;
00924
00925
00926 int_t prev = cset. size ();
00927
00928
00929 int dim = cset [0]. dim ();
00930
00931
00932 int_t maxneighbors = getmaxneighbors (dim);
00933
00934
00935 static BitField b;
00936 static int_t _maxneighbors = 0;
00937 if (maxneighbors != _maxneighbors)
00938 {
00939 if (_maxneighbors > 0)
00940 b. free ();
00941 _maxneighbors = maxneighbors;
00942 b. allocate (maxneighbors);
00943 }
00944
00945
00946 hashedset<tCube> queue;
00947
00948
00949 int_t count = 0;
00950
00951
00952
00953 for (int_t i = 0; i < cset. size (); ++ i)
00954 {
00955
00956 ++ count;
00957 if (!quiet && !(count % 373))
00958 scon << std::setw (10) << count <<
00959 "\b\b\b\b\b\b\b\b\b\b";
00960
00961
00962 const tCube &c = cset [i];
00963
00964
00965 b. clearall (maxneighbors);
00966
00967
00968 if (!acyclic (c, dim, other, &b, maxneighbors))
00969 continue;
00970
00971
00972 const hashedset<tCube> &cubimage = map (c);
00973 hashedset<tCube> ximage = cubimage;
00974 if (indexmap)
00975 ximage. add (c);
00976 ximage. remove (img);
00977 cubreducequiet (img, ximage);
00978
00979
00980 if (!ximage. empty ())
00981 continue;
00982
00983
00984 if (checkacyclic && !remainsacyclic (map, c, other))
00985 continue;
00986
00987
00988 if (!quiet && !cubimage. empty ())
00989 {
00990 sseq << "R\n";
00991 for (int_t j = 0; j < cubimage. size (); ++ j)
00992 sseq << '2' << cubimage [j] << '\n';
00993 if (indexmap)
00994 sseq << '2' << c << '\n';
00995 }
00996 img. add (cubimage);
00997 if (indexmap)
00998 img. add (c);
00999
01000
01001 imgsrc. remove (cubimage);
01002 if (indexmap)
01003 imgsrc. remove (c);
01004
01005
01006 queue. remove (c);
01007
01008
01009 b. clearall (maxneighbors);
01010 getneighbors (c, &b, cset, &queue, 0);
01011
01012
01013 if (!quiet)
01014 sseq << "L\n" << '2' << c << '\n';
01015 other. add (c);
01016 cset. removenum (i);
01017 -- i;
01018 }
01019
01020
01021 if (!quiet)
01022 scon << '*';
01023 count = 0;
01024
01025
01026 while (!queue. empty ())
01027 {
01028
01029 if (!quiet && !(count % 373))
01030 scon << std::setw (10) << count <<
01031 "\b\b\b\b\b\b\b\b\b\b";
01032 ++ count;
01033
01034
01035 tCube c = queue [0];
01036 queue. removenum (0);
01037
01038
01039 b. clearall (maxneighbors);
01040
01041
01042 if (!acyclic (c, dim, other, &b, maxneighbors))
01043 continue;
01044
01045
01046 const hashedset<tCube> &cubimage = map (c);
01047 hashedset<tCube> ximage = cubimage;
01048 if (indexmap)
01049 ximage. add (c);
01050 ximage. remove (img);
01051 cubreducequiet (img, ximage);
01052
01053
01054 if (!ximage. empty ())
01055 continue;
01056
01057
01058 if (checkacyclic && !remainsacyclic (map, c, other))
01059 continue;
01060
01061
01062 if (!quiet && !cubimage. empty ())
01063 {
01064 sseq << "R\n";
01065 for (int_t i = 0; i < cubimage. size (); ++ i)
01066 sseq << '2' << cubimage [i] << '\n';
01067 if (indexmap)
01068 sseq << '2' << c << '\n';
01069 }
01070 img. add (cubimage);
01071 if (indexmap)
01072 img. add (c);
01073
01074
01075 imgsrc. remove (cubimage);
01076 if (indexmap)
01077 imgsrc. remove (c);
01078
01079
01080 b. clearall (maxneighbors);
01081 getneighbors (c, &b, cset, &queue, 0);
01082
01083
01084 if (!quiet)
01085 sseq << "L\n" << '2' << c << '\n';
01086 cset. remove (c);
01087 other. add (c);
01088 }
01089
01090
01091 if (!quiet)
01092 scon << "\b \b";
01093
01094
01095 return prev - cset. size ();
01096 }
01097
01098
01099 }
01100 }
01101
01102 #endif // _CHOMP_HOMOLOGY_CUBISETS_H_
01103
01105