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


C++ FloatArray::size方法代码示例

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


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

示例1:

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
TEST(ArrayTest, AssignmentOperator)
{
    FloatArray a0;

    FloatArray a1;
    a1.resize(2);
    a1[0] = 10;
    a1[1] = 11;

    {
        FloatArray a;
        a = a0;

        ASSERT_EQ(0u, a.size());
    }

    {
        FloatArray a;
        a = a1;

        ASSERT_EQ(2u, a.size());
        ASSERT_EQ(10, a[0]);
        ASSERT_EQ(11, a[1]);
    }
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:28,代码来源:cvfArray-Test.cpp

示例2: setArray

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void UniformFloat::setArray(const FloatArray& values)
{
    CVF_ASSERT(values.size() > 0);

    m_type = FLOAT;
    m_data = values;
}
开发者ID:akva2,项目名称:ResInsight,代码行数:10,代码来源:cvfUniform.cpp

示例3: GetTextPosition

CLabel::TEXTPOSINFO CLabel::GetTextPosition(const StringArray& lines) const
{
	TEXTPOSINFO result;

	FloatArray lineWidths = GetLineWidths(lines);
	result.linePosX.reserve(lineWidths.size());
	for(unsigned int i = 0; i < lineWidths.size(); i++)
	{
		float posX = 0;
		float lineWidth = lineWidths[i];
		switch(m_horizontalAlignment)
		{
			case HORIZONTAL_ALIGNMENT_LEFT:
				posX = 0;
				break;
			case HORIZONTAL_ALIGNMENT_RIGHT:
				posX = m_size.x - lineWidth;
				break;
			case HORIZONTAL_ALIGNMENT_CENTER:
				posX = static_cast<float>(static_cast<int>(m_size.x - lineWidth) / 2);
				break;
		}
		result.linePosX.push_back(posX);
	}

	float textHeight = GetTextHeight(lines);
	float posY = 0;
	switch(m_verticalAlignment)
	{
		case VERTICAL_ALIGNMENT_TOP:
			posY = 0;
			break;
		case VERTICAL_ALIGNMENT_BOTTOM:
			posY = m_size.y - textHeight;
			break;
		case VERTICAL_ALIGNMENT_CENTER:
			posY = static_cast<float>(static_cast<int>(m_size.y - textHeight) / 2);
			break;
	}
	result.posY = posY;

	return result;
}
开发者ID:whztt07,项目名称:Palleon,代码行数:43,代码来源:Label.cpp

示例4: b

TEST(ArrayTest, testConstruction)
{

	// fundamental type
	typedef Poco::Array<float,6> FloatArray;
	FloatArray a = { { 42.f } };

	for (unsigned i=1; i<a.size(); ++i) {
		a[i] = a[i-1]+1.f;
	}

	// copy constructor and assignment operator
	FloatArray b(a);
	FloatArray c;
	c = a;
	EXPECT_TRUE (a==b && a==c);

	typedef Poco::Array<double,6> DArray;
	typedef Poco::Array<int,6> IArray;
	IArray ia = {{1, 2, 3, 4, 5, 6 }};
	DArray da;
	da = ia;
	da.assign(42);

	// user-defined type
	typedef Poco::Array<Element,10> ElementArray;
	ElementArray g;

	for (unsigned i=0; i<g.size(); ++i) {
		g[i]._data = i;
	}

	for (unsigned i=0; i<g.size(); ++i) {
		EXPECT_TRUE(g[i]._data == i);
	}


}
开发者ID:ichenq,项目名称:PocoNet,代码行数:38,代码来源:ArrayTest.cpp

示例5: DoAnim

void DoAnim()
{
    static double time = 0.0; //Total time running.
    static double artTime = 0.0; //Total time with the current art.

    static DWORD lastTime = 0; //Time of last call.
    const double elapsed = double(GetTickCount() - lastTime) / 1000.0;

    if (lastTime)
    {
        lastTime = GetTickCount();
    }
    else
    {
        lastTime = GetTickCount();
        return;
    }

    time += elapsed;
    artTime += elapsed;

    //If we need new art, get it.
    static CKnot::AutoArt threads;
    static Arrays arrays;
    static FloatArray grid;


    if (!threads.get() || artTime > ResetTime)
    {
        CKnot::StrokeList sl = CreateSquareStrokes();
        sl = RemoveStrokes(sl);

        threads = CKnot::CreateThread(sl);
        artTime = 0.0;

        grid.clear();
        grid.reserve(sl.size() * 10);
        for (CKnot::StrokeList::const_iterator it = sl.begin(); it != sl.end(); ++it)
        {
            grid.push_back(it->a.x);
            grid.push_back(it->a.y);
            grid.push_back(it->type == CKnot::Cross ? 1.0 : 0.0);
            grid.push_back(it->type == CKnot::Glance ? 1.0 : 0.0);
            grid.push_back(it->type == CKnot::Bounce ? 1.0 : 0.0);

            grid.push_back(it->b.x);
            grid.push_back(it->b.y);
            grid.push_back(it->type == CKnot::Cross ? 1.0 : 0.0);
            grid.push_back(it->type == CKnot::Glance ? 1.0 : 0.0);
            grid.push_back(it->type == CKnot::Bounce ? 1.0 : 0.0);
        }

        for (size_t i = 0; i < arrays.size(); ++i)
            delete arrays[i];
        arrays.clear();

        const size_t threadCount = threads->GetThreadCount();

        for (size_t i = 0; i < threadCount; ++i)
        {
            const CKnot::Art::Thread* thread = threads->GetThread(i);
            const CKnot::Art::Z* z = threads->GetZ(i);

            const size_t segsPerKnot = 25;
            const size_t kc = thread->GetKnotCount();

            FloatArray* quads = new FloatArray;
            arrays.push_back(quads);


            const size_t target = kc * segsPerKnot;
            const size_t memSize = 12 * (target + 1);
            quads->reserve(memSize);

            const float scr = double(rand()) / RAND_MAX / 2;
            const float ecr = double(rand()) / RAND_MAX / 2 + .5;
            const float scg = double(rand()) / RAND_MAX / 2;
            const float ecg = double(rand()) / RAND_MAX / 2 + .5;
            const float scb = double(rand()) / RAND_MAX / 2;
            const float ecb = double(rand()) / RAND_MAX / 2 + .5;

            for (size_t i = 0; i <= target; ++i)
            {
                const double s = double(i) / double(target);
                const double t = s;

                const CKnot::vec2 cur = thread->Y(t);
                const CKnot::vec2 dcur = thread->Y(t + .00001);
                const CKnot::vec2 diff = dcur - cur;

                CKnot::vec2 normal(diff.y, -diff.x);
                normal = normal * (1.0 / normal.GetLength());
                normal = normal * .01;
                const CKnot::vec2 flip(-normal.x, -normal.y);

                const CKnot::vec2 start = cur + normal;
                const CKnot::vec2 end = cur + flip;

                const bool over = z->Y(t) > 0.0;

//.........这里部分代码省略.........
开发者ID:codeplea,项目名称:celtic_knots,代码行数:101,代码来源:saver.cpp


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