Public Member Functions | Static Public Member Functions | Protected Attributes

chomp::homengin::cubfile Class Reference

An abstract class that is inherited by all the cubical sets. More...

#include <cubfiles.h>

Inheritance diagram for chomp::homengin::cubfile:
chomp::homengin::bitcodefile chomp::homengin::bmdfile chomp::homengin::cellistfile chomp::homengin::cubitmap chomp::homengin::cublistfile chomp::homengin::winbmpfile

List of all members.

Public Member Functions

 cubfile (const char *_filename)
 The default constructor.
virtual ~cubfile ()
 The destructor.
const char * filename () const
 What is the name of the associated disk file?
virtual int dim () const
 What is the dimension of the set of cubes?
virtual int count () const
 How many cubes are there in the set?
virtual bool bitmaptype () const
 Is this a bitmap type of set of cubes?
virtual bool elementary () const
 Is this a set of elementary cubes, as opposed to full cubes?
virtual bool spacewrapping () const
 Does this set include the definition of space wrapping?
virtual int * spacewrapping (int *table) const
 Fills in the space wrapping table if applicable.
virtual void setwrapping (const int *table, int count=0)
 Sets the space wrapping according to the given table.
virtual int boundingbox (int *mincoord, int *maxcoord) const
 Determines the bounding box of the set of cubes.
int volume (int chunk=0, bool power2=false) const
 Determine the volume of the bounding box of the set of cubes.
virtual int readcubes (chomp::homology::CubicalComplex &s) const
 Reads a set of cubical cells from the file.
virtual int readcubes (chomp::homology::SetOfCubes &s) const
 Reads a set of cubes from the file.
virtual int readcubes (int *&sizes, char *&bytes, int padding=0, bool power2=false) const
 Reads a bitmap from a file.

Static Public Member Functions

static const char * name ()
 The name of this type of a cubical set.
static std::ostream & describe (std::ostream &out)
 Describes this particular type of a set of cubes.
static bool compatible (const char *filename)
 Verifies if the file format is compatible with this cubfile type.

Protected Attributes

std::string _filename
 The name of the corresponding disk file.
int _dim
 The dimension of the space, 0 if unknown.
int _count
 The number of cubes in the set, -1 if unknown.
std::vector< int > _min
 The minimal coordinates of the cubes' corners (bounding box).
std::vector< int > _max
 The maximal coordinates of the cubes' corners (bounding box).
std::vector< int > _wrapping
 The space wrapping information if any.

Detailed Description

An abstract class that is inherited by all the cubical sets.

Definition at line 63 of file cubfiles.h.


Constructor & Destructor Documentation

chomp::homengin::cubfile::cubfile ( const char *  _filename  )  [inline]

The default constructor.

Definition at line 231 of file cubfiles.h.

                                            : _filename (filename),
        _dim (0), _count (-1), _min (), _max (), _wrapping ()
{
        return;
} /* cubfile::cubfile */

chomp::homengin::cubfile::~cubfile (  )  [inline, virtual]

The destructor.

Definition at line 237 of file cubfiles.h.

{
        return;
} /* cubfile::~cubfile */


Member Function Documentation

virtual bool chomp::homengin::cubfile::bitmaptype (  )  const [inline, virtual]

Is this a bitmap type of set of cubes?

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 101 of file cubfiles.h.

        {
                throw "Undefined bitmapness of a set of cubes.";
        }

virtual int chomp::homengin::cubfile::boundingbox ( int *  mincoord,
int *  maxcoord 
) const [inline, virtual]

Determines the bounding box of the set of cubes.

All the coordinates of cubes are at least 'min', and strictly smaller than 'max'. Returns 0.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, and chomp::homengin::winbmpfile.

Definition at line 144 of file cubfiles.h.

References _max, and _min.

        {
                if (_min. size () && _max. size ())
                {
                        if (mincoord)
                                std::copy (_min. begin (), _min. end (),
                                        mincoord);
                        if (maxcoord)
                                std::copy (_max. begin (), _max. end (),
                                        maxcoord);
                        return 0;
                }
                throw "Undefined bounding box of a set of cubes.";
        }

static bool chomp::homengin::cubfile::compatible ( const char *  filename  )  [inline, static]

Verifies if the file format is compatible with this cubfile type.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 180 of file cubfiles.h.

        {
                return false;
        }

virtual int chomp::homengin::cubfile::count (  )  const [inline, virtual]

How many cubes are there in the set?

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 93 of file cubfiles.h.

References _count.

Referenced by setwrapping().

        {
                if (_count >= 0)
                        return _count;
                throw "Undefined number of cubes in a set.";
        }

static std::ostream& chomp::homengin::cubfile::describe ( std::ostream &  out  )  [inline, static]

Describes this particular type of a set of cubes.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 173 of file cubfiles.h.

        {
                out << "This is an unknown set of cubes.";
                return out;
        }

virtual int chomp::homengin::cubfile::dim (  )  const [inline, virtual]

What is the dimension of the set of cubes?

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, and chomp::homengin::bitcodefile.

Definition at line 85 of file cubfiles.h.

References _dim.

Referenced by setwrapping().

        {
                if (_dim > 0)
                        return _dim;
                throw "Undefined dimension of a set of cubes.";
        }

virtual bool chomp::homengin::cubfile::elementary (  )  const [inline, virtual]

Is this a set of elementary cubes, as opposed to full cubes?

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 107 of file cubfiles.h.

        {
                throw "Undefined type of a set of cubes.";
        }

const char* chomp::homengin::cubfile::filename (  )  const [inline]

What is the name of the associated disk file?

Definition at line 79 of file cubfiles.h.

        {
                return _filename. c_str ();
        }

static const char* chomp::homengin::cubfile::name (  )  [inline, static]

The name of this type of a cubical set.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 167 of file cubfiles.h.

        {
                return "unknown set of cubes";
        }

virtual int chomp::homengin::cubfile::readcubes ( int *&  sizes,
char *&  bytes,
int  padding = 0,
bool  power2 = false 
) const [inline, virtual]

Reads a bitmap from a file.

Allocates memory for the table of sizes, and for the bytes of the bitmap. If padding > 0, then padds the lines to a multiple of the given number of bytes. If requested, additionally rounds the sizes in each direction up to the nearest power of 2.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 202 of file cubfiles.h.

        {
                throw "Unable to read a bitmap set of cubes.";
        }

virtual int chomp::homengin::cubfile::readcubes ( chomp::homology::CubicalComplex s  )  const [inline, virtual]

Reads a set of cubical cells from the file.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 186 of file cubfiles.h.

        {
                throw "Unable to read a set of cells.";
        }

virtual int chomp::homengin::cubfile::readcubes ( chomp::homology::SetOfCubes s  )  const [inline, virtual]

Reads a set of cubes from the file.

Reimplemented in chomp::homengin::cublistfile, chomp::homengin::cellistfile, chomp::homengin::bitcodefile, chomp::homengin::winbmpfile, chomp::homengin::bmdfile, and chomp::homengin::cubitmap.

Definition at line 192 of file cubfiles.h.

        {
                throw "Unable to read a set of cubes.";
        }

virtual void chomp::homengin::cubfile::setwrapping ( const int *  table,
int  count = 0 
) [inline, virtual]

Sets the space wrapping according to the given table.

Definition at line 132 of file cubfiles.h.

References _wrapping, count(), and dim().

        {
                _wrapping. clear ();
                int d = count ? count : dim ();
                _wrapping. assign (table, table + d);
                return;
        }

virtual int* chomp::homengin::cubfile::spacewrapping ( int *  table  )  const [inline, virtual]

Fills in the space wrapping table if applicable.

Returns the address of the table.

Definition at line 120 of file cubfiles.h.

References _wrapping.

        {
                if (_wrapping. size ())
                {
                        std::copy (_wrapping. begin (), _wrapping. end (),
                                table);
                        return table;
                }
                throw "Unknown space wrapping of a set of cubes.";
        }

virtual bool chomp::homengin::cubfile::spacewrapping (  )  const [inline, virtual]

Does this set include the definition of space wrapping?

Definition at line 113 of file cubfiles.h.

References _wrapping.

        {
                return (_wrapping. size () != 0);
        }

int chomp::homengin::cubfile::volume ( int  chunk = 0,
bool  power2 = false 
) const

Determine the volume of the bounding box of the set of cubes.

The volume is measured in cubes or in chunks of cubes (e.g., chunk = 8 measures the bitmap size in bytes). If requested, the width in each direction is rounded up to the nearest power of 2 while calculating the volume.


Member Data Documentation

int chomp::homengin::cubfile::_count [mutable, protected]

The number of cubes in the set, -1 if unknown.

Definition at line 216 of file cubfiles.h.

Referenced by chomp::homengin::bitcodefile::count(), chomp::homengin::cellistfile::count(), chomp::homengin::cublistfile::count(), and count().

std::string chomp::homengin::cubfile::_filename [protected]

The name of the corresponding disk file.

Definition at line 210 of file cubfiles.h.

std::vector<int> chomp::homengin::cubfile::_max [mutable, protected]

The maximal coordinates of the cubes' corners (bounding box).

Definition at line 222 of file cubfiles.h.

Referenced by chomp::homengin::bmdfile::bmdfile(), boundingbox(), and chomp::homengin::cubitmap::cubitmap().

std::vector<int> chomp::homengin::cubfile::_min [mutable, protected]
std::vector<int> chomp::homengin::cubfile::_wrapping [mutable, protected]

The space wrapping information if any.

Definition at line 225 of file cubfiles.h.

Referenced by setwrapping(), and spacewrapping().


The documentation for this class was generated from the following file: