Commit e49717ac authored by Manuel Grizonnet's avatar Manuel Grizonnet

ENH: fix some coverity bugs 25/10/2016

parent 32f11b04
......@@ -203,7 +203,16 @@ int main(int argc, char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
filter->Update();
try
{
filter->Update();
}
catch (itk::ExceptionObject& err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return -1;
}
// Software Guide : EndCodeSnippet
writer->SetFileName(argv[2]);
......
......@@ -223,7 +223,16 @@ int main(int argc, char* argv[])
writer->SetInput(rescaleFilter->GetOutput());
writer->Update();
try
{
writer->Update();
}
catch (itk::ExceptionObject& err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return -1;
}
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......
......@@ -137,7 +137,7 @@ void SamplingRateCalculator
// Then compute number of samples for each class
for (it = m_RatesByClass.begin(); it != m_RatesByClass.end() ; ++it)
{
double ratio = it->second.Tot / static_cast<double>(totalNumberOfSamplesAvailable);
double ratio = totalNumberOfSamplesAvailable != 0 ? it->second.Tot / static_cast<double>(totalNumberOfSamplesAvailable): 0;
it->second.Required = static_cast<unsigned long>(0.5+ratio*value);
this->UpdateRate(it->first);
......
......@@ -372,19 +372,33 @@ SamplingRateCalculatorList
total_nb_samples+=nb_samples[i];
}
for (unsigned int i=0 ; i<this->Size() ; i++)
{
const Superclass::InternalContainerSizeType sampleListSize = this->Size();
for (unsigned int i=0 ; i<sampleListSize ; i++)
{
if (total_nb_samples != 0)
{
this->GetNthElement(i)->SetTotalNumberOfSamples(vcl_floor(0.5+tot[0]*nb_samples[i]/static_cast<double>(total_nb_samples)));
}
else
{
this->GetNthElement(i)->SetTotalNumberOfSamples(0);
}
}
break;
}
case EQUAL:
{
const Superclass::InternalContainerSizeType sampleListSize = this->Size();
unsigned long total_by_image = static_cast<unsigned long>(vcl_floor(tot[0]/static_cast<double>(this->Size())));
for (unsigned int i=0 ; i<this->Size() ; i++)
unsigned long total_by_image = 0;
if (sampleListSize != 0)
{
total_by_image = static_cast<unsigned long>(vcl_floor(tot[0]/static_cast<double>(sampleListSize)));
}
for (unsigned int i=0 ; i<sampleListSize ; i++)
{
this->GetNthElement(i)->SetTotalNumberOfSamples(total_by_image);
}
......
......@@ -217,6 +217,7 @@ struct PixelInfo
m_Point(),
m_Index(),
m_Pixel(),
m_Resolution (1),
m_HasPoint( false ),
m_HasIndex( false ),
m_HasPixel( false ),
......
......@@ -165,10 +165,6 @@ private:
*/
Ui::ImportImagesDialog * m_UI;
/**
*/
QPushButton * m_IgnoreButton;
/**
*/
GDALOverviewsBuilderVector m_GDALOverviewsBuilders;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment