本文整理汇总了C++中imagegeom::Pointer::getOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::getOrigin方法的具体用法?C++ Pointer::getOrigin怎么用?C++ Pointer::getOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imagegeom::Pointer
的用法示例。
在下文中一共展示了Pointer::getOrigin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataCheck
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void CropImageGeometry::dataCheck()
{
if(getErrorCondition() < 0) { return; }
setErrorCondition(0);
// Validate the incoming DataContainer, Geometry, and AttributeMatrix ; bail if any do not exist since we plan on using them later on in the dataCheck
// Error messages are handled by the getPrereq functions
DataContainer::Pointer srcCellDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName());
ImageGeom::Pointer image = getDataContainerArray()->getPrereqGeometryFromDataContainer<ImageGeom, AbstractFilter>(this, getCellAttributeMatrixPath().getDataContainerName());
AttributeMatrix::Pointer srcCellAttrMat = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, getCellAttributeMatrixPath(), -301);
if(getErrorCondition() < 0) { return; }
DataContainer::Pointer destCellDataContainer = srcCellDataContainer;
AttributeMatrix::Pointer destCellAttrMat;
if (m_SaveAsNewDataContainer == true)
{
float ox = 0.0f, oy = 0.0f, oz = 0.0f, rx = 0.0f, ry = 0.0f, rz = 0.0f;
size_t dx = 0, dy = 0, dz = 0;
image->getOrigin(ox, oy, oz);
image->getResolution(rx, ry, rz);
image->getDimensions(dx, dy, dz);
destCellDataContainer = getDataContainerArray()->createNonPrereqDataContainer<AbstractFilter>(this, getNewDataContainerName());
if(NULL == destCellDataContainer.get() || getErrorCondition() < 0)
{
return;
}
IGeometry::Pointer imageCopy = image->deepCopy();
destCellDataContainer->setGeometry(imageCopy);
destCellAttrMat = srcCellAttrMat->deepCopy();
destCellDataContainer->addAttributeMatrix(destCellAttrMat->getName(), destCellAttrMat);
}
else
{
destCellAttrMat = srcCellAttrMat;
}
if(NULL == destCellDataContainer.get() || NULL == destCellAttrMat.get() || getErrorCondition() < 0)
{
return;
}
if (getXMax() < getXMin())
{
QString ss = QObject::tr("X Max (%1) less than X Min (%2)").arg(getXMax()).arg(getXMin());
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getYMax() < getYMin())
{
QString ss = QObject::tr("Y Max (%1) less than Y Min (%2)").arg(getYMax()).arg(getYMin());
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getZMax() < getZMin())
{
QString ss = QObject::tr("Z Max (%1) less than Z Min (%2)").arg(getZMax()).arg(getZMin());
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getXMin() < 0)
{
QString ss = QObject::tr("X Min (%1) less than 0").arg(getXMin());
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getYMin() < 0)
{
QString ss = QObject::tr("Y Min (%1) less than 0").arg(getYMin());
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getZMin() < 0)
{
QString ss = QObject::tr("Z Min (%1) less than 0").arg(getZMin());
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getXMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1))
{
QString ss = QObject::tr("The X Max (%1) is greater than the Image Geometry X extent (%2)").arg(getXMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getXPoints()) - 1);
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getYMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1))
{
QString ss = QObject::tr("The Y Max (%1) is greater than the Image Geometry Y extent (%2)").arg(getYMax()).arg(static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getYPoints()) - 1);
notifyErrorMessage(getHumanLabel(), ss, -5550);
setErrorCondition(-5550);
}
if (getZMax() > (static_cast<int64_t>(destCellDataContainer->getGeometryAs<ImageGeom>()->getZPoints()) - 1))
{
//.........这里部分代码省略.........
示例2: 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)
//.........这里部分代码省略.........