Wildmeshing Toolkit
OperationSequence.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Operation.hpp"
4 
5 #include <wmtk/Tuple.hpp>
6 
7 
8 namespace wmtk {
9 class Mesh;
10 
11 namespace operations {
12 
13 
15 {
16 public:
17  OperationSequence(Mesh& mesh, const std::vector<std::shared_ptr<Operation>>& operations = {});
18  virtual ~OperationSequence();
19 
20  // main entry point of the operator by the scheduler
21  std::vector<simplex::Simplex> operator()(const simplex::Simplex& simplex) override;
22 
23  double priority(const simplex::Simplex& simplex) const override
24  {
25  assert(!m_operations.empty());
26  return m_priority == nullptr ? m_operations.front()->priority(simplex)
27  : m_priority(simplex);
28  }
29 
30  bool use_random_priority() const override
31  {
32  assert(!m_operations.empty());
34 
35  return m_operations.front()->use_random_priority();
36  }
37 
38  bool& use_random_priority() override
39  {
40  assert(!m_operations.empty());
43  }
44 
45  PrimitiveType primitive_type() const override;
46  void reserve_enough_simplices() override;
47 
48  void add_operation(const std::shared_ptr<Operation>& op) { m_operations.push_back(op); }
49 
50 protected:
54  std::vector<simplex::Simplex> execute(const simplex::Simplex& simplex) override
55  {
56  throw std::runtime_error("This shoud never be called");
57  }
58 
62  std::vector<simplex::Simplex> unmodified_primitives(
63  const simplex::Simplex& simplex) const override
64  {
65  throw std::runtime_error("This shoud never be called");
66  }
67 
68  virtual std::vector<simplex::Simplex> execute_operations(const simplex::Simplex& simplex) = 0;
69 
70  std::vector<std::shared_ptr<Operation>> m_operations;
71 
72 private:
74 };
75 
76 } // namespace operations
77 } // namespace wmtk
const Mesh & mesh() const
Definition: Operation.hpp:45
virtual bool use_random_priority() const
Definition: Operation.hpp:40
std::function< double(const simplex::Simplex &)> m_priority
Definition: Operation.hpp:99
double priority(const simplex::Simplex &simplex) const override
void add_operation(const std::shared_ptr< Operation > &op)
std::vector< simplex::Simplex > operator()(const simplex::Simplex &simplex) override
PrimitiveType primitive_type() const override
std::vector< simplex::Simplex > execute(const simplex::Simplex &simplex) override
returns an empty vector in case of failure
std::vector< simplex::Simplex > unmodified_primitives(const simplex::Simplex &simplex) const override
Returns all simplices that will be potentially affected by the OperationSequence.
virtual std::vector< simplex::Simplex > execute_operations(const simplex::Simplex &simplex)=0
std::vector< std::shared_ptr< Operation > > m_operations
OperationSequence(Mesh &mesh, const std::vector< std::shared_ptr< Operation >> &operations={})
Definition: Accessor.hpp:6