Wildmeshing Toolkit
AndOperationSequence.cpp
Go to the documentation of this file.
2 
3 
4 namespace wmtk::operations {
5 
6 
8  Mesh& mesh,
9  const std::vector<std::shared_ptr<Operation>>& operations)
10  : OperationSequence(mesh, operations)
11 {}
12 
14 
15 std::vector<simplex::Simplex> AndOperationSequence::execute_operations(
16  const simplex::Simplex& simplex)
17 {
18  assert(!m_operations.empty());
19 
20  std::vector<simplex::Simplex> queue;
21  queue.push_back(simplex);
22  for (int64_t i = 0; i < m_operations.size(); ++i) {
23  auto& o = m_operations[i];
24  // assert(queue.size() == 1);
25 
26  auto tuple_resurrected = queue.front().tuple();
27 
28  const auto new_queue =
29  (*o)(simplex::Simplex(mesh(), o->primitive_type(), tuple_resurrected));
30  if (new_queue.empty()) return i == 0 ? std::vector<simplex::Simplex>() : queue;
31 
32  queue = new_queue;
33  }
34 
35  return queue;
36 }
37 
38 
39 } // namespace wmtk::operations
AndOperationSequence(Mesh &mesh, const std::vector< std::shared_ptr< Operation >> &operations={})
std::vector< simplex::Simplex > execute_operations(const simplex::Simplex &simplex) override
const Mesh & mesh() const
Definition: Operation.hpp:45
std::vector< std::shared_ptr< Operation > > m_operations