Example #1
0
void Savanna::init(int argc, char* argv[])
{
    SN_LOG("*** Savanna BenchMark for Gepard, 2016. *** ");
    SN_LOG("Usage: " << argv[0] << " [config-file]");

    std::string configFile = "";
    if (argc > 1) {
        configFile = argv[1];
    }

    // Set default configs.
    configs["iterateCount"] = 10;
    configs["maxVelocity"] = 51;
    configs["paintRectSize"] = 30;
    configs["rectHeight"] = 5;
    configs["rectNumbers"] = 20;
    configs["rectWidth"] = 5;
    configs["seed"] = 1985;
    configs["warmupCount"] = 3;
    configs["windowHeight"] = 500;
    configs["windowWidth"] = 500;

    SN_LOG("Read config file...");
    if (!configFile.empty()) {
        std::fstream fs(configFile, std::fstream::in);
        std::string line;

        while (std::getline(fs, line)) {
            // Romove '#' comment part and ' ' chars.
            line = line.substr(0, line.find('#'));
            if (std::remove(line.begin(), line.end(), ' ') == line.end()) {
                continue;
            }

            std::istringstream issLine(line);
            std::string key;

            if (std::getline(issLine, key, '=')) {
                std::string value;

                if (std::getline(issLine, value)) {
                    configs[key] = atoi(value.c_str());
                }
            }
        }

        SN_LOG("...done.");
    } else {
        SN_LOG("...not found. Use default configs.");
    }
    SN_LOG("");

    SN_LOG(" * Configs:");
    for (ConfigMap::iterator config = configs.begin(); config != configs.end(); ++config) {
        SN_LOG(config->first << "=" << config->second);
    }
    SN_LOG("");

    surface = makeUnique(new gepard::XSurface(configs["windowWidth"], configs["windowHeight"]));
}
bool  MeshModel::loadOBJ(std::ifstream& infile)
{
	double x,y,z;
	bool hasUV = false;
	std::string a,b,c;

	while (!infile.eof())
	{
		// get line
		std::string curLine;
		std::getline(infile, curLine);

		// read type of the line
		std::istringstream issLine(curLine);
		std::string linetype;
		issLine >> linetype;

		if (linetype == "v")
		{
			issLine >> x >> y >> z;
			Point2 p(x,y);
			vertices.push_back(p);
			continue;
		}
		if (linetype == "vt")
		{
			hasUV = true;
			issLine >> x >> y;
			Point2 p(x,y);
			texCoords->push_back(p);
			continue;
		}
Example #3
0
inline void readNextMessageFromFile( std::ifstream& p_ifMessages, const std::string& p_strImageFolder )
{
    //ds line buffer
    std::string strLineBuffer;

    //ds read one line
    std::getline( p_ifMessages, strLineBuffer );

    if( strLineBuffer.empty( ) ){ throw CExceptionEndOfFile( "received empty string - file end reached" ); }

    //ds get it to a stringstream
    std::istringstream issLine( strLineBuffer );

    //ds information fields
    double dTimeSeconds;
    std::string strToken;
    std::string strMessageType;

    //ds fetch first part of the message
    issLine >> strToken >> strToken >> dTimeSeconds >> strMessageType;

    //ds get time to seconds
    dTimeSeconds /= 1000000;

    //ds set message information depending on type
    if( "IMU" == strMessageType )
    {
        //ds IMU message
        txt_io::CIMUMessage msgIMU( "/imu", "imu", g_uFrameIDIMU, dTimeSeconds );

        //ds fields
        Eigen::Vector3d vecAngularVelocity;
        CLinearAccelerationIMU vecLinearAcceleration;

        //ds parse the values (order x/z/y) TODO align coordinate systems
        issLine >> strToken >> vecLinearAcceleration[0] >> vecLinearAcceleration[1] >> vecLinearAcceleration[2] >> vecAngularVelocity[0] >> vecAngularVelocity[1] >> vecAngularVelocity[2];

        //ds rotate around X axis by 180 degrees
        vecLinearAcceleration.y( ) = -vecLinearAcceleration.y( );
        vecLinearAcceleration.z( ) = -vecLinearAcceleration.z( );
        vecAngularVelocity.y( )    = -vecAngularVelocity.y( );
        vecAngularVelocity.z( )    = -vecAngularVelocity.z( );

        //ds set message fields
        msgIMU.setAngularVelocity( vecAngularVelocity );
        msgIMU.setLinearAcceleration( vecLinearAcceleration );

        //ds pump it into the synchronizer
        g_vecMessagesIMU.push( msgIMU );
    }