The Original CHomP Software
Static Public Member Functions | Static Protected Attributes | Friends | List of all members
chomp::homology::tPointBase< coordtype > Class Template Reference

This class keeps a common set of points which are indexed for the use of other classes, like cubes or cubical cells. More...

#include <pointbas.h>

Inheritance diagram for chomp::homology::tPointBase< coordtype >:
chomp::homology::tWrapBase< coordtype >

Static Public Member Functions

static int_t number (const coordtype *c, int d)
 Returns the number of the point with given coordinates. More...
 
static bool check (const coordtype *c, int d)
 Checks whether this point is already included in the list. More...
 
static const coordtype * coord (int_t number, int d)
 Retrieves the coordinates of the given point. More...
 
static int defaultdimension (void)
 Determines the default dimension of points. More...
 
static void quiet (bool what=true)
 Sets the point base to be quiet or not. More...
 
static void setwrapping (const coordtype *c, int mindim=1, int maxdim=MaxBasDim)
 Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'. More...
 
static void setwrapping (coordtype c, int mindim=1, int maxdim=MaxBasDim)
 Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'. More...
 
static const coordtype * getwrapping (int d)
 Returns the space wrapping for the given dimension. More...
 
static void wrapcoord (coordtype *c, int dim)
 Wraps the given coordinates if necessary. More...
 
static void wrapcopy (coordtype *dest, const coordtype *src, int dim)
 Copies the coordinates and wraps them if necessary. More...
 
static void reset (void)
 Resets the internal data. More...
 
static void forget (void)
 Forgets the base points, frees memory and makes this data structure ususable: An exception is thrown if this data is used. More...
 
static outputstreamshowused (outputstream &out)
 Shows the number of vertices stored for all the dimensions. More...
 
static std::ostream & showused (std::ostream &out)
 Shows the number of vertices stored for all the dimensions. More...
 

Static Protected Attributes

static tPointset< coordtype > ** p = NULL
 The sets of points from which numbers are taken. More...
 
static int n = 0
 The number of allocated sets of points. More...
 
static bool show = true
 Should the summary of points' usage be displayed? More...
 
static bool forgotten = false
 Were the base points forgotten? More...
 
static tPointBaseInitializer< coordtype > pointBaseInitializer
 An object responsible for deleting the pointsets at exit. More...
 

Friends

class tPointBaseInitializer< coordtype >
 Friendship class which shows the statistics in its destructor. More...
 

Detailed Description

template<class coordtype>
class chomp::homology::tPointBase< coordtype >

This class keeps a common set of points which are indexed for the use of other classes, like cubes or cubical cells.

This base is used to give each n-dimensional point its unique number. The consecutive numbers for each dimension begin with 1.

Definition at line 101 of file pointbas.h.

Member Function Documentation

◆ check()

template<class coordtype >
bool chomp::homology::tPointBase< coordtype >::check ( const coordtype *  c,
int  d 
)
inlinestatic

Checks whether this point is already included in the list.

Return false if not, true if yes. Does not add the point to the structure.

Definition at line 194 of file pointbas.h.

195{
196 if (forgotten)
197 throw "Trying to check forgotten coordinates.";
198 if ((d > n) || (d <= 0) || (p [d - 1] == NULL))
199 return 0;
200 return p [d - 1] -> check (c);
201} /* tPointBase::check */
static bool forgotten
Were the base points forgotten?
Definition: pointbas.h:173
static tPointset< coordtype > ** p
The sets of points from which numbers are taken.
Definition: pointbas.h:164
static bool check(const coordtype *c, int d)
Checks whether this point is already included in the list.
Definition: pointbas.h:194
static int n
The number of allocated sets of points.
Definition: pointbas.h:167

◆ coord()

template<class coordtype >
const coordtype * chomp::homology::tPointBase< coordtype >::coord ( int_t  number,
int  d 
)
inlinestatic

Retrieves the coordinates of the given point.

Definition at line 183 of file pointbas.h.

184{
185 if (forgotten)
186 throw "Trying to retrieve forgotten coordinates.";
187 if ((d > n) || (d <= 0) || (p [d - 1] == NULL))
188 return NULL;
189 else
190 return (*(p [d - 1])) [nr];
191} /* tPointBase::coord */

Referenced by chomp::homology::tCubeBase< coordtype >::coord(), chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::leftcoord(), chomp::homology::tCellBase< coordtype >::rightcoord(), and chomp::homology::tCellBase< coordtype >::tCellBase().

◆ defaultdimension()

template<class coordtype >
int chomp::homology::tPointBase< coordtype >::defaultdimension ( void  )
static

Determines the default dimension of points.

Definition at line 381 of file pointbas.h.

382{
383 static int dim = 0;
384 if (dim)
385 return dim;
386 for (int d = 1; d <= n; ++ d)
387 {
388 if (!p [d - 1])
389 continue;
390 if (p [d - 1] -> empty ())
391 continue;
392 dim = d;
393 return d;
394 }
395 return 0;
396} /* tPointBase::defaultdimension */

◆ forget()

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::forget ( void  )
inlinestatic

Forgets the base points, frees memory and makes this data structure ususable: An exception is thrown if this data is used.

Definition at line 356 of file pointbas.h.

357{
358 if (forgotten)
359 throw "Trying to forget already forgotten coordinates.";
360
361 reset ();
362 forgotten = true;
363 return;
364} /* tPointBase::forget */
static void reset(void)
Resets the internal data.
Definition: pointbas.h:338

Referenced by chomp::homology::tPointBaseInitializer< coordtype >::~tPointBaseInitializer().

◆ getwrapping()

template<class coordtype >
const coordtype * chomp::homology::tPointBase< coordtype >::getwrapping ( int  d)
inlinestatic

Returns the space wrapping for the given dimension.

Definition at line 299 of file pointbas.h.

300{
301 if (forgotten)
302 throw "Trying to get wrapping of forgotten coordinates.";
303
304 if ((d <= 0) || (d - 1 >= n) || !p [d - 1])
305 return NULL;
306 else
307 return p [d - 1] -> wrapspace ();
308} /* tPointBase::getwrapping */

Referenced by chomp::homology::tCellBase< coordtype >::tCellBase(), chomp::homology::tCellFix< dimfix, coordtype >::tCellFix(), and chomp::homology::tCellVar< coordtype >::tCellVar().

◆ number()

template<class coordtype >
int_t chomp::homology::tPointBase< coordtype >::number ( const coordtype *  c,
int  d 
)
inlinestatic

Returns the number of the point with given coordinates.

Points for each dimension get numbers starting at 1.

Definition at line 211 of file pointbas.h.

212{
213 if (forgotten)
214 throw "Trying to find the number of forgotten coordinates.";
215
216 if (d < 0)
217 return -1;
218 if (d >= MaxBasDim)
219 throw "Dimension too high.";
220
221 // enhance the table of sets of points if necessary
222 if (d > n)
223 {
224 tPointset<coordtype> **newtable =
225 new tPointset<coordtype> * [d];
226 for (int i = 0; i < d; ++ i)
227 newtable [i] = (i < n) ? p [i] : NULL;
228 if (p)
229 delete [] p;
230 p = newtable;
231 n = d;
232 }
233
234 if (!p [d - 1])
235 {
236 p [d - 1] = new tPointset<coordtype> (1024);
237 p [d - 1] -> dimension (d);
238 }
239
240 int_t number = p [d - 1] -> add (c);
241 if (number > NumMask)
242 throw "Too many points.";
243
244 return number;
245} /* tPointBase::number */
static int_t number(const coordtype *c, int d)
Returns the number of the point with given coordinates.
Definition: pointbas.h:211
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115
const int MaxBasDim
The maximal dimension that can be used if the high bits of an integer store the value of the dimensio...
Definition: pointbas.h:89
const int_t NumMask
The mask of the bits remaining after the dimension bits are excluded.
Definition: pointbas.h:77

References chomp::homology::MaxBasDim, and chomp::homology::NumMask.

Referenced by chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::tCellBase(), and chomp::homology::tCubeBase< coordtype >::tCubeBase().

◆ quiet()

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::quiet ( bool  what = true)
inlinestatic

Sets the point base to be quiet or not.

If not quiet, it displays some usage statistics when the data is reset.

Definition at line 204 of file pointbas.h.

205{
206 show = !what;
207 return;
208} /* tPointBase::quiet */
static bool show
Should the summary of points' usage be displayed?
Definition: pointbas.h:170

◆ reset()

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::reset ( void  )
inlinestatic

Resets the internal data.

Note: Cubes and cells created before resetting may be unusable after the reset.

Definition at line 338 of file pointbas.h.

339{
340 for (int i = 0; i < n; ++ i)
341 {
342 if (p [i])
343 {
344 delete p [i];
345 p [i] = NULL;
346 }
347 }
348 delete [] p;
349 p = NULL;
350 n = 0;
351 forgotten = false;
352 return;
353} /* tPointBase::reset */

◆ setwrapping() [1/2]

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::setwrapping ( const coordtype *  c,
int  mindim = 1,
int  maxdim = MaxBasDim 
)
inlinestatic

Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'.

The space wrapping in each direction can be different.

Definition at line 248 of file pointbas.h.

250{
251 if (forgotten)
252 throw "Trying to wrap forgotten coordinates.";
253
254 // correct the left and right bound for dimensions
255 if (mindim < 1)
256 mindim = 1;
257 if (maxdim > MaxBasDim)
258 maxdim = MaxBasDim;
259
260 // enhance the table of sets of points if necessary
261 if (maxdim > n)
262 {
263 tPointset<coordtype> **newtable =
264 new tPointset<coordtype> * [maxdim];
265 for (int i = 0; i < maxdim; ++ i)
266 newtable [i] = (i < n) ? p [i] : NULL;
267 if (p)
268 delete [] p;
269 p = newtable;
270 n = maxdim;
271 }
272
273 // set wrapping coordinates and allocate sets of points if needed
274 for (int d = mindim; d < maxdim; ++ d)
275 {
276 if (!p [d - 1])
277 {
278 p [d - 1] = new tPointset<coordtype>;
279 p [d - 1] -> dimension (d);
280 }
281 p [d - 1] -> wrapspace (c);
282 }
283
284 return;
285} /* tPointBase::setwrapping */

References chomp::homology::MaxBasDim.

Referenced by chomp::homology::ComputeBettiNumbers(), and chomp::homology::SetSpaceWrapping().

◆ setwrapping() [2/2]

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::setwrapping ( coordtype  c,
int  mindim = 1,
int  maxdim = MaxBasDim 
)
inlinestatic

Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller than 'maxdim'.

The space wrapping in each direction is the same.

Definition at line 288 of file pointbas.h.

290{
291 coordtype wraptable [MaxBasDim];
292 for (int i = 0; i < MaxBasDim; ++ i)
293 wraptable [i] = c;
294 setwrapping (wraptable, mindim, maxdim);
295 return;
296} /* tPointBase::setwrapping */
static void setwrapping(const coordtype *c, int mindim=1, int maxdim=MaxBasDim)
Sets space wrapping for all the dimensions in the range starting with 'mindim' and strictly smaller t...
Definition: pointbas.h:248

References chomp::homology::MaxBasDim.

◆ showused() [1/2]

template<class coordtype >
outputstream & chomp::homology::tPointBase< coordtype >::showused ( outputstream out)
static

Shows the number of vertices stored for all the dimensions.

Definition at line 399 of file pointbas.h.

400{
401 if (forgotten)
402 throw "Trying to show forgotten coordinates.";
403
404 bool shown = false;
405 for (int i = 0; i < n; ++ i)
406 {
407 if (!p [i])
408 continue;
409 const tPointset<coordtype> &pset = *(p [i]);
410 if (pset. empty ())
411 continue;
412 out << (shown ? ", " : "Vertices used: ") <<
413 pset. size () << " of dim " << (i + 1);
414 shown = true;
415 }
416 if (shown)
417 out << ".\n";
418 return out;
419} /* tPointBase::showused */

Referenced by chomp::homology::tPointBaseInitializer< coordtype >::~tPointBaseInitializer().

◆ showused() [2/2]

template<class coordtype >
std::ostream & chomp::homology::tPointBase< coordtype >::showused ( std::ostream &  out)
static

Shows the number of vertices stored for all the dimensions.

Definition at line 422 of file pointbas.h.

423{
424 outputstream tout (out);
425 showused (tout);
426 return out;
427} /* tPointBase::showused */
static outputstream & showused(outputstream &out)
Shows the number of vertices stored for all the dimensions.
Definition: pointbas.h:399

◆ wrapcoord()

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::wrapcoord ( coordtype *  c,
int  dim 
)
inlinestatic

Wraps the given coordinates if necessary.

Definition at line 311 of file pointbas.h.

312{
313 if ((dim > n) || (dim <= 0) || (p [dim - 1] == NULL))
314 return;
315 const coordtype *cw = p [dim - 1] -> wrapspace ();
316 if (cw)
317 chomp::homology::wrapcoord (c, c, cw, dim);
318 return;
319} /* tPointBase::wrapcoord */
void wrapcoord(coordtype *destination, const coordtype *source, const coordtype *wrap, int dim)
Wraps coordinates stored in 'c' accordint to the wrap table 'wrap' and store the result in the table ...
Definition: pointset.h:119

References chomp::homology::wrapcoord().

Referenced by chomp::homology::tCellFix< dimfix, coordtype >::rightcoord(), and chomp::homology::tCellVar< coordtype >::rightcoord().

◆ wrapcopy()

template<class coordtype >
void chomp::homology::tPointBase< coordtype >::wrapcopy ( coordtype *  dest,
const coordtype *  src,
int  dim 
)
inlinestatic

Copies the coordinates and wraps them if necessary.

Definition at line 322 of file pointbas.h.

324{
325 const coordtype *cw;
326 if ((dim > n) || (dim <= 0) || (p [dim - 1] == 0))
327 cw = 0;
328 else
329 cw = p [dim - 1] -> wrapspace ();
330 if (cw)
331 chomp::homology::wrapcoord (dest, src, cw, dim);
332 else
333 copycoord (dest, src, dim);
334 return;
335} /* tPointBase::wrapcopy */
void copycoord(coordtype *destination, const coordtype *source, int dim)
Copies the coordinates of one point to another.
Definition: pointset.h:108

References chomp::homology::copycoord(), and chomp::homology::wrapcoord().

Referenced by chomp::homology::tCellFix< dimfix, coordtype >::initialize(), chomp::homology::tCellVar< coordtype >::initialize(), chomp::homology::tCubeFix< dimfix, coordtype >::tCubeFix(), and chomp::homology::tCubeVar< coordtype >::tCubeVar().

Friends And Related Function Documentation

◆ tPointBaseInitializer< coordtype >

template<class coordtype >
friend class tPointBaseInitializer< coordtype >
friend

Friendship class which shows the statistics in its destructor.

Definition at line 157 of file pointbas.h.

Member Data Documentation

◆ forgotten

template<class coordtype >
bool chomp::homology::tPointBase< coordtype >::forgotten = false
staticprotected

Were the base points forgotten?

Definition at line 173 of file pointbas.h.

◆ n

template<class coordtype >
int chomp::homology::tPointBase< coordtype >::n = 0
staticprotected

The number of allocated sets of points.

Definition at line 167 of file pointbas.h.

◆ p

template<class coordtype >
tPointset< coordtype > ** chomp::homology::tPointBase< coordtype >::p = NULL
staticprotected

The sets of points from which numbers are taken.

Definition at line 164 of file pointbas.h.

◆ pointBaseInitializer

template<class coordtype >
tPointBaseInitializer< coordtype > chomp::homology::tPointBase< coordtype >::pointBaseInitializer
staticprotected

An object responsible for deleting the pointsets at exit.

Definition at line 176 of file pointbas.h.

◆ show

template<class coordtype >
bool chomp::homology::tPointBase< coordtype >::show = true
staticprotected

Should the summary of points' usage be displayed?

Definition at line 170 of file pointbas.h.


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