The Original CHomP Software
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
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

Public Member Functions

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

Static Public Member Functions

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

Protected Attributes

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

Detailed Description

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

Definition at line 62 of file cubfiles.h.

Constructor & Destructor Documentation

◆ cubfile()

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

The default constructor.

Definition at line 230 of file cubfiles.h.

231 _dim (0), _count (-1), _min (), _max (), _wrapping ()
232{
233 return;
234} /* cubfile::cubfile */
std::vector< int > _wrapping
The space wrapping information if any.
Definition: cubfiles.h:224
int _count
The number of cubes in the set, -1 if unknown.
Definition: cubfiles.h:215
std::vector< int > _min
The minimal coordinates of the cubes' corners (bounding box).
Definition: cubfiles.h:218
std::vector< int > _max
The maximal coordinates of the cubes' corners (bounding box).
Definition: cubfiles.h:221
std::string _filename
The name of the corresponding disk file.
Definition: cubfiles.h:209
const char * filename() const
What is the name of the associated disk file?
Definition: cubfiles.h:78
int _dim
The dimension of the space, 0 if unknown.
Definition: cubfiles.h:212

◆ ~cubfile()

chomp::homengin::cubfile::~cubfile ( )
inlinevirtual

The destructor.

Definition at line 236 of file cubfiles.h.

237{
238 return;
239} /* cubfile::~cubfile */

Member Function Documentation

◆ bitmaptype()

virtual bool chomp::homengin::cubfile::bitmaptype ( ) const
inlinevirtual

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 100 of file cubfiles.h.

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

◆ boundingbox()

virtual int chomp::homengin::cubfile::boundingbox ( int *  mincoord,
int *  maxcoord 
) const
inlinevirtual

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 143 of file cubfiles.h.

144 {
145 if (_min. size () && _max. size ())
146 {
147 if (mincoord)
148 std::copy (_min. begin (), _min. end (),
149 mincoord);
150 if (maxcoord)
151 std::copy (_max. begin (), _max. end (),
152 maxcoord);
153 return 0;
154 }
155 throw "Undefined bounding box of a set of cubes.";
156 }

References _max, and _min.

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

◆ compatible()

static bool chomp::homengin::cubfile::compatible ( const char *  filename)
inlinestatic

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

Definition at line 179 of file cubfiles.h.

180 {
181 return false;
182 }

◆ count()

virtual int chomp::homengin::cubfile::count ( ) const
inlinevirtual

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 92 of file cubfiles.h.

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

References _count.

Referenced by setwrapping().

◆ describe()

static std::ostream & chomp::homengin::cubfile::describe ( std::ostream &  out)
inlinestatic

Describes this particular type of a set of cubes.

Definition at line 172 of file cubfiles.h.

173 {
174 out << "This is an unknown set of cubes.";
175 return out;
176 }

◆ dim()

virtual int chomp::homengin::cubfile::dim ( ) const
inlinevirtual

What is the dimension of the set of cubes?

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

Definition at line 84 of file cubfiles.h.

85 {
86 if (_dim > 0)
87 return _dim;
88 throw "Undefined dimension of a set of cubes.";
89 }

References _dim.

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

◆ elementary()

virtual bool chomp::homengin::cubfile::elementary ( ) const
inlinevirtual

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 106 of file cubfiles.h.

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

◆ filename()

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

What is the name of the associated disk file?

Definition at line 78 of file cubfiles.h.

79 {
80 return _filename. c_str ();
81 }

References _filename.

◆ name()

static const char * chomp::homengin::cubfile::name ( )
inlinestatic

The name of this type of a cubical set.

Definition at line 166 of file cubfiles.h.

167 {
168 return "unknown set of cubes";
169 }

◆ readcubes() [1/3]

virtual int chomp::homengin::cubfile::readcubes ( chomp::homology::CubicalComplex s) const
inlinevirtual

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 185 of file cubfiles.h.

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

◆ readcubes() [2/3]

virtual int chomp::homengin::cubfile::readcubes ( chomp::homology::SetOfCubes s) const
inlinevirtual

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 191 of file cubfiles.h.

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

◆ readcubes() [3/3]

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

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 201 of file cubfiles.h.

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

◆ setwrapping()

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

Sets the space wrapping according to the given table.

Definition at line 131 of file cubfiles.h.

132 {
133 _wrapping. clear ();
134 int d = count ? count : dim ();
135 _wrapping. assign (table, table + d);
136 return;
137 }
virtual int count() const
How many cubes are there in the set?
Definition: cubfiles.h:92
virtual int dim() const
What is the dimension of the set of cubes?
Definition: cubfiles.h:84

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

◆ spacewrapping() [1/2]

virtual bool chomp::homengin::cubfile::spacewrapping ( ) const
inlinevirtual

Does this set include the definition of space wrapping?

Definition at line 112 of file cubfiles.h.

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

References _wrapping.

◆ spacewrapping() [2/2]

virtual int * chomp::homengin::cubfile::spacewrapping ( int *  table) const
inlinevirtual

Fills in the space wrapping table if applicable.

Returns the address of the table.

Definition at line 119 of file cubfiles.h.

120 {
121 if (_wrapping. size ())
122 {
123 std::copy (_wrapping. begin (), _wrapping. end (),
124 table);
125 return table;
126 }
127 throw "Unknown space wrapping of a set of cubes.";
128 }

References _wrapping.

◆ volume()

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

◆ _count

int chomp::homengin::cubfile::_count
mutableprotected

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

Definition at line 215 of file cubfiles.h.

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

◆ _dim

int chomp::homengin::cubfile::_dim
mutableprotected

◆ _filename

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

The name of the corresponding disk file.

Definition at line 209 of file cubfiles.h.

Referenced by filename().

◆ _max

std::vector<int> chomp::homengin::cubfile::_max
mutableprotected

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

Definition at line 221 of file cubfiles.h.

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

◆ _min

std::vector<int> chomp::homengin::cubfile::_min
mutableprotected

◆ _wrapping

std::vector<int> chomp::homengin::cubfile::_wrapping
mutableprotected

The space wrapping information if any.

Definition at line 224 of file cubfiles.h.

Referenced by setwrapping(), and spacewrapping().


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