void ComparableModels::WriteMatchingPoints(const std::string &WorldFilename, const std::string &ModelFilename) { if(UsedWorldPoints.size() == 0) { std::cout << "There are no comparable points!" << std::endl; exit(-1); } //world std::vector<OrientedPoint> WorldPoints; for(unsigned int i = 0; i < UsedWorldPoints.size(); i++) { WorldPoints.push_back(World.Points_[UsedWorldPoints[i]]); } ModelFile WorldOutput; WorldOutput.setPoints(WorldPoints); WorldOutput.Init(); WorldOutput.Write(WorldFilename); //model ModelFile ModelOutput; ModelOutput.setPoints(MatchingModelPoints); ModelOutput.Init(); ModelOutput.Write(ModelFilename); }
int main(int argc, char *argv[]) { std::string WithTrianglesFilename, WithoutTrianglesFilename, OutputFilename; po::options_description desc("Allowed options"); desc.add_options() ("help", "Help message.") ("withtris", po::value<std::string>(&WithTrianglesFilename), "Set file with triangles.") ("withouttris", po::value<std::string>(&WithoutTrianglesFilename), "Set file without triangles.") ("output", po::value<std::string>(&OutputFilename), "Set output file.") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("help")) { std::cout << desc << std::endl; exit(-1); } CheckRequiredArgs(vm); ModelFile ModelWithTriangles; ModelWithTriangles.Read(WithTrianglesFilename); ModelWithTriangles.Init(); ModelFile ModelWithoutTriangles; ModelWithoutTriangles.Read(WithoutTrianglesFilename); ModelWithoutTriangles.Init(); if(ModelWithTriangles.NumPoints() != ModelWithoutTriangles.NumPoints()) { std::cout << "The two models must have identical point lists!" << std::endl; exit(-1); } std::vector<vector<unsigned int> > VertexLists = ModelWithTriangles.getVertexLists(); ModelWithoutTriangles.setVertexLists(VertexLists); ModelWithoutTriangles.Write(OutputFilename); return 0; }
int main(int argc, char* argv[]) { std::cout << "Enter main." << std::endl; std::string InputFile, OutputFile; double ScannerLocX, ScannerLocY, ScannerLocZ; double ForwardX, ForwardY, ForwardZ; unsigned int NumPoints; double ThetaMin, ThetaMax, PhiMin, PhiMax, minmax; std::cout << "Options:" << std::endl; po::options_description desc("Allowed options"); desc.add_options() ("help", "Help message.") ("input", po::value<std::string>(&InputFile), "Set input file") ("output", po::value<std::string>(&OutputFile), "Set output file") ("ScannerLocX", po::value<double>(&ScannerLocX)->default_value(0.0), "Set scanner location (x)") ("ScannerLocY", po::value<double>(&ScannerLocY)->default_value(0.0), "Set scanner location (y)") ("ScannerLocZ", po::value<double>(&ScannerLocZ)->default_value(0.0), "Set scanner location (z)") ("ForwardX", po::value<double>(&ForwardX)->default_value(0.0), "Set forward (x)") ("ForwardY", po::value<double>(&ForwardY)->default_value(0.0), "Set forward (y)") ("ForwardZ", po::value<double>(&ForwardZ)->default_value(0.0), "Set forward (z)") ("NumPoints", po::value<unsigned int>(&NumPoints)->default_value(100), "Set number of points (one side of the grid, assuming a square grid)") ("PhiMin", po::value<double>(&PhiMin)->default_value(-10.0), "Set min phi angle") ("PhiMax", po::value<double>(&PhiMax)->default_value(10.0), "Set max phi angle") ("ThetaMin", po::value<double>(&ThetaMin)->default_value(-10.0), "Set min theta angle") ("ThetaMax", po::value<double>(&ThetaMax)->default_value(10.0), "Set max theta angle") ("minmax", po::value<double>(&minmax), "Set max theta angle") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); //assign the variables (if they were specified) if(vm.count("help")) { std::cout << desc << std::endl; return 1; } CheckRequiredArgs(vm); std::cout << std::endl << std::endl; if(!vm.count("minmax")) { //convert degrees to radians PhiMin = deg2rad(PhiMin); PhiMax = deg2rad(PhiMax); ThetaMin = deg2rad(ThetaMin); ThetaMax = deg2rad(ThetaMax); } else { PhiMin = deg2rad(-minmax); PhiMax = deg2rad(minmax); ThetaMin = deg2rad(-minmax); ThetaMax = deg2rad(minmax); } ///////////////////////////////////////////////////// //setup model ModelFile Scene; Scene.Read(InputFile); Scene.Init(); //setup scanner LidarScanner Scanner(true); //use octree Scene.BuildOctree(); vgl_point_3d<double> Pos(ScannerLocX, ScannerLocY, ScannerLocZ); vgl_vector_3d<double> Dir(ForwardX, ForwardY, ForwardZ); Scanner.Orient(Pos, Dir); Scanner.ScanParams.setNumPhiPoints(NumPoints); Scanner.ScanParams.setNumThetaPoints(NumPoints); Scanner.ScanParams.setPhiMin(PhiMin); Scanner.ScanParams.setPhiMax(PhiMax); Scanner.ScanParams.setThetaMin(ThetaMin); Scanner.ScanParams.setThetaMax(ThetaMax); //scan PerformScan(Scene, Scanner, OutputFile); return 0; }
int main(int argc, char *argv[]) { std::string SceneFilename, ModelFilename; double mismatch; //parse arguments po::options_description desc("Allowed options"); desc.add_options() ("help", "Help message.") ("scene", po::value<std::string>(&SceneFilename), "Set scene file") ("model", po::value<std::string>(&ModelFilename), "Set model file") ("mismatch", po::value<double>(&mismatch), "Set mismatch.") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); if(vm.count("help")) { std::cout << desc << std::endl; exit(-1); } CheckRequiredArgs(vm); ModelFile Scene; Scene.Read(SceneFilename); Scene.Init(); ModelFile Model; Model.Read(ModelFilename); Model.Init(); if(Scene.NumPoints() != Model.NumPoints() ) { std::cout << "Number of points do not match (points should already be correspondences.)!" << std::endl; exit(-1); } vgl_point_3d<double> ScannerLocation; bool IsScan = Scene.getScannerLocation(ScannerLocation); std::vector<Color<unsigned char> > Colors; for(unsigned int i = 0; i < Scene.NumPoints(); i++) { double s = (Scene.getCoord(i) - ScannerLocation).length(); double m = (Model.getCoord(i) - ScannerLocation).length(); if(s > (m + mismatch)) { Colors.push_back(Colors::Red()); } else { Colors.push_back(Colors::Green()); } } ModelFile SceneColored; SceneColored.setCoords(Scene.getCoords()); SceneColored.setColors(Colors); SceneColored.Write("SceneColored.vtp"); ModelFile ModelColored; ModelColored.setCoords(Model.getCoords()); ModelColored.setColors(Colors); ModelColored.Write("ModelColored.vtp"); return 0; }