本文整理汇总了C++中proportionaltimegeometry::Pointer类的典型用法代码示例。如果您正苦于以下问题:C++ Pointer类的具体用法?C++ Pointer怎么用?C++ Pointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: itkDebugMacro
void mitk::ProbeFilter::GenerateOutputInformation()
{
mitk::Surface::ConstPointer input = this->GetInput();
mitk::Image::ConstPointer source = this->GetSource();
mitk::Surface::Pointer output = this->GetOutput();
if(input.IsNull()) return;
if(source.IsNull()) return;
if(input->GetGeometry()==NULL) return;
if(source->GetGeometry()==NULL) return;
if( (input->GetTimeGeometry()->CountTimeSteps()==1) && (source->GetTimeGeometry()->CountTimeSteps()>1) )
{
Geometry3D::Pointer geo3D = Geometry3D::New();
BaseGeometry::Pointer geometry3D = dynamic_cast<BaseGeometry*>(geo3D.GetPointer());
geometry3D->Initialize();
geometry3D->SetBounds(source->GetTimeGeometry()->GetBoundsInWorld());
ProportionalTimeGeometry::Pointer outputTimeGeometry = ProportionalTimeGeometry::New();
outputTimeGeometry->Initialize(geometry3D, source->GetTimeGeometry()->CountTimeSteps());
outputTimeGeometry->SetFirstTimePoint(source->GetTimeGeometry()->GetMinimumTimePoint());
TimePointType stepDuration = source->GetTimeGeometry()->GetMaximumTimePoint(0) - source->GetTimeGeometry()->GetMinimumTimePoint(0);
outputTimeGeometry->SetStepDuration(stepDuration);
output->Expand(outputTimeGeometry->CountTimeSteps());
output->SetTimeGeometry( outputTimeGeometry );
}
else
output->SetGeometry( static_cast<BaseGeometry*>(input->GetGeometry()->Clone().GetPointer()) );
itkDebugMacro(<<"GenerateOutputInformation()");
}
示例2: InitializeViews
//TODO_GOETZ
// Remove old function, so only this one is working.
bool
RenderingManager
::InitializeViews(const BaseGeometry * dataGeometry, RequestType type, bool preserveRoughOrientationInWorldSpace)
{
ProportionalTimeGeometry::Pointer propTimeGeometry = ProportionalTimeGeometry::New();
propTimeGeometry->Initialize(dynamic_cast<BaseGeometry *>(dataGeometry->Clone().GetPointer()), 1);
return InitializeViews(propTimeGeometry, type, preserveRoughOrientationInWorldSpace);
}
示例3: SetTimeGeometry
void mitk::PlanarFigure::InitializeTimeGeometry( unsigned int timeSteps )
{
mitk::PlaneGeometry::Pointer geometry2D = mitk::PlaneGeometry::New();
geometry2D->Initialize();
// The geometry is propagated automatically to all time steps,
// if EvenlyTimed is true...
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(geometry2D, timeSteps);
SetTimeGeometry(timeGeometry);
}
示例4: SetTimeGeometry
void mitk::PlaneGeometryData::SetPlaneGeometry(mitk::PlaneGeometry *geometry2d)
{
if(geometry2d != NULL)
{
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(geometry2d, 1);
SetTimeGeometry(timeGeometry);
Modified();
}
else
Superclass::SetGeometry(geometry2d);
}
示例5: GetGeometryForTimeStep
itk::LightObject::Pointer mitk::ProportionalTimeGeometry::InternalClone() const
{
itk::LightObject::Pointer parent = Superclass::InternalClone();
ProportionalTimeGeometry::Pointer newTimeGeometry =
dynamic_cast<ProportionalTimeGeometry * > (parent.GetPointer());
newTimeGeometry->m_FirstTimePoint = this->m_FirstTimePoint;
newTimeGeometry->m_StepDuration = this->m_StepDuration;
newTimeGeometry->m_GeometryVector.clear();
newTimeGeometry->Expand(this->CountTimeSteps());
for (TimeStepType i =0; i < CountTimeSteps(); ++i)
{
BaseGeometry::Pointer tempGeometry = GetGeometryForTimeStep(i)->Clone();
newTimeGeometry->SetTimeStepGeometry(tempGeometry, i);
}
return parent;
}
示例6: SetTimeGeometry
void mitk::PlanarFigure::InitializeTimeGeometry( unsigned int timeSteps )
{
mitk::Geometry2D::Pointer geometry2D = mitk::Geometry2D::New();
geometry2D->Initialize();
if ( timeSteps > 1 )
{
mitk::ScalarType timeBounds[] = {0.0, 1.0};
geometry2D->SetTimeBounds( timeBounds );
}
// The geometry is propagated automatically to all time steps,
// if EvenlyTimed is true...
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(geometry2D, timeSteps);
SetTimeGeometry(timeGeometry);
}
示例7: itkDebugMacro
void mitk::PlaneFit::GenerateOutputInformation()
{
mitk::PointSet::ConstPointer input = this->GetInput();
mitk::GeometryData::Pointer output = this->GetOutput();
itkDebugMacro(<<"GenerateOutputInformation()");
if (input.IsNull()) return;
if ( m_PointSet == NULL )
{
return;
}
bool update = false;
if ( output->GetGeometry() == NULL || output->GetTimeGeometry() == NULL )
update = true;
if ( ( ! update ) && ( output->GetTimeGeometry()->CountTimeSteps() != input->GetTimeGeometry()->CountTimeSteps() ) )
update = true;
if ( update )
{
mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New();
ProportionalTimeGeometry::Pointer timeGeometry = dynamic_cast<ProportionalTimeGeometry *>(m_TimeGeometry.GetPointer());
timeGeometry->Initialize(planeGeometry, m_PointSet->GetPointSetSeriesSize());
//m_TimeGeometry->InitializeEvenlyTimed(
// planeGeometry, m_PointSet->GetPointSetSeriesSize() );
TimeStepType timeStep;
for ( timeStep = 0;
(timeStep < m_PointSet->GetPointSetSeriesSize())
&& (timeStep < m_Planes.size());
++timeStep )
{
timeGeometry->SetTimeStepGeometry( m_Planes[timeStep], timeStep );
}
output->SetTimeGeometry( m_TimeGeometry );
}
}
示例8: SetTimeGeometry
mitk::ExtrudedContour::ExtrudedContour()
: m_Contour(NULL), m_ClippingGeometry(NULL), m_AutomaticVectorGeneration(false)
{
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(1);
SetTimeGeometry(timeGeometry);
FillVector3D(m_Vector, 0.0, 0.0, 1.0);
m_RightVector.Fill(0.0);
m_ExtrusionFilter = vtkLinearExtrusionFilter::New();
m_ExtrusionFilter->CappingOff();
m_ExtrusionFilter->SetExtrusionTypeToVectorExtrusion();
double vtkvector[3]={0,0,1};
// set extrusion vector
m_ExtrusionFilter->SetVector(vtkvector);
m_TriangleFilter = vtkTriangleFilter::New();
m_TriangleFilter->SetInputConnection(m_ExtrusionFilter->GetOutputPort());
m_SubdivisionFilter = vtkLinearSubdivisionFilter::New();
m_SubdivisionFilter->SetInputConnection(m_TriangleFilter->GetOutputPort());
m_SubdivisionFilter->SetNumberOfSubdivisions(4);
m_ClippingBox = vtkPlanes::New();
m_ClipPolyDataFilter = vtkClipPolyData::New();
m_ClipPolyDataFilter->SetInputConnection(m_SubdivisionFilter->GetOutputPort());
m_ClipPolyDataFilter->SetClipFunction(m_ClippingBox);
m_ClipPolyDataFilter->InsideOutOn();
m_Polygon = vtkPolygon::New();
m_ProjectionPlane = mitk::PlaneGeometry::New();
}
示例9: assert
void mitk::SlicedData::SetGeometry(BaseGeometry* aGeometry3D)
{
if(aGeometry3D!=NULL)
{
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
SlicedGeometry3D::Pointer slicedGeometry = dynamic_cast<SlicedGeometry3D*>(aGeometry3D);
if(slicedGeometry.IsNull())
{
PlaneGeometry* geometry2d = dynamic_cast<PlaneGeometry*>(aGeometry3D);
if(geometry2d!=NULL)
{
if((GetSlicedGeometry()->GetPlaneGeometry(0)==geometry2d) && (GetSlicedGeometry()->GetSlices()==1))
return;
slicedGeometry = SlicedGeometry3D::New();
slicedGeometry->InitializeEvenlySpaced(geometry2d, 1);
}
else
{
slicedGeometry = SlicedGeometry3D::New();
PlaneGeometry::Pointer planeGeometry = PlaneGeometry::New();
planeGeometry->InitializeStandardPlane(aGeometry3D);
slicedGeometry->InitializeEvenlySpaced(planeGeometry, (unsigned int)(aGeometry3D->GetExtent(2)));
}
}
assert(slicedGeometry.IsNotNull());
timeGeometry->Initialize(slicedGeometry, 1);
Superclass::SetTimeGeometry(timeGeometry);
}
else
{
if(GetGeometry()==NULL)
return;
Superclass::SetGeometry(NULL);
}
}
示例10: localeSwitch
std::vector<BaseData::Pointer> ItkImageIO::Read()
{
std::vector<BaseData::Pointer> result;
mitk::LocaleSwitch localeSwitch("C");
Image::Pointer image = Image::New();
const unsigned int MINDIM = 2;
const unsigned int MAXDIM = 4;
const std::string path = this->GetLocalFileName();
MITK_INFO << "loading " << path << " via itk::ImageIOFactory... " << std::endl;
// Check to see if we can read the file given the name or prefix
if (path.empty())
{
mitkThrow() << "Empty filename in mitk::ItkImageIO ";
}
// Got to allocate space for the image. Determine the characteristics of
// the image.
m_ImageIO->SetFileName(path);
m_ImageIO->ReadImageInformation();
unsigned int ndim = m_ImageIO->GetNumberOfDimensions();
if (ndim < MINDIM || ndim > MAXDIM)
{
MITK_WARN << "Sorry, only dimensions 2, 3 and 4 are supported. The given file has " << ndim
<< " dimensions! Reading as 4D.";
ndim = MAXDIM;
}
itk::ImageIORegion ioRegion(ndim);
itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();
itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
unsigned int dimensions[MAXDIM];
dimensions[0] = 0;
dimensions[1] = 0;
dimensions[2] = 0;
dimensions[3] = 0;
ScalarType spacing[MAXDIM];
spacing[0] = 1.0f;
spacing[1] = 1.0f;
spacing[2] = 1.0f;
spacing[3] = 1.0f;
Point3D origin;
origin.Fill(0);
unsigned int i;
for (i = 0; i < ndim; ++i)
{
ioStart[i] = 0;
ioSize[i] = m_ImageIO->GetDimensions(i);
if (i < MAXDIM)
{
dimensions[i] = m_ImageIO->GetDimensions(i);
spacing[i] = m_ImageIO->GetSpacing(i);
if (spacing[i] <= 0)
spacing[i] = 1.0f;
}
if (i < 3)
{
origin[i] = m_ImageIO->GetOrigin(i);
}
}
ioRegion.SetSize(ioSize);
ioRegion.SetIndex(ioStart);
MITK_INFO << "ioRegion: " << ioRegion << std::endl;
m_ImageIO->SetIORegion(ioRegion);
void *buffer = new unsigned char[m_ImageIO->GetImageSizeInBytes()];
m_ImageIO->Read(buffer);
image->Initialize(MakePixelType(m_ImageIO), ndim, dimensions);
image->SetImportChannel(buffer, 0, Image::ManageMemory);
const itk::MetaDataDictionary &dictionary = m_ImageIO->GetMetaDataDictionary();
// access direction of itk::Image and include spacing
mitk::Matrix3D matrix;
matrix.SetIdentity();
unsigned int j, itkDimMax3 = (ndim >= 3 ? 3 : ndim);
for (i = 0; i < itkDimMax3; ++i)
for (j = 0; j < itkDimMax3; ++j)
matrix[i][j] = m_ImageIO->GetDirection(j)[i];
// re-initialize PlaneGeometry with origin and direction
PlaneGeometry *planeGeometry = image->GetSlicedGeometry(0)->GetPlaneGeometry(0);
planeGeometry->SetOrigin(origin);
planeGeometry->GetIndexToWorldTransform()->SetMatrix(matrix);
// re-initialize SlicedGeometry3D
SlicedGeometry3D *slicedGeometry = image->GetSlicedGeometry(0);
slicedGeometry->InitializeEvenlySpaced(planeGeometry, image->GetDimension(2));
slicedGeometry->SetSpacing(spacing);
//.........这里部分代码省略.........
示例11: ioRegion
std::vector<BaseData::Pointer> LabelSetImageIO::Read()
{
const std::string& locale = "C";
const std::string& currLocale = setlocale( LC_ALL, NULL );
if ( locale.compare(currLocale)!=0 )
{
try
{
setlocale(LC_ALL, locale.c_str());
}
catch(...)
{
mitkThrow() << "Could not set locale.";
}
}
// begin regular image loading, adapted from mitkItkImageIO
itk::NrrdImageIO::Pointer nrrdImageIO = itk::NrrdImageIO::New();
Image::Pointer image = Image::New();
const unsigned int MINDIM = 2;
const unsigned int MAXDIM = 4;
const std::string path = this->GetLocalFileName();
MITK_INFO << "loading " << path << " via itk::ImageIOFactory... " << std::endl;
// Check to see if we can read the file given the name or prefix
if (path.empty())
{
mitkThrow() << "Empty filename in mitk::ItkImageIO ";
}
// Got to allocate space for the image. Determine the characteristics of
// the image.
nrrdImageIO->SetFileName(path);
nrrdImageIO->ReadImageInformation();
unsigned int ndim = nrrdImageIO->GetNumberOfDimensions();
if (ndim < MINDIM || ndim > MAXDIM)
{
MITK_WARN << "Sorry, only dimensions 2, 3 and 4 are supported. The given file has " << ndim << " dimensions! Reading as 4D.";
ndim = MAXDIM;
}
itk::ImageIORegion ioRegion(ndim);
itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();
itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
unsigned int dimensions[MAXDIM];
dimensions[0] = 0;
dimensions[1] = 0;
dimensions[2] = 0;
dimensions[3] = 0;
ScalarType spacing[MAXDIM];
spacing[0] = 1.0f;
spacing[1] = 1.0f;
spacing[2] = 1.0f;
spacing[3] = 1.0f;
Point3D origin;
origin.Fill(0);
unsigned int i;
for (i = 0; i < ndim; ++i)
{
ioStart[i] = 0;
ioSize[i] = nrrdImageIO->GetDimensions(i);
if (i<MAXDIM)
{
dimensions[i] = nrrdImageIO->GetDimensions(i);
spacing[i] = nrrdImageIO->GetSpacing(i);
if (spacing[i] <= 0)
spacing[i] = 1.0f;
}
if (i<3)
{
origin[i] = nrrdImageIO->GetOrigin(i);
}
}
ioRegion.SetSize(ioSize);
ioRegion.SetIndex(ioStart);
MITK_INFO << "ioRegion: " << ioRegion << std::endl;
nrrdImageIO->SetIORegion(ioRegion);
void* buffer = new unsigned char[nrrdImageIO->GetImageSizeInBytes()];
nrrdImageIO->Read(buffer);
image->Initialize(MakePixelType(nrrdImageIO), ndim, dimensions);
image->SetImportChannel(buffer, 0, Image::ManageMemory);
// access direction of itk::Image and include spacing
mitk::Matrix3D matrix;
matrix.SetIdentity();
unsigned int j, itkDimMax3 = (ndim >= 3 ? 3 : ndim);
for (i = 0; i < itkDimMax3; ++i)
for (j = 0; j < itkDimMax3; ++j)
//.........这里部分代码省略.........
示例12: pixelType
void mitk::Image::Initialize(vtkImageData* vtkimagedata, int channels, int tDim, int sDim, int pDim)
{
if(vtkimagedata==nullptr) return;
m_Dimension=vtkimagedata->GetDataDimension();
unsigned int i, *tmpDimensions=new unsigned int[m_Dimension>4?m_Dimension:4];
for(i=0;i<m_Dimension;++i) tmpDimensions[i]=vtkimagedata->GetDimensions()[i];
if(m_Dimension<4)
{
unsigned int *p;
for(i=0,p=tmpDimensions+m_Dimension;i<4-m_Dimension;++i, ++p)
*p=1;
}
if(pDim>=0)
{
tmpDimensions[1]=pDim;
if(m_Dimension < 2)
m_Dimension = 2;
}
if(sDim>=0)
{
tmpDimensions[2]=sDim;
if(m_Dimension < 3)
m_Dimension = 3;
}
if(tDim>=0)
{
tmpDimensions[3]=tDim;
if(m_Dimension < 4)
m_Dimension = 4;
}
mitk::PixelType pixelType(MakePixelType(vtkimagedata));
Initialize(pixelType, m_Dimension, tmpDimensions, channels);
const double *spacinglist = vtkimagedata->GetSpacing();
Vector3D spacing;
FillVector3D(spacing, spacinglist[0], 1.0, 1.0);
if(m_Dimension>=2)
spacing[1]=spacinglist[1];
if(m_Dimension>=3)
spacing[2]=spacinglist[2];
// access origin of vtkImage
Point3D origin;
double vtkorigin[3];
vtkimagedata->GetOrigin(vtkorigin);
FillVector3D(origin, vtkorigin[0], 0.0, 0.0);
if(m_Dimension>=2)
origin[1]=vtkorigin[1];
if(m_Dimension>=3)
origin[2]=vtkorigin[2];
SlicedGeometry3D* slicedGeometry = GetSlicedGeometry(0);
// re-initialize PlaneGeometry with origin and direction
PlaneGeometry* planeGeometry = static_cast<PlaneGeometry*>(slicedGeometry->GetPlaneGeometry(0));
planeGeometry->SetOrigin(origin);
// re-initialize SlicedGeometry3D
slicedGeometry->SetOrigin(origin);
slicedGeometry->SetSpacing(spacing);
ProportionalTimeGeometry::Pointer timeGeometry = ProportionalTimeGeometry::New();
timeGeometry->Initialize(slicedGeometry, m_Dimensions[3]);
SetTimeGeometry(timeGeometry);
delete [] tmpDimensions;
}
示例13: indexForUnlabeledTimeStep
mitk::ProportionalTimeGeometry::Pointer mitk::ProportionalTimeGeometryToXML::FromXML(TiXmlElement *timeGeometryElement)
{
if (!timeGeometryElement)
{
MITK_ERROR << "Cannot deserialize ProportionalTimeGeometry from nullptr.";
return nullptr;
}
int numberOfTimeSteps = 0;
if (TIXML_SUCCESS != timeGeometryElement->QueryIntAttribute("NumberOfTimeSteps", &numberOfTimeSteps))
{
MITK_WARN << "<ProportionalTimeGeometry> found without NumberOfTimeSteps attribute. Counting...";
}
// might be missing!
TimePointType firstTimePoint;
std::string firstTimePoint_s;
TimePointType stepDuration;
std::string stepDuration_s;
try
{
if (TIXML_SUCCESS == timeGeometryElement->QueryStringAttribute("FirstTimePoint", &firstTimePoint_s))
{
firstTimePoint = boost::lexical_cast<double>(firstTimePoint_s);
}
else
{
firstTimePoint = -std::numeric_limits<TimePointType>::max();
}
if (TIXML_SUCCESS == timeGeometryElement->QueryStringAttribute("StepDuration", &stepDuration_s))
{
stepDuration = boost::lexical_cast<double>(stepDuration_s);
}
else
{
stepDuration = std::numeric_limits<TimePointType>::infinity();
}
}
catch (boost::bad_lexical_cast &e)
{
MITK_ERROR << "Could not parse string as number: " << e.what();
return nullptr;
}
// list of all geometries with their time steps
std::multimap<TimeStepType, BaseGeometry::Pointer> allReadGeometries;
int indexForUnlabeledTimeStep(-1);
for (TiXmlElement *currentElement = timeGeometryElement->FirstChildElement(); currentElement != nullptr;
currentElement = currentElement->NextSiblingElement())
{
// different geometries could have been inside a ProportionalTimeGeometry.
// By now, we only support Geometry3D
std::string tagName = currentElement->Value();
if (tagName == "Geometry3D")
{
Geometry3D::Pointer restoredGeometry = Geometry3DToXML::FromXML(currentElement);
if (restoredGeometry.IsNotNull())
{
int timeStep(-1);
if (TIXML_SUCCESS != currentElement->QueryIntAttribute("TimeStep", &timeStep))
{
timeStep = indexForUnlabeledTimeStep--; // decrement index for next one
MITK_WARN << "Found <Geometry3D> without 'TimeStep' attribute in <ProportionalTimeGeometry>. No guarantees "
"on order anymore.";
}
if (allReadGeometries.count(static_cast<TimeStepType>(timeStep)) > 0)
{
MITK_WARN << "Found <Geometry3D> tags with identical 'TimeStep' attribute in <ProportionalTimeGeometry>. No "
"guarantees on order anymore.";
}
allReadGeometries.insert(std::make_pair(static_cast<TimeStepType>(timeStep), restoredGeometry.GetPointer()));
}
}
else
{
MITK_WARN << "Found unsupported tag <" << tagName << "> inside <ProportionalTimeGeometry>. Ignoring.";
}
}
// now add all BaseGeometries that were read to a new instance
// of ProportionalTimeGeometry
ProportionalTimeGeometry::Pointer newTimeGeometry = ProportionalTimeGeometry::New();
newTimeGeometry->SetFirstTimePoint(firstTimePoint);
newTimeGeometry->SetStepDuration(stepDuration);
newTimeGeometry->ReserveSpaceForGeometries(allReadGeometries.size());
TimeStepType t(0);
for (auto entry : allReadGeometries)
{
// We add items with newly assigned time steps.
// This avoids great confusion when a file contains
// bogus numbers.
newTimeGeometry->SetTimeStepGeometry(entry.second, t++);
}
//.........这里部分代码省略.........
示例14: localeSwitch
std::vector<itk::SmartPointer<mitk::BaseData>> mitk::GeometryDataReaderService::Read()
{
// Switch the current locale to "C"
LocaleSwitch localeSwitch("C");
std::vector<itk::SmartPointer<BaseData>> result;
InputStream stream(this);
TiXmlDocument doc;
stream >> doc;
if (!doc.Error())
{
TiXmlHandle docHandle(&doc);
for (TiXmlElement *geomDataElement = docHandle.FirstChildElement("GeometryData").ToElement();
geomDataElement != nullptr;
geomDataElement = geomDataElement->NextSiblingElement())
{
for (TiXmlElement *currentElement = geomDataElement->FirstChildElement(); currentElement != nullptr;
currentElement = currentElement->NextSiblingElement())
{
// different geometries could have been serialized from a GeometryData
// object:
std::string tagName = currentElement->Value();
if (tagName == "Geometry3D")
{
Geometry3D::Pointer restoredGeometry = Geometry3DToXML::FromXML(currentElement);
if (restoredGeometry.IsNotNull())
{
GeometryData::Pointer newGeometryData = GeometryData::New();
newGeometryData->SetGeometry(restoredGeometry);
result.push_back(newGeometryData.GetPointer());
}
else
{
MITK_ERROR << "Invalid <Geometry3D> tag encountered. Skipping.";
}
}
else if (tagName == "ProportionalTimeGeometry")
{
ProportionalTimeGeometry::Pointer restoredTimeGeometry =
ProportionalTimeGeometryToXML::FromXML(currentElement);
if (restoredTimeGeometry.IsNotNull())
{
GeometryData::Pointer newGeometryData = GeometryData::New();
newGeometryData->SetTimeGeometry(restoredTimeGeometry);
result.push_back(newGeometryData.GetPointer());
}
else
{
MITK_ERROR << "Invalid <ProportionalTimeGeometry> tag encountered. Skipping.";
}
}
} // for child of <GeometryData>
} // for <GeometryData>
}
else
{
mitkThrow() << "Parsing error at line " << doc.ErrorRow() << ", col " << doc.ErrorCol() << ": " << doc.ErrorDesc();
}
if (result.empty())
{
mitkThrow() << "Did not read a single GeometryData object from input.";
}
return result;
}
示例15: ioRegion
std::vector<BaseData::Pointer> ItkImageIO::Read()
{
std::vector<BaseData::Pointer> result;
const std::string& locale = "C";
const std::string& currLocale = setlocale( LC_ALL, NULL );
if ( locale.compare(currLocale)!=0 )
{
try
{
setlocale(LC_ALL, locale.c_str());
}
catch(...)
{
MITK_INFO << "Could not set locale " << locale;
}
}
Image::Pointer image = Image::New();
const unsigned int MINDIM = 2;
const unsigned int MAXDIM = 4;
const std::string path = this->GetLocalFileName();
MITK_INFO << "loading " << path << " via itk::ImageIOFactory... " << std::endl;
// Check to see if we can read the file given the name or prefix
if (path.empty())
{
mitkThrow() << "Empty filename in mitk::ItkImageIO ";
}
// Got to allocate space for the image. Determine the characteristics of
// the image.
m_ImageIO->SetFileName( path );
m_ImageIO->ReadImageInformation();
unsigned int ndim = m_ImageIO->GetNumberOfDimensions();
if ( ndim < MINDIM || ndim > MAXDIM )
{
MITK_WARN << "Sorry, only dimensions 2, 3 and 4 are supported. The given file has " << ndim << " dimensions! Reading as 4D.";
ndim = MAXDIM;
}
itk::ImageIORegion ioRegion( ndim );
itk::ImageIORegion::SizeType ioSize = ioRegion.GetSize();
itk::ImageIORegion::IndexType ioStart = ioRegion.GetIndex();
unsigned int dimensions[ MAXDIM ];
dimensions[ 0 ] = 0;
dimensions[ 1 ] = 0;
dimensions[ 2 ] = 0;
dimensions[ 3 ] = 0;
ScalarType spacing[ MAXDIM ];
spacing[ 0 ] = 1.0f;
spacing[ 1 ] = 1.0f;
spacing[ 2 ] = 1.0f;
spacing[ 3 ] = 1.0f;
Point3D origin;
origin.Fill(0);
unsigned int i;
for ( i = 0; i < ndim ; ++i )
{
ioStart[ i ] = 0;
ioSize[ i ] = m_ImageIO->GetDimensions( i );
if(i<MAXDIM)
{
dimensions[ i ] = m_ImageIO->GetDimensions( i );
spacing[ i ] = m_ImageIO->GetSpacing( i );
if(spacing[ i ] <= 0)
spacing[ i ] = 1.0f;
}
if(i<3)
{
origin[ i ] = m_ImageIO->GetOrigin( i );
}
}
ioRegion.SetSize( ioSize );
ioRegion.SetIndex( ioStart );
MITK_INFO << "ioRegion: " << ioRegion << std::endl;
m_ImageIO->SetIORegion( ioRegion );
void* buffer = new unsigned char[m_ImageIO->GetImageSizeInBytes()];
m_ImageIO->Read( buffer );
image->Initialize( MakePixelType(m_ImageIO), ndim, dimensions );
image->SetImportChannel( buffer, 0, Image::ManageMemory );
// access direction of itk::Image and include spacing
mitk::Matrix3D matrix;
matrix.SetIdentity();
unsigned int j, itkDimMax3 = (ndim >= 3? 3 : ndim);
for ( i=0; i < itkDimMax3; ++i)
for( j=0; j < itkDimMax3; ++j )
//.........这里部分代码省略.........