24 std::vector<MeshLib::Element*>
const& vec_src_eles,
25 std::vector<std::size_t>
const& vec_removed)
27 std::vector<MeshLib::Element*> vec_dest_eles(vec_src_eles.size() -
31 for (std::size_t i = 0; i < vec_removed[0]; ++i)
33 vec_dest_eles[cnt++] = vec_src_eles[i];
35 for (std::size_t i = 1; i < vec_removed.size(); ++i)
37 for (std::size_t j = vec_removed[i - 1] + 1; j < vec_removed[i]; ++j)
39 vec_dest_eles[cnt++] = vec_src_eles[j];
42 for (std::size_t i = vec_removed.back() + 1; i < vec_src_eles.size(); ++i)
44 vec_dest_eles[cnt++] = vec_src_eles[i];
54 const std::vector<std::size_t>& removed_element_ids,
55 const std::string& new_mesh_name)
57 if (removed_element_ids.empty())
59 INFO(
"No elements to remove");
63 INFO(
"Removing total {:d} elements...", removed_element_ids.size());
64 std::vector<MeshLib::Element*> tmp_elems =
66 INFO(
"{:d} elements remain in mesh.", tmp_elems.size());
69 std::vector<MeshLib::Node*> new_nodes =
71 std::vector<MeshLib::Element*> new_elems =
78 INFO(
"Removing total {:d} nodes...", removed_node_ids.size());
79 for (
auto nodeid : removed_node_ids)
81 delete new_nodes[nodeid];
82 new_nodes[nodeid] =
nullptr;
84 new_nodes.erase(std::remove(new_nodes.begin(), new_nodes.end(),
nullptr),
87 if (!new_elems.empty())
93 removed_element_ids, removed_node_ids));
97 INFO(
"Current selection removes all elements.");
102 std::vector<MeshLib::Element*>
const& elements,
103 std::vector<MeshLib::Node*>
const& nodes)
105 std::vector<bool> unused_nodes(nodes.size(),
true);
106 for (
auto e : elements)
108 for (
unsigned i = 0; i < e->getNumberOfNodes(); i++)
110 unused_nodes[getNodeIndex(*e, i)] =
false;
118 std::vector<MeshLib::Node*>& nodes)
120 assert(nodes_to_delete.size() == nodes.size());
122 for (std::size_t i = 0; i < nodes.size(); i++)
124 if (nodes_to_delete[i])
130 nodes.erase(remove(begin(nodes), end(nodes),
nullptr), end(nodes));
134 const std::vector<std::size_t>& del_nodes_idx,
135 const std::string& new_mesh_name)
137 if (del_nodes_idx.empty())
143 std::vector<MeshLib::Node*> new_nodes =
145 std::vector<MeshLib::Element*> new_elems =
152 for (
auto eid : removed_element_ids)
154 delete new_elems[eid];
155 new_elems[eid] =
nullptr;
157 new_elems.erase(std::remove(new_elems.begin(), new_elems.end(),
nullptr),
161 std::vector<bool>
const node_delete_flag =
167 if (!new_elems.empty())
173 removed_element_ids, del_nodes_idx));
Definition of Duplicate functions.
Definition of the Element class.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Node class.
const std::vector< std::size_t > & getSearchedElementIDs() const
return marked elements
std::size_t searchByNodeIDs(const std::vector< std::size_t > &nodes)
Marks all elements connecting to any of the given nodes.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Properties & getProperties()
std::size_t searchNodesConnectedToOnlyGivenElements(const std::vector< std::size_t > &elements)
const std::vector< std::size_t > & getSearchedNodeIDs() const
return marked node IDs
Properties excludeCopyProperties(std::vector< std::size_t > const &exclude_elem_ids, std::vector< std::size_t > const &exclude_node_ids) const
std::vector< Node * > copyNodeVector(const std::vector< Node * > &nodes)
Creates a deep copy of a Node vector.
std::vector< Element * > copyElementVector(std::vector< Element * > const &elements, std::vector< Node * > const &new_nodes, std::vector< std::size_t > const *const node_id_map)