本文整理汇总了C++中int32arraytype::Pointer::getNumberOfTuples方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::getNumberOfTuples方法的具体用法?C++ Pointer::getNumberOfTuples怎么用?C++ Pointer::getNumberOfTuples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类int32arraytype::Pointer
的用法示例。
在下文中一共展示了Pointer::getNumberOfTuples方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeInactiveObjects
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool AttributeMatrix::removeInactiveObjects(QVector<bool> activeObjects, Int32ArrayType::Pointer Ids)
{
bool acceptableMatrix = false;
//Only valid for feature or ensemble type matrices
if(m_Type == DREAM3D::AttributeMatrixType::VertexFeature || m_Type == DREAM3D::AttributeMatrixType::VertexEnsemble ||
m_Type == DREAM3D::AttributeMatrixType::EdgeFeature || m_Type == DREAM3D::AttributeMatrixType::EdgeEnsemble ||
m_Type == DREAM3D::AttributeMatrixType::FaceFeature || m_Type == DREAM3D::AttributeMatrixType::FaceEnsemble ||
m_Type == DREAM3D::AttributeMatrixType::CellFeature || m_Type == DREAM3D::AttributeMatrixType::CellEnsemble)
{
acceptableMatrix = true;
}
size_t totalTuples = getNumTuples();
if( static_cast<size_t>(activeObjects.size()) == totalTuples && acceptableMatrix == true)
{
size_t goodcount = 1;
QVector<size_t> NewNames(totalTuples, 0);
QVector<size_t> RemoveList;
for(qint32 i = 1; i < activeObjects.size(); i++)
{
if(activeObjects[i] == false)
{
RemoveList.push_back(i);
NewNames[i] = 0;
}
else
{
NewNames[i] = goodcount;
goodcount++;
}
}
if(RemoveList.size() > 0)
{
QList<QString> headers = getAttributeArrayNames();
for (QList<QString>::iterator iter = headers.begin(); iter != headers.end(); ++iter)
{
IDataArray::Pointer p = getAttributeArray(*iter);
QString type = p->getTypeAsString();
if(type.compare("NeighborList<T>") == 0)
{
removeAttributeArray(*iter);
}
else
{
p->eraseTuples(RemoveList);
}
}
QVector<size_t> tDims(1, (totalTuples - RemoveList.size()));
setTupleDimensions(tDims);
// Loop over all the points and correct all the feature names
size_t totalPoints = Ids->getNumberOfTuples();
int32_t* id = Ids->getPointer(0);
for (size_t i = 0; i < totalPoints; i++)
{
if(id[i] >= 0 && id[i] < NewNames.size())
{
id[i] = static_cast<int32_t>( NewNames[id[i]] );
}
}
}
}
else
{
return false;
}
return true;
}
示例2: 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);
}
}