Beispiel #1
0
void testApp::updateBack() {
	backTriangles.clear();
	Triangle cur;
	ofVec3f offset(0, 0, backOffset);
	
	ofVec3f nw = surface[getSurfaceIndex(roiStart.x, roiStart.y)];
	ofVec3f ne = surface[getSurfaceIndex(roiEnd.x - 1, roiStart.y)];
	ofVec3f sw = surface[getSurfaceIndex(roiStart.x, roiEnd.y - 1)];
	ofVec3f se = surface[getSurfaceIndex(roiEnd.x - 1, roiEnd.y - 1)];
	
	ofVec3f nwo = nw + offset;
	ofVec3f swo = sw + offset;
	ofVec3f neo = ne + offset;
	ofVec3f seo = se + offset;
	
	addBack(nwo, neo, ne, nw); // top
	addBack(ne, neo, seo, se); // right
	addBack(sw, se, seo, swo); // bottom
	addBack(nwo, nw, sw, swo); // left
	
	// two back faces
	addBack(nwo, swo, seo, neo);
	
	calculateNormals(backTriangles, backNormals);
}
/**
 * Add at position i of the linkList
 * Note: index is not zero-based
 */
void addatPosition(dlinklist *ll,int position,float value)
{
	int length = listSize(ll);
	if(position > length + 1) {
		printf("You entered the position out of the bound!\n");
		return;
	}
	node *temp;
	int i = 1;
	data *newData = createData(value);

	if(position == 1) {
		//insert here - addFront and return;
		addFront(ll,newData);
	} else if(position == length + 1) {
		//insert here - addBack and return;
		addBack(ll,newData);
	}

	node *newNode = createNode(newData);
	for(temp= ll->head; temp != NULL; temp=temp->next) {
		if(i == position) {
			//insert here and return;
			temp->prev->next = newNode;
			newNode->next = temp;
			newNode->prev = temp->prev;
			temp->prev = newNode;
#if DEBUG
			printf(">>==============Node added at position %d with value : %f================<<\n",position,value);
#endif
			return;
		}
		i++;
	}
}
Beispiel #3
0
void loadDirectoryToList(char *path, struct List *subPath){
    char *buffer;
    DIR *dir;
    struct dirent *ent;
    int len;
    if ((dir = opendir (path)) != NULL) {
        /* print all the files and directories within directory */
        while ((ent = readdir (dir)) != NULL) {
            len = strlen(path) + strlen(ent->d_name) + 2;
            buffer = (char *)malloc(sizeof(char)*len);
            //printf("%s\n",ent->d_name);
            strcpy(buffer, path);
            strcat(buffer, "/");
            strcat(buffer, ent->d_name);
            struct Node * node = createStrNode(buffer, fdl_path);
            addBack(subPath, node);
            //buffer = "\0";
        }
        closedir (dir);
    } else {
        /* could not open directory */
        perror ("");
        exit(0);
    }
}
Beispiel #4
0
void StringLinkedList::insert(int index, const std::string& e) {
	if (index < 0 || index > n){
		throw OutOfBoundException("index is out of bounds");
	}
	
	else
{
		StringNode* node = head, *prev = new StringNode;
		StringNode* v = new StringNode;
		v->elem = e;
		int pos = 0;
		while (pos != index  && node-> next != NULL){
			prev = node;
			node = node->next;
			pos++;
		}
		if(index == 0) addFront(e);
		else if(index == n) addBack(e);
		else{
		prev->next = v;
		v->next = node;
		n++;
		}
	}
}
Beispiel #5
0
int main(int argc, char* argv[])
{
	struct clinklist* myLl = createlinklist();
	struct data* myDta=NULL;
	myDta = createData(1.1,2.2);
	addFront(myLl,myDta);
	printList(myLl);
printf("\n");

	myDta = createData(3.3,4.4);
	addFront(myLl,myDta);
	printList(myLl);
printf("\n");

	myDta = createData(5.5,6.6);
	addFront(myLl,myDta);
	printList(myLl);
printf("\n");

	myDta = createData(0.0,0.0);
	addBack(myLl,myDta);
	printList(myLl);
printf("\n");
	

  return 0;
}
Beispiel #6
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//		Helpers
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void Hash::adjust(int newsize)
{
	for ( ; m_size < newsize; )
	{
		addBack(-1);
	}//for
}//adjust - stitch on new bins
Beispiel #7
0
void List::addAll(const IList* list){
  IIterator* iter = list->iterator();
  assert(iter != nullptr);
  while(iter->hasNext()){
    addBack(iter->next());
  }
  delete iter;  // don't forget to delete your iterator
}
void LightCycle::initBike() {
	addFront();
	addBack();
	addBottomBar();
	addBottomDetails();
	addEngineBlock();
	addInnerCircles();
	addLayeredCircles();
}
Beispiel #9
0
DataTypeId addDataType(const char name[], _md)
{
	if (getTypeIdByName(name, modelPtr) != BAD_INDEX)
	{
		return BAD_INDEX;
	}
	
	addBack(types_m, DataType, createDataType(name));
	return types_m.len - 1;
}
Beispiel #10
0
Hash::Hash(int m)
{
	m_size = 0;
	active = 0;
	m_front = nullptr;

	for(int i = 0; i < m; i++)
	{
		addBack(-1);
	}//for
}//Hash Default Constructor
Beispiel #11
0
/**
 * Creates a new argument expression list from an existing expression. To be used in
 * situations where the argument expression list does not already exist.
 */
GrammarList newExpressionList(Expression e) {
  GrammarList eList = (GrammarList)malloc(sizeof(struct grammarList_));
  eList->precode = NULL;
  eList->postcode = NULL;
  eList->s = NULL;
  eList->code = NULL;
  eList->tt = NULL;
  eList->type = expressionList;
  eList->head = 0;
  eList->tail = 0;
  addBack(eList, e);
  return eList;
}
Beispiel #12
0
/**
 * Creates a new parameter list from an existing parameter. To be used in sutations
 * where a parameter list does not already exist. See addBack for cases where the
 * list already exists.
 */
GrammarList newParameterList(Parameter p) {
  GrammarList pList = (GrammarList)malloc(sizeof(struct grammarList_));
  pList->precode = NULL;
  pList->postcode = NULL;
  pList->s = NULL;
  pList->code = NULL;
  pList->tt = NULL;
  pList->type = parameterList;
  pList->head = 0;
  pList->tail = 0;
  addBack(pList, p);
  return pList;
}
Beispiel #13
0
/**
 * Creates a new argument expression list from an existing expression. To be used in
 * situations where the argument expression list does not already exist.
 */
GrammarList newArgumentExpressionList(Expression e) {
  GrammarList aeList = (GrammarList)malloc(sizeof(struct grammarList_));
  aeList->precode = NULL;
  aeList->postcode = NULL;
  aeList->s = NULL;
  aeList->code = NULL;
  aeList->tt = NULL;
  aeList->type = argument;
  aeList->head = 0;
  aeList->tail = 0;
  addBack(aeList, e);
  return aeList;
}
Beispiel #14
0
/**
 * Create a new statement list from an existing statement. To be used in situations where
 * a statement list does not already exist.
 */
GrammarList newStatementList(Statement s) {
  GrammarList sList = (GrammarList)malloc(sizeof(struct grammarList_));
  sList->precode = NULL;
  sList->postcode = NULL;
  sList->s = NULL;
  sList->code = NULL;
  sList->tt = NULL;
  sList->type = statement;
  sList->head = 0;
  sList->tail = 0;
  addBack(sList, s);
  return sList;
}
Beispiel #15
0
List * parseFile(char * fileName, List * list){
    
    FILE * fp;
    char *name, *type, *temp;
    int rating;
    char buffer[200];
    
    fp = fopen(fileName, "r");
    if (fp == NULL)
        printf("The file was not loaded.\n");
    
    while (fgets(buffer, 200, fp) != NULL){
        name = strtok(buffer, ",");
        type = strtok(NULL, ",");
        rating = strtol(strtok(NULL, ",\n"), &temp, 10);
        
        Restaurant * newRest = createRestaurant(name, type, rating);
        Element * newElement = createElement(newRest);
        list = addBack(list, newElement);
        
    }
    fclose(fp);
    return list;
}
Beispiel #16
0
void IntegerList::addFront(int input) {
    addBack(input);
}
Beispiel #17
0
/**
 * Adds a new statement to the front of the statementlist
 */
GrammarList extendStatementList(GrammarList sList, Statement s) {
  addBack(sList, s);
  return sList;
}
Beispiel #18
0
/* Add an element to the end of the queue */
void enqueue (Queue *Q, int a)
{
    Q->myList->head = addBack( Q->myList, a );
    Q->queueLength = Q->myList->length;
}
Beispiel #19
0
void List::push(int x)
{
	addBack(x);
}//push - lovely wrapper
Beispiel #20
0
void AssemFunc::finalise() {
	// Add the necessary commands to the top and bottom of the function, 
	// depending on if the function is the main entry point, and whether the
	// local stack pointer needs to be moved or not

	// NB: Front intrsuctions are done in reverse

	if (_name == "main") {
		vector<string> args;
		args.push_back("r0");
		args.push_back("#0");
		addBack("mov", args);
	}

	if (_stackPointer > 0) {
		// Only do this if we actually need to move the pointer, avoid 
		// sub sp sp #0 and the like.
		vector<string> spArgs(2, "sp");
		spArgs.push_back("#" + boost::lexical_cast<string>(_stackPointer));
		addFront("sub", spArgs);

		vector<string> fpArgs;
		fpArgs.push_back("fp");
		fpArgs.push_back("sp");
		fpArgs.push_back("#4");
		addFront("add", fpArgs);

		fpArgs.clear();
		fpArgs.push_back("sp");
		fpArgs.push_back("fp");
		fpArgs.push_back("#4");
		addBack("sub", fpArgs);
	} else if (_pointerByReg != "") {

		if (_pointerByReg[0] == '.') {
			// size is in a label
			string tempReg = _freeRegs.front();

			vector<string> spArgs(2, "sp");
			spArgs.push_back(tempReg);
			addFront("sub", spArgs);

			spArgs.clear();
			spArgs.push_back(tempReg);
			spArgs.push_back(_pointerByReg);
			addFront("ldr", spArgs);
		} else {
			vector<string> spArgs(2, "sp");
			spArgs.push_back(_pointerByReg);
			addFront("sub", spArgs);
		}

		vector<string> fpArgs;
		fpArgs.push_back("fp");
		fpArgs.push_back("sp");
		fpArgs.push_back("#4");
		addFront("add", fpArgs);

		fpArgs.clear();
		fpArgs.push_back("sp");
		fpArgs.push_back("fp");
		fpArgs.push_back("#4");
		addBack("sub", fpArgs);
	}

	if (_name == "main") {
		vector<string> args;
		args.push_back("sp!");
		args.push_back("{fp, lr}");
		addFront("stmfd", args);

		args.clear();
		args.push_back("sp!");
		args.push_back("{fp, pc}");
		addBack("ldmfd", args);

		addFront("main:", vector<string>());

		vector<string> globArgs(1, _name);
		addFront(".global", globArgs);
	} else {
		vector<string> args;
		args.push_back("sp!");
		args.push_back("{r4-r10, fp, lr}");
		addFront("stmfd", args);

		args.clear();
		args.push_back("sp!");
		args.push_back("{r4-r10, fp, pc}");
		addBack("ldmfd", args);

		addFront(_name + ":", vector<string>());
	}

	vector<string> alignArgs(1, "2");
	addFront(".align", alignArgs);

}
Beispiel #21
0
void testApp::addBack(ofVec3f& a, ofVec3f& b, ofVec3f& c, ofVec3f& d) {
	addBack(a, b, d);
	addBack(b, c, d);
}