32 if (s->matches_attribute(attribute))
return s;
35 throw std::runtime_error(
"unable to find attribute");
45 const std::shared_ptr<const operations::AttributeTransferStrategyBase>& other)
50 if (s->matches_attribute(attribute)) {
56 throw std::runtime_error(
"unable to find attribute");
60 const std::shared_ptr<const operations::AttributeTransferStrategyBase>& other)
62 spdlog::debug(
"Adding a transfer");
68 if (!
mesh().is_valid(simplex)) {
75 const auto simplex_resurrect = simplex;
82 auto mods =
execute(simplex_resurrect);
85 if (
after(unmods, mods)) {
89 }
catch (
const std::exception& e) {
107 if (
mesh().is_removed(simplex.
tuple()) || !
mesh().is_valid(simplex)) {
111 const auto simplex_resurrect = simplex;
116 if (&invariant_mesh == &
mesh()) {
122 const std::vector<simplex::Simplex> invariant_simplices =
123 m_mesh.
map(invariant_mesh, simplex_resurrect);
136 const std::vector<simplex::Simplex>& unmods,
137 const std::vector<simplex::Simplex>& mods)
const
152 for (
const auto& s : direct_mods) {
153 if (!s.tuple().is_null()) {
159 if (direct_mods.size() > 1) {
164 if (&
m_mesh == &(at_ptr->mesh())) {
166 if (s.primitive_type() == at_ptr->primitive_type()) {
171 auto& at_mesh = at_ptr->mesh();
172 auto at_mesh_simplices =
m_mesh.
map(at_mesh, direct_mods);
184 if (s.primitive_type() == at_ptr->primitive_type()) {
185 at_ptr->run(at_mesh.get_simplex(s));
196 constexpr
static int64_t default_preallocation_size = 3;
198 auto run = [&](
auto&& m) {
199 if constexpr (!std::is_const_v<std::remove_reference_t<decltype(m)>>) {
200 auto cap = m.m_attribute_manager.m_capacities;
201 for (
auto& v : cap) {
202 v *= default_preallocation_size;
204 m.reserve_more_attributes(cap);
simplex::Simplex get_simplex(const simplex::IdSimplex &s) const
Convert an IdSimplex into a Simplex.
multimesh::attribute::AttributeScopeHandle create_scope()
std::vector< simplex::Simplex > map(const Mesh &other_mesh, const simplex::Simplex &my_simplex) const
maps a simplex from this mesh to any other mesh
bool is_same_mesh(const Mesh &) const
bool directly_modified_after(const std::vector< simplex::Simplex > &simplices_before, const std::vector< simplex::Simplex > &simplices_after) const override
bool before(const simplex::Simplex &t) const override
const Mesh & mesh() const
void execute_from_root(Mesh &mesh)
void set_transfer_strategy(const attribute::MeshAttributeHandle &attribute, const std::shared_ptr< const operations::AttributeTransferStrategyBase > &other)
virtual bool after(const std::vector< simplex::Simplex > &unmods, const std::vector< simplex::Simplex > &mods) const
const Mesh & mesh() const
virtual PrimitiveType primitive_type() const =0
void clear_attribute_transfer_strategies()
virtual std::vector< simplex::Simplex > execute(const simplex::Simplex &simplex)=0
returns an empty vector in case of failure
std::shared_ptr< const operations::AttributeTransferStrategyBase > get_transfer_strategy(const attribute::MeshAttributeHandle &attribute)
virtual void reserve_enough_simplices()
std::vector< std::shared_ptr< const operations::AttributeTransferStrategyBase > > m_attr_transfer_strategies
virtual std::vector< simplex::Simplex > operator()(const simplex::Simplex &simplex)
void add_transfer_strategy(const std::shared_ptr< const operations::AttributeTransferStrategyBase > &other)
virtual std::vector< simplex::Simplex > unmodified_primitives(const simplex::Simplex &simplex) const =0
Returns all simplices that will be potentially affected by the operation.
invariants::InvariantCollection m_invariants
virtual bool before(const simplex::Simplex &simplex) const
void apply_attribute_transfer(const std::vector< simplex::Simplex > &direct_mods)
void sort_and_clean()
Sort simplex vector and remove duplicates.
void add(const IdSimplex &simplex)
Add simplex to the collection.
void reserve(const size_t new_cap)
const std::vector< IdSimplex > & simplex_vector() const
Return const reference to the simplex vector.
const Tuple & tuple() const
PrimitiveType primitive_type() const
ClosedStarIterable closed_star_iterable(const Mesh &mesh, const Simplex &simplex)