Пример #1
0
static void
render_scene (APP_STATE_T * state)
{
    update_model (state);
    redraw_scene (state);
    TRACE_VC_MEMORY_ONCE_FOR_ID ("after render_scene", gid2);
}
Пример #2
0
/*
* The main procedure is similar to the main found in ARITH1E.C. It has
* to initialize the coder and the model. It then sits in a loop reading
* input symbols and encoding them. One difference is that every 256
* symbols a compression check is performed. If the compression ratio
* falls below 10%, a flush character is encoded. This flushes the encod
* ing model, and will cause the decoder to flush its model when the 
* file is being expanded. The second difference is that each symbol is
* repeatedly encoded until a successful encoding occurs. When trying to
* encode a character in a particular order, the model may have to
* transmit an ESCAPE character. If this is the case, the character has
* to be retransmitted using a lower order. This process repeats until a
* successful match is found of the symbol in a particular context.
* Usually this means going down no further than the order -1 model.
* However, the FLUSH and DONE symbols drop back to the order -2 model.
*
*/
void CompressFile(FILE *input,BIT_FILE *output,int argc,char *argv[])
{
 SYMBOL s;
 int c;
 int escaped;
 int flush = 0;
 long int text_count = 0;
 initialize_options( argc, argv );
 initialize_model();
 initialize_arithmetic_encoder();
 for ( ; ; ) {
 if ( ( ++text_count & 0x0ff ) == 0 )
 	flush = check_compression( input, output );
 if ( !flush )
 	c = getc( input );
 else
 	c = FLUSH;
 if ( c == EOF )
 	c = DONE;
 do {
	 escaped = convert_int_to_symbol( c, &s);
	 encode_symbol( output, &s );
 } while ( escaped );
 if ( c == DONE )
 	break;
 if ( c == FLUSH ) {
	 flush_model();
	 flush = 0;
 }
 update_model( c );
 add_character_to_model( c );
 }
 flush_arithmetic_encoder( output );
}
Пример #3
0
int main ()
{
   bcm_host_init();
   printf("Note: ensure you have sufficient gpu_mem configured\n");

   // Clear application state
   memset( state, 0, sizeof( *state ) );
      
   // Start OGLES
   init_ogl(state);

   // Setup the model world
   init_model_proj(state);

   // initialise the OGLES texture(s)
   init_textures(state);

   while (!terminate)
   {
      update_model(state);
      redraw_scene(state);
   }
   exit_func();
   return 0;
}
Пример #4
0
/*
* The main loop for expansion is very similar to the expansion
* routine used in the simpler compression program, ARITH1E.C. The
* routine first has to initialize the the arithmetic coder and the
* model. The decompression loop differs in a couple of respect.
* First of all, it handles the special ESCAPE character, by
* removing them from the input bit stream but just throwing them
* away otherwise. Secondly, it handles the special FLUSH character.
* Once the main decoding loop is done, the cleanup code is called,
* and the program exits.
*
*/
void ExpandFile(BIT_FILE *input,FILE *output,int argc,char *argv[])
{
 SYMBOL s;
 int c;
 int count;
 initialize_options( argc, argv );
 initialize_model();
 initialize_arithmetic_decoder( input );
 for ( ; ; ) {
	 do {
	 get_symbol_scale( &s );
	 count = get_current_count( &s );
	 c = convert_symbol_to_int( count, &s );
	 remove_symbol_from_stream( input, &s );
	 } while ( c == ESCAPE );
	 if ( c == DONE )
	 	break;
	 if ( c != FLUSH )
	 	putc( (char) c, output );
	 else
	 	flush_model();
	 update_model( c );
	 add_character_to_model( c );
 }
}
Пример #5
0
RFO::RFO()
{
  version=0.1f;
  m_cols = new ModelColumns();
  m_model = Gtk::TreeStore::create (*m_cols);
  update_model();
}
Пример #6
0
CExport double calculate_VR(void* ptr, void** p) {
    if (!update_model(ptr, p)) {
        show_error("calculate_VR");
        return DBL_NAN;
    }
    return ((SphereModel*)ptr)->calculate_VR();
}
Пример #7
0
CExport void calculate_qxqy(void* ptr, void** p, int nq, double iq[], double qx[], double qy[]) {
    if (!update_model(ptr, p))
        show_error("calculate_qxqy", nq, iq);
    else
        while (nq-- != 0)
            *iq++ = (*(SphereModel*)ptr)(*qx++, *qy++);
}
Пример #8
0
void RFO::clear()
{
  Objects.clear();
  version = 0.0f;
  m_filename = "";
  transform3D.identity();
  update_model();
}
Пример #9
0
void SelectWidget::select_index(int index) {
    selected_index = index;
    if (selected_index >= 0) {
        SelectWidgetItem *item = &items.at(selected_index);
        label.set_text(item->name);
        label.update();
        update_model();
    }
}
Пример #10
0
void RFO::DeleteSelected(Gtk::TreeModel::iterator &iter)
{
  int i = (*iter)[m_cols->m_object];
  int j = (*iter)[m_cols->m_file];

  if (j >= 0)
    Objects[i].files.erase (Objects[i].files.begin() + j);
  else if (i >= 0)
    Objects.erase (Objects.begin() + i);
  update_model();
}
Пример #11
0
void RFO::DeleteSelected(Gtk::TreeModel::iterator &iter)
{
  RFO_Object *object;
  RFO_File *file;
  get_selected_stl (iter, object, file);
  if (file != NULL)
    Objects[object->idx].files.erase (Objects[object->idx].files.begin() + file->idx);
  else if (object != NULL)
    Objects.erase (Objects.begin() + object->idx);
  update_model();
}
Пример #12
0
/***********************************
 * Decompress a 32 bit Integer
 ***********************************/
uint32_t decompress_int(Arithmetic_stream as, stream_model *PA){
    
    uint32_t Byte = 0, prevByte = 0, x = 0;
    
    // we encode byte per byte i.e. x = [B0 B1 B2 B3] (msB first)
    
    // Read B0 the Arithmetic Stream using the alphabet model
    Byte = read_value_from_as(as, PA[0]);
    // Update model
    update_model(PA[0], Byte);
    prevByte = Byte;
    
     x = Byte << 24;
    
    // Read B1 from the Arithmetic Stream using the alphabet model
    Byte = read_value_from_as(as, PA[1]);
    // Update model
    update_model(PA[1], Byte);
    prevByte = Byte;
    
    x |= Byte << 16;
    
    // Send B2 to the Arithmetic Stream using the alphabet model
    Byte = read_value_from_as(as, PA[2]);
    // Update model
    update_model(PA[2], Byte);
    prevByte = Byte;
    
    x |= Byte << 8;
    
    // Send B3 to the Arithmetic Stream using the alphabet model
    Byte = read_value_from_as(as, PA[3]);
    // Update model
    update_model(PA[3], Byte);
    
     x |= Byte;
    
    return x;
    
    
}
Пример #13
0
static void encode_arith_symbol(MscCoderArithModel *arithModel, PutBitContext *pb, int value) {
	MscCoderArithSymbol arithSymbol;

	// convert value to range symbol
	convert_int_to_symbol(arithModel, value, &arithSymbol);

	// encode symbol by arith encoder
	encode_symbol(pb, &arithSymbol);

	// update arithmetic model
	update_model(arithModel, value);
}
HandModel::HandModel( const vector<float>& values ) {
  BoundedParameter<float> par;
  par.l = -FLT_MAX;
  par.u = FLT_MAX;

  for ( unsigned int i = 0; i < values.size(); i++ ) {
    par.v = values[i];
    params.push_back( par );
  }

  update_model();
}
Пример #15
0
// calculations
CExport void calculate_q(void* ptr, void** p, int nq, double iq[], double q[]) {
    if (!update_model(ptr, p))
        show_error("calculate_q", nq, iq);
    else
{
std::cout << "err q" << " " << nq << " " << q << " " << iq << std::endl;
std::cout << "err q" << " " << nq << " " << *(q) << " " << *(iq) << std::endl; 
        while (nq-- != 0)
{
            *iq++ = (*(SphereModel*)ptr)(*q++);
std::cout << "err q" << " " << nq << " " << q << " " << iq << std::endl;
std::cout << "err q" << " " << nq << " " << q[-1] << " " << iq[-1] << std::endl; }
std::cout << "done q" << std::endl; }
}
Пример #16
0
/***********************************
 * Compress a 32 bit Integer
 ***********************************/
uint32_t compress_int(Arithmetic_stream as, stream_model *PA, uint32_t x){
    
    uint32_t Byte = 0, prevByte = 0;
    
    // we encode byte per byte i.e. x = [B0 B1 B2 B3] (msB first)
    
    // Send B0 to the Arithmetic Stream using the alphabet model
    Byte = x >> 24;
    send_value_to_as(as, PA[0], Byte);
    // Update model
    update_model(PA[0], Byte);
    prevByte = Byte;
    
    // Send B1 to the Arithmetic Stream using the alphabet model
    Byte = (x & 0x00ff0000) >> 16;
    send_value_to_as(as, PA[1], Byte);
    // Update model
    update_model(PA[1], Byte);
    prevByte = Byte;
    
    // Send B2 to the Arithmetic Stream using the alphabet model
    Byte = (x & 0x0000ff00) >> 8;
    send_value_to_as(as, PA[2], Byte);
    // Update model
    update_model(PA[2], Byte);
    prevByte = Byte;
    
    // Send B3 to the Arithmetic Stream using the alphabet model
    Byte = (x & 0x000000ff);
    send_value_to_as(as, PA[3], Byte);
    // Update model
    update_model(PA[3], Byte);
    
    return 1;
    
    
}
Пример #17
0
//���������������������������������������������������������������������������
// Lander - run
//���������������������������������������������������������������������������
void Lander::step ()
{
    if (!remote)
    {
        process_events ();
        update_model ();

        // If we're on the network, let everyone know our new position
        if (Net && Net->is_active())
        {
            LanderPositionData pd (*this);
            Net->broadcast (player_id, &pd, sizeof (pd));
        }
    }
}
Пример #18
0
Gtk::TreePath RFO::createFile(RFO_Object *parent, const Slicer &stl,
			      std::string location)
{
  RFO_File r;
  r.stl = stl;
  r.location = location;
  parent->files.push_back(r);
  update_model();
  Gtk::TreePath path;
  path.push_back (0); // root
  path.push_back (parent->idx);
  path.push_back (parent->files.size() - 1);

  return path;
}
Пример #19
0
bool ChessFieldModel::load_game(QUrl file)
{
    QString qstr = file.path();
    QByteArray ba = qstr.toLatin1();
    const char *fname = ba.data();
    if(!fname || !*fname) {
        return false;
    }
    std::ifstream in(fname+1);// because of trailing '/'
    if(in) {
        bool ret = m_chess_board.load_game(in);
        in.close();
        update_model();
        return ret;
    }
    return false;
}
Пример #20
0
static int decode_arith_symbol(MscCoderArithModel *arithModel, GetBitContext *gb) {
	MscCoderArithSymbol arithSymbol;
	int count, value;

	// get range symbol
	get_symbol_scale(arithModel, &arithSymbol);

	// get value for symbol
	count = get_current_count(&arithSymbol);
	value = convert_symbol_to_int(arithModel, count, &arithSymbol);

	// remove symbol from stream
	remove_symbol_from_stream(gb, &arithSymbol);

	// update arithmetic coder model
	update_model(arithModel, value);

	return value;
}
Пример #21
0
SelectWidget::SelectWidget(GuiWindow *gui_window) :
    Widget(gui_window),
    label(gui_window->gui)
{
    arrow_icon_img = gui->img_caret_down;
    padding_left = 4;
    padding_right = 4;
    padding_top = 4;
    padding_bottom = 4;
    icon_spacing = 4;
    hovering = false;
    text_color = color_fg_text();
    selected_index = -1;

    context_menu = create<MenuWidgetItem>(gui_window);
    context_menu_open = false;

    update_model();
}
Пример #22
0
arma::cube ung_ssm::predict_sample(const arma::mat& theta_posterior,
  const arma::mat& alpha, const arma::uvec& counts,
  const unsigned int predict_type, const unsigned int nsim) {
  
  unsigned int d = 1;
  if (predict_type == 3) d = m;
  
  arma::mat expanded_theta = rep_mat(theta_posterior, counts);
  arma::mat expanded_alpha = rep_mat(alpha, counts);
  unsigned int n_samples = expanded_theta.n_cols;
  arma::cube sample(d, n, nsim * n_samples);
  for (unsigned int i = 0; i < n_samples; i++) {
    update_model(expanded_theta.col(i));
    a1 = expanded_alpha.col(i);
    sample.slices(i * nsim, (i + 1) * nsim - 1) =
      sample_model(predict_type, nsim);
    
  }
  return sample;
}
Пример #23
0
unsigned int do_deari(unsigned int insize)
{
  in_size = (unsigned int)insize;    
  
  in_pos = 0;
  deari_pos = 0;

  start_model();                              /* Set up other modules.    */
  start_inputing_bits();
  start_decoding();
  for (;;) {                                  /* Loop through characters. */
    int ch; int symbol;
    symbol = decode_symbol(cum_freq);       /* Decode next symbol.      */
    if (symbol==EOF_symbol) break;          /* Exit loop if EOF symbol. */
    ch = index_to_char[symbol];             /* Translate to a character.*/
    deari[deari_pos++]=(unsigned char)ch;   /* Write that character.    */
    update_model(symbol);                   /* Update the model.        */
  }
  
  return deari_pos;
}
Пример #24
0
TextWidget::TextWidget(GuiWindow *gui_window) :
    Widget(gui_window),
    _userdata(NULL),
    _label(gui),
    _padding_left(4),
    _padding_right(4),
    _padding_top(4),
    _padding_bottom(4),
    _text_color(0.0f, 0.0f, 0.0f, 1.0f),
    _sel_text_color(1.0f, 1.0f, 1.0f, 1.0f),
    _background_color(0.828f, 0.862f, 0.916f, 1.0f),
    _hover_color(0.7f, 0.7f, 0.8f, 1.0f),
    _selection_color(color_selection()),
    _cursor_color(0.1216f, 0.149f, 0.2078, 1.0f),
    _auto_size(false),
    fixed_min_width(0),
    fixed_max_width(200),
    _icon_size_w(16),
    _icon_size_h(16),
    _icon_margin(4),
    _cursor_start(0),
    _cursor_end(0),
    _select_down(false),
    _have_focus(false),
    _scroll_x(0),
    _placeholder_label(gui),
    _placeholder_color(0.4f, 0.4f, 0.4f, 1.0f),
    _mouse_down_dbl(false),
    _background_on(true),
    _hover_on(false),
    _text_interaction_on(true),
    _icon_img(NULL),
    _hovering(false),
    _on_key_event(default_on_key_event),
    _on_text_change_event(default_on_text_change_event),
    _on_mouse_event(default_on_mouse_event)
{
    update_model();
}
Пример #25
0
void TextWidget::scroll_index_into_view(int char_index) {
    if (_auto_size) {
        _scroll_x = 0;
    } else {
        int x, y;
        pos_at_cursor(char_index, x, y);

        int cursor_too_far_right = x - (width - _padding_right);
        if (cursor_too_far_right > 0)
            _scroll_x += cursor_too_far_right;

        int cursor_too_far_left = -x + label_start_x();
        if (cursor_too_far_left > 0)
            _scroll_x -= cursor_too_far_left;

        int max_scroll_x = max(0, _label.width() - (width - label_start_x() - _padding_right));
        _scroll_x = clamp(0, _scroll_x, max_scroll_x);
    }

    update_model();
    update_selection_model();
}
Пример #26
0
bool GurobiProgram::solve(bool relax){
    //cout << "\n Presolve = " << grb_env->get(GRB_IntParam_Presolve) << endl;
//    print_constraints();
    if (relax) relax_model();
//    relax_model();
    grb_mod->optimize();
//    grb_mod->write("~/Gqc_ots.lp");
    if (grb_mod->get(GRB_IntAttr_Status) != 2) {
        cerr << "\nModel has not been solved to optimality, error code = " << grb_mod->get(GRB_IntAttr_Status) << endl;
        return false;
    }
    update_model();
    //grb_mod->write("/home/kbestuzheva/PowerTools--/qc_ots.lp");
    GRBVar* gvars = grb_mod->getVars();
    for(int i = 0; i < grb_mod->get(GRB_IntAttr_NumVars); ++i) {
//        cout << gvars[i].get(GRB_StringAttr_VarName) << "  " << gvars[i].get(GRB_DoubleAttr_X) << endl;
        if (gvars[i].get(GRB_CharAttr_VType)==GRB_BINARY) {
            cout << gvars[i].get(GRB_StringAttr_VarName) << "  ";
            cout << gvars[i].get(GRB_DoubleAttr_X);
            cout << "\n";
        }
    }
//    cout << "\n***** Optimal Objective = " << grb_mod->get(GRB_DoubleAttr_ObjVal) << " *****\n";
    model->_opt = grb_mod->get(GRB_DoubleAttr_ObjVal);
    if (grb_mod->get(GRB_IntAttr_IsMIP)) {
        cout.setf(ios::fixed);
        cout.precision(3);
        cout << "Results: " << grb_mod->get(GRB_DoubleAttr_ObjVal) << " & ";
        cout.precision(4);
    	cout << (grb_mod->get(GRB_DoubleAttr_MIPGap))*100 << "% & ";
    	cout.precision(0);
    	cout << grb_mod->get(GRB_DoubleAttr_NodeCount) << " & ";
        cout.precision(2);
        cout << grb_mod->get(GRB_DoubleAttr_Runtime) << " & " << endl;
    }
    delete[] gvars;
    return true;
}
void model::update(double time)
{
    view::update(time);
	
    create_phys();

	double dt = time - (last_update_ ? *last_update_ : 0);
    if (!cg::eq_zero(dt))
    {

        update_model(time, dt);

        sync_phys(dt);

        sync_nodes_manager(dt);
        
        update_contact_effects(time);

    }

    last_update_ = time;

}
Пример #28
0
int
mug_msg_list_view_query (MugMsgListView * self, const char *query)
{
	MugMsgListViewPrivate *priv;
	gboolean rv;

	g_return_val_if_fail (MUG_IS_MSG_LIST_VIEW (self), FALSE);

	priv = MUG_MSG_LIST_VIEW_GET_PRIVATE (self);
	gtk_list_store_clear (priv->_store);

	g_free (priv->_query);
	priv->_query = query ? g_strdup (query) : NULL;

	if (!query)
		return TRUE;

	rv = update_model (priv->_store, priv->_xpath, query, self);

	gtk_tree_view_columns_autosize (GTK_TREE_VIEW (self));

	return rv;
}
Пример #29
0
void model::update(double time)
{
    view::update(time);
	
	if(start_)
	{
		start_();
		start_.clear();
	}

	double dt = time - (last_update_ ? *last_update_ : 0);
    if (!cg::eq_zero(dt))
    {

        update_model(time, dt);
#if 0
        if (!manual_controls_)
#endif
        sync_phys(dt);
#if 0
        else
        {
            cg::geo_base_3 base = phys_->get_base(*phys_zone_); 
            decart_position cur_pos = phys_vehicle_->get_position();
            geo_position cur_glb_pos(cur_pos, base);
            set_state(state_t(cur_glb_pos.pos, cur_pos.orien.get_course(), 0)); 
        }
#endif


        sync_nodes_manager(dt);

    }

    last_update_ = time;

}
Пример #30
0
int _main ()
{
   bcm_host_init();

   // Clear application state
   memset( state, 0, sizeof( *state ) );
      
   // Start OGLES
   init_ogl(state);

   // Setup the model world
   init_model_proj(state);

   // initialise the OGLES texture(s)
   init_textures(state);

   while (!terminate)
   {
      update_model(state);
      redraw_scene(state);
   }
   exit_func();
   return 0;
}