Skip to content
Snippets Groups Projects
Commit feefe51f authored by Jonathan Guinet's avatar Jonathan Guinet
Browse files

REFAC CheckExpression modification in MaskMuParserFilter

parent c79fdd0a
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,6 @@ void LabelObjectOpeningMuParserFilter<TImage, TFunction>::DisplayVar() const ...@@ -85,7 +85,6 @@ void LabelObjectOpeningMuParserFilter<TImage, TFunction>::DisplayVar() const
{ {
const std::map<std::string, double*>& variables = this->m_Functor.GetVar(); const std::map<std::string, double*>& variables = this->m_Functor.GetVar();
std::cout<<"nb var "<<variables.size()<<std::endl;
// Get the number of variables // Get the number of variables
std::map<std::string, double*>::const_iterator item = variables.begin(); std::map<std::string, double*>::const_iterator item = variables.begin();
......
...@@ -103,17 +103,11 @@ bool MaskMuParserFilter<TInputImage, TOutputImage, TFunction>::CheckExpression() ...@@ -103,17 +103,11 @@ bool MaskMuParserFilter<TInputImage, TOutputImage, TFunction>::CheckExpression()
FunctorPointer checkFunctor = FunctorType::New(); FunctorPointer checkFunctor = FunctorType::New();
checkFunctor->SetExpression(m_Expression); checkFunctor->SetExpression(m_Expression);
//initialize
InputImageConstPointer inputPtr = this->GetInput();
itk::ImageConstIterator<TInputImage> inputIt(inputPtr, inputPtr->GetRequestedRegion());
inputIt.GoToBegin();
FunctorType& functor = *checkFunctor; FunctorType& functor = *checkFunctor;
try try
{ {
functor(inputIt.Get()); functor(this->GetInput()->GetPixel(this->GetInput()->GetBufferedRegion().GetIndex()));
} }
catch (itk::ExceptionObject& err) catch (itk::ExceptionObject& err)
......
...@@ -68,6 +68,16 @@ public: ...@@ -68,6 +68,16 @@ public:
/** Update the pixel description */ /** Update the pixel description */
void UpdatePixelDescription(const IndexType& index); void UpdatePixelDescription(const IndexType& index);
/** add layer name in pixel information description**/
void AddLayerNameToDisplay(const char *layerName);
/** remove layer name in pixel information description return true if the layer name have been found
* false otherwise **/
bool RemoveLayerNameToDisplay(const char *layerName);
protected: protected:
/** Constructor */ /** Constructor */
PixelDescriptionModel(); PixelDescriptionModel();
...@@ -80,6 +90,9 @@ protected: ...@@ -80,6 +90,9 @@ protected:
/** Notify a registered listener */ /** Notify a registered listener */
void NotifyListener(ListenerType * listener); void NotifyListener(ListenerType * listener);
/** check if the layer pixel description has to be displayed **/
bool HasToDisplayLayerPixeldescription(const char *layerName);
private: private:
PixelDescriptionModel(const Self&); // purposely not implemented PixelDescriptionModel(const Self&); // purposely not implemented
void operator =(const Self&); // purposely not implemented void operator =(const Self&); // purposely not implemented
...@@ -87,6 +100,9 @@ private: ...@@ -87,6 +100,9 @@ private:
/** The pixel description */ /** The pixel description */
std::string m_PixelDescription; std::string m_PixelDescription;
/** which layer to display **/
std::vector<std::string> m_LayerNameToDisplay;
}; // end class }; // end class
} // end namespace otb } // end namespace otb
......
...@@ -44,6 +44,51 @@ PixelDescriptionModel<TOutputImage> ...@@ -44,6 +44,51 @@ PixelDescriptionModel<TOutputImage>
m_PixelDescription = ""; m_PixelDescription = "";
} }
template <class TOutputImage>
void PixelDescriptionModel<TOutputImage>
::AddLayerNameToDisplay(const char* layerName)
{
std::string stringName(layerName);
m_LayerNameToDisplay.push_back(stringName);
}
/** **/
template <class TOutputImage>
bool PixelDescriptionModel<TOutputImage>
::RemoveLayerNameToDisplay(const char * layerName)
{
for (unsigned int i = 0; i < m_LayerNameToDisplay.size(); i++)
{
if (!(m_LayerNameToDisplay.at(i).compare(layerName)))
{
std::cout << "layer found remove " << m_LayerNameToDisplay.at(i) << std::endl;
m_LayerNameToDisplay.erase(m_LayerNameToDisplay.begin()+i);
return true;
}
}
return false;
}
template <class TOutputImage>
bool PixelDescriptionModel<TOutputImage>
::HasToDisplayLayerPixeldescription(const char * layerName)
{
for (unsigned int i = 0; i < m_LayerNameToDisplay.size(); i++)
{
if (!(m_LayerNameToDisplay.at(i).compare(layerName)))
return true;
}
return false;
}
template <class TOutputImage> template <class TOutputImage>
void void
PixelDescriptionModel<TOutputImage> PixelDescriptionModel<TOutputImage>
...@@ -57,7 +102,7 @@ PixelDescriptionModel<TOutputImage> ...@@ -57,7 +102,7 @@ PixelDescriptionModel<TOutputImage>
it != this->GetLayers()->End(); ++it) it != this->GetLayers()->End(); ++it)
{ {
// If the layer is visible // If the layer is visible
if (it.Get()->GetVisible()) if (it.Get()->GetVisible() || this->HasToDisplayLayerPixeldescription(it.Get()->GetName()))
{ {
// Get the pixel description // Get the pixel description
oss << it.Get()->GetPixelDescription(index) << std::endl; oss << it.Get()->GetPixelDescription(index) << std::endl;
......
...@@ -65,7 +65,6 @@ ScalarToRGBPixelFunctor<TScalar> ...@@ -65,7 +65,6 @@ ScalarToRGBPixelFunctor<TScalar>
ans[0] = static_cast<RGBComponentType>( bytes[m_Index[0]] * 3 ); ans[0] = static_cast<RGBComponentType>( bytes[m_Index[0]] * 3 );
ans[1] = static_cast<RGBComponentType>( (bytes[m_Index[0]] + bytes[m_Index[1]]) * 5 ); ans[1] = static_cast<RGBComponentType>( (bytes[m_Index[0]] + bytes[m_Index[1]]) * 5 );
ans[2] = static_cast<RGBComponentType>( (bytes[m_Index[0]] + bytes[m_Index[2]]) ); ans[2] = static_cast<RGBComponentType>( (bytes[m_Index[0]] + bytes[m_Index[2]]) );
return ans; return ans;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment