예제 #1
0
파일: GC.cpp 프로젝트: thinkermao/LL-Script
    void GarbageCollector::garbageCollect()
    {
        size_t old = from_space_->free_space_;

        forward_ = new Object[Ceil(space_size_)];
        memset((void*)forward_, 0, Ceil(space_size_));

        // queue
        Object scanned = (Object)to_space_->bottom_;

        // copy all glboal variables
        globalVariable_();

        // breadth-first scanning of object graph
        while (scanned < (Object)to_space_->top_)
        {
            Object parent_obj = scanned;
            variableReference_(&parent_obj);
            scanned += SizeOfObject(parent_obj);
        }

        // Now all live objects will have been evacuated into the to-space,
        // and we don't need the data in the from-space anymore.
        swapSpace();

        delete[]forward_;
        forward_ = nullptr;

#ifdef _DEBUG
        std::cout << "[GC] before free: " << old
            << ", after free: " << from_space_->free_space_
			<< ", used space:" << from_space_->space_size_ - from_space_->free_space_
            << ", total free space: " << from_space_->free_space_ - old << std::endl;
#endif // _DEBUG
	}
예제 #2
0
int OffsetCorrection(TextEdition *te)
{
    SDL_Rect pos, rect = te->pos;
    int c,l,doneX=1,doneY=1;

    rect.x = 0;
    rect.y = 0;
    rect.w -= VSBWidth(*te);
    rect.h -= HSBHeight(*te);
    GetPositionInEdition(*te, te->cursorPos, &l, &c);

    pos.x = te->tab[l][c].x + te->offsetX;
    pos.y = te->tab[l][c].y + te->offsetY;
    pos.w = 1;
    pos.h = te->fontHeight;
    if (pos.x < rect.x)
        te->offsetX = rect.x - te->tab[l][c].x;
    else if (pos.x + pos.w > rect.x + rect.w)
        te->offsetX = rect.x + rect.w - (te->tab[l][c].x + pos.w);
    else doneX = 0;
    if (pos.y < rect.y)
        te->offsetY = Ceil((rect.y - te->tab[l][c].y)*1.0/te->hSpace) * te->hSpace;
    else if (pos.y + pos.h > rect.y + rect.h)
        te->offsetY = Ceil((rect.y + rect.h - (te->tab[l][c].y + pos.h))*1.0/te->hSpace) * te->hSpace;
    else doneY = 0;

    if (doneX)
        SetHSBFromOffset(te);
    if (doneY)
        SetVSBFromOffset(te);

    return doneX || doneY;
}
예제 #3
0
파일: SceneMgr.cpp 프로젝트: lorichen/xgame
bool SceneMgr::createMapArray(xs::Rect& rcPreRead)
{
	int nCols = Ceil(rcPreRead.right - rcPreRead.left, 64);
	int nRows = Ceil(rcPreRead.bottom - rcPreRead.top, 32);
	m_nMatrixWidth = nCols + nRows;
	m_nMatrixHeight = m_nMatrixWidth - 1;

	m_rcMapTileRect.left = m_rcMapTileRect.top = 0;
	m_rcMapTileRect.right = m_nMatrixWidth;
	m_rcMapTileRect.bottom = m_nMatrixHeight;

	m_pTiles = new Tile[m_nMatrixWidth * m_nMatrixHeight]();

	if(m_pTiles == 0)
		return false;

	m_pMultiValueTable = new DWORD[m_nMatrixHeight];
	if (m_pMultiValueTable == 0)
		return false;
	for (int k=0,nVal=0; k<m_nMatrixHeight; k++,nVal+=m_nMatrixWidth)
		m_pMultiValueTable[k] = nVal;

	initBlockInfo((xs::Point&)rcPreRead, nRows, nCols*2,nRows,nCols*2);

	return true;
}
void gfx_font_adapter::translate_storage(void* storage, scalar x, scalar y)
{
    gfx_serialized_scanlines_adaptor_bin* sd = (gfx_serialized_scanlines_adaptor_bin*)storage;
    int ox = sd->x();
    int oy = sd->y();
    sd->setX(ox + SCALAR_TO_INT(Ceil(x)));
    sd->setY(oy + SCALAR_TO_INT(Ceil(y)));
}
예제 #5
0
파일: BST.c 프로젝트: richzw/CodeHome
// find ceil of a given input in BST. If input is more
// than the max key in BST, return -1
int Ceil(struct node* root, int input)
{
	if (root == NULL)
		return -1;
	if (root->data == input)
		return input;
	if (root->data < input)
		return Ceil(root->right, input);
	
	int ceil = Ceil(root->left, input);
	return (ceil >= input)? ceil: root->data;
}
예제 #6
0
/**
 *PrintGraphic
 *  打印图形.
 *Params:
 *  pGraphic[in] - 需要打印的图片.
 *  X0[in] - 相对打印区域左上角(X坐标), 单位: mm
 *  Y0[in] - 相对打印区域左上角(Y坐标), 单位: mm
 *  X1[in] - 相对打印区域右下角(X坐标), 单位: mm, 缺省: 0
 *  Y1[in] - 相对打印区域右下角(Y坐标), 单位: mm, 缺省: 0
 *  bStretch[in] - 是否进行缩放打印
 */
void __fastcall CPrinter::PrintGraphic(TGraphic* pGraphic, Extended X0, Extended Y0, Extended X1, Extended Y1,
                                       bool bStretch)
{
    if ((PPRN == NULL) || (pGraphic == NULL))
    {
        return ;
    }
    if (!PPRN->Printing)
    {
        return;
    }

    int px0 = Ceil(Ceil((X0 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py0 = Ceil(Ceil((Y0 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    int px1 = Ceil(Ceil((X1 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py1 = Ceil(Ceil((Y1 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    px0 = px0 + 2 * AvgCharWidth();
    py0 = py0 - GetOffSetY();
    px1 = px1 + 2 * AvgCharWidth();
    py1 = py1 - GetOffSetY();
    if (bStretch)
    {
        PPRN->Canvas->StretchDraw(TRect(px0, py0, px1, py1), pGraphic);
    }
    else
    {
        PPRN->Canvas->Draw(px0, py0, pGraphic);
    }
}
예제 #7
0
/**
 *PrintRectangle
 *  打印边框.
 *Params:
 *  X0[in] - 相对打印区域左上角(X坐标), 单位: mm
 *  Y0[in] - 相对打印区域左上角(Y坐标), 单位: mm
 *  X1[in] - 相对打印区域右下角(X坐标), 单位: mm
 *  Y1[in] - 相对打印区域右下角(Y坐标), 单位: mm
 *  bBold[in] - 是否画粗线
 *  LineColor[in] - 边框颜色, 缺省: clBlack(黑色)
 */
void __fastcall CPrinter::PrintRectangle(Extended X0, Extended Y0, Extended X1, Extended Y1, bool bBold,
                                         TColor LineColor)
{
    if (PPRN == NULL)
    {
        return ;
    }
    if (!PPRN->Printing)
    {
        return;
    }

    int px0 = Ceil(Ceil((X0 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py0 = Ceil(Ceil((Y0 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    int px1 = Ceil(Ceil((X1 + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py1 = Ceil(Ceil((Y1 + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    px0 = px0 + 2 * AvgCharWidth();
    py0 = py0 - GetOffSetY();
    px1 = px1 + 2 * AvgCharWidth();
    py1 = py1 - GetOffSetY();
    PPRN->Canvas->Pen->Width = bBold ? 2 : 1;
    PPRN->Canvas->Pen->Color = LineColor;
    PPRN->Refresh();
    PPRN->Canvas->Rectangle(px0, py0, px1, py1);
}
예제 #8
0
파일: SceneMgr.cpp 프로젝트: lorichen/xgame
void SceneMgr::loadBlockInfo(xs::Point& ptLeftTop, int nIndex, int nTileRow, int nTileCol)
{
	int row = nTileRow;
	int col = nTileCol;
	if (ptLeftTop.x + GRID_WIDTH > m_nMapWidth)
		nTileCol = Ceil(m_nMapWidth - ptLeftTop.x, 32);
	if (ptLeftTop.y + GRID_HEIGHT > m_nMapHeight)
		nTileRow = Ceil(m_nMapHeight - ptLeftTop.y, 32);
	initBlockInfo(ptLeftTop, nTileRow, nTileCol,row,col);
	m_pStream->seek(m_pMapTable[nIndex]);
	xs::Point ptTileLeftTop;
	m_SceneCo.pixel2Tile(ptLeftTop, ptTileLeftTop);
	_LoadBlock(m_pStream, ptTileLeftTop, nTileRow, nTileCol, m_pItemCF);
	m_pStream->seekToBegin();
}
예제 #9
0
ConvergenceResult Root_Bisection(RealFunction& f,Real& a, Real& b, Real& x, Real tol)
{
  Real fa,fb,fx,tol2;
  fa = f(a);
  fb = f(b);
  if(fa == 0) { x=b=a; return ConvergenceX; }
  if(fb == 0) { x=a=b; return ConvergenceX; }
  if(Sign(fa) == Sign(fb)) return ConvergenceError;  //must have opposing signs
  tol2 = tol*Two;
  int maxIters = (int)Ceil((Log(b-a)-Log(tol))/Ln2);
  x = Half*(a+b);
  for(int i=0;i<maxIters;i++) {
    fx = f(x);
    if(Sign(fx) == Sign(fa)) {  //shift a to x
      a = x; fa = fx;
    }
    else if(Sign(fx) == Sign(fb)) { //shift b to x
      b = x; fb = fx;
    }
    else {
      if(fx == 0) { return ConvergenceX;  }
      else {
	LOG4CXX_ERROR(KrisLibrary::logger(),"Weird error in Root_Bisection(), perhaps function not stateless?\n");
	return ConvergenceError;
      }
    }
    x = Half*(a+b);
  }
  return MaxItersReached;
}
예제 #10
0
int MilestonePath::DiscretizeEdge(int i,Real h)
{
  EdgePlanner* e=edges[i];
  const Config& a=e->Start();
  const Config& b=e->Goal();
  CSpace* space=e->Space();
  int numDivs = (int)Ceil(space->Distance(a,b)/h);
  //don't do anything...
  if(numDivs <= 1) return 1;

  //create a bunch of replacement edges
  Real du=One/numDivs;
  Real u=0;
  Config x1,x2;
  MilestonePath replacement;
  for(int k=0;k<numDivs;k++) {
    if(k==0) x1=a;
    else e->Eval(u,x1);
    if(k+1==numDivs) x2=b;
    else e->Eval(u+du,x2);
    EdgePlanner* e2 = space->LocalPlanner(x1,x2);
    if(e2->IsVisible()) 
      replacement.edges.push_back(e2);
    else {
      cerr<<"Warning, reparameterized edge "<<i<<" is infeasible"<<endl;
      replacement.edges.push_back(e2);
    }
    u += du;
  }
  Assert(!replacement.edges.empty());
  Splice(i,i+1,replacement);
  return replacement.edges.size();
}
예제 #11
0
int SetVSBFromOffset(TextEdition *te)
{
    int h = te->pos.h - HSBHeight(*te),
        length = (h * te->pos.h) / (te->tab[te->lastLine][0].y + te->hSpace);
    double z = te->tab[te->lastLine][0].y + te->hSpace - h;

    if (te->offsetY >= 0 || z <= 0)
        te->offsetY = 0;
    if (z > 0 && te->offsetY < (z = -(Ceil(z/te->hSpace)*te->hSpace)) )
        te->offsetY = z;

    if (length < h && SetVSBLength(te, length))
    {
        te->posVSB.y = ((h - length) * te->offsetY) / z;
        te->posVSB.x = te->pos.w - te->VScrollBar->w;
        return 1;
    }
    else
    {
        if (te->VScrollBar)
            SDL_FreeSurface(te->VScrollBar);
        te->VScrollBar = NULL;
        return 0;
    }
}
//---------------------------------------------------------------------------
// TImageBuffer constructor
//
__fastcall TImageBuffer::TImageBuffer(int Size, int Count) {

  FAllocSister = NULL;

  Sync = new TMultiReadExclusiveWriteSynchronizer();

  ChunkSize = Size;
  ChunkCount = 1 << (int)Ceil(Log2(Count));
  IndexMask = ChunkCount - 1;
  Chunks = new TBufferChunk *[ChunkCount];
  ChunkStates = new TBufferChunkState [ChunkCount];

  NextReadChunkIndex = NextWriteChunkIndex = 0;

  // Create all the buffer chunks
  for (unsigned n = 0; n < ChunkCount; n++) {
    Chunks[n] = new TBufferChunk(ChunkSize, n);
    ChunkStates[n] = csFree;
  }  // for (unsigned n = 0; n < nChunkCount; n++)

  // Initialize our event objects
  ReadChunkReady  = new TEvent(NULL, true, false, IntToHex((int)this, 8) + ":Read");
  if (!ReadChunkReady->Handle)
    throw ESelfImageSystemError("Failed to create image buffer read event object.");
  WriteChunkReady = new TEvent(NULL, true, false, IntToHex((int)this, 8) + ":Write");
  if (!WriteChunkReady->Handle)
    throw ESelfImageSystemError("Failed to create image buffer write event object.");

}  // TImageBuffer::TImageBuffer(int nChunkSize, int nChunkCount)
예제 #13
0
파일: film.cpp 프로젝트: Drooids/pbrt-v3
Bounds2i Film::GetSampleBounds() const {
    Bounds2f floatBounds(Floor(Point2f(croppedPixelBounds.pMin) +
                               Vector2f(0.5f, 0.5f) - filter->radius),
                         Ceil(Point2f(croppedPixelBounds.pMax) -
                              Vector2f(0.5f, 0.5f) + filter->radius));
    return (Bounds2i)floatBounds;
}
예제 #14
0
파일: 109p.c 프로젝트: RAJU009F/my-work
main()
    {
    struct BST *rt=NULL;
    
        rt=insert(rt,5);
        insert(rt,64);
        insert(rt,23);
        insert(rt,2);
        insert(rt,3);
        insert(rt,4);
        
        int i=0;
        printf("INPUT\tFLOOR\tCEIL\n");
        for(i=0;i<=34;i++)
            {
                int c=Ceil(rt,i);
                int f=Floor(rt,i);
                 printf(" [%d]\t[%d]\t[%d]\n",i,f,c);   
            
            }
        
    
    printf("\nInoredr:\n");
    printinorder(rt);
    int sum=0;
    addsum(rt,&sum);
    printf("\nInoredr:\n");
    printinorder(rt);
    printf("\n");
    }
예제 #15
0
파일: xim2col.cpp 프로젝트: gpu/CLBlast
void Xim2col<T>::DoIm2col(const size_t channels, const size_t height, const size_t width,
                          const size_t kernel_h, const size_t kernel_w, const size_t pad_h,
                          const size_t pad_w, const size_t stride_h, const size_t stride_w,
                          const size_t dilation_h, const size_t dilation_w,
                          const Buffer<T> &im_buffer, const size_t im_offset,
                          const Buffer<T> &col_buffer, const size_t col_offset) {

  // Makes sure all dimensions are larger than zero
  if ((channels == 0) || (height == 0) || (width == 0)) { throw BLASError(StatusCode::kInvalidDimension); }

  // Sets the output height and width
  const auto size_h = height + 2 * pad_h;
  const auto padding_h = dilation_h * (kernel_h - 1) + 1;
  const auto output_h = (size_h >= padding_h) ? (size_h - padding_h) / stride_h + 1 : 1;
  const auto size_w = width + 2 * pad_w;
  const auto padding_w = dilation_w * (kernel_w - 1) + 1;
  const auto output_w = (size_w >= padding_w) ? (size_w - padding_w) / stride_w + 1 : 1;

  // Retrieves the Xcopy kernel from the compiled binary
  auto kernel = Kernel(program_, "im2col");

  // Sets the kernel arguments
  kernel.SetArgument(0, static_cast<int>(height));
  kernel.SetArgument(1, static_cast<int>(width));
  kernel.SetArgument(2, static_cast<int>(channels));
  kernel.SetArgument(3, static_cast<int>(output_h));
  kernel.SetArgument(4, static_cast<int>(output_w));
  kernel.SetArgument(5, static_cast<int>(kernel_h));
  kernel.SetArgument(6, static_cast<int>(kernel_w));
  kernel.SetArgument(7, static_cast<int>(pad_h));
  kernel.SetArgument(8, static_cast<int>(pad_w));
  kernel.SetArgument(9, static_cast<int>(stride_h));
  kernel.SetArgument(10, static_cast<int>(stride_w));
  kernel.SetArgument(11, static_cast<int>(dilation_h));
  kernel.SetArgument(12, static_cast<int>(dilation_w));
  kernel.SetArgument(13, im_buffer());
  kernel.SetArgument(14, static_cast<int>(im_offset));
  kernel.SetArgument(15, col_buffer());
  kernel.SetArgument(16, static_cast<int>(col_offset));

  // Launches the kernel
  const auto w_ceiled = Ceil(output_w, db_["COPY_DIMX"]);
  const auto h_ceiled = Ceil(output_h, db_["COPY_DIMY"]);
  const auto global = std::vector<size_t>{w_ceiled, h_ceiled * channels};
  const auto local = std::vector<size_t>{db_["COPY_DIMX"], db_["COPY_DIMY"]};
  RunKernel(kernel, queue_, device_, global, local, event_);
}
예제 #16
0
파일: GC.cpp 프로젝트: thinkermao/LL-Script
 Semispace::Semispace(size_t size)
 {
     space_size_ = Ceil(size);
     bottom_ = new char[space_size_];
     end_ = bottom_ + space_size_;
     top_ = bottom_;
     free_space_ = space_size_;
 }
예제 #17
0
bool UserInput::empty() const
{
    return ( 
        history.size() == 0 && 
        min_variants.size() == 0 && 
        Ceil(*this).empty() 
        );
}
예제 #18
0
int SetOffsetFromVSB(TextEdition *te)
{
    int h = te->pos.h - HSBHeight(*te);
    double z = te->tab[te->lastLine][0].y + te->hSpace - h;

    if (!te->VScrollBar)
        return 0;

    if (te->posVSB.y < 0)
        te->posVSB.y = 0;
    if (te->posVSB.y > te->pos.h - HSBHeight(*te) - te->VScrollBar->h)
        te->posVSB.y = te->pos.h - HSBHeight(*te) - te->VScrollBar->h;

    te->offsetY = -(te->posVSB.y * (Ceil(z/te->hSpace)*te->hSpace)) / (h - te->VScrollBar->h);
    te->offsetY = Ceil(te->offsetY*1.0/te->hSpace) * te->hSpace;
    return 1;
}
예제 #19
0
파일: common.hpp 프로젝트: dividiti/CLBlast
void FillMatrix(Queue &queue, const Device &device,
                const Program &program, const Databases &,
                EventPointer event, const std::vector<Event> &waitForEvents,
                const size_t m, const size_t n, const size_t ld, const size_t offset,
                const Buffer<T> &dest,
                const T constant_value) {
  auto kernel = Kernel(program, "FillMatrix");
  kernel.SetArgument(0, static_cast<int>(m));
  kernel.SetArgument(1, static_cast<int>(n));
  kernel.SetArgument(2, static_cast<int>(ld));
  kernel.SetArgument(3, static_cast<int>(offset));
  kernel.SetArgument(4, dest());
  kernel.SetArgument(5, GetRealArg(constant_value));
  auto local = std::vector<size_t>{8, 8};
  auto global = std::vector<size_t>{Ceil(m, 8), Ceil(n, 8)};
  RunKernel(kernel, queue, device, global, local, event, waitForEvents);
}
예제 #20
0
static SDATE jdn_jalali( long jdn )
{
    static SDATE ret;
    int day, month, year;
    int iYear, iMonth, iDay;
    int depoch;
    int cycle;
    int cyear;
    int ycycle;
    int aux1, aux2;
    int yday;

    day = 1;
    month = 1;
    year = 475;
    depoch = jdn - jalali_jdn( year, month, day );
    cycle = ( int ) ( depoch / 1029983 );
    cyear = depoch % 1029983;
    if( cyear == 1029982 ) {
        ycycle = 2820;
    } else {
        aux1 = cyear / 366;
        aux2 = cyear % 366;
        ycycle = ( ( ( 2134 * aux1 ) + ( 2816 * aux2 ) + 2815 ) / 1028522 ) + aux1 + 1;
    }
    iYear = ycycle + ( 2820 * cycle ) + 474;
    if ( iYear <= 0 ) {
        iYear = iYear - 1;
    }
    year = iYear;
    yday = ( jdn - jalali_jdn( year, month, day ) ) + 1;
    if( yday <= 186 ) {
        iMonth = Ceil( ( yday - 1 ) / 31 );
    } else {
        iMonth = Ceil( ( yday - 7 ) / 30 );
    }
    iMonth++;
    month = iMonth;
    iDay = ( jdn - jalali_jdn( year, month, day ) ) + 1;
    ret.day = iDay;
    ret.mon = iMonth;
    ret.year = iYear;

    return ret;
}
예제 #21
0
파일: 109p.c 프로젝트: RAJU009F/my-work
int Ceil(struct BST *root,int input)
    {
        if(!root)
            return -1;
            
         if(root->data==input)
            return root->data;
            
         if(root->data<input)
            return Ceil(root->r,input);
            
          int c=Ceil(root->l,input);
          return c>=input?c:root->data;        
    
    
    
    
    }    
예제 #22
0
bool CheckBounds(Robot& robot,const TimeScaledBezierCurve& traj,Real dt)
{
  Real T=traj.EndTime();
  int numdivs = (int)Ceil(T/dt);
  vector<Real> times(numdivs);
  for(int i=0;i<numdivs;i++) 
    times[i] = T*Real(i)/Real(numdivs-1);  
  return CheckBounds(robot,traj,times);
}
예제 #23
0
파일: GC.cpp 프로젝트: thinkermao/LL-Script
 Object Semispace::allocateMemory(size_t size)
 {
     size_t space_size = Ceil(size);
     if (top_ + space_size > end_)
         return (Object)nullptr;
     Object obj = (Object)top_;
     top_ += space_size;
     free_space_ -= size;
     return obj;
 }
예제 #24
0
파일: film.cpp 프로젝트: Drooids/pbrt-v3
std::unique_ptr<FilmTile> Film::GetFilmTile(const Bounds2i &sampleBounds) {
    // Bound image pixels that samples in _sampleBounds_ contribute to
    Vector2f halfPixel = Vector2f(0.5f, 0.5f);
    Bounds2f floatBounds = (Bounds2f)sampleBounds;
    Point2i p0 = (Point2i)Ceil(floatBounds.pMin - halfPixel - filter->radius);
    Point2i p1 = (Point2i)Floor(floatBounds.pMax - halfPixel + filter->radius) +
                 Point2i(1, 1);
    Bounds2i tilePixelBounds = Intersect(Bounds2i(p0, p1), croppedPixelBounds);
    return std::unique_ptr<FilmTile>(new FilmTile(
        tilePixelBounds, filter->radius, filterTable, filterTableWidth));
}
예제 #25
0
void DebugRenderer::AddSphereSector(const Sphere& sphere, const Quaternion& rotation, float angle,
    bool drawLines, const Color& color, bool depthTest)
{
    if (angle <= 0.0f)
        return;
    else if (angle >= 360.0f)
    {
        AddSphere(sphere, color, depthTest);
        return;
    }

    static const unsigned numCircleSegments = 8;
    static const unsigned numLines = 4;
    static const float arcStep = 45.0f;

    const unsigned uintColor = color.ToUInt();
    const float halfAngle = 0.5f * angle;
    const unsigned numArcSegments = static_cast<unsigned>(Ceil(halfAngle / arcStep)) + 1;

    // Draw circle
    for (unsigned j = 0; j < numCircleSegments; ++j)
    {
        AddLine(
            sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, halfAngle),
            sphere.center_ + rotation * sphere.GetLocalPoint((j + 1) * 360.0f / numCircleSegments, halfAngle),
            uintColor);
    }

    // Draw arcs
    const unsigned step = numCircleSegments / numLines;
    for (unsigned i = 0; i < numArcSegments - 1; ++i)
    {
        for (unsigned j = 0; j < numCircleSegments; j += step)
        {
            const float nextPhi = i + 1 == numArcSegments - 1 ? halfAngle : (i + 1) * arcStep;
            AddLine(
                sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, i * arcStep),
                sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, nextPhi),
                uintColor);
        }
    }

    // Draw lines
    if (drawLines)
    {
        for (unsigned j = 0; j < numCircleSegments; j += step)
        {
            AddLine(sphere.center_,
                sphere.center_ + rotation * sphere.GetLocalPoint(j * 360.0f / numCircleSegments, halfAngle),
                uintColor);
        }
    }
}
예제 #26
0
/**
 *PrintText
 *  打印文本.
 *Params:
 *  sText[in] - 需要打印的文本
 *  X[in] - 相对打印区域左上角(X坐标), 单位: mm
 *  Y[in] - 相对打印区域左上角(Y坐标), 单位: mm
 *  FontSize[in] - 字体大小, 缺省:10
 *  FontColor[in] - 字体颜色, 缺省:clBlack(黑色)
 */
void __fastcall CPrinter::PrintText(AnsiString sText, Extended X, Extended Y, int FontSize, TColor FontColor)
{
    if (PPRN == NULL)
    {
        return ;
    }
    if (!PPRN->Printing)
    {
        return;
    }

    int px = Ceil(Ceil((X + eOffsX) * HPointsPerInch() * 10000 / 25.4) / 10000);
    int py = Ceil(Ceil((Y + eOffsY) * VPointsPerInch() * 10000 / 25.4) / 10000);
    px = px + 2 * AvgCharWidth();
    py = py - GetOffSetY();                 //绝对坐标, 不用换算成相对于Y轴坐标
    PPRN->Canvas->Font->Name = "宋体";
    PPRN->Canvas->Font->Size = FontSize;
    PPRN->Canvas->Font->Color = FontColor;
    PPRN->Refresh();
    PPRN->Canvas->TextOut(px, py, sText);
}
예제 #27
0
파일: anchors.cpp 프로젝트: ggrekhov/ugene
static void static_WindowSmooth(const SCORE Score[], unsigned uCount, unsigned uWindowLength,
  SCORE SmoothScore[], double dCeil)
	{
#define	Ceil(x)	((SCORE) ((x) > dCeil ? dCeil : (x)))

	if (1 != uWindowLength%2)
		Quit("WindowSmooth=%u must be odd", uWindowLength);

	if (uCount <= uWindowLength)
		{
		for (unsigned i = 0; i < uCount; ++i)
			SmoothScore[i] = 0;
		return;
		}

	const unsigned w2 = uWindowLength/2;
	for (unsigned i = 0; i < w2; ++i)
		{
		SmoothScore[i] = 0;
		SmoothScore[uCount - i - 1] = 0;
		}

	SCORE scoreWindowTotal = 0;
	for (unsigned i = 0; i < uWindowLength; ++i)
		{
		scoreWindowTotal += Ceil(Score[i]);
		}

	for (unsigned i = w2; ; ++i)
		{
		SmoothScore[i] = scoreWindowTotal/uWindowLength;
		if (i == uCount - w2 - 1)
			break;

		scoreWindowTotal -= Ceil(Score[i - w2]);
		scoreWindowTotal += Ceil(Score[i + w2 + 1]);
		}
#undef Ceil
	}
예제 #28
0
struct BT  *Ceil(struct BT *root, int key, struct BT **prev)
{
	if(root)
	{
		if(!Ceil(root->r, key, prev))
			return NULL;
		if(root->data==key)
				return root;
		 if(root->data<key)
				return (*prev);
	
			*prev = root;
		return Ceil(root->l, key, prev);
		
		
	}else
		
	return NULL;
	
	
	
}
예제 #29
0
double TfSbornyZakaz::Sum() {
	LockWindowUpdate(Handle);
	double sum = 0;

	// здесь сбрасываем использование принтеров
	for (int i = 0; i < listOfTools->Count; i++) {
		TTool *tool = (TTool*)listOfTools->Items[i];
		tool->SetUse(false);
	}

	// чистим
	slgoods->Clear();
	Memo1->Clear();
	sldescription->Clear();

	if (sbForSelFrame->ControlCount == 0) {
		sum = 0;
	}
	else {
		// поищем что есть посчитать, все фреймы, виртуальная функция Sum
		for (int i = 0; i < listOfIzdelies->Count; i++) {
			TfrSelectable *izdelie =
				dynamic_cast<TfrSelectable*>(listOfIzdelies->Items[i]);
			sum += izdelie->Sum();
		}

		double zakazCount = spCount->Value;
		// подсчитаем использование оборудования
		for (int i = 0; i < listOfTools->Count; i++) {
			TToolPrepareTool *tool =
				dynamic_cast<TToolPrepareTool*>(listOfTools->Items[i]);
			if (tool && tool->GetUse() == true) {
				Memo1->Lines->Add(tool->prepareTool->myToString(zakazCount));
				sum += Ceil(tool->prepareTool->price * zakazCount);
			}
		}

	}

	lbAllPrice->Caption = "Сумма: " + FloatToStrF(sum, ffFixed, 10, 2) +
		" руб.";

	allsum = sum;

	LockWindowUpdate(NULL);
	return sum;
}
예제 #30
0
CMatlibVector<CReal> Bartlett(const int iLen)
{
	const int iHalf = (int) Ceil((CReal) iLen / 2);
	CMatlibVector<CReal> fvHalfWin(iHalf);
	CMatlibVector<CReal> fvRet(iLen, VTY_TEMP);

	for (int i = 0; i < iHalf; i++)
		fvHalfWin[i] = (CReal) 2.0 * i / (iLen - 1);

	/* Build complete output vector depending on odd or even input length */
	if (iLen % 2)
		fvRet.Merge(fvHalfWin, fvHalfWin(iHalf - 1, -1, 1)); /* Odd */
	else
		fvRet.Merge(fvHalfWin, fvHalfWin(iHalf, -1, 1)); /* Even */

	return fvRet;
}