Skip to content

Studio/src/Data/MeshWorkQueue.h

Provides concurrent access to a list of shapes to work needing reconstruction.

Namespaces

Name
shapeworks

Classes

Name
class shapeworks::MeshWorkItem
class shapeworks::MeshWorkQueue

Functions

Name
Q_DECLARE_METATYPE(shapeworks::MeshWorkItem )

Functions Documentation

function Q_DECLARE_METATYPE

Q_DECLARE_METATYPE(
    shapeworks::MeshWorkItem 
)

Source code

#pragma once

// stl
#include <list>

// qt
#include <QMutex>
#include <QMetaType>

// vnl
#include "vnl/vnl_vector.h"

#include <Eigen/Eigen>


namespace shapeworks {

class MeshWorkItem
{
public:
  std::string filename;
  Eigen::VectorXd points;
  int domain{0};

  size_t memory_size{0};

  friend bool operator<(const MeshWorkItem &a, const MeshWorkItem &b);

  friend bool operator==(const MeshWorkItem &a, const MeshWorkItem &b);
};


class MeshWorkQueue
{

public:

  using WorkList = std::list<MeshWorkItem>;

  MeshWorkQueue();
  ~MeshWorkQueue();

  void push(const MeshWorkItem &item);

  MeshWorkItem* get_next_work_item();

  bool is_inside(const MeshWorkItem &item);

  void remove(const MeshWorkItem &item);

  bool is_empty();

  int size();

private:

  bool in_inside_list(const MeshWorkItem &item, const WorkList& list);

  // for concurrent access
  QMutex mutex_;

  WorkList work_list_;

  WorkList processing_list_;
};
}

Q_DECLARE_METATYPE(shapeworks::MeshWorkItem);

Updated on 2022-07-23 at 17:50:05 -0600