<commit_before>#ifndef __vtkMultisenseUtils_h
#define __vtkMultisenseUtils_h


#include <cstdio>
#include <iostream>
#include <string>

#include <Eigen/Dense>
#include <boost/shared_ptr.hpp>

#include <lcm/lcm-cpp.hpp>

#include <bot_frames/bot_frames.h>
#include <bot_param/param_client.h>

#include <lcmtypes/bot_core.hpp>
#include <lcmtypes/multisense.hpp>



#include <vtkSmartPointer.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkFloatArray.h>
#include <vtkUnsignedIntArray.h>
#include <vtkIdTypeArray.h>
#include <vtkCellArray.h>
#include <vtkTimerLog.h>


//----------------------------------------------------------------------------
namespace
{


class ScanLineData
{
public:

  uint64_t Revolution;
  uint64_t ScanLineId;
  double SpindleAngle;
  Eigen::Isometry3d ScanToLocalStart;
  Eigen::Isometry3d ScanToLocalEnd;
  bot_core::planar_lidar_t msg;
};


class DataArrays
{
public:

  vtkSmartPointer<vtkPolyData> Dataset;

  vtkPoints* Points;
  vtkFloatArray* Intensity;
  vtkUnsignedIntArray* ScanLineId;
  vtkFloatArray* Azimuth;
  vtkFloatArray* SpindleAngle;
  vtkFloatArray* Distance;
  vtkUnsignedIntArray* Timestamp;
};

//----------------------------------------------------------------------------
vtkSmartPointer<vtkCellArray> NewVertexCells(vtkIdType numberOfVerts)
{
  vtkSmartPointer<vtkIdTypeArray> cells = vtkSmartPointer<vtkIdTypeArray>::New();
  cells->SetNumberOfValues(numberOfVerts*2);
  vtkIdType* ids = cells->GetPointer(0);
  for (vtkIdType i = 0; i < numberOfVerts; ++i)
    {
    ids[i*2] = 1;
    ids[i*2+1] = i;
    }

  vtkSmartPointer<vtkCellArray> cellArray = vtkSmartPointer<vtkCellArray>::New();
  cellArray->SetCells(numberOfVerts, cells.GetPointer());
  return cellArray;
}

//-----------------------------------------------------------------------------
DataArrays CreateData(vtkIdType numberOfPoints)
{
  vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();

  // points
  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
  points->SetDataTypeToFloat();
  points->Allocate(numberOfPoints);
  polyData->SetPoints(points.GetPointer());
  polyData->SetVerts(NewVertexCells(numberOfPoints));

  // intensity
  vtkSmartPointer<vtkFloatArray> intensity = vtkSmartPointer<vtkFloatArray>::New();
  intensity->SetName("intensity");
  intensity->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(intensity.GetPointer());

  // scan line id
  vtkSmartPointer<vtkUnsignedIntArray> scanLineId = vtkSmartPointer<vtkUnsignedIntArray>::New();
  scanLineId->SetName("scan_line_id");
  scanLineId->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(scanLineId.GetPointer());

  // azimuth
  vtkSmartPointer<vtkFloatArray> azimuth = vtkSmartPointer<vtkFloatArray>::New();
  azimuth->SetName("azimuth");
  azimuth->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(azimuth.GetPointer());

  // spindle angle
  vtkSmartPointer<vtkFloatArray> spindleAngle = vtkSmartPointer<vtkFloatArray>::New();
  spindleAngle->SetName("spindle_angle");
  spindleAngle->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(spindleAngle.GetPointer());

  // range
  vtkSmartPointer<vtkFloatArray> distance = vtkSmartPointer<vtkFloatArray>::New();
  distance->SetName("distance");
  distance->SetNumberOfTuples(numberOfPoints);
  polyData->GetPointData()->AddArray(distance.GetPointer());

  // timestamp
  vtkSmartPointer<vtkUnsignedIntArray> timestamp = vtkSmartPointer<vtkUnsignedIntArray>::New();<commit_msg>fix bug in array allocation<commit_after>#ifndef __vtkMultisenseUtils_h
#define __vtkMultisenseUtils_h


#include <cstdio>
#include <iostream>
#include <string>

#include <Eigen/Dense>
#include <boost/shared_ptr.hpp>

#include <lcm/lcm-cpp.hpp>

#include <bot_frames/bot_frames.h>
#include <bot_param/param_client.h>

#include <lcmtypes/bot_core.hpp>
#include <lcmtypes/multisense.hpp>



#include <vtkSmartPointer.h>
#include <vtkXMLPolyDataWriter.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkFloatArray.h>
#include <vtkUnsignedIntArray.h>
#include <vtkIdTypeArray.h>
#include <vtkCellArray.h>
#include <vtkTimerLog.h>


//----------------------------------------------------------------------------
namespace
{


class ScanLineData
{
public:

  uint64_t Revolution;
  uint64_t ScanLineId;
  double SpindleAngle;
  Eigen::Isometry3d ScanToLocalStart;
  Eigen::Isometry3d ScanToLocalEnd;
  bot_core::planar_lidar_t msg;
};


class DataArrays
{
public:

  vtkSmartPointer<vtkPolyData> Dataset;

  vtkPoints* Points;
  vtkFloatArray* Intensity;
  vtkUnsignedIntArray* ScanLineId;
  vtkFloatArray* Azimuth;
  vtkFloatArray* SpindleAngle;
  vtkFloatArray* Distance;
  vtkUnsignedIntArray* Timestamp;
};

//----------------------------------------------------------------------------
vtkSmartPointer<vtkCellArray> NewVertexCells(vtkIdType numberOfVerts)
{
  vtkSmartPointer<vtkIdTypeArray> cells = vtkSmartPointer<vtkIdTypeArray>::New();
  cells->SetNumberOfValues(numberOfVerts*2);
  vtkIdType* ids = cells->GetPointer(0);
  for (vtkIdType i = 0; i < numberOfVerts; ++i)
    {
    ids[i*2] = 1;
    ids[i*2+1] = i;
    }

  vtkSmartPointer<vtkCellArray> cellArray = vtkSmartPointer<vtkCellArray>::New();
  cellArray->SetCells(numberOfVerts, cells.GetPointer());
  return cellArray;
}

//-----------------------------------------------------------------------------
DataArrays CreateData(vtkIdType numberOfPoints)
{
  vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();

  // points
  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
  points->SetDataTypeToFloat();
  points->Allocate(numberOfPoints);
  polyData->SetPoints(points.GetPointer());
  polyData->SetVerts(NewVertexCells(numberOfPoints));

  // intensity
  vtkSmartPointer<vtkFloatArray> intensity = vtkSmartPointer<vtkFloatArray>::New();
  intensity->SetName("intensity");
  intensity->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(intensity.GetPointer());

  // scan line id
  vtkSmartPointer<vtkUnsignedIntArray> scanLineId = vtkSmartPointer<vtkUnsignedIntArray>::New();
  scanLineId->SetName("scan_line_id");
  scanLineId->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(scanLineId.GetPointer());

  // azimuth
  vtkSmartPointer<vtkFloatArray> azimuth = vtkSmartPointer<vtkFloatArray>::New();
  azimuth->SetName("azimuth");
  azimuth->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(azimuth.GetPointer());

  // spindle angle
  vtkSmartPointer<vtkFloatArray> spindleAngle = vtkSmartPointer<vtkFloatArray>::New();
  spindleAngle->SetName("spindle_angle");
  spindleAngle->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(spindleAngle.GetPointer());

  // range
  vtkSmartPointer<vtkFloatArray> distance = vtkSmartPointer<vtkFloatArray>::New();
  distance->SetName("distance");
  distance->Allocate(numberOfPoints);
  polyData->GetPointData()->AddArray(distance.GetPointer());

  // timestamp
  vtkSmartPointer<vtkUnsignedIntArray> timestamp = vtkSmartPointer<vtkUnsignedIntArray>::New();
{'fraction_non_alphanumeric': 0.18740442096482693, 'fraction_numerical': 0.0036146253301821214, 'mean_word_length': 4.445874337623013, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7645955', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2363, 'n_words': 329}