Example #1
0
/**
 * \param[in] rUser user name
 * \return true = success, false = failure
 */ 
bool remove_table(const std::string& rUser)
{
  fprintf(stderr, "removing table for user '%s'\n", rUser.c_str());
  
  std::string tp(IncronTab::GetUserTablePath(rUser));
 
  if (unlink(tp.c_str()) != 0 && errno != ENOENT) {
    fprintf(stderr, "cannot remove table for user '%s': %s\n", rUser.c_str(), strerror(errno));
    return false;
  }
  
  return true;
}
Example #2
0
void PlayerPlaylist::select(int id) {

  std::stringstream ss;
  ss << id;

  Gtk::TreePath tp(ss.str());

  //Gtk::TreeViewColumn *tvc;
  //  m_TreeView.get_cursor(tp,tvc);
  std::cout<<tp.to_string()<<std::endl;
  //tp.next();
  m_TreeView.set_cursor(tp);
}
    bool MultipleTermPositions::skipTo(int32_t target)
    {
        while (termPositionsQueue->top() && target > termPositionsQueue->top()->doc())
        {
            TermPositionsPtr tp(termPositionsQueue->top());
            termPositionsQueue->pop();

            if (tp->skipTo(target))
                termPositionsQueue->add(tp);
            else
                tp->close();
        }
        return next();
    }
Example #4
0
void PrettyPrinter::special_print(const Store* store,
                                  std::ostream& outStream,
                                  const std::string tableName,
                                  const size_t& limit,
                                  const size_t& start) {
  ftprinter::FTPrinter tp(tableName, outStream);
  tp.addColumn("#rowid", 6);
  const size_t columns = store->columnCount();

  // TODO: how about using limit=0 as parameter to print whole table instead of strange -1 for unsigned?
  auto prepareLimit = (limit < (size_t) - 1) ? std::min(limit, store->size()) : store->size();

  for (size_t column_index = 0; column_index < columns; ++column_index) {
    // Auto adjusting widths means iterating over the table twice, but we use it for
    // debugging purposes only, anyways, so we'll go with beauty of output here
    auto name = store->nameOfColumn(column_index);
    size_t width = std::accumulate(RangeIter(0),
                                   RangeIter(prepareLimit),
                                   // minimum width is 4
                                   name.size() > 4 ? name.size() : 4,
                                   [&](size_t max, const size_t row)->size_t {
      size_t sz = generateValue(store, column_index, row).size();
      return sz > max ? sz : max;
    });
    tp.addColumn(name, width);
  }
  tp.addColumn("$tid", 6);
  tp.addColumn("$cidbeg", 6);
  tp.addColumn("$cidend", 6);

  if (limit < (size_t) - 1) {
    outStream << "(showing first " << limit << " rows)" << std::endl;
  }

  if (tableName.size() > 0)
    tp.printTableName();

  tp.printHeader();

  for (size_t row = start; row < store->size() && row < limit; ++row) {
    tp << row;
    for (size_t column = 0; column < columns; ++column) {
      tp << generateValue(store, column, row);
    }
    writeTid(tp, store->_tidVector[row]);
    writeCid(tp, store->_cidBeginVector[row]);
    writeCid(tp, store->_cidEndVector[row]);
  }
  tp.printFooter();
}
Example #5
0
void SlippyMap::render(QPainter *p, const QRect &rect)
{
    for (int x = 0; x <= m_tilesRect.width(); ++x)
        for (int y = 0; y <= m_tilesRect.height(); ++y) {
            QPoint tp(x + m_tilesRect.left(), y + m_tilesRect.top());
            QRect box = tileRect(tp);
            if (rect.intersects(box)) {
                if (m_tilePixmaps.contains(tp))
                    p->drawPixmap(box, m_tilePixmaps.value(tp));
                else
                    p->drawPixmap(box, m_emptyTile);
            }
        }
}
Example #6
0
void MyApp::PaintScreen(sInt screen,sInt time)
{ 
  time += screen*1234;

  // set rendertarget

  static sU32 colors[4] = { 0xff405060,0xffc04040,0xff40c040,0xff4040c0 };

  sTargetPara tp(sST_CLEARALL,colors[screen&3],0,sGetScreenColorBuffer(screen),sGetScreenDepthBuffer(screen));

  sSetTarget(tp);

  // set camera

  View.SetTargetCurrent();
  View.SetZoom(1.0f);
  View.Model.EulerXYZ(time*0.0011f,time*0.0013f,time*0.0015f);
  View.Model.l.Init(0,0,0);
  View.Camera.l.Init(0,0,-4);
  View.Prepare();

  // set material

  sCBuffer<sSimpleMaterialEnvPara> cb;
  cb.Data->Set(View,Env);
  Mtrl->Set(&cb);

  // draw

  Geo->Draw();

  // debug

  sF32 avg = Timer.GetAverageDelta();
  Painter->SetTarget();
  Painter->Begin();
  Painter->SetPrint(0,0xff000000,2);
  Painter->SetPrint(0,~0,2);
  Painter->PrintF(10,10,L"screen %d: %s",screen,ScreenNames[screen]);
  if (screen)
    Painter->PrintF(10,30,L"on %s",AdapterName);
  else
    Painter->PrintF(10,30,L"%5.2ffps %5.3fms",1000.0f/avg,avg);
  Painter->End();

  // resolve multisampling

  sResolveTarget();
}
Example #7
0
/**
 * generates MC neutrons using available threads
 */
Ellipsoid4d<t_real> TASReso::GenerateMC(std::size_t iNum, std::vector<t_vec>& vecNeutrons) const
{
	// use deferred version if threading is disabled
	//if(!m_bEnableThreads)
	//	return GenerateMC_deferred(iNum, vecNeutrons);


	// number of iterations over random sample positions
	std::size_t iIter = m_res.size();
	if(vecNeutrons.size() != iNum*iIter)
		vecNeutrons.resize(iNum*iIter);

	Ellipsoid4d<t_real> ell4dret;
	for(std::size_t iCurIter = 0; iCurIter<iIter; ++iCurIter)
	{
		const ResoResults& resores = m_res[iCurIter];

		Ellipsoid4d<t_real> ell4d = calc_res_ellipsoid4d<t_real>(
			resores.reso, resores.reso_v, resores.reso_s, resores.Q_avg);

		unsigned int iNumThreads = get_max_threads();
		std::size_t iNumPerThread = iNum / iNumThreads;
		std::size_t iRemaining = iNum % iNumThreads;

		tl::ThreadPool<void()> tp(iNumThreads);
		for(unsigned iThread=0; iThread<iNumThreads; ++iThread)
		{
			std::vector<t_vec>::iterator iterBegin = vecNeutrons.begin() + iNumPerThread*iThread + iCurIter*iNum;
			std::size_t iNumNeutr = iNumPerThread;
			if(iThread == iNumThreads-1)
				iNumNeutr = iNumPerThread + iRemaining;

			tp.AddTask([iterBegin, iNumNeutr, this, &ell4d]()
				{ mc_neutrons<t_vec>(ell4d, iNumNeutr, this->m_opts, iterBegin); });
		}

		tp.StartTasks();

		auto& lstFut = tp.GetFutures();
		for(auto& fut : lstFut)
			fut.get();

		if(iCurIter == 0)
			ell4dret = ell4d;
	}

	//mc_neutrons<t_vec>(ell4d, iNum, m_opts, vecNeutrons.begin());
	return ell4dret;
}
Example #8
0
/*
 * Iterate backwards through list of primes then form difference between prime
 * and input. Then perform a binary search for this difference.
 * Number of primes less than n is O (n / log n) so searching takes 
 * O ( log (n / log n) ) = O ( log n - log log n ) = O ( log n )
 * Iterating through primes and binary searching thus takes:
 * O(n / log n * log n) = O(n)
 */
std::vector<TwoPrimes> find_goldbachs(std::vector<int> &primes, int input,
                                      bool all_pairs) {

    int num_primes = primes.size();
    std::vector<TwoPrimes> result;
    
    for(int i = num_primes - 1; i >= 0; --i) {
 
        int p1 = primes[i];
        int p2 = input - p1;
        //binary search for p2 in primes
        bool found_p2 = std::binary_search(primes.begin(), primes.end(), p2);
            if(found_p2) {
                if(all_pairs == false) {
                    TwoPrimes tp(p1, p2);
                    result.push_back(tp);
                    return result;
                }
                TwoPrimes tp(p1, p2);
                result.push_back(tp);
            };
    }
    return result;
}
Example #9
0
 vector<Interval> insert(vector<Interval>& intervals, Interval newInterval) {
     intervals.push_back(newInterval);
     int n = intervals.size();
     compare cmp;
     sort(intervals.begin(), intervals.end(), cmp);
     
     vector<Interval> v;
     v.clear();
     int b = intervals[0].start, mx = intervals[0].end;
     for(int i = 1; i < n; i++) {
         if(intervals[i].start <= mx) {
             mx = max(mx, intervals[i].end);
         }
         else {
             Interval tp(b, mx);
             v.push_back(tp);
             b = intervals[i].start;
             mx = intervals[i].end;
         }
     }
     Interval tp(b, mx);
     v.push_back(tp);
     return v;
 }
Example #10
0
	void Canvas::draw()
	{
		redrawIfNecessary();
		ofImage* cairoTexture = texture.getTextureRef();
		cairoTexture->bind();
		ofDrawQuadTextured(polygon.getVertexs(), ofTexCoordsFor());
		cairoTexture->unbind();

		for (map<int, DataTouch>::const_iterator t = touchPoints.begin(); t != touchPoints.end(); ++t)
		{
			ofSetColor(kRGBBlue);
			ofVec3f tp(t->second.getTouchPoint());
			ofCircle(tp.x, tp.y, tp.z, 0.003);
		}
	}
Example #11
0
void ConfusionMatrix::print_summary() {
  // overall counts and summary
  cout.precision(4);
  cout << "== Summary ==" << endl;
  cout << setw(23) <<"Correctly classified:" << setw(12) << right << correct << setw(10) << right << accuracy() * 100 << "%" << endl;
  cout << setw(23) << "Incorrectly classified:" << setw(12) << right << incorrect << setw(10) << right << error() * 100 << "%" << endl;
  cout << setw(23) << "Total classifications:" << setw(12) << right << correct + incorrect << endl << endl;
  
  // determine the width of the left (category name) column
  int max_name_length = 0;
  for(int category = 1; category <= data_set->categories_size(); category++)
    if(data_set->category_feature()->names[category].length() > max_name_length)
      max_name_length = data_set->category_feature()->names[category].length();
  if(average_row_name.length() > max_name_length)
    max_name_length = average_row_name.length();
  max_name_length += 1;
  
  // detailed category information
  cout << "== Category Performance ==" << endl;
  cout << setw(max_name_length) << "";
  cout << setw(9) << right << "True +";
  cout << setw(9) << right << "False +";
  cout << setw(9) << right << "True -";
  cout << setw(9) << right << "False -";
  cout << setw(9) << right << "Precis.";
  cout << setw(9) << right << "Recall";
  cout << setw(9) << right << "F-score" << endl;
  
  for(int category = 1; category <= data_set->categories_size(); category++) {
    cout << setw(max_name_length) << data_set->category_feature()->names[category];
    cout << setw(9) << tp(category);
    cout << setw(9) << fp(category);
    cout << setw(9) << tn(category);
    cout << setw(9) << fn(category);
    cout << setw(8) << precision(category) * 100 << "%";
    cout << setw(8) << recall(category) * 100 << "%";
    cout << setw(8) << fscore(category) * 100 << "%" << endl;
  }
  
  cout << setw(max_name_length) << average_row_name;
  cout << setw(9) << avg_tp();
  cout << setw(9) << avg_fp();
  cout << setw(9) << avg_tn();
  cout << setw(9) << avg_fn();
  cout << setw(8) << avg_precision() * 100 << "%";
  cout << setw(8) << avg_recall() * 100 << "%";
  cout << setw(8) << avg_fscore() * 100 << "%" << endl;
}
void WEpochAveragingTotal::addEmmSum( const WLEMMeasurement::ConstSPtr emm )
{
    WLTimeProfiler tp( CLASS, "addEmmSum" );
    ++m_count;
    WLEMData::ConstSPtr emdIn;
    WLEMData::SPtr emdSum;

    for( size_t mod = 0; mod < emm->getModalityCount(); ++mod )
    {
        emdIn = emm->getModality( mod );
        emdSum = m_emmSum->getModality( mod );
        const WLEMData::DataT& dataIn = emdIn->getData();
        WLEMData::DataT& dataSum = emdSum->getData();
        dataSum += dataIn;
    }
}
Example #13
0
/// Return a map containing all metrics.
StringMapDouble CoverMetrics::all() const {
    StringMapDouble m;
    m["tp"] = tp();
    m["fp"] = fp();
    m["tn"] = tn();
    m["fn"] = fn();
    m["precision"]   = precision();
    m["recall"]      = recall();
    m["f1score"]     = f1score();
    m["accuracy"]    = accuracy();
    m["fprate"]      = fprate();
    m["specificity"] = specificity();
    m["fnrate"]      = fnrate();
    m["matthews"]    = matthews();
    return m;
}
Example #14
0
void UAV::sendCurrentTelem()
{
    updateUavLatLng();
    Protocol::TelemetryPacket tp(telemSeqNumber++);
    double velocity_x = qrand() % 30 + 80;
    double velocity_y = qrand() % 30 + 80;
    double velocity_z = qrand() % 30 + 80;
    double altitude = qrand() % 75 + 150;
    tp.SetVelocity(velocity_x, velocity_y, velocity_z);
    tp.SetOrientation(4,5,6);
    tp.SetLocation(uavLat, uavLng, altitude);
    tp.SetHeading(10);

    sendAPacket(&tp);
    
}
Example #15
0
 // Called by Cocos when touches have ended
 void CocosTouchLayer::ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
 {
     // Go over all the touchs in the set
     for (CCSetIterator it = pTouches->begin(); it != pTouches->end(); it++)
     {
         // Translate touch position to GL coordinates
         CCTouch *ccTouch = (CCTouch *)(*it);
         CCPoint pos = CCDirector::sharedDirector()->convertToUI(ccTouch->locationInView(ccTouch->view()));
         
         // Create a new ichigo touch object with the new position
         TouchPoint tp((int)ccTouch, pos.x, pos.y);
         
         // Let the event manager handle this touch
         EventManager::getInstance()->onTouchEnded(&tp);
     }        
 }
Example #16
0
// See if we can insert some tags
TEST(ThreadProfile, InsertTagsNoWrap) {
  PseudoStack* stack = new PseudoStack();
  Thread::tid_t tid = 1000;
  ThreadInfo info("testThread", tid, true, stack, nullptr);
  ThreadProfile tp(&info, 100);
  int test_size = 50;
  for (int i = 0; i < test_size; i++) {
    tp.addTag(ProfileEntry('t', i));
  }
  ASSERT_TRUE(tp.mEntries != nullptr);
  int readPos = tp.mReadPos;
  while (readPos != tp.mWritePos) {
    ASSERT_TRUE(tp.mEntries[readPos].mTagName == 't');
    ASSERT_TRUE(tp.mEntries[readPos].mTagInt == readPos);
    readPos = (readPos + 1) % tp.mEntrySize;
  }
}
Example #17
0
/*
*  CLinePtr::GetAdjustedLineLength
*
*  @mfunc  returns the length of the line _without_ EOP markers
*
*  @rdesc  LONG; the length of the line
*/
LONG CLinePtr::GetAdjustedLineLength()
{
    CLine* pline = GetCurrRun();
    Assert(pline);

    LONG cchJunk;
    LONG cchTrim;
    CTreePos *ptpRet, *ptpPrev;

    LONG cpEndLine = _pdp->GetFirstCp() + GetCp() - GetIch() + pline->_cch;
    CTreePos* ptp = _pdp->GetMarkup()->TreePosAtCp(cpEndLine, &cchJunk);

    _pdp->EndNodeForLine(cpEndLine, ptp, &cchTrim, &ptpRet, NULL);
    cchTrim = min(cchTrim, pline->_cch);

    LONG cpNewMost = cpEndLine - cchTrim;

    if(ptpRet)
    {
        ptpPrev = ptpRet;

        if(ptpPrev->GetCch()==0 || ptpPrev->IsNode() || (ptpPrev->IsText() && ptpPrev->GetCp()>=cpNewMost))
        {
            do
            {
                ptpPrev = ptpPrev->PreviousTreePos();
            } while(ptpPrev->GetCch() == 0);
        }

        if(ptpPrev->IsEndElementScope() && ptpPrev->Branch()->Tag()==ETAG_BR)
        {
            cchTrim += 2;
        }
        else if(ptpPrev->IsText())
        {
            CTxtPtr tp(_pdp->GetMarkup(), cpNewMost-1);
            if(tp.GetChar() == WCH_ENDPARA1)
            {
                cchTrim++;
            }
        }
    }

    cchTrim = min(cchTrim, pline->_cch);
    return pline->_cch-cchTrim;
}
Example #18
0
void SPUse::print(SPPrintContext* ctx) {
    bool translated = false;

    if ((this->x._set && this->x.computed != 0) || (this->y._set && this->y.computed != 0)) {
        Geom::Affine tp(Geom::Translate(this->x.computed, this->y.computed));
        sp_print_bind(ctx, tp, 1.0);
        translated = true;
    }

    if (this->child) {
        this->child->invoke_print(ctx);
    }

    if (translated) {
        sp_print_release(ctx);
    }
}
QSqlDatabase QMail::createDatabase()
{
    if (!databaseDataInstance()->hasLocalData()) {
        databaseDataInstance()->setLocalData(new QDatabaseInstanceData);
    }
    QDatabaseInstanceData* instance = databaseDataInstance()->localData();

    QSqlDatabase db;
    if (instance->init) {
        db = QSqlDatabase::database("qmailstore_sql_connection");
    } else {
        qMailLog(Messaging) << "opening database";
        db = QSqlDatabase::addDatabase("QSQLITE", "qmailstore_sql_connection");
        
        QDir dbDir(dataPath() + "database");
        if (!dbDir.exists()) {
#ifdef Q_OS_UNIX
            QString path = dataPath();
            if (path.endsWith('/'))
                path = path.left(path.length() - 1);
            if (!QDir(path).exists() && ::mkdir(QFile::encodeName(path), S_IRWXU) == -1)
                qCritical() << "Cannot create database directory: " << errno;
#endif
            if (!dbDir.mkpath(dataPath() + "database"))
                qCritical() << "Cannot create database path";
        }

        db.setDatabaseName(dataPath() + "database/qmailstore.db");
#endif

        if(!db.open()) {
            QSqlError dbError = db.lastError();
            qCritical() << "Cannot open database: " << dbError.text();
        }

        QDir tp(tempPath());
        if(!tp.exists())
            if(!tp.mkpath(tempPath()))
                qCritical() << "Cannot create temp path";

        instance->init = true;
    }

    return db;
}
Example #20
0
void
Trace::push_back(const AircraftState& state)
{
  assert(cached_size == delta_list.size());
  assert(cached_size == chronological_list.Count());

  if (empty()) {
    // first point determines origin for flat projection
    task_projection.reset(state.location);
    task_projection.update_fast();
  } else if (state.time < fixed(back().GetTime())) {
    // gone back in time

    if (unsigned(state.time) + 180 < back().GetTime()) {
      /* not fixable, clear the trace and restart from scratch */
      clear();
      return;
    }

    /* not much, try to fix it */
    EraseLaterThan(unsigned(state.time) - 10);
  } else if ((unsigned)state.time - back().GetTime() < 2)
    // only add one item per two seconds
    return;

  TracePoint tp(state);
  tp.project(task_projection);

  EnforceTimeWindow(tp.GetTime());

  if (size() >= max_size)
    Thin();

  assert(size() < max_size);

  TraceDelta &td = Insert(tp);
  td.InsertBefore(chronological_list);

  ++cached_size;

  if (!chronological_list.IsFirst(td))
    UpdateDelta(td.GetPrevious());

  ++append_serial;
}
void CAICallback::DrawUnit(const char* name,float3 pos,float rotation,int lifetime,int team,bool transparent,bool drawBorder)
{
	CUnitDrawer::TempDrawUnit tdu;
	tdu.unitdef=unitDefHandler->GetUnitByName(name);
	if(!tdu.unitdef){
		info->AddLine("Uknown unit in CAICallback::DrawUnit %s",name);
		return;
	}
	tdu.pos=pos;
	tdu.rot=rotation;
	tdu.team=team;
	tdu.drawBorder=drawBorder;
	std::pair<int,CUnitDrawer::TempDrawUnit> tp(gs->frameNum+lifetime,tdu);
	if(transparent)
		unitDrawer->tempTransperentDrawUnits.insert(tp);
	else
		unitDrawer->tempDrawUnits.insert(tp);
}
Example #22
0
void test_constexpr_pair() {
#if STL2_CONSTEXPR_EXTENSIONS
  constexpr auto t = tp(42, 3.14);
  static_assert(__stl2::models::Same<decltype(t), const TP>);
  constexpr int f = t.first;
  CHECK(f == 42);
  constexpr int fg = __stl2::get<0>(t);
  CHECK(fg == 42);
  constexpr int ff = t.in();
  CHECK(ff == 42);
  constexpr double s = t.second;
  CHECK(s == 3.14);
  constexpr double sg = __stl2::get<1>(t);
  CHECK(sg == 3.14);
  constexpr double sf = t.out();
  CHECK(sf == 3.14);
#endif
}
Example #23
0
inline dynd::ndt::type xarray_from_pylist(PyObject *obj)
{
  // TODO: Add ability to specify access flags (e.g. immutable)
  // Do a pass through all the data to deduce its type and shape
  std::vector<intptr_t> shape;
  dynd::ndt::type tp(dynd::void_id);
  Py_ssize_t size = PyList_GET_SIZE(obj);
  shape.push_back(size);
  for (Py_ssize_t i = 0; i < size; ++i) {
    deduce_pylist_shape_and_dtype(PyList_GET_ITEM(obj, i), shape, tp, 1);
  }

  if (tp.get_id() == dynd::void_id) {
    tp = dynd::ndt::type(dynd::int32_id);
  }

  return dynd::ndt::make_type(shape.size(), shape.data(), tp);
}
Example #24
0
int bdbdump(int argc, char* argv[], bool dumpFormat)
{
	char*			slash;
	char*			filename;
	Table*			table;
	TablePrinter	tp(dumpFormat);
	bool			ret;
	DatabaseConfig	dbConfig;

	if (argc < 2)
	{
		printf("usage: bdbdump db-file\n");
		exit(1);
	}
	
	dbConfig.dir = ".";
	filename = argv[1];
	if ((slash = strrchr(filename, '/')) != NULL)
	{
		dbConfig.dir = argv[1];
		*slash = '\0';
		filename = slash + 1;
		if (chdir(dbConfig.dir) < 0)
		{
			printf("cannot find database directory!\n");
			exit(1);
		}
		dbConfig.dir = ".";
	}
	
	ret = database.Init(dbConfig);
	if (!ret)
	{
		printf("cannot initialise database!\n");
		exit(1);
	}
	
	table = new Table(&database, filename);
	table->Visit(tp);
	
	delete table;
	
	return 0;
}
Example #25
0
void server()
{

    std::cout << "Server" << std::endl;

    int server_fd = sock_listen("12345", 10, NULL);

    if ( server_fd == -1 )
    {
        std::cout << "sock_listen error " << errno << " " << strerror( errno ) << std::endl;
        exit(1);
    }


    threadpool tp(10);

    while (true)
    {
        sockaddr_storage client_addr;
        socklen_t len = sizeof(client_addr);

        int client_fd = accept(server_fd, (sockaddr*)&client_addr, &len);

        tp.add_task( [client_fd] () {

            print_client_info("New client - ", client_addr);
            std::cout<<std::endl;

            char buf[BUF_SIZE];
            memset(buf, 0, sizeof(buf) );

            ssize_t num_recv = recv(client_fd, buf, BUF_SIZE, 0);
            std::cout << "num_recv " << num_recv << " " << buf << std::endl;

            sleep(2);

            strncpy(buf, "abcdef", BUF_SIZE);
            ssize_t num_sent = send(client_fd, buf, strlen(buf)+1, 0);
            std::cout << "num_sent " << num_sent << std::endl;

            close( client_fd );
        });
    }
}
void CAICallback::DrawUnit(const char* unitName,float3 pos,float rotation,int lifetime,int teamId,bool transparent,bool drawBorder,int facing)
{
	CUnitDrawer::TempDrawUnit tdu;
	tdu.unitdef=unitDefHandler->GetUnitByName(unitName);
	if(!tdu.unitdef){
		logOutput.Print("Uknown unit in CAICallback::DrawUnit %s",unitName);
		return;
	}
	tdu.pos=pos;
	tdu.rotation=rotation;
	tdu.team=teamId;
	tdu.drawBorder=drawBorder;
	tdu.facing=facing;
	std::pair<int,CUnitDrawer::TempDrawUnit> tp(gs->frameNum+lifetime,tdu);
	if(transparent)
		unitDrawer->tempTransparentDrawUnits.insert(tp);
	else
		unitDrawer->tempDrawUnits.insert(tp);
}
void PbrtSceneImporter::_pbrtTexture(PbrtImport::SubString i_name, PbrtImport::SubString i_type, PbrtImport::SubString i_texname, const PbrtImport::ParamSet &i_params)
  {
  if (_VerifyWorld("Texture")==false) return;

  std::string name(i_name.to_string()), type(i_type.to_string()), texname(i_texname.to_string());
  PbrtImport::TextureParams tp(i_params, i_params, m_graphicsState.floatTextures, m_graphicsState.spectrumTextures);
  if (type == "float")
    {
    intrusive_ptr<const Texture<double>> ft = m_texture_factory.CreateFloatTexture(texname, m_current_transform, tp);
    if (ft) m_graphicsState.floatTextures[name] = ft;
    }
  else if (type == "color") 
    {
    intrusive_ptr<const Texture<SpectrumCoef_d>> st = m_texture_factory.CreateSpectrumCoefTexture(texname, m_current_transform, tp);
    if (st) m_graphicsState.spectrumTextures[name] = st;
    }
  else
    PbrtImport::Utils::LogError(mp_log, std::string("Texture type ") + type + std::string(" unknown."));
  }
Example #28
0
EventEngine::Ptr EventEngineFactory::createTP(const Config& p_config)
{
  Epoll::Ptr epoll(new Epoll());
  EpollED::Ptr epollED(new EpollED(epoll));
  EventEngines::ThreadPool::Ptr tp(new EventEngines::ThreadPool(epollED, p_config.eventEngineSize));

  KeyboardSocket::Ptr keybSocket(new KeyboardSocket());
  KeyboardES::Ptr keybES(new KeyboardES(keybSocket));
  EventHandler::Ptr keybEH(new KeyboardTPEH("log.txt", keybES, *tp));

  TcpSocket::Ptr listenerSokcet(new TcpSocket());
  ListenerES::Ptr listenerES(new ListenerES(listenerSokcet, p_config.port));
  EventHandler::Ptr acceptorEH(new AcceptorEH<EventEngines::ThreadPool>(listenerES, *tp));

  tp->add(keybEH);
  tp->add(acceptorEH);

  return EventEngine::Ptr(new ThreadPoolEE(tp));
}
Example #29
0
double solve()
{
	point tp(0,0,0),end(0,0,1),vec;
	double ang;	int i,cn;
	if(sign(a)) tp.x=d/a;
	else if(sign(b)) tp.y=d/b;
	else if(sign(c)) tp.z=d/c;
	ps[n+1]=tp;	vec=(point(a,b,c))*(end);
	if(sign(vec.x)==0) vec.x=0;
	if(sign(vec.y)==0) vec.y=0;
	if(sign(vec.z)==0) vec.z=0;
	ang=(a*end.x+b*end.y+c*end.z)/(point(a,b,c).getlen());
	ang=acos(ang);
	if(sign(ang)!=-0 && sign(ang-PI)!=0)
	for(i=0;i<n;i++) ps[i]=rotate(org,vec,ps[i],ang);
	for(int i=0;i<n;i++) ps[i].z=0;
	//然后求凸包面积
	return ans;
}
Example #30
0
/*
 * Set the cursor visibility (0 = invis, 1 = normal, 2 = bright)
 */
static void curs_set(int vis)
{
	char *v = NULL;

	if (!vis)
	{
		v = vi;
	}
	else if (vis > 1)
	{
		v = vs ? vs : ve;
	}
	else
	{
		v = ve ? ve : vs;
	}

	if (v) tp(v);
}