Changeset 2807 in orxonox.OLD for orxonox/branches
- Timestamp:
- Nov 11, 2004, 1:40:43 PM (20 years ago)
- Location:
- orxonox/branches/importer/importer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/importer/importer/array.cc
r2804 r2807 3 3 Array::Array () 4 4 { 5 createArray (2000); 6 } 7 Array::Array (unsigned int arraySize) 8 { 9 createArray (arraySize); 5 createArray (); 10 6 } 11 7 12 void Array::createArray ( unsigned int newArraySize)8 void Array::createArray () 13 9 { 14 10 if (verbose >= 2) 15 printf ("crating new Array of size %i\n", newArraySize); 16 array = new GLfloat [newArraySize]; 11 printf ("crating new Array\n"); 12 firstEntry = new Entry; 13 firstEntry->next =NULL; 14 currentEntry=firstEntry; 17 15 entryCount = -1; //0 means one entry 18 arraySize = newArraySize;19 16 return; 20 17 } 21 18 22 void Array::resizeArray (unsigned int newSize)23 {24 if (verbose >= 2)25 printf ("Resizing Array to size %i\n", newSize);26 GLfloat* newArray = new GLfloat [newSize];27 28 for (int i=0; i<=entryCount; i++)29 newArray[i] = array[i];30 31 delete [] array;32 array = newArray;33 arraySize = newSize;34 35 return;36 }37 38 19 void Array::finalizeArray (void) 39 20 { 40 21 if (verbose >= 3) 41 22 printf ("Finalizing array.\n"); 42 resizeArray (entryCount+1); 23 if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) 24 printf ("could not allocate %i data Blocks\n", entryCount); 25 Entry* walker = firstEntry; 26 for (int i=0; i<=entryCount; i++) 27 { 28 array[i] = walker->value; 29 walker = walker->next; 30 } 43 31 return; 44 32 } … … 49 37 if (verbose >= 3) 50 38 printf ("adding new Entry to Array: %f\n", entry); 39 51 40 entryCount++; 52 53 if (entryCount > arraySize) 54 resizeArray(arraySize+2000); 55 56 array[entryCount] = entry; 41 currentEntry->value = entry; 42 currentEntry->next = new Entry; 43 currentEntry = currentEntry->next; 44 currentEntry->next = NULL; 57 45 58 46 } … … 80 68 void Array::debug () 81 69 { 82 printf (" arraySize=%i, entryCount=%i, address=%p\n", arraySize, entryCount, array);70 printf ("entryCount=%i, address=%p\n", entryCount, array); 83 71 } -
orxonox/branches/importer/importer/array.h
r2804 r2807 11 11 public: 12 12 Array (); 13 Array (unsigned int arraySize);14 13 15 void createArray (unsigned int newArraySize); 16 void resizeArray (unsigned int newSize); 14 void createArray (); 17 15 void finalizeArray (void); 18 16 void addEntry (GLfloat entry); … … 23 21 void debug(void); 24 22 private: 23 struct Entry 24 { 25 GLfloat value; 26 Entry* next; 27 }; 28 25 29 GLfloat* array; 26 unsigned int arraySize; 27 unsigned int entryCount; 28 30 int entryCount; 31 Entry* firstEntry; 32 Entry* currentEntry; 33 34 29 35 }; 30 36 -
orxonox/branches/importer/importer/framework.cc
r2804 r2807 2 2 #include "object.h" 3 3 4 int verbose = 2;4 int verbose = 4; 5 5 WindowHandler wHandler; // Create an instance of the whandler basecode class 6 6 Object* obj;
Note: See TracChangeset
for help on using the changeset viewer.