33 #include "chomp/system/config.h"    34 #include "chomp/system/textfile.h"    35 #include "chomp/system/timeused.h"    36 #include "chomp/system/arg.h"    37 #include "chomp/struct/hashsets.h"    47 #define SPACE_WRAPPING    56 * * * UNDER CONSTRUCTION * * *\n\    57 Converts a cubical set into an equivalent simplicial complex.\n\    58 Version 0.00 (August 4, 2015). Copyright (C) 1997-2016 by Pawel Pilarczyk.\n\    59 This is free software. No warranty. Consult 'license.txt' for details.";
    63 This program saves a simplicial set obtained from a cubical set by means of\n\    64 simplicial subdivision, using the representation of cubical cells by means of\n\    65 the Cartesian product of the 2D simplices that correspond to the edges.\n\    66 Please, beware of the fact that this is a very inefficient way of subdividing\n\    67 each hypercube into the union of simplices; a much smarter algorithm\n\    68 is possible, but I needed this specific one to check some features.\n\    70 input.cub - the name of a file that contains a list of cubical cells,\n\    71 output.sim - the name of a file that will contain a list of simplices,\n\    72 Switches and additional arguments:\n\    73 --log filename - save the output to a file (without progress indicators),\n\    74 --quiet - suppress data output to the screen (whcih can be still logged),\n\    75 --help - display this brief help information only and exit.\n\    76 For more information please consult the accompanying documentation\n\    77 or ask the program's author at http://www.PawelPilarczyk.com/.";
    84 template <
class CellT>
    94                 cells. push_back (prod. getCell ());
    99 template <
class ProdCellT, 
class SimCellT>
   102         using chomp::homology::sbug;
   104         int cellDim (prod. dim ());
   105         if (cellDim >= chomp::homology::MaxBasDim)
   106                 throw "Too high dimension of a product cell.";
   107         std::vector<int_t> pointNumbers (cellDim + 1);
   108         typedef typename ProdCellT::CellType CellT;
   109         typedef typename CellT::VertexType CoordT;
   110         std::vector<CellT> cells;
   111         sbug << 
"DEBUG: prod = " << prod << 
"\n";
   113         int spaceDim = cells. size ();
   114         for (
int i = 0; i <= cellDim; ++ i)
   116                 CoordT c [chomp::homology::MaxBasDim];
   117                 for (
int j = 0; j < spaceDim; ++ j)
   118                         c [j] = cells [j] [i];
   119                 pointNumbers [i] = chomp::homology::tPointBase<CoordT>::number
   122         std::sort (pointNumbers. begin (), pointNumbers. end ());
   123         simplex = SimCellT (cellDim, pointNumbers);
   124         sbug << 
"DEBUG: simplex = " << simplex << 
"\n\n";
   135 int main (
int argc, 
char *argv [])
   137         using namespace chomp::homology;
   140         typedef short int CoordT;
   146         program_time = 
"Aborted after";
   151 #ifdef SPACE_WRAPPING   152         const int maxWrapping = 100;
   153         char *wrapping [maxWrapping];
   159         arg (a, NULL, inName);
   160         arg (a, NULL, outName);
   161 #ifdef SPACE_WRAPPING   162         arg (a, 
"w", wrapping, nWrapping, maxWrapping);
   166         argstreamprepare (a);
   167         int argresult = a. analyze (argc, argv);
   172                 sout << 
title << 
'\n';
   177                 sout << 
"Call with '--help' for help.\n";
   182         if ((argresult > 0) || !outName)
   191 #ifdef SPACE_WRAPPING   193                 for (
int i = 0; i < nWrapping; ++ i)
   195                         setWrapping<typename CubCellT::WrapType>
   196                                 (std::string (wrapping [i]));
   201                 sout << 
"Transforming cubical cells into simplices:\n'" <<
   202                         inName << 
"' --> '" << outName << 
"'...\n";
   205                 std::ifstream in (inName);
   210                 std::ofstream out (outName);
   212                         fileerror (outName, 
"create");
   216                 int_t cubCounter (0);
   217                 int_t simCounter (0);
   230                         prodCells. normalize ();
   233                         int_t prodSize (prodCells. size ());
   234                         for (int_t n = 0; n < prodSize; ++ n)
   236                                 const ProdCellT &prod (prodCells [n]);
   237                                 if (prod. dim () != q. dim ())
   245                                 out << simplex << 
"\n";
   251                 sout << cubCounter << 
" cubical cells read.\n";
   252                 sout << simCounter << 
" simplices written.\n";
   254                 program_time = 
"Total time used:";
   258         catch (
const char *msg)
   260                 sout << 
"ERROR: " << msg << 
'\n';
   263         catch (
const std::exception &e)
   265                 sout << 
"ERROR: " << e. what () << 
'\n';
   270                 sout << 
"ABORT: An unknown error occurred.\n";
 Elements of the ring Z_p. 
 
A function that converts a cubical cell into a simplicial set that corresponds to the cartesian produ...
 
void flattenProduct(const tProdCell< CellT > &prod, std::vector< CellT > &cells)
 
const char * helpinfo
Brief help information on the program's usage. 
 
A simplex with vertices of arbitrary type. 
 
A Cartesian product of simplicial cells of arbitrary type. 
 
void cube2product(const CubCellT &q, SetT &cells)
Transforms an elementary cube into a simplicial set that represents the Cartesian product of the simp...
 
Tools for coordinate wrapping, a.k.a. 
 
void prod2simplex(const ProdCellT &prod, SimCellT &simplex)
 
const char * title
The title of the program and licensing information. 
 
Hashing keys for std::string. 
 
A simplex class with arbitrary vertices. 
 
The decision on whether the empty cell should be used as a valid cell of dimension -1...
 
int main(int argc, char *argv [])
The main procedure of the program. 
 
A Cartesian product of simplicial cells as a simplicial cell. 
 
An empty cell existence decision class with settable global flag. 
 
An elementary cubical cell with vertex coordinates of integer type.