FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Geometry::MeshPartOperations< MeshType_ > Class Template Reference

Boolean operations on mesh parts. More...

#include <mesh_part_ops.hpp>

Static Public Member Functions

static MeshPartType meshpart_difference (const MeshPartType &left, const MeshPartType &right)
 Compute the difference of two meshparts. More...
 
template<typename AttributeFn_ >
static MeshPartType meshpart_intersection (const MeshPartType &left, const MeshPartType &right, const AttributeFn_ &attribute_merge)
 Compute the intersection of two meshparts. More...
 
static MeshPartType meshpart_symmetric_difference (const MeshPartType &left, const MeshPartType &right)
 Compute the symmetric difference of two meshparts. More...
 
template<typename AttributeFn_ >
static MeshPartType meshpart_union (const MeshPartType &left, const MeshPartType &right, const AttributeFn_ &attribute_merge)
 Compute the union of two meshparts. More...
 

Private Types

using AttributeDataType = typename MeshPartType::AttributeDataType
 Data types for meshpart attributes. More...
 
using AttributeSetType = typename MeshPartType::AttributeSetType
 AttributeSet type. More...
 
using IndexSetHolderType = IndexSetHolder< ShapeType >
 IndexSetHolder type. More...
 
using Join = Inner::DimVector< ShapeType, JoinEntry >
 JoinVecs for all dimensions. More...
 
using JoinEntry = Inner::JoinEntry
 Type for tracking relationships between meshpart entities. More...
 
using JoinVec = std::vector< JoinEntry >
 Collection of JoinEntries. More...
 
using MeshPartType = MeshPart< MeshType >
 Meshpart type. More...
 
using MeshType = MeshType_
 Mesh type underlying all mesh parts. More...
 
using ShapeType = typename MeshType::ShapeType
 Shape type. More...
 
using TargetSetHolderType = TargetSetHolder< ShapeType >
 TargetSetHolder type. More...
 

Static Private Member Functions

template<int dim_ = ShapeType::dimension>
static void build_target_set_holder (TargetSetHolderType &output_tsh, Join &join, const std::function< bool(const JoinEntry &)> &pred, const TargetSetHolderType &left_tsh, const TargetSetHolderType &right_tsh)
 Construct target sets out of the join. More...
 
template<int dim_ = ShapeType::dimension>
static void build_topology (IndexSetHolderType &output_ish, Join &join, const IndexSetHolderType &left_ish, const TargetSetHolderType &left_tsh, const IndexSetHolderType &right_ish, const TargetSetHolderType &right_tsh)
 Outer wrapper for topology construction. More...
 
template<int dim_, int codim_>
static void build_topology_inner (IndexSetHolderType &output_ish, Join &join, const IndexSetHolderType &left_ish, const TargetSetHolderType &left_tsh, const IndexSetHolderType &right_ish, const TargetSetHolderType &right_tsh)
 Inner logc for topology construction. More...
 
static std::set< Stringcommon_attributes (const MeshPartType &left, const MeshPartType &right)
 Find common attributes of two meshparts. More...
 
template<typename AttributeFn_ >
static void copy_attributes (const AttributeFn_ &fn, const Join &join, MeshPartType &result, const MeshPartType &left, const MeshPartType &right)
 Attribute copy logic. More...
 
template<int dim_ = ShapeType::dimension>
static void join_elements (Join &join, const TargetSetHolderType &left_tsh, const TargetSetHolderType &right_tsh)
 Construct a join of entities. More...
 
template<typename AttributeFn_ , typename PredFn_ >
static MeshPartType meshpart_op (const MeshPartType &left, const MeshPartType &right, const AttributeFn_ &attribute_merge, const PredFn_ &join_pred, const bool create_topology)
 Common logic for all meshpart operations. More...
 
template<typename Iter_ , typename T_ >
static std::optional< Indexsearch (Iter_ begin, Iter_ end, const T_ &value)
 Binary search. More...
 
template<typename Iter_ , typename T_ , typename CompFn_ >
static std::optional< Indexsearch (Iter_ begin, Iter_ end, const T_ &value, const CompFn_ &fn)
 Binary search. More...
 

Detailed Description

template<typename MeshType_>
class FEAT::Geometry::MeshPartOperations< MeshType_ >

Boolean operations on mesh parts.

Template Parameters
MeshType_The type of the mesh underlying the meshparts, i.e. this class template can operate on meshparts of type MeshPart<MeshType_>.

Available operations are:

  • intersections
  • union
  • difference
  • symmetric difference

This class template serves as a common namespace for boolean operations on meshparts. The operations are essentially free functions, this template is just for convenience to store common type aliases.

Author
Markus Muegge

Definition at line 187 of file mesh_part_ops.hpp.

Member Typedef Documentation

◆ AttributeDataType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::AttributeDataType = typename MeshPartType::AttributeDataType
private

Data types for meshpart attributes.

Definition at line 200 of file mesh_part_ops.hpp.

◆ AttributeSetType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::AttributeSetType = typename MeshPartType::AttributeSetType
private

AttributeSet type.

Definition at line 203 of file mesh_part_ops.hpp.

◆ IndexSetHolderType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::IndexSetHolderType = IndexSetHolder<ShapeType>
private

IndexSetHolder type.

Definition at line 218 of file mesh_part_ops.hpp.

◆ Join

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::Join = Inner::DimVector<ShapeType, JoinEntry>
private

JoinVecs for all dimensions.

Definition at line 212 of file mesh_part_ops.hpp.

◆ JoinEntry

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::JoinEntry = Inner::JoinEntry
private

Type for tracking relationships between meshpart entities.

Definition at line 206 of file mesh_part_ops.hpp.

◆ JoinVec

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::JoinVec = std::vector<JoinEntry>
private

Collection of JoinEntries.

Definition at line 209 of file mesh_part_ops.hpp.

◆ MeshPartType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::MeshPartType = MeshPart<MeshType>
private

Meshpart type.

Definition at line 197 of file mesh_part_ops.hpp.

◆ MeshType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::MeshType = MeshType_
private

Mesh type underlying all mesh parts.

Definition at line 191 of file mesh_part_ops.hpp.

◆ ShapeType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::ShapeType = typename MeshType::ShapeType
private

Shape type.

Definition at line 194 of file mesh_part_ops.hpp.

◆ TargetSetHolderType

template<typename MeshType_ >
using FEAT::Geometry::MeshPartOperations< MeshType_ >::TargetSetHolderType = TargetSetHolder<ShapeType>
private

TargetSetHolder type.

Definition at line 215 of file mesh_part_ops.hpp.

Member Function Documentation

◆ build_target_set_holder()

template<typename MeshType_ >
template<int dim_ = ShapeType::dimension>
static void FEAT::Geometry::MeshPartOperations< MeshType_ >::build_target_set_holder ( TargetSetHolderType output_tsh,
Join join,
const std::function< bool(const JoinEntry &)> &  pred,
const TargetSetHolderType left_tsh,
const TargetSetHolderType right_tsh 
)
inlinestaticprivate

Construct target sets out of the join.

Template Parameters
dim_Current dimension
Parameters
[in,out]output_tshOutput target set holder. Target sets are written to this.
[in,out]joinEntity join. For entities that are part of the result meshpart, target set indices are added to the join.
[in]predJoin predicate
[in]left_tshLeft target set holder
[in]right_tshRight target set holder

This function walks over the join and uses the join predicate to determine what entities should be added to the result meshpart. If it finds an entity that should be added, it pulls the correct mesh-index from the left or right target set.

Definition at line 795 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::build_target_set_holder(), and XABORTM.

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::build_target_set_holder(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op().

◆ build_topology()

template<typename MeshType_ >
template<int dim_ = ShapeType::dimension>
static void FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology ( IndexSetHolderType output_ish,
Join join,
const IndexSetHolderType left_ish,
const TargetSetHolderType left_tsh,
const IndexSetHolderType right_ish,
const TargetSetHolderType right_tsh 
)
inlinestaticprivate

Outer wrapper for topology construction.

Template Parameters
dim_Current dimension
Parameters
[in,out]output_ishOutput index set holder
[in]joinEntity join. Used to determine where to pull topology from
[in]left_ishLeft index set holder
[in]left_tshLeft target set holder
[in]right_ishRight index set holder
[in]right_tshRight target set holder

In order to build the topology of the result meshpart, each apair of dimension needs to be visited. This wrapper recursively runs through the b dimensions.

Definition at line 600 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology_inner().

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op().

◆ build_topology_inner()

template<typename MeshType_ >
template<int dim_, int codim_>
static void FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology_inner ( IndexSetHolderType output_ish,
Join join,
const IndexSetHolderType left_ish,
const TargetSetHolderType left_tsh,
const IndexSetHolderType right_ish,
const TargetSetHolderType right_tsh 
)
inlinestaticprivate

Inner logc for topology construction.

Template Parameters
diim_Current "cell" dimension
codim_Current "face" dimension
Parameters
[in,out]output_ishOutput index set holder
[in]joinEntity join. Used to determine where to pull topology from
[in]left_ishLeft index set holder
[in]left_tshLeft target set holder
[in]right_ishRight index set holder
[in]right_tshRight target set holder

In order to build the topology of the result meshpart, each apair of dimension needs to be visited. This wrapper recursively runs through the a dimensions and constructs the actual topologies.

Definition at line 637 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology_inner(), FEAT::Geometry::Inner::JoinEntry::index, FEAT::Geometry::MeshPartOperations< MeshType_ >::search(), and XASSERT.

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology_inner().

◆ common_attributes()

template<typename MeshType_ >
static std::set< String > FEAT::Geometry::MeshPartOperations< MeshType_ >::common_attributes ( const MeshPartType left,
const MeshPartType right 
)
inlinestaticprivate

Find common attributes of two meshparts.

Parameters
[in]leftLeft meshpart
[in]rightRight meshpart
Returns
Set of all attributes that occur in both meshparts with the same name and dimension

Definition at line 486 of file mesh_part_ops.hpp.

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::copy_attributes().

◆ copy_attributes()

template<typename MeshType_ >
template<typename AttributeFn_ >
static void FEAT::Geometry::MeshPartOperations< MeshType_ >::copy_attributes ( const AttributeFn_ &  fn,
const Join join,
MeshPartType result,
const MeshPartType left,
const MeshPartType right 
)
inlinestaticprivate

Attribute copy logic.

Template Parameters
AttributeFn_Type of attribute merge function
Parameters
[in]fnAttribute merge function instance
[in]joinEntity join. Used to determine where to pull attribute values from
[in,out]resultThe result meshpart. Attributes will be added to this meshpart.
[in]leftLeft meshpart of operation
[in]rightRight meshpart of operation

Copies, and merges (if required), attributes that exist with the same dimension on both left and right.

Definition at line 517 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPart< MeshType_ >::add_attribute(), FEAT::Geometry::MeshPartOperations< MeshType_ >::common_attributes(), FEAT::Geometry::MeshPart< MeshType_ >::get_num_entities(), and XABORTM.

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op().

◆ join_elements()

template<typename MeshType_ >
template<int dim_ = ShapeType::dimension>
static void FEAT::Geometry::MeshPartOperations< MeshType_ >::join_elements ( Join join,
const TargetSetHolderType left_tsh,
const TargetSetHolderType right_tsh 
)
inlinestaticprivate

Construct a join of entities.

Template Parameters
dim_Current dimension
Parameters
[in,out]joinJoin to write to
[in]left_tshLeft target set holder
[in]right_tshRight target set holder

This function construct the entity join. The join tracks which entities of the left and right meshparts correspond to the same mesh entity, (and later also to which entity of the result meshpart). This is calculated for all entities, which allows implementing the different boolean operations via a simple predicate later.

Definition at line 872 of file mesh_part_ops.hpp.

References FEAT::Geometry::TargetSet::get_indices(), FEAT::Geometry::TargetSet::get_num_entities(), FEAT::Geometry::MeshPartOperations< MeshType_ >::join_elements(), FEAT::Geometry::Inner::JoinEntry::left, FEAT::Geometry::Inner::JoinEntry::right, and FEAT::Geometry::MeshPartOperations< MeshType_ >::search().

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::join_elements(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op().

◆ meshpart_difference()

template<typename MeshType_ >
static MeshPartType FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_difference ( const MeshPartType left,
const MeshPartType right 
)
inlinestatic

Compute the difference of two meshparts.

Parameters
[in]leftLefthand-side of difference
[in]rightRighthand-side of difference

Computes a new meshpart that contains all entities that occur in left but not in right.

Assume the following 2D mesh with quads A, B, C.

*  +--------+--------+--------+
*  |        |        |        |
*  |   A    |   B    |   C    |
*  |        |        |        |
*  +--------+--------+--------+
* 

Further assume that left is a meshpart consisting of the quads A, B and all their vertices and edges and that right is a meshpart consisting of quad B and all its vertices and edges. Then the difference of left and right consists of the quad A, the leftmost two vertices of the mesh, the leftmost edge of the mesh, and the top and bottom edges of A. Note that the right edge of A is not part of the result meshpart, as it is an entity of right and has as such been removed.

This function does not support mesparts with topology.

This function supports meshparts with attributes. If both left and right contain an attribute with the same name and dimension, then an attribute with the same name and dimension will be created on the result meshpart. Values will be copied over from left.

Definition at line 344 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op(), and XASSERTM.

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_symmetric_difference().

◆ meshpart_intersection()

template<typename MeshType_ >
template<typename AttributeFn_ >
static MeshPartType FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_intersection ( const MeshPartType left,
const MeshPartType right,
const AttributeFn_ &  attribute_merge 
)
inlinestatic

Compute the intersection of two meshparts.

Template Parameters
AttributeFn_Type of attribute merging function. Must be a callable that accepts a signature of DT(const DT&, const DT&), where DT = typename MeshPart<MeshType_>::AttributeDataType
Parameters
[in]leftLefthand-side of intersection
[in]rightRighthand-side of intersection
[in]attribute_mergeAttribute merging function

Computes a new meshpart that contains all entities that occur in both left and right.

Assume the following 2D mesh with quads A, B, C.

*  +--------+--------+--------+
*  |        |        |        |
*  |   A    |   B    |   C    |
*  |        |        |        |
*  +--------+--------+--------+
* 

Further assume that left is a meshpart consisting of the quads A, B and all their vertices and edges and that right is a meshpart consisting of quads B, C and all their vertices and edges. Then the intersection of left and right consists of the quad B and all its vertices and edges.

This function supports meshparts with topology. If left or right contain a topology, then the applicable parts of the topologies will be copied to the result meshpart. Precedence is given to right, if an entitiy appears in both meshparts.

This function supports meshparts with attributes. If both left and right contain an attribute with the same name and dimension, then an attribute with the same name and dimension will be created on the result meshpart. For each value the attribute_merge function gets called to decide how to merge the existing attribute values.

Definition at line 259 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op().

◆ meshpart_op()

template<typename MeshType_ >
template<typename AttributeFn_ , typename PredFn_ >
static MeshPartType FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op ( const MeshPartType left,
const MeshPartType right,
const AttributeFn_ &  attribute_merge,
const PredFn_ &  join_pred,
const bool  create_topology 
)
inlinestaticprivate

Common logic for all meshpart operations.

Template Parameters
AttributeFn_Type of attribute merging function. See actual docs of operations for details
PredFn_Type of join predicate. Callable with signature bool(const JoinEntry&)
Parameters
[in]leftLefthand-side of operation
[in]rightRighthand-side of operation
[in]attribute_mergeAttribute merging function
[in]join_predJoin predicate

This function forms the common basis for all current meshpart operations. The left, right, and attribute_merge parameters are the same as the operations parameters. The join_pred determines the actual operation, by selecting which entities should be included in the final meshpart. A join_pred that only selects entities that occur in both left and right implements an intersection, a join_pred that selects all entities implements a union, etc.

Definition at line 427 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::build_target_set_holder(), FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology(), FEAT::Geometry::MeshPartOperations< MeshType_ >::copy_attributes(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::join_elements().

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_difference(), FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_intersection(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_union().

◆ meshpart_symmetric_difference()

template<typename MeshType_ >
static MeshPartType FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_symmetric_difference ( const MeshPartType left,
const MeshPartType right 
)
inlinestatic

Compute the symmetric difference of two meshparts.

Parameters
[in]leftLefthand-side of symmetric difference
[in]rightRighthand-side of symmetric difference

Computes a new meshpart that contains all entities that occur either in left but not right, or right but not left.

Assume the following 2D mesh with quads A, B, C.

*  +--------+--------+--------+
*  |        |        |        |
*  |   A    |   B    |   C    |
*  |        |        |        |
*  +--------+--------+--------+
* 

Further assume that left is a meshpart consisting of the quads A, B and all their vertices and edges and that right is a meshpart consisting of quads B, C and all their vertices and edges. Then the symmetric difference of left and right consists of the quads A, C, the two leftmost vertices of the mesh the two rightmost vertices of the mesh, and the boundary edges of A and C. Note that the right edge of A and the left edge of C are not part of the result meshpart. They have been removed as part of quad B.

This function does not support mesparts with topology.

This function supports meshparts with attributes. If both left and right contain an attribute with the same name and dimension, then an attribute with the same name and dimension will be created on the result meshpart. Values will be copied over from left and right.

Definition at line 399 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_difference(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_union().

◆ meshpart_union()

template<typename MeshType_ >
template<typename AttributeFn_ >
static MeshPartType FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_union ( const MeshPartType left,
const MeshPartType right,
const AttributeFn_ &  attribute_merge 
)
inlinestatic

Compute the union of two meshparts.

Template Parameters
AttributeFn_Type of attribute merging function. Must be a callable that accepts a signature of DT(const DT&, const DT&), where DT = typename MeshPart<MeshType_>::AttributeDataType
Parameters
[in]leftLefthand-side of union
[in]rightRighthand-side of union
[in]attribute_mergeAttribute merging function

Computes a new meshpart that contains all entities that occur in either left or right.

Assume the following 2D mesh with quads A, B, C.

*  +--------+--------+--------+
*  |        |        |        |
*  |   A    |   B    |   C    |
*  |        |        |        |
*  +--------+--------+--------+
* 

Further assume that left is a meshpart consisting of the quad A and all its vertices and edges and that right is a meshpart consisting of quad C and all its vertices and edges. Then the union of left and right consists of the quads A, B, and all their vertices and edges.

This function supports meshparts with topology. If left or right contain a topology, then the applicable parts of the topologies will be copied to the result meshpart. Precedence is given to right, if an entitiy appears in both meshparts.

This function supports meshparts with attributes. If both left and right contain an attribute with the same name and dimension, then an attribute with the same name and dimension will be created on the result meshpart. If an entity occurs in both meshparts, then the attribute_merge function gets called to decide how to merge the existing attribute values. Otherwise the attribute values get copied as is.

Definition at line 306 of file mesh_part_ops.hpp.

References FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_op().

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::meshpart_symmetric_difference().

◆ search() [1/2]

template<typename MeshType_ >
template<typename Iter_ , typename T_ >
static std::optional< Index > FEAT::Geometry::MeshPartOperations< MeshType_ >::search ( Iter_  begin,
Iter_  end,
const T_ &  value 
)
inlinestaticprivate

Binary search.

Template Parameters
Iter_Iterator type
T_Target value type
Parameters
[in]beginStart iterator
[in]endEnd iterator
[in]valueTarget value
Returns
Index of the target value in the range [begin, end), if the range contains the value. nullopt otherwise.

Definition at line 993 of file mesh_part_ops.hpp.

References FEAT::value.

Referenced by FEAT::Geometry::MeshPartOperations< MeshType_ >::build_topology_inner(), and FEAT::Geometry::MeshPartOperations< MeshType_ >::join_elements().

◆ search() [2/2]

template<typename MeshType_ >
template<typename Iter_ , typename T_ , typename CompFn_ >
static std::optional< Index > FEAT::Geometry::MeshPartOperations< MeshType_ >::search ( Iter_  begin,
Iter_  end,
const T_ &  value,
const CompFn_ &  fn 
)
inlinestaticprivate

Binary search.

Template Parameters
Iter_Iterator type
T_Target value type
CompFn_Custom comparison function
Parameters
[in]beginStart iterator
[in]endEnd iterator
[in]valueTarget value
[in]fnComparison function
Returns
Index of the target value in the range [begin, end), if the range contains the value. nullopt otherwise.

Definition at line 1021 of file mesh_part_ops.hpp.

References FEAT::value.


The documentation for this class was generated from the following file: