コード例 #1
0
// ========================================================================
void process_surface_entity(const Ioss::SideSet* sset ,
                            stk::mesh::BulkData & bulk)
{
    assert(sset->type() == Ioss::SIDESET);

    const stk::mesh::MetaData& meta = stk::mesh::MetaData::get(bulk);
    const stk::mesh::EntityRank element_rank = stk::topology::ELEMENT_RANK;

    int block_count = sset->block_count();
    for (int i=0; i < block_count; i++) {
        Ioss::SideBlock *block = sset->get_block(i);
        if (stk::io::include_entity(block)) {
            std::vector<int> side_ids ;
            std::vector<int> elem_side ;

            stk::mesh::Part * const side_block_part = meta.get_part(block->name());
            stk::mesh::EntityRank side_rank = side_block_part->primary_entity_rank();

            block->get_field_data("ids", side_ids);
            block->get_field_data("element_side", elem_side);

            assert(side_ids.size() * 2 == elem_side.size());
            stk::mesh::PartVector add_parts( 1 , side_block_part );

            size_t side_count = side_ids.size();
            std::vector<stk::mesh::Entity> sides(side_count);
            for(size_t is=0; is<side_count; ++is) {

                stk::mesh::Entity const elem = bulk.get_entity(element_rank, elem_side[is*2]);

                // If NULL, then the element was probably assigned to an
                // element block that appears in the database, but was
                // subsetted out of the analysis mesh. Only process if
                // non-null.
                if (bulk.is_valid(elem)) {
                    // Ioss uses 1-based side ordinal, stk::mesh uses 0-based.
                    // Hence the '-1' in the following line.
                    int side_ordinal = elem_side[is*2+1] - 1 ;

                    stk::mesh::Entity side = stk::mesh::Entity();
                    if (side_rank == 2) {
                        side = stk::mesh::declare_element_side(bulk, side_ids[is], elem, side_ordinal);
                    } else {
                        side = stk::mesh::declare_element_edge(bulk, side_ids[is], elem, side_ordinal);
                    }
                    bulk.change_entity_parts( side, add_parts );
                    sides[is] = side;
                } else {
                    sides[is] = stk::mesh::Entity();
                }
            }

            const stk::mesh::FieldBase *df_field = stk::io::get_distribution_factor_field(*side_block_part);

            if (df_field != NULL) {
                stk::io::field_data_from_ioss(bulk, df_field, sides, block, "distribution_factors");
            }
        }
    }
}
コード例 #2
0
LEVEL_RESULT play_replay_level(const config& game_config,
		const config* level, CVideo& video, game_state& state_of_game, bool is_unit_test)
{
	try{
		const int ticks = SDL_GetTicks();
		int num_turns = (*level)["turns"].to_int(-1);

		config init_level = *level;
		carryover_info sides(state_of_game.carryover_sides);
		sides.transfer_to(init_level);
		state_of_game.carryover_sides = sides.to_config();

		DBG_NG << "creating objects... " << (SDL_GetTicks() - ticks) << "\n";
		replay_controller replaycontroller(init_level, state_of_game, ticks, num_turns, game_config, video);
		DBG_NG << "created objects... " << (SDL_GetTicks() - replaycontroller.get_ticks()) << "\n";
		const events::command_disabler disable_commands;

		//replay event-loop
		for (;;){
			replaycontroller.play_slice();
			if (is_unit_test) { 
				if (replaycontroller.manage_noninteractively()) {
					return VICTORY;
				}
			}
		}
	}
	catch(end_level_exception&){
		DBG_NG << "play_replay_level: end_level_exception\n";
	}

	return VICTORY;
}
コード例 #3
0
 bool makesquare(vector<int>& nums) {
     if(nums.size() < 4) return false;
     int sum = 0;
     for(int x: nums) sum += x;
     if(sum % 4 != 0) return false;
     sort(nums.begin(), nums.end(), greater<int>());
     vector<int> sides(4);
     return dfs(0, sides, nums, sum / 4);
 }
コード例 #4
0
 bool makesquare(vector<int>& nums) {
     if(nums.size() < 4)
         return false;
     int len = 0;
     for(auto x: nums)
         len += x;
     if(len % 4 != 0)
         return false;
     int side = len / 4;
     vector<int> sides(4, 0);
     return helper(nums, sides, 0, side);
 }
コード例 #5
0
void
CGnuPlotBorderData::
save(std::ostream &os) const
{
  int s = sides().getValue(31);

  os << "set border " << s << " " <<
        CStrUniqueMatch::valueToString<DrawLayer>(layer()) <<
        " lt " << lineType() <<
        " linewidth " << lineWidth() <<
        " dashtype solid" << std::endl;
}
コード例 #6
0
SGVoxels::SGVoxels(const vector<vec3f>& voxels, float side) {
	this->setName("voxels");

	Geometry g;
	g.init(3, 4, 2, ftQuads);

	vec3f sides(side);
	for(U32 i=0; i<voxels.size(); i++) {
		g.addCube(voxels[i], voxels[i] + side);
	}

	this->setup(g);
}
コード例 #7
0
  //
  // BuildSideList
  //
  void SideListBox::BuildSideList()
  {
    DeleteAllItems();

    if (random)
    {
      AddTextItem("Random", TRANSLATE(("#game.sides.random")));
    }

    for (NBinTree<Sides::Side>::Iterator sides(&Sides::GetSides()); *sides; sides++)
    {
      AddTextItem((*sides)->GetName().str, TRANSLATE(((*sides)->GetDescription().str)));
    }
  }
コード例 #8
0
void
CGnuPlotBorderData::
show(std::ostream &os) const
{
  int s = sides().getValue(31);

  if (s)
    os << "border is not drawn" << std::endl;
  else
    os << "border " << s << " is drawn in" <<
          CStrUniqueMatch::valueToString<DrawLayer>(layer()) << " layer with" <<
          " linecolor " << lineStyle() <<
          " linewidth " << lineWidth() <<
          " lineType " << lineType() << std::endl;
}
コード例 #9
0
ファイル: savegame.cpp プロジェクト: mrwillis21/wesnoth
void loadgame::set_gamestate()
{
	gamestate_ = saved_game(load_config_);
#if 0
	//we dont need this code since we always restore our random from [snapshot] or [replay_start] (except for start of scenario saves where we don't have those)
	//also the random_seed isn't stored at toplevel anymore.


	// Get the status of the random in the snapshot.
	// For a replay we need to restore the start only, the replaying gets at
	// proper location.
	// For normal loading also restore the call count.
	int seed = load_config_["random_seed"].to_int(42);
	if(seed == 42){
		config cfg = load_config_.child_or_empty("carryover_sides_start");
		seed = cfg["random_seed"].to_int(42);
	}
	unsigned calls = show_replay_ ? 0 : gamestate_.snapshot["random_calls"].to_int();
	carryover_info sides(gamestate_.carryover_sides_start);
	sides.rng().seed_random(seed, calls);
	gamestate_.carryover_sides_start = sides.to_config();
#endif
}
コード例 #10
0
ファイル: letter.cpp プロジェクト: gottcode/tanglet
void Letter::setColor(const QColor& color) {
	QColor darker = color.darker(106);
	QColor darkest = color.darker(160);

	auto height = boundingRect().height();

	QLinearGradient sides(0, 0, 0, height);
	sides.setColorAt(0, darker);
	sides.setColorAt(1, darkest);
	setBrush(sides);

	QLinearGradient face_border(0, 0, 0, height);
	face_border.setColorAt(0, color);
	face_border.setColorAt(1, darker);
	m_face->setPen(QPen(face_border, 1));

	auto radius = height / 2;
	QRadialGradient face(radius, radius, radius);
	face.setColorAt(0, color);
	face.setColorAt(0.5, color);
	face.setColorAt(1, darker);
	m_face->setBrush(face);
}