⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rect.cpp

📁 LinPacker是一个优化矩形布局的工具
💻 CPP
字号:
/*************************************************************************** *   Copyright (C) 2003 by ita                                             * *   tnagy@eleve.emn.fr                                                    * *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * ***************************************************************************/#include "rect.h"Rectangle::Rectangle(int lo, int la, int xpos, int ypos,bool orient,int num,int pos){	longueur = lo;	largeur = la;	posx = xpos;	posy = ypos;	orientation = orient;	position = pos;	numero = num;};Rectangle::Rectangle(){	longueur = 0;	largeur = 0;	posx = 0;	posy = 0;	orientation = 0;	position = 0;	numero = 0;};Rectangle::~Rectangle(){};	intRectangle::getLongueur(){	if (orientation)		return longueur;		return largeur;};	intRectangle::getLargeur(){	if (orientation)		return largeur;		return longueur;};	intRectangle::getYHaut(){	return (posy + getLongueur());	};	intRectangle::getXMax(){	return (posx + getLargeur());};///////////// Divers	intRectangle::recouvre(Rectangle * rect){	if (! rect)	{		//cout << "comparaison avec un rectangle nul !!"<<endl;		return 0;	}	float x1,x2,y1,y2;	float l1,l2,L1,L2; 	float valx,valy;	l1 = getLargeur()/2.0;	l2 = rect->getLargeur()/2.0;	L1 = getLongueur()/2.0;	L2 = rect->getLongueur()/2.0;	x1 = posx  		+	l1;	x2 = rect->posx	+	l2;	y1 = posy		+	L1;	y2 = rect->posy 	+	L2;	if (x1 < x2)	{		valx = x2 - x1;	}	else 	{		valx = x1 - x2;	}	if (y1 < y2)	{		valy = y2 - y1;	}	else	{		valy = y1 - y2;	}	//cout <<valx<<" "<<valy<<" - ";	//cout <<x1<<" "<<x2<<" - ";	//cout <<y1<<" "<<y2<<" - ";	//cout <<l1<<" "<<l2<<" - ";	//cout <<L1<<" "<<L2<<" - "<<endl;/*if (valx >(l1 + l2))	return 0;if (valy > (L1 + L2) )	return 0;return 1;*/		if ( (valx < (l1 + l2) ) and (valy < (L1 + L2) ) )	{		//cout << "superposition de rectangles" <<endl;		return 1; 	}	return 0;};	intRectangle::getSurface(){	return (getLargeur() * getLongueur());};////////// lieulieu::lieu(){	posx=0;	posy=0;}lieu::lieu(int i, int j){	posx=i;	posy=j;}///////// hachagehash::hash(){	idx=0;	val=0;}hash::hash(int i,int j){	idx=i;	val=j;}bool operator< (Rectangle x, Rectangle y){	// attention, relation d'ordre oppos閑 (=>tri inverse)	return (x.getSurface() > y.getSurface());}bool operator< (hash x, hash y){	return (x.val < y.val);}/*   bool operator> (Rectangle x, Rectangle y)   {   return (x.getSurface() < y.getSurface());   }   bool operator== (Rectangle x, Rectangle y)   {   return (x.getSurface() == y.getSurface());   }   */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -