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

  Program:   Visualization Toolkit
  Module:    vtkReverseSense.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 1993-2002 <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 "vtkReverseSense.h"

#include "vtkDataArray.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"

vtkCxxRevisionMacro(vtkReverseSense, "1.26");
vtkStandardNewMacro(vtkReverseSense);

// Construct object so that behavior is to reverse cell ordering and
// leave normal orientation as is.
vtkReverseSense::vtkReverseSense()
{
  this->ReverseCells = 1;
  this->ReverseNormals = 0;
}

void vtkReverseSense::Execute()
{
  vtkPolyData *input= this->GetInput();
  vtkPolyData *output= this->GetOutput();
  vtkDataArray *normals=input->GetPointData()->GetNormals();
  vtkDataArray *cellNormals=input->GetCellData()->GetNormals();

  vtkDebugMacro(<<"Reversing sense of poly data");

  output->CopyStructure(input);
  output->GetPointData()->PassData(input->GetPointData());
  output->GetCellData()->PassData(input->GetCellData());

  //If specified, traverse all cells and reverse them
  int abort=0;
  vtkIdType progressInterval;
  
  if ( this->ReverseCells )
    {
    vtkIdType numCells=input->GetNumberOfCells();
    vtkCellArray *verts, *lines, *polys, *strips;

    //Instantiate necessary topology arrays
    verts = vtkCellArray::New();
    verts->DeepCopy(input->GetVerts());
    lines = vtkCellArray::New();
    lines->DeepCopy(input->GetLines());
    polys = vtkCellArray::New();
    polys->DeepCopy(input->GetPolys());
    strips = vtkCellArray::New();
    strips->DeepCopy(input->GetStrips());

    output->SetVerts(verts); verts->Delete();
    output->SetLines(lines); lines->Delete();
    output->SetPolys(polys);  polys->Delete();
    output->SetStrips(strips);  strips->Delete();

    progressInterval=numCells/10+1;
    for (vtkIdType cellId=0; cellId < numCells && !abort; cellId++ )
      {
      if ( ! (cellId % progressInterval) ) //manage progress / early abort
        {
        this->UpdateProgress (0.6*cellId/numCells);
        abort = this->GetAbortExecute();
        }
      output->ReverseCell(cellId);
      }
    }

  //If specified and normals available, reverse orientation of normals.
  // Using NewInstance() creates normals of the same data type.
  if ( this->ReverseNormals && normals )
    {
    //first do point normals
    vtkIdType numPoints=input->GetNumberOfPoints();
    vtkDataArray *outNormals=normals->NewInstance();
    outNormals->SetNumberOfComponents(outNormals->GetNumberOfComponents());
    outNormals->SetNumberOfTuples(numPoints);
    float n[3];

    progressInterval=numPoints/5+1;
    for ( int ptId=0; ptId < numPoints; ptId++ )
      {<commit_msg>ERR: wrong number of components for point normals.<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkReverseSense.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) 1993-2002 <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 "vtkReverseSense.h"

#include "vtkDataArray.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"

vtkCxxRevisionMacro(vtkReverseSense, "1.27");
vtkStandardNewMacro(vtkReverseSense);

// Construct object so that behavior is to reverse cell ordering and
// leave normal orientation as is.
vtkReverseSense::vtkReverseSense()
{
  this->ReverseCells = 1;
  this->ReverseNormals = 0;
}

void vtkReverseSense::Execute()
{
  vtkPolyData *input= this->GetInput();
  vtkPolyData *output= this->GetOutput();
  vtkDataArray *normals=input->GetPointData()->GetNormals();
  vtkDataArray *cellNormals=input->GetCellData()->GetNormals();

  vtkDebugMacro(<<"Reversing sense of poly data");

  output->CopyStructure(input);
  output->GetPointData()->PassData(input->GetPointData());
  output->GetCellData()->PassData(input->GetCellData());

  //If specified, traverse all cells and reverse them
  int abort=0;
  vtkIdType progressInterval;
  
  if ( this->ReverseCells )
    {
    vtkIdType numCells=input->GetNumberOfCells();
    vtkCellArray *verts, *lines, *polys, *strips;

    //Instantiate necessary topology arrays
    verts = vtkCellArray::New();
    verts->DeepCopy(input->GetVerts());
    lines = vtkCellArray::New();
    lines->DeepCopy(input->GetLines());
    polys = vtkCellArray::New();
    polys->DeepCopy(input->GetPolys());
    strips = vtkCellArray::New();
    strips->DeepCopy(input->GetStrips());

    output->SetVerts(verts); verts->Delete();
    output->SetLines(lines); lines->Delete();
    output->SetPolys(polys);  polys->Delete();
    output->SetStrips(strips);  strips->Delete();

    progressInterval=numCells/10+1;
    for (vtkIdType cellId=0; cellId < numCells && !abort; cellId++ )
      {
      if ( ! (cellId % progressInterval) ) //manage progress / early abort
        {
        this->UpdateProgress (0.6*cellId/numCells);
        abort = this->GetAbortExecute();
        }
      output->ReverseCell(cellId);
      }
    }

  //If specified and normals available, reverse orientation of normals.
  // Using NewInstance() creates normals of the same data type.
  if ( this->ReverseNormals && normals )
    {
    //first do point normals
    vtkIdType numPoints=input->GetNumberOfPoints();
    vtkDataArray *outNormals=normals->NewInstance();
    outNormals->SetNumberOfComponents(normals->GetNumberOfComponents());
    outNormals->SetNumberOfTuples(numPoints);
    float n[3];

    progressInterval=numPoints/5+1;
    for ( int ptId=0; ptId < numPoints; ptId++ )
      {
{'fraction_non_alphanumeric': 0.17235976183014728, 'fraction_numerical': 0.007521153243497336, 'mean_word_length': 4.176804541768045, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 93, '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': '7458702', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1946, 'n_words': 431}