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

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

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

  Portions of this code are covered under the VTK copyright.
  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.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 __vtkItkCellMultiVisitor_h
#define __vtkItkCellMultiVisitor_h

#include "vtkVertex.h"
#include "vtkLine.h"


#include "itkVertexCell.h"
#include "itkLineCell.h"




/**

  Implementation of the Multi Visitor Pattern

   */
template < typename TCellPixelType, typename TCellTraits >
class vtkItkCellMultiVisitor
{

  vtkCellArray* m_Cells;
  int* m_LastCell;
  int* m_TypeArray;

public:


  typedef TCellTraits                         CellTraits;
  typedef TCellPixelType                      CellPixelType;


  // typedef the itkCells we are interested in
  typedef itk::LineCell<CellPixelType,CellTraits>     LineCellType;
  typedef itk::VertexCell<CellPixelType,CellTraits>   VertexCellType;


  // Set the vtkCellArray that will be constructed
  void SetCellArray(vtkCellArray* a) 
    {
      m_Cells = a;
    }


  // Set the cell counter pointer
  void SetCellCounter(int* i)
    {
      m_LastCell = i;
    }


  // Set the type array for storing the vtk cell types
  void SetTypeArray(int* i)
    {
      m_TypeArray = i;
    }



  // Visit a vertex and create the VTK_VERTEX cell 
  void Visit(unsigned long cellId, VertexCellType * t)
    {
      m_Cells->InsertNextCell(1,  (vtkIdType*)t->PointIdsBegin());
      m_TypeArray[*m_LastCell] = VTK_VERTEX;
      (*m_LastCell)++;
    }


  // Visit a line and create the VTK_LINE cell 
  void Visit(unsigned long cellId, LineCellType * t)
    {
      m_Cells->InsertNextCell(2,  (vtkIdType*)t->PointIdsBegin());
      m_TypeArray[*m_LastCell] = VTK_LINE;
      (*m_LastCell)++;
    }

};
  


#endif
<commit_msg>ENH: Triangle cell case added.<commit_after>/*=========================================================================

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

  Copyright (c) 2002 Insight Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

  Portions of this code are covered under the VTK copyright.
  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.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 __vtkItkCellMultiVisitor_h
#define __vtkItkCellMultiVisitor_h

#include "vtkVertex.h"
#include "vtkLine.h"
#include "vtkTriangle.h"


#include "itkVertexCell.h"
#include "itkLineCell.h"
#include "itkTriangleCell.h"




/**

  Implementation of the Multi Visitor Pattern

   */
template < typename TCellPixelType, typename TCellTraits >
class vtkItkCellMultiVisitor
{

  vtkCellArray* m_Cells;
  int* m_LastCell;
  int* m_TypeArray;

public:


  typedef TCellTraits                         CellTraits;
  typedef TCellPixelType                      CellPixelType;


  // typedef the itkCells we are interested in
  typedef itk::VertexCell<CellPixelType,CellTraits>     VertexCellType;
  typedef itk::LineCell<CellPixelType,CellTraits>       LineCellType;
  typedef itk::TriangleCell<CellPixelType,CellTraits>   TriangleCellType;


  // Set the vtkCellArray that will be constructed
  void SetCellArray(vtkCellArray* a) 
    {
      m_Cells = a;
    }


  // Set the cell counter pointer
  void SetCellCounter(int* i)
    {
      m_LastCell = i;
    }


  // Set the type array for storing the vtk cell types
  void SetTypeArray(int* i)
    {
      m_TypeArray = i;
    }



  // Visit a vertex and create the VTK_VERTEX cell 
  void Visit(unsigned long cellId, VertexCellType * t)
    {
      m_Cells->InsertNextCell(1,  (vtkIdType*)t->PointIdsBegin());
      m_TypeArray[*m_LastCell] = VTK_VERTEX;
      (*m_LastCell)++;
    }


  // Visit a line and create the VTK_LINE cell 
  void Visit(unsigned long cellId, LineCellType * t)
    {
      m_Cells->InsertNextCell(2,  (vtkIdType*)t->PointIdsBegin());
      m_TypeArray[*m_LastCell] = VTK_LINE;
      (*m_LastCell)++;
    }

  // Visit a line and create the VTK_TRIANGLE cell 
  void Visit(unsigned long cellId, TriangleCellType * t)
    {
      m_Cells->InsertNextCell(2,  (vtkIdType*)t->PointIdsBegin());
      m_TypeArray[*m_LastCell] = VTK_TRIANGLE;
      (*m_LastCell)++;
    }


};
  


#endif

{'fraction_non_alphanumeric': 0.13865949683118878, 'fraction_numerical': 0.0024966391396197426, 'mean_word_length': 3.3581589958158995, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1187835', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1585, 'n_words': 428}