Beispiel #1
0
void Entity_ungroupSelected(){
	if ( GlobalSelectionSystem().countSelected() < 1 ) {
		return;
	}

	UndoableCommand undo( "ungroupSelectedEntities" );

	scene::Path world_path( makeReference( GlobalSceneGraph().root() ) );
	world_path.push( makeReference( Map_FindOrInsertWorldspawn( g_map ) ) );

	scene::Instance &instance = GlobalSelectionSystem().ultimateSelected();
	scene::Path path = instance.path();

	if ( !Node_isEntity( path.top() ) ) {
		path.pop();
	}

	if ( Node_getEntity( path.top() ) != 0
		 && node_is_group( path.top() ) ) {
		if ( world_path.top().get_pointer() != path.top().get_pointer() ) {
			parentBrushes( path.top(), world_path.top() );
			Path_deleteTop( path );
		}
	}
}
Beispiel #2
0
void Entity_ungroupSelected()
{
  UndoableCommand undo("ungroupSelectedEntities");

  scene::Path world_path(makeReference(GlobalSceneGraph().root()));
  world_path.push(makeReference(Map_FindOrInsertWorldspawn(g_map)));

  GlobalSelectionSystem().foreachSelected(EntityUngroupVisitor(world_path));
}
Beispiel #3
0
void Entity_groupSelected(){
	if ( GlobalSelectionSystem().countSelected() < 1 ) {
		return;
	}

	UndoableCommand undo( "groupSelectedEntities" );

	scene::Path world_path( makeReference( GlobalSceneGraph().root() ) );
	world_path.push( makeReference( Map_FindOrInsertWorldspawn( g_map ) ) );

	EntityFindSelected fse;
	GlobalSceneGraph().traverse( fse );
	if ( fse.groupPath ) {
		GlobalSceneGraph().traverse( EntityGroupSelected( *fse.groupPath ) );
	}
	else
	{
		GlobalSceneGraph().traverse( EntityGroupSelected( world_path ) );
	}
}
Beispiel #4
0
int
main(int ac, char* av[])
{
    std::string sim_dir("");
    std::string desc_path("description.txt");
    std::string chain_path("chain.txt");
    std::string sim_path("sim.txt");
    std::string result_dir("results/");
    std::string world_path("world.txt");

    std::string result_path("results");
    time_t nowt = time(0);
    std::string now = boost::lexical_cast<std::string>(nowt);
    std::string txt_end(".txt");
    result_path = result_path + now + txt_end;
    

    struct sim_settings sets = _DEFAULT_SETS;
    boost::program_options::variables_map vm;

    if (!parse_options(ac, av, vm, sets))
    {
        return 1;
    }

    /* Check to make sure the simulation directory and all of its components
     * exist
     */
    if (  (sets.sim_dir.length() == 0)
       || (! boost::filesystem::is_directory(sets.sim_dir)))
    {
        std::cerr << "The simululation directory ('"
                  << sets.sim_dir
                  << "') specified by --dir must exist!" << std::endl;
        return 1;
    }

    /* Make sure the directory path ends with a path delimeter */
    if (! (sets.sim_dir.at(sets.sim_dir.length()-1) == DELIMITER))
    {
        sets.sim_dir.push_back(DELIMITER);
    }
    sets.desc_path = sets.sim_dir + sets.desc_path;
    sets.chain_path = sets.sim_dir + sets.chain_path;
    sets.sim_path = sets.sim_dir + sets.sim_path;
    sets.result_dir = sets.sim_dir + sets.result_dir;
    sets.result_path = sets.result_dir + result_path;
    sets.world_path = sets.sim_dir + world_path;

    if (! boost::filesystem::is_regular_file(sets.desc_path))
    {
        std::cerr << "The description file does not exist. ("
                  << sets.desc_path
                  << ")" << std::endl;
        return 1;
    }
    if (! boost::filesystem::is_regular_file(sets.chain_path))
    {
        std::cerr << "The chain file does not exist. ( " <<
           sets.chain_path << ")" << std::endl;
        return 1;
    }
    if (! boost::filesystem::is_regular_file(sets.sim_path))
    {
        std::cerr << "The simulation file does not exist. ( " <<
           sets.sim_path << ")" << std::endl;
        return 1;
    }

    /* Verify and (if needed) create the result directory */
    if (! boost::filesystem::is_directory(sets.result_dir))
    {
        std::cerr << "The result directory doesn't exist yet...creating...";
        try
        {
            boost::filesystem::create_directory(sets.result_dir);
            std::cerr << "Last char is: " 
                      << sets.sim_dir.at(sets.sim_dir.length()-1) << std::endl;
        }
        catch (std::exception& e)
        {
            std::cerr << "Error: " << e.what() << std::endl;
            return 1;
        }
        catch (...)
        {
            std::cerr << "Unknown error occured while creating directory" << std::endl;
            return 1;
        }
        std::cout << "Success!" << std::endl;
    }

    /* If we're using collisions, make sure the world.txt file exists in
     * the simulation directory.
     */
    if (sets.collisions && (! boost::filesystem::is_regular_file(sets.world_path)))
    {
        std::cerr << "You asked to use collisions and the world file ("
                  << sets.world_path << ") does not exist." << std::endl;
        return 1;
    }
    Json::Value result_root;

    boost::shared_ptr<ckbot::CK_ompl> rate_machine_p;
    rate_machine_p = load_ckbot_rate_machine(sets, result_root);
    if (!rate_machine_p) {
        std::cerr << "Error loading the rate machine. Exiting." << std::endl;
        return 1;
    }

    report_setup(&sets);

    boost::shared_ptr<oc::SimpleSetup> ss_p;
    ss_p = load_and_run_simulation(rate_machine_p, std::cout, sets, result_root);
    if (!ss_p)
    {
        std::cerr << "Error loading simulation...exiting." << std::endl;
        return 1;
    }
    /* Write the results to file in Json format */
    std::ofstream result_file;
    result_file.open((char*)sets.result_path.c_str());
    result_file << result_root;
    result_file.close();

    return 0;
}