box_list.c File Reference

Detailed Description

Implementation of the functions operating on Tlist with Tbox as a basic type.

See Also
box_list.h, list.h, Tlist, Tbox.

Definition in file box_list.c.

Functions

void InitListOfBoxes (Tlist *l)
 Constructor. More...
 
void CopyListOfBoxes (Tlist *l_dst, Tlist *l_src)
 Copy constructor. More...
 
double ListOfBoxesVolume (boolean *used, Tlist *l)
 Computes the volume of a list. More...
 
double ListOfBoxesMaxDiagonal (boolean *used, Tlist *l)
 Computes the maximum diagonal for all boxes in a list. More...
 
double ListOfBoxesMaxSize (boolean *used, Tlist *l)
 Computes the maximum size for all boxes in a list. More...
 
void ListOfBoxesBB (boolean *used, Tbox *b, Tlist *l)
 Computes an axis-aligned bounding box for all boxes in a list. More...
 
void ListOfBoxesCluster (boolean *used, Tlist *l_out, Tlist *l_in)
 Clusters a list of boxes. More...
 
void ConcatListOfBoxes (Tlist *l_new, Tlist *l)
 Concats two lists. More...
 
void ReverseListOfBoxes (Tlist *l_orig, Tlist *l)
 Reverses a list. More...
 
void PrintListOfBoxes (FILE *f, boolean *used, char *heading, Tlist *l)
 Prints a list of boxes. More...
 
boolean ReadListOfBoxes (char *filename, Tlist *l)
 Reads a list of boxes from a file. More...
 
void SaveListOfBoxes (FILE *f, Tlist *list)
 Saves a list of boxes. More...
 
void LoadListOfBoxes (FILE *f, Tlist *list)
 Loads a list of boxes from a file. More...
 
void DeleteListOfBoxes (Tlist *l)
 Destructor. More...
 

Function Documentation

void InitListOfBoxes ( Tlist l)

Defines an empty list of boxes.

Parameters
lThe list to create.

Definition at line 24 of file box_list.c.

References InitList().

Referenced by CopyListOfBoxes(), DealWithCP(), Heap2List(), IncrementalSampleCuikSystemInBox(), ListOfBoxesCluster(), LoadListOfBoxes(), ReverseListOfBoxes(), and SampleCuikSystemInBox().

void CopyListOfBoxes ( Tlist l_dst,
Tlist l_src 
)

Copies one list into another.

The boxes in l_src are duplicated before inserting them into l_dst.

Parameters
l_dstThe new list to create.
l_srcThe source list from which to copy.

Definition at line 29 of file box_list.c.

References AddLastElement(), Advance(), CopyBox(), EndOfList(), First(), GetCurrent(), InitIterator(), and InitListOfBoxes().

double ListOfBoxesVolume ( boolean used,
Tlist l 
)

Computes the sum of the volume of the boxes stored in the list.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
lThe list.
See Also
BoxVolume

Definition at line 50 of file box_list.c.

References Advance(), EndOfList(), First(), GetBoxVolume(), GetCurrent(), and InitIterator().

double ListOfBoxesMaxDiagonal ( boolean used,
Tlist l 
)

Computes the maximum diagonal for all the boxes stored in the list.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
lThe list.
See Also
BoxDiagonal

Definition at line 70 of file box_list.c.

References Advance(), EndOfList(), First(), GetBoxDiagonal(), GetCurrent(), and InitIterator().

double ListOfBoxesMaxSize ( boolean used,
Tlist l 
)

Computes the maximum size for all the boxes stored in the list.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
lThe list.
See Also
BoxSize

Definition at line 91 of file box_list.c.

References Advance(), EndOfList(), First(), GetBoxSize(), GetCurrent(), and InitIterator().

void ListOfBoxesBB ( boolean used,
Tbox b,
Tlist l 
)

Computes a box that is an axis-aligned bounding box for all boxes in a list.
This is a box constructor and, therefore box b does not need to be initialized externally before calling this function.
The dimensionality of the output box is that of the boxes in the list.
If the list is empty it returns a dimension-less box.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
bThe output box defining the bounding box for the boxes in the list for the used dimensions.
lThe list.
See Also
BoxUnion

Definition at line 113 of file box_list.c.

References Advance(), BoxUnion(), CopyBox(), EndOfList(), First(), GetCurrent(), InitBox(), InitIterator(), and ListSize().

void ListOfBoxesCluster ( boolean used,
Tlist l_out,
Tlist l_in 
)

Computes a list of boxes, with one box bounding each one of the connected components defined by the boxes in the input list.
A box is included in a connected component if it has a non-null intersection with one of the boxes already in the component.

Parameters
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
l_outThe output list, with one box for each one of the clusters of the input list.
l_inThe input list to be clustered.

Definition at line 138 of file box_list.c.

References AddLastElement(), Advance(), BoxesIntersection(), BoxUnion(), CopyBox(), DeleteBox(), EndOfList(), FALSE, First(), GetCurrent(), InitIterator(), InitListOfBoxes(), ListSize(), NEW, and TRUE.

Referenced by DealWithCP().

void ConcatListOfBoxes ( Tlist l_new,
Tlist l 
)

Adds l_new at the end of l. We assume l to be properly initialized.

Parameters
l_newThe list to add.
lThe list where to add.

Definition at line 230 of file box_list.c.

References AddLastElement(), Advance(), CopyBox(), EndOfList(), First(), GetCurrent(), and InitIterator().

void ReverseListOfBoxes ( Tlist l_orig,
Tlist l 
)

Reverses the order of a list.

This is a constructor and, thus, l is initialized inside the function.

Parameters
l_origThe list to reverse.
lThe ouput reversed list.

Definition at line 245 of file box_list.c.

References AddFirstElement(), Advance(), CopyBox(), EndOfList(), First(), GetCurrent(), InitIterator(), and InitListOfBoxes().

void PrintListOfBoxes ( FILE *  f,
boolean used,
char *  heading,
Tlist l 
)

Prints a list of boxes to a stream that can be stdout.

Parameters
fThe stream where to write.
usedArray of booleans, one for each interval of the input boxes. If the boolean is TRUE, the corresponding interval is used in the computations. If the given pointer is NULL, all intervals are used.
headingA string to be printed before each box. Possibly NULL, in which case nothing is printed. This is used to differentiate list printed in the same file.
lThe list to be printed.
See Also
PrintBox

Definition at line 265 of file box_list.c.

References Advance(), EndOfList(), First(), GetCurrent(), InitIterator(), and PrintBoxSubset().

Referenced by DealWithCP().

boolean ReadListOfBoxes ( char *  filename,
Tlist l 
)

This is a constructor from a file.

Parameters
filenameThe name of the file from where to read the boxes.
lThe list to initialize.
Returns
TRUE if the given file exists and it could be opened and FALSE otherwise.
See Also
ReadBox

Definition at line 286 of file box_list.c.

References AddLastElement(), FALSE, InitList(), ReadBox(), and TRUE.

Referenced by LoadSamples(), and main().

void SaveListOfBoxes ( FILE *  f,
Tlist l 
)

Saves a list of boxes to a stream in binary format.

Parameters
fThe stream where to write.
lThe list to be saved.
See Also
SaveBox

Definition at line 316 of file box_list.c.

References Advance(), EndOfList(), First(), GetCurrent(), InitIterator(), ListSize(), and SaveBox().

Referenced by SaveCSState().

void LoadListOfBoxes ( FILE *  f,
Tlist l 
)

This is a constructor from a file in binary format.

Parameters
fThe binary stream from where to read the list.
lThe list to be created from the binary file.
See Also
LoadBox

Definition at line 334 of file box_list.c.

References AddLastElement(), InitListOfBoxes(), and LoadBox().

Referenced by LoadCSState().

void DeleteListOfBoxes ( Tlist l)

Destructor

Parameters
lThe list to be deleted.
See Also
DeleteBox

Definition at line 353 of file box_list.c.

References DeleteBox(), DeleteCurrent(), EndOfList(), First(), GetCurrent(), and InitIterator().

Referenced by DealWithCP(), IncrementalSampleCuikSystemInBox(), LoadSamples(), main(), MPI_SolveCuikSystem(), SampleCuikSystemInBox(), and SolveCuikSystem().