Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

box_heap.c File Reference

Implementation of the functions operating on box Theap. More...

#include "box_heap.h"
#include "interval.h"
#include "boolean.h"
#include "defines.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

void InitHeapOfBoxes (boolean(*LessThan)(void *, void *, void *), void *userData, Theap *h)
 Constructor.
void AddBox2HeapOfBoxes (Tbox *b, Theap *h)
 Adds a box to a heap of boxes.
double HeapOfBoxesVolume (boolean *used, Theap *h)
 Computes the volume of a heap.
double HeapOfBoxesMaxDiagonal (boolean *used, Theap *h)
 Computes the maximum diagonal for all boxes in a heap.
double HeapOfBoxesMaxSize (boolean *used, Theap *h)
 Computes the maximum size for all boxes in a heap.
void Heap2List (Tlist *l, Theap *h)
 Converts a heap of boxes into a list.
void AddList2Heap (Tlist *l, Theap *h)
 Adds a list of boxes into a heap.
void PrintHeapOfBoxes (FILE *f, boolean *used, char *heading, Theap *h)
 Prints a heap of boxes.

Detailed Description

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

See also:
box_heap.h, heap.h, Theap, Tbox.

Definition in file box_heap.c.


Function Documentation

void InitHeapOfBoxes ( boolean(*)(void *, void *, void *)  LessThan,
void *  userData,
Theap h 
)

Defines an empty heap of boxes.

Parameters:
LessThan The function defining the sorting criterion for the boxes in the heap.
userData The pointer to the data to pass to the LessThan operator as a third parameter.
h The heap to create.
See also:
CmpBoxDepthFirst, CmpBoxBreadthFirst, InitHeap.

Definition at line 21 of file box_heap.c.

References CopyBox(), DeleteBox(), FALSE, INIT_NUM_BOXES_IN_HEAP, and InitHeap().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void AddBox2HeapOfBoxes ( Tbox b,
Theap h 
)

Adds a box to a heap of boxes. The box is copied into the heap and, thus, it can be freely modified after calling this function.

Parameters:
b The box to add.
h The heap where to add the box.

Definition at line 26 of file box_heap.c.

References AddElement2Heap(), and NO_UINT.

Referenced by MPI_SolveCuikSystem(), PostProcessBox(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

double HeapOfBoxesVolume ( boolean used,
Theap h 
)

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

Parameters:
used Array 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.
h The heap.
See also:
BoxVolume

Definition at line 31 of file box_heap.c.

References GetBoxVolume(), GetHeapElement(), and HeapSize().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

double HeapOfBoxesMaxDiagonal ( boolean used,
Theap h 
)

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

Parameters:
used Array 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.
h The heap.
See also:
BoxDiagonal

Definition at line 45 of file box_heap.c.

References GetBoxDiagonal(), GetHeapElement(), and HeapSize().

Here is the call graph for this function:

double HeapOfBoxesMaxSize ( boolean used,
Theap h 
)

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

Parameters:
used Array 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.
h The heap.
See also:
BoxSize

Definition at line 63 of file box_heap.c.

References GetBoxSize(), GetHeapElement(), and HeapSize().

Here is the call graph for this function:

void Heap2List ( Tlist l,
Theap h 
)

Converts a heap of boxes into a list of boxes. The list is constructed (i.e., initialized) inside the function.

Parameters:
l The list to defined.
h The heap to convert into a list.
See also:
box_list.h

Definition at line 82 of file box_heap.c.

References AddLastElement(), CopyBox(), GetHeapElement(), HeapSize(), and InitListOfBoxes().

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void AddList2Heap ( Tlist l,
Theap h 
)

Adds a list of boxes into a previously initialized heap.

Parameters:
l The list with the boxes to add to the heap.
h The heap where to add the boxes.
See also:
box_list.h

Definition at line 97 of file box_heap.c.

References AddElement2Heap(), Advance(), EndOfList(), First(), GetCurrent(), InitIterator(), and NO_UINT.

Referenced by MPI_SolveCuikSystem(), and SolveCuikSystem().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintHeapOfBoxes ( FILE *  f,
boolean used,
char *  heading,
Theap h 
)

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

The elements of the heap are printed breadth first.

Parameters:
f The stream where to write.
used Array 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.
heading A string to be printed before each box. Possibly NULL, in which case nothing is printed. This is used to differentiate heap printed in the same file.
h The heap to be printed.
See also:
PrintBox

Definition at line 110 of file box_heap.c.

References GetHeapElement(), HeapSize(), and PrintBoxSubset().

Here is the call graph for this function: