Esempio n. 1
0
void display(void)
{
	int i;
	glClearColor(1.0f,1.0f,1.0f,1.0f);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
	glPointSize(1.0);

	glBegin(GL_POINTS);
	
	init_buffer();		//initialize buffer
	rotate_all();		//rotate object
	project_data();		//project object
	drawPoly_zbuffer();	//draws cube
	performUpdate();	//moves balls and handles collisions

	//draws the balls
	for(i=0;i<no_balls;i++)
	{
		find_intersect(Balls[i].pos[0],Balls[i].pos[1],Balls[i].pos[2],Balls[i].r);
		fill_color(Balls[i].pos[0],Balls[i].pos[1],Balls[i].pos[2],i%6);
	}
	//draws the z-buffer	
	disp_zbuf();
		
	glEnd();
	glutSwapBuffers();
}
Esempio n. 2
0
int 
lsh_data(projection_family_t* pfamily, double* data)
{
 	size_t i;
	int hash = 1;

	for (i = 0; i < pfamily->projection_nb; i++)
		hash = 33 * hash + project_data(pfamily->projections[i], data);

	return hash;
}
Esempio n. 3
0
int main (int argc, char* argv[])
{
	if (argc == 1)
	{
		std::cout << "Usage: " << argv[0] << " gml-file" << std::endl;
		std::cout << "\tgives you the name of all polylines in the file" << std::endl;
		std::cout << "Usage: " << argv[0] << " gml-file polyline-to-convert" << std::endl;
		std::cout << "\tcreates for the given polyline points boundary conditions" <<
		std::endl;
		return -1;
	}
	GeoLib::GEOObjects* geo_objs (new GeoLib::GEOObjects);
	std::string schema_name(
	        "/home/fischeth/workspace/OGS-FirstFloor/sources/FileIO/OpenGeoSysGLI.xsd");
	ProjectData* project_data (new ProjectData);
	project_data->setGEOObjects (geo_objs);
	FileIO::XmlGmlInterface xml(project_data, schema_name);
	std::string fname (argv[1]);
	xml.readFile(QString::fromStdString (fname));

	std::vector<std::string> geo_names;
	geo_objs->getGeometryNames (geo_names);
	if (geo_names.empty ())
	{
		std::cout << "no geometries found" << std::endl;
		return -1;
	}
	const GeoLib::PolylineVec* ply_vec (geo_objs->getPolylineVecObj(geo_names[0]));
	if (!ply_vec)
	{
		std::cout << "could not found polylines" << std::endl;
		delete project_data;
		return -1;
	}
	const size_t n_ply (ply_vec->size());

	std::vector<size_t> ply_pnt_ids;
	for (size_t k(0); k < n_ply; k++)
	{
		std::string ply_name;
		if (ply_vec->getNameOfElementByID(k, ply_name))
		{
			if (argc == 2)
				std::cout << "polyline " << k << ": " << ply_name << std::endl;
			else if (ply_name.find (argv[2]) != std::string::npos)
			{
				std::cout << "found polyline " << ply_name << std::endl;
				GeoLib::Polyline const* ply (ply_vec->getElementByName(ply_name));
				const size_t n_ply_pnts (ply->getNumberOfPoints());
				for (size_t j(0); j < n_ply_pnts; j++)
					ply_pnt_ids.push_back (ply->getPointID(j));
			}
		}
	}

	if (argc == 2)
		return 0;

	std::vector<GeoLib::Point*> const* geo_pnts (geo_objs->getPointVec(geo_names[0]));
	// write gli file and bc file
	std::ofstream gli_out ("TB.gli");
	std::ofstream bc_out ("TB.bc");
	bc_out << "// file generated by " << argv[0] << std::endl;
	if (gli_out && bc_out)
	{
		gli_out << "#POINTS" << std::endl;
		for (size_t k(0); k < ply_pnt_ids.size(); k++)
		{
			gli_out << k << " " << *((*geo_pnts)[ply_pnt_ids[k]]) << " $NAME PLYPNT" <<
			argv[2] << k << std::endl;
			// boundary condition
			bc_out << "#BOUNDARY_CONDITION" << std::endl;
			bc_out << "\t$PCS_TYPE" << std::endl << "\t\tGROUNDWATER_FLOW" << std::endl;
			bc_out << "\t$PRIMARY_VARIABLE" << std::endl << "\t\tHEAD" << std::endl;
			bc_out << "\t$GEO_TYPE" << std::endl << "\t\tPOINT PLYPNT" << argv[2] <<
			k << std::endl;
			bc_out << "\t$DIS_TYPE" << std::endl << "\t\tCONSTANT " <<
			(*((*geo_pnts)[ply_pnt_ids[k]]))[2] << std::endl;
		}
		gli_out << "#STOP" << std::endl;
		bc_out << "#STOP" << std::endl;
		gli_out.close ();
		bc_out.close ();
	}

	delete project_data;
}
Esempio n. 4
0
int main (int argc, char* argv[])
{
	if (argc == 1)
	{
		std::cout << "Usage: " << argv[0] << " gml-file" << std::endl;
		return -1;
	}
	GeoLib::GEOObjects* geo_objs (new GeoLib::GEOObjects);
	ProjectData* project_data (new ProjectData);
	project_data->setGEOObjects (geo_objs);
	std::string schema_name(
	        "/home/fischeth/workspace/OGS-FirstFloor/sources/FileIO/OpenGeoSysGLI.xsd");
	FileIO::XmlGmlInterface xml(project_data, schema_name);
	std::string fname (argv[1]);
	xml.readFile(QString::fromStdString (fname));

	std::vector<std::string> geo_names;
	geo_objs->getGeometryNames (geo_names);
	if (geo_names.empty ())
	{
		std::cout << "no geometries found" << std::endl;
		return -1;
	}
	const GeoLib::SurfaceVec* sfc_vec (geo_objs->getSurfaceVecObj(geo_names[0]));
	if (!sfc_vec)
	{
		std::cout << "could not found surfaces" << std::endl;
		delete project_data;
		return -1;
	}
	const size_t n_sfc (sfc_vec->size());

	std::vector<size_t> sfc_pnt_ids;
	for (size_t k(0); k < n_sfc; k++)
	{
		std::string sfc_name;
		if (sfc_vec->getNameOfElementByID(k, sfc_name))
			if (sfc_name.find ("Terrain") != std::string::npos)
			{
				std::cout << k << ": " << sfc_name << std::endl;
				GeoLib::Surface const* sfc (sfc_vec->getElementByName(sfc_name));
				const size_t n_triangles (sfc->getNTriangles());
				for (size_t j(0); j < n_triangles; j++)
				{
					GeoLib::Triangle const* tri ((*sfc)[j]);
					for (size_t i(0); i < 3; i++)
						sfc_pnt_ids.push_back ((*tri)[i]);
				}
			}
	}

	// make entries unique
	std::cout << "make points unique ... " << std::flush;
	std::sort (sfc_pnt_ids.begin(), sfc_pnt_ids.end());
	std::vector<size_t>::iterator it (sfc_pnt_ids.begin());
	while (it != sfc_pnt_ids.end())
	{
		std::vector<size_t>::iterator next (it);
		next++;
		if (next != sfc_pnt_ids.end())
		{
			if (*it == *next)
				it = sfc_pnt_ids.erase (it);
			else
				it++;
		}
		else
			it++;
	}
	std::cout << "done" << std::endl;

	std::vector<GeoLib::Point*> const* geo_pnts (geo_objs->getPointVec(geo_names[0]));
	// write gli file and bc file
	std::ofstream gli_out ("TB.gli");
	std::ofstream bc_out ("TB.bc");
	bc_out << "// file generated by " << argv[0] << "\n";
	if (gli_out && bc_out)
	{
		gli_out << "#POINTS" << "\n";
		for (size_t k(0); k < sfc_pnt_ids.size(); k++)
		{
			gli_out << k << " " << *((*geo_pnts)[sfc_pnt_ids[k]]) << " $NAME " << k <<
			"\n";
			// boundary condition
			bc_out << "#BOUNDARY_CONDITION" << "\n";
			bc_out << "\t$PCS_TYPE" << "\n" << "\t\tGROUNDWATER_FLOW" << "\n";
			bc_out << "\t$PRIMARY_VARIABLE" << "\n" << "\t\tHEAD" << "\n";
			bc_out << "\t$GEO_TYPE" << "\n" << "\t\tPOINT " << k << "\n";
			bc_out << "\t$DIS_TYPE" << "\n" << "\t\tCONSTANT " <<
			(*((*geo_pnts)[sfc_pnt_ids[k]]))[2] << "\n";
		}
		gli_out << "#STOP" << "\n";
		bc_out << "#STOP" << "\n";
		gli_out.close ();
		bc_out.close ();
	}

	delete project_data;
}