Exemple #1
0
// Ebu
void SubExportDialog::on_filePushButton_clicked() {

    // Create or open file to write datas
    mStlFileName = QFileDialog::getOpenFileName(this,
                                                tr("Open stl file"),
                                                QDir::homePath(),
                                                tr("EBU-N19 (*.stl)"));

    if ( !mStlFileName.isEmpty() ) {

        FileReader file_reader(mStlFileName,"");

        if ( file_reader.readRawData(mStlFileName) == false ) {
            QString error_msg = file_reader.errorMsg();
            QMessageBox::warning(this, "Open EBU-N19 file", error_msg);
            return;
        }

        EbuParser* parser = new EbuParser;

        parser->readGsiBlock(file_reader, this);
    }

    ui->fileLineEdit->setText(mStlFileName);
}
Exemple #2
0
int main()
{
	task_pool task_exector;
	background_file_reader<char> file_reader(L"test.txt");
	long task_id = task_exector.new_task();
	task_exector.submit_task(task_id, file_reader);
	task_exector.wait_for_task(task_id);
	std::cout << file_reader.get_buffer();
	task_exector.release_task(task_id);
}
bool	HttpFileStream::postFile(FilePoster& file_poster)
{
	ProxySocket* proxy_socket	=	file_poster._proxy_socket;
	HTTPERROR&	http_error		=	file_poster._http_error;
	IProgressDelegate* delegate	=	file_poster._delegate;
	if (proxy_socket)
	{
		bool	complete	=	false;
		Util::FileReader	file_reader(_filepath);
		if (file_reader.open())
		{
			int file_size = getFileSize();	//不支持大文件
			if (file_size > 0)
			{
				int unsend_data = file_size;
				char buff[kmax_file_buffer_size];
				while(unsend_data > 0)
				{
					int read_count = file_reader.read(buff,kmax_file_buffer_size);
					if (read_count > 0)
					{
						bool send = proxy_socket->writeAll(buff,read_count);
						if (!send)
						{
							http_error	=	HTTPERROR_TRANSPORT;
							break;
						}
						else
						{
							unsend_data -= read_count;
							if (delegate)
							{
								delegate->dataWriteProgress(file_size - unsend_data,file_size);
							}
						}
					}
					else
					{
						http_error	=	HTTPERROR_IO;
						break;
					}
				}
				complete = unsend_data == 0;
			}
		}
		return complete;
	}
	else
	{
		assert(false);
		return false;
	}
}
// load the data serialised during the extraction run
void NodeBasedGraphFactory::LoadDataFromFile(const boost::filesystem::path &input_file)
{
    // the extraction_containers serialise all data necessary to create the node-based graph into a
    // single file, the *.osrm file. It contains nodes, basic information about which of these nodes
    // are traffic signals/stop signs. It also contains Edges and purely annotative meta-data
    storage::io::FileReader file_reader(input_file, storage::io::FileReader::VerifyFingerprint);

    auto barriers_iter = inserter(barriers, end(barriers));
    auto traffic_signals_iter = inserter(traffic_signals, end(traffic_signals));

    const auto number_of_node_based_nodes = util::loadNodesFromFile(
        file_reader, barriers_iter, traffic_signals_iter, coordinates, osm_node_ids);

    std::vector<NodeBasedEdge> edge_list;
    util::loadEdgesFromFile(file_reader, edge_list);

    if (edge_list.empty())
    {
        throw util::exception("Node-based-graph (" + input_file.string() + ") contains no edges." +
                              SOURCE_REF);
    }

    util::loadAnnotationData(file_reader, annotation_data);

    // at this point, the data isn't compressed, but since we update the graph in-place, we assign
    // it here.
    compressed_output_graph =
        util::NodeBasedDynamicGraphFromEdges(number_of_node_based_nodes, edge_list);

    // check whether the graph is sane
    BOOST_ASSERT([this]() {
        for (const auto nbg_node_u : util::irange(0u, compressed_output_graph.GetNumberOfNodes()))
        {
            for (EdgeID nbg_edge_id : compressed_output_graph.GetAdjacentEdgeRange(nbg_node_u))
            {
                // we cannot have invalid edge-ids in the graph
                if (nbg_edge_id == SPECIAL_EDGEID)
                    return false;

                const auto nbg_node_v = compressed_output_graph.GetTarget(nbg_edge_id);

                auto reverse = compressed_output_graph.FindEdge(nbg_node_v, nbg_node_u);

                // found an edge that is reversed in both directions, should be two distinct edges
                if (compressed_output_graph.GetEdgeData(nbg_edge_id).reversed &&
                    compressed_output_graph.GetEdgeData(reverse).reversed)
                    return false;
            }
        }
        return true;
    }());
}
Exemple #5
0
int main(int argc, char* argv[])
{
	if (argc > 1)
	{
		for (int i = 1; i < argc; ++i)
		{
			file_reader fr = file_reader(std::string(argv[i]));
			fr.read_file();
			fr.display();
		}
	}
	else
	{
		std::cout << "there was nothing to do" << std::endl;
	}
	return 0;
}
Exemple #6
0
std::size_t loadGraph(const std::string &path,
                      std::vector<extractor::QueryNode> &coordinate_list,
                      std::vector<TarjanEdge> &graph_edge_list)
{
    storage::io::FileReader file_reader(path, storage::io::FileReader::VerifyFingerprint);

    // load graph data
    std::vector<extractor::NodeBasedEdge> edge_list;

    auto nop = boost::make_function_output_iterator([](auto) {});

    auto number_of_nodes = util::loadNodesFromFile(file_reader, nop, nop, coordinate_list);

    util::loadEdgesFromFile(file_reader, edge_list);

    // Building an node-based graph
    for (const auto &input_edge : edge_list)
    {
        if (input_edge.source == input_edge.target)
        {
            continue;
        }

        if (input_edge.forward)
        {
            graph_edge_list.emplace_back(input_edge.source,
                                         input_edge.target,
                                         (std::max)(input_edge.weight, 1),
                                         input_edge.name_id);
        }
        if (input_edge.backward)
        {
            graph_edge_list.emplace_back(input_edge.target,
                                         input_edge.source,
                                         (std::max)(input_edge.weight, 1),
                                         input_edge.name_id);
        }
    }

    return number_of_nodes;
}
Exemple #7
0
/*!
* Outputs the content of a text file into the referenced string.
*
* @param uri Path to the file.
* @param output Reference for the output string.
*
* @return Returns if the file was read successfully.
*/
bool readTextFile( std::string url, std::string& output )
{
	std::ifstream file_reader( url );

	if ( file_reader.is_open( ) )
	{
		std::string line;
		while ( file_reader.good( ) )
		{
			std::getline( file_reader, line );
			output.append( line + '\n' );
		}

		file_reader.close( );

		return true;
	}
	else
	{
		std::cout << "Unable to open file: " + url + "\n";

		return false;
	}
}
/*****************************
 *
 * if you want to read from the TUM associate.txt file;
 */
void visualOdometry::readFromFile(string file_name, std::vector<GROUND_TRUTH>& ground_truth_list){
    //read associate files
    std::string dir_prefix;
    boost::filesystem::path dir_full = file_name.c_str();
    boost::filesystem::path dir_prefix_boost = dir_full.parent_path();
    dir_prefix = std::string(dir_prefix_boost.c_str());

    std::ifstream file_reader(file_name.c_str());
    if (file_reader.is_open()){
        std::string line_string;
        while(std::getline(file_reader,line_string)){
            GROUND_TRUTH ground_truth;
            std::vector<std::string> line_string_split;
            boost::algorithm::split(line_string_split,line_string,boost::is_any_of(" "));
            ground_truth.time_stamp = boost::lexical_cast<double>(line_string_split[0]);
            ground_truth.file_name_depth = dir_prefix + std::string("/")+line_string_split[9];
            ground_truth.file_name_rgb = dir_prefix + std::string("/")+line_string_split[11];
            float x,y,z,qx,qy,qz,qw;
            x=boost::lexical_cast<float>(line_string_split[1]);
            y=boost::lexical_cast<float>(line_string_split[2]);
            z=boost::lexical_cast<float>(line_string_split[3]);
            qx=boost::lexical_cast<float>(line_string_split[4]);
            qy=boost::lexical_cast<float>(line_string_split[5]);
            qz=boost::lexical_cast<float>(line_string_split[6]);
            qw=boost::lexical_cast<float>(line_string_split[7]);
            ground_truth.pose_frame.push_back(x);
            ground_truth.pose_frame.push_back(y);
            ground_truth.pose_frame.push_back(z);
            ground_truth.pose_frame.push_back(qx);
            ground_truth.pose_frame.push_back(qy);
            ground_truth.pose_frame.push_back(qz);
            ground_truth.pose_frame.push_back(qw);
            ground_truth_list.push_back(ground_truth);
        }
    }
}