本文整理汇总了C++中int32arraytype::Pointer::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::getSize方法的具体用法?C++ Pointer::getSize怎么用?C++ Pointer::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int32arraytype::Pointer
的用法示例。
在下文中一共展示了Pointer::getSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestDataArray
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void TestDataArray()
{
int32_t* ptr = NULL;
{
Int32ArrayType::Pointer d = Int32ArrayType::CreateArray(0, "Test7");
DREAM3D_REQUIRE_EQUAL(0, d->getSize());
DREAM3D_REQUIRE_EQUAL(0, d->getNumberOfTuples());
ptr = d->getPointer(0);
DREAM3D_REQUIRE_EQUAL(ptr, 0);
DREAM3D_REQUIRE_EQUAL(d->isAllocated(), false);
}
{
QVector<size_t> dims(1, NUM_COMPONENTS);
Int32ArrayType::Pointer int32Array = Int32ArrayType::CreateArray(NUM_ELEMENTS, dims, "Test8");
ptr = int32Array->getPointer(0);
DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true);
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS, int32Array->getNumberOfTuples());
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS * NUM_COMPONENTS, int32Array->getSize());
for (int i = 0; i < NUM_TUPLES; ++i)
{
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
int32Array->setComponent(i, c, i + c);
}
}
// Resize Larger
int32Array->resize(NUM_TUPLES_2);
DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_2, int32Array->getNumberOfTuples());
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_2, int32Array->getSize());
DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true);
// This should have saved our data so lets look at the data and compare it
for (int i = 0; i < NUM_TUPLES; ++i)
{
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
DREAM3D_REQUIRE_EQUAL( (int32Array->getComponent(i, c)), (i + c))
}
}
// Resize Smaller - Which should have still saved some of our data
int32Array->resize(NUM_TUPLES_3);
DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_3, int32Array->getNumberOfTuples());
DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_3, int32Array->getSize());
DREAM3D_REQUIRE_EQUAL(int32Array->isAllocated(), true);
// This should have saved our data so lets look at the data and compare it
for (int i = 0; i < NUM_TUPLES; ++i)
{
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
DREAM3D_REQUIRE_EQUAL( (int32Array->getComponent(i, c)), (i + c))
}
}
// Change number of components
// dims[0] = NUM_COMPONENTS_4;
// int32Array->setDims(dims);
// DREAM3D_REQUIRE_EQUAL(NUM_TUPLES_4, int32Array->getNumberOfTuples());
// DREAM3D_REQUIRE_EQUAL(NUM_ELEMENTS_4, int32Array->getSize());
double temp = 9999;
int32Array->initializeTuple(0, temp );
for (int c = 0; c < NUM_COMPONENTS; ++c)
{
DREAM3D_REQUIRE_EQUAL( (int32Array->getComponent(0, c)), (9999))
}
ptr = int32Array->getPointer(0);
}
}