Skip to content

Libs/Analyze/MeshWorkQueue.h

Namespaces

Name
shapeworks
User usage reporting (telemetry)

Classes

Name
class shapeworks::MeshWorkItem
Provides concurrent access to a list of shapes to work needing reconstruction.
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 <QMetaType>
#include <QMutex>

// eigen
#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_;
};
}  // namespace shapeworks

Q_DECLARE_METATYPE(shapeworks::MeshWorkItem);

Updated on 2024-03-17 at 12:58:44 -0600