当前位置: 首页>>代码示例>>C++>>正文


C++ Region类代码示例

本文整理汇总了C++中Region的典型用法代码示例。如果您正苦于以下问题:C++ Region类的具体用法?C++ Region怎么用?C++ Region使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Region类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: validate

bool Region::validate(const Region& reg, const char* name)
{
    bool result = true;
    const_iterator cur = reg.begin();
    const_iterator const tail = reg.end();
    const_iterator prev = cur++;
    Rect b(*prev);
    while (cur != tail) {
        b.left   = b.left   < cur->left   ? b.left   : cur->left;
        b.top    = b.top    < cur->top    ? b.top    : cur->top;
        b.right  = b.right  > cur->right  ? b.right  : cur->right;
        b.bottom = b.bottom > cur->bottom ? b.bottom : cur->bottom;
        if (cur->top == prev->top) {
            if (cur->bottom != prev->bottom) {
                LOGE("%s: invalid span %p", name, cur);
                result = false;
            } else if (cur->left < prev->right) {
                LOGE("%s: spans overlap horizontally prev=%p, cur=%p",
                        name, prev, cur);
                result = false;
            }
        } else if (cur->top < prev->bottom) {
            LOGE("%s: spans overlap vertically prev=%p, cur=%p",
                    name, prev, cur);
            result = false;
        }
        prev = cur;
        cur++;
    }
    if (b != reg.getBounds()) {
        result = false;
        LOGE("%s: invalid bounds [%d,%d,%d,%d] vs. [%d,%d,%d,%d]", name,
                b.left, b.top, b.right, b.bottom,
                reg.getBounds().left, reg.getBounds().top, 
                reg.getBounds().right, reg.getBounds().bottom);
    }
    if (result == false) {
        reg.dump(name);
    }
    return result;
}
开发者ID:Alberto96,项目名称:frameworks_base,代码行数:41,代码来源:Region.cpp

示例2: TEST

TEST(Region, Iterators)
{
  Region a;
  a.createUnion(a, Region(Rect(0, 0, 32, 64)));
  a.createUnion(a, Region(Rect(0, 0, 64, 32)));
  int c = 0;
  for (Region::iterator it=a.begin(), end=a.end(); it!=end; ++it) {
    ++c;
  }
  EXPECT_EQ(2, c);

  c = 0;
  for (Region::const_iterator it=a.begin(), end=a.end(); it!=end; ++it) {
    ++c;
  }
  EXPECT_EQ(2, c);
}
开发者ID:1007650105,项目名称:aseprite,代码行数:17,代码来源:region_tests.cpp

示例3: RegionForSid

void
Palette::processCursor(SpaceCursor* c, int downdragup) {
	Region* r = RegionForSid(c->sid);
	c->region = r;
	if ( r ) {
		if ( r->isButton() ) {
			switch (downdragup) {
			case CURSOR_DOWN: r->buttonDown(); break;
			case CURSOR_UP: r->buttonUp(); break;
			}
		} else {
			switch (downdragup) {
			case CURSOR_DOWN: r->cursorDown(c); break;
			case CURSOR_DRAG: r->cursorDrag(c); break;
			case CURSOR_UP: r->cursorUp(c); break;
			}
		}
	} else {
		NosuchErrorOutput("Palette::processCursor Unable to find region (A) for sid=%d/%s",c->sid,c->source.c_str());
	}
}
开发者ID:nosuchtim,项目名称:manifold_postpalette,代码行数:21,代码来源:Palette.cpp

示例4: ASSERT

void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion)
{
    unpaintedRegion = rect;

    if (isInAcceleratedCompositingMode())
        return;

    ASSERT(m_currentBackingStoreStateID <= m_nextBackingStoreStateID);
    if (m_currentBackingStoreStateID < m_nextBackingStoreStateID) {
        // Tell the web process to do a full backing store update now, in case we previously told
        // it about our next state but didn't request an immediate update.
        sendUpdateBackingStoreState(RespondImmediately);

        if (m_isWaitingForDidUpdateBackingStoreState) {
            // Wait for a DidUpdateBackingStoreState message that contains the new bits before we paint
            // what's currently in the backing store.
            waitForAndDispatchDidUpdateBackingStoreState();
        }

        // Dispatching DidUpdateBackingStoreState (either beneath sendUpdateBackingStoreState or
        // beneath waitForAndDispatchDidUpdateBackingStoreState) could destroy our backing store or
        // change the compositing mode.
        if (!m_backingStore || isInAcceleratedCompositingMode())
            return;
    } else {
        ASSERT(!m_isWaitingForDidUpdateBackingStoreState);
        if (!m_backingStore) {
            // The view has asked us to paint before the web process has painted anything. There's
            // nothing we can do.
            return;
        }
    }

    m_backingStore->paint(context, rect);
    unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size()));

    discardBackingStoreSoon();
}
开发者ID:dankurka,项目名称:webkit_titanium,代码行数:38,代码来源:DrawingAreaProxyImpl.cpp

示例5: if

//recursively identify a contiguous region of the same color, or any color
//contiguous here means all blocks are connected by an edge
void Region::identifyRegion(Region& region, Coord orig, unsigned char color)
{
    if (orig.x >= nextris::options::get_options().game.width || orig.y >= nextris::options::get_options().game.height ||
            orig.x < 0 || orig.y < 0) //edge!
        return;
    if (region.grid[orig.x][orig.y] == NULL) //no block
        return;
    if (region.grid[orig.x][orig.y]->getColor() != color && color != 255) //wrong color
        return;

    cdebug << "Entering Region::identifyRegion()\n";

    //prevent duplicate adds
    for (unsigned int i = 0; i < region.blocks.size(); ++i)
        if (region.blocks[i]->isAt(orig) )
            return;
        else if (region.blocks[i] == region.grid[orig.x][orig.y])
            return;

    //add this block
    cdebug << "Adding " << orig.x << "," << orig.y << "\n";
    if (region.grid[orig.x][orig.y] == NULL)
        cdebug << "BUT IT'S NULL!!1????\n";
    region.addBlock(region.grid[orig.x][orig.y]);

    //recurse for neighbors
    Coord c1 = {orig.x, orig.y + 1},
          c2 = {orig.x, orig.y - 1},
          c3 = {orig.x - 1, orig.y},
          c4 = {orig.x + 1, orig.y};

    identifyRegion(region, c1, color);
    identifyRegion(region, c2, color);
    identifyRegion(region, c3, color);
    identifyRegion(region, c4, color);

    cdebug << "Exiting Region::identifyRegion()\n";
}
开发者ID:Cheezmeister,项目名称:Nextris,代码行数:40,代码来源:block.cpp

示例6: fillRegionWithColor

void RenderEngine::fillRegionWithColor(const Region& region, uint32_t height,
                                       float red, float green, float blue, float alpha) {
    size_t c;
    Rect const* r = region.getArray(&c);
    Mesh mesh(Mesh::TRIANGLES, c*6, 2);
    Mesh::VertexArray<vec2> position(mesh.getPositionArray<vec2>());
    for (size_t i=0 ; i<c ; i++, r++) {
        position[i*6 + 0].x = r->left;
        position[i*6 + 0].y = height - r->top;
        position[i*6 + 1].x = r->left;
        position[i*6 + 1].y = height - r->bottom;
        position[i*6 + 2].x = r->right;
        position[i*6 + 2].y = height - r->bottom;
        position[i*6 + 3].x = r->left;
        position[i*6 + 3].y = height - r->top;
        position[i*6 + 4].x = r->right;
        position[i*6 + 4].y = height - r->bottom;
        position[i*6 + 5].x = r->right;
        position[i*6 + 5].y = height - r->top;
    }
    setupFillWithColor(red, green, blue, alpha);
    drawMesh(mesh);
}
开发者ID:,项目名称:,代码行数:23,代码来源:

示例7:

void
Network::link(const std::string& srcRegionName, const std::string& destRegionName, 
              const std::string& linkType, const std::string& linkParams, 
              const std::string& srcOutputName, const std::string& destInputName)
{
  
  // Find the regions
  if (! regions_.contains(srcRegionName))
    NTA_THROW << "Network::link -- source region '" << srcRegionName << "' does not exist";
  Region* srcRegion = regions_.getByName(srcRegionName);
  
  if (! regions_.contains(destRegionName))
    NTA_THROW << "Network::link -- dest region '" << destRegionName << "' does not exist";
  Region* destRegion = regions_.getByName(destRegionName);

  // Find the inputs/outputs
  const Spec* srcSpec = srcRegion->getSpec();
  std::string outputName = srcOutputName;
  if (outputName == "")
    outputName = srcSpec->getDefaultOutputName();
  
  Output* srcOutput = srcRegion->getOutput(outputName);
  if (srcOutput == NULL)
    NTA_THROW << "Network::link -- output " << outputName 
              << " does not exist on region " << srcRegionName;


  const Spec *destSpec = destRegion->getSpec();
  std::string inputName;
  if (destInputName == "")
    inputName = destSpec->getDefaultInputName();
  else
    inputName = destInputName;

  Input* destInput = destRegion->getInput(inputName);
  if (destInput == NULL)
  {
    NTA_THROW << "Network::link -- input '" << inputName 
              << " does not exist on region " << destRegionName;
  }

  // Create the link itself
  destInput->addLink(linkType, linkParams, srcOutput);

}
开发者ID:Asele,项目名称:nupic.core,代码行数:45,代码来源:Network.cpp

示例8: createRegions

void createRegions(struct rt_wdb* wdbp)
{
    struct wmember tophead;
    BU_LIST_INIT(&tophead.l);

    for (std::map<std::string, Region*>::iterator it = regionTable.begin();
	it != regionTable.end();
	++it) {
	Region* regionp = it->second;

	std::cout << regionp->getDescription() << std::endl;

	if ((regionp->getMaterial() != 0) && (regionp->nonEmpty()))
	    regionp->push(wdbp, &tophead);
	else
	    std::cout << "Empty region: " << regionp->getCompNr() << (regionp->referred() ? " (referred)" : " (unreferred)") << std::endl;
    }

    mk_lfcomb(wdbp, "g_all", &tophead, 0);

    mk_freemembers(&tophead.l);
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:22,代码来源:regtab.cpp

示例9: ATRACE_CALL

void Layer::unlockPageFlip(
        const Transform& planeTransform, Region& outDirtyRegion)
{
    ATRACE_CALL();

    Region postedRegion(mPostedDirtyRegion);
    if (!postedRegion.isEmpty()) {
        mPostedDirtyRegion.clear();
        if (!visibleRegionScreen.isEmpty()) {
            // The dirty region is given in the layer's coordinate space
            // transform the dirty region by the surface's transformation
            // and the global transformation.
            const Layer::State& s(drawingState());
            const Transform tr(planeTransform * s.transform);
            postedRegion = tr.transform(postedRegion);

            // At this point, the dirty region is in screen space.
            // Make sure it's constrained by the visible region (which
            // is in screen space as well).
            postedRegion.andSelf(visibleRegionScreen);
            outDirtyRegion.orSelf(postedRegion);
        }
    }
}
开发者ID:,项目名称:,代码行数:24,代码来源:

示例10: MakeSelectedRegionsByCountry

Node::PtrList RegionsBuilder::MakeSelectedRegionsByCountry(Region const & country,
                                                           Regions const & allRegions)
{
  std::vector<LevelRegion> regionsInCountry{{PlaceLevel::Country, country}};
  for (auto const & region : allRegions)
  {
    if (country.ContainsRect(region))
      regionsInCountry.emplace_back(GetLevel(region), region);
  }

  auto const comp = [](LevelRegion const & l, LevelRegion const & r) {
    auto const lArea = l.GetArea();
    auto const rArea = r.GetArea();
    return lArea != rArea ? lArea > rArea : l.GetRank() < r.GetRank();
  };
  std::sort(std::begin(regionsInCountry), std::end(regionsInCountry), comp);

  Node::PtrList nodes;
  nodes.reserve(regionsInCountry.size());
  for (auto && region : regionsInCountry)
    nodes.emplace_back(std::make_shared<Node>(std::move(region)));

  return nodes;
}
开发者ID:milchakov,项目名称:omim,代码行数:24,代码来源:regions_builder.cpp

示例11: remove

void Image::remove(Region& reg)
{
	int minX, minY, maxX, maxY;

	minX = reg.OffsetX();
	minY = reg.OffsetY();

	maxX = width < minX + reg.Width() ? width : minX + reg.Width();
	maxY = height < minY + reg.Height() ? height : minY + reg.Height();

	int i, j;

	for (j = minY; j < maxY; j++)
	{
		for (i = minX; i < maxX; i++)
		{
			if (reg(i - minX, j - minY) == 255)
			{
				this->operator ()(i, j) = 0;
			}
		}
	}

}
开发者ID:tetratec,项目名称:runescape-classic-dump,代码行数:24,代码来源:Image.cpp

示例12: post_force

void FixEfield::post_force(int vflag)
{
  double **f = atom->f;
  double *q = atom->q;
  int *mask = atom->mask;
  imageint *image = atom->image;
  int nlocal = atom->nlocal;

  // reallocate efield array if necessary

  if (varflag == ATOM && nlocal > maxatom) {
    maxatom = atom->nmax;
    memory->destroy(efield);
    memory->create(efield,maxatom,4,"efield:efield");
  }

  // update region if necessary

  Region *region = NULL;
  if (iregion >= 0) {
    region = domain->regions[iregion];
    region->prematch();
  }

  // fsum[0] = "potential energy" for added force
  // fsum[123] = extra force added to atoms

  fsum[0] = fsum[1] = fsum[2] = fsum[3] = 0.0;
  force_flag = 0;

  double **x = atom->x;
  double fx,fy,fz;

  // constant efield

  if (varflag == CONSTANT) {
    double unwrap[3];

    // charge interactions
    // force = qE, potential energy = F dot x in unwrapped coords

    if (qflag) {
      for (int i = 0; i < nlocal; i++)
        if (mask[i] & groupbit) {
          if (region && !region->match(x[i][0],x[i][1],x[i][2])) continue;
          fx = q[i]*ex;
          fy = q[i]*ey;
          fz = q[i]*ez;
          f[i][0] += fx;
          f[i][1] += fy;
          f[i][2] += fz;

          domain->unmap(x[i],image[i],unwrap);
          fsum[0] -= fx*unwrap[0]+fy*unwrap[1]+fz*unwrap[2];
          fsum[1] += fx;
          fsum[2] += fy;
          fsum[3] += fz;
        }
    }

    // dipole interactions
    // no force, torque = mu cross E, potential energy = -mu dot E

    if (muflag) {
      double **mu = atom->mu;
      double **t = atom->torque;
      double tx,ty,tz;
      for (int i = 0; i < nlocal; i++)
        if (mask[i] & groupbit) {
          if (region && !region->match(x[i][0],x[i][1],x[i][2])) continue;
          tx = ez*mu[i][1] - ey*mu[i][2];
          ty = ex*mu[i][2] - ez*mu[i][0];
          tz = ey*mu[i][0] - ex*mu[i][1];
          t[i][0] += tx;
          t[i][1] += ty;
          t[i][2] += tz;
          fsum[0] -= mu[i][0]*ex + mu[i][1]*ey + mu[i][2]*ez;
        }
    }

  // variable efield, wrap with clear/add
  // potential energy = evar if defined, else 0.0

  } else {

    modify->clearstep_compute();

    if (xstyle == EQUAL) ex = qe2f * input->variable->compute_equal(xvar);
    else if (xstyle == ATOM)
      input->variable->compute_atom(xvar,igroup,&efield[0][0],4,0);
    if (ystyle == EQUAL) ey = qe2f * input->variable->compute_equal(yvar);
    else if (ystyle == ATOM)
      input->variable->compute_atom(yvar,igroup,&efield[0][1],4,0);
    if (zstyle == EQUAL) ez = qe2f * input->variable->compute_equal(zvar);
    else if (zstyle == ATOM)
      input->variable->compute_atom(zvar,igroup,&efield[0][2],4,0);
    if (estyle == ATOM)
      input->variable->compute_atom(evar,igroup,&efield[0][3],4,0);

    modify->addstep_compute(update->ntimestep + 1);
//.........这里部分代码省略.........
开发者ID:altynbekm,项目名称:lammps,代码行数:101,代码来源:fix_efield.cpp

示例13: StepRegion

void StepRegion(Region &Reg, double TimeStp, double &MinTimeStp, double &PresDeriv) {
    Reg.StepRegion(TimeStp, MinTimeStp, PresDeriv);
};
开发者ID:pyal,项目名称:eos_cpp,代码行数:3,代码来源:eno_my.cpp

示例14: PreClc

void PreClc(Region &Reg) {
    Reg.ClcMass();
};
开发者ID:pyal,项目名称:eos_cpp,代码行数:3,代码来源:eno_my.cpp

示例15: main

void main(int argc, char *argv[]) {
    argc--;
    cout << " uil_my - version\n";
    cout << " Coreleft " << Coreleft() << "\n";
    //   char tmp[50];
    if((argc < 2) || (GetCmd("/h", argc, argv) != NULL)) {
        cout
            << "usage:\n"
            << argv[0] << "  in_lmethod  output_file\n"
            << "      /h - display help\n"
            << "      /dN - set dimension N\n"
            << "      /s - Skip vacuum for better show\n"
            << "      /oT - output in T times more frequently when something happens on the bound\n"
            << "      /eN - Skip calculation of sound N times ( 10 by default )\n"
            <<
#ifndef InternalPointsUrs
            "  current version - no internal points \n";
#else
            "  current version - with internal points \n";
#endif
        exit(1);
    }

    my_file = new fstream(argv[2], ios::out);


    int FstIter = 0;
    double TimeStp, EndTime, CurTime = 0, TimeWrite, PresDerivCoef;
    Region *Reg = GetRegion(
        argv[1], *my_file, FstIter, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime);
    //	my_file->close();};/*

    double CoefUp = 1, NumSkipS = 10;
    char *tmp;
    if((tmp = GetCmd("/e", argc, argv)) != NULL)
        NumSkipS = atoi(tmp);
    if((tmp = GetCmd("/o", argc, argv)) != NULL)
        CoefUp = min(atof(tmp), 1);
    if((tmp = GetCmd("/s", argc, argv)) != NULL)
        Reg->RegionShow = 1;
    int d = 1;
    if((tmp = GetCmd("/d", argc, argv)) != NULL)
        d = atoi(tmp);
    //cout<<d<<"\n";

    Reg->SetBodySkipS(NumSkipS);

    Reg->SetWorkDim(d);
    Reg->ClcMass();
    int x = 1;

    double CurStp, OldTimeWrite, NewTimeWrite, PresDeriv = 1, OldStp = 1e5;
    int BreakSignal = 0;
    Time_struct Time;
    double CurStpSum = 0;
    int CurStpNum = 1;
    cout << " Before clc Coreleft " << Coreleft() << "\n";
    while((!(CurTime >= EndTime)) && (!BreakSignal)) {
        OldTimeWrite = CurTime;
        NewTimeWrite =
            min(OldTimeWrite + TimeWrite / (1 + PresDeriv * PresDerivCoef), EndTime);
        //cout<<" Before While NewTime "<<NewTimeWrite<<"\n";
        while((!(CurTime >= NewTimeWrite)) && (!BreakSignal)) {
            NewTimeWrite =
                min(OldTimeWrite + TimeWrite / (1 + PresDeriv * PresDerivCoef), EndTime);
            if(x < 100) {
                x++;
                CurStp = 0.5 * log10(x) * TimeStp;
            } else
                CurStp = TimeStp;
            if(CurStp + CurTime > NewTimeWrite)
                CurStp = NewTimeWrite - CurTime;
            if(CurStp < MathZer)
                break;
            if(CurStp > OldStp)
                CurStp = OldStp * (CoefUp * log(CurStp / OldStp) + 1);
            OldStp = CurStp;
            CurStpSum += CurStp;
            CurStpNum++;

            CurTime += CurStp;
            StepRegion(*Reg, CurStp, TimeStp, PresDeriv);
        }
        OutHead(*my_file, *Reg, CurTime, TimeStp, TimeWrite, PresDerivCoef, EndTime);
        cout << " Write !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1\n";
        cout << " CurStp " << CurStpSum / CurStpNum << " CurTime " << CurTime << "\n";
        CurStpNum = 1;
        CurStpSum = 0;
#ifdef WCPP
        if(_kbhit()) {
            BreakSignal = _getch();
            if(BreakSignal == ESC)
                break;
        }
#else
        while((BreakSignal = bioskey(1)) != 0)
            if(BreakSignal == ESC)
                break;
            else {
                cout << " " << BreakSignal;
//.........这里部分代码省略.........
开发者ID:pyal,项目名称:eos_cpp,代码行数:101,代码来源:eno_my.cpp


注:本文中的Region类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。