GCGlib  0.04.228
GCG Graphics Engine
gcg.h File Reference

GCG - Group for Computer Graphics, Image and Vision library. More...

#include <stdio.h>
#include <math.h>
#include <new>
#include "gcg.h"

Go to the source code of this file.

Classes

class  gcgCLASS
 Base class for all GCGlib classes. It is used for better control of object instantiation, memory allocation, and object reuse. Some systems (like DLL versions in Windows) might demand special tasks in order to be stable. All GCGlib classes must be inherited from gcgCLASS. More...
 
class  gcgBASIS1D< NUMTYPE >
 Abstract class for 1D basis projection/reconstruction interfaces. More...
 
class  gcgBASIS2D< NUMTYPE >
 Abstract class for 2D basis projection/reconstruction interfaces. More...
 
class  gcgIMAGE
 Class for handling images with up to 32 bits per pixel and up to 4 channels. More...
 
class  gcgEVENTSPERSECOND
 Class to estimate the number of events per second. More...
 
class  gcgVIDEO
 Base class for video processing. More...
 
class  gcgVIDEOCAPTURE
 Class for capturing video from camera devices. More...
 
class  gcgVIDEOFILE
 Class for decode frames from a video file. More...
 
class  gcgDATA
 Generic abstract class for defining classes to be used in the GCGlib data structures. In fact, a specialization of a correct and data structure dependent class is mandatory for using the data structures. More...
 
class  gcgITERATOR
 Generic abstract class to allow iterations over the several GCGlib data structures. The gcgITERATOR::next() returns the next object until it is NULL. The returned object type depends on the data structure and commonly is a specialization of gcgORDEREDNODE, gcgDOUBLELINK or gcgLINK classes. While iteration is being done, the original data structure must not be changed by insertions, removals or moves. Iterators copies all needed information to iterate over the nodes and are not allowed to change its associated data structure. A data structure can have several gcgITERATOR instances working at a time. The gcgITERATOR object must be deleted after use. More...
 
class  gcgDATASTRUCTURE
 Base abstract class for defining data structures in GCGlib. It indicates the minimum methods that all data structures must provide. Some abstract specializations of this class demand other interfaces to handle their elements under more specific or restricted conditions. More...
 
class  gcgLINK
 Generic abstract class for defining a linkable node for use in single linked lists and linear data structures. It can be used with several classes in GCGlib. It is sufficient for use for some data structures as gcgLINKEDLIST. Specialized objects of this class may be returned by gcgITERATOR objects obtained from the data structures. More...
 
class  gcgDOUBLELINK
 Generic abstract class for defining a linkable node for use in double linked lists and linear data structures. It can be used with several classes in GCGlib, including extended nodes (gcgORDEREDNODE) that can be compared, enumerated and ordered by more sophisticated data structures. This is intended for use in lists, maps and trees. The gcgDOUBLELINKEDLIST must receive instances of gcgDOUBLELINK or its specialized classes. Specialized objects of this class may be returned by gcgITERATOR objects obtained from the data structures. More...
 
class  gcgLISTSTRUCTURE
 Base abstract class for defining a sequential data structure in GCGlib for lists. It indicates the minimum methods that all list structures with elements that can be in any position must provide. Note that some data structures might provide other interfaces to handle their elements. This interface is different than gcgORDEREDSTRUCTURE where the elements are ordered and countable in the data structure. More...
 
class  gcgLINKEDLIST
 It is a concrete class that defines a fast single linked list. This is a standard data structure that may be used with Last-In-First-Out policies. Use it if you need O(1) time costs for insertions and deletions in the head and tail, but can afford O(n) for searching from first to last element. It cannot iterate from last to first element as gcgDOUBLELINKEDLIST does. A drawback of using linked lists is their tendency to fragment memory and have low cache hits during searches. These problems can be avoided using arrays. Use the gcgLINKEDLIST::getIterator() method to obtain an iterator for the list from head to tail elements. Use gcgQUEUE if you need synchronized and exclusive accesses in enqueue and dequeue operations. More...
 
class  gcgDOUBLELINKEDLIST
 It is a concrete class that defines a fast double linked list. This is a standard data structure that may be used with First-In-First-Out or Last-In-First-Out policies. Use it if you need O(1) time costs for insertions and deletions at head and tail, but can afford O(n) for searching. You must use gcgDOUBLELINK or its specializations in all methods. A drawback of using linked lists is their tendency to fragment memory and have low cache hits during searches. These problems can be avoided using arrays. This class can iterate from first to last element and vice-versa. Use the gcgDOUBLELINKEDLIST::getIterator() method to obtain an iterator for the list to span the nodes from head to tail or vice-versa. Use gcgLINKEDLIST if you need a simpler single linked lists which can be only spanned from head to tail. More...
 
class  gcgORDEREDNODE
 Generic abstract class for defining an extended node for use in ordered data structures like gcgORDEREDSTRUCTURE which needs comparable nodes. It can be used with several classes in GCGlib, mainly those where nodes need to be compared, enumerated and ordered. This is intended for use in more sophisticated versions of lists, maps and trees. Specialized objects of this class may be returned by gcgITERATOR objects obtained from the data structures. Since it inherits from gcgLINK and gcgDOUBLELINK, gcgORDEREDNODE objects can also be used with linear data structures with gcgLISTSTRUCTURE. More...
 
class  gcgORDEREDSTRUCTURE
 Base abstract class for defining a hierarchical data structure in GCGlib for ordered nodes. It indicates the minimum methods that all data structures with ordered elements must provide. Note that some data structures might provide other interfaces to handle their elements. This interface is different than gcgLISTSTRUCTURE where the elements can be positioned anywhere in the data structure. Some data maps will also need a compare() method which is responsible for comparing any two ordered nodes. More...
 
class  gcgAVLTREE
 Generic abstract class to manage a AVL tree. AVL tree is a self balancing data structure that keeps a binary tree almost balanced. It has the restriction that all nodes have children with, at most, one level of difference between them. This constraint is stronger than those of the red-black trees and, as such, the cost for balance maintenance is higher. It has O(log n) complexity for searches, insertions and deletions. The delete operator has a constant multiplier higher than insertions. The height of an AVL tree is strictly less than 1.44 log(n + 2) - 0.328. It is more rigidly balanced than red-black trees leading to slower insertion and removals but slightly faster searches. The nodes in this tree must be comparable. As such, a class specialization must provide gcgAVLTREE::compare() method that has the function of determining if two gcgORDEREDNODE nodes are equal, greater or smaller. Use the gcgAVLTREE::getIterator() to obtain a fast iterator to traverse the AVL nodes in ascending or descending order. More...
 
class  gcgHASHTABLE
 Generic abstract class to manage a hash table. A hash table is a data structure that organizes the node into several buckets, according to a hash function. The number of buckets, or table's capacity, can be adjusted anytime and is closely related to the table performance. If well defined, the hash table is capable of O(1) searches. This class provides self adjusting loads: number of elements / number of buckets. The minimum load is checked whenever a node is removed. It is useful to define how many buckets (if any) are allowed to be empty, waiting to be populated. The maximum load is checked whenever a node is inserted in the table. It is useful to limit the maximum number of elements per bucket, in average. The performance of the hash table during insertions, deletes, and searches are strongly dependent on the gcgHASHTABLE::hash() method. To solve the unavoidable collisions, fast data structures are used for each bucket. The nodes in this table must be comparable. As such, a class specialization must provide gcgHASHTABLE::compare() method that has the function of determining if two gcgORDEREDNODE nodes are equal, greater or smaller. Use the gcgHASHTABLE::getIterator() to obtain a fast iterator to traverse all table entries. More...
 
union  _GCGDIGITALKEY
 Union type for defining digital keys for data map classes. The data maps might use fixed or variable length keys and a careful reading of their documentation is recommended. In general, a key is assumed a digital sequence that can be null terminated strings or a sequence of bytes with fixed size. In this case the bit sequence is assumed to be MSB first from the leftmost bit of the leftmost byte to the rightmost ones (lexicographic order). In general, keys having size up to sizeof(intptr_t), i.e. integers that fit within the same number of bits of a pointer, are copied for performance purposes. For simplicity, the bit sequence is also assumed to be the MSB first from leftmost bit of the word to the rightmost bit. If the keys are null terminated strings or fixed size greater than sizeof(intptr_t), their contents are not copied: only the pointer to the actual key is stored internally. If used as a pointer to the actual key, it can point to any memory region holding the digital sequence. However, its content must NEVER change while in use. The behaviour of the data map is undefined if that happens. A common practice is to point to an internal attribute of the corresponding gcgDATA instance. For ease of use, several constructors are provided for integer keys. Examples of use: trie->insert((int) b, data); // Implicit conversion from int to void* in pkey trie->insert(100L, data); // Implicit conversion from long to void* in pkey trie->insert(str, data); // Implicit conversion from char* to void* in pkey trie->insert(&key, data); // Implicit conversion from class* to void* in pkey trie->search((long long) a); trie->search(GCGDIGITALKEY(188));. More...
 
class  gcgDATAMAP
 Base abstract class for defining a hierarchical data structure in GCGlib for key/value mappings. It indicates the minimum methods that all data structures for kay/value mapping must provide. Note that some data maps might provide other interfaces to handle their elements. The data maps might use fixed or variable length keys and a careful reading of their documentation is recommended. The value is assumed to be an instance of gcgDATA. Data maps differs from gcgLISTSTRUCTURE and gcgORDEREDSTRUCTURE in the sense that only the key is used for indexing the gcgDATA nodes. The key and the value are explicitaly separated internally. Also, the gcgDATA instances are not linked explicitally. The underlying key/value mappings are driven by internal nodes specially designed for the data map. The drawback is that this might lead to more memory fragmentation when compared with gcgLISTSTRUCTURE and gcgORDEREDSTRUCTURE. A key is assumed a digital sequence that can be null terminated strings or a sequence of bytes with fixed size (MSB first order). Keys having size up to sizeof(intptr_t), i.e. integers that fit within the same number of bits of a pointer, are copied for performance purposes (also MSB first order). If the keys are null terminated strings or fixed size greater than sizeof(intptr_t), their contents are not copied: only the pointer to the actual key is stored internally. If used as a pointer to the actual key, it can point to any memory region holding the digital sequence. However, its content must NEVER change while in use. The behaviour of the data map is undefined if that happens. A common practice is to point to an internal attribute of the corresponding gcgDATA instance (if not using integer keys). See the data map documentation. For ease of use, several constructors (GCGDIGITALKEY) are provided for integer keys. More...
 
class  gcgPATRICIAMAP
 Concrete class that implements a PATRICIA tree for key/value mappings. Insertion or search for a random key in a PATRICIA trie built from N random bitstrings requires about log N bit comparisons on the average, and about 2 log N bit comparisons in the worst case. The number of bit comparisons is never more than the length of the key. PATRICIA tree (“Practical Algorithm To Retrieve Information Coded In Alphanumeric”) was proposed by Morrison in 1968. In GCGlib, we use the internal organization proposed in "Chapter 15: Radix Search" of the course of Algorithms and Data Structures, Princeton University, avaliable at http://www.cs.princeton.edu/courses/archive/spring09/cos226/handouts/Algs3Ch15.pdf and developed by Robert Sedgewick since 1978. It has only one type of nodes and has no one-way branching. The remove operation was implemented using the logic presented in the book "A Practical Guide to Data Structures and Algorithms using Java", Sally A. Goldman and Kenneth J. Goldman, Chapman & Hall/CRC, 2008, ISBN‑13: 978‑1‑58488‑455‑2. The gcgPATRICIAMAP can be used with digital keys of any size. A key is a unique digital sequence that refers to a gcgDATA pointer. The bitstrings are scanned in MSB first order (lexicographic). To use gcgPATRICIAMAP, the programmer must first define the key size keysize. If keysize size is 0, the keys in the data map are null terminated strings. Otherwise, the keys have fixed size of keysize bytes. If keysize is 0 (for null terminated strings) or greater than sizeof(void*) (for very long fixed size keys), only the pointer to the actual key content is stored in the tree. Thus, in that cases, the keys are passed by reference in the methods parameters. To enhance performance, if keysize is less than or equal to sizeof(long) bytes, the keys are passed by value in the parameters and are copied internally. This results in much faster searchings in the tree. The stored key pointers (when key size is 0 or greater than sizeof(intptr_t), i.e. integers that fit within the same number of bits of a pointer) are never deleted or freed by gcgPATRICIAMAP. Use gcgPATRICIAMAP when you need key/value mappings where the key has variable size (strings) or has long fixed size. More...
 
class  gcgTHREAD
 Generic abstract class for defining a thread. More...
 
class  gcgLOCK
 Defines a lock for easy critical section control. Provides timed lock, which tries to lock an internal mutex before a given timeout has elapsed. More...
 
class  gcgQUEUE
 Defines a queue with synchronized access. This is a standard data structure that may be used with First-In-First-Out or Last-In-First-Out policies. This is intended for multi-task applications. Use gcgLINKEDLIST if you do not need exclusive accesses in enqueue and dequeue operations. More...
 
class  gcgCACHE
 Defines a synchronized and thread safe memory cache. This is an abstract data structure that may be used to restrict the existence of multiple objects at a time in memory. This class manages key/value pairs using a TRIE tree and a double linked list. The key is generally, a short and unique identity for the data which, in turn, can be of any size. In fact, gcgCACHE stores only the pointer to the data regardless the memory chunk it spans. A key in gcgCACHE can have up to 255 bytes, or be a null terminated string, and all methods access it by a pointer. If the key has at most sizeof(long), the underlying data structure will work more efficiently due to specific optimizations. The size in bytes of the key is configured with setKeySize() method. If zero is given, the keys are treated as null terminated strings with a maximum length of 254. Note that the keys are stored internally for each key/value pair. There are two main interfaces: one for the application requests (non-virtual and data independent methods) and one for the data creation, removal and persistence (abstract, virtual and data dependent methods that must be implemented). The main application interface consists of the get() method for which the application presents the desired key and, if the corresponding data is cached (cache hit), it returns its pointer immediately (its entry is marked as the most recently used). If the data is not present (cache miss), the data interface is called for its retrieval before get() returns. In this case, the gcgCLASS calls the retrieveData() method to get the missing data for the requested key. If the missing data is retrieved but the cache is full (the cache cost capacity exceeds with the new key/value cost), the gcgCACHE calls the discardData() to delete or persist the least recently used key/value pairs until the cost of the new key/value fits in the cache limit. At any time, the application can discard one or all entries by calling flush() method. More...
 
class  gcgJOB
 Generic abstract class for defining a job/task for using with GCGlib. It inherits gcgORDEREDNODE in order to be used in one linked list. More...
 
class  gcgTHREADPOOL
 Controls a pool of threads for executing multiple jobs concurrently. More...
 
class  gcgPRODUCERCONSUMER
 Controls and synchronizes multiple producers and consumers accessing a shared and limited buffer. Supports blocking and non-blocking calls to put() and get(). More...
 
class  gcgTEXTURE2D
 Class to transparently deal with 3D textures. Allocates the texture directly from graphics system and provides functions for binding, unbinding and updating the texture. More...
 
class  gcgINETPEER
 Implements methods for peer-to-peer communication using TCP/IP protocol. More...
 
class  gcgINETSERVICE
 Class with methods to listen a specific port and, as additionnal functionality, manage multiple peers. Methods for insertion, removal and visiting peers are provided. More...
 
class  gcgDISCRETE1D< NUMTYPE >
 Class for 1D signal definition and processing. More...
 
class  gcgMATRIX< NUMTYPE >
 Class for handling matrices with arbitrary dimension. It is used in general functions for linear algebra. More...
 
class  gcgLEGENDREBASIS1D< NUMTYPE >
 Class for Legendre 1D polynomials computation. More...
 
class  gcgLEGENDREBASIS2D< NUMTYPE >
 Class for Legendre 2D polynomials computation. More...
 
class  gcgDWTBASIS1D< NUMTYPE >
 Class for real, discrete, wavelets decomposition and recomposition. More...
 
class  gcgSEQUENCEDERIVATIVE2D< NUMTYPE >
 
class  gcgFILTERMASK1D< NUMTYPE >
 

Macros

#define MIN(a, b)   ((a > b) ? (b) : (a))
 A macro that returns the minimum of a and b. More...
 
#define MAX(a, b)   ((a < b) ? (b) : (a))
 A macro that returns the maximum of a and b. More...
 
#define ABS(a)   (((a) < 0) ? -(a) : (a))
 A macro that returns the absolute value of a. More...
 
#define SWAP(a, b)   {(a) ^= (b); (b) ^= (a); (a) ^= (b);}
 A macro that swaps the values of a and b variables. More...
 
#define DEG2RAD(a)   (((a) * M_PI) / 180.0)
 A macro that converts a degrees in radians. More...
 
#define RAD2DEG(a)   (((a) * 180) / M_PI)
 A macro that converts a radians in degrees. More...
 
#define TRUE   1
 Defines the boolean value for true. More...
 
#define FALSE   0
 Defines the boolean value for false. More...
 
#define EPSILON   0.0000077
 Defines the minimum accepted value for single precision real numbers. More...
 
#define INF   1.0e+16
 Defines the biggest value for real numbers. More...
 
#define FEQUAL(a, b)   (fabs((a)-(b)) < EPSILON)
 A macro for real numbers equality comparisons. More...
 
#define M_PI   3.14159265358979323846
 A macro that defines the number PI with 20 decimals. More...
 
#define NULL   0
 Defines the null pointer. More...
 
#define ISPOWEROF2(n)   (!(n & (n-1)))
 A macro for checking if the integer number n is a power of 2. More...
 
#define GCG_REPORT_CODE(t, d, m)   (((((int) d) & (int) 0xff) << 3) | ((((int) m) & (int) 0x3ff) << 11) | ((((int) t) & (int) 0x07) << 0))
 Composes an error/warning/information given a triple (TYPE, DOMAIN, MESSAGE) with 3, 8 and 10 bits respectively. More...
 
#define GCG_REPORT_TYPE(c)   ((((int) c) >> 0) & (int) 0x07)
 Extracts the TYPE from a report code. Uses 3 bits. More...
 
#define GCG_REPORT_DOMAIN(c)   ((((int) c) >> 3) & (int) 0xff)
 Extracts the DOMAIN from a report code. Uses 7 bits. More...
 
#define GCG_REPORT_MESSAGE(c)   ((((int) c) >> 11) & (int) 0x3ff)
 Extracts the MESSAGE from a report code. Uses 10 bits. More...
 
#define GCG_SUCCESS   0
 Successful operation. To report a successful operation, call gcgReport(GCG_SUCCESS). GCGlib NEVER reports successful operations for performance purposes. More...
 
#define GCG_ERROR   1
 Indicate an error code.
 
#define GCG_WARNING   2
 Indicate a warning code.
 
#define GCG_INFORMATION   3
 Indicate an information code.
 
#define GCG_DOMAIN_MEMORY   8
 Memory management reports.
 
#define GCG_DOMAIN_NETWORK   9
 Network management reports.
 
#define GCG_DOMAIN_FILE   10
 File management reports.
 
#define GCG_DOMAIN_IMAGE   11
 Image management reports.
 
#define GCG_DOMAIN_CAMERA   12
 Camera management reports.
 
#define GCG_DOMAIN_VIDEO   13
 Video management reports.
 
#define GCG_DOMAIN_THREAD   14
 Thread management reports.
 
#define GCG_DOMAIN_GRAPHICS   15
 Graphics reports.
 
#define GCG_DOMAIN_GEOMETRY   16
 Geometry reports.
 
#define GCG_DOMAIN_ALGEBRA   17
 Algebra reports.
 
#define GCG_DOMAIN_CONFIG   18
 Configuration reports.
 
#define GCG_DOMAIN_DATASTRUCTURE   19
 Data structure reports.
 
#define GCG_DOMAIN_SIGNAL   20
 Signal management reports.
 
#define GCG_DOMAIN_USER   21
 User defined reports.
 
#define GCG_REPORT_ALL   -1
 Indicates all types and domains. It is an exclusive macro for gcgEnableReportLog(). Any negative values used with these functions indicate all types and domains. By default, only errors are enabled to be logged. To enable warnings and information, call gcgEnableReportLog(GCG_WARNING, true) and gcgEnableReportLog(GCG_INFORMATION, true).
 
#define GCG_NONE   0
 Successful operation.
 
#define GCG_ALLOCATIONERROR   1
 Allocation error.
 
#define GCG_INVALIDOBJECT   2
 Attempt to use an invalid object.
 
#define GCG_BADPARAMETERS   3
 Bad parameters.
 
#define GCG_INITERROR   4
 Initialization problem.
 
#define GCG_INTERNALERROR   5
 General internal problem.
 
#define GCG_TIMEOUT   6
 Timeout.
 
#define GCG_IOERROR   7
 Input/output problem.
 
#define GCG_FORMATMISMATCH   8
 Format mismatch.
 
#define GCG_UNRECOGNIZEDFORMAT   9
 Unrecognized format.
 
#define GCG_UNSUPPORTEDFORMAT   10
 Unsupported format.
 
#define GCG_UNSUPPORTEDOPERATION   11
 Unsupported operation.
 
#define GCG_INFORMATIONPROBLEM   12
 Information retrieval problem.
 
#define GCG_READERROR   13
 General error reading or receiving.
 
#define GCG_WRITEERROR   14
 General error writing or sending.
 
#define GCG_NOTCONNECTED   15
 Current object is not connected.
 
#define GCG_SOCKETERROR   16
 General socket problem.
 
#define GCG_SELECTERROR   17
 An error occurred in select()
 
#define GCG_CONNECTIONCLOSED   18
 Connection closed by remote peer.
 
#define GCG_HOSTNOTFOUND   19
 Host not found.
 
#define GCG_CONNECTERROR   20
 General connection problem.
 
#define GCG_SETSOCKETOPTERROR   21
 An error occurred in setsocketopt()
 
#define GCG_BINDERROR   22
 An error occurred in bind()
 
#define GCG_LISTENERROR   23
 An error occurred in listen()
 
#define GCG_ACCEPTERROR   24
 An error occurred in accept()
 
#define GCG_EXCEPTION   25
 An exception was caught.
 
#define GCG_ACCEPTBADADDRESS   26
 Accepting with a bad pointer address or too small buffer.
 
#define GCG_CONNECTIONREFUSED   27
 Connection refused by host.
 
#define GCG_CONNECTIONABORTED   28
 Connection aborted: data transmission time-out or protocol problem.
 
#define GCG_WRITEBADADDRESS   29
 Sending with a bad pointer address or too small buffer.
 
#define GCG_READBADADDRESS   30
 Receiving with a bad pointer address or too small buffer.
 
#define GCG_SENDSHUTDOWN   31
 Cannot send messages after shutdown.
 
#define GCG_RECEIVESHUTDOWN   32
 Cannot receive messages after shutdown.
 
#define GCG_INVALIDSOCKET   33
 Invalid socket.
 
#define GCG_STREAMCONTROLERROR   34
 Stream control error.
 
#define GCG_ALREADYRUNNING   35
 Already running.
 
#define GCG_CREATIONFAILED   36
 Creation failure.
 
#define GCG_MUTEXFAILURE   37
 Mutex failure.
 
#define GCG_SEMAPHOREFAILURE   38
 Semaphore failure.
 
#define GCG_NOBUFFER   39
 No buffer space available or queue full.
 
#define GCG_JOBNOTEXECUTED   40
 Job not executed.
 
#define GCG_INTERRUPTED   41
 Interrupted by extern signal.
 
#define GCG_DISCONNECTED   42
 This object was active and is now disconnected.
 
#define GCG_STOPERROR   43
 Process, thread or job could not be stoped.
 
#define GCG_NOTRUNNING   44
 Process, thread or job is not running.
 
#define GCG_EXITFAILURE   45
 Object did not exit properly.
 
#define GCG_RELEASEERROR   46
 Resource release error.
 
#define GCG_LOCKERROR   47
 Lock was not acquired.
 
#define GCG_OWNERSHIPERROR   48
 Object is not owned by the caller.
 
#define GCG_REMOVALERROR   49
 Removal error.
 
#define GCG_STOREFAILURE   50
 Data was not stored.
 
#define GCG_OPENERROR   51
 Open error.
 
#define GCG_DECODEERROR   52
 Decode error.
 
#define GCG_FUNCTIONCALLFAILED   53
 Function call failed.
 
#define GCG_GRAPHICSERROR   54
 Graphics system error.
 
#define GCG_INCOMPATIBILITYERROR   55
 Incompatibility error.
 
#define GCG_CONFIGERROR   56
 Error configuring request.
 
#define GCG_UNAVAILABLERESOURCE   57
 Unavailable resource.
 
#define GCG_STARTERROR   58
 Start error.
 
#define GCG_OUTOFBOUNDS   59
 Out of bounds.
 
#define GCG_ENDOFSTREAM   60
 End of stream.
 
#define GCG_OPERATIONFAILED   61
 Operation failed.
 
#define GCG_MEMORYLEAK   62
 Memory leak detected.
 
#define GCG_INSERTIONFAILED   63
 Insertion failed.
 
#define GCG_ADAPTING   64
 Adapting to new conditions.
 
#define GCG_UNDEFINED   65
 Undefined error.
 
#define GCG_BORDER_EXTENSION_ZERO   1
 Defines the border extension as: zero outside the signal support 0 0 0 s[0] s[1] s[2] 0 0 0. More...
 
#define GCG_BORDER_EXTENSION_CLAMP   2
 Defines the border extension as: the first/last value s[0] s[0] s[0] s[0] s[1] s[2] s[2] s[2] s[2]. More...
 
#define GCG_BORDER_EXTENSION_PERIODIC   3
 Defines the border extension as: periodically extended s[0] s[1] s[2] s[0] s[1] s[2] s[0] s[1] s[2]. More...
 
#define GCG_BORDER_EXTENSION_SYMMETRIC_NOREPEAT   4
 Defines the border extension as: symmetrically extended s[0] s[2] s[1] s[0] s[1] s[2] s[1] s[0] s[2]. More...
 
#define GCG_BORDER_EXTENSION_SYMMETRIC_REPEAT   5
 Defines the border extension as: symmetrically extended with repeat s[2] s[1] s[0] s[0] s[1] s[2] s[2] s[1] s[0]. More...
 
#define GCG_EVENT_NOTREADYORDISCONNECTED   0x0
 Indicates that the peer is not ready for communication, an error occurred or the peer is disconnected.
 
#define GCG_EVENT_RECEIVEREADY   0x1
 Indicates that the peer is ready to receive messages.
 
#define GCG_EVENT_SENDREADY   0x2
 Indicates that the peer is ready to send messages. Even if the peer is ready to send, it does not imply that the caller will not block. This also depends on the size of the message.
 
#define GCG_EVENT_RECEIVESENDREADY   (GCG_EVENT_RECEIVEREADY | GCG_EVENT_SENDREADY)
 Indicates that the peer is ready to receive or send messages.
 
#define GCG_EVENT_INSERTED   0x4
 Indicates that the peer was inserted by processEvents().
 
#define GCG_EVENT_REMOVED   0x8
 Indicates that the peer was removed by processEvents().
 
#define GCG_EVENT_VISIT   0x10
 Indicates that the peer was flagged to be visited by eventHandler().
 
#define GCG_EVENT_NEWCONNECTION   0x20
 Indicates that a new connection was accepted.
 

Typedefs

typedef union _GCGDIGITALKEY GCGDIGITALKEY
 Union type for defining digital keys for data map classes. The data maps might use fixed or variable length keys and a careful reading of their documentation is recommended. In general, a key is assumed a digital sequence that can be null terminated strings or a sequence of bytes with fixed size. In this case the bit sequence is assumed to be MSB first from the leftmost bit of the leftmost byte to the rightmost ones (lexicographic order). In general, keys having size up to sizeof(intptr_t), i.e. integers that fit within the same number of bits of a pointer, are copied for performance purposes. For simplicity, the bit sequence is also assumed to be the MSB first from leftmost bit of the word to the rightmost bit. If the keys are null terminated strings or fixed size greater than sizeof(intptr_t), their contents are not copied: only the pointer to the actual key is stored internally. If used as a pointer to the actual key, it can point to any memory region holding the digital sequence. However, its content must NEVER change while in use. The behaviour of the data map is undefined if that happens. A common practice is to point to an internal attribute of the corresponding gcgDATA instance. For ease of use, several constructors are provided for integer keys. Examples of use: trie->insert((int) b, data); // Implicit conversion from int to void* in pkey trie->insert(100L, data); // Implicit conversion from long to void* in pkey trie->insert(str, data); // Implicit conversion from char* to void* in pkey trie->insert(&key, data); // Implicit conversion from class* to void* in pkey trie->search((long long) a); trie->search(GCGDIGITALKEY(188));. More...
 

Functions

static int SQR (int x)
 Inline function for squaring integers. More...
 
static short SQR (short x)
 Inline function for squaring shorts. More...
 
static long SQR (long x)
 Inline function for squaring longs. More...
 
static float SQR (float x)
 Inline function for squaring floats. More...
 
static double SQR (double x)
 Inline function for squaring doubles. More...
 
bool gcgReport (int code, const char *format=NULL,...)
 Reports an error. To avoid serialization, it is NEVER called for successful operations inside GCGlib. The last report might not have been issued by the last call. Check the error/warning only when a method or function fails. It saves the error/warning information and, if logging is enabled, send an error string to the stream. If the type is GCG_SUCCESS, nothing is sent to the log. Codes of information type might be sent only to the log. Ex. gcgReport(GCG_REPORT_CODE(GCG_ERROR, GCG_MEMORY, GCG_ALLOCATIONERROR)). To report a successful operation, call gcgReport(GCG_SUCCESS). More...
 
int gcgGetReport (int sizestring=0, char *extrastring=NULL)
 Returns the code of the last report. Use GCG_REPORT_TYPE(), GCG_REPORT_DOMAIN(), and GCG_REPORT_MESSAGE() to extract the details of the error code. More...
 
const char * gcgGetReportString (char **typestr=NULL, char **domainstr=NULL)
 Gets the strings of the last report. More...
 
bool gcgEnableReportLog (int code, bool enable)
 Enables or disables the logging of messages of a specific type or domain. When a type or domain is enabled, the gcgReport() function sends any message of that type or domain to gcgOutputLog(). To enable all types and domains, call gcgEnableReportLog(GCG_REPORT_ALL, true). Likewise, to disable them all call gcgEnableReportLog(GCG_REPORT_ALL, false). To enable all messages of a specific type, INFORMATION for example, call gcgEnableReportLog(GCG_INFORMATION, true). All information messages will be logged. In the other hand, to disable all INFORMATION messages, call gcgEnableReportLog(GCG_INFORMATION, false). To enable all messages of a specific domain, GRAPHICS for example, call gcgEnableReportLog(GCG_DOMAIN_GRAPHICS, true). All messages related to graphics functions will be logged for all types. By default, only the type GCG_ERROR is enabled and reported. More...
 
FILE * gcgGetLogStream ()
 Returns the current log stream. The default log stream is stderr. More...
 
FILE * gcgSetLogStream (FILE *logstream)
 Sets a new stream for logging. The default log stream is stderr. Returns the previous log stream. More...
 
void gcgOutputLog (const char *format,...)
 Reports a new message to the log stream. More...
 
uintptr_t getAllocatedMemoryCounter ()
 Function to retrieve how much memory was dynamically allocated by using GCGlib. More...
 
bool gcgInverseMatrix2 (MATRIX2 inverse, MATRIX2 matrix)
 Computes the inverse of a 2x2 matrix by the direct method. It is suitable for fast inverse computation in bidimensional spaces. In this version, both input and output matrices are C vectors of 4 floats in row first order. More...
 
bool gcgInverseMatrix3 (MATRIX3 inverse, MATRIX3 matrix)
 Computes the inverse of a 3x3 matrix by the direct method. It is suitable for fast inverse computation in tridimensional spaces. More...
 
bool gcgInverseMatrix4 (MATRIX4 inverse, MATRIX4 matrix)
 Computes the inverse of a 4x4 matrix by the direct method. It is suitable for fast inverse computation in homogeneous spaces in computer graphics. In this version, both input and output matrices are C vectors of 16 floats in row first order. More...
 
bool gcgInverseMatrix2 (MATRIX2d inverse, MATRIX2d matrix)
 Computes the inverse of a 2x2 matrix by the direct method. It is suitable for fast inverse computation in bidimensional spaces. In this version, both input and output matrices are C vectors of 4 doubles in row first order. More...
 
bool gcgInverseMatrix3 (MATRIX3d inverse, MATRIX3d matrix)
 Computes the inverse of a 3x3 matrix by the direct method. It is suitable for fast inverse computation in tridimensional spaces. More...
 
bool gcgInverseMatrix4 (MATRIX4d inverse, MATRIX4d matrix)
 Computes the inverse of a 4x4 matrix by the direct method. It is suitable for fast inverse computation in homogeneous spaces in computer graphics. In this version, both input and output matrices are C vectors of 16 doubles in row first order. More...
 
bool gcgEigenSymmetric (int norder, float matrix[], float eigenvectors[], float eigenvalues[])
 Computes the eigensystem decomposition of a symmetric matrix matrix with arbitraty order. The resulted eigenvectors are stored as rows in a matrix eigenvectors with norder x norder elements. Their respective norder eigenvalues are stored in the vector eigenvalues. The eigenvectors and eigenvalues are ordered by decreasing eigenvalues. Version adapted from the public domain Java Matrix library JAMA. In this version, the input and output matrices are C vectors of norder x norder floats in row first order. More...
 
bool gcgEigenSymmetric (int norder, double matrix[], double eigenvectors[], double eigenvalues[])
 Computes the eigensystem decomposition of a symmetric matrix matrix with arbitraty order. The resulted eigenvectors are stored as rows in a matrix eigenvectors with norder x norder elements. Their respective norder eigenvalues are stored in the vector eigenvalues. The eigenvectors and eigenvalues are ordered by decreasing eigenvalues. Version adapted from the public domain Java Matrix library JAMA. In this version, the input and output matrices are C vectors of norder x norder doubles in row first order. More...
 
bool gcgEigenSymmetricMatrix3 (MATRIX3 matrix, MATRIX3 eigenvectors, VECTOR3 eigenvalues)
 Computes the eigensystem decomposition of a symmetric 3 x 3 matrix matrix. The resulted eigenvectors are stored as rows in a matrix eigenvectors with 3 x 3 elements. Their respective three eigenvalues are stored in the vector eigenvalues. The eigenvectors and eigenvalues are ordered by decreasing eigenvalues. Version adapted from the public domain Java Matrix library JAMA. In this version, the input and output matrices are C vectors of 3 x 3 floats in row first order. More...
 
bool gcgEigenSymmetricMatrix3 (MATRIX3d matrix, MATRIX3d eigenvectors, VECTOR3d eigenvalues)
 Computes the eigensystem decomposition of a symmetric 3 x 3 matrix matrix. The resulted eigenvectors are stored as rows in a matrix eigenvectors with 3 x 3 elements. Their respective three eigenvalues are stored in the vector eigenvalues. The eigenvectors and eigenvalues are ordered by decreasing eigenvalues. Version adapted from the public domain Java Matrix library JAMA. In this version, the input and output matrices are C vectors of 3 x 3 doubles in row first order. More...
 
bool gcgDrawLogo (float scale=0.67)
 Draws the GCG logo on the top right conner of the viewport. More...
 
bool gcgDrawAABox (VECTOR3 bbmin, VECTOR3 bbmax)
 Draws an axis aligned box. Normals are sent and can be used for lighting. All parameters are float values. More...
 
bool gcgDrawAABox (VECTOR3d bbmin, VECTOR3d bbmax)
 Draws an axis aligned box. Normals are sent and can be used for lighting. All parameters are double values. More...
 
bool gcgDrawOBox (VECTOR3 obbangles, VECTOR3 obbcenter, VECTOR3 obbsize)
 Draws an oriented box. Normals are sent and can be used for lighting. All parameters are float values. More...
 
bool gcgDrawOBox (VECTOR3d obbangles, VECTOR3d obbcenter, VECTOR3d obbsize)
 Draws an oriented box. Normals are sent and can be used for lighting. All parameters are double values. More...
 
bool gcgDrawVectorPyramid (float x, float y, float z, VECTOR3 vector, float scale)
 Draws an oriented pyramid (its base is not drawn) which can be used to represent vectors: 4 triangles are drawn using 6 vertices. Normals are sent and can be used for lighting. All parameters are float. More...
 
bool gcgDrawVectorPyramid (float x, float y, float z, VECTOR3d vector, float scale)
 Draws an oriented pyramid (its base is not drawn) which can be used to represent vectors: 4 triangles are drawn using 6 vertices. Normals are sent and can be used for lighting. All parameters are double. More...
 
bool gcgDrawVectorPyramidClosed (float x, float y, float z, VECTOR3 vector, float scale)
 Draws an oriented pyramid (its base is also drawn) which can be used to represent vectors: 6 triangles are drawn using 8 vertices. Normals are sent and can be used for lighting. All parameters are float. More...
 
bool gcgDrawVectorPyramidClosed (float x, float y, float z, VECTOR3d vector, float scale)
 Draws an oriented pyramid (its base is also drawn) which can be used to represent vectors: 6 triangles are drawn using 8 vertices. Normals are sent and can be used for lighting. All parameters are double. More...
 
bool gcgDrawVectorThetrahedron (float x, float y, float z, VECTOR3 vector, float scale)
 Draws an oriented thetahedron (its base is not drawn) which can be used to represent vectors: 3 triangles are drawn using 5 vertices. Normals are sent and can be used for lighting. All parameters are float. More...
 
bool gcgDrawVectorThetrahedron (float x, float y, float z, VECTOR3d vector, float scale)
 Draws an oriented thetrahedron (its base is not drawn) which can be used to represent vectors: 3 triangles are drawn using 5 vertices. Normals are sent and can be used for lighting. All parameters are double. More...
 
bool gcgDrawVectorThetrahedronClosed (float x, float y, float z, VECTOR3 vector, float scale)
 Draws an oriented thetrahedron (its base is also drawn) which can be used to represent vectors: 4 triangles are drawn using 6 vertices. Normals are sent and can be used for lighting. All parameters are float. More...
 
bool gcgDrawVectorThetrahedronClosed (float x, float y, float z, VECTOR3d vector, float scale)
 Draws an oriented thetrahedron (its base is also drawn) which can be used to represent vectors: 4 triangles are drawn using 6 vertices. Normals are sent and can be used for lighting. All parameters are double. More...
 
float gcgBlinkingAlpha ()
 Computes a value between 0 and 1 in function of time that can be used as opacity value to simulate blinking objects. More...
 
bool gcgHeatColor (float normheat, VECTOR3 color)
 Returns a color given a normalized "heat" value between 0 and 1. Uses a palette that partitions the unity with the colors dark blue, blue, bluish cyan, cyan, greenish cyan, green, greenish yellow, yellow, orange and red. All parameters have float type. More...
 
bool gcgHeatColor (double normheat, VECTOR3d color)
 Returns a color given a normalized "heat" value between 0 and 1. Uses a palette that partitions the unity with the colors dark blue, blue, bluish cyan, cyan, greenish cyan, green, greenish yellow, yellow, orange and red. All parameters have double type. More...
 
float gcgTriangleArea (VECTOR3 v0, VECTOR3 v1, VECTOR3 v2)
 Computes the area of a triangle with edges (v0,v1), (v1, v2), (v2, v0). See Graphics Gems II - Pag. 170. More...
 
void gcgTriangleGradient (VECTOR3 grad_u, VECTOR3 v0, VECTOR3 v1, VECTOR3 v2, float u0, float u1, float u2)
 Computes the gradient of a scalar u over a 3D triangle with edges (v0,v1), (v1, v2), (v2, v0). More...
 
float gcgSphericalDistance (float latitude1, float longitude1, float latitude2, float longitude2)
 Computes the distance between two points on the unit sphere using the method of R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159): http://www.movable-type.co.uk/scripts/gis-faq-5.1.htmlComputes. More...
 
template<class NUMTYPE >
bool gcgLinearSolver (gcgDISCRETE2D< NUMTYPE > *A, gcgDISCRETE1D< NUMTYPE > *b, gcgDISCRETE1D< NUMTYPE > *x)
 Computes the solution of a linear system. If A is a square matrix (number of equations = number of unknowns), the result is unique. If the number of rows of A is greater than the number of columns (number of equations > number of unknowns), the solution minimizes the quadratic error of the system (least-squares). More...
 
unsigned int gcgPackRLE8 (unsigned int fullsize, unsigned char *srcdata, unsigned char *RLEdata)
 Packs a 8 bit sequence as a Run-Lenght Encoded block. More...
 
unsigned int gcgUnpackRLE8 (unsigned char *RLEdata, unsigned char *dstdata)
 Decompress a 8 bit Run-Length Encoded data coded with gcgPackRLE8(). More...
 
unsigned int gcgPackRLE32 (unsigned int fullsize, unsigned char *srcdata, unsigned char *RLEdata)
 Packs a 32 bit sequence as a Run-Lenght Encoded block. The parameter srcdata MUST be 4 aligned <=> fullsize MUST be multiple of 4. More...
 
unsigned int gcgUnpackRLE32 (unsigned char *RLEdata, unsigned char *dstdata)
 Decompress a 32 bit Run-Length Encoded data coded with gcgPackRLE32(). More...
 
unsigned int gcgCompressImageRLE8 (unsigned int width, unsigned int height, unsigned char *srcdata, unsigned char *RLEdata)
 Compress a 8 bit bitmap image as a Run-Lenght Encoded block. More...
 
unsigned int gcgDecompressImageRLE8 (unsigned int width, unsigned int height, unsigned char *RLEdata, unsigned char *dstdata)
 Decompress a bit Run-Length Encoded 8 bits bitmap image. It receives a compressed block of a Windows .bmp image or the result of the compression with gcgCompressImageRLE8(). More...
 
unsigned int gcgDecompressImageRLE4 (unsigned int width, unsigned int height, unsigned char *RLEdata, unsigned char *dstdata)
 Decompress a bit Run-Length Encoded 4 bits bitmap image. It receives a compressed block of a Windows .bmp image. More...
 
bool gcgSaveBytesAsText (unsigned int size, unsigned char *data, char *outputname)
 Saves a byte array as C code for software embedding. More...
 
bool gcgSaveFloatsAsText (unsigned int size, float *data, char *outputname)
 Saves a float array as C code for software embedding. More...
 
bool gcgSaveBMPcode (char *inputname, char *outputname)
 Saves a windows bitmap image as C code for software embedding. More...
 
unsigned int gcgGetNumberOfProcessors ()
 Gets the number of processors installed in the system. More...
 

Variables

const char * GCG_VERSION
 Points to the full version string on the form: major.minor.build. More...
 
const char * GCG_BUILD_DATE
 Points to the build date string. More...
 
const int GCG_VERSION_MAJOR
 Points to the integer major version value. More...
 
const int GCG_VERSION_MINOR
 Points to the integer minor version value. More...
 
const int GCG_VERSION_BUILD
 Points to the integer build version value. More...
 

Detailed Description

GCG - Group for Computer Graphics, Image and Vision library.

Universidade Federal de Juiz de Fora
Instituto de Ciências Exatas
Departamento de Ciência da Computação

Typedef Documentation

◆ GCGDIGITALKEY

Union type for defining digital keys for data map classes. The data maps might use fixed or variable length keys and a careful reading of their documentation is recommended. In general, a key is assumed a digital sequence that can be null terminated strings or a sequence of bytes with fixed size. In this case the bit sequence is assumed to be MSB first from the leftmost bit of the leftmost byte to the rightmost ones (lexicographic order). In general, keys having size up to sizeof(intptr_t), i.e. integers that fit within the same number of bits of a pointer, are copied for performance purposes. For simplicity, the bit sequence is also assumed to be the MSB first from leftmost bit of the word to the rightmost bit. If the keys are null terminated strings or fixed size greater than sizeof(intptr_t), their contents are not copied: only the pointer to the actual key is stored internally. If used as a pointer to the actual key, it can point to any memory region holding the digital sequence. However, its content must NEVER change while in use. The behaviour of the data map is undefined if that happens. A common practice is to point to an internal attribute of the corresponding gcgDATA instance. For ease of use, several constructors are provided for integer keys. Examples of use: trie->insert((int) b, data); // Implicit conversion from int to void* in pkey trie->insert(100L, data); // Implicit conversion from long to void* in pkey trie->insert(str, data); // Implicit conversion from char* to void* in pkey trie->insert(&key, data); // Implicit conversion from class* to void* in pkey trie->search((long long) a); trie->search(GCGDIGITALKEY(188));.

Since
0.04.201

Function Documentation

◆ gcgLinearSolver()

template<class NUMTYPE >
bool gcgLinearSolver ( gcgDISCRETE2D< NUMTYPE > *  A,
gcgDISCRETE1D< NUMTYPE > *  b,
gcgDISCRETE1D< NUMTYPE > *  x 
)

Computes the solution of a linear system. If A is a square matrix (number of equations = number of unknowns), the result is unique. If the number of rows of A is greater than the number of columns (number of equations > number of unknowns), the solution minimizes the quadratic error of the system (least-squares).

Parameters
[in]Amatrix with m rows and n columns (m >= n).
[in]bvector with m rows.
[out]xvector with n rows that receives the solution.
Returns
true if the system had a solution computed.
Since
0.02.0

◆ gcgSphericalDistance()

float gcgSphericalDistance ( float  latitude1,
float  longitude1,
float  latitude2,
float  longitude2 
)

Computes the distance between two points on the unit sphere using the method of R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159): http://www.movable-type.co.uk/scripts/gis-faq-5.1.htmlComputes.

Since
0.04.166
Parameters
[in]latitude1Latitude coordinate (in radians) of the first point over the unit sphere.
[in]longitude1Latitude coordinate (in radians) of the first point over the unit sphere.
[in]latitude2Latitude coordinate (in radians) of the second point over the unit sphere.
[in]longitude2Latitude coordinate (in radians) of the second point over the unit sphere.
Returns
the distance between the two points over the unit sphere.

◆ gcgTriangleArea()

float gcgTriangleArea ( VECTOR3  v0,
VECTOR3  v1,
VECTOR3  v2 
)

Computes the area of a triangle with edges (v0,v1), (v1, v2), (v2, v0). See Graphics Gems II - Pag. 170.

Since
0.01.6
Parameters
[in]v0First vertex of the triangle.
[in]v1Second vertex of the triangle.
[in]v2Third vertex of the triangle.
Returns
the area of the triangle.

◆ gcgTriangleGradient()

void gcgTriangleGradient ( VECTOR3  grad_u,
VECTOR3  v0,
VECTOR3  v1,
VECTOR3  v2,
float  u0,
float  u1,
float  u2 
)

Computes the gradient of a scalar u over a 3D triangle with edges (v0,v1), (v1, v2), (v2, v0).

Since
0.01.6
Parameters
[out]grad_uthe 3D vector that will contain the gradient of u. The resulting gradient vector is necessarily over the triangle plane.
[in]v0First vertex of the triangle.
[in]v1Second vertex of the triangle.
[in]v2Third vertex of the triangle.
[in]u0The scalar value of v0 vertex.
[in]u1The scalar value of v1 vertex.
[in]u2The scalar value of v2 vertex.

◆ getAllocatedMemoryCounter()

uintptr_t getAllocatedMemoryCounter ( )

Function to retrieve how much memory was dynamically allocated by using GCGlib.

Returns
Number of bytes dynamically allocated by using GCGlib classes and functions.
Since
0.04.186