本文整理汇总了C++中datacontainer::Pointer::doesAttributeMatrixExist方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::doesAttributeMatrixExist方法的具体用法?C++ Pointer::doesAttributeMatrixExist怎么用?C++ Pointer::doesAttributeMatrixExist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datacontainer::Pointer
的用法示例。
在下文中一共展示了Pointer::doesAttributeMatrixExist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataCheck
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ReadImage::dataCheck()
{
setErrorCondition(0);
//check file name exists
if(getInputFileName().isEmpty())
{
setErrorCondition(-1);
notifyErrorMessage(getHumanLabel(), "The input file name must be set before executing this filter.", getErrorCondition());
return;
}
//read image metadata
itk::ImageIOBase::Pointer imageIO = itk::ImageIOFactory::CreateImageIO(getInputFileName().toLocal8Bit().constData(), itk::ImageIOFactory::ReadMode);
if(NULL == imageIO)
{
setErrorCondition(-2);
QString message = QObject::tr("Unable to read image '%1'").arg(getInputFileName());
notifyErrorMessage(getHumanLabel(), message, getErrorCondition());
return;
}
imageIO->SetFileName(getInputFileName().toLocal8Bit().data());
imageIO->ReadImageInformation();
//get size of image
const size_t numDimensions = imageIO->GetNumberOfDimensions();
int xdim = imageIO->GetDimensions(0);
int ydim = imageIO->GetDimensions(1);
int zdim = 1;
if(3 != numDimensions)
{
if(2 == numDimensions)
{
//allow 2 dimensional images (as 3d image with size 1 in the z direction)
}
else
{
QString message = QObject::tr("3 dimensional image required (slected image dimensions: %1)").arg(numDimensions);
setErrorCondition(-3);
notifyErrorMessage(getHumanLabel(), message, getErrorCondition());
return;
}
}
else
{
zdim = imageIO->GetDimensions(2);
}
//determine if container/attribute matrix already exist. if so check size compatibility
DataArrayPath createdPath;
DataContainer::Pointer m;
AttributeMatrix::Pointer cellAttrMat;
createdPath.update(getDataContainerName(), getCellAttributeMatrixName(), getImageDataArrayName() );
m = getDataContainerArray()->getDataContainer(getDataContainerName());
bool createAttributeMatrix = false;
if(NULL == m.get()) //datacontainer doesn't exist->create
{
m = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getDataContainerName());
ImageGeom::Pointer image = ImageGeom::CreateGeometry(DREAM3D::Geometry::ImageGeometry);
m->setGeometry(image);
m->getGeometryAs<ImageGeom>()->setDimensions(xdim, ydim, zdim);
double zRes = 1;
double zOrigin = 0;
if(3 == numDimensions)
{
zRes = imageIO->GetSpacing(2);
zOrigin = imageIO->GetOrigin(2);
}
m->getGeometryAs<ImageGeom>()->setResolution(imageIO->GetSpacing(0), imageIO->GetSpacing(0), zRes);
m->getGeometryAs<ImageGeom>()->setOrigin(imageIO->GetOrigin(0), imageIO->GetOrigin(1), zOrigin);
createAttributeMatrix = true;
if(getErrorCondition() < 0) { return; }
}
else //datacontainer exists, check if attribute matrix exists
{
bool dcExists = m->doesAttributeMatrixExist(getCellAttributeMatrixName());
ImageGeom::Pointer image = m->getPrereqGeometry<ImageGeom, AbstractFilter>(this);
if(getErrorCondition() < 0) { return; }
size_t iDims[3] = { 0, 0, 0 };
float iRes[3] = { 0.0f, 0.0f, 0.0f };
float iOrigin[4] = { 0.0f, 0.0f, 0.0f };
image->getDimensions(iDims);
image->getResolution(iRes);
image->getOrigin(iOrigin);
if(dcExists && NULL != image.get())//attribute matrix exists, check compatibility
{
//get matrix
cellAttrMat = m->getPrereqAttributeMatrix<AbstractFilter>(this, getCellAttributeMatrixName(), false);
if(getErrorCondition() < 0) { return; }
//check dimension compatibility
QVector<size_t> tDims = cellAttrMat->getTupleDimensions();
if(tDims[0] != xdim || iDims[0] != xdim)
//.........这里部分代码省略.........