<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 __otbNoStretchRenderingFunction_h
#define __otbNoStretchRenderingFunction_h

#include <cassert>
#include <iomanip>
#include <vector>

#include "otbMacro.h"
#include "otbI18n.h"
#include "otbChannelSelectorFunctor.h"
#include "otbStandardRenderingFunction.h"
#include "otbViewerConst.h"

#include "otbRenderingFunction.h"


namespace otb
{
  namespace Function
  {
    // Identity class template defined in otbStandardRenderingFunction.h
    // template <class TInputPixel, class TOutputPixel> class Identity;

    /** \class NoStretchRenderingFunction
     * \brief No stretch rendering (0-255 clipping).
     * If the input image is an Image, the function renders it with R, G and
     * B channels all equals.
     * If it is a VectorImage, the function renders the selected channels.
     *  \ingroup Visualization
     */
    template <class TPixel, class TRGBPixel,
              class TPixelRepresentationFunction = ChannelSelectorFunctor<TPixel>,
              class TTransferFunction = Identity<
                typename itk::NumericTraits<typename itk::NumericTraits<TPixel>::ValueType>::RealType,
                typename itk::NumericTraits<typename itk::NumericTraits<TPixel>::ValueType>::RealType
                > >
    class NoStretchRenderingFunction
      : public StandardRenderingFunction<TPixel, TRGBPixel, TPixelRepresentationFunction, TTransferFunction>
    {
      public:
        /** Standard class typedefs */
        typedef NoStretchRenderingFunction                   Self;
        typedef StandardRenderingFunction<TPixel, TRGBPixel> Superclass;
        typedef itk::SmartPointer<Self>                      Pointer;
        typedef itk::SmartPointer<const Self>                ConstPointer;

        /** type macro */
        //itkTypeMacro(NoStretchRenderingFunction, RenderingFunction);
        itkTypeMacro(NoStretchRenderingFunction, StandardRenderingFunction);

        /** new macro */
        itkNewMacro(Self);

        /** PixelType macros */
        typedef TRGBPixel                                         OutputPixelType;
        typedef typename OutputPixelType::ValueType               OutputValueType;
        typedef TPixel                                            PixelType;
        typedef typename itk::NumericTraits<PixelType>::ValueType ScalarType;
        typedef itk::VariableLengthVector<ScalarType>             VectorPixelType;
        typedef itk::RGBPixel<ScalarType>                         RGBPixelType;
        typedef typename itk::NumericTraits<ScalarType>::RealType RealScalarType;
        typedef itk::VariableLengthVector<RealScalarType>         InternalPixelType;
        typedef typename Superclass::ParametersType               ParametersType;

        // MDE
        typedef TTransferFunction                                 TransferFunctionType;
        typedef TPixelRepresentationFunction                      PixelRepresentationFunctionType;
        
        typedef typename PixelRepresentationFunctionType::Pointer         PixelRepresentationFunctionPointerType;
        typedef typename PixelRepresentationFunctionType::ChannelListType ChannelListType;
        // \MDE
 
        /**
         * Convert the output of the pixel representation to a RGB pixel on
         * unsigned char to be displayed on screen. Values are contrained to
         * 0-255 with a transfer function and a clamping operation.
         * If the pixel representation gives one band, the image is displayed
         * on grey level
         * If it gives 3 bands, it is interpreted as Red, Green and Blue
         * If there is a fourth band, it is considered as the alpha channel
         * and is not scaled.
         */
        virtual OutputPixelType EvaluateTransferFunction(const InternalPixelType &  spixel) const
        {
          if ((spixel.Size() != 1) && (spixel.Size() != 3) && (spixel.Size() != 4))
          {
            itkExceptionMacro( << "the PixelRepresentation function should give an output of "
                               << "size 1, 3 or 4 otherwise I don't know how to make an RGB of it !" );
          }

          OutputPixelType output(SCREEN_COLOR_MAX_VALUE);

          if (spixel.Size() == 1)
          {
            OutputValueType value = ClippedValue(m_TransferFunction(spixel[0]));
            output[0] = value;
            output[1] = value;
            output[2] = value;
          }
          else
          {
            output[0] = ClippedValue(m_TransferFunction(spixel[0]));
            output[1] = ClippedValue(m_TransferFunction(spixel[1]));
            output[2] = ClippedValue(m_TransferFunction(spixel[2]));
          }
<commit_msg>COMP:use this statement to allow to compile Monteverdi with gcc 4.7<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 __otbNoStretchRenderingFunction_h
#define __otbNoStretchRenderingFunction_h

#include <cassert>
#include <iomanip>
#include <vector>

#include "otbMacro.h"
#include "otbI18n.h"
#include "otbChannelSelectorFunctor.h"
#include "otbStandardRenderingFunction.h"
#include "otbViewerConst.h"

#include "otbRenderingFunction.h"


namespace otb
{
  namespace Function
  {
    // Identity class template defined in otbStandardRenderingFunction.h
    // template <class TInputPixel, class TOutputPixel> class Identity;

    /** \class NoStretchRenderingFunction
     * \brief No stretch rendering (0-255 clipping).
     * If the input image is an Image, the function renders it with R, G and
     * B channels all equals.
     * If it is a VectorImage, the function renders the selected channels.
     *  \ingroup Visualization
     */
    template <class TPixel, class TRGBPixel,
              class TPixelRepresentationFunction = ChannelSelectorFunctor<TPixel>,
              class TTransferFunction = Identity<
                typename itk::NumericTraits<typename itk::NumericTraits<TPixel>::ValueType>::RealType,
                typename itk::NumericTraits<typename itk::NumericTraits<TPixel>::ValueType>::RealType
                > >
    class NoStretchRenderingFunction
      : public StandardRenderingFunction<TPixel, TRGBPixel, TPixelRepresentationFunction, TTransferFunction>
    {
      public:
        /** Standard class typedefs */
        typedef NoStretchRenderingFunction                   Self;
        typedef StandardRenderingFunction<TPixel, TRGBPixel> Superclass;
        typedef itk::SmartPointer<Self>                      Pointer;
        typedef itk::SmartPointer<const Self>                ConstPointer;

        /** type macro */
        //itkTypeMacro(NoStretchRenderingFunction, RenderingFunction);
        itkTypeMacro(NoStretchRenderingFunction, StandardRenderingFunction);

        /** new macro */
        itkNewMacro(Self);

        /** PixelType macros */
        typedef TRGBPixel                                         OutputPixelType;
        typedef typename OutputPixelType::ValueType               OutputValueType;
        typedef TPixel                                            PixelType;
        typedef typename itk::NumericTraits<PixelType>::ValueType ScalarType;
        typedef itk::VariableLengthVector<ScalarType>             VectorPixelType;
        typedef itk::RGBPixel<ScalarType>                         RGBPixelType;
        typedef typename itk::NumericTraits<ScalarType>::RealType RealScalarType;
        typedef itk::VariableLengthVector<RealScalarType>         InternalPixelType;
        typedef typename Superclass::ParametersType               ParametersType;

        // MDE
        typedef TTransferFunction                                 TransferFunctionType;
        typedef TPixelRepresentationFunction                      PixelRepresentationFunctionType;
        
        typedef typename PixelRepresentationFunctionType::Pointer         PixelRepresentationFunctionPointerType;
        typedef typename PixelRepresentationFunctionType::ChannelListType ChannelListType;
        // \MDE
 
        /**
         * Convert the output of the pixel representation to a RGB pixel on
         * unsigned char to be displayed on screen. Values are contrained to
         * 0-255 with a transfer function and a clamping operation.
         * If the pixel representation gives one band, the image is displayed
         * on grey level
         * If it gives 3 bands, it is interpreted as Red, Green and Blue
         * If there is a fourth band, it is considered as the alpha channel
         * and is not scaled.
         */
        virtual OutputPixelType EvaluateTransferFunction(const InternalPixelType &  spixel) const
        {
          if ((spixel.Size() != 1) && (spixel.Size() != 3) && (spixel.Size() != 4))
          {
            itkExceptionMacro( << "the PixelRepresentation function should give an output of "
                               << "size 1, 3 or 4 otherwise I don't know how to make an RGB of it !" );
          }

          OutputPixelType output(SCREEN_COLOR_MAX_VALUE);

          if (spixel.Size() == 1)
          {
            OutputValueType value = ClippedValue(this->m_TransferFunction(spixel[0]));
            output[0] = value;
            output[1] = value;
            output[2] = value;
          }
          else
          {
            output[0] = ClippedValue(this->m_TransferFunction(spixel[0]));
            output[1] = ClippedValue(this->m_TransferFunction(spixel[1]));
            output[2] = ClippedValue(this->m_TransferFunction(spixel[2]));
          }

{'fraction_non_alphanumeric': 0.09884052461509218, 'fraction_numerical': 0.00551226002661091, 'mean_word_length': 2.489058355437666, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2488754', 'n_tokens_mistral': 2677, 'n_tokens_neox': 2530, 'n_words': 740}