예제 #1
0
void LoopOperator::forwardEstimation(
		boost::ptr_vector<MeshContext>& contextStack ,
		                        FitobCalculator* calc ,
		                        int& stackIndex ,
		                        double& timeStamp ){
	// see if the expression in the condition constant is
	// we use the context on the top of the stack
	MeshContext& actualContext = contextStack[stackIndex];
	FITOB_OUT_LEVEL3(verb(),"LoopOperator::forwardEstimation  Test if it is constant");
	bool constCondition_ = loopCondition_->isConstantExpression(actualContext);
	nrLoop_ = 0;
	if (constCondition_)
	{  // expression is constant, we calculate the LOOP count
		nrLoop_ = (int)(loopCondition_->eval(actualContext.minGlobCoord()));
	}
	else{
		FITOB_ERROR_EXIT(" Expression in the LOOP operator must be a constant (invariant) expression ");
	}

	// call the body N times
	for (int ind = 0; ind < nrLoop_ ; ind++){
		FITOB_OUT_LEVEL3(verb(),"LoopOperator::forwardEstimation bef. :" << stackIndex <<
			  " contextStack.size():" << contextStack.size() << " ind:"<<ind << " nrLoop:" << nrLoop_);
		loopBody_->forwardEstimation( contextStack , calc , stackIndex , timeStamp );
		FITOB_OUT_LEVEL3(verb(),"LoopOperator::forwardEstimation aft. :" << stackIndex <<
			  " contextStack.size():" << contextStack.size() << " ind:"<<ind << " nrLoop:" << nrLoop_);
	}
}
 void operator()(boost::ptr_vector<Variable>& target, Tag tag) {
   target.push_back( new ValueVariable<Tag>() );
   if (localization::MetaInfo<Tag>::has_range) {
     target.push_back( new MinVariable<Tag>() );
     target.push_back( new MaxVariable<Tag>() );
   }
 }
예제 #3
0
파일: main.cpp 프로젝트: fromtherussia/e2d
void renderScene() {
    FrameTimeCounter counter;
    int avgFps = 0;
    int iterations = 0;
    while (!complete) {
        counter.BeginCounting();

        physicsWorld->Simulate(1.0f / 10.0f);

        contextPtr->BeginScene();
        contextPtr->ApplyCamera(*cameraPtr);
        //contextPtr->RenderLine(vec2(0.0f, 0.0f), vec2(100.0f, 100.0f));
        for (int i = 0; i < physicsBodies.size(); ++i) {
            physicsBodies[i].DebugRender(debugRenderer);
        }

        for (int i = 0; i < physicsJoints.size(); ++i) {
            physicsJoints[i].DebugRender(debugRenderer);
        }

        contextPtr->EndScene();



        counter.EndCounting();

        avgFps += counter.GetFps();
        iterations++;
        if (iterations > 10) {
            SetWindowTextA(hWnd, formatString("fps: %d", avgFps / iterations).c_str());
            iterations = 0;
            avgFps = 0;
        }
    }
}
예제 #4
0
파일: Selector.cpp 프로젝트: ncdc/qpid
 void set(const string& id, const qb::Value& value) {
     if (value.type==qb::Value::T_STRING) {
         strings.push_back(new string(*value.s));
         values[id] = strings[strings.size()-1];
     } else {
         values[id] = value;
     }
 }
예제 #5
0
 void set_type(Uint32 type){
     switch (type){
         case man_Pistol: cooldown = 10; damage = 10; ammo.resize(100); break;
         case semi_Pistol: cooldown = 5; damage = 8; ammo.resize(30); break;
         case man_Rifle: cooldown = 15; damage = 20; ammo.resize(8); break;
         case semi_Rifle: cooldown = 8; damage = 18; ammo.resize(30); break;
         case auto_Rifle: cooldown = 2; damage = 15; ammo.resize(50); break;
         default: break;
     }
     version = type;
 }
예제 #6
0
파일: wkb.cpp 프로젝트: GISpecialist/mapnik
bool geometry_utils::from_wkb(boost::ptr_vector<geometry_type>& paths,
                               const char* wkb,
                               unsigned size,
                               wkbFormat format)
{
    std::size_t geom_count = paths.size();
    wkb_reader reader(wkb, size, format);
    reader.read(paths);
    if (paths.size() > geom_count)
        return true;
    return false;
}
예제 #7
0
파일: Functions.cpp 프로젝트: alesapin/lspl
void AddLoopMatcherImpl::operator()( boost::ptr_vector<Matcher> & matchers, uint min, uint max, std::vector<uint> & alternativesCount ) const {
	LoopMatcher * matcher = new LoopMatcher( min, max );

	for ( int i = alternativesCount.size() - 1; i >= 0 ; -- i ) { // Важно!! Здесь перебираем в обратном порядке!
		MatcherContainer * matcherGroup = new MatcherContainer(); // Создаем контейнер для альтернативы

		matcherGroup->addMatchers( matchers.end() - alternativesCount[ i ], matchers.end(), matchers );

		matcher->addAlternative( matcherGroup );
	}

	matchers.push_back( matcher );
}
예제 #8
0
inline bool command::fetch(std::vector<variant>& row)
{
  if (0 == m_hnd.stmt) return false;
  if (m_cols.empty()) columns();

  const sword r(lib::singleton().p_OCIStmtFetch2(m_hnd.stmt, m_hnd.err, 1, OCI_FETCH_NEXT, 1, OCI_DEFAULT));
  if (OCI_NO_DATA == r) return false;
  m_hnd.check(r);

  row.resize(m_cols.size());
  for (size_t i(0); i < m_cols.size(); ++i)
    m_cols[i](row[i]);
  return true;
}
예제 #9
0
파일: command.hpp 프로젝트: respu/brig
inline bool command::fetch(std::vector<variant>& row)
{
  if (!m_stmt) return false;
  if (m_cols.empty()) columns();

  const int r(lib::singleton().p_mysql_stmt_fetch(m_stmt));
  if (MYSQL_NO_DATA == r) return false;
  check(1 != r);

  row.resize(m_cols.size());
  for (size_t i(0); i < m_cols.size(); ++i)
    check(m_cols[i](m_stmt, (unsigned int)i, row[i]) == 0);
  return true;
}
예제 #10
0
파일: command.hpp 프로젝트: respu/brig
inline bool command::fetch(std::vector<variant>& row)
{
  if (lib::error(m_req)) return false;
  if (m_cols.empty()) columns();

  const int r(lib::singleton().p_cci_cursor(m_req, 1, CCI_CURSOR_CURRENT, &m_err));
  if (CCI_ER_NO_MORE_DATA == r) return false;
  check(r);
  check(lib::singleton().p_cci_fetch(m_req, &m_err));

  row.resize(m_cols.size());
  for (size_t i(0); i < m_cols.size(); ++i)
    if (lib::error(m_cols[i](m_req, i, row[i]))) throw std::runtime_error("CUBRID error");
  return true;
}
예제 #11
0
파일: command.hpp 프로젝트: respu/brig
inline void command::close_request()
{
  if (lib::error(m_req)) return;
  m_cols.clear();
  int req(CCI_ER_REQ_HANDLE); std::swap(m_req, req);
  lib::singleton().p_cci_close_req_handle(req);
}
예제 #12
0
 Layout(float s0_snr,float mean_dif_,unsigned char odf_fold = 8,float discrete_scale_ = 0.5,float spin_density_ = 2000.0)
         :mean_dif(mean_dif_),discrete_scale(discrete_scale_),spin_density(spin_density_)
 {
     ti.init(odf_fold);
     for (unsigned int index = 0; index * discrete_scale <= spin_density+1.0; ++index)
         rician_gen.push_back(new RacianNoise((float)index * discrete_scale,spin_density/s0_snr));
 }
예제 #13
0
void AotGraphan::analyzeString( const std::string & str, boost::ptr_vector<Unit> & units ) {
	setupRml();

	try {
		CGraphmatFile file;

		if( !file.LoadDicts() ) { // Загружаем словари
			throw std::logic_error( file.GetLastError() );
		}

		if( !file.LoadStringToGraphan( str ) ) { // Загружаем файл
			throw std::logic_error( file.GetLastError() );
		}

		for( const CGraLine & line : file.GetUnits() ) {
			units.push_back( new Unit( line.GetToken(), line.GetTokenLength(), line.GetInputOffset(), line.IsWordOrNumberOrAbbr() ? Unit::WORD : line.IsPunct() ? Unit::PUNCT : Unit::UNKNOWN ) );
		}
	} catch ( const std::exception & e ) {
		throw e;
	} catch ( const CExpc & e ) {
		throw std::logic_error( "Couldn't init morphology: " + e.m_strCause );
	} catch (...) {
		throw std::logic_error( "Couldn't init morphology due to unknown error" );
	}
}
    /**
     * Function FindRescues
     * Grab all possible RESCUE_CACHE_CANDIDATEs into a vector.
     * @param aRescuer - the working RESCUER instance.
     * @param aCandidates - the vector the will hold the candidates.
     */
    static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
    {
        typedef std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map_t;
        candidate_map_t candidate_map;

        wxString part_name_suffix = aRescuer.GetPartNameSuffix();

        for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
        {
            wxString part_name( each_component->GetPartName() );

            LIB_PART* cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true );
            LIB_PART* lib_match = aRescuer.GetLibs()->FindLibPart( part_name );

            // Test whether there is a conflict
            if( !cache_match || !lib_match )
                continue;
            if( !cache_match->PinsConflictWith( *lib_match, /* aTestNums */ true,
                    /* aTestNames */ true, /* aTestType */ true, /* aTestOrientation */ true,
                    /* aTestLength */ false ))
                continue;

            RESCUE_CACHE_CANDIDATE candidate(
                part_name, part_name + part_name_suffix,
                cache_match, lib_match );
            candidate_map[part_name] = candidate;
        }

        // Now, dump the map into aCandidates
        for( const candidate_map_t::value_type& each_pair : candidate_map )
        {
            aCandidates.push_back( new RESCUE_CACHE_CANDIDATE( each_pair.second ) );
        }
    }
    /**
     * Function FindRescues
     * Grab all possible RESCUE_CASE_CANDIDATES into a vector.
     * @param aRescuer - the working RESCUER instance.
     * @param aCandidates - the vector the will hold the candidates.
     */
    static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates )
    {
        typedef std::map<wxString, RESCUE_CASE_CANDIDATE> candidate_map_t;
        candidate_map_t candidate_map;

        for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) )
        {
            wxString part_name( each_component->GetPartName() );

            LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( part_name );
            std::vector<LIB_ALIAS*> case_insensitive_matches;
            aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name );

            if( case_sensitive_match || !( case_insensitive_matches.size() ) )
                continue;

            RESCUE_CASE_CANDIDATE candidate(
                part_name, case_insensitive_matches[0]->GetName(),
                case_insensitive_matches[0]->GetPart() );
            candidate_map[part_name] = candidate;
        }

        // Now, dump the map into aCandidates
        for( const candidate_map_t::value_type& each_pair : candidate_map )
        {
            aCandidates.push_back( new RESCUE_CASE_CANDIDATE( each_pair.second ) );
        }
    }
예제 #16
0
파일: Functions.cpp 프로젝트: alesapin/lspl
void AddNormalizationRestrictionImpl::operator()( boost::ptr_vector<Restriction> & restrictions ) const {
	AgreementRestriction *agrRestr = new AgreementRestriction();
	agrRestr->addArgument(new AttributeExpression(new CurrentAnnotationExpression(), lspl::text::attributes::AttributeKey::BASE));
	agrRestr->addArgument(new ConstantExpression("1"));
	Restriction * restriction = agrRestr;
	restrictions.push_back( restriction );
}
예제 #17
0
파일: wkb.cpp 프로젝트: GISpecialist/mapnik
 void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths)
 {
     int num_rings = read_integer();
     if (num_rings > 0)
     {
         std::unique_ptr<geometry_type> poly(new geometry_type(geometry_type::types::Polygon));
         for (int i = 0; i < num_rings; ++i)
         {
             int num_points = read_integer();
             if (num_points > 0)
             {
                 CoordinateArray ar(num_points);
                 read_coords_xyz(ar);
                 poly->move_to(ar[0].x, ar[0].y);
                 for (int j = 1; j < num_points; ++j)
                 {
                     poly->line_to(ar[j].x, ar[j].y);
                 }
                 poly->close_path();
             }
         }
         if (poly->size() > 2) // ignore if polygon has less than 3 vertices
             paths.push_back(poly.release());
     }
 }
예제 #18
0
파일: Projector.cpp 프로젝트: salilab/imp
void Projector::compute_projections(boost::ptr_vector<Projection>& projections,
                                    int image_size) const {

  // get coordinates
  IMP::algebra::Vector3Ds points(particles_.size());
  for (unsigned int i = 0; i < particles_.size(); i++) {
    points[i] = core::XYZ(particles_[i]).get_coordinates();
  }

  int axis_size = estimate_image_size(points);
  if (axis_size <= image_size) axis_size = image_size;

  // storage for rotated points
  IMP::algebra::Vector3Ds rotated_points(points.size());
  IMP::algebra::Rotation3Ds rotations;
  IMP::algebra::Vector3Ds axes;
  projection_sphere_.get_all_rotations_and_axes(rotations, axes);

  for (unsigned int i = 0; i<rotations.size(); i++) {
    // rotate points
    for (unsigned int point_index = 0; point_index < points.size();
         point_index++) {
      rotated_points[point_index] = rotations[i] * points[point_index];
    }
    // project
    IMP_UNIQUE_PTR<Projection> p(new Projection(rotated_points, mass_,
                                                pixel_size_, resolution_,
                                                axis_size));
    p->set_rotation(rotations[i]);
    p->set_axis(axes[i]);
    p->set_id(i);
    projections.push_back(p.release());
  }
}
예제 #19
0
double distance::getEuclidean2(boost::ptr_vector<double>& v1, boost::ptr_vector<double>& v2)
{
	double euclidean = 0;
	int n = v1.size() == v2.size() ? v1.size() : 0;
	if (n > 0)
	{
		for (boost::ptr_vector<double>::iterator it1 = v1.begin(), it2 = v2.begin(); it1 != v1.end(), it2 != v2.end(); it1++, it2++)
		{
			euclidean += (*it1 - *it2)*(*it1 - *it2);
		}
		euclidean = sqrt(euclidean);
		return euclidean;
	}
	else
		return (double)-1;
}
예제 #20
0
std::auto_ptr<T> release_ptr( T *p, boost::ptr_vector<T,C,A>& vec)
{
    std::auto_ptr<T> result;

	for( typename boost::ptr_vector<T,C,A>::iterator it( vec.begin()), e( vec.end()); it != e; ++it)
	{
		if( &(*it) == p)
		{
			typename boost::ptr_vector<T,C,A>::auto_type ptr = vec.release( it);
            result.reset( ptr.release());
            break;
		}
	}

	return result;
}
예제 #21
0
inline std::vector<std::string> command::columns()
{
  using namespace std;
  using namespace brig::unicode;

  vector<string> cols;
  if (0 == m_hnd.stmt) return cols;
  m_cols.clear();
  ub4 count(0);
  m_hnd.check(lib::singleton().p_OCIAttrGet(m_hnd.stmt, OCI_HTYPE_STMT, &count, 0, OCI_ATTR_PARAM_COUNT, m_hnd.err));
  for (ub4 i(0); i < count; ++i)
  {
    OCIParam *dsc(0);
    m_hnd.check(lib::singleton().p_OCIParamGet(m_hnd.stmt, OCI_HTYPE_STMT, m_hnd.err, (void**)&dsc, i + 1));
    try
    {

      ub2 data_type(0), size(0);
      sb2 precision(0);
      sb1 scale(-1);
      ub1 charset_form(SQLCS_NCHAR);
      utext *name(0), *nty_schema(0), *nty(0);
      ub4 name_len(0), nty_schema_len(0), nty_len(0);

      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &name, &name_len, OCI_ATTR_NAME, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &data_type, 0, OCI_ATTR_DATA_TYPE, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &size, 0, OCI_ATTR_DATA_SIZE, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &precision, 0, OCI_ATTR_PRECISION, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &scale, 0, OCI_ATTR_SCALE, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &charset_form, 0, OCI_ATTR_CHARSET_FORM, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &nty_schema, &nty_schema_len, OCI_ATTR_SCHEMA_NAME, m_hnd.err));
      m_hnd.check(lib::singleton().p_OCIAttrGet(dsc, OCI_DTYPE_PARAM, &nty, &nty_len, OCI_ATTR_TYPE_NAME, m_hnd.err));

      identifier nty_lcase = { transform<char>(nty_schema, lower_case), transform<char>(nty, lower_case), "" };

      m_cols.push_back(define_factory(&m_hnd, i + 1, data_type, size, precision, scale, charset_form, nty_lcase));
      cols.push_back(transform<char>(name));

    }
    catch (const exception&)  { handles::free_descriptor((void**)&dsc, OCI_DTYPE_PARAM); throw; }
    handles::free_descriptor((void**)&dsc, OCI_DTYPE_PARAM);
  }

  ub4 rows = ub4(PageSize);
  m_hnd.check(lib::singleton().p_OCIAttrSet(m_hnd.stmt, OCI_HTYPE_STMT, &rows, 0, OCI_ATTR_PREFETCH_ROWS, m_hnd.err));
  return cols;
}
예제 #22
0
static void grid2utf(T const& grid_type,
                     boost::ptr_vector<uint16_t> & lines,
                     std::vector<typename T::lookup_type>& key_order,
                     unsigned int resolution)
{
    typedef std::map< typename T::lookup_type, typename T::value_type> keys_type;
    typedef typename keys_type::const_iterator keys_iterator;

    typename T::feature_key_type const& feature_keys = grid_type.get_feature_keys();
    typename T::feature_key_type::const_iterator feature_pos;

    keys_type keys;
    // start counting at utf8 codepoint 32, aka space character
    uint16_t codepoint = 32;

    unsigned array_size = std::ceil(grid_type.width()/static_cast<float>(resolution));
    for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
    {
        uint16_t idx = 0;
        uint16_t* line = new uint16_t[array_size];
        typename T::value_type const* row = grid_type.getRow(y);
        for (unsigned x = 0; x < grid_type.width(); x=x+resolution)
        {
            // todo - this lookup is expensive
            typename T::value_type feature_id = row[x];
            feature_pos = feature_keys.find(feature_id);
            if (feature_pos != feature_keys.end())
            {
                typename T::lookup_type const& val = feature_pos->second;
                keys_iterator key_pos = keys.find(val);
                if (key_pos == keys.end())
                {
                    // Create a new entry for this key. Skip the codepoints that
                    // can't be encoded directly in JSON.
                    if (codepoint == 34) ++codepoint;      // Skip "
                    else if (codepoint == 92) ++codepoint; // Skip backslash
                    if (feature_id == mapnik::grid::base_mask)
                    {
                        keys[""] = codepoint;
                        key_order.push_back("");
                    }
                    else
                    {
                        keys[val] = codepoint;
                        key_order.push_back(val);
                    }
                    line[idx++] = static_cast<uint16_t>(codepoint);
                    ++codepoint;
                }
                else
                {
                    line[idx++] = static_cast<uint16_t>(key_pos->second);
                }
            }
            // else, shouldn't get here...
        }
        lines.push_back(line);
    }
}
예제 #23
0
파일: Functions.cpp 프로젝트: alesapin/lspl
void AddWordMatcherImpl::operator()( boost::ptr_vector<Matcher> & matchers, const std::string & base, SpeechPart speechPart, uint index, boost::ptr_vector< Restriction > & restrictions ) const {
   	Matcher * matcher = new WordMatcher( base, speechPart );

   	matcher->variable = Variable( speechPart, index );
   	matcher->addRestrictions( restrictions );

   	matchers.push_back( matcher );
}
예제 #24
0
파일: command.hpp 프로젝트: respu/brig
inline void command::close_stmt()
{
  if (!m_stmt) return;
  m_binds.clear();
  m_cols.clear();
  MYSQL_STMT* stmt(0); std::swap(stmt, m_stmt);
  lib::singleton().p_mysql_stmt_close(stmt);
}
예제 #25
0
파일: group.cpp 프로젝트: cm277/ebftpd
void GetAll(boost::ptr_vector<acl::Group>& groups)
{
  groups.clear();

  QueryResults results;
  mongo::Query query;
  boost::unique_future<bool> future;
  TaskPtr task(new db::Select("groups", query, results, future));
  Pool::Queue(task);

  future.wait();

  if (results.size() == 0) return;

  for (auto& obj: results)
    groups.push_back(bson::Group::Unserialize(obj));
}
예제 #26
0
파일: wkb.cpp 프로젝트: rjw57/mapnik
 void read_point(boost::ptr_vector<geometry_type> & paths)
 {
     geometry_type* pt = new geometry_type(Point);
     double x = read_double();
     double y = read_double();
     pt->move_to(x, y);
     paths.push_back(pt);
 }
예제 #27
0
파일: wkb.cpp 프로젝트: GISpecialist/mapnik
 void read_point(boost::ptr_vector<geometry_type> & paths)
 {
     double x = read_double();
     double y = read_double();
     std::unique_ptr<geometry_type> pt(new geometry_type(geometry_type::types::Point));
     pt->move_to(x, y);
     paths.push_back(pt.release());
 }
예제 #28
0
파일: command.hpp 프로젝트: respu/brig
inline std::vector<std::string> command::columns()
{
  std::vector<std::string> cols;
  if (lib::error(m_req)) return cols;

  m_cols.clear();
  T_CCI_SQLX_CMD cmd_type;
  int col_count(0);
  T_CCI_COL_INFO* col_info(lib::singleton().p_cci_get_result_info(m_req, &cmd_type, &col_count));
  if (!col_info) throw std::runtime_error("CUBRID error");

  for (int i(1); i <= col_count; ++i)
  {
    m_cols.push_back(get_data_factory(CCI_GET_RESULT_INFO_TYPE(col_info, i)));
    cols.push_back(CCI_GET_RESULT_INFO_NAME(col_info, i));
  }
  return cols;
}
예제 #29
0
파일: Functions.cpp 프로젝트: alesapin/lspl
void AddAlternativeDefinitionImpl::operator()( boost::ptr_vector<Alternative> & alts, boost::ptr_vector<Matcher> & matchers, boost::ptr_map<AttributeKey,Expression> & bindings, const std::string & source, const std::string & transformSource ) const {
	Alternative * alternative = new Alternative( source, transformSource ); // Добавляем новую альтернативу к шаблону

	alternative->addMatchers( matchers ); // Добавляем сопоставители
	alternative->addBindings( bindings ); // Добавляем связывания
	alternative->updateDependencies(); // Обновляем зависимости альтернативы

	alts.push_back( alternative );
}
예제 #30
0
void MultiDispatch::parseParameters(
    const std::vector<std::string>& input,
    boost::ptr_vector<ExpressionPiece>& output) {
  for (vector<string>::const_iterator it = input.begin(); it != input.end();
       ++it) {
    const char* src = it->c_str();
    output.push_back(get_complex_param(src));
  }
}