コード例 #1
0
ファイル: bootldr.c プロジェクト: wheelerz/ento
/* check the checksum */
void 
checksum(void)
{
	g2x();
	if(cksum!=0)	// if checksum does not add to zero, bad check, reset
		RESET();
#if VERBOSE == 2
	putch('\r');	// echo each hex record on a new line
	putch('\n');	// echo each hex record on a new line
#endif
}
コード例 #2
0
ファイル: Grid.cpp プロジェクト: blake0701/terrainBlockMesher
vector<IO::OFILE::Data> Grid::getOData(const string & type) const {

	vector<IO::OFILE::Data> out;

	////////////////////////////////////////////////////////////
	//
	// 		Text file output:
	//
	if (type.compare(IO::OFILE::TYPE::TXT) == 0) {

		// add a piece of data: points
		IO::OFILE::Data dat;

		// set pre and post fields:
		dat.type = type;
		dat.origin = gridName;

		// Output Cartesian points:
		if (flag_output_cart) {

			dat.name = "grid_points_cartesian";
			dat.pre_data = "// " + gridName + ": " + String(gSize)
					+ " points in Cartesian space (" + String(getN()) + ")\n";

			for (unsigned int g = 0; g < gridSize(); ++g) {

				// pick a coordinate:
				const MultiIndexed::IndexSet coord = g2x(g);

				// get Cartesian coordinate:
				COORD_GRID x = getPoint(coord);

				// write:
				dat.data += String(x) + "   ";

			}

		}

		// grid point output:
		else {

			dat.name = "grid_points";
			dat.pre_data = "// " + gridName + ": " + String(indexSize())
					+ " points in grid space (" + String(getN()) + ")\n";

			for (unsigned int i = 0; i < indexSize(); i++) {

				// pick a coordinate:
				MultiIndexed::IndexSet coord = i2x(i);

				// get Cartesian coordinate:
				COORD_GRID x = getGridPoint(coord);

				// write:
				dat.data += String(x) + "   ";

			}

		}

		// write points:
		dat.data += "\n";
		out.push_back(dat);

	}

	////////////////////////////////////////////////////////////
	//
	// 		VTK ascii file output:
	//
	else if (type.compare(IO::OFILE::TYPE::VTK_ASCII) == 0) {

		// add a piece of data: points
		IO::OFILE::Data dat;

		// set pre and post fields:
		dat.type = type;
		dat.origin = gridName;

		// Output Cartesian points:
		if (flag_output_cart) {

			// meta data for grid points:
			vector<int> dims = getN();
			dims.resize(3, 1);
			dat.name = "grid_points_cartesian";
			dat.pre_data = String("DATASET UNSTRUCTURED_GRID\n")
				//	+ "DIMENSIONS " + IO::vi2s(dims) + "\n"
					+ "POINTS " + String(gridSize()) + " \n";

			for (unsigned int g = 0; g < gridSize(); g++) {

				// pick a coordinate:
				MultiIndexed::IndexSet coord = g2x(g);

				// get Cartesian coordinate:
				COORD_GRID x = getPoint(coord);

				// vtk expects 3 dimensions:
				x.resize(3, 0);

				// write:
				dat.data += String(x) + "   ";

			}

		}

		// grid point output:
		else {

			// meta data for grid points:
			vector<int> dims = getN();
			dims.resize(3, 1);
			dat.name = "grid_points";
			dat.pre_data = String("DATASET STRUCTURED_GRID\n")
					+ "DIMENSIONS " + String(dims) + "\n"
					+ "POINTS " + String(indexSize()) + " \n";

			for (unsigned int i = 0; i < indexSize(); i++) {

				// pick a coordinate:
				MultiIndexed::IndexSet coord = i2x(i);

				// get Cartesian coordinate:
				COORD_GRID x = getPoint(coord);

				// vtk expects 3 dimensions:
				x.resize(3, 0);

				// write:
				dat.data += String(x) + "   ";

			}

		}

		// write points:
		dat.data += "\n";
		out.push_back(dat);

		// add new piece of data: cells
		dat = IO::OFILE::Data();

		// set pre and post fields:
		dat.type = type;
		dat.origin = gridName;
		dat.pre_data = "CELLS " + String(cells()) + " ";
		dat.data = "";

		// Output in Cartesian space:
		if (flag_output_cart) {

			dat.name = "grid_cells_cartesian";

			// count data output:
			int dcounter = 0;

			// cell output:
			for(int i = 0; i < cells(); i++) {

				// get cell:
				MultiIndexed::IndexCell cell = getIndexCell(i);

				// grid filter:
				for(unsigned j = 0; j < cell.size(); j++)
					cell[j] = filter_i2g(cell[j]);
				reduceDup_v(cell);

				// write cell:
				dat.data += String(cell.size());
				dcounter++;
				for(unsigned j = 0; j < cell.size(); j++){
					cout<<String(cell[j])<<" -> "<<String(x2g(cell[j]))<<endl;
					dat.data += " " + String(x2g(cell[j]));
					dcounter++;
				}
				cout<<endl;
				dat.data += "\n";

			}

			dat.pre_data += String(dcounter) + "\n";

		}

		dat.data += "\n";
		out.push_back(dat);

	}

	return out;

}