Beispiel #1
0
DLLEXP NodeHandle h3dextAddTerrainNode( NodeHandle parent, const char *name, ResHandle heightMapRes,
                                        ResHandle materialRes )
{
    SceneNode *parentNode = Modules::sceneMan().resolveNodeHandle( parent );
    if( parentNode == 0x0 ) return 0;

    Resource *hmapRes = Modules::resMan().resolveResHandle( heightMapRes );
    if( hmapRes == 0x0 || hmapRes->getType() != ResourceTypes::Texture ||
            ((TextureResource *)hmapRes)->getTexType() != TextureTypes::Tex2D ) return 0;

    Resource *matRes =  Modules::resMan().resolveResHandle( materialRes );
    if( matRes == 0x0 || matRes->getType() != ResourceTypes::Material ) return 0;

    Modules::log().writeInfo( "Adding Terrain node '%s'", safeStr( name ).c_str() );

    TerrainNodeTpl tpl( safeStr( name ), (TextureResource *)hmapRes, (MaterialResource *)matRes );
    SceneNode *sn = Modules::sceneMan().findType( SNT_TerrainNode )->factoryFunc( tpl );
    return Modules::sceneMan().addNode( sn, *parentNode );
}
void Mandelcrunchmulti::fill_buffer()
{
    // a vector filled with futures. We will wait for all of them to be finished.
    std::vector<std::future<void>> futures;
    ctpl::thread_pool tpl(this->params->cores);

    // calculate the mandelbrot set line by line. Each line will be pushed to the
    // thread pool as separate job. The id parameter of the lambda function
    // represents the thread id.
    double x = this->params->x;
    double y = this->params->y;
    int iy = 0; /**< row to calculate*/
    for (auto &int_vec : buff) {
        futures.push_back(tpl.push([&int_vec, x, y, iy, this](int id) {
            double ypass = y;  // y value is constant for each row
            double xpass = x;
            if (iy != 0)
                ypass += this->params->ydelta * iy;
            for (unsigned int ix = 0; ix < this->params->xrange; ix++) {
                auto crunched_mandel = this->crunch_mandel_complex(
                    xpass, ypass, this->params->bailout);
                unsigned int its = std::get<0>(crunched_mandel);
                if (this->params->col_algo == constants::COL_ALGO::ESCAPE_TIME)
                    int_vec[ix] = this->iterations_factory(its, 0, 0);
                if (this->params->col_algo == constants::COL_ALGO::CONTINUOUS) {
                    double Zx = std::get<1>(crunched_mandel);
                    double Zy = std::get<2>(crunched_mandel);
                    int_vec[ix] = this->iterations_factory(its, Zx, Zy);
                }
                // increment xpass by xdelta
                xpass += this->params->xdelta;
            }
        }));
        iy++;
    }
    // make sure all jobs are finished
    for (const std::future<void> &f : futures) {
        f.wait();
    }
}
Beispiel #3
0
void API_Create_Index(IndexStruct I)
{
	Index idx(I.index_name);
	idx.initializeIndex(&I);
	idx.createIndex();

	Table tb(I.table_name);
	tb.getTableInfo();
	//Catalog do
	Tuple tpl(I.table_name);
	Attribute at = tb.getAttr(I.attr_name);
	tpl.FetchAll(at.attr_id);
	int listSize = TupleList_IDX.size();
	IndexInfo idxInfo;
	idxInfo.attr_size = at.attr_len;
	idxInfo.indexname = I.index_name;
	idxInfo.maxKeyNum = (4096 - 4 - INDEX_BLOCK_INFO) / (4+at.attr_len);
	Create_Index(idxInfo);
	cout << "Query OK, " << listSize;
	if (listSize!=1)cout << " rows affected." << endl;
	else cout << " row affected." << endl;
	//Index do
}
Beispiel #4
0
int main()
{
  std::vector<TplData> template_data;

  // string without any tags and template without tags -> should show unchanged text
  template_data.push_back(TplData("This is a text that does not contain any replacement tags.",
                                  std::vector<ReplData>(),
                                  "This is a text that does not contain any replacement tags."
                                  ));

  // template with tag, but no replacement data -> should show unchanged text
  template_data.push_back(TplData("This is a text with {..replacement..} tags.",
                                  std::vector<ReplData>(),
                                  "This is a text with {..replacement..} tags."
                                  ));

  // template with replacement tags
  template_data.push_back(TplData("The {..person..} is {..attribute..}.",
                                  std::vector<ReplData>(),
                                  "The hobbit is small."
                                  ));
  template_data.back().replacements.push_back(ReplData("person", "hobbit", false));
  template_data.back().replacements.push_back(ReplData("attribute", "small", false));

  // template with replacement tags that match words in the text -> should not change text
  template_data.push_back(TplData("The person has an object.",
                                  std::vector<ReplData>(),
                                  "The person has an object."
                                  ));
  template_data.back().replacements.push_back(ReplData("person", "hobbit", false));
  template_data.back().replacements.push_back(ReplData("object", "teapot", false));

  // tag with HTML code replacement and disabled "kill HTML" option
  template_data.push_back(TplData("This is {..what..}.",
                                  std::vector<ReplData>(),
                                  "This is <html>."
                                  ));
  template_data.back().replacements.push_back(ReplData("what", "<html>", false));

  // another tag with HTML code replacement and disabled "kill HTML" option
  template_data.push_back(TplData("The information can be found at {..url..}.",
                                  std::vector<ReplData>(),
                                  "The information can be found at http://www.example.com/this/is_not/a.html?page=you&should=request."
                                  ));
  template_data.back().replacements.push_back(ReplData("url", "http://www.example.com/this/is_not/a.html?page=you&should=request", false));

  // tag with HTML code replacement and enabled "kill HTML" option
  template_data.push_back(TplData("This is {..what..}.",
                                  std::vector<ReplData>(),
                                  "This is &lt;html&gt;."
                                  ));
  template_data.back().replacements.push_back(ReplData("what", "<html>", true));

  // another tag with HTML code replacement and enabled "kill HTML" option
  template_data.push_back(TplData("The information can be found at {..url..}.",
                                  std::vector<ReplData>(),
                                  "The information can be found at http://www.example.com/this/is_not/a.html?page=you&amp;should=request."
                                  ));
  template_data.back().replacements.push_back(ReplData("url", "http://www.example.com/this/is_not/a.html?page=you&should=request", true));

  // tag with HTML code replacement and enabled and disabled "kill HTML" option
  template_data.push_back(TplData("This is {..what..} and {..what_else..}.",
                                  std::vector<ReplData>(),
                                  "This is <html> and &lt;html&gt;."
                                  ));
  template_data.back().replacements.push_back(ReplData("what", "<html>", false));
  template_data.back().replacements.push_back(ReplData("what_else", "<html>", true));


  // Run through all the test data and check, whether it does match the expected result.
  unsigned int i;
  for (i=0; i<template_data.size(); ++i)
  {
    MsgTemplate tpl(template_data[i].tpl_text);
    std::vector<ReplData>::const_iterator iter = template_data[i].replacements.begin();
    while (iter != template_data[i].replacements.end())
    {
      tpl.addReplacement(iter->tag, iter->replacement, iter->killHTML);
      ++iter;
    } //while

    const std::string shownText = tpl.show();
    if (shownText != template_data[i].expectedResultText)
    {
       std::cout << "Output of template " << i << " does not match the expected text!\n";
       std::cout << "Output:   \"" << shownText << "\".\n"
                 << "Expected: \"" << template_data[i].expectedResultText << "\".\n";
       return 1;
    }
  } //for i

  //success
  return 0;
}
Beispiel #5
0
inline void init_tp(){
	sbi(DDRB, 1); //LED
	sbi(DDRC, 3); //TP6
	tpl(OFF);
	tp6(LOW);
}