Example #1
0
struct node *mirrorImage(struct node *tree){
struct node *ptr;
if(tree!=NULL)
{
mirrorImage(tree->left);
mirrorImage(tree->right);
ptr=tree->left;
tree->left=tree->right;
tree->right=ptr;
}
}
    void VirtualMirrorCombine::updateResult(DataContainer& data) {
        ScopedTypedData<RenderData> normalImage(data, p_normalImageID.getValue());
        ScopedTypedData<RenderData> mirrorImage(data, p_mirrorImageID.getValue());
        ScopedTypedData<RenderData> mirrorRendered(data, p_mirrorRenderID.getValue());

        if (normalImage != 0 && mirrorImage != 0 && mirrorRendered != 0) {
            glEnable(GL_DEPTH_TEST);
            glDepthFunc(GL_ALWAYS);

            FramebufferActivationGuard f*g(this);
            createAndAttachColorTexture();
            createAndAttachDepthTexture();

            _shader->activate();
            decorateRenderProlog(data, _shader);

            cgt::TextureUnit normalColorUnit, normalDepthUnit, mirrorColorUnit, mirrorDepthUnit, mirrorRenderedDepthUnit;
            normalImage->bind(_shader, normalColorUnit, normalDepthUnit, "_normalColor", "_normalDepth", "_normalTexParams");
            mirrorImage->bind(_shader, mirrorColorUnit, mirrorDepthUnit, "_mirrorColor", "_mirrorDepth", "_mirrorTexParams");
            mirrorRendered->bindDepthTexture(_shader, mirrorRenderedDepthUnit, "_mirrorRenderedDepth", "_mirrorRenderedTexParams");

            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            QuadRdr.renderQuad();

            _shader->deactivate();
            cgt::TextureUnit::setZeroUnit();
            glDepthFunc(GL_LESS);
            glDisable(GL_DEPTH_TEST);
            LGL_ERROR;

            data.addData(p_targetImageID.getValue(), new RenderData(_fbo));
        }
        else {
            LDEBUG("No suitable input images found.");
        }
    }
Example #3
0
void GlPictureFlow::addImage(QImage i)
{
    i = i.scaled(sizeBig,sizeBig);
    i = mirrorImage(i);
    images.append(i);
}
Example #4
0
File: main.c Project: bruno-edo/hw2
// Main function
int main( void )
{
  char command[MAXLENGTH];
  char c;


 /********************************************************************
  * YOU WILL NEED TO COMPLETE THE FOLLOWING SECTION FOR STAGES 2 - 5 *
  *******************************************************************/

  printPrompt();

  while( fgets( command, MAXLENGTH, stdin ) != NULL ) 
  {

    int  imgNum;
    char *p;

    if(( p=strrchr( command, '\n')) != NULL ) {
      *p = '\0'; // remove '\n' at end of line
    }
    // find the first non-space character in the command
    p = command;
    while(isspace(*p)) {
      p++;
    }
    c = tolower(*p);

    if( isdigit(c)) // Command k
    {
       if( sscanf( command, "%d", &imgNum ) == 1 ) 
       {
           //Checks to see if there's images in the album.     
           if(first != NULL)
           {
               //Retrieves the image.
               found = getCurrentImage(first);
               found2 = selectImage(found, imgNum);

               //Checks to see if the requested image exist in the album.
               if(found2 != NULL)
               {
                   found->current = FALSE;
                   found2->current = TRUE;
                   printNodeInfos(found2); 
                   last_action = 'k';
                   location = found->index; //Index of the previous image 
                   found = NULL;
                   found2 = NULL;
                   
               }
           }
       }
    }
    else switch( c ) 
    {

    case 'h': // help

      printf(" A - Add image\n" );
      printf(" I - Index\n" );
      printf(" P - Print image\n" );
      printf(" F - Forward\n" );
      printf(" B - Back\n" );
      printf("<k>- make image number k the current image\n");
      printf(" D - Delete image\n" );
      printf(" L - Look for image\n" );
      printf(" R - Rotate image counterclockwise\n" );
      printf(" M - Mirror image (reflect vertically)\n" );
      printf("NE - zoom into North East corner\n" );
      printf("NW - zoom into North West corner\n" );
      printf("SW - zoom into South West corner\n" );
      printf("SE - zoom into South East corner\n" );
      printf(" O - zoom Out\n" );
      printf(" U - Undo\n" );
      printf(" H - Help\n" );
      printf(" Q - Quit\n" );
      break;

      // INSERT CODE FOR OTHER COMMANDS
    
    case 'a':
        p++; //Moves cursor away from 'a'
        while(isspace(*p)) 
        {
             p++;
        }
        int *dim;
        QTnode* qt = getImage(p, dim);

        if(qt != NULL)
        {
            insertNode(qt, dim, p);
            printNodeInfos(getCurrentImage(first)); //Whenever a node is added, it becomes the selected node
        }
        last_action = 'a';
        break;
    
    case 'i':
        if(first != NULL)
        {
            printIndex(first);
        }
        break;
        
    case 'p':
    {
        ListNode* currentImage = getCurrentImage(first);
        
        if(currentImage != NULL)
        {
            printImage(currentImage->image, currentImage->size);
        }
        
        break;
    }
        
    case 'f':
    {
        ListNode* currentImage = getCurrentImage(first);
        
        if(currentImage != NULL && (currentImage->next != NULL))
        {
            
            currentImage->current = FALSE;
            currentImage = currentImage->next;
            currentImage->current = TRUE;
            printNodeInfos(currentImage);
            last_action = 'f';
        }
        break;
    }
        
    case 'b':
    {
        ListNode* currentImage = getCurrentImage(first);
        
        if(currentImage != NULL && (currentImage->previous != NULL))
        {
            currentImage->current = FALSE;
            currentImage = currentImage->previous;
            currentImage->current = TRUE;
            printNodeInfos(currentImage);
            last_action = 'b';
        }
        break;
    } 
   
        //'K' command is treated in the upper portion of the code
        
    case 'd':
        removeNode();
        if(first != NULL)
        {
            printNodeInfos(getCurrentImage(first)); 
        }    
        last_action = 'd';
         
        break;
        
    case 'l':
        if(first != NULL)
        {
            p++; //Moves cursor away from 'a'
            while(isspace(*p)) 
            {
                 p++;
            }
            ListNode* foundImage = findBySubString(first, p);
            
            //Image with the substring was found
            if(foundImage != NULL)
            {
                ListNode* currentImage = getCurrentImage(first);               
                currentImage->current = FALSE;
                foundImage->current = TRUE;
                printNodeInfos(getCurrentImage(first));
                last_action = 'l';
                location = currentImage->index;
            }   
        }
        break;
        
        case 'r':
        {
            ListNode* currentImage = getCurrentImage(first);
            if(currentImage != NULL)
            {
                rotateImage(currentImage->image);
                printImage(currentImage->image, currentImage->size); 
            } 
            last_action = 'r';           
            break;
        }
        
        case 'm':
        {
            ListNode* currentImage = getCurrentImage(first);
            if(currentImage != NULL)
            {
                mirrorImage(currentImage->image);
                printImage(currentImage->image, currentImage->size);
            }
            last_action = 'm';
            
            break;
        }
        
        case 'n':
        {
            ListNode* currentImage = getCurrentImage(first);
            if(currentImage == NULL)
            {
                break;
            }
            
            //This line gets the next character of the command, so it can be
            //treated accordingly.
            char c2 = *(++p); //Dereferencing the pointer and moving it to the next char of the string
            
            if(c2 == 'e')
            {
                if(currentImage->image->ne == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->ne;
                printImage(currentImage->image, currentImage->size);
                last_action = 'w';  //because "ne" does not work, find a letter that is not used
                location = 'w';
            }
            
            else if(c2 == 'w')

            {
                if(currentImage->image->nw == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->nw;
                printImage(currentImage->image, currentImage->size);
                last_action = 'x';
                location = 'x';
            }
            
            break;
        }
        
        case 's':
        {
            ListNode* currentImage = getCurrentImage(first);
            
            if(currentImage == NULL)
            {
                break;
            }
            
            //This line gets the next character of the command, so it can be
            //treated accordingly.
            char c2 = *(++p); //Dereferencing the pointer and moving it to the next char of the string
            
            if(c2 == 'e')
            {
                if(currentImage->image->se == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->se;
                printImage(currentImage->image, currentImage->size);
                last_action = 'y';
                location = 'y';
            }
            
            else if(c2 == 'w')
            {
                if(currentImage->image->sw == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->sw;
                printImage(currentImage->image, currentImage->size);
                last_action = 'z';
                location = 'z';
            }
            break;
        }
        
        case 'o':
        {
            ListNode* currentImage = getCurrentImage(first);
            
            if(currentImage == NULL || (currentImage->image->out == NULL))
            {
                break;
            }
            
            currentImage->image = currentImage->image->out;
            printImage(currentImage->image, currentImage->size);
            last_action = 'o';
            break;
        }
        
         case 'u':
 
    if(last_action == 'm'){
    ListNode* currentImage = getCurrentImage(first);
            if(currentImage != NULL)
            {
                mirrorImage(currentImage->image);
                printImage(currentImage->image, currentImage->size);
            }
            
            break;
        }
 
    else if(last_action == 'r'){
   ListNode* currentImage = getCurrentImage(first);
            if(currentImage != NULL)
            {
                rotateImage(currentImage->image);
                rotateImage(currentImage->image);
                rotateImage(currentImage->image);
                printImage(currentImage->image, currentImage->size); 
      break;        } 
   }
  
  else if(last_action == 'a'){
  removeNode();
        if(first != NULL)
        {
            printNodeInfos(getCurrentImage(first)); 
        }    
  break;
  }
   
  else if(last_action == 'd'){
	//todo me no smart
        break;
  }
  
  else if(last_action == 'w' || (last_action == 'x') || (last_action == 'y') || (last_action == 'z')){
  
            ListNode* currentImage = getCurrentImage(first);
            
            if(currentImage == NULL || (currentImage->image->out == NULL))
            {
                break;
            }
            
            currentImage->image = currentImage->image->out;
            printImage(currentImage->image, currentImage->size);
            break;
  }
  
  else if(last_action == 'o'){
  ListNode* currentImage = getCurrentImage(first);
  
		  if(location == 'w')
		  { if(currentImage->image->ne == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->ne;
                printImage(currentImage->image, currentImage->size);
		   
		  	break;
		  }
   
		 else if(location == 'x')
		 {                if(currentImage->image->nw == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->nw;
                printImage(currentImage->image, currentImage->size);
		     break;
		 }
   
		 else if(location == 'y')
		 { if(currentImage->image->se == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->se;
                printImage(currentImage->image, currentImage->size);
		 	break;
		 }
   
	   else if(location == 'z')
	   { if(currentImage->image->sw == NULL)
                {
                    break;
                }
                
                currentImage->image = currentImage->image->sw;
                printImage(currentImage->image, currentImage->size);
			break;
	   }
   
   }
   
 else if(last_action == 'b'){
         ListNode* currentImage = getCurrentImage(first);
        
        if(currentImage != NULL && (currentImage->next != NULL))
        {
            
            currentImage->current = FALSE;
            currentImage = currentImage->next;
            currentImage->current = TRUE;
            printNodeInfos(currentImage);
        }
 break;
 }
 
 else if(last_action == 'f'){
 ListNode* currentImage = getCurrentImage(first);
        
        if(currentImage != NULL && (currentImage->previous != NULL))
        {
            currentImage->current = FALSE;
            currentImage = currentImage->previous;
            currentImage->current = TRUE;
            printNodeInfos(currentImage);
        }
 break;
 }
 
 else if(last_action == 'k' || (last_action == 'l')){
                //Retrieves the image.
               found = getCurrentImage(first);
               found2 = selectImage(found, location);

               //Checks to see if the requested image exist in the album.
               if(found2 != NULL)
               {
                   found->current = FALSE;
                   found2->current = TRUE;
                   printNodeInfos(found2); 
                   found = NULL;
                   found2 = NULL;
                   
               }
 break;
 }
 
   

        
    case 'q': // quit program
      printf("Bye!\n");
      return 0;
      break;
      
    default:
      printf("Unrecognized command: %s\n", command );
      break;
    }

    printPrompt();
  }

  return 0;
}
Example #5
0
int main(){
int option,val;
struct node *ptr;
create_tree(tree);
//clrscr();
do{
printf("\n***************MAIN MENU**********************");
printf("\n 1.Insert Element");
printf("\n 2.Pre-order Traversal");
printf("\n 3.In-order Traversal");
printf("\n 4.Post-order Traversal");
printf("\n 5.Find the smallest element");
printf("\n 6.Find the largest element");
printf("\n 7.Delete an element");
printf("\n 8.Count the total number of nodes");
printf("\n 9.Count the total number of External nodes");
printf("\n 10.Count the total number of Internal nodes");
printf("\n 11.Determine the height of the tree");
printf("\n 12.Find the mirror image of the tree");
printf("\n 13.Delete the tree");
printf("\n 14.Exit");
printf("\n*************************************************");
printf("\n\n");
printf("Enter your option : ");
scanf("%d",&option);

switch(option)
{
case 1: printf("\n Enter the value of the nuw node : ");
	scanf("%d",&val);
	tree=insertElement(tree,val);
	break;

case 2: printf("\n The Elements of the tree are : \n");
	preorderTraversal(tree);
	break;

case 3: printf("\n The Elements of the tree are : \n");
	inorderTraversal(tree);
	break;

case 4: printf("\n The Elements of the tree are : \n");
	postorderTraversal(tree);
	break;

case 5: ptr=findSmallestElement(tree);
	printf("\n The smallest Element of the tree is : %d",ptr->data);
	break;

case 6: ptr=findLargestElement(tree);
	printf("\n The largest Element of the tree is : %d",ptr->data);
	break;

case 7: printf("\n Enter the Element to be deleted : ");
	scanf("%d",&val);
	tree=deleteElement(tree,val);
	break;

case 8: printf("\n Total Number of Nodes in the tree is = %d",totalNodes(tree));
	break;

case 9: printf("\n Total Number of External Nodes = %d",totalExternalNodes(tree));
	break;

case 10: printf("\n Total Number of Internal Nodes = %d",totalInternalNodes(tree));
	 break;

case 11: printf("\n The Height of Binary Tree is = %d",Height(tree));
	 break;

case 12: tree=mirrorImage(tree);
	 break;

case 13: tree=deleteTree(tree);
	 break;

case 14: printf("Exit\n");
     break;

default:
	system("cls");
	printf("Invalid Option\n");
	printf("Re-enter your Option\n\n");
	
	
}
}while(option!=14);
getch();
return 0;

}