<commit_before>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __otbRenderingFunction_h
#define __otbRenderingFunction_h

#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkVariableLengthVector.h"

namespace otb
{
namespace Function
{
/**\class RenderingFunction
 * \brief Base class for rendering functions.
 *  Please note that this class is pure virtual, and should be
 *  subclassed.
 */
template <class TPixelPrecision, class TRGBPixel>
class RenderingFunction
  : public itk::Object
{
public:
  /** Standard class typedefs */
  typedef RenderingFunction             Self;
  typedef itk::Object                   Superclass;
  typedef itk::SmartPointer<Self>       Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

  /** type macro */
  itkTypeMacro(RenderingFunction,Object);

  /** PixelType macros */
  typedef TRGBPixel                                  OutputPixelType;
  typedef TPixelPrecision                            ScalarPixelType;
  typedef itk::VariableLengthVector<ScalarPixelType> VectorPixelType;
  /** Extrema vector */
  typedef std::vector<ScalarPixelType>               ExtremaVectorType;
  
  /** Evaluate method (scalar version) */
  virtual const OutputPixelType Evaluate(ScalarPixelType spixel) = 0;
  /** Evaluate method (vector version) */
  virtual const OutputPixelType Evaluate(const VectorPixelType & vpixel) = 0;
  
  /** Set the minimum (scalar version) */
  virtual void SetMinimum(ScalarPixelType spixel)
  {
    m_Minimum.clear();
    m_Minimum.push_back(spixel);
  }
  
  /** Set the maximum (scalar version) */
  virtual void SetMaximum(ScalarPixelType spixel)
  {
    m_Maximum.clear();
    m_Maximum.push_back(spixel);
  }
  
 /** Set minimum (vector version) */
  virtual void SetMinimum(const VectorPixelType & vpixel)
  {
    m_Minimum.clear();
    for(unsigned int i = 0; i < vpixel.Size();++i)
      {
      m_Minimum.push_back(vpixel[i]);
      }
  }
  
  /** Set maximum (vector version) */
  virtual void SetMaximum(const VectorPixelType & vpixel)
  {
    m_Maximum.clear();
    for(unsigned int i = 0; i < vpixel.Size();++i)
      {
      m_Maximum.push_back(vpixel[i]);
      }
  }

  /** Set minimum (std::vector version) */
  virtual void SetMinimum(const ExtremaVectorType & vpixel)
  {
    m_Minimum = vpixel;
  }

  /** Set maximum (std::vector version) */
  virtual void SetMaximum(const ExtremaVectorType & vpixel)
  {
    m_Maximum = vpixel;
  }

protected:
  /** Constructor */
  RenderingFunction()  {}
  /** Destructor */
  virtual ~RenderingFunction() {}

  /** Extrema values */
  ExtremaVectorType m_Minimum;
  ExtremaVectorType m_Maximum;

private:
  RenderingFunction(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented
};
} // end namespace Function
} // end namepsace otb

#endif


<commit_msg>ENH: (Visu Refactoring) Replacing instantiation by constructor initializer<commit_after>/*=========================================================================

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt for details.


     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
#ifndef __otbRenderingFunction_h
#define __otbRenderingFunction_h

#include "itkObject.h"
#include "itkObjectFactory.h"
#include "itkVariableLengthVector.h"

namespace otb
{
namespace Function
{
/**\class RenderingFunction
 * \brief Base class for rendering functions.
 *  Please note that this class is pure virtual, and should be
 *  subclassed.
 */
template <class TPixelPrecision, class TRGBPixel>
class RenderingFunction
  : public itk::Object
{
public:
  /** Standard class typedefs */
  typedef RenderingFunction             Self;
  typedef itk::Object                   Superclass;
  typedef itk::SmartPointer<Self>       Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

  /** type macro */
  itkTypeMacro(RenderingFunction,Object);

  /** PixelType macros */
  typedef TRGBPixel                                  OutputPixelType;
  typedef TPixelPrecision                            ScalarPixelType;
  typedef itk::VariableLengthVector<ScalarPixelType> VectorPixelType;
  /** Extrema vector */
  typedef std::vector<ScalarPixelType>               ExtremaVectorType;
  
  /** Evaluate method (scalar version) */
  virtual const OutputPixelType Evaluate(ScalarPixelType spixel) = 0;
  /** Evaluate method (vector version) */
  virtual const OutputPixelType Evaluate(const VectorPixelType & vpixel) = 0;
  
  /** Set the minimum (scalar version) */
  virtual void SetMinimum(ScalarPixelType spixel)
  {
    m_Minimum.clear();
    m_Minimum.push_back(spixel);
  }
  
  /** Set the maximum (scalar version) */
  virtual void SetMaximum(ScalarPixelType spixel)
  {
    m_Maximum.clear();
    m_Maximum.push_back(spixel);
  }
  
 /** Set minimum (vector version) */
  virtual void SetMinimum(const VectorPixelType & vpixel)
  {
    m_Minimum.clear();
    for(unsigned int i = 0; i < vpixel.Size();++i)
      {
      m_Minimum.push_back(vpixel[i]);
      }
  }
  
  /** Set maximum (vector version) */
  virtual void SetMaximum(const VectorPixelType & vpixel)
  {
    m_Maximum.clear();
    for(unsigned int i = 0; i < vpixel.Size();++i)
      {
      m_Maximum.push_back(vpixel[i]);
      }
  }

  /** Set minimum (std::vector version) */
  virtual void SetMinimum(const ExtremaVectorType & vpixel)
  {
    m_Minimum = vpixel;
  }

  /** Set maximum (std::vector version) */
  virtual void SetMaximum(const ExtremaVectorType & vpixel)
  {
    m_Maximum = vpixel;
  }

protected:
  /** Constructor */
  RenderingFunction() : m_Minimum(), m_Maximum()  {}
  /** Destructor */
  virtual ~RenderingFunction() {}

  /** Extrema values */
  ExtremaVectorType m_Minimum;
  ExtremaVectorType m_Maximum;

private:
  RenderingFunction(const Self&); //purposely not implemented
  void operator=(const Self&); //purposely not implemented
};
} // end namespace Function
} // end namepsace otb

#endif



{'fraction_non_alphanumeric': 0.1398243045387994, 'fraction_numerical': 0.001171303074670571, 'mean_word_length': 3.4328358208955225, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1440844', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1939, 'n_words': 529}