当前位置: 首页>>代码示例>>C++>>正文


C++ Pointcloud::savePointsToFile方法代码示例

本文整理汇总了C++中Pointcloud::savePointsToFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointcloud::savePointsToFile方法的具体用法?C++ Pointcloud::savePointsToFile怎么用?C++ Pointcloud::savePointsToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pointcloud的用法示例。


在下文中一共展示了Pointcloud::savePointsToFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run


//.........这里部分代码省略.........
    Pointcloud pointc = tS.getPointCloud();

    for(Pointcloud::Point p : *pointc.getPoints()){
        if(p.X == 2 && p.Y == 0){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Right side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == -2 && p.Y == 0){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Left side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 0 && p.Y == 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Upper side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 0 && p.Y == -2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Lower side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X ==  -2 && p.Y == -2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Upper left diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 2 && p.Y == -2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Lower left diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == 2 && p.Y == 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Lower right diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
        else if(p.X == -2 && p.Y == 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Upper right diagonal side object behind object scanned. FAILURE!" << std::endl;
            ++error;
        }
    }

    //PointCloud test
    testResultsFile << "Enviroment Simulator test PointCloud" << std::endl;
    Pointcloud pC = testSim.getPointCloud();
    if(pC.getPoints()->size() > 1){
        testResultsFile << "Error: ";
        ++error;
        testResultsFile << "PointCloud: " << "Radius failed" << std::endl;
    }
    for(Pointcloud::Point p : *pC.getPoints()){
        //std::cout << "x: " << p.X << " y: " << p.Y;
        if(p.X != 3){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "X wrong" << std::endl;
            ++error;
        }
        if(p.Y != -1){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Y wrong" << std::endl;
            ++error;
        }
    }

    //save pc
    pC.savePointsToFile("testpC.pcl");
    Pointcloud loadpC;
    //load pc from file
    loadpC.loadPointsFromFile("testpC.pcl");
    //make map from loaded pc
    try{
        Map pCloadMap("testpC.map", &loadpC);
        //check point
        if(pCloadMap.getMapObject(0,3) != 1){
            testResultsFile << "PointCloud: " << "Load from file failed" << std::endl;
        }
    }
    catch(int e){
        if(e != 2){
            testResultsFile << "Error: ";
            testResultsFile << "PointCloud: " << "Excpention error." << std::endl;
            ++error;
        }
    }

    //Done
    testResultsFile << "Enviroment Simulator test done" << std::endl;
    if(error == 0){
        testResultsFile << "Test Succes!" << std::endl;
        std::cout << "Test Succes!" << std::endl;
    }

    testResultsFile << '\n' << '\n';
    testResultsFile.close();
    std::cout << "Enviroment Simulator test done" << std::endl;
    return error;
}
开发者ID:Ban-aan,项目名称:THO78-Roborescue,代码行数:101,代码来源:test.cpp


注:本文中的Pointcloud::savePointsToFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。