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

  Program:   Visualization Toolkit
  Module:    vtkPlotPie.cxx

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/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 notice for more information.

=========================================================================*/

#include "vtkPlotPie.h"

#include "vtkContext2D.h"
#include "vtkBrush.h"
#include "vtkColorSeries.h"
#include "vtkPoints2D.h"
#include "vtkContextMapper2D.h"
#include "vtkTable.h"
#include "vtkMath.h"

#include "vtkObjectFactory.h"

#include "vtkstd/algorithm"

namespace {

template<class A>
A SumData(A *a, int n)
{
  A sum = 0;
  for (int i = 0; i < n; ++i)
    {
    sum += a[i];
    }
  return sum;
}

template<class A>
void CopyToPoints(vtkPoints2D *points, A *a, int n)
{
  points->SetNumberOfPoints(n);

  A sum = SumData(a,n);
  float* data = static_cast<float*>(points->GetVoidPointer(0));
  float startAngle = 0.0;

  for (int i = 0; i < n; ++i)
    {
    data[2*i] = startAngle;
    data[2*i+1] = startAngle + ((static_cast<float>(a[i]) / sum) * 360.0);
    startAngle = data[2*i+1];
    }
}
}

class vtkPlotPiePrivate
{
  public:
    vtkPlotPiePrivate()
      {
      this->CenterX = 0;
      this->CenterY = 0;
      this->Radius  = 0;
      }

  float CenterX;
  float CenterY;
  float Radius;
};

//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotPie);

//-----------------------------------------------------------------------------
vtkPlotPie::vtkPlotPie()
{
  this->ColorSeries = vtkSmartPointer<vtkColorSeries>::New();
  this->Points = 0;
  this->Private = new vtkPlotPiePrivate();
  this->Dimensions[0] = this->Dimensions[0] = this->Dimensions[0] =
    this->Dimensions[0] = 0;
}
<commit_msg>BUG: Corrected typo in variable initialization.<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkPlotPie.cxx

  Copyright (c) <NAME>, <NAME>, <NAME>
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/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 notice for more information.

=========================================================================*/

#include "vtkPlotPie.h"

#include "vtkContext2D.h"
#include "vtkBrush.h"
#include "vtkColorSeries.h"
#include "vtkPoints2D.h"
#include "vtkContextMapper2D.h"
#include "vtkTable.h"
#include "vtkMath.h"

#include "vtkObjectFactory.h"

#include "vtkstd/algorithm"

namespace {

template<class A>
A SumData(A *a, int n)
{
  A sum = 0;
  for (int i = 0; i < n; ++i)
    {
    sum += a[i];
    }
  return sum;
}

template<class A>
void CopyToPoints(vtkPoints2D *points, A *a, int n)
{
  points->SetNumberOfPoints(n);

  A sum = SumData(a,n);
  float* data = static_cast<float*>(points->GetVoidPointer(0));
  float startAngle = 0.0;

  for (int i = 0; i < n; ++i)
    {
    data[2*i] = startAngle;
    data[2*i+1] = startAngle + ((static_cast<float>(a[i]) / sum) * 360.0);
    startAngle = data[2*i+1];
    }
}
}

class vtkPlotPiePrivate
{
  public:
    vtkPlotPiePrivate()
      {
      this->CenterX = 0;
      this->CenterY = 0;
      this->Radius  = 0;
      }

  float CenterX;
  float CenterY;
  float Radius;
};

//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotPie);

//-----------------------------------------------------------------------------
vtkPlotPie::vtkPlotPie()
{
  this->ColorSeries = vtkSmartPointer<vtkColorSeries>::New();
  this->Points = 0;
  this->Private = new vtkPlotPiePrivate();
  this->Dimensions[0] = this->Dimensions[1] = this->Dimensions[2] =
    this->Dimensions[3] = 0;
}

{'fraction_non_alphanumeric': 0.26850507982583455, 'fraction_numerical': 0.013546202225447508, 'mean_word_length': 2.7556766575840146, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4586006', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1346, 'n_words': 315}