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

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkShapeLabelObject.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 __itkShapeLabelObject_h
#define __itkShapeLabelObject_h

#include "itkLabelObject.h"
#include "itkLabelMap.h"
#include "itkAffineTransform.h"
#include "itkMatrix.h"

namespace itk
{
/** \class ShapeLabelObject
 *  \brief A Label object to store the common attributes related to the shape of the object
 *
 * ShapeLabelObject stores  the common attributes related to the shape of the object
 *
 * \author <NAME>. Biologie du Developpement et de la Reproduction, INRA de Jouy-en-Josas, France.
 *
 * This implementation was taken from the Insight Journal paper:
 * http://hdl.handle.net/1926/584  or
 * http://www.insight-journal.org/browse/publication/176
 *
 * \ingroup DataRepresentation
 */
template< class TLabel, unsigned int VImageDimension >
class ITK_EXPORT ShapeLabelObject:public LabelObject< TLabel, VImageDimension >
{
public:
  /** Standard class typedefs */
  typedef ShapeLabelObject                       Self;
  typedef LabelObject< TLabel, VImageDimension > Superclass;
  typedef typename Superclass::LabelObjectType   LabelObjectType;
  typedef SmartPointer< Self >                   Pointer;
  typedef SmartPointer< const Self >             ConstPointer;
  typedef WeakPointer< const Self >              ConstWeakPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(ShapeLabelObject, LabelObject);

  typedef LabelMap< Self > LabelMapType;

  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);

  typedef typename Superclass::IndexType IndexType;

  typedef TLabel LabelType;

  typedef typename Superclass::LineType LineType;

  typedef typename Superclass::LengthType LengthType;

  typedef typename Superclass::LineContainerType LineContainerType;

  typedef typename Superclass::AttributeType AttributeType;
  itkStaticConstMacro(SIZE, AttributeType, 100);
  itkStaticConstMacro(PHYSICAL_SIZE, AttributeType, 101);
  itkStaticConstMacro(REGION_ELONGATION, AttributeType, 102);
  itkStaticConstMacro(SIZE_REGION_RATIO, AttributeType, 103);
  itkStaticConstMacro(CENTROID, AttributeType, 104);
  itkStaticConstMacro(REGION, AttributeType, 105);
  itkStaticConstMacro(SIZE_ON_BORDER, AttributeType, 106);
  itkStaticConstMacro(PHYSICAL_SIZE_ON_BORDER, AttributeType, 107);
  itkStaticConstMacro(FERET_DIAMETER, AttributeType, 108);
  itkStaticConstMacro(BINARY_PRINCIPAL_MOMENTS, AttributeType, 109);
  itkStaticConstMacro(BINARY_PRINCIPAL_AXES, AttributeType, 110);
  itkStaticConstMacro(BINARY_ELONGATION, AttributeType, 111);
  itkStaticConstMacro(PERIMETER, AttributeType, 112);
  itkStaticConstMacro(ROUNDNESS, AttributeType, 113);
  itkStaticConstMacro(EQUIVALENT_RADIUS, AttributeType, 114);
  itkStaticConstMacro(EQUIVALENT_PERIMETER, AttributeType, 115);
  itkStaticConstMacro(EQUIVALENT_ELLIPSOID_RADIUS, AttributeType, 116);
  itkStaticConstMacro(BINARY_FLATNESS, AttributeType, 117);

  static AttributeType GetAttributeFromName(const std::string & s)
  {
    if ( s == "Size" )
      {
      return SIZE;
      }
    else if ( s == "PhysicalSize" )
      {
      return PHYSICAL_SIZE;
      }
    else if ( s == "RegionElongation" )
      {
      return REGION_ELONGATION;
      }
    else if ( s == "SizeRegionRatio" )
      {
      return SIZE_REGION_RATIO;
      }
    else if ( s == "Centroid" )
      {
      return CENTROID;
      }
    else if ( s == "Region" )
      {
      return REGION;
      }
    else if ( s == "SizeOnBorder" )
      {
      return SIZE_ON_BORDER;
      }
    else if ( s == "PhysicalSizeOnBorder" )
      {
      return PHYSICAL_SIZE_ON_BORDER;
      }
    else if ( s == "FeretDiameter" )
      {
      return FERET_DIAMETER;
      }
    else if ( s == "BinaryPrincipalMoments" )
      {
      return BINARY_PRINCIPAL_MOMENTS;
      }
    else if ( s == "BinaryPrincipalAxes" )
      {
      return BINARY_PRINCIPAL_AXES;
      }
    else if ( s == "BinaryElongation" )
      {
      return BINARY_ELONGATION;
      }
    else if ( s == "Perimeter" )
      {
      return PERIMETER;
      }
    else if ( s == "Roundness" )
      {
      return ROUNDNESS;
      }
    else if ( s == "EquivalentRadius" )
      {
      return EQUIVALENT_RADIUS;
      }
    else if ( s == "EquivalentPerimeter" )
      {
      return EQUIVALENT_PERIMETER;
      }
    else if ( s == "EquivalentEllipsoidSize" )
      {
      return EQUIVALENT_ELLIPSOID_RADIUS;
      }
    else if ( s == "BinaryFlatness" )
      {
      return BINARY_FLATNESS;
      }
    // can't recognize the name
    return Superclass::GetAttributeFromName(s);
  }

  static std::string GetNameFromAttribute(const AttributeType & a)
  {
    switch ( a )
      {
      case SIZE:
        return "Size";
        break;
      case PHYSICAL_SIZE:
        return "PhysicalSize";
        break;
      case REGION_ELONGATION:
        return "RegionElongation";
        break;
      case SIZE_REGION_RATIO:
        return "SizeRegionRatio";
        break;
      case CENTROID:
        return "Centroid";
      case REGION:
        return "Region";
        break;
      case SIZE_ON_BORDER:
        return "SizeOnBorder";
        break;
      case PHYSICAL_SIZE_ON_BORDER:
        return "PhysicalSizeOnBorder";
        break;
      case FERET_DIAMETER:
        return "FeretDiameter";<commit_msg>Switch was missing break for CENTROID.<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkShapeLabelObject.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 __itkShapeLabelObject_h
#define __itkShapeLabelObject_h

#include "itkLabelObject.h"
#include "itkLabelMap.h"
#include "itkAffineTransform.h"
#include "itkMatrix.h"

namespace itk
{
/** \class ShapeLabelObject
 *  \brief A Label object to store the common attributes related to the shape of the object
 *
 * ShapeLabelObject stores  the common attributes related to the shape of the object
 *
 * \author <NAME>. Biologie du Developpement et de la Reproduction, INRA de Jouy-en-Josas, France.
 *
 * This implementation was taken from the Insight Journal paper:
 * http://hdl.handle.net/1926/584  or
 * http://www.insight-journal.org/browse/publication/176
 *
 * \ingroup DataRepresentation
 */
template< class TLabel, unsigned int VImageDimension >
class ITK_EXPORT ShapeLabelObject:public LabelObject< TLabel, VImageDimension >
{
public:
  /** Standard class typedefs */
  typedef ShapeLabelObject                       Self;
  typedef LabelObject< TLabel, VImageDimension > Superclass;
  typedef typename Superclass::LabelObjectType   LabelObjectType;
  typedef SmartPointer< Self >                   Pointer;
  typedef SmartPointer< const Self >             ConstPointer;
  typedef WeakPointer< const Self >              ConstWeakPointer;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(ShapeLabelObject, LabelObject);

  typedef LabelMap< Self > LabelMapType;

  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);

  typedef typename Superclass::IndexType IndexType;

  typedef TLabel LabelType;

  typedef typename Superclass::LineType LineType;

  typedef typename Superclass::LengthType LengthType;

  typedef typename Superclass::LineContainerType LineContainerType;

  typedef typename Superclass::AttributeType AttributeType;
  itkStaticConstMacro(SIZE, AttributeType, 100);
  itkStaticConstMacro(PHYSICAL_SIZE, AttributeType, 101);
  itkStaticConstMacro(REGION_ELONGATION, AttributeType, 102);
  itkStaticConstMacro(SIZE_REGION_RATIO, AttributeType, 103);
  itkStaticConstMacro(CENTROID, AttributeType, 104);
  itkStaticConstMacro(REGION, AttributeType, 105);
  itkStaticConstMacro(SIZE_ON_BORDER, AttributeType, 106);
  itkStaticConstMacro(PHYSICAL_SIZE_ON_BORDER, AttributeType, 107);
  itkStaticConstMacro(FERET_DIAMETER, AttributeType, 108);
  itkStaticConstMacro(BINARY_PRINCIPAL_MOMENTS, AttributeType, 109);
  itkStaticConstMacro(BINARY_PRINCIPAL_AXES, AttributeType, 110);
  itkStaticConstMacro(BINARY_ELONGATION, AttributeType, 111);
  itkStaticConstMacro(PERIMETER, AttributeType, 112);
  itkStaticConstMacro(ROUNDNESS, AttributeType, 113);
  itkStaticConstMacro(EQUIVALENT_RADIUS, AttributeType, 114);
  itkStaticConstMacro(EQUIVALENT_PERIMETER, AttributeType, 115);
  itkStaticConstMacro(EQUIVALENT_ELLIPSOID_RADIUS, AttributeType, 116);
  itkStaticConstMacro(BINARY_FLATNESS, AttributeType, 117);

  static AttributeType GetAttributeFromName(const std::string & s)
  {
    if ( s == "Size" )
      {
      return SIZE;
      }
    else if ( s == "PhysicalSize" )
      {
      return PHYSICAL_SIZE;
      }
    else if ( s == "RegionElongation" )
      {
      return REGION_ELONGATION;
      }
    else if ( s == "SizeRegionRatio" )
      {
      return SIZE_REGION_RATIO;
      }
    else if ( s == "Centroid" )
      {
      return CENTROID;
      }
    else if ( s == "Region" )
      {
      return REGION;
      }
    else if ( s == "SizeOnBorder" )
      {
      return SIZE_ON_BORDER;
      }
    else if ( s == "PhysicalSizeOnBorder" )
      {
      return PHYSICAL_SIZE_ON_BORDER;
      }
    else if ( s == "FeretDiameter" )
      {
      return FERET_DIAMETER;
      }
    else if ( s == "BinaryPrincipalMoments" )
      {
      return BINARY_PRINCIPAL_MOMENTS;
      }
    else if ( s == "BinaryPrincipalAxes" )
      {
      return BINARY_PRINCIPAL_AXES;
      }
    else if ( s == "BinaryElongation" )
      {
      return BINARY_ELONGATION;
      }
    else if ( s == "Perimeter" )
      {
      return PERIMETER;
      }
    else if ( s == "Roundness" )
      {
      return ROUNDNESS;
      }
    else if ( s == "EquivalentRadius" )
      {
      return EQUIVALENT_RADIUS;
      }
    else if ( s == "EquivalentPerimeter" )
      {
      return EQUIVALENT_PERIMETER;
      }
    else if ( s == "EquivalentEllipsoidSize" )
      {
      return EQUIVALENT_ELLIPSOID_RADIUS;
      }
    else if ( s == "BinaryFlatness" )
      {
      return BINARY_FLATNESS;
      }
    // can't recognize the name
    return Superclass::GetAttributeFromName(s);
  }

  static std::string GetNameFromAttribute(const AttributeType & a)
  {
    switch ( a )
      {
      case SIZE:
        return "Size";
        break;
      case PHYSICAL_SIZE:
        return "PhysicalSize";
        break;
      case REGION_ELONGATION:
        return "RegionElongation";
        break;
      case SIZE_REGION_RATIO:
        return "SizeRegionRatio";
        break;
      case CENTROID:
        return "Centroid";
        break;
      case REGION:
        return "Region";
        break;
      case SIZE_ON_BORDER:
        return "SizeOnBorder";
        break;
      case PHYSICAL_SIZE_ON_BORDER:
        return "PhysicalSizeOnBorder";
        break;
      case FERET_DIAMETER:
        return "FeretDiameter";
{'fraction_non_alphanumeric': 0.10662251655629139, 'fraction_numerical': 0.010596026490066225, 'mean_word_length': 3.1601239669421486, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '225307', 'n_tokens_mistral': 3915, 'n_tokens_neox': 3696, 'n_words': 881}