ug4
subset util

Functions

void ug::AdjustSubsetsForLgmNg (Grid &grid, SubsetHandler &sh, bool keepExistingInterfaceSubsets=false)
 reorders subsets in a way that allows for easy export to lgm-ng. More...
 
template<class TSubsetHandler >
void ug::AdjustSubsetsForSimulation (TSubsetHandler &sh, bool preserveExistingSubsets)
 Adjust the grid so that it is ready for simulation with ug4. More...
 
template<class TElem , class TSubsetHandler >
void ug::AssignAssociatedEdgesToSubsets (TSubsetHandler &sh, const ISubsetHandler &srcIndHandler)
 Assigns associated edges of elements of type TElem in sh to sh. More...
 
template<class TElem , class TSubsetHandler >
void ug::AssignAssociatedFacesToSubsets (TSubsetHandler &sh, const ISubsetHandler &srcIndHandler)
 Assigns associated faces of elements of type TElem in sh to sh. More...
 
template<class TElem , class TSubsetHandlerDest , class TSubsetHandlerSrc >
void ug::AssignAssociatedLowerDimElemsToSubsets (TSubsetHandlerDest &sh, const TSubsetHandlerSrc &srcIndHandler)
 Assigns associated elements of elements of type TElem in sh to sh. More...
 
template<class TElem , class TSubsetHandlerDest , class TSubsetHandlerSrc >
void ug::AssignAssociatedSidesToSubsets (TSubsetHandlerDest &sh, const TSubsetHandlerSrc &srcIndHandler)
 Assigns associated sides of elements of type TElem in sh to sh. More...
 
template<class TIterator >
void ug::AssignAssociatedVerticesToSubset (ISubsetHandler &sh, TIterator elemsBegin, TIterator elemsEnd, int subsetIndex)
 assigns vertices of the given elements to the subset at subsetIndex More...
 
template<class TElem , class TSubsetHandler >
void ug::AssignAssociatedVerticesToSubsets (TSubsetHandler &sh, const ISubsetHandler &srcIndHandler)
 Assigns associated vertices of elements of type TElem in sh to sh. More...
 
void ug::AssignFaceInterfaceEdgesToSubsets (Grid &grid, SubsetHandler &sh)
 assigns edges which belong to no subset and are adjacent to faces of different subsets to new subsets. More...
 
void ug::AssignGridToSubset (Grid &g, ISubsetHandler &sh, int subsetInd)
 Assigns all elements of the given grid to the given subset. More...
 
void ug::AssignInnerAndBoundarySubsets (Grid &grid, ISubsetHandler &shOut, int inSubset, int bndSubset)
 assigns objects to subsets depending on whether they are inner or boundary objects. More...
 
void ug::AssignRegionToSubset (Grid &grid, ISubsetHandler &shVolsOut, const ISubsetHandler &shFaces, Volume *proxyVol, int newSubsetIndex)
 assigns a region of volumes to a subset. More...
 
void ug::AssignSelectionToSubset (ISelector &sel, ISubsetHandler &sh, int subsetInd)
 Assigns all selected elements to the specified subset. More...
 
template<class TElem >
void ug::AssignSidesToSubsets (ISubsetHandler &sh, ISelector *psel=NULL)
 Assigns all sides of elements of the given type to a separate subset. More...
 
void ug::AssignSubsetColors (ISubsetHandler &sh)
 assigns a different color to each subset More...
 
template<class TElem , class TSubsetHandler >
void ug::AssignUnassignedElemsToSubset (TSubsetHandler &sh, int si)
 Assigns all elements of type TElem with subset index -1 to subset at index si. More...
 
void ug::AssignVolumeInterfaceFacesToSubsets (Grid &grid, SubsetHandler &sh)
 assigns faces which belong to no subset and are adjacent to volumes of different subsets to new subsets. More...
 
void ug::ComputeLocalSubsetDimensions (ISubsetHandler &sh, AChar aDimension, bool includeUnassigned)
 Computes the local subset dimension for each element and stores it in the given attachment. More...
 
void ug::CopySubsetIndicesToSides (ISubsetHandler &sh, bool toUnassignedOnly)
 copies subset-indices to sides of all elements in the subset handler More...
 
void ug::CopySubsetIndicesToSides (ISubsetHandler &sh, GridObjectCollection goc, bool toUnassignedOnly)
 copies subset-indices to sides of the specified elements More...
 
void ug::CopySubsetIndicesToSides (ISubsetHandler &sh, ISelector &sel, bool toUnassignedOnly)
 copies subset-indices to sides of the elements selected in 'sel' More...
 
template<class TIterator >
void ug::CopySubsetIndicesToSides (ISubsetHandler &sh, TIterator elemsBegin, TIterator elemsEnd, bool toUnassignedOnly)
 copies subset-indices to side-elements More...
 
template<class TAAPosVRT >
UG_API number ug::FaceArea (ISubsetHandler &sh, int si, size_t lvl, TAAPosVRT &aaPos)
 Returns the area sum of convex faces given by subset index and level. More...
 
template<typename TBaseObj >
void ug::FindSubsetGroups (std::vector< int > &minCondInd, const std::vector< bool > &isMarked, const ISubsetHandler &sh, const NeighborhoodType nbhType=NHT_VERTEX_NEIGHBORS)
 
vector3 ug::GetColorFromStandardPalette (int index)
 Returns an rgb vector (values ranging from 0 to 1), with the i-th default color. More...
 
int ug::GetFirstFreeSubset (const ISubsetHandler &sh)
 returns the first subset, which does not contain any elements at all More...
 
template<class TElem >
int ug::GetMaxSubsetIndex (SubsetHandler &sh)
 returns the index of the last subset, that contains elements of type TElem. More...
 
template<class TElem >
void ug::MakeSubsetsConsecutive (SubsetHandler &sh)
 moves subsets so that no empty subset of type TElem is between filled ones. More...
 
void ug::SeparateFaceSubsetsByNormal (Grid &grid, SubsetHandler &sh, APosition aPos=aPosition, ANormal *paNorm=NULL, int applyToSubset=-2)
 separates faces by orthogonal axis-aligned normals. More...
 
void ug::SeparateFaceSubsetsByNormal (Grid &grid, SubsetHandler &sh, std::vector< vector3 > vNormals, APosition aPos=aPosition, ANormal *paNorm=NULL, int applyToSubset=-2)
 separates subset by the given normals. More...
 
bool ug::SeparateRegions (Grid &grid, ISubsetHandler &shVolsOut, const ISubsetHandler &shFaces, const MarkerPointManager &mpm, int firstSubsetIndex)
 finds regions by marker-points More...
 
template<class TElem >
void ug::SeparateSubsetsByLowerDimSelection (Grid &grid, SubsetHandler &sh, Selector &sel, bool appendAtEnd=false)
 Assigns all elements of the given type to subsets. More...
 
template<class TElem >
void ug::SeparateSubsetsByLowerDimSeparators (Grid &grid, SubsetHandler &sh, bool appendAtEnd, boost::function< bool(typename TElem::lower_dim_base_object *)> cbIsSeparator)
 Assigns all elements of the given type to subsets. More...
 
template<class TElem >
void ug::SeparateSubsetsByLowerDimSubsets (Grid &grid, SubsetHandler &sh, bool appendAtEnd=false)
 Assigns all elements of the given type to subsets. More...
 
bool ug::SplitIrregularManifoldSubset (SubsetHandler &sh, int srcIndex, int targetIndex, bool strictSplitting=false)
 Keeps a regular part in the subset and assigns all other faces to another one. More...
 
void ug::AssignSubsetsByElementType (ISubsetHandler &sh)
 Assigns subset depending on the element type. More...
 
void ug::AssignSubsetsByElementType (ISubsetHandler &sh, GridObjectCollection g)
 Assigns subset depending on the element type. More...
 

Detailed Description

Several methods that ease subset-handling are grouped here.

Function Documentation

◆ AdjustSubsetsForLgmNg()

UG_API void ug::AdjustSubsetsForLgmNg ( Grid grid,
SubsetHandler sh,
bool  keepExistingInterfaceSubsets = false 
)

reorders subsets in a way that allows for easy export to lgm-ng.

.lgm and .ng are the geometry-file-types of ug3. They require a very special subset-structure. This method will try to adjust the subsets in a way that makes export using

See also
ExportGridToUG easy. Please note, that this method does not yet produce fully compatible output. In order to ensure maximal compatibility you should avoid to have empty subsets between filled ones.

Through keepExistingInterfaceSubsets you can decide whether interface faces or edges which already are assigned to a subset shall be kept. Note that the algorithm may not produce a fully compatible geometry in this case (this depends on your initial subsets).

References ug::GridSubsetHandler::assign_subset(), ug::AssignFaceInterfaceEdgesToSubsets(), ug::AssignVolumeInterfaceFacesToSubsets(), ug::GridSubsetHandler::begin(), ug::CollectFaces(), ug::CollectVolumes(), ug::Grid::edges_begin(), ug::Grid::edges_end(), ug::GridSubsetHandler::end(), ug::Grid::faces_begin(), ug::Grid::faces_end(), ug::FixEdgeOrientation(), FixFaceOrientation(), ug::ISubsetHandler::get_subset_index(), ug::GetPolyChainType(), ug::GridSubsetHandler::num(), ug::ISubsetHandler::num_subsets(), ug::Grid::num_volumes(), ug::PCT_CLOSED, ug::SplitIrregularManifoldSubset(), ug::SplitIrregularPolyChain(), ug::Grid::volumes_begin(), and ug::Grid::volumes_end().

◆ AdjustSubsetsForSimulation()

template<class TSubsetHandler >
void ug::AdjustSubsetsForSimulation ( TSubsetHandler &  sh,
bool  preserveExistingSubsets 
)

Adjust the grid so that it is ready for simulation with ug4.

For simulation it is crucial that all geometric objects of a grid are assigned to a subset. Furthermore all lower dimensional elements, which are only connected to higher dimensional elements of one subset should be in the same subset as those elements. Elements which form an interface between different subsets should be in a separate subset.

You may specify, that existing subsets shall not be touched. This is a good idea, if you already specified some boundaries etc. However, you should in this case make sure, that all elements which are not assigned to a subset intentionally, are assigned to subset -1.

References ug::AssignSidesToSubsets< Edge >(), ug::AssignSidesToSubsets< Face >(), ug::AssignSidesToSubsets< Volume >(), ug::Grid::begin(), ug::Selector::begin(), ug::Selector::clear(), ug::Grid::end(), ug::Selector::end(), ug::EraseEmptySubsets(), ug::GetFirstFreeSubset(), ug::Grid::num_edges(), ug::Grid::num_faces(), ug::Grid::num_volumes(), ug::SelectAssociatedEdges(), ug::SelectAssociatedVertices(), ug::SelectBoundaryElements(), and ug::SelectInterfaceElements().

◆ AssignAssociatedEdgesToSubsets()

template<class TElem , class TSubsetHandler >
void ug::AssignAssociatedEdgesToSubsets ( TSubsetHandler &  sh,
const ISubsetHandler srcIndHandler 
)

Assigns associated edges of elements of type TElem in sh to sh.

Make sure that TElem is not of type Edge or any derivate.

The method iterates over all elements of type TElem in sh and assigns associated edges to sh. The target subset-index is taken from srcIndHandler.

Valid types for TSubsetHandler are SubsetHandler and MGSubsetHandler compatible types.

This method is e.g. used for SurfaceView creation.

References ug::CollectEdges(), and ug::ISubsetHandler::get_subset_index().

◆ AssignAssociatedFacesToSubsets()

template<class TElem , class TSubsetHandler >
void ug::AssignAssociatedFacesToSubsets ( TSubsetHandler &  sh,
const ISubsetHandler srcIndHandler 
)

Assigns associated faces of elements of type TElem in sh to sh.

Make sure that TElem is not of type Face or any derivate.

The method iterates over all elements of type TElem in sh and assigns associated faces to sh. The target subset-index is taken from srcIndHandler.

Valid types for TSubsetHandler are SubsetHandler and MGSubsetHandler compatible types.

This method is e.g. used for SurfaceView creation.

References ug::CollectFaces(), and ug::ISubsetHandler::get_subset_index().

◆ AssignAssociatedLowerDimElemsToSubsets()

template<class TElem , class TSubsetHandlerDest , class TSubsetHandlerSrc >
void ug::AssignAssociatedLowerDimElemsToSubsets ( TSubsetHandlerDest &  sh,
const TSubsetHandlerSrc &  srcIndHandler 
)

Assigns associated elements of elements of type TElem in sh to sh.

The method iterates over all elements of type TElem in sh and assigns associated elements of lower dimension to sh. The subset-index to which those elements are assigned are taken from srcIndHandler.

Associated elements that are assigned to sh and have a subset-index of -1 in srcIndHandler are assigned to the subset at alternativeSubsetIndex.

Valid types for TSubsetHandler are SubsetHandler and MGSubsetHandler compatible types.

This method is e.g. used for SurfaceView creation.

◆ AssignAssociatedSidesToSubsets()

template<class TElem , class TSubsetHandlerDest , class TSubsetHandlerSrc >
void ug::AssignAssociatedSidesToSubsets ( TSubsetHandlerDest &  sh,
const TSubsetHandlerSrc &  srcIndHandler 
)

Assigns associated sides of elements of type TElem in sh to sh.

The method iterates over all elements of type TElem in sh and assigns associated sides to sh. The target subset-index is taken from srcIndHandler.

Valid types for TSubsetHandler are SubsetHandler and MGSubsetHandler compatible types.

This method is e.g. used for SurfaceView creation.

References ug::CollectAssociated(), and s.

◆ AssignAssociatedVerticesToSubset()

template<class TIterator >
void ug::AssignAssociatedVerticesToSubset ( ISubsetHandler sh,
TIterator  elemsBegin,
TIterator  elemsEnd,
int  subsetIndex 
)

assigns vertices of the given elements to the subset at subsetIndex

TIterator should be an stl-compatible iterator. Its value_type should be a pointer to either Edge, Face, Volume or an derived type of the three.

References ug::ISubsetHandler::assign_subset().

◆ AssignAssociatedVerticesToSubsets()

template<class TElem , class TSubsetHandler >
void ug::AssignAssociatedVerticesToSubsets ( TSubsetHandler &  sh,
const ISubsetHandler srcIndHandler 
)

Assigns associated vertices of elements of type TElem in sh to sh.

Make sure that TElem is not of type Vertex or any derivate.

The method iterates over all elements of type TElem in sh and assigns associated vertices to sh. The target subset-index is taken from srcIndHandler.

Valid types for TSubsetHandler are SubsetHandler and MGSubsetHandler compatible types.

This method is e.g. used for SurfaceView creation.

References ug::ISubsetHandler::get_subset_index().

◆ AssignFaceInterfaceEdgesToSubsets()

UG_API void ug::AssignFaceInterfaceEdgesToSubsets ( Grid grid,
SubsetHandler sh 
)

assigns edges which belong to no subset and are adjacent to faces of different subsets to new subsets.

the edges of each interface between two subset are put into a seperate subset, starting at GetMaxSubsetIndex<Edge>(sh) + 1.

References ug::GridSubsetHandler::assign_subset(), ug::GridSubsetHandler::begin(), ug::CollectEdges(), ug::CollectFaces(), ug::GridSubsetHandler::end(), ug::ISubsetHandler::get_subset_index(), ug::GridSubsetHandler::num_elements(), and ug::ISubsetHandler::num_subsets().

Referenced by ug::AdjustSubsetsForLgmNg().

◆ AssignGridToSubset()

UG_API void ug::AssignGridToSubset ( Grid g,
ISubsetHandler sh,
int  subsetInd 
)

◆ AssignInnerAndBoundarySubsets()

UG_API void ug::AssignInnerAndBoundarySubsets ( Grid grid,
ISubsetHandler shOut,
int  inSubset,
int  bndSubset 
)

◆ AssignRegionToSubset()

UG_API void ug::AssignRegionToSubset ( Grid grid,
ISubsetHandler shVolsOut,
const ISubsetHandler shFaces,
Volume proxyVol,
int  newSubsetIndex 
)

assigns a region of volumes to a subset.

Indirectly uses Grid::mark.

All volumes that are connected directly or indirectly to proxyVol (that means on can reach the volume without traversing a face that is assigned to a subset) are considered to be in the same region as proxyVol. All those volumes will be assigned to to the subset in shVolsOut specified by newSubsetIndex.

shFaces will be used to determine whether a side of the volume is contained in a subset (!= -1) and is thus considered to be a boundary of the region.

shFaces and shVolsOut may refer to the same subset handler.

References ug::ISubsetHandler::assign_subset(), ug::CollectVolumes(), ug::Grid::get_face(), ug::ISubsetHandler::get_subset_index(), ug::GetNeighbours(), and ug::Volume::num_faces().

Referenced by ug::SeparateRegions().

◆ AssignSelectionToSubset()

UG_API void ug::AssignSelectionToSubset ( ISelector sel,
ISubsetHandler sh,
int  subsetInd 
)

Assigns all selected elements to the specified subset.

Make sure that the specified subset handler and the specified selector operate on the same grid.

References ug::ISubsetHandler::assign_subset(), ug::GridObjectCollection::begin(), ug::GridObjectCollection::end(), ug::ISelector::get_grid_objects(), ug::ISelector::grid(), ug::ISubsetHandler::grid(), ug::GridObjectCollection::num_levels(), and UG_ASSERT.

◆ AssignSidesToSubsets()

template<class TElem >
void ug::AssignSidesToSubsets ( ISubsetHandler sh,
ISelector psel = NULL 
)

Assigns all sides of elements of the given type to a separate subset.

All elements of type TElem::lower_dim_base_object, which are located in subset -1, are assigned to a subset, depending on the subsets of neighbors of type TElem. For each neighborhood constellation a separate subset index is chosen.

Valid parameters for TElem are: Edge, Face, Volume

You may specify a selector, which indicates which elements to check, when looking for neighbors in different subsets. Please note, that the selector is only used, if a selected side is encountered.

References ug::ISubsetHandler::assign_subset(), ug::Grid::begin(), ug::CollectAssociated(), ug::Grid::end(), ug::ISubsetHandler::get_subset_index(), ug::GetFirstFreeSubset(), ug::ISubsetHandler::grid(), ug::ISelector::is_selected(), and ug::ISubsetHandler::num_subsets().

◆ AssignSubsetColors()

◆ AssignSubsetsByElementType() [1/2]

UG_API void ug::AssignSubsetsByElementType ( ISubsetHandler sh)

Assigns subset depending on the element type.

References ug::AssignSubsetsByElementType(), ug::Grid::get_grid_objects(), and ug::ISubsetHandler::grid().

◆ AssignSubsetsByElementType() [2/2]

◆ AssignUnassignedElemsToSubset()

template<class TElem , class TSubsetHandler >
void ug::AssignUnassignedElemsToSubset ( TSubsetHandler &  sh,
int  si 
)

Assigns all elements of type TElem with subset index -1 to subset at index si.

References ug::Grid::begin(), and ug::Grid::end().

◆ AssignVolumeInterfaceFacesToSubsets()

UG_API void ug::AssignVolumeInterfaceFacesToSubsets ( Grid grid,
SubsetHandler sh 
)

assigns faces which belong to no subset and are adjacent to volumes of different subsets to new subsets.

the faces of each interface between two subset are put into a seperate subset, starting at GetMaxSubsetIndex<Face>(sh) + 1.

References ug::GridSubsetHandler::assign_subset(), ug::GridSubsetHandler::begin(), ug::CollectFaces(), ug::CollectVolumes(), ug::GridSubsetHandler::end(), ug::ISubsetHandler::get_subset_index(), ug::GridSubsetHandler::num_elements(), and ug::ISubsetHandler::num_subsets().

Referenced by ug::AdjustSubsetsForLgmNg().

◆ ComputeLocalSubsetDimensions()

UG_API void ug::ComputeLocalSubsetDimensions ( ISubsetHandler sh,
AChar  aDimension,
bool  includeUnassigned 
)

Computes the local subset dimension for each element and stores it in the given attachment.

The local subset dimension of an element is the dimension of the highest dimensional associated element in the same subset as the element itself.

If an element isn't assigned to a subset (subset index == -1) then the local subset dimension is either defined as the smallest subset-dimension of any associated element of higher dimension (if includeUnassigned==true) or is simply set to -1 (if inculdeUnassigned==false).

The subset-dimension of each element will be written to the 'aDimension' attachment. If this attachment isn't already attached to the subset-handler's grid, it will be automatically attached to all elements. Make sure to detach it when it is no longer needed!

If a local subset-dimension can't be computed for a given element, -1 is assigned.

References ug::Grid::associated_elements(), ug::Grid::attach_to_all(), ug::Grid::begin(), ug::Grid::end(), ug::ISubsetHandler::get_subset_index(), ug::ISubsetHandler::grid(), and UG_COND_THROW.

Referenced by ug::CopySubsetIndicesToSides().

◆ CopySubsetIndicesToSides() [1/4]

UG_API void ug::CopySubsetIndicesToSides ( ISubsetHandler sh,
bool  toUnassignedOnly 
)

copies subset-indices to sides of all elements in the subset handler

Lower dimensional elements have higher priority during assignment (e.g. if toUnnassignedOnly == 'true' and the unassigned edge e is connected to a face and a to volume element of different subsets, then it will be assigned to the subset of the connected face).

References ug::Grid::get_grid_objects(), ug::ISubsetHandler::grid(), and UG_COND_THROW.

Referenced by ug::CopySubsetIndicesToSides().

◆ CopySubsetIndicesToSides() [2/4]

UG_API void ug::CopySubsetIndicesToSides ( ISubsetHandler sh,
GridObjectCollection  goc,
bool  toUnassignedOnly 
)

copies subset-indices to sides of the specified elements

Lower dimensional elements have higher priority during assignment (e.g. if toUnnassignedOnly == 'true' and the unassigned edge e is connected to a face and a to volume element of different subsets, then it will be assigned to the subset of the connected face).

References ug::Grid::attach_to_all(), ug::GridObjectCollection::begin(), ug::ComputeLocalSubsetDimensions(), ug::CopySubsetFromHigherDimNbr(), ug::CopySubsetIndicesToSides(), ug::Grid::detach_from_all(), ug::GridObjectCollection::end(), ug::ISubsetHandler::grid(), ug::GridObjectCollection::num_levels(), and UG_COND_THROW.

◆ CopySubsetIndicesToSides() [3/4]

UG_API void ug::CopySubsetIndicesToSides ( ISubsetHandler sh,
ISelector sel,
bool  toUnassignedOnly 
)

copies subset-indices to sides of the elements selected in 'sel'

Lower dimensional elements have higher priority during assignment (e.g. if toUnnassignedOnly == 'true' and the unassigned edge e is connected to a face and a to volume element of different subsets, then it will be assigned to the subset of the connected face).

References ug::CopySubsetIndicesToSides(), and ug::ISelector::get_grid_objects().

◆ CopySubsetIndicesToSides() [4/4]

template<class TIterator >
void ug::CopySubsetIndicesToSides ( ISubsetHandler sh,
TIterator  elemsBegin,
TIterator  elemsEnd,
bool  toUnassignedOnly 
)

copies subset-indices to side-elements

Indices can be copied to all sides or to unassigned sides only.

References ug::ISubsetHandler::assign_subset(), ug::Grid::associated_elements(), ug::ISubsetHandler::get_subset_index(), ug::ISubsetHandler::grid(), s, ug::PointerConstArray< TPtr >::size(), and UG_ASSERT.

◆ FaceArea()

template<class TAAPosVRT >
UG_API number ug::FaceArea ( ISubsetHandler sh,
int  si,
size_t  lvl,
TAAPosVRT &  aaPos 
)

Returns the area sum of convex faces given by subset index and level.

Parameters
shsubset handler
sisubset index
lvlgrid level
aaPosposition attachment
Returns
number area sum of convex faces

References ug::FaceArea(), ug::GridObjectCollection::faces_begin(), ug::GridObjectCollection::faces_end(), ug::ISubsetHandler::get_grid_objects_in_subset(), ug::GridObjectCollection::num(), and UG_WARNING.

◆ FindSubsetGroups()

template<typename TBaseObj >
void ug::FindSubsetGroups ( std::vector< int > &  minCondInd,
const std::vector< bool > &  isMarked,
const ISubsetHandler sh,
const NeighborhoodType  nbhType = NHT_VERTEX_NEIGHBORS 
)

FindSubsetGroups Finds out the topology of the domain Computes the connectivity of subsets basing on the elements in the coarsest grid (grid level 0). For every subset, this function computes the smallest subset index such that this subset and the subset with that smallest index are connected (i.e. either have a common boundary or via further subsets with common boundaries).

Template Parameters
TBaseObjthe base element type (for ex. 'Volume'): only elements of this type are considered in the subsets
Parameters
[out]minCondIndan array indexed by the subset indices, so that every entry of a marked subset is initialized with the smallest subset id connected to it; for subsets that are not marked, the entry is set to -1; for marked subsets that contain no elements of type TBaseObj, the entry is set to -2
[in]isMarked'true' for subsets that should be considered, 'false' for other subsets
[in]shthe subset handler of the domain
[in]nbhTypetype of the connectivity (for ex. via vertices, or only full edges, ...)

References ug::GridObjectCollection::begin(), ug::CollectNeighbors(), ug::GridObjectCollection::end(), ug::ISubsetHandler::get_grid_objects_in_subset(), ug::ISubsetHandler::get_subset_index(), ug::ISubsetHandler::grid(), ug::ISubsetHandler::num_subsets(), UG_ASSERT, and UG_THROW.

◆ GetColorFromStandardPalette()

UG_API vector3 ug::GetColorFromStandardPalette ( int  index)

Returns an rgb vector (values ranging from 0 to 1), with the i-th default color.

References ug::GetColorFromDefaultPalette().

◆ GetFirstFreeSubset()

◆ GetMaxSubsetIndex()

template<class TElem >
int ug::GetMaxSubsetIndex ( SubsetHandler sh)

returns the index of the last subset, that contains elements of type TElem.

returns -1 if no subset contains elements of type TElem. All geometric objects and the 4 geometric base objects are valid types.

call this method like this: GetMaxSubsetIndex<Face>(yourSubsetHandler);

References ug::GridSubsetHandler::num_elements(), and ug::ISubsetHandler::num_subsets().

◆ MakeSubsetsConsecutive()

template<class TElem >
void ug::MakeSubsetsConsecutive ( SubsetHandler sh)

moves subsets so that no empty subset of type TElem is between filled ones.

This algorithm does not change the order of filled subsets. Since this algorithm only checks for elements of type TElem, it is possible that after termination subsets are empty regarding other element-types.

References ug::ISubsetHandler::move_subset(), ug::GridSubsetHandler::num_elements(), and ug::ISubsetHandler::num_subsets().

◆ SeparateFaceSubsetsByNormal() [1/2]

UG_API void ug::SeparateFaceSubsetsByNormal ( Grid grid,
SubsetHandler sh,
APosition  aPos = aPosition,
ANormal paNorm = NULL,
int  applyToSubset = -2 
)

separates faces by orthogonal axis-aligned normals.

The faces of each existing subset are assigned to new subsets based on the closest axis-aligned normal. Faces with similar normals which are contained in different subsets are assigned to different subsets.

Parameters
gridGrid
shSubset Handler
aPosPosition Attachment
paNormpointer to the normal attachment. NULL indicates that normals shall be calculated on the fly (default).
applyToSubsetAllows to specify which subset shall be separated. -2: All subsets, 0, ..., numSubsets: The specified subset only.

References ug::SeparateFaceSubsetsByNormal().

◆ SeparateFaceSubsetsByNormal() [2/2]

UG_API void ug::SeparateFaceSubsetsByNormal ( Grid grid,
SubsetHandler sh,
std::vector< vector3 vNormals,
APosition  aPos = aPosition,
ANormal paNorm = NULL,
int  applyToSubset = -2 
)

separates subset by the given normals.

The faces of each existing subset are assigned to new subsets based on the closest matching normal. Faces with similar normals which are contained in different subsets are assigned to different subsets.

Parameters
gridGrid
shSubset Handler
vNormalsnormals
aPosPosition Attachment
paNormpointer to the normal attachment. NULL indicates that normals shall be calculated on the fly (default).
applyToSubsetAllows to specify which subset shall be separated. -2: All subsets, 0, ..., numSubsets: The specified subset only.

References ug::Grid::AttachmentAccessor< TElem, TAttachment >::access(), ug::GridSubsetHandler::assign_subset(), ug::GridSubsetHandler::begin(), ug::CalculateNormal(), ug::GridSubsetHandler::end(), ug::Grid::has_face_attachment(), ug::Grid::has_vertex_attachment(), ug::AttachmentAccessor< TElem, TAttachment, TElemHandler >::valid(), and ug::VecDistanceSq().

Referenced by ug::SeparateFaceSubsetsByNormal().

◆ SeparateRegions()

UG_API bool ug::SeparateRegions ( Grid grid,
ISubsetHandler shVolsOut,
const ISubsetHandler shFaces,
const MarkerPointManager mpm,
int  firstSubsetIndex 
)

finds regions by marker-points

Indirectly uses Grid::mark. If a region contains the i-th marker-point, it is assigned to the subset (firstSubsetIndex + i).

A region is a group of volumes that is surrounded by faces that lie in subsets != -1.

NOTE that this method currently only works for tetrahedral grids (at least the markers are only associated with tetrahedrons).

References ug::aPosition, ug::AssignRegionToSubset(), ug::Grid::begin(), ug::Grid::end(), ug::MarkerPointManager::get_marker(), ug::Grid::has_vertex_attachment(), ug::MarkerPoint::name, ug::SubsetInfo::name, ug::MarkerPointManager::num_markers(), ug::PointIsInsideTetrahedron(), ug::MarkerPoint::pos, and ug::ISubsetHandler::subset_info().

◆ SeparateSubsetsByLowerDimSelection()

template<class TElem >
void ug::SeparateSubsetsByLowerDimSelection ( Grid grid,
SubsetHandler sh,
Selector sel,
bool  appendAtEnd = false 
)

Assigns all elements of the given type to subsets.

Different subsets are created for different regions. A region is a set of elements of the given type, which are surrounded by a closed set of lower dimensional elements, which are all assigned to a subset.

◆ SeparateSubsetsByLowerDimSeparators()

template<class TElem >
void ug::SeparateSubsetsByLowerDimSeparators ( Grid grid,
SubsetHandler sh,
bool  appendAtEnd,
boost::function< bool(typename TElem::lower_dim_base_object *)>  cbIsSeparator 
)

Assigns all elements of the given type to subsets.

Different subsets are created for different regions. A region is a set of elements of the given type, which are surrounded by a closed set of lower dimensional elements, which are all separators.

Through a callback one can specify the elements which separate subsets. If the callback returns true for an element, the element is regarded as a separator.

Note that the callback operates on elements which have one dimension less than TElem. The callback is compatible with the CB_ConsiderVertex, CB_ConsiderEdge and CB_ConsiderFace callbacks.

References ug::GridSubsetHandler::assign_subset(), ug::Grid::begin(), ug::Selector::begin(), ug::CollectAssociated(), ug::ISelector::deselect(), ug::Selector::empty(), ug::Grid::end(), ug::Grid::get_side(), ug::ISelector::is_selected(), ug::ISubsetHandler::num_subsets(), and ug::ISelector::select().

◆ SeparateSubsetsByLowerDimSubsets()

template<class TElem >
void ug::SeparateSubsetsByLowerDimSubsets ( Grid grid,
SubsetHandler sh,
bool  appendAtEnd = false 
)

Assigns all elements of the given type to subsets.

Different subsets are created for different regions. A region is a set of elements of the given type, which are surrounded by a closed set of lower dimensional elements, which are all assigned to a subset.

◆ SplitIrregularManifoldSubset()

UG_API bool ug::SplitIrregularManifoldSubset ( SubsetHandler sh,
int  srcIndex,
int  targetIndex,
bool  strictSplitting = false 
)

Keeps a regular part in the subset and assigns all other faces to another one.

THIS ALGORITHM USES Grid::mark

If the faces in the given subset build an irregular manifold, then this algorithm finds a regular part and assigns all other faces to the given targetIndex.

Parameters
strictSplittingif true, faces of all subsets are considered when deciding whether an edge is a manifold edge or not. If false, only faces of the subset with index 'srcIndex' are considered. Default is false.
Returns
true if the subset was splitted, false if not.

References ug::GridSubsetHandler::assign_subset(), ug::GridSubsetHandler::begin(), ug::Grid::begin_marking(), ug::CollectAssociated(), ug::GridSubsetHandler::empty(), ug::Grid::enable_options(), ug::GridSubsetHandler::end(), ug::Grid::end_marking(), ug::FACEOPT_AUTOGENERATE_EDGES, ug::ISubsetHandler::get_subset_index(), ug::ISubsetHandler::grid(), ug::Grid::is_marked(), ug::Grid::mark(), ug::GridSubsetHandler::num(), ug::Grid::option_is_enabled(), and UG_LOG.

Referenced by ug::AdjustSubsetsForLgmNg().