本文整理汇总了C++中idataarray::Pointer::getTypeSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::getTypeSize方法的具体用法?C++ Pointer::getTypeSize怎么用?C++ Pointer::getTypeSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idataarray::Pointer
的用法示例。
在下文中一共展示了Pointer::getTypeSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: 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");
}
示例3: execute
//.........这里部分代码省略.........
refDC->getGeometryAs<ImageGeom>()->getResolution(refRes);
sampleDC->getGeometryAs<ImageGeom>()->getResolution(sampleRes);
refDC->getGeometryAs<ImageGeom>()->getOrigin(refOrigin);
sampleDC->getGeometryAs<ImageGeom>()->getOrigin(sampleOrigin);
// Further down we divide by sampleRes, so here check to make sure that no components of the resolution are 0
// This would be incredible unusual behavior if it were to occur, hence why we don't spend the time
// doing the validation up in the dataCheck
bool zeroRes = false;
for (size_t i = 0; i < 3; i++)
{
if (sampleRes[i] == 0.0f)
{
zeroRes = true;
break;
}
}
if (zeroRes == true)
{
QString ss = QObject::tr("A component of the resolution for the Image Geometry associated with DataContainer '%1' is 0. This would result in a division by 0 operation").arg(m_SamplingCellAttributeMatrixPath.getDataContainerName());
setErrorCondition(-5555);
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
int64_t refDims[3] = { 0, 0, 0 };
int64_t sampleDims[3] = { 0, 0, 0 };
for (size_t i = 0; i < 3; i++)
{
refDims[i] = static_cast<int64_t>(_refDims[i]);
sampleDims[i] = static_cast<int64_t>(_sampleDims[i]);
}
int64_t numRefTuples = refDims[0] * refDims[1] * refDims[2];
float x = 0.0f, y = 0.0f, z = 0.0f;
int64_t col = 0, row = 0, plane = 0;
int64_t refIndex = 0;
int64_t sampleIndex = 0;
int64_t planeComp = 0, rowComp = 0;
// Create arrays on the reference grid to hold data present on the sampling grid
QList<QString> voxelArrayNames = sampleAttrMat->getAttributeArrayNames();
for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
IDataArray::Pointer p = sampleAttrMat->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(numRefTuples, p->getComponentDimensions(), p->getName());
refAttrMat->addAttributeArray(p->getName(), data);
}
bool outside = false;
for (int64_t i = 0; i < refDims[2]; i++)
{
planeComp = i * refDims[0] * refDims[1];
for (int64_t j = 0; j < refDims[1]; j++)
{
rowComp = j * refDims[0];
for (int64_t k = 0; k < refDims[0]; k++)
{
outside = false;
x = (k * refRes[0] + refOrigin[0]);
y = (j * refRes[1] + refOrigin[1]);
z = (i * refRes[2] + refOrigin[2]);
if ((x - sampleOrigin[0]) < 0) { outside = true; }
else { col = int64_t((x - sampleOrigin[0]) / sampleRes[0]); }
if ((y - sampleOrigin[1]) < 0) { outside = true; }
else { row = int64_t((y - sampleOrigin[1]) / sampleRes[1]); }
if ((z - sampleOrigin[2]) < 0) { outside = true; }
else { plane = int64_t((z - sampleOrigin[2]) / sampleRes[2]); }
if (col > sampleDims[0] || row > sampleDims[1] || plane > sampleDims[2]) { outside = true; }
if (outside == false)
{
sampleIndex = (plane * sampleDims[0] * sampleDims[1]) + (row * sampleDims[0]) + col;
refIndex = planeComp + rowComp + k;
for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
IDataArray::Pointer p = sampleAttrMat->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 = refAttrMat->getAttributeArray(*iter);
void* source = NULL;
void* destination = NULL;
int nComp = data->getNumberOfComponents();
source = p->getVoidPointer((nComp * sampleIndex));
destination = data->getVoidPointer((nComp * refIndex));
::memcpy(destination, source, p->getTypeSize() * nComp);
}
}
}
}
}
notifyStatusMessage(getHumanLabel(), "Complete");
}
示例4: execute
//.........这里部分代码省略.........
if (fabs(GeometryMath::CosThetaBetweenVectors(zAxis, xAxisNew)) > closestAxis) { xResNew = zRes, closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(zAxis, xAxisNew)); }
yResNew = yRes;
closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(yAxis, yAxisNew));
if (fabs(GeometryMath::CosThetaBetweenVectors(xAxis, yAxisNew)) > closestAxis) { yResNew = xRes, closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(xAxis, yAxisNew)); }
if (fabs(GeometryMath::CosThetaBetweenVectors(zAxis, yAxisNew)) > closestAxis) { yResNew = zRes, closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(zAxis, yAxisNew)); }
zResNew = zRes;
closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(zAxis, zAxisNew));
if (fabs(GeometryMath::CosThetaBetweenVectors(xAxis, zAxisNew)) > closestAxis) { zResNew = xRes, closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(xAxis, zAxisNew)); }
if (fabs(GeometryMath::CosThetaBetweenVectors(yAxis, zAxisNew)) > closestAxis) { zResNew = yRes, closestAxis = fabs(GeometryMath::CosThetaBetweenVectors(yAxis, zAxisNew)); }
xpNew = static_cast<int64_t>(nearbyint((xMax - xMin) / xResNew) + 1);
ypNew = static_cast<int64_t>(nearbyint((yMax - yMin) / yResNew) + 1);
zpNew = static_cast<int64_t>(nearbyint((zMax - zMin) / zResNew) + 1);
params.xpNew = xpNew;
params.xResNew = xResNew;
params.xMinNew = xMin;
params.ypNew = ypNew;
params.yResNew = yResNew;
params.yMinNew = yMin;
params.zpNew = zpNew;
params.zResNew = zResNew;
params.zMinNew = zMin;
int64_t newNumCellTuples = params.xpNew * params.ypNew * params.zpNew;
DataArray<int64_t>::Pointer newIndiciesPtr = DataArray<int64_t>::CreateArray(newNumCellTuples, "_INTERNAL_USE_ONLY_RotateSampleRef_NewIndicies");
newIndiciesPtr->initializeWithValue(-1);
int64_t* newindicies = newIndiciesPtr->getPointer(0);
#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
tbb::task_scheduler_init init;
bool doParallel = true;
#endif
#ifdef SIMPLib_USE_PARALLEL_ALGORITHMS
if (doParallel == true)
{
tbb::parallel_for(tbb::blocked_range3d<int64_t, int64_t, int64_t>(0, params.zpNew, 0, params.ypNew, 0, params.xpNew),
RotateSampleRefFrameImpl(newIndiciesPtr, ¶ms, rotMat, m_SliceBySlice), tbb::auto_partitioner());
}
else
#endif
{
RotateSampleRefFrameImpl serial(newIndiciesPtr, ¶ms, rotMat, m_SliceBySlice);
serial.convert(0, params.zpNew, 0, params.ypNew, 0, params.xpNew);
}
// This could technically be parallelized also where each thread takes an array to adjust. Except
// that the DataContainer is NOT thread safe or re-entrant so that would actually be a BAD idea.
QString attrMatName = getCellAttributeMatrixPath().getAttributeMatrixName();
QList<QString> voxelArrayNames = m->getAttributeMatrix(attrMatName)->getAttributeArrayNames();
// resize attribute matrix
QVector<size_t> tDims(3);
tDims[0] = params.xpNew;
tDims[1] = params.ypNew;
tDims[2] = params.zpNew;
m->getAttributeMatrix(attrMatName)->resizeAttributeArrays(tDims);
for (QList<QString>::iterator iter = voxelArrayNames.begin(); iter != voxelArrayNames.end(); ++iter)
{
IDataArray::Pointer p = m->getAttributeMatrix(attrMatName)->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.
IDataArray::Pointer data = p->createNewArray(newNumCellTuples, p->getComponentDimensions(), p->getName());
void* source = NULL;
void* destination = NULL;
int64_t newIndicies_I = 0;
int32_t nComp = data->getNumberOfComponents();
for (size_t i = 0; i < static_cast<size_t>(newNumCellTuples); i++)
{
newIndicies_I = newindicies[i];
if(newIndicies_I >= 0)
{
source = p->getVoidPointer((nComp * newIndicies_I));
if (NULL == source)
{
QString ss = QObject::tr("The index is outside the bounds of the source array");
setErrorCondition(-11004);
notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
return;
}
destination = data->getVoidPointer((data->getNumberOfComponents() * i));
::memcpy(destination, source, p->getTypeSize() * data->getNumberOfComponents());
}
else
{
data->initializeTuple(i, 0);
}
}
m->getAttributeMatrix(attrMatName)->addAttributeArray(*iter, data);
}
m->getGeometryAs<ImageGeom>()->setResolution(params.xResNew, params.yResNew, params.zResNew);
m->getGeometryAs<ImageGeom>()->setDimensions(params.xpNew, params.ypNew, params.zpNew);
m->getGeometryAs<ImageGeom>()->setOrigin(xMin, yMin, zMin);
notifyStatusMessage(getHumanLabel(), "Complete");
}
示例5: 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");
//.........这里部分代码省略.........