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

  Program:   Visualization Toolkit
  Module:    vtkMultisenseSource.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 "vtkMultisenseSource.h"


#include "vtkPolyData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkSmartPointer.h"
#include "vtkNew.h"
#include "vtkDoubleArray.h"
#include "vtkTransform.h"
#include "vtkMatrix4x4.h"
#include "vtkMath.h"

#include <boost/thread/thread.hpp>

#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 <sys/select.h>

#include <queue>
#include <deque>

#include "vtkMultisenseUtils.h"

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

template<typename T>
class SynchronizedQueue
{
  public:

    SynchronizedQueue () :
      queue_(), mutex_(), cond_(), request_to_end_(false), enqueue_data_(true) { }

    void
    enqueue (const T& data)
    {
      boost::unique_lock<boost::mutex> lock (mutex_);

      if (enqueue_data_)
      {
        queue_.push (data);
        cond_.notify_one ();
      }
    }

    bool
    dequeue (T& result)
    {
      boost::unique_lock<boost::mutex> lock (mutex_);

      while (queue_.empty () && (!request_to_end_))
      {
        cond_.wait (lock);
      }

      if (request_to_end_)
      {
        doEndActions ();
        return false;
      }

      result = queue_.front ();
      queue_.pop ();

      return true;
    }

    void
    stopQueue ()
    {
      boost::unique_lock<boost::mutex> lock (mutex_);
      request_to_end_ = true;
      cond_.notify_one ();
    }

    unsigned int
    size ()
    {
      boost::unique_lock<boost::mutex> lock (mutex_);
      return static_cast<unsigned int> (queue_.size ());
    }

    bool
    isEmpty () const
    {
      boost::unique_lock<boost::mutex> lock (mutex_);
      return (queue_.empty ());
    }

  private:
    void
    doEndActions ()
    {
      enqueue_data_ = false;

      while (!queue_.empty ())
      {
        queue_.pop ();
      }
    }

    std::queue<T> queue_;              // Use STL queue to store data
    mutable boost::mutex mutex_;       // The mutex to synchronise on
    boost::condition_variable cond_;   // The condition to wait for

    bool request_to_end_;
    bool enqueue_data_;
};


//----------------------------------------------------------------------------
class LCMListener
{
public:

  LCMListener()
  {
    this->ShouldStop = true;
    this->NewData = false;
    this->CurrentRevolution = 0;
    this->CurrentScanLine = 0;
    this->SplitAngle = 90;
    this->SplitRange = 180;
    this->LastOffsetSpindleAngle = 0;
    this->MaxNumberOfScanLines = 10000;
    this->botparam_ = 0;
    this->botframes_ = 0;

    this->DistanceRange[0] = 0.0;
    this->DistanceRange[1] = 30.0;
    this->EdgeDistanceThreshold = 0.03;
<commit_msg>change default sweep split angle<commit_after>/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkMultisenseSource.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 "vtkMultisenseSource.h"


#include "vtkPolyData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkSmartPointer.h"
#include "vtkNew.h"
#include "vtkDoubleArray.h"
#include "vtkTransform.h"
#include "vtkMatrix4x4.h"
#include "vtkMath.h"

#include <boost/thread/thread.hpp>

#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 <sys/select.h>

#include <queue>
#include <deque>

#include "vtkMultisenseUtils.h"

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

template<typename T>
class SynchronizedQueue
{
  public:

    SynchronizedQueue () :
      queue_(), mutex_(), cond_(), request_to_end_(false), enqueue_data_(true) { }

    void
    enqueue (const T& data)
    {
      boost::unique_lock<boost::mutex> lock (mutex_);

      if (enqueue_data_)
      {
        queue_.push (data);
        cond_.notify_one ();
      }
    }

    bool
    dequeue (T& result)
    {
      boost::unique_lock<boost::mutex> lock (mutex_);

      while (queue_.empty () && (!request_to_end_))
      {
        cond_.wait (lock);
      }

      if (request_to_end_)
      {
        doEndActions ();
        return false;
      }

      result = queue_.front ();
      queue_.pop ();

      return true;
    }

    void
    stopQueue ()
    {
      boost::unique_lock<boost::mutex> lock (mutex_);
      request_to_end_ = true;
      cond_.notify_one ();
    }

    unsigned int
    size ()
    {
      boost::unique_lock<boost::mutex> lock (mutex_);
      return static_cast<unsigned int> (queue_.size ());
    }

    bool
    isEmpty () const
    {
      boost::unique_lock<boost::mutex> lock (mutex_);
      return (queue_.empty ());
    }

  private:
    void
    doEndActions ()
    {
      enqueue_data_ = false;

      while (!queue_.empty ())
      {
        queue_.pop ();
      }
    }

    std::queue<T> queue_;              // Use STL queue to store data
    mutable boost::mutex mutex_;       // The mutex to synchronise on
    boost::condition_variable cond_;   // The condition to wait for

    bool request_to_end_;
    bool enqueue_data_;
};


//----------------------------------------------------------------------------
class LCMListener
{
public:

  LCMListener()
  {
    this->ShouldStop = true;
    this->NewData = false;
    this->CurrentRevolution = 0;
    this->CurrentScanLine = 0;
    this->SplitAngle = 0;
    this->SplitRange = 180;
    this->LastOffsetSpindleAngle = 0;
    this->MaxNumberOfScanLines = 10000;
    this->botparam_ = 0;
    this->botframes_ = 0;

    this->DistanceRange[0] = 0.0;
    this->DistanceRange[1] = 30.0;
    this->EdgeDistanceThreshold = 0.03;

{'fraction_non_alphanumeric': 0.19896936730604065, 'fraction_numerical': 0.0075866017749785285, 'mean_word_length': 2.477849676455948, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 71, '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': '5904591', 'n_tokens_mistral': 2218, 'n_tokens_neox': 2118, 'n_words': 468}