예제 #1
0
void QAniTransferFunctionInstance::load(QFile & file) {
	file.read((char *)&m_resolution, 4);
	file.read((char *)&m_tfResolutionChange, 4);
	m_tfDrawArrayChange = new float[m_resolution];
	file.read((char *)m_tfDrawArrayChange, 4 * m_resolution);

	int size;
	file.read((char *)&size, 4);
	for (int i = 0; i < size; ++i) {
		double mean,sigma,height;
		file.read((char *)&mean, 8);
		file.read((char *)&sigma, 8);
		file.read((char *)&height, 8);
		GaussianObjectChange goc(mean, sigma, height);
		m_gaussianObjectChange.push_back(goc);
	}
	file.read((char *)&size, 4);
	for (int i = 0; i < size; ++i) {
		float x;
		Vector4 color;
		file.read((char *)&x, 4);
		file.read((char *)((double*)color), 32);
		ColorTickChange ctc(x, color);
		m_tfColorTickChange.push_back(ctc);
	}
}
예제 #2
0
QAniTransferFunctionInstance::QAniTransferFunctionInstance(QAniKeyframe* s, QAniKeyframe* e) : QAniInstance(QAniInstance::TransferFunction, s, e) {
	QAniTransferFunctionKeyframe * start = (QAniTransferFunctionKeyframe*)s;
	QAniTransferFunctionKeyframe * end = (QAniTransferFunctionKeyframe*)e;
	m_resolution = start->getResolution();
	m_tfResolutionChange = end->getResolution() - start->getResolution();
	if (m_tfResolutionChange == 0) {
		m_tfDrawArrayChange = new float[start->getResolution()];
		for (int i = 0; i < start->getResolution(); ++i) {
			m_tfDrawArrayChange[i] = end->getDrawArray()[i] - start->getDrawArray()[i];
		}
	}
	else m_tfDrawArrayChange = NULL;

	int idx = (start->getGaussians()->size() < end->getGaussians()->size() ?
			   start->getGaussians()->size() : end->getGaussians()->size());
	m_gaussianObjectChange.clear();
	for (int i = 0; i < idx; ++i) {
		GaussianObjectChange goc((*end->getGaussians())[i].m_mean - (*start->getGaussians())[i].m_mean,
					 (*end->getGaussians())[i].m_sigma - (*start->getGaussians())[i].m_sigma,
					 (*end->getGaussians())[i].m_heightFactor - (*start->getGaussians())[i].m_heightFactor);
		m_gaussianObjectChange.push_back(goc);
	}
	idx = (start->getColors()->size() < end->getColors()->size() ?
		   start->getColors()->size() : end->getColors()->size());
	m_tfColorTickChange.clear();
	for (int i = 0; i < idx; ++i) {
		Vector4 color((*end->getColors())[i].m_color.redF() - (*start->getColors())[i].m_color.redF(),
			      (*end->getColors())[i].m_color.greenF() - (*start->getColors())[i].m_color.greenF(),
			      (*end->getColors())[i].m_color.blueF() - (*start->getColors())[i].m_color.blueF(),
			      (*end->getColors())[i].m_color.alphaF() - (*start->getColors())[i].m_color.alphaF());
		ColorTickChange ctc((*end->getColors())[i].m_resX - (*start->getColors())[i].m_resX, color);
		m_tfColorTickChange.push_back(ctc);
	}
}
예제 #3
0
//	geometric-object-collection
GridObjectCollection MGSelector::get_grid_objects() const
{
	uint numLevels = num_levels();
	GridObjectCollection goc(numLevels);
	
	for(uint i = 0; i < numLevels; ++i)
	{
		goc.add_level(	&m_levels[i]->m_vertices,
						&m_levels[i]->m_edges,
						&m_levels[i]->m_faces,
						&m_levels[i]->m_volumes);
	}
	
	return goc;
}
GridObjectCollection
MultiGridSubsetHandler::
get_grid_objects_in_subset(int subsetIndex) const
{
	subset_required(subsetIndex);
	GridObjectCollection goc(m_levels.size());
	for(size_t i = 0; i < m_levels.size(); ++i)
	{
		goc.add_level(	&m_levels[i][subsetIndex]->m_vertices,
						&m_levels[i][subsetIndex]->m_edges,
						&m_levels[i][subsetIndex]->m_faces,
						&m_levels[i][subsetIndex]->m_volumes);
	}
	
	return goc;
}
GridObjectCollection
MultiGridSubsetHandler::
get_grid_objects_in_level(int level) const
{
	level_required(level);
	uint numSubsets = num_subsets_in_list();
	GridObjectCollection goc(numSubsets);
	for(uint i = 0; i < numSubsets; ++i)
	{
		goc.add_level(	&m_levels[level][i]->m_vertices,
						&m_levels[level][i]->m_edges,
						&m_levels[level][i]->m_faces,
						&m_levels[level][i]->m_volumes);
	}
	
	return goc;
}
예제 #6
0
int main()
{
	init_MCU();
	sel_mode();
	
	while (1)
	{
		switch (pattern)
		{
			case 1:
			if ( check_crossline() ) //Be 90
			{
				pattern = 21;
				break;
			}
			if ( check_rightline() ) // Chuyen lan phai
			{
				pattern = 51;
				break;
			}
			if ( check_leftline() ) // Chuyen lan trai
			{
				pattern = 61;
				break;
			}
			led7(10);
			set_encoder(19);
			switch (doc_cam_bien(0b01111110))
			{
				case 0b01111110:
				toc_do(0, 0);
				goc(0);
				break;
				case 0b00011000:	// Chay thang
				goc( 0 );
				toc_do( 100 , 100 );
				break;

				//lech phai
				case 0b00011100:
				case 0b00001000:
				toc_do(90, 80);
				goc(8);
				break;
				case 0b00001100:
				toc_do(90, 70);
				goc(10);
				break;
				case 0b00001110:
				case 0b00000100:
				toc_do(90, 60);
				goc(12);
				break;
				case 0b00000110:
				toc_do(90, 50);
				goc(15);
				break;
				case 0b00000010:
				toc_do(90, 30);
				goc(20);
				pattern = 11;	//Lệch phải góc lớn
				break;

				//////////////////////////////////////////

				//lech trai
				case 0b00111000:
				case 0b00010000:
				toc_do(80, 90);
				goc(-8);
				break;
				case 0b00110000:
				toc_do(70, 90);
				goc(-10);
				break;
				case 0b01110000:
				case 0b00100000:
				toc_do(60, 90);
				goc(-12);
				break;
				case 0b01100000:
				toc_do(50, 90);
				goc(-15);
				break;
				case 0b01000000:
				toc_do(30, 90);
				goc(-20);
				pattern = 12; //Lệch trái góc lớn
				break;
				default:
				break;
			}
			break;

			case 11: 	//Lệch phải góc lớn
			led7(11);
			set_encoder(23);
			switch (doc_cam_bien(0b11001100))
			{
				case 0b11000000:
				toc_do(95, 15);
				goc(75);
				break;
				case 0b10000000:
				toc_do(95, 20);
				goc(51);
				break;
				case 0b00000000:
				toc_do(95, 25);
				goc(48);
				break;
				case 0b00000100:
				toc_do(95, 25);
				goc(37);
				break;
				case 0b00001100:
				toc_do(95, 25);
				goc(29);
				pattern = 1;
				break;
				default: pattern = 11;
			}
			break;
			case 12: //Lệch trái góc lớn
			led7(12);
			set_encoder(23);
			switch (doc_cam_bien(0b00110011))
			{
				case 0b00000011:
				toc_do(15, 95);
				goc(-73);
				break;
				case 0b00000001:
				toc_do(20, 95);
				goc(-50);
				break;
				case 0b00000000:
				toc_do(25, 95);
				goc(-47);
				break;
				case 0b00100000:
				toc_do(25, 95);
				goc(-36);
				break;
				case 0b00110000:
				toc_do(25, 95);
				goc(-28);
				pattern = 1;
				break;
				default: pattern = 12;
			}
			break;

			case 21:		//Xử lý khi gặp vạch tín hiệu cua vuông đầu tiên
			led7(18);
			set_encoder(20);
			goc( 0 );
			toc_do( 60 , 60);
			pattern = 22;
			cnt_1ms = 0;
			xung = 0;
			break;

			case 22:		// Delay hết vạch
			led7(22);
			set_encoder(20);
			goc( 0 );
			toc_do( 60 , 60);
			if ( cnt_1ms > 150 || xung > 10 )
			{
				pattern = 23;
				cnt_1ms = 0;
				xung = 0;
			}
			break;

			case 23:
			led7(23);
			//cua trái
			if ( (xung > 100) && ((doc_cam_bien(0b11111111) == 0b11111000)  || (doc_cam_bien(0b11111111) == 0b11110000) || (doc_cam_bien(0b11111111) == 0b11100000) || (doc_cam_bien(0b11111111) == 0b11111100)))	// Neu gap tin hieu nay la goc cua 90 trai thi be
			{
				pattern = 24;
				xung = 0;
				cnt_1ms = 0;
				break;
			}
			//cua phải
			if (  (xung > 100) &&   ((doc_cam_bien(0b11111111) == 0b00011111 ) || (doc_cam_bien(0b11111111) == 0b00000111) || (doc_cam_bien(0b11111111) == 0b00001111) || (doc_cam_bien(0b11111111) == 0b00111111))) // Neu gap tin hieu nay la goc cua 90 phai thi be
			{
				pattern = 25;
				xung = 0;
				cnt_1ms = 0;
				break;
			}
			if ( (xung > 30) && (xung < 100) && check_crossline() == 1)
			{
				pattern = 71;
				xung = 0;
				cnt_1ms = 0;
				break;
			}
			// Nguoc lai thi chinh thang cho xe
			switch (doc_cam_bien(0b01111110))
			{
				case 0b00011000:
				goc( 0 );
				toc_do(30, 30 );
				break;
				//lech phai
				case 0b00001000:
				toc_do(23, 3);
				goc(8);
				break;
				case 0b00001100:
				toc_do(23, -3);
				goc(10);
				break;
				case 0b00000100:
				toc_do(23, -8);
				goc(13);
				break;
				case 0b00000110:
				case 0b00000010:
				toc_do(23, -13);
				goc(18);
				break;
				////////////////////////////////
				case 0b00010000:
				toc_do(5, 20);
				goc(-8);
				break;
				case 0b00110000:
				toc_do(0, 20);
				goc(-10);
				break;
				case 0b00100000:
				toc_do(-5, 20);
				goc(-13);
				break;
				case 0b01100000:
				case 0b01000000:
				toc_do(10, 20);
				goc(-18);
				break;
				default:
				break;
			}
			break;

			case 24://delay het vach line TRAI
			set_encoder(10);
			toc_do(50, 50);
			if ( (xung > 100) && ((doc_cam_bien(0b00000111) == 0b00000111) || (doc_cam_bien(0b00001111) == 0b00001111)))
			{
				pattern = 23 ;
				break;
			}
			if (cnt_1ms > 100 || xung > 1)
			{
				pattern = 26;
				break;
			}
			break;

			case 25:	//delay het vach line PHAI
			set_encoder(10);
			toc_do(50, 50);
			if ( (xung > 100 ) && ((doc_cam_bien(0b11100000) == 0b11100000) || (doc_cam_bien(0b11110000) == 0b11110000)))
			{
				pattern = 23 ;
				break;
			}
			if (cnt_1ms > 100 || xung > 1)
			{
				pattern = 27;
				break;
			}
			break;

			case 26: //vuông trái
			led7(24);
			goc( - 140 );
			set_encoder(8);
			toc_do( -20 , 90 );
			led7(1);
			pattern = 31;
			cnt_1ms = 0;
			break;

			case 27://vuông phải
			led7(25);
			goc( 140 );
			set_encoder(8);
			toc_do( 90 , -20 );
			led7(2);
			pattern = 41;
			cnt_1ms = 0;
			break;


			case 31:	//delay cho xe kịp bẻ vuông trái
			led7(31);
			if ( cnt_1ms > 50 )
			{
				pattern = 32;
				cnt_1ms = 0;
			}
			break;

			case 32:	//chờ tín hiệu để về trường hợp chạy thẳng
			led7(32);
			if ( doc_cam_bien(0b11100111) == 0b00100000 )
			{
				pattern = 1;
				cnt_1ms = 0;
			}
			break;

			case 41: //delay cho xe kịp bẻ vuông phải
			led7(41);
			if ( cnt_1ms > 50 )
			{
				pattern = 42;
				cnt_1ms = 0;
			}
			break;

			case 42: //chờ tín hiệu để về trường hợp chạy thẳng
			led7(42);
			if ( doc_cam_bien(0b11100111) == 0b00000100 )
			{
				pattern = 1;
				cnt_1ms = 0;
			}
			break;

			case 51: //xử lý khi gặp vạch tín hiệu chuyển làn PHẢI
			set_encoder(20);
			if ((doc_cam_bien(0b11100000) == 0b11100000) || (doc_cam_bien(0b11110000) == 0b11110000))
			{
				pattern = 21 ;
				break;
			}
			led7(51);
			goc( 0 );
			toc_do( 70 , 70 );
			pattern = 52;
			cnt_1ms = 0;
			xung = 0;
			break;

			case 52: //delay hết vạch
			if ( cnt_1ms > 100 || xung > 10)
			{
				pattern = 53;
				cnt_1ms = 0;
			}
			if ((doc_cam_bien(0b11100000) == 0b11100000) || (doc_cam_bien(0b11110000) == 0b11110000))
			{
				pattern = 21 ;
				break;
			}
			break;

			case 53: //hết vạch trắng
			if ( doc_cam_bien(0b11111111) == 0b00000000 )
			{
				goc( 75 );
				toc_do( 60 , 50 );
				pattern = 54;
				cnt_1ms = 0;
				break;
			}
			switch ( doc_cam_bien(0b11100111) )
			{
				case 0x00:
				goc( 0 );
				toc_do( 30 , 30 );
				break;
				case 0x04:
				case 0x06:
				case 0x07:
				case 0x03:
				goc( 15 );
				toc_do( 30 , 20 );
				break;
				case 0x20:
				case 0x60:
				case 0xe0:
				case 0xc0:
				goc( -15 );
				toc_do( 20 , 30 );
				break;
				default:
				break;
			}
			break;

			case 54: //bắt được line, chuyển về chạy thẳng
			if ( doc_cam_bien( 0b00001100 ) == 0b00001100 )
			{
				pattern = 1;
				cnt_1ms = 0;
				led7(0);
			}
			break;

			case 61:	//xử lý khi gặp vạch tín hiệu chuyển làn TRÁI
			set_encoder(20);
			if ( (doc_cam_bien(0b00000111) == 0b00000111) || (doc_cam_bien(0b00001111) == 0b00001111) )
			{
				pattern = 21 ;
				break;
			}
			led7(61);
			goc( 0 );
			toc_do( 90 , 90 );
			pattern = 62;
			cnt_1ms = 0;
			xung = 0;
			break;

			case 62: //delay hết vạch
			if ( cnt_1ms > 100 || xung > 10)
			{
				pattern = 63;
				cnt_1ms = 0;
			}
			if ((doc_cam_bien(0b00000111) == 0b00000111) || (doc_cam_bien(0b00001111) == 0b00001111))
			{
				pattern = 21 ;
				break;
			}
			break;

			case 63: //hết vạch trắng
			if ( doc_cam_bien(0b11111111) == 0x00 )
			{
				goc( -75 );
				toc_do( 50 , 60 );
				pattern = 64;
				cnt_1ms = 0;
				break;
			}
			switch ( doc_cam_bien(0b11100111) )
			{
				case 0x00:
				goc( 0 );
				toc_do( 30 , 30 );
				break;
				case 0x04:
				case 0x06:
				case 0x07:
				case 0x03:
				goc( 15 );
				toc_do( 30 , 20 );
				break;
				case 0x20:
				case 0x60:
				case 0xe0:
				case 0xc0:
				goc( -15 );
				toc_do( 20 , 30 );
				break;
				default:
				break;
			}
			break;

			case 64: //bắt được line, chuyển về chạy thẳng
			if ( doc_cam_bien( 0b00110000 ) == 0b00110000 )
			{
				pattern = 1;
				cnt_1ms = 0;
				led7(0);
			}
			break;

			case 71: // Delay het vach
			set_encoder(30);
			toc_do(100, 100);
			led7(71);
			if ( cnt_1ms > 100 || xung > 10)
			{
				pattern = 72;
				cnt_1ms = 0;
			}
			break;

			case 72:
			if (doc_cam_bien(0xff) == 0b00000000)
			{
				goc(0);
				toc_do(100, 100);
				pattern = 73;
				break;
			}

			switch (doc_cam_bien(0b01111110))
			{
				case 0b00011000:
				goc( 0 );
				toc_do(100, 100 );
				break;
				//lech phai
				case 0b00001000:
				toc_do(90, 17);
				goc(8);
				break;
				case 0b00001100:
				toc_do(90, 70);
				goc(13);
				break;
				case 0b00000100:
				toc_do(90, 65);
				goc(18);
				break;
				case 0b00000110:
				case 0b00000010:
				toc_do(90, 60);
				goc(26);
				break;
				//////////////////////////////////////////////////////////////////////////
				case 0b00010000:
				toc_do(75, 90);
				goc(-8);
				break;
				case 0b00110000:
				toc_do(70, 90);
				goc(-13);
				break;
				case 0b00100000:
				toc_do(65, 90);
				goc(-18);
				break;
				case 0b01100000:
				case 0b01000000:
				toc_do(60, 90);
				goc(-26);
				break;
				default:
				break;
			}
			break;
			case 73:
			goc(0);
			toc_do(100, 100);
			if (doc_cam_bien(0b11111111) > 0)
			{
				pattern = 1;
			}
			break;

			default:
			pattern = 1;
			break;
		}
	}

}