Пример #1
0
 TypeOfFE_P1ttdc(): TypeOfFE(0,0,3,1,Data,1,1,3,3,Pi_h_coef)
  { const R2 Pt[] = { Shrink(R2(0,0)), Shrink(R2(1,0)), Shrink(R2(0,1)) }; 
    for (int i=0;i<NbDoF;i++) {
     pij_alpha[i]= IPJ(i,i,0);
     P_Pi_h[i]=Pt[i];
     // cout << Pt[i] << " " ;
    }
    //	cout <<" cshrink: " << cshrink << " cshrink1 : "<< cshrink1 <<endl;
   }
Пример #2
0
void Street::CreatePlaneStreet()
{
	double height = 0.0f;
	std::vector<Vertex *> vert;
	for (int i = 0; i < 4; i++)
	{
		int u = (i == 2) ? 3 : ((i == 3) ? 2 : i);
		Vertex *tmp = vertices->at(u);
		vert.push_back(new Vertex(tmp->X(), tmp->Y(), height));
	}
	faces->push_back(new Face(new std::vector<Vertex *>(vert)));
	
	// trottoir
	double heightTrot = 0.2f;
	vert.clear();
	for (unsigned int i = 0; i < vertices->size(); i++)
	{
		int u = (i == 2) ? 3 : ((i == 3) ? 2 : i);
		Vertex *tmp = vertices->at(u);
		vert.push_back(new Vertex(tmp->X(), tmp->Y(), heightTrot));
	}
	Shrink(vert, 0.1f);
	faces->push_back(new Face(new std::vector<Vertex *>(vert)));
	
	std::vector<Vertex *> vect;
	for (unsigned int i = 0; i < vertices->size(); i++)
		vect.push_back(new Vertex(vertices->at(i)->X(), vertices->at(i)->Y(), heightTrot));
	Shrink(vect, 0.1f);
	
	for (unsigned int i = 0; i < vect.size(); i++)
	{
		std::vector<Vertex *> *trot = new std::vector<Vertex *>();
		trot->push_back(new Vertex(*vect[i]));
		trot->push_back(new Vertex(vect[i]->X(), 
					   vect[i]->Y(), height));
		trot->push_back(new Vertex(*vect[(i+1)%4]));
		trot->push_back(new Vertex(vect[(i+1)%4]->X(), 
					   vect[(i+1)%4]->Y(), height));
		
		faces->push_back(new Face(trot));
	}
	
	// add tree
	ImportObj tree(TREE_FILE);
	std::vector<Face*>::iterator itf;
	std::vector<Face*> treefaces = tree.GetFaces();
	Vertex *v;
	
	for (itf = treefaces.begin(); itf != treefaces.end(); ++itf)
	{
		v = new Vertex(GravityCenter(*vertices));
		(*itf)->Translate(v->X(), v->Y(), v->Z());
		faces->push_back((*itf));
		delete v;
	}
}
Пример #3
0
			TypeOfFE_P4dcLagrange (): TypeOfFE(3 + 3 * 3 + 3, 1, Data, 4, 1, 15, 15, Pi_h_coef) {
				static const R2 Pt[15] = {
					R2(0 / 4., 0 / 4.),
					R2(4 / 4., 0 / 4.),
					R2(0 / 4., 4 / 4.),
					R2(3 / 4., 1 / 4.),
					R2(2 / 4., 2 / 4.),
					R2(1 / 4., 3 / 4.),
					R2(0 / 4., 3 / 4.),
					R2(0 / 4., 2 / 4.),
					R2(0 / 4., 1 / 4.),
					R2(1 / 4., 0 / 4.),
					R2(2 / 4., 0 / 4.),
					R2(3 / 4., 0 / 4.),
					R2(1 / 4., 2 / 4.),
					R2(2 / 4., 1 / 4.),
					R2(1 / 4., 1 / 4.)}
				;

				for (int i = 0; i < NbDoF; i++) {
					pij_alpha[i] = IPJ(i, i, 0);
					P_Pi_h[i] = Shrink(Pt[i]);
				}

				// 3,4,5, 6,7,8, 9,10,11,
			}
Пример #4
0
void House::CreateWindow(Vertex &vL, Vertex &vR, double base, double height)
{
	std::vector<Vertex*> front;
	front.push_back(new Vertex(vL.X(), vL.Y(), base));
	front.push_back(new Vertex(vL.X(), vL.Y(), height));
	front.push_back(new Vertex(vR.X(), vR.Y(), height));
	front.push_back(new Vertex(vR.X(), vR.Y(), base));
	
	std::vector<Vertex*> window;
	std::vector<Vertex*>::iterator itv;
	for (itv = front.begin(); itv != front.end(); ++itv)
	{
		window.push_back(new Vertex(*(*itv)));
	}
	Shrink(window, 0.6f);
	
	std::vector<Vertex*>* pan;
	for (int i = 0; i < 4; i++)
	{
		pan = new std::vector<Vertex*>();
		
		pan->push_back(new Vertex(*(front[i])));
		pan->push_back(new Vertex(*(front[(i+1)%4])));
		pan->push_back(new Vertex(*(window[i])));
		pan->push_back(new Vertex(*(window[(i+1)%4])));
		
		faces->push_back(new Face(pan));
	}
}
Пример #5
0
void
DviDoc::Unshrink ()
{
  if (displayShrinkFactor > 1)
    {
      Shrink (-1);
    }
}
Пример #6
0
void MainWindow::ChangeResolution(int w, int h)
{
    ui->displaywidget->setMinimumSize(w,h);
    ui->displaywidget->setMaximumSize(w,h);
    //shrink accordingly
    QApplication::processEvents();
    QTimer::singleShot(0,this,SLOT(Shrink()));
}
Пример #7
0
   TypeOfFE_P2ttdc(): TypeOfFE(0,0,6,1,Data,3,1,6,6,Pi_h_coef)
    { const R2 Pt[] = { Shrink(R2(0,0)), Shrink(R2(1,0)), Shrink(R2(0,1)),
	                Shrink(R2(0.5,0.5)),Shrink(R2(0,0.5)),Shrink(R2(0.5,0)) };
      for (int i=0;i<NbDoF;i++) {
       pij_alpha[i]= IPJ(i,i,0);
       P_Pi_h[i]=Pt[i]; }
     }
Пример #8
0
const void *
PkChar::GetBitmap (/*[in]*/ int shrinkFactor)
{
  MAPINTTORASTER::const_iterator it = bitmaps.find(shrinkFactor);
  if (it != bitmaps.end())
    {
      return (it->second);
    }
  Unpack ();
  void * p = Shrink(shrinkFactor);
  bitmaps[shrinkFactor] = p;
  return (p);
}
Пример #9
0
LRESULT VirtualDimension::OnTimer(HWND /*hWnd*/, UINT /*message*/, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
	POINT pt;

	//Do not shrink and let the timer run if the mouse is over the window -> it will be hidden later, when
	//mouse is not on window anymore.
	GetCursorPos(&pt);
	if (!IsPointInWindow(pt) && GetWindowThreadProcessId(GetForegroundWindow(),NULL) != GetCurrentThreadId())
	{
		KillTimer(m_autoHideTimerId); //already auto-hidden -> do not need to
		Shrink();
	}

	return 0;
}
Пример #10
0
/*=============================================================================================*\
|	MouseDown																					|
+-----------------------------------------------------------------------------------------------+
|	Effet: Intercepter les click de sourie au dessus du boutton de la view.						|
|	Entre: 																						|
|		BPoint point: Location ou curseur.														|
\*=============================================================================================*/
void ShrinkView::MouseDown(BPoint point)
{	
	BView::MouseDown(point);
	if( point.x >= 0 && point.x < Bounds().Width() && point.y >= 0 && point.y < 16)
	{
		if(m_bShrink)
		{
			Expand();
		}	
		else
		{
			Shrink();
		}
		Draw(BRect(0,0,Bounds().Width(),15));
	}
}//End of MouseDown.
Пример #11
0
void *
TPointerArray::RemoveLastItem()
{
void	*retItem = NULL;

	if (fNumberOfItems != 0)
	{
		retItem = fItemArray[fNumberOfItems - 1];
		
		fNumberOfItems--;
		
		Shrink();
	}
	
	return retItem;
}
Пример #12
0
void *
TPointerArray::RemoveItemByIndex(NMUInt32 ndx)
{
void	*retItem = NULL;

	if (ndx < fNumberOfItems)
	{
		retItem = fItemArray[ndx];

		if (ndx+1 < fNumberOfItems)
		{
			machine_move_data(&fItemArray[ndx+1], &fItemArray[ndx], (fNumberOfItems - ndx - 1) * sizeof(void*));
		}

		fNumberOfItems--;
		Shrink();
	}

	return retItem;
}
Пример #13
0
void StringHash::Delete(unsigned int index)
{
    if (index >= size || strings[index] == NULL)
        return;

    delete strings[index];
    strings[index] = NULL;
    count--;

    if (count * 8 < size && size > 32)
        Shrink();
    else
    {
        // rehash the next strings until we find empty slot
        index = (index + 1) & mask;

        while (strings[index] != NULL)
        {
            if ((keys[index] & mask) != index)
            {
                unsigned int h = Iterate(keys[index], *strings[index]);

                if (h != (unsigned int) index)
                {
                    keys[h] = keys[index];
                    strings[h] = strings[index];
                    objects[h] = objects[index];

                    strings[index] = NULL;
                    objects[index] = NULL;
                }
            }

            index = (index + 1) & mask;
        }
    }
}
Пример #14
0
void ShrinkAdd(Projectile *p, int t) {
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	Shrink(p, t);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
Пример #15
0
int main(int argc, char* argv[]){
    if(argc != 3){
        printf("Useage: input_name output_name");
        exit(0);
    }
    
    char file_answer;
    
    printf("Select mode:\n"
           "1.bin to bmp\n"
           "2.bmp to bmp\n"
           "3.bin to bin\n");
    file_answer=getchar();
    fflush(stdin);
    
    char *Input=argv[1], *Output=argv[2];//retrive input/output name from commandline
    BmpHead *pBmpHeader = new BmpHead;
    unsigned char **pucImageData; 
    char *pcColorMap=NULL;
           
    if((file_answer == '1')||(file_answer == '3')){   //read bin file
        system("cls");
        
        //assign header information courtersy of Lena.bin
	    (*pBmpHeader).bfType=19778;
	    (*pBmpHeader).bfSize=54 + 1024+ 512*512 ; // raw data size = 512*512 = 262144 bytes, modify when necessary
	    (*pBmpHeader).bfReserved=0;
	    (*pBmpHeader).bfOffBits=1078;
	    (*pBmpHeader).biSize=40;
	    (*pBmpHeader).biWidth= 512;		//number of columns of the image
	    (*pBmpHeader).biHeight= 512;		//number of rows of the image
	    (*pBmpHeader).biPlanes=1;
	    (*pBmpHeader).biBitCount=8;
	    (*pBmpHeader).biCompression=0;
	    (*pBmpHeader).biSizeImage= 512*512;	//raw data size = 512*512 = 26144 bytes, modify when necessary, e.g., a 256x256 image: raw data size = 256*256
	    (*pBmpHeader).biXPelsPerMeter=2834;
	    (*pBmpHeader).biYpelsPerMeter=2834;
	    (*pBmpHeader).biClrUsed=0;
	    (*pBmpHeader).biClrImportant=0;
        
        //read provided colormap
        FILE *colormap=NULL;
        pcColorMap = new char [1024];
        if((colormap=fopen("colormap.bin", "rb")) == NULL){
            printf("Failed to find colormap.bin\n");
            exit(0);
        }
        fread(pcColorMap, sizeof(char), pBmpHeader->bfOffBits-64, colormap);
        fclose(colormap);
        
        //read raw data fron input
        pucImageData = ReadImage( Input, pBmpHeader->biWidth, 0);
        
        printf("successfully read raw data from %s.\n\n", Input);
    }
     
    else if(file_answer == '2'){  //read bmp file
        system("cls");
        
        //read input header infomation
        pBmpHeader=ReadBmpHeader(Input);
        printf("raw data size: %d\n", pBmpHeader->biSizeImage);
        printf("Image Width: %d\n", pBmpHeader->biWidth);
        printf("Image Height %d\n", pBmpHeader->biHeight);
	    printf("Header occupies 54 bytes\n");
        printf("Color map occupies 1024 bytes\n");	
        
        //read input colormap
        pcColorMap=ReadColorMap(Input, 1024);
        
        //read raw data from input
                                                    //set offset=1024+54
        pucImageData=ReadImage(Input, pBmpHeader->biWidth, 1078);
        printf("successfully read raw data from %s.\n\n", Input);
    }
    
    srand(time(NULL));//plant random seed
    
    //function menu
    char fx_answer;
    int width, cutoff;
    do{
        printf(
           "Select function:\n"
           "A.Turn Lena upside down\n"
           "B.Turn Lena around\n"
           "C.Rotate Lena by 45 deg clockwise\n"
           "D.Shrink Lena by half\n"
           "E.Invert Lena\n"
           "F.Add normal noise to Lena\n"
           "G.Add impluse noise to Lena\n"
           "H.Moving average filtering\n"
           "I.Midian filtering\n"
           "J.Differential flitering\n"
           "K.LPF\n"
           "L.HPF\n"
           "\n0.Exit\n");
        printf("Your choice: [_]\b\b");
        fx_answer = getchar();
        fx_answer = tolower(fx_answer);
        fflush(stdin);
        
        switch(fx_answer){//savefile(): ask user to save as picture or not
            case 'a':// selected: turn lena upside down
                UpsideDown(pucImageData, pBmpHeader->biWidth);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
            
            case 'b'://selected: turn lena around
                LeftRight(pucImageData, pBmpHeader->biWidth);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'c'://selected: rotate lena
                ImgRotate(pucImageData, pBmpHeader->biWidth, 45);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
            
            case 'd'://selected: shrink lena
                Shrink(pucImageData, pBmpHeader->biWidth, pBmpHeader, 2);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'e'://selected: invert lena
                Invert(pucImageData, pBmpHeader->biWidth);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'f'://selected: add noise
                NormalNoise(pucImageData, pBmpHeader->biWidth);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'g'://selected: add paper n salt noise
                ImpluseNoise(pucImageData, pBmpHeader->biWidth);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'h'://selected: moving average filter
                //ask user to input sampling width
                printf("Enter sampling width:");
                scanf("%d", &width);
                fflush(stdin);
                MAF(pucImageData, pBmpHeader->biWidth, width);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'i'://selected: moving midian filter
                //ask user to input sampling width
                printf("Enter sampling width:");
                scanf("%d", &width);
                fflush(stdin);
                MF(pucImageData, pBmpHeader->biWidth, width);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'j'://selected: differential filter
                DIF(pucImageData, pBmpHeader->biWidth);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'k'://selected: low-pass filter
                //ask user to input cutoff frequency
                printf("Enter cutoff frenquency(0~%d):", (int)pBmpHeader->biWidth/2);
                scanf("%d", &cutoff);
                fflush(stdin);
                LPF(pucImageData, pBmpHeader->biWidth, cutoff);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case 'l'://selected: high-pass filter
                //ask user to input cutoff frequency
                printf("Enter cutoff frenquency(0~%d):", (int)pBmpHeader->biWidth/2);
                scanf("%d", &cutoff);
                fflush(stdin);
                HPF(pucImageData, pBmpHeader->biWidth, cutoff);
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            case '0'://selected: exit
                //ask one last time whether user want to save or not
                savefile(Output, pucImageData, file_answer, pBmpHeader, pcColorMap);
                break;
                 
            default:
                system("cls");
                printf("Your choice is not in the list!\n");
                break;
            
        }
        
        if(fx_answer == 0)
            break;//selected: exit. break the loop
        
        
    } while(fx_answer != '0');
    
    //returning dynamic allocated memory
    delete [] pcColorMap;
    delete [] pucImageData;
    delete pBmpHeader;
    pcColorMap=NULL;
    pucImageData=NULL;
    pBmpHeader=NULL;
    
    printf("EOP\n");
}
Пример #16
0
void mediancut( WORD * data, int num_pixels, int num_colors, void * dest_bitmap, char * palette )
{
  unsigned char r,g,b;
  int i, axis, SelectedBox, TargetBox;
	int TargetColors;
  int NumBoxes;

  TotalPixels = num_pixels;
  TargetColors = num_colors;

  //for ( i=0; i< 32768; i++ )
  //		Frequency[i] = 0;
  //MedianClearFrequencies(Frequency);

  BoxRedLo[0] = 0;
  BoxRedHi[0] = MAXVAL;
  BoxBlueLo[0] = 0;
  BoxBlueHi[0] = MAXVAL;
  BoxGreenLo[0] = 0;
  BoxGreenHi[0] = MAXVAL;

/*  for ( i=0; i< TotalPixels; i++ )	{
		if ((Frequency[ data[i] ]++)==0)	{
			r = (data[i]>>10)&31;
			g = (data[i]>>5)&31;
			b = (data[i]>>0)&31;
			if ( r < BoxRedLo[0] )
				BoxRedLo[0] = r;
			else if( r > BoxRedHi[0] )
				BoxRedHi[0] = r;
	
			if ( g < BoxGreenLo[0] )
				BoxGreenLo[0] = g;
			else if( g > BoxGreenHi[0] )
				BoxGreenHi[0] = g;
	
			if ( b < BoxBlueLo[0] )
				BoxBlueLo[0] = b;
			else if( b > BoxBlueHi[0] )
				BoxBlueHi[0] = b;
		}
	}
*/

  BoxNumElements[0] = TotalPixels;
  NumBoxes = 1;
	
  //for ( i=0; i< TotalPixels; i++ )	
  //	Frequency[ data[i] ]++;
  //MedianReadFrequencies( data,TotalPixels );
  Shrink(0);

  while(NumBoxes < TargetColors )    {
							 
		SelectedBox = FindNextBoxToSplit(NumBoxes);
		if (SelectedBox == -1 ) break;
		
		TargetBox	= FindTargetBox( NumBoxes );
		axis			= FindAxisToSplit( SelectedBox );

		switch(axis)	{
		case 0:	SplitBoxRed( SelectedBox, TargetBox );
					break;
		case 1:	SplitBoxBlue( SelectedBox, TargetBox );
					break;
		case 2:	SplitBoxGreen( SelectedBox, TargetBox );
					break;
		}

		Shrink(SelectedBox);
		Shrink(TargetBox);
	
		if (TargetBox == NumBoxes )  NumBoxes++;

  }

  //for ( i=0; i< TotalPixels; i++ )
  //		VideoMemory[i] = Frequency[ bmp->Bits[i] ];

 	MedianSetPalette( NumBoxes, palette );
//	MedianPutImage( data, dest_bitmap, TotalPixels );
}
Пример #17
0
void FontFactory::ReleaseCache()
{
	SAFE_RELEASE_COLLECTION(mCacheItems);
	Shrink();
}