int main()
{
    try
    {
        // name of generated file
        std::string filename("bigfile_bio_test.las");
        // test writing mor than 204 million points
        bio::stream_offset const n_million_points = 210;
        bio::stream_offset const point_count = 1024 * 1024 * n_million_points;

        std::cout.setf(std::ios::fixed, std::ios::floatfield);
        std::cout.setf(std::ios::showpoint);
        std::cout.precision(2);

        std::cout << "LAS file: " << filename << std::endl;
        std::cout << "Writing " << point_count << " points" << std::endl;
        {
            typedef bio::stream<bio::file_descriptor_sink> bio_ostream;
            bio_ostream bigofs(filename);
            las::Header header;
            las::Writer writer(bigofs, header);

            las::Point empty_point(&las::DefaultHeader::get());
            bio::stream_offset i = 0;
            for (i = 0; i < point_count; ++i)
            {
                if (!writer.WritePoint(empty_point))
                {
                    std::ostringstream oss;
                    oss << "failed to write point #" << i;
                    throw std::runtime_error(oss.str());
                }

                if (i % 1000 == 0)
                {
                    std::cout << "\b\b\b\b\b\b\b\b" << double(i)/point_count * 100.0;
                }
            }
            assert(i == point_count);
        }

        std::cout << std::endl << "Reading " << point_count << " points" << std::endl;
        {
            typedef bio::stream<bio::file_descriptor_source> bio_istream;
            bio_istream bigifs(filename); 
            las::Reader reader(bigifs);
    
            bio::stream_offset i = 0;
            while (reader.ReadNextPoint())
            {
                las::Point const& p = reader.GetPoint();

                if (!p.Validate())
                {
                    std::ostringstream oss;
                    oss << "invalid point around #" << i;
                    throw std::runtime_error(oss.str());
                }

                if (i % 1000 == 0)
                {
                    std::cout << "\b\b\b\b\b\b\b\b" << double(i)/point_count * 100.0;
                }
                ++i;
            }
            assert(i == point_count);
        }

        std::cout << std::endl << "Done." << std::endl;

        return EXIT_SUCCESS;
    }
    catch (std::exception const& e)
    {
        std::cerr << e.what() << std::endl;
    }
 
    return EXIT_FAILURE;
}
Exemplo n.º 2
0
v3dmc_point create_point3p(GLfloat x, GLfloat y, GLfloat z){
	v3dmc_point point = empty_point();
	set_point_coords(&point,x,y,z);
	return point;
}