TEST( ResourceDependenciesGraph, removingFile )
{
   ResourceDependenciesGraph graph;

   FilePath file( "a.res" );
   FilePath res1( "b.tmat" );
   FilePath res2( "c.tmat" );
   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );

   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onFileRemoved( res1 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 1, graph.getAffectedResources( file ).size() );

   graph.onFileRemoved( res2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );

   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onFileRemoved( file );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );
}
示例#2
0
void CJabberProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen)
{
	int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);

	DWORD dwAttributes = GetFileAttributes(pszDest);
	if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
		CreateDirectoryTreeT(pszDest);

	pszDest[ tPathLen++ ] = '\\';

	const TCHAR* szFileType = ProtoGetAvatarExtension( getByte(hContact, "AvatarType", PA_FORMAT_PNG));

	if (hContact != NULL) {
		char str[ 256 ];
		DBVARIANT dbv;
		if (!db_get_utf(hContact, m_szModuleName, "jid", &dbv)) {
			strncpy(str, dbv.pszVal, sizeof str);
			str[ sizeof(str)-1 ] = 0;
			db_free(&dbv);
		}
		else _i64toa((LONG_PTR)hContact, str, 10);
		mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S%s"), ptrA(JabberSha1(str)), szFileType);
	}
	else if (m_ThreadInfo != NULL) {
		mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@%S avatar%s"),
			m_ThreadInfo->username, m_ThreadInfo->server, szFileType);
	}
	else {
		ptrA res1( getStringA("LoginName")), res2( getStringA("LoginServer"));
		mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S@%S avatar%s"),
			(res1) ? (LPSTR)res1 : "noname", (res2) ? (LPSTR)res2 : m_szModuleName, szFileType);
	}
}
示例#3
0
int main(int argc, char *argv[])
{
    //embed fonts
    QFile res1(":/fonts/bell-gothic-black.ttf");
    if (res1.open(QIODevice::ReadOnly))
    {
        QFontDatabase::addApplicationFontFromData(res1.readAll());
    }
    QFile res2(":/fonts/bell-gothic-bold.ttf");
    if (res2.open(QIODevice::ReadOnly))
    {
        QFontDatabase::addApplicationFontFromData(res2.readAll());
    }
    QFile res3(":/fonts/bell-gothic-light.ttf");
    if (res3.open(QIODevice::ReadOnly))
    {
        QFontDatabase::addApplicationFontFromData(res3.readAll());
    }

    QApplication a(argc, argv);

    MainWindow w;
    w.show();

    return a.exec();
}
TEST( ResourceDependenciesGraph, removingDir )
{
   ResourceDependenciesGraph graph;

   FilePath file( "/directory1/a.res" );
   FilePath res1( "/directory2/b.tmat" );
   FilePath res2( "/directory3/c.tmat" );
   FilePath dir1( "/directory1" );
   FilePath dir2( "/directory2" );
   FilePath dir3( "/directory3" );
   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );

   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onDirRemoved( dir2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 1, graph.getAffectedResources( file ).size() );
   CPPUNIT_ASSERT_EQUAL( res2.getRelativePath(), graph.getAffectedResources( file ).front().getRelativePath() );

   graph.onDirRemoved( dir3 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );

   graph.addDependency( file, res1 );
   graph.addDependency( file, res2 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 2, graph.getAffectedResources( file ).size() );

   graph.onDirRemoved( dir1 );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( file ).size() );
}
示例#5
0
void example_test_class::test_hello_world2()
{
  logMsg("Hello world without framework magic");
  try
  {
    /*
     Connection, Statement and ResultSet are typedefs from unit_fixture.h:

     typedef std::auto_ptr<sql::Connection> Connection;
     typedef std::auto_ptr<sql::PreparedStatement> PreparedStatement;
     typedef std::auto_ptr<sql::ParameterMetaData> ParameterMetaData;
     typedef std::auto_ptr<sql::Statement> Statement;
     typedef std::auto_ptr<sql::Savepoint> Savepoint;
     typedef std::auto_ptr<sql::ResultSet> ResultSet;
     typedef sql::Driver Driver;
     typedef std::auto_ptr<sql::ResultSetMetaData> ResultSetMetaData;
     typedef std::auto_ptr<sql::DatabaseMetaData> DatabaseMetaData;

     Do yourself a favour and use auto_ptr in tests!
     */
    Connection my_con(getConnection());
    Statement my_stmt(my_con->createStatement());

    /*
     The framework defines a couple of public members (from unit_fixture.h):

     Connection con;
     PreparedStatement pstmt;
     Statement stmt;
     ResultSet res;

     The members are managed in unit_fixture.cpp setUp() and tearDown().
     You don't need to clean up them as long as setUp() and tearDown()
     are called and are not overwritten by your own method.

     However note, if you declare a local variable of the same type
     and name of any of the above members, for example ResultSet res, some
     compilers will spawn warnings that you are hiding members.
     */
    res.reset(my_stmt->executeQuery("SELECT 'Hello world!' AS _world"));

    res->next();
    logMsg(res->getString("_world"));
    res->close();

    ResultSet res2(my_stmt->executeQuery("SELECT 'What a boring example' AS _complain"));
    res2->next();
    logMsg(res2->getString("_complain"));
    res2->close();
  }
  catch (sql::SQLException &e)
  {
    logErr(e.what());
    logErr("SQLState: " + std::string(e.getSQLState()));
    fail(e.what(), __FILE__, __LINE__);
  }
}
int btPersistentManifold::sortCachedPoints(const btManifoldPoint& pt) 
{

		//calculate 4 possible cases areas, and take biggest area
		//also need to keep 'deepest'
		
		int maxPenetrationIndex = -1;
#define KEEP_DEEPEST_POINT 1
#ifdef KEEP_DEEPEST_POINT
		btScalar maxPenetration = pt.getDistance();
		for (int i=0;i<4;i++)
		{
			if (m_pointCache[i].getDistance() < maxPenetration)
			{
				maxPenetrationIndex = i;
				maxPenetration = m_pointCache[i].getDistance();
			}
		}
#endif //KEEP_DEEPEST_POINT
		
		btScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.));
		if (maxPenetrationIndex != 0)
		{
			btVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA;
			btVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;
			btVector3 cross = a0.cross(b0);
			res0 = cross.length2();
		}
		if (maxPenetrationIndex != 1)
		{
			btVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA;
			btVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;
			btVector3 cross = a1.cross(b1);
			res1 = cross.length2();
		}

		if (maxPenetrationIndex != 2)
		{
			btVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA;
			btVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA;
			btVector3 cross = a2.cross(b2);
			res2 = cross.length2();
		}

		if (maxPenetrationIndex != 3)
		{
			btVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA;
			btVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA;
			btVector3 cross = a3.cross(b3);
			res3 = cross.length2();
		}

		btVector4 maxvec(res0,res1,res2,res3);
		int biggestarea = maxvec.closestAxis4();
		return biggestarea;
}
TEST( ResourceDependenciesGraph, basics )
{
   ResourceDependenciesGraph graph;

   FilePath res1( "a.res" );
   FilePath res2( "b.res" );
   graph.addDependency( res1, res2 );

   CPPUNIT_ASSERT_EQUAL( ( uint ) 1, graph.getAffectedResources( res1 ).size() );
   CPPUNIT_ASSERT_EQUAL( ( uint ) 0, graph.getAffectedResources( res2 ).size() );
}
示例#8
0
void test_verify_1()
{
  cout << "Verify Test 1" << endl;
  vector<int> res1 (100);
  vector<int> res2 (100);
  cout << "res1 == res2: " << TestEnvironment::verify(res1, res2) << endl;
  vector<int> res3 (50);
  vector<int> res4 (100);
  cout << "res3 == res4: " << TestEnvironment::verify(res3, res4) << endl;
  cout << endl;
}
示例#9
0
void Test_M2MDevice::test_total_resource_count()
{
    M2MResource res(*m2mobject_stub::inst,"test","test",M2MResourceInstance::STRING,M2MBase::Dynamic);

    m2mobjectinstance_stub::resource_list.push_back(&res);
    M2MResource res2(*m2mobject_stub::inst,"test","test",M2MResourceInstance::STRING,M2MBase::Dynamic);

    m2mobjectinstance_stub::resource_list.push_back(&res2);

    CHECK(device->total_resource_count() == 2);

    m2mobjectinstance_stub::resource_list.clear();
}
示例#10
0
int main(int argc, char *argv[])
{
    //embed fonts
    QFile res1(":/fonts/bell-gothic-black.ttf");
    if (res1.open(QIODevice::ReadOnly))
    {
        QFontDatabase::addApplicationFontFromData(res1.readAll());
    }
    QFile res2(":/fonts/bell-gothic-bold.ttf");
    if (res2.open(QIODevice::ReadOnly))
    {
        QFontDatabase::addApplicationFontFromData(res2.readAll());
    }
    QFile res3(":/fonts/bell-gothic-light.ttf");
    if (res3.open(QIODevice::ReadOnly))
    {
        QFontDatabase::addApplicationFontFromData(res3.readAll());
    }

    bool quiet = false;

    QApplication a(argc, argv);

    #ifdef Q_OS_WIN
        if (argc>1)
        {
            QString arg1 = argv[1];
            qDebug() << arg1;
            if (arg1 == "-q" || arg1 == "-quiet" || arg1 == "-s" || arg1 == "-silent")
            {
                quiet = true;

                QuietInstaller qi = QuietInstaller();
            }
            else
            {
                qWarning() << "Unknown argument";
            }
        }
    #endif

    MainWindow w;
    w.show();

    return a.exec();
}
示例#11
0
void If::execute(void* result, Tree &tree)
{
	std::vector<bool>& res = *(std::vector<bool>*)result;
		uint size = (uint) res.size();

		std::vector<bool> arg(size), res1(size), res2(size);
		getNextArgument(&arg, tree);
		getNextArgument(&res1, tree);
		getNextArgument(&res2, tree);

		for(uint i = 0; i < size; i++)
			if(arg[i]) {
				res[i] = res1[i];
			} else {
				res[i] = res2[i];
			}
}
示例#12
0
 /*
  * compare: Compare running time of 2 implementations of Nearest Neighbor Search by performing N queries
  *          on N reference points where each point has dimension k
  */
void TestEnvironment::compare(NearestNeighbor<float> *impl1, NearestNeighbor<float> *impl2, int N, int k)
{
  //cout << "N = " << N << endl;
  vector<Point<float>> data (N);
  vector<Point<float>> queries (N);
  vector<int> res1 (N);
  vector<int> res2 (N);
  TestEnvironment::gen_data(data, k);
  TestEnvironment::gen_data(queries, k);
  impl1->nns(data, queries, res1);
  impl2->nns(data, queries, res2);
  if(!verify(res1, res2))
  {
    cout << "Results don't match !!!" << endl;
    exit(-1);
  }

  print_result(N, impl1->get_search_time().count(), impl2->get_search_time().count());

}
示例#13
0
bool authpgsql_connection::getuserinfo(authpgsql_userinfo &uiret,
				       const char *username,
				       const char *service)
{
	std::string querybuf;

	if (!do_connect())
		return false;

	if (config_file.select_clause.empty())
	{
		std::ostringstream o;

		o << "SELECT "
		  << config_file.login_field << ", "
		  << config_file.crypt_field << ", "
		  << config_file.clear_field << ", "
		  << config_file.uid_field << ", "
		  << config_file.gid_field << ", "
		  << config_file.home_field << ", "
		  << (strcmp(service, "courier") == 0 ?
		      config_file.defaultdelivery_field
		      :config_file.maildir_field) << ", "
		  << config_file.quota_field << ", "
		  << config_file.name_field << ", "
		  << config_file.options_field
		  << " FROM " << config_file.user_table
		  << " WHERE " << config_file.login_field
		  << " = '"
		  << escape_username(username)
		  << "' AND (" << config_file.where_clause << ")";

		querybuf=o.str();
	}
	else
	{
		std::map<std::string, std::string> parameters;

		parameters["service"]=service;

		querybuf=config_file
			.parse_custom_query(config_file.select_clause,
					    escape(username),
					    config_file.defdomain,
					    parameters);
	}

	DPRINTF("SQL query: %s", querybuf.c_str());

	result res1(*this, querybuf);

	if (res1)
		return getuserinfo(uiret, res1);

	disconnect();
	if (do_connect())
	{
		result res2(*this, querybuf);

		if (res2)
			return getuserinfo(uiret, res2);
	}
	return false;
}
示例#14
0
std::shared_ptr<TextureParameters> processTexture(
    domCommon_color_or_texture_type_complexType::domTexture *tex
)
{
    std::shared_ptr<TextureParameters> parameters(new TextureParameters);
    //parameters.transparent = tuu == TRANSPARENCY_MAP_UNIT;
    //parameters.opaque = opaque;
    //parameters.transparency = transparency;

    //find the newparam for the sampler based on the texture attribute
    domFx_sampler2D_common *sampler = NULL;
    domFx_surface_common *surface = NULL;
    domImage *dImg = NULL;

    std::string target = std::string("./") + std::string(tex->getTexture());
    // OSG_INFO<<"processTexture("<<target<<")"<<std::endl;

    daeSIDResolver res1( /*_currentEffect*/currentEffect(), target.c_str() );
    daeElement *el = res1.getElement();

    if (el == NULL )
    {
        std::cout << "Could not locate newparam for texture sampler2D \"" << tex->getTexture() <<
            "\". Checking if data does incorrect linking straight to the image" << std::endl;
        GetDAE().getDatabase()->getElement( (daeElement**)&dImg, 0, tex->getTexture(), "image" );
        if (dImg != NULL )
        {
            std::cout << "Direct image link found. Data is incorrect but will continue to load texture" << std::endl;
        }
    }
    else
    {
        domCommon_newparam_type *cnp = daeSafeCast< domCommon_newparam_type >( el );
        domFx_newparam_common *npc = daeSafeCast< domFx_newparam_common >( el );

        if (cnp != NULL )
        {
            sampler = cnp->getSampler2D();
        }
        else if (npc != NULL )
        {
            sampler = npc->getFx_basic_type_common()->getSampler2D();
        }

        if (sampler == NULL )
        {
            std::cout << "Wrong newparam type. Expected sampler2D" << std::endl;
            return nullptr;
        }

        if (sampler->getSource() == NULL )
        {
            std::cout << "Could not locate source for sampler2D" << std::endl;
            return nullptr;
        }

        //find the newparam for the surface based on the sampler2D->source value
        target = std::string("./") + std::string( sampler->getSource()->getValue() );
        daeSIDResolver res2( /*_currentEffect*/currentEffect(), target.c_str() );
        el = res2.getElement();
        if (el == NULL )
        {
            std::cout << "Could not locate newparam for source " << sampler->getSource()->getValue() << std::endl;
            return nullptr;
        }
        cnp = daeSafeCast< domCommon_newparam_type >( el );
        npc = daeSafeCast< domFx_newparam_common >( el );

        if (cnp != NULL )
        {
            surface = cnp->getSurface();
        }
        else if (npc != NULL )
        {
            surface = npc->getFx_basic_type_common()->getSurface();
        }

        if (surface == NULL )
        {
            std::cout << "Wrong newparam type. Expected surface" << std::endl;
            return NULL;
        }

        //look for the domImage based on the surface initialization stuff
        daeIDRef &ref = surface->getFx_surface_init_common()->getInit_from_array()[0]->getValue();
        dImg = daeSafeCast< domImage >( getElementFromIDRef( ref ) );
    }

    parameters->filename = processImagePath(dImg);
	std::cout << "ImagePath: " << parameters->filename << std::endl;
    if (parameters->filename.empty())
    {
		
        return NULL;
    }
	

    //set texture parameters
    if (sampler)
    {
        if (sampler->getWrap_s())
        {
            parameters->wrap_s = sampler->getWrap_s()->getValue();//getWrapMode(sampler->getWrap_s()->getValue());
        }
        if (sampler->getWrap_t())
        {
            parameters->wrap_t = sampler->getWrap_t()->getValue();//getWrapMode(sampler->getWrap_s()->getValue());
        }

        if (sampler->getMinfilter() && sampler->getMinfilter()->getValue() != FX_SAMPLER_FILTER_COMMON_NONE)
        {
            parameters->filter_min = sampler->getMinfilter()->getValue();//getFilterMode(sampler->getMinfilter()->getValue(), true);
        }
        if (sampler->getMagfilter() && sampler->getMagfilter()->getValue() != FX_SAMPLER_FILTER_COMMON_NONE)
        {
            parameters->filter_mag = sampler->getMagfilter()->getValue();//getFilterMode(sampler->getMagfilter()->getValue(), false);
        }

        if (sampler->getBorder_color() != NULL )
        {
            const domFloat4& col = sampler->getBorder_color()->getValue();
            parameters->border = col;// parameters.border.set(col[0], col[1], col[2], col[3]);
        }
    }

	   
	//osg::Texture2D* t2D = NULL;
    //TextureParametersMap::const_iterator mapIt = _textureParamMap.find(parameters);
    //if (mapIt != _textureParamMap.end())
    //{
    //    t2D = mapIt->second.get();
    //}
    //else
    //{
    //    osg::ref_ptr<osg::Image> img = osgDB::readRefImageFile(parameters.filename);

    //    if (!img.valid())
    //    {
    //        _textureParamMap[parameters] = NULL;
    //        return NULL;
    //    }

    //    OSG_INFO<<"  processTexture(..) - readImage("<<parameters.filename<<")"<<std::endl;

    //    if (tuu == TRANSPARENCY_MAP_UNIT)
    //    {
    //        img = processImageTransparency(img.get(), opaque, transparency);
    //    }

    //    t2D = new osg::Texture2D(img.get());

    //    t2D->setWrap( osg::Texture::WRAP_S, parameters.wrap_s);
    //    t2D->setWrap( osg::Texture::WRAP_T, parameters.wrap_t);
    //    t2D->setFilter( osg::Texture::MIN_FILTER, parameters.filter_min);
    //    t2D->setFilter( osg::Texture::MAG_FILTER, parameters.filter_mag);
    //    t2D->setBorderColor(parameters.border);

    //    _textureParamMap[parameters] = t2D;
    //}

    //_texCoordSetMap[TextureToCoordSetMap::key_type(ss, tuu)] = tex->getTexcoord();

    return /*t2D*/parameters;
}
void SIMPLE_Agents::get_IR_reading( vector <double> &_reading){
    double x,z,X,Z,rotation = 0.0;
    this->pos = this->get_pos();
    double y = pos[1] + 0.011;
    btMatrix3x3 m = btMatrix3x3(body->getWorldTransform().getRotation());
    double rfPAngle = btAsin(-m[1][2]);
       if ( rfPAngle < SIMD_HALF_PI )   {
           if ( rfPAngle > -SIMD_HALF_PI ) rotation = btAtan2(m[0][2],m[2][2]);
            else rotation = -btAtan2(-m[0][1],m[0][0]);
        }
        else rotation = btAtan2(-m[0][1],m[0][0]);

 //   IR0 reading
      x = pos[0]+((robot_radius) * cos(-rotation + 0.3));   //calc IR sensor X based on robot radius
      z = pos[2]+((robot_radius) * sin(-rotation + 0.3));
      from1[0] = btVector3(x, y, z);                        //sensor position based on robot rotation vector to hold btVector
      X = x+((IR_range) * cos(-rotation + 0.3 ));           //calc IR ray end position based on IR range and placement of sensor on the robot
      Z = z+((IR_range) * sin(-rotation + 0.3 ));
      to1[0] = btVector3( X, y, Z );                        //Max reading pos of the IR based on rotation and IR range
      btCollisionWorld::ClosestRayResultCallback res0(from1[0], to1[0]); //struct for the closest ray callback
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res0.m_flags = 0xFFFFFFFF;
       this->world->rayTest(from1[0], to1[0], res0);        //check for ray collision between the coords sets
    if(res0.hasHit()){
        _reading[0] = IR_range*res0.m_closestHitFraction ;
        to1[0]=res0.m_hitPointWorld;                        //update the vector with the btVector results -> used to render it in openGL
    }

 //   IR7 reading
      x = pos[0]+((robot_radius) * cos(-rotation - 0.3));
      z = pos[2]+((robot_radius) * sin(-rotation - 0.3));
      from1[1] = btVector3(x, y, z);
      X = x+((IR_range) * cos(-rotation - 0.3 ));
      Z = z+((IR_range) * sin(-rotation - 0.3 ));
      to1[1] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res7(from1[1], to1[1]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res7.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[1], to1[1], res7);
      if(res7.hasHit()){
          _reading[1] = IR_range*res7.m_closestHitFraction;
          to1[1]=res7.m_hitPointWorld;
      }

 //   IR1 reading corrospond to epuck
      x = pos[0]+((robot_radius) * cos(-rotation + 0.8));
      z = pos[2]+((robot_radius) * sin(-rotation + 0.8));
      from1[2] = btVector3(x, y, z);
      X = x+((IR_range) * cos(-rotation + 0.8 ));
      Z = z+((IR_range) * sin(-rotation + 0.8 ));
      to1[2] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res1(from1[2], to1[2]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res1.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[2], to1[2], res1);
      if(res1.hasHit()){
        _reading[2] = IR_range*res1.m_closestHitFraction;
        to1[2]=res1.m_hitPointWorld;
      }


 //   IR6 reading
      x = pos[0]+((robot_radius) * cos(-rotation - 0.8));
      z = pos[2]+((robot_radius) * sin(-rotation - 0.8));
      from1[3] = btVector3(x, y, z);
      X = x+((IR_range) * cos(-rotation - 0.8 ));
      Z = z+((IR_range) * sin(-rotation - 0.8 ));
      to1[3] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res6(from1[3], to1[3]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res6.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[3], to1[3], res6);
      if(res6.hasHit()){
          _reading[3] = IR_range*res6.m_closestHitFraction;
          to1[3]=res6.m_hitPointWorld;
     }

 //   IR2 reading
      x = pos[0]+((0.028) * cos(-rotation + 1.57));
      z = pos[2]+((0.028) * sin(-rotation + 1.57));
      from1[4] = btVector3(x, y, z);
      X = x+((0.049) * cos(-rotation + 1.57 ));
      Z = z+((0.049) * sin(-rotation + 1.57));
      to1[4] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res2(from1[4], to1[4]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res2.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[4], to1[4], res2);
      if(res2.hasHit()){
          _reading[4] = 0.049*(res2.m_closestHitFraction) - 0.009;
          to1[4]=res2.m_hitPointWorld;
      }

 //   IR5 reading
      x = pos[0]+((0.028) * cos(-rotation - 1.57));
      z = pos[2]+((0.028) * sin(-rotation - 1.57));
      from1[5] = btVector3(x, y, z);
      X = x+((0.049) * cos(-rotation - 1.57 ));
      Z = z+((0.049) * sin(-rotation - 1.57 ));
      to1[5] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res5(from1[5], to1[5]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res5.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[5], to1[5], res5);
      if(res5.hasHit()){
           _reading[5] = 0.049*res5.m_closestHitFraction - 0.009;
           to1[5]=res5.m_hitPointWorld;
      }


 //   IR3 reading
      x = pos[0]+((robot_radius) * cos(-rotation + 2.64));
      z = pos[2]+((robot_radius) * sin(-rotation + 2.64));
      from1[6] = btVector3(x, y, z);
      X = x+((IR_range) * cos(-rotation + 2.64 ));
      Z = z+((IR_range) * sin(-rotation + 2.64 ));
      to1[6] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res3(from1[6], to1[6]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res3.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[6], to1[6], res3);
      if(res3.hasHit()){
          _reading[6] = IR_range*res3.m_closestHitFraction;
          to1[6]=res3.m_hitPointWorld;
      }

  //   IR4 reading
      x = pos[0]+((robot_radius) * cos(-rotation - 2.64));
      z = pos[2]+((robot_radius) * sin(-rotation - 2.64));
      from1[7] = btVector3(x, y, z);
      X = x+((IR_range) * cos(-rotation - 2.64 ));
      Z = z+((IR_range) * sin(-rotation - 2.64 ));
      to1[7] = btVector3( X, y, Z );
      btCollisionWorld::ClosestRayResultCallback res4(from1[7], to1[7]);
      //uncomment below line if you experience any ray pentration problem to the object this might happened with very slow machine
      //res4.m_flags = 0xFFFFFFFF;
      this->world->rayTest(from1[7], to1[7], res4);
      if(res4.hasHit()){
          _reading[7] = IR_range*res4.m_closestHitFraction;
          to1[7]=res4.m_hitPointWorld;
      }

//        for( int i = 0; i < num_IR_sensors; i++){
//            printf(" \nIR%d distance reading= %f ",i,_reading[i]);
//        }

    //calibrating distance to IR value reading according to a line equations
  for(int i = 0; i < num_IR_sensors; i++){
       if (_reading[i] > 0.03 && _reading[i] <= 0.04)
           _reading[i] = -20600 * _reading[i] + 924;
       else if (_reading[i] > 0.02 && _reading[i] <= 0.03)
           _reading[i] = -37000 * _reading[i] + 1416;
       else if (_reading[i] > 0.01 && _reading[i] <= 0.02)
           _reading[i] = -153500 * _reading[i] + 3746;
       else if (_reading[i] > 0.005 && _reading[i] <= 0.01)
           _reading[i] = -252600 * _reading[i] + 4737;
       else if (_reading[i] >= 0.0 && _reading[i] <= 0.005 )
           _reading[i] = -124200 * _reading[i] + 4095;

  }
//  for( int i = 0; i < num_IR_sensors; i++){
//      printf("\n IR%d distance reading= %f ",i,_reading[i]);
//  }

//    take_occupancy_reading(_reading, get_rotation(), get_pos()[0], get_pos()[2] );


}