Skip to content
Snippets Groups Projects
Commit d736f8e2 authored by Julien Malik's avatar Julien Malik
Browse files

ENH: PrintSelf improvements to avoid segfaults when projections are not initialized

parent f52f82e2
Branches
Tags
No related merge requests found
......@@ -176,6 +176,8 @@ protected:
virtual void GenerateInputRequestedRegion();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
StreamingResampleImageFilter(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
......
......@@ -133,5 +133,19 @@ StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionTy
this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() );
}
template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType>
void
StreamingResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecisionType>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "OutputOrigin: " << this->GetOutputOrigin() << std::endl;
os << indent << "OutputSpacing: " << this->GetOutputSpacing() << std::endl;
os << indent << "OutputStartIndex: " << this->GetOutputStartIndex() << std::endl;
os << indent << "OutputSize: " << this->GetOutputSize() << std::endl;
}
}
#endif
......@@ -107,7 +107,13 @@ DEMToOrthoImageGenerator<TDEMImage, TMapProjection>
::PrintSelf(std::ostream& os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Map projection:" << m_MapProjection->GetWkt() << std::endl;
if (m_MapProjection.IsNull())
os << indent << "Map projection: NULL" << std::endl;
else
{
os << indent << "Map projection:" << std::endl;
m_MapProjection->Print(os, indent.GetNextIndent());
}
}
} // namespace otb
......
......@@ -106,6 +106,9 @@ public:
protected:
GenericMapProjection();
virtual ~GenericMapProjection();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
OssimMapProjectionType* m_MapProjection;
std::string m_ProjectionRefWkt;
......
......@@ -212,6 +212,17 @@ GenericMapProjection<Transform, TScalarType, NInputDimensions, NOutputDimensions
std::cout << m_MapProjection->print(std::cout);
}
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions,
unsigned int NOutputDimensions>
void
GenericMapProjection<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "ProjectionRefWkt: " << m_ProjectionRefWkt << std::endl;
}
} // namespace otb
#endif
......@@ -277,6 +277,8 @@ protected:
virtual void UpdateTransform();
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
GenericRSResampleImageFilter(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
......
......@@ -371,12 +371,24 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage>
outputSize[0] = static_cast<unsigned int>(vcl_floor(vcl_abs(sizeCartoX / this->GetOutputSpacing()[0])));
outputSize[1] = static_cast<unsigned int>(vcl_floor(vcl_abs(sizeCartoY / this->GetOutputSpacing()[1])));
this->SetOutputSize(outputSize);
std::cout <<"Output Image params :"
<< " \n OutputSize " << outputSize
<< " \n OutputOrigin " << origin
<< " \n OutputSpacing "<< this->GetOutputSpacing()
<< std::endl;
}
template <class TInputImage, class TOutputImage>
void
GenericRSResampleImageFilter<TInputImage, TOutputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "EstimateInputRpcModel:" << (m_EstimateInputRpcModel ? "On" : "Off") << std::endl;
os << indent << "EstimateOutputRpcModel:" << (m_EstimateOutputRpcModel ? "On" : "Off") << std::endl;
os << indent << "RpcEstimationUpdated:" << (m_RpcEstimationUpdated ? "True" : "False") << std::endl;
os << indent << "OutputOrigin: " << m_Resampler->GetOutputOrigin() << std::endl;
os << indent << "OutputSpacing: " << m_Resampler->GetOutputSpacing() << std::endl;
os << indent << "OutputStartIndex: " << m_Resampler->GetOutputStartIndex() << std::endl;
os << indent << "OutputSize: " << m_Resampler->GetOutputSize() << std::endl;
os << indent << "GenericRSTransform: " << std::endl;
m_Transform->Print(os, indent.GetNextIndent());
}
}
......
......@@ -190,13 +190,7 @@ protected:
m_TransformUpToDate = false;
}
void PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Up to date: " << m_TransformUpToDate << std::endl;
os << indent << "Input transform: " << m_InputTransform << std::endl;
os << indent << "Output transform: " << m_OutputTransform << std::endl;
}
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
GenericRSTransform(const Self &); //purposely not implemented
......
......@@ -346,15 +346,26 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
return inverseTransform;
}
//TODO
// template<class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
// void
// GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
// ::PrintSelf() const
// {
//
// std::cout << m_Transform->print(std::cout);
// }
template<class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
void
GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Up to date: " << m_TransformUpToDate << std::endl;
if (m_TransformUpToDate)
{
os << indent << "Input transform: "<< std::endl;
m_InputTransform->Print(os, indent.GetNextIndent());
os << indent << "Output transform: " << std::endl;
m_OutputTransform->Print(os, indent.GetNextIndent());
}
else
{
os << indent << "Input transform: NULL" << std::endl;
os << indent << "Output transform: NULL" << std::endl;
}
}
} // namespace otb
......
......@@ -157,6 +157,12 @@ protected:
}
virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const
{
Superclass::PrintSelf(os, indent);
os << indent << "Wkt : " << this->GetWkt() << std::endl;
}
private:
MapProjection(const Self &); //purposely not implemented
void operator =(const Self&); //purposely not implemented
......
......@@ -48,6 +48,7 @@ int otbGenericRSResampleImageFilterNew(int argc, char* argv[])
{
// SmartPointer instanciation
ImageResamplerType::Pointer resampler = ImageResamplerType::New();
std::cout << resampler << std::endl;
return EXIT_SUCCESS;
}
......@@ -120,6 +121,7 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[])
resampler->SetOutputRpcGridSize(20);
resampler->EstimateOutputRpcModelOn();
}
// Write the resampled image
WriterType::Pointer writer= WriterType::New();
......@@ -128,6 +130,8 @@ int otbGenericRSResampleImageFilter(int argc, char* argv[])
writer->SetInput(resampler->GetOutput());
writer->Update();
std::cout << resampler << std::endl;
return EXIT_SUCCESS;
}
......@@ -192,8 +196,8 @@ int otbGenericRSResampleImageFilterFromMap(int argc, char* argv[])
{
resampler->SetInputRpcGridSize(20);
resampler->EstimateInputRpcModelOn();
}
}
// Write the resampled image
typedef otb::StreamingImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer= WriterType::New();
......@@ -202,6 +206,8 @@ int otbGenericRSResampleImageFilterFromMap(int argc, char* argv[])
writer->SetInput(resampler->GetOutput());
writer->Update();
std::cout << resampler << std::endl;
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment