本文整理汇总了C++中idataarray::Pointer::getNumberOfTuples方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::getNumberOfTuples方法的具体用法?C++ Pointer::getNumberOfTuples怎么用?C++ Pointer::getNumberOfTuples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idataarray::Pointer
的用法示例。
在下文中一共展示了Pointer::getNumberOfTuples方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resize
/**
* @brief
* @param parentId
* @return
*/
virtual int readH5Data(hid_t parentId)
{
int err = 0;
resize(0);
IDataArray::Pointer p = H5DataArrayReader::ReadIDataArray(parentId, getName());
if (p.get() == NULL)
{
return -1;
}
m_Array = reinterpret_cast<T*>(p->getVoidPointer(0));
m_Size = p->getSize();
m_OwnsData = true;
m_MaxId = (m_Size == 0) ? 0 : m_Size - 1;
m_IsAllocated = true;
m_Name = p->getName();
m_NumTuples = p->getNumberOfTuples();
m_CompDims = p->getComponentDimensions();
m_NumComponents = p->getNumberOfComponents();
// Tell the intermediate DataArray to release ownership of the data as we are going to be responsible
// for deleting the memory
p->releaseOwnership();
return err;
}
示例2: copyCellData
IDataArray::Pointer copyCellData(IDataArray::Pointer inputData, int32_t features, int32_t* featureIds)
{
QString featureArrayName = inputData->getName();
typename DataArray<T>::Pointer cell = std::dynamic_pointer_cast<DataArray<T> >(inputData);
if (NULL == cell) { return IDataArray::NullPointer(); }
QVector<size_t> dims = inputData->getComponentDimensions();
typename DataArray<T>::Pointer feature = DataArray<T>::CreateArray(features, dims, featureArrayName);
T* fPtr = feature->getPointer(0);
T* cPtr = cell->getPointer(0);
int32_t numComp = cell->getNumberOfComponents();
int32_t featureIdx = 0;
size_t cells = inputData->getNumberOfTuples();
for (size_t i = 0; i < cells; ++i)
{
// Get the feature id (or what ever the user has selected as their "Feature" identifier
featureIdx = featureIds[i];
// Now get the pointer to the start of the tuple for the Cell Array at the given Feature Id Index value
T* cSourcePtr = cPtr + (numComp * i);
// Now get the pointer to the start of the tuple for the Feature Array at the proper index
T* fDestPtr = fPtr + (numComp * featureIdx);
// Now just raw copy the bytes from the source to the destination
::memcpy(fDestPtr, cSourcePtr, sizeof(T) * numComp);
}
return feature;
}
示例3: dataCheck
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MoveData::dataCheck()
{
setErrorCondition(0);
DataArrayPath amSrcPath = getAttributeMatrixSource();
DataArrayPath amDestPath = getAttributeMatrixDestination();
DataArrayPath daSrcPath = getDataArraySource();
if (getWhatToMove() == k_MoveAttributeMatrix)
{
DataContainer::Pointer amDestDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getDataContainerDestination());
DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, amSrcPath.getDataContainerName());
AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, amSrcPath, -301);
if(getErrorCondition() < 0) { return; }
if (amSrcDataContainer->getName() == amDestDataContainer->getName())
{
QString ss = QObject::tr("The source and destination Data Container are the same. Is this what you meant to do?");
notifyWarningMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix);
amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName());
}
else if (getWhatToMove() == k_MoveDataArray )
{
AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, daSrcPath, -301);
AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, amDestPath, -301);
IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(this, daSrcPath);
if(getErrorCondition() < 0) { return; }
if (daDestAttributeMatrix->getNumTuples() != daSrcDataArray->getNumberOfTuples())
{
setErrorCondition(-11019);
QString ss = QObject::tr("The number of tuples of source Attribute Array (%1) and destination Attribute Matrix (%2) do not match").arg(daSrcDataArray->getNumberOfTuples()).arg(daDestAttributeMatrix->getNumTuples());
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
else if (amSrcPath == amDestPath)
{
QString ss = QObject::tr("The source and destination Attribute Matrix are the same. Is this what you meant to do?");
notifyWarningMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
daDestAttributeMatrix->addAttributeArray(daSrcPath.getDataArrayName(), daSrcDataArray);
daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName());
}
else
{
setErrorCondition(-11020);
QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved");
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
}
示例4: addAttributeArray
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int AttributeMatrix::addAttributeArray(const QString& name, IDataArray::Pointer data)
{
if (data->getName().compare(name) != 0)
{
qDebug() << "Adding Attribute Array with different array name than key name" << "\n";
qDebug() << "Key name: " << name << "\n";
qDebug() << "Array Name:" << data->getName() << "\n";
data->setName(name);
}
if(getNumTuples() != data->getNumberOfTuples())
{
qDebug() << "AttributeMatrix::Name: " << getName() << " dataArray::name: " << data->getName() << " Type: " << data->getTypeAsString();
qDebug() << "getNumTuples(): " << getNumTuples() << " data->getNumberOfTuples(): " << data->getNumberOfTuples();
}
Q_ASSERT(getNumTuples() == data->getNumberOfTuples());
m_AttributeArrays[name] = data;
return 0;
}
示例5: copyData
void copyData(IDataArray::Pointer fromData, IDataArray::Pointer toData, size_t location)
{
typename DataArray<T>::Pointer fData = std::dynamic_pointer_cast<DataArray<T>>(fromData);
typename DataArray<T>::Pointer tData = std::dynamic_pointer_cast<DataArray<T>>(toData);
//only wanting to grab data from tuple 1 to numTuples of the fromData array,s ince the zeroth slot is a placeholder the first AM should already have
T* src = fData->getPointer(1 * fromData->getNumberOfComponents());
T* dest = tData->getPointer(location * toData->getNumberOfComponents());
size_t bytes = sizeof(T) * (fromData->getNumberOfTuples() - 1) * fromData->getNumberOfComponents();
::memcpy(dest, src, bytes);
}
示例6: validateAttributeArraySizes
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool AttributeMatrix::validateAttributeArraySizes()
{
int64_t arraySize = 0;
int64_t matrixSize = getNumTuples();
for(QMap<QString, IDataArray::Pointer>::iterator iter = m_AttributeArrays.begin(); iter != m_AttributeArrays.end(); ++iter)
{
IDataArray::Pointer d = iter.value();
arraySize = d->getNumberOfTuples();
if(arraySize != matrixSize)
{
return false;
}
}
return true;
}
示例7: copyData
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
bool ModifiedLambertProjectionArray::copyData(size_t destTupleOffset, IDataArray::Pointer sourceArray)
{
if(!m_IsAllocated) { return false; }
if(0 == m_ModifiedLambertProjectionArray.size()) { return false; }
if(destTupleOffset >= m_ModifiedLambertProjectionArray.size()) { return false; }
if(!sourceArray->isAllocated()) { return false; }
Self* source = dynamic_cast<Self*>(sourceArray.get());
if(sourceArray->getNumberOfComponents() != getNumberOfComponents()) { return false; }
if( sourceArray->getNumberOfTuples()*sourceArray->getNumberOfComponents() + destTupleOffset*getNumberOfComponents() > m_ModifiedLambertProjectionArray.size() ) { return false; }
size_t sourceNTuples = source->getNumberOfTuples();
for(size_t i = 0; i < sourceNTuples; i++)
{
m_ModifiedLambertProjectionArray[destTupleOffset + i] = (*source)[i];
}
return true;
}
示例8: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ChangeResolution::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer m;
if(m_SaveAsNewDataContainer == false)
{
m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName());
}
else
{
m = getDataContainerArray()->getDataContainer(getNewDataContainerName());
}
if(m->getGeometryAs<ImageGeom>()->getXRes() == m_Resolution.x
&& m->getGeometryAs<ImageGeom>()->getYRes() == m_Resolution.y
&& m->getGeometryAs<ImageGeom>()->getZRes() == m_Resolution.z)
{
return;
}
AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
size_t dims[3] = { 0, 0, 0 };
m->getGeometryAs<ImageGeom>()->getDimensions(dims);
float sizex = (dims[0]) * m->getGeometryAs<ImageGeom>()->getXRes();
float sizey = (dims[1]) * m->getGeometryAs<ImageGeom>()->getYRes();
float sizez = (dims[2]) * m->getGeometryAs<ImageGeom>()->getZRes();
size_t m_XP = size_t(sizex / m_Resolution.x);
size_t m_YP = size_t(sizey / m_Resolution.y);
size_t m_ZP = size_t(sizez / m_Resolution.z);
if (m_XP == 0) { m_XP = 1; }
if (m_YP == 0) { m_YP = 1; }
if (m_ZP == 0) { m_ZP = 1; }
size_t totalPoints = m_XP * m_YP * m_ZP;
float x = 0.0f, y = 0.0f, z = 0.0f;
size_t col = 0, row = 0, plane = 0;
size_t index;
size_t index_old;
std::vector<size_t> newindicies(totalPoints);
for (size_t i = 0; i < m_ZP; i++)
{
QString ss = QObject::tr("Changing Resolution - %1 Percent Complete").arg(((float)i / m->getGeometryAs<ImageGeom>()->getZPoints()) * 100);
notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss);
for (size_t j = 0; j < m_YP; j++)
{
for (size_t k = 0; k < m_XP; k++)
{
x = (k * m_Resolution.x);
y = (j * m_Resolution.y);
z = (i * m_Resolution.z);
col = size_t(x / m->getGeometryAs<ImageGeom>()->getXRes());
row = size_t(y / m->getGeometryAs<ImageGeom>()->getYRes());
plane = size_t(z / m->getGeometryAs<ImageGeom>()->getZRes());
index_old = (plane * m->getGeometryAs<ImageGeom>()->getXPoints() * m->getGeometryAs<ImageGeom>()->getYPoints()) + (row * m->getGeometryAs<ImageGeom>()->getXPoints()) + col;
index = (i * m_XP * m_YP) + (j * m_XP) + k;
newindicies[index] = index_old;
}
}
}
QVector<size_t> tDims(3, 0);
tDims[0] = m_XP;
tDims[1] = m_YP;
tDims[2] = m_ZP;
AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, cellAttrMat->getName(), cellAttrMat->getType());
QList<QString> voxelArrayNames = cellAttrMat->getAttributeArrayNames();
for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
IDataArray::Pointer p = cellAttrMat->getAttributeArray(*iter);
// Make a copy of the 'p' array that has the same name. When placed into
// the data container this will over write the current array with
// the same name. At least in theory.
IDataArray::Pointer data = p->createNewArray(p->getNumberOfTuples(), p->getComponentDimensions(), p->getName());
data->resize(totalPoints);
void* source = NULL;
void* destination = NULL;
size_t newIndicies_I = 0;
int nComp = data->getNumberOfComponents();
for (size_t i = 0; i < static_cast<size_t>(totalPoints); i++)
{
newIndicies_I = newindicies[i];
source = p->getVoidPointer((nComp * newIndicies_I));
destination = data->getVoidPointer((data->getNumberOfComponents() * i));
::memcpy(destination, source, p->getTypeSize() * data->getNumberOfComponents());
}
cellAttrMat->removeAttributeArray(*iter);
newCellAttrMat->addAttributeArray(*iter, data);
}
m->getGeometryAs<ImageGeom>()->setResolution(m_Resolution.x, m_Resolution.y, m_Resolution.z);
m->getGeometryAs<ImageGeom>()->setDimensions(m_XP, m_YP, m_ZP);
//.........这里部分代码省略.........
示例9: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void WarpRegularGrid::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer m;
if (m_SaveAsNewDataContainer == false) { m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName()); }
else { m = getDataContainerArray()->getDataContainer(getNewDataContainerName()); }
AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
AttributeMatrix::Pointer newCellAttrMat = cellAttrMat->deepCopy();
size_t dims[3] = { 0, 0, 0 };
m->getGeometryAs<ImageGeom>()->getDimensions(dims);
float res[3] = { 0.0f, 0.0f, 0.0f };
m->getGeometryAs<ImageGeom>()->getResolution(res);
size_t totalPoints = m->getGeometryAs<ImageGeom>()->getNumberOfElements();
float x = 0.0f, y = 0.0f, z = 0.0f;
float newX = 0.0f, newY = 0.0f;
int col = 0.0f, row = 0.0f, plane = 0.0f;
size_t index;
size_t index_old;
std::vector<size_t> newindicies(totalPoints);
std::vector<bool> goodPoint(totalPoints, true);
for (size_t i = 0; i < dims[2]; i++)
{
QString ss = QObject::tr("Warping Data - %1 Percent Complete").arg(((float)i / dims[2]) * 100);
notifyStatusMessage(getMessagePrefix(), getHumanLabel(), ss);
for (size_t j = 0; j < dims[1]; j++)
{
for (size_t k = 0; k < dims[0]; k++)
{
x = static_cast<float>((k * res[0]));
y = static_cast<float>((j * res[1]));
z = static_cast<float>((i * res[2]));
index = (i * dims[0] * dims[1]) + (j * dims[0]) + k;
determine_warped_coordinates(x, y, newX, newY);
col = newX / res[0];
row = newY / res[1];
plane = i;
index_old = (plane * dims[0] * dims[1]) + (row * dims[0]) + col;
newindicies[index] = index_old;
if (col > 0 && col < dims[0] && row > 0 && row < dims[1]) { goodPoint[index] = true; }
else { goodPoint[index] = false; }
}
}
}
QList<QString> voxelArrayNames = cellAttrMat->getAttributeArrayNames();
for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
IDataArray::Pointer p = cellAttrMat->getAttributeArray(*iter);
// Make a copy of the 'p' array that has the same name. When placed into
// the data container this will over write the current array with
// the same name. At least in theory
IDataArray::Pointer data = p->createNewArray(p->getNumberOfTuples(), p->getComponentDimensions(), p->getName());
data->resize(totalPoints);
void* source = NULL;
void* destination = NULL;
size_t newIndicies_I = 0;
int nComp = data->getNumberOfComponents();
for (size_t i = 0; i < static_cast<size_t>(totalPoints); i++)
{
newIndicies_I = newindicies[i];
if(goodPoint[i] == true)
{
source = p->getVoidPointer((nComp * newIndicies_I));
destination = data->getVoidPointer((data->getNumberOfComponents() * i));
::memcpy(destination, source, p->getTypeSize() * data->getNumberOfComponents());
}
else
{
int var = 0;
data->initializeTuple(i, &var);
}
}
cellAttrMat->removeAttributeArray(*iter);
newCellAttrMat->addAttributeArray(*iter, data);
}
m->removeAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
m->addAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName(), newCellAttrMat);
notifyStatusMessage(getHumanLabel(), "Complete");
}
示例10: execute
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void RegularizeZSpacing::execute()
{
setErrorCondition(0);
dataCheck();
if(getErrorCondition() < 0) {
return;
}
DataContainer::Pointer m = getDataContainerArray()->getDataContainer(getCellAttributeMatrixPath().getDataContainerName());
size_t dims[3];
m->getGeometryAs<ImageGeom>()->getDimensions(dims);
std::ifstream inFile;
inFile.open(m_InputFile.toLatin1().data());
float zval = 0.0f;
std::vector<float> zboundvalues(dims[2] + 1, 0.0);
for (size_t iter = 0; iter < dims[2] + 1; iter++)
{
inFile >> zval;
zboundvalues[iter] = zval;
}
inFile.close();
float xRes = m->getGeometryAs<ImageGeom>()->getXRes();
float yRes = m->getGeometryAs<ImageGeom>()->getYRes();
float sizez = zboundvalues[dims[2]];
size_t m_XP = dims[0];
size_t m_YP = dims[1];
size_t m_ZP = static_cast<size_t>(sizez / m_NewZRes);
if (m_ZP == 0) {
m_ZP = 1;
}
size_t totalPoints = m_XP * m_YP * m_ZP;
size_t index = 0, oldindex = 0;
size_t plane = 0;
std::vector<size_t> newindicies(totalPoints, 0);
for (size_t i = 0; i < m_ZP; i++)
{
plane = 0;
for (size_t iter = 1; iter < dims[2]; iter++)
{
if ((i * m_NewZRes) > zboundvalues[iter]) {
plane = iter;
}
}
for (size_t j = 0; j < m_YP; j++)
{
for (size_t k = 0; k < m_XP; k++)
{
oldindex = (plane * dims[0] * dims[1]) + (j * dims[0]) + k;
index = (i * dims[0] * dims[1]) + (j * dims[0]) + k;
newindicies[index] = oldindex;
}
}
}
AttributeMatrix::Pointer cellAttrMat = m->getAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
QVector<size_t> tDims(3, 0);
tDims[0] = m_XP;
tDims[1] = m_YP;
tDims[2] = m_ZP;
AttributeMatrix::Pointer newCellAttrMat = AttributeMatrix::New(tDims, cellAttrMat->getName(), cellAttrMat->getType());
QList<QString> voxelArrayNames = cellAttrMat->getAttributeArrayNames();
for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
IDataArray::Pointer p = cellAttrMat->getAttributeArray(*iter);
// Make a copy of the 'p' array that has the same name. When placed into
// the data container this will over write the current array with
// the same name. At least in theory
IDataArray::Pointer data = p->createNewArray(p->getNumberOfTuples(), p->getComponentDimensions(), p->getName());
data->resize(totalPoints);
void* source = NULL;
void* destination = NULL;
size_t newIndicies_I = 0;
int nComp = data->getNumberOfComponents();
for (size_t i = 0; i < static_cast<size_t>(totalPoints); i++)
{
newIndicies_I = newindicies[i];
source = p->getVoidPointer((nComp * newIndicies_I));
destination = data->getVoidPointer((data->getNumberOfComponents() * i));
::memcpy(destination, source, p->getTypeSize() * data->getNumberOfComponents());
}
cellAttrMat->removeAttributeArray(*iter);
newCellAttrMat->addAttributeArray(*iter, data);
}
m->getGeometryAs<ImageGeom>()->setResolution(xRes, yRes, m_NewZRes);
m->getGeometryAs<ImageGeom>()->setDimensions(m_XP, m_YP, m_ZP);
m->removeAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName());
m->addAttributeMatrix(getCellAttributeMatrixPath().getAttributeMatrixName(), newCellAttrMat);
notifyStatusMessage(getHumanLabel(), "Complete");
//.........这里部分代码省略.........