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


C++ PointArray::push_back方法代码示例

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


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

示例1: makeRectanglePoints

PointArray ShapeManager::makeRectanglePoints(int x, int y, int width, int height)
{
    PointArray points;
    points.push_back(Point(x, y));
    points.push_back(Point(x + width, y));
    points.push_back(Point(x + width, y + height));
    points.push_back(Point(x, y + height));

    return points;
}
开发者ID:jjangminkim,项目名称:AmsongApp,代码行数:10,代码来源:ShapeManager.cpp

示例2: SplineInterpolate

static void SplineInterpolate( const PointArray& inPts, PointArray& outPts, unsigned int N )
{
    int point_num = inPts.size();

    // 闭合
    bool isClose = IsPointEqual( inPts.back(), inPts.front() );
    if( isClose )
    {
        point_num--;
    }

    // Creates all control points to create the curve of
    Spline::ControlPoint* points = new Spline::ControlPoint[point_num];
    for( int i = 0; i < point_num; i++ )
    {
        points[i].position.x = ( float )inPts[i].x;
        points[i].position.y = ( float )inPts[i].y;
        points[i].position.z = 0.0f;
    }

    // Creates the curve. First argument is a pointer to the control points.
    // Second argument is the number of control points. The third is the curve type.
    // 注:使用cardinal spline,类型为CARDINAL(默认系数为1)或 CATMULLROM(自动计算系数)
    SplineWrapper* curve = new SplineWrapper( points, point_num, CATMULLROM );

    // 偏移量(将个数放大1倍,更加细密一些)
    //const int N = 1;
    const float C = 0.8f;
    float d = curve->getLength() / ( point_num * N - 1 );
    // The SplineWrapper has a position which is a value between 0 and the total length
    // of the curve. With the move(...) function you can increase or decrease this value
    // to move on the curve. The getPosition() function returns the world position
    // depending on how far you have moved on the curve.
    while( !curve->isEndReached() )
    {
        // Get the world position
        Position pos = curve->getPosition();
        outPts.push_back( Position2DT_Point( pos ) );

        // Travel 0.5 units on the curve each iteration
        curve->move( d );
    }
    outPts.push_back( inPts[point_num - 1] );
    delete curve;

    // 删除点数组内存
    delete [] points;
    points = 0;

    if( isClose )
    {
        outPts.push_back( inPts.front() );
    }
}
开发者ID:kanbang,项目名称:myexercise,代码行数:54,代码来源:Smooth.cpp

示例3: Open

	static bool Open(PointArray& PA, char* FileName) {
		char buf[10];
		Point A(0,0);
		ifstream f(FileName);
		if(!f) return true;
		f >> buf; if(lstrcmp(buf,"X")) return true;
		f >> buf; if(lstrcmp(buf,"Y")) return true;
		while(!f.eof()){
			f >> A.X; f >> A.Y;
			PA.push_back(A);
		}
		return false;
	}
开发者ID:Make-Believe,项目名称:FRIS,代码行数:13,代码来源:main.cpp

示例4: read_bundler_points

void read_bundler_points(std::ifstream &file, unsigned int n_points, PointArray& point_list)
{
	point_list.reserve(n_points);

	for (unsigned int i = 0; i < n_points; ++i) {
		double p0, p1, p2; // position
		int r, g, b; // color;
		unsigned int n_vis;

		file >> p0 >> p1 >> p2;
		file >> r >> g >> b;
		file >> n_vis;

		Point point;
		read_visibility(file, n_vis, point.visibility_list);

		point.position << p0, p1, p2;
		point.color << r, g, b;

		point_list.push_back(point);
	}
}
开发者ID:srajotte,项目名称:easyBA,代码行数:22,代码来源:io.cpp

示例5: ApproximatePolygon

static void ApproximatePolygon( const PointArray& cnpts, PointArray& polygon, double tolerance )
{
    if( cnpts.empty() ) return;

    int n = cnpts.size();
    // 是否封闭等值线???
    if( IsPointEqual( cnpts.front(), cnpts.back() ) )
    {
        n--;
    }
    int minEdge = n + 1, k = n;

    IntArray indexes;
    for( int i = 0; i < ( int )cnpts.size(); i++ )
    {
        indexes.push_back( i );
    }
    while( k < minEdge )
    {
        minEdge = k;
        int p = 0;
        while( p < minEdge - ( n % 2 == 0 ? 3 : 2 ) )
        {
            double distance = GetPointDistanceToLine( cnpts[indexes[p + 1]], cnpts[indexes[p]], cnpts[indexes[p + 2]] );
            if ( distance < tolerance )
            {
                indexes[p + 1] = -1;
                k -= 1;
            }
            p += 2;
        }
        UpdateIndexes( indexes );
    }

    for( int i = 0; i < ( int )indexes.size(); i++ )
    {
        polygon.push_back( cnpts[indexes[i]] );
    }
}
开发者ID:kanbang,项目名称:myexercise,代码行数:39,代码来源:Label.cpp

示例6: initPoints

void ShapeManager::initPoints()
{
    // 기본 값으로 position setting.
    clearAllPositions();

    // BIG_REV_TRI
    PointArray points;
    points.push_back(Point(240, 360));
    points.push_back(Point(1040, 360));
    points.push_back(Point(640, 700));
    _triangles[BIG_REV_TRI].setPoints(points);
    points.clear();

    // MID_REV_TRI
    points.push_back(Point(340, 360));
    points.push_back(Point(940, 360));
    points.push_back(Point(640, 600));
    _triangles[MID_REV_TRI].setPoints(points);
    points.clear();

    // SMALL_REV_TRI
    points.push_back(Point(440, 360));
    points.push_back(Point(840, 360));
    points.push_back(Point(640, 500));
    _triangles[SMALL_REV_TRI].setPoints(points);
    points.clear();

    // MINI_REV_TRI
    points.push_back(Point(404, 500));
    points.push_back(Point(876, 500));
    points.push_back(Point(640, 700));
    _triangles[MINI_REV_TRI].setPoints(points);
    points.clear();

    // MICRO_REV_TRI
    points.push_back(Point(514, 500));
    points.push_back(Point(764, 500));
    points.push_back(Point(640, 600));
    _triangles[MICRO_REV_TRI].setPoints(points);
    points.clear();

    // PIES
    points.push_back(Point(240, 20));
    points.push_back(Point(1040, 700));
    Angle angle;
    angle = std::make_pair(180.0F, 180.0F);
    _pies[BIG_CENTER_PIE].setPoints(points);
    _pies[BIG_CENTER_PIE].setAngle(angle);

    points.push_back(Point(240, 20));
    points.push_back(Point(1040, 700));
    angle = std::make_pair(180.0F, 40.0F);
    _pies[BIG_LEFT_PIE].setPoints(points);
    _pies[BIG_LEFT_PIE].setAngle(angle);
    points.clear();

    points.push_back(Point(240, 20));
    points.push_back(Point(1040, 700));
    angle = std::make_pair(320.0F, 40.0F);
    _pies[BIG_RIGHT_PIE].setPoints(points);
    _pies[BIG_RIGHT_PIE].setAngle(angle);
    points.clear();

    points.push_back(Point(340, 120));
    points.push_back(Point(940, 600));
    angle = std::make_pair(180.0F, 180.0F);
    _pies[MID_PIE].setPoints(points);
    _pies[MID_PIE].setAngle(angle);
    points.clear();

    points.push_back(Point(440, 220));
    points.push_back(Point(840, 500));
    angle = std::make_pair(180.0F, 180.0F);
    _pies[SMALL_PIE].setPoints(points);
    _pies[SMALL_PIE].setAngle(angle);
    points.clear();

    // RECTANGLES
    points = makeRectanglePoints(280, 160, 50, 50);
    _rectangles[OUT_LEFT_RECT].setPoints(points);

    points = makeRectanglePoints(615, 30, 50, 50);
    _rectangles[OUT_CENTER_RECT].setPoints(points);

    points = makeRectanglePoints(950, 160, 50, 50);
    _rectangles[OUT_RIGHT_RECT].setPoints(points);

    points = makeRectanglePoints(430, 180, 40, 40);
    _rectangles[MID_LEFT_RECT].setPoints(points);

    points = makeRectanglePoints(810, 180, 40, 40);
    _rectangles[MID_RIGHT_RECT].setPoints(points);

    points = makeRectanglePoints(480, 290, 40, 40);
    _rectangles[IN_LEFT_RECT].setPoints(points);

    points = makeRectanglePoints(800, 290, 40, 40);
    _rectangles[IN_RIGHT_RECT].setPoints(points);

    points = makeRectanglePoints(620, 550, 40, 40);
//.........这里部分代码省略.........
开发者ID:jjangminkim,项目名称:AmsongApp,代码行数:101,代码来源:ShapeManager.cpp

示例7: searchBoundary

void Contour::searchBoundary( PointArray& bpts, IntArray& bpos )
{
    // 记录所有边界分支
    BoundaryEdgeArray bea;
    for( int i = 0; i < ( int )eaa.size(); i++ )
    {
        if( eaa[i]->isBoundary() )
        {
            BoundaryEdge be = {i, false};
            bea.push_back( be );
        }
    }
    if( bea.empty() ) return;

    // 记录搜索得到的点编号
    IntArray pia;

    // 前提:边界必然是闭合的
    // 可能存在多个边界(内外边界)
    while( true )
    {
        // 搜索可用的边界
        int bi = -1;
        for( int i = 0; i < ( int )bea.size(); i++ )
        {
            BoundaryEdge be = bea[i];
            if( !be.used )
            {
                bi = i;
                break;
            }
        }
        if( bi == -1 ) break;

        // 记录之前已搜索到的边界点个数
        int boundPts_num = pia.size();

        DT_Edge e = getEdgeObject( bea[bi].ei )->e;
        bea[bi].used = true;  // 标记为使用

        pia.push_back( e.s );
        pia.push_back( e.t );

        int nt = e.t;
        while( true )
        {
            int nbi = -1;
            for( int i = 0; i < ( int )bea.size(); i++ )
            {
                if( bea[i].used ) continue;

                DT_Edge ne = getEdgeObject( bea[i].ei )->e;
                if( nt == ne.s )
                {
                    nt = ne.t;
                    nbi = i;
                    break;
                }
                else if( nt == ne.t )
                {
                    nt = ne.s;
                    nbi = i;
                    break;
                }
            }
            if( nbi == -1 ) break;

            bea[nbi].used = true;
            pia.push_back( nt );
        }

        int n = pia.size() - boundPts_num;
        if( n >= 3 )
        {
            // 至少是3个点
            bpos.push_back( n );
        }
    }

    // 将点编号转换成实际的点坐标
    for( int i = 0; i < ( int )pia.size(); i++ )
    {
        bpts.push_back( pa[pia[i]] );
    }
}
开发者ID:kanbang,项目名称:myexercise,代码行数:85,代码来源:Trace.cpp


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