TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
     // start coding at 10:51
     if (inorder.size() == 0) return NULL;
     // if (inorder.size() == 1) return new TreeNode(inorder[0]);
     int i;
     for (i = 0; i < inorder.size(); i++)
         if (preorder[0] == inorder[i]) break;
     TreeNode* root = new TreeNode(preorder[0]);
     preorder.erase(preorder.begin());
     vector<int> li (inorder.begin(), inorder.begin()+i);
     vector<int> ri;
     if (i < inorder.size()) {vector<int> temp (inorder.begin()+i+1, inorder.end()); ri = temp;} // make sure here
     root->left  = buildTree(preorder, li);
     root->right = buildTree(preorder, ri);
     return root;
 }
Beispiel #2
0
bool goto_mp_wait(saved_game& state, const config& game_config, wesnothd_connection* connection, bool observe)
{
	lobby_info li(game_config, std::vector<std::string>());

	gui2::dialogs::mp_join_game dlg(state, li, *connection, false, observe);

	if(!dlg.fetch_game_config()) {
		connection->send_data(config("leave_game"));
		return false;
	}

	if(dlg.started()) {
		return true;
	}

	return dlg.show();
}
Beispiel #3
0
static QString htmlAttribsToString(const HtmlAttribList &attribs)
{
  QString result;
  HtmlAttribListIterator li(attribs);
  HtmlAttrib *att;
  for (li.toFirst();(att=li.current());++li)
  {
    if (!att->value.isEmpty())  // ignore attribute without values as they
                                // are not XHTML compliant
    {
      result+=" ";
      result+=att->name;
      result+="=\""+convertToXML(att->value)+"\"";
    }
  }
  return result;
}
Beispiel #4
0
/// \brief One dimensional midpoint displacement fractal.
///
/// Size must be a power of 2.
/// Falloff is the decay of displacement as the fractal is refined.
/// Array is size + 1 long. array[0] and array[size] are filled
/// with the control points for the fractal.
void Segment::fill1d(BasePoint const & l, BasePoint const &h,
                     float *array) const
{
  array[0] = l.height();
  array[m_res] = h.height();
  LinInterp li(m_res, l.roughness(), h.roughness());

  // seed the RNG.
  // The RNG is seeded only once for the line and the seed is based on the
  // two endpoints -because they are the common parameters for two adjoining
  // tiles
  //srand((l.seed() * 1000 + h.seed()));
  WFMath::MTRand::uint32 seed[2] = { l.seed(), h.seed() };
  WFMath::MTRand rng(seed, 2);

  // stride is used to step across the array in a deterministic fashion
  // effectively we do the 1/2  point, then the 1/4 points, then the 1/8th
  // points etc. this has to be the same order every time because we call
  // on the RNG at every point
  decltype(getResolution()) stride = m_res / 2;

  // depth is used to indicate what level we are on. the displacement is
  // reduced each time we traverse the array.
  float depth = 1;

  while (stride)
  {
    for (decltype(getResolution()) i = stride; i < m_res; i += stride * 2)
    {
      auto hh = array[i - stride];
      auto lh = array[i + stride];
      auto hd = std::fabs(hh - lh);
      auto roughness = li.calc(i);

      //eliminate the problem where hd is nearly zero, leaving a flat section.
      if ((hd * 100.f) < roughness)
      {
        hd += 0.05f * roughness;
      }

      array[i] = ((hh + lh) / 2.f) + randHalf(rng) * roughness  * hd / (1.f + std::pow(depth, BasePoint::FALLOFF));
    }
    stride >>= 1;
    depth++;
  }
}
Beispiel #5
0
void qlist()
{
  QList<QString> l;
  QLinkedList<QString> ll;

  l << "1" << "2" << "3";
  ll << "1" << "2" << "3";

  //qDebug() << l[0];

  QLinkedListIterator<QString> li(ll);
  while(li.hasNext())
    qDebug() << li.next();

  //<< ll;

}
int main()
{
    // Initialize list with random integers
    std::vector<int> vec(40, 0);
    std::iota(std::begin(vec), std::end(vec), 0);
    std::mt19937_64 engine(std::time(nullptr));
    std::shuffle(std::begin(vec), std::end(vec), engine);
    example::list<int> li(std::begin(vec), std::end(vec));

    // Sort with container_aware_adapter
    using sorter = cppsort::container_aware_adapter<
        cppsort::selection_sorter
    >;
    cppsort::sort(sorter{}, li);

    assert(std::is_sorted(std::begin(li), std::end(li)));
}
void QgsMapRendererJob::drawOldLabeling( const QgsMapSettings& settings, QgsRenderContext& renderContext )
{
  // render all labels for vector layers in the stack, starting at the base
  QListIterator<QString> li( settings.layers() );
  li.toBack();
  while ( li.hasPrevious() )
  {
    if ( renderContext.renderingStopped() )
    {
      break;
    }

    QString layerId = li.previous();

    QgsMapLayer *ml = QgsMapLayerRegistry::instance()->mapLayer( layerId );

    if ( !ml || ( ml->type() != QgsMapLayer::VectorLayer ) )
      continue;

    // only make labels if the layer is visible
    // after scale dep viewing settings are checked
    if ( ml->hasScaleBasedVisibility() && ( settings.scale() < ml->minimumScale() || settings.scale() > ml->maximumScale() ) )
      continue;

    bool split = false;
    const QgsCoordinateTransform* ct = 0;
    QgsRectangle r1 = settings.visibleExtent(), r2;

    if ( settings.hasCrsTransformEnabled() )
    {
      ct = QgsCoordinateTransformCache::instance()->transform( ml->crs().authid(), settings.destinationCrs().authid() );
      split = reprojectToLayerExtent( ct, ml->crs().geographicFlag(), r1, r2 );
    }

    renderContext.setCoordinateTransform( ct );
    renderContext.setExtent( r1 );

    ml->drawLabels( renderContext );
    if ( split )
    {
      renderContext.setExtent( r2 );
      ml->drawLabels( renderContext );
    }
  }
}
void RTFDocVisitor::visitPre(DocParamList *pl)
{
  if (m_hide) return;
  DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocParamList)}\n");

  // Put in the direction: in/out/in,out if specified.
  if (pl->direction()!=DocParamSect::Unspecified)
  {
    m_t << "[";
    if (pl->direction()==DocParamSect::In)
    {
      m_t << "in";
    }
    else if (pl->direction()==DocParamSect::Out)
    {
      m_t << "out";
    }
    else if (pl->direction()==DocParamSect::InOut)
    {
      m_t << "in,out";
    }
    m_t << "] ";
  }

  m_t << "{\\i ";
  //QStrListIterator li(pl->parameters());
  //const char *s;
  QListIterator<DocNode> li(pl->parameters());
  DocNode *param;
  bool first=TRUE;
  for (li.toFirst();(param=li.current());++li)
  {
    if (!first) m_t << ","; else first=FALSE;
    if (param->kind()==DocNode::Kind_Word)
    {
      visit((DocWord*)param); 
    }
    else if (param->kind()==DocNode::Kind_LinkedWord)
    {
      visit((DocLinkedWord*)param); 
    }
  }
  m_t << "} ";
  m_lastIsPara=TRUE;
}
Beispiel #9
0
void MemberGroup::addGroupedInheritedMembers(OutputList &ol,ClassDef *cd,
               MemberListType lt,
               ClassDef *inheritedFrom,const QCString &inheritId)
{
  //printf("** addGroupedInheritedMembers()\n");
  MemberListIterator li(*memberList);
  MemberDef *md;
  for (li.toFirst();(md=li.current());++li)
  {
    //printf("matching %d == %d\n",lt,md->getSectionList(m_parent)->listType());
    if (lt==md->getSectionList(m_parent)->listType())
    {
      MemberList ml(lt);
      ml.append(md);
      ml.writePlainDeclarations(ol,cd,0,0,0,DefinitionIntf::TypeGroup,inheritedFrom,inheritId);
    }
  }
}
void SWE::computeBathymetrySources()
{
#pragma omp parallel for
	for (int i = 1; i <= nx; i++)
	{
		for (int j = 1; j <= ny; j++)
		{
			Bu[li(nx + 2, i, j)] = g * 0.5f * (h[li(nx + 2, i, j)] + h[li(nx + 2, i - 1, j)]) * (b[li(nx + 2, i, j)] - b[li(nx + 2, i - 1, j)]);
			Bv[li(nx + 2, i, j)] = g * 0.5f * (h[li(nx + 2, i, j)] + h[li(nx + 2, i, j - 1)]) * (b[li(nx + 2, i, j)] - b[li(nx + 2, i, j - 1)]);
		}
	}

}
Beispiel #11
0
U32 Mesh::Manager::ReportList( const char * name) // = NULL
{
    U32 count = 0;
    U32 len = 0, hit = FALSE;
    if ( name)
    {
        len = strlen( name);
    }
    else
    {
        hit = TRUE;
    }
    U32 mem = 0;
    remem = recount = rgeo = ranim = rmrm = 0;
    NBinTree<MeshRoot>::Iterator li(&rootTree);
    while (MeshRoot * root = li++)
    {
        if (!root->isChunk && (!name || !strnicmp( root->fileName.str, name, len)))
        {
            mem += Report( *root);
            hit = TRUE;

            count++;
        }
    }
    if (hit)
    {
        CON_DIAG( ("%4ld %-31s: %9ld   g%6ld a%6ld m%6ld", count, "mesh types", mem,
                   rgeo, ranim, rmrm
                  ));
        LOG_DIAG( ("%4ld %-31s: %9ld   g%6ld a%6ld m%6ld", count, "mesh types", mem,
                   rgeo, ranim, rmrm
                  ));

        CON_DIAG( ("%4ld %-31s: %9ld", recount, "mesh instances", remem ) );
        LOG_DIAG( ("%4ld %-31s: %9ld", recount, "mesh instances", remem ) );
    }
    else
    {
        CON_DIAG( ("Can't find mesh type: %s", name) );
    }

    return mem + remem;
}
void XmlDocVisitor::visitPre(DocParamList *pl)
{
  if (m_hide) return;
  m_t << "<parameteritem>" << endl;
  m_t << "<parameternamelist>" << endl;
  //QStrListIterator li(pl->parameters());
  //const char *s;
  QListIterator<DocNode> li(pl->parameters());
  DocNode *param;
  for (li.toFirst();(param=li.current());++li)
  {
    m_t << "<parametername";
    if (pl->direction()!=DocParamSect::Unspecified)
    {
      m_t << " direction=\"";
      if (pl->direction()==DocParamSect::In)
      {
        m_t << "in";
      }
      else if (pl->direction()==DocParamSect::Out)
      {
        m_t << "out";
      }
      else if (pl->direction()==DocParamSect::InOut)
      {
        m_t << "inout";
      }
      m_t << "\"";
    }
    m_t << ">";
    if (param->kind()==DocNode::Kind_Word)
    {
      visit((DocWord*)param); 
    }
    else if (param->kind()==DocNode::Kind_LinkedWord)
    {
      visit((DocLinkedWord*)param); 
    }
    m_t << "</parametername>" << endl;
  }
  m_t << "</parameternamelist>" << endl;
  m_t << "<parameterdescription>" << endl;
}
Beispiel #13
0
void StringTable::clear()
{
    int 	i;

    ASSERT(this);

    for (i=0 ; i<HASH_SIZE ; i++) {
	List *l = &this->lists[i];
	ListIterator li(*l);
	char *s;
	while ( (s = (char*)li.getNext()) ) 
	    delete s;
	l->clear();
    }
    //
    // Clear the list.
    //
    this->size = 0;
}
Beispiel #14
0
void run_learn_predict_test(bool& ok) {
	test_tool t("test/digits/learn_predict", ok);

	typedef recognition_problem p;

	reexp::lang<p> lang;
	reexp::data<p> data(lang, sample_dim());
	setup_reg<p>(lang, data);

	reexp::stats<p> stats(data);

	reexp::learner<p> learner(lang, stats);
	setup_learner(learner);

	int rounds = 3;

	for (int i = 0; i < rounds; i++) {
		float before = stats.ndl();
		if (!learner.add_exp()) break;
		t<<"expression added."<<checkl;
		float after = stats.ndl();
		t<<"info "<<before<<" -> "<<after<<checkl<<checkl;
	}

	t<<checkl<<"learning done."<<checkl<<checkl;

	print_scan(t, lang, stats);

	reexp::pinfo info;
	setup_pinfo(info);
	reexp::lang_info<p> li(info, lang);

	t<<"vars:\n\n"<<li.drawn_vars_tostring(cvarid::x, cvarid::y);

	t<<"px"<<checkl<<checkl;
	print_pixels(t, data.var(varid::pixel));
	for (int i = 0; i < rounds; i++) {
		t<<"exp"<<i<<checkl<<checkl;
		print_pixels(t, data.var(varid::digit9 + i + 1));
	}

	print_prediction<p>(t, stats);
}
Beispiel #15
0
bool SqlCalls::SqlDelete(QString table, QSqlDatabase database, QStringList clausulas, QString &error)
{
    //DELETE FROM `table` WHERE `column`=value1 AND `column2`=otherValue;
    if(!database.isOpen())
    {
        error = QObject::tr("Base de datos cerrada");
        return false;
    }
    /*
    if(database.driverName() == "QMYSQL")
    {
        //qDebug()<< "Mysql";
    }
    else if (database.driverName() == "QSQLITE")
    {

    }
    TODO reactivar cuando haya soporte multi-driver
    */
    QString colums;
    QTextStream s(&colums);

    s << "DELETE FROM `" << table << "` WHERE ";

    QStringListIterator li(clausulas);
    while (li.hasNext()) {
        QString a = li.next();
        s << a;
        if(li.hasNext())
            s<< " AND ";
    }
    s << ";";

    QSqlQuery q(database);
    q.prepare(colums);
    bool b = q.exec();
    if (!b)
    {
        error = q.lastError().text();
        lastError = error;
    }
    return b;
}
Beispiel #16
0
bool Definition::hasSections() const
{
  //printf("Definition::hasSections(%s) #sections=%d\n",name().data(),
  //    m_impl->sectionDict ? m_impl->sectionDict->count() : 0);
  if (m_impl->sectionDict==0) return FALSE;
  SDict<SectionInfo>::Iterator li(*m_impl->sectionDict);
  SectionInfo *si;
  for (li.toFirst();(si=li.current());++li)
  {
    if (si->type==SectionInfo::Section || 
        si->type==SectionInfo::Subsection || 
        si->type==SectionInfo::Subsubsection ||
        si->type==SectionInfo::Paragraph)
    {
      return TRUE;
    }
  }
  return FALSE;
}
Beispiel #17
0
 void node::unlink_by_target(const SODIUM_SHARED_PTR<node>& targ)
 {
     SODIUM_FORWARD_LIST<node::target>::iterator this_it;
     for (SODIUM_FORWARD_LIST<node::target>::iterator last_it = targets.before_begin(); true; last_it = this_it) {
         this_it = last_it;
         ++this_it;
         if (this_it == targets.end())
             break;
         if (this_it->n == targ) {
             targets.erase_after(last_it);
             if (targ) {
                 boost::intrusive_ptr<listen_impl_func<H_STREAM> > li(
                     reinterpret_cast<listen_impl_func<H_STREAM>*>(listen_impl.get()));
                 targ->sources.remove(li);
             }
             break;
         }
     }
 }
Beispiel #18
0
void LatexDocVisitor::visitPre(DocParamList *pl)
{
  if (m_hide) return;
  m_t << "\\item[";
  if (pl->direction()!=DocParamSect::Unspecified)
  {
    m_t << "\\mbox{";
    if (pl->direction()==DocParamSect::In)
    {
      m_t << "$\\leftarrow$";
    }
    else if (pl->direction()==DocParamSect::Out)
    {
      m_t << "$\\rightarrow$";
    }
    else if (pl->direction()==DocParamSect::InOut)
    {
      m_t << "$\\leftrightarrow$";
    }
    m_t << "} ";
  }
  m_t << "{\\em ";
  //QStrListIterator li(pl->parameters());
  //const char *s;
  QListIterator<DocNode> li(pl->parameters());
  DocNode *param;
  bool first=TRUE;
  for (li.toFirst();(param=li.current());++li)
  {
    if (!first) m_t << ","; else first=FALSE;
    m_insideItem=TRUE;
    if (param->kind()==DocNode::Kind_Word)
    {
      visit((DocWord*)param); 
    }
    else if (param->kind()==DocNode::Kind_LinkedWord)
    {
      visit((DocLinkedWord*)param); 
    }
    m_insideItem=FALSE;
  }
  m_t << "}]";
}
Beispiel #19
0
void			cur_write(char *str, int size)
{
	int			len;
	int			flag;

	flag = 0;
	len = *co() + size;
	if (len % (cur_scrco() + 1) == 0)
		flag = 1;
	write(1, str, size);
	if (flag)
	{
		cur_bli();
		if (*li() == cur_scrli())
			cur_uroll();
		else
			cur_nli();
	}
}
void MessageQueueClient::write(const ByteStream& msg, const struct timespec* timeout, Stats* stats) const
{
    if (!fClientSock.isOpen())
    {
        fClientSock.open();

        try
        {
            fClientSock.connectionTimeout(timeout);
            fClientSock.connect(&fServ_addr);
        }
        catch (...)
        {
            fClientSock.close();
            throw;
        }
    }

    try
    {
        fClientSock.write(msg, stats);
    }
    catch (runtime_error& e)
    {
        try
        {
            ostringstream oss;
            oss << "MessageQueueClient::write: error writing " << msg.length() << " bytes to "
                << fClientSock << ". Socket error was " << e.what() << endl;
//			cerr << oss.str() << endl;
            logging::Message::Args args;
            logging::LoggingID li(31);
            args.add(oss.str());
            fLogger.logMessage(logging::LOG_TYPE_WARNING, logging::M0000, args, li);
        }
        catch (...)
        {
        }

        fClientSock.close();
        throw;
    }
}
QString LinkedTextHandler::toString(const QList<LinkedTextImpl> &list) 
{
  QListIterator<LinkedTextImpl> li(list);
  QString result;
  LinkedTextImpl *lt;
  for (li.toFirst();(lt=li.current());++li)
  {
    switch(lt->kind())
    {
      case ILinkedText::Kind_Text:
        result+=dynamic_cast<ILT_Text*>(lt)->text()->latin1();
        break;
      case ILinkedText::Kind_Ref:
        result+=dynamic_cast<ILT_Ref *>(lt)->text()->latin1();
        break;
    }
  }
  return result;
}
Beispiel #22
0
AbstractQoreNode* CallReferenceCallNode::parseInitImpl(LocalVar* oflag, int pflag, int& lvids, const QoreTypeInfo*& typeInfo) {
   // call references calls can return any value
   typeInfo = 0;

   pflag &= ~(PF_RETURN_VALUE_IGNORED);

   const QoreTypeInfo* expTypeInfo = 0;
   if (exp) {
      exp = exp->parseInit(oflag, pflag, lvids, expTypeInfo);

      if (expTypeInfo && codeTypeInfo && expTypeInfo->hasType() && !codeTypeInfo->parseAccepts(expTypeInfo)) {
	 // raise parse exception
	 QoreStringNode* desc = new QoreStringNode("invalid call; expression gives ");
	 expTypeInfo->getThisType(*desc);
	 desc->concat(", but a call reference or closure is required to make a call");
	 qore_program_private::makeParseException(getProgram(), "PARSE-TYPE-ERROR", desc);
      }
   }

   if (args) {
      bool needs_eval = args->needs_eval();

      // turn off PF_RETURN_VALUE_IGNORED
      pflag &= ~PF_RETURN_VALUE_IGNORED;
      
      ListIterator li(args);
      while (li.next()) {
	 AbstractQoreNode** n = li.getValuePtr();
	 if (*n) {
	    const QoreTypeInfo* argTypeInfo = 0;
	    (*n) = (*n)->parseInit(oflag, pflag, lvids, argTypeInfo);
	    
	    if (!needs_eval && (*n)->needs_eval()) {
	       args->setNeedsEval();
	       needs_eval = true;
	    }
	 }
      }
   }
   
   return this;
}
Beispiel #23
0
MeshEnt * Mesh::Manager::PickAtScreenPos(S32 x, S32 y, MeshObj **child) // = NULL
{
    Vector pos;
    const MeshObj *mobj, *closeObj = NULL;
    MeshEnt *closeEnt = NULL;
    F32 t;

    Vid::ScreenToCamera( pos, x, y);
    pos *= Vid::CurCamera().FarPlane();
    const Matrix &cam = Vid::CurCamera().WorldMatrix();
    cam.Transform(pos);

    Vector diff = pos - cam.posit;
    F32 mindist2 = 1000000000.0f;

    for (NList<MeshEnt>::Iterator li(&entList); *li; li++)
    {
        MeshEnt &meshent = *(*li);
        if (!meshent.CollideBounds( cam.posit, pos))
        {
            continue;
        }
        mobj = meshent.CollidePoly(cam.posit, pos, t);

        if (mobj)
        {
            Vector tdiff = diff * t;
            F32 dist2 = tdiff.Magnitude2();

            if (dist2 < mindist2)
            {
                closeObj = mobj;
                closeEnt = *li;
            }
        }
    }
    if (child)
    {
        *child = (MeshObj *) closeObj;
    }
    return closeEnt;
}
Beispiel #24
0
//Step function
void Block::step()
{
  WorldManager &wm = WorldManager::getInstance();
  ObjectList all_colliding = wm.isCollision(this, this->getPosition());
  ObjectListIterator li(&all_colliding);
  //for every object colliding with this block...
  for (li.first(); !li.isDone(); li.next())
    {
      //if it's a plate...
      if (li.currentObject() -> getType() == "Plate")
	{
	  isOnPlate = true;
	  //change sprite
	  chooseSprite(isOnPlate);
	  return;
	}
    }
  isOnPlate = false;
  chooseSprite(isOnPlate);
}
Beispiel #25
0
  //
  // BuildMirrorList
  //
  // Test displayed objects for mirror plane clip 
  //
  void BuildMirrorList()
  {
    indexMeshEntMirror = arrayMeshEntMirror;

    NList<MapObj>::Iterator li(&listOnMap); 
    while (MapObj * obj = li++)
    {
      MeshEnt & ent = obj->Mesh();
      
      if (ent.visible && ent.BoundsTest() != clipOUTSIDE)
      {
        *indexMeshEntMirror++ = &ent;

        if (indexMeshEntMirror >= lastMeshEntMirror)
        {
          break;
        }
      }
    }
  }
Beispiel #26
0
void Mesh::Manager::RenderList()
{
    NList<MeshEnt>::Iterator li( &entList);

    for (!li; *li; li++)
    {
        MeshEnt &ent = *(*li);

        if (ent.BoundsTest() == clipOUTSIDE)
        {
            continue;
        }
        ent.Render();

        if (Vid::renderState.status.showShadows && Vid::Light::sun && Vid::Light::sun->IsActive())
        {
            Terrain::RenderShadowWithWater( ent);
        }
    }
}
Beispiel #27
0
/*
 * Testing the functioning of an list iterator.
 */
TEST_F(ListTest, listIteratorTests)
{
        int noItems = 0;
        list.addHead(item);
        list.addTail(item1);
        Stateplex::ListIterator<Stateplex::ListItem> li(&list);

        EXPECT_EQ(li.hasCurrent(), true);
        EXPECT_EQ(li.current(), item);
        EXPECT_EQ(li.subsequent(), item1);
        EXPECT_EQ(li.hasSubsequent(), false);
        EXPECT_EQ(li.isBackwards(), false);
        list.addTail(item2);
        EXPECT_EQ(li.hasCurrent(),true);
        EXPECT_EQ(li.current(),item1);

        EXPECT_EQ(li.hasSubsequent(),false);
        noItems = countItems(&list);
        std::cout << "noItems is " << noItems << std::endl;
}
void SWE::writeVTKFile(string FileName)
{
	// VTK HEADER
	Vtk_file.open(FileName.c_str());
	Vtk_file << "# vtk DataFile Version 2.0" << endl;
	Vtk_file << "HPC Tutorials: Michael Bader, Kaveh Rahnema, Oliver Meister" << endl;
	Vtk_file << "ASCII" << endl;
	Vtk_file << "DATASET RECTILINEAR_GRID" << endl;
	Vtk_file << "DIMENSIONS " << nx + 1 << " " << ny + 1 << " " << "1" << endl;
	Vtk_file << "X_COORDINATES " << nx + 1 << " float" << endl;
	//GITTER PUNKTE
	for (int i = 0; i < nx + 1; i++)
		Vtk_file << i*dx << endl;
	Vtk_file << "Y_COORDINATES " << ny + 1 << " float" << endl;
	//GITTER PUNKTE
	for (int i = 0; i < ny + 1; i++)
		Vtk_file << i*dy << endl;
	Vtk_file << "Z_COORDINATES 1 float" << endl;
	Vtk_file << "0" << endl;
	Vtk_file << "CELL_DATA " << ny*nx << endl;
	Vtk_file << "SCALARS H float 1" << endl;
	Vtk_file << "LOOKUP_TABLE default" << endl;
	//DOFS
	for (int j = 1; j < ny + 1; j++)
		for (int i = 1; i < nx + 1; i++)
			Vtk_file << h[li(nx + 2, i, j)] /* + b[li(nx + 2, i, j)]*/ << endl;
	Vtk_file << "SCALARS HU float 1" << endl;
	Vtk_file << "LOOKUP_TABLE default" << endl;
	for (int j = 1; j < ny + 1; j++)
		for (int i = 1; i < nx + 1; i++)
			Vtk_file << hu[li(nx + 2, i, j)] /*/ h[li(nx + 2, i, j)]*/ << endl;
	Vtk_file << "SCALARS HV float 1" << endl;
	Vtk_file << "LOOKUP_TABLE default" << endl;
	for (int j = 1; j < ny + 1; j++)
		for (int i = 1; i < nx + 1; i++)
			Vtk_file << hv[li(nx + 2, i, j)] /*/ h[li(nx + 2, i, j)]*/ << endl;
	Vtk_file << "SCALARS B float 1" << endl;
	Vtk_file << "LOOKUP_TABLE default" << endl;
	for (int j = 1; j < ny + 1; j++)
		for (int i = 1; i < nx + 1; i++)
			Vtk_file << b[li(nx + 2, i, j)] << endl;
	Vtk_file << "SCALARS WATER_HEIGHT float 1" << endl;
	Vtk_file << "LOOKUP_TABLE default" << endl;
	for (int j = 1; j < ny + 1; j++)
		for (int i = 1; i < nx + 1; i++)
			Vtk_file << h[li(nx + 2, i, j)] + b[li(nx + 2, i, j)] << endl;
	Vtk_file.close();
}
int df::Manager::onEvent(const df::Event *p_event) const {
    int return_count = 0;

    for (int i = 0; i < this->event_count; i++) {
        if (this->event[i].compare(p_event->getType()) == 0) {
            if (this->obj_list[i].isEmpty()) {
                return 0;
            }
            
            df::ObjectListIterator li(&(obj_list[i]));

            for (li.first(); !li.isDone(); li.next()) {
                li.currentObject()->eventHandler(p_event);
                return_count++;
            }
            
            return return_count;
        }
    }
    return 0;
}
Beispiel #30
0
void run_learn_picked_predict_test(bool& ok) {
	test_tool t("test/digits/learn_picked_predict", ok);

	typedef recognition_problem p;

	reexp::lang<p> lang;
	reexp::data<p> data(lang, sample_dim());
	setup_reg<p>(lang, data);

	reexp::stats<p> stats(data);


	float before = stats.ndl();
	lang.add_exp(lang.rel(relid::up_down), 3);
	float after = stats.ndl();
	t<<"info "<<before<<" -> "<<after<<checkl<<checkl;
	before = after;
	lang.add_exp(lang.rel(relid::left_right), 3);
	after = stats.ndl();
	t<<"info "<<before<<" -> "<<after<<checkl<<checkl;

	t<<checkl<<"learning done."<<checkl<<checkl;

	print_scan(t, lang, stats);

	reexp::pinfo info;
	setup_pinfo(info);
	reexp::lang_info<p> li(info, lang);

	t<<"vars:\n\n"<<li.drawn_vars_tostring(cvarid::x, cvarid::y);

	t<<"px"<<checkl<<checkl;
	print_pixels(t, data.var(varid::pixel));
	for (int i = 0; i < 1; i++) {
		t<<"exp"<<i<<checkl<<checkl;
		print_pixels(t, data.var(varid::digit9 + i + 1));
	}

	print_prediction<p>(t, stats);
}