Blender V5.3
blender::IndexMask Class Reference

#include <BLI_index_mask.hh>

Inherits blender::index_mask::IndexMaskData.

Public Types

using Initializer = std::variant<IndexRange, Span<int64_t>, Span<int>, int64_t>

Public Member Functions

std::optional< RawMaskIterator > find (int64_t query_index) const
std::optional< RawMaskIterator > find_larger_equal (int64_t query_index) const
std::optional< RawMaskIterator > find_smaller_equal (int64_t query_index) const
bool contains (int64_t query_index) const
IndexMask slice (int64_t start, int64_t size) const
IndexMask slice (RawMaskIterator first_it, RawMaskIterator last_it, int64_t size) const
IndexMask slice_content (IndexRange range) const
IndexMask slice_content (int64_t start, int64_t size) const
IndexMask slice_and_shift (IndexRange range, int64_t offset, LinearAllocator<> &memory) const
IndexMask slice_and_shift (int64_t start, int64_t size, int64_t offset, LinearAllocator<> &memory) const
IndexMask shift (const int64_t offset, LinearAllocator<> &memory) const
IndexMask complement (const IndexMask &universe, LinearAllocator<> &memory) const
template<ForeachSegmentFn Fn, exec_mode::Tag Mode = exec_mode::Serial>
void foreach_segment (Fn &&fn, Mode mode=exec_mode::serial) const
template<typename T>
void to_indices (MutableSpan< T > r_indices) const
void set_bits (MutableBitSpan r_bits, int64_t offset=0) const
void to_bits (MutableBitSpan r_bits, int64_t offset=0) const
void to_bools (MutableSpan< bool > r_bools) const
Vector< IndexRange > to_ranges () const
Vector< IndexRange > to_ranges_invert (IndexRange universe) const

Static Public Member Functions

template<typename T>
static IndexMask from_indices (Span< T > indices, LinearAllocator<> &memory)
static IndexMask from_bits (BitSpan bits, LinearAllocator<> &memory)
static IndexMask from_bits (const IndexMask &universe, BitSpan bits, LinearAllocator<> &memory)
static IndexMask from_bools (Span< bool > bools, LinearAllocator<> &memory)
static IndexMask from_bools (const VArray< bool > &bools, LinearAllocator<> &memory)
static IndexMask from_bools (const IndexMask &universe, Span< bool > bools, LinearAllocator<> &memory)
static IndexMask from_bools (const IndexMask &universe, const VArray< bool > &bools, LinearAllocator<> &memory)
static IndexMask from_bools_inverse (Span< bool > bools, LinearAllocator<> &memory)
static IndexMask from_bools_inverse (const VArray< bool > &bools, LinearAllocator<> &memory)
static IndexMask from_bools_inverse (const IndexMask &universe, Span< bool > bools, LinearAllocator<> &memory)
static IndexMask from_bools_inverse (const IndexMask &universe, const VArray< bool > &bools, LinearAllocator<> &memory)
template<typename T>
static IndexMask from_ranges (OffsetIndices< T > offsets, const IndexMask &mask, LinearAllocator<> &memory)
static IndexMask from_repeating (const IndexMask &mask_to_repeat, int64_t repetitions, int64_t stride, int64_t initial_offset, LinearAllocator<> &memory)
static IndexMask from_every_nth (int64_t n, int64_t indices_num, const int64_t initial_offset, LinearAllocator<> &memory)
static IndexMask from_segments (Span< IndexMaskSegment > segments, LinearAllocator<> &memory)
static IndexMask from_initializers (const Span< Initializer > initializers, LinearAllocator<> &memory)
static IndexMask from_union (const IndexMask &mask_a, const IndexMask &mask_b, LinearAllocator<> &memory)
static IndexMask from_union (Span< IndexMask > masks, LinearAllocator<> &memory)
static IndexMask from_difference (const IndexMask &mask_a, const IndexMask &mask_b, LinearAllocator<> &memory)
static IndexMask from_intersection (const IndexMask &mask_a, const IndexMask &mask_b, LinearAllocator<> &memory)
static IndexMask from_batch_predicate (const IndexMask &universe, LinearAllocator<> &memory, FunctionRef< int64_t(const IndexMaskSegment &universe_segment, IndexRangesBuilder< int16_t > &builder)> batch_predicate, exec_mode::Mode mode=exec_mode::parallel)
static Vector< IndexMask, 4 > from_group_ids (const VArray< int > &group_ids, LinearAllocator<> &memory)
static Vector< IndexMask, 4 > from_group_ids (const IndexMask &universe, const VArray< int > &group_ids, LinearAllocator<> &memory)
static void foreach_segment_zipped (Span< IndexMask > masks, FunctionRef< bool(Span< IndexMaskSegment > segments)> fn)

Friends

bool operator== (const IndexMask &a, const IndexMask &b)
bool operator!= (const IndexMask &a, const IndexMask &b)

#IndexMask Inline Methods

 IndexMask ()
 IndexMask (int64_t size)
 IndexMask (IndexRange range)
int64_t size () const
bool is_empty () const
IndexRange index_range () const
int64_t first () const
int64_t last () const
IndexRange bounds () const
int64_t min_array_size () const
RawMaskIterator index_to_iterator (int64_t index) const
int64_t iterator_to_index (const RawMaskIterator &it) const
int64_t operator[] (int64_t i) const
int64_t operator[] (const RawMaskIterator &it) const
IndexMask slice (IndexRange range) const
int64_t segments_num () const
IndexMaskSegment segment (int64_t segment_i) const
template<ForeachIndexFn Fn, exec_mode::Tag Mode = exec_mode::Serial>
void foreach_index (Fn &&fn, Mode mode=exec_mode::serial) const
template<typename IndexT, ForeachIndexFn Fn, exec_mode::Tag Mode = exec_mode::Serial>
void foreach_index_optimized (Fn &&fn, Mode mode=exec_mode::serial) const
template<ForeachSegmentFn Fn>
void foreach_segment (Fn &&fn, const exec_mode::Tag auto mode) const
template<ForeachSegmentOrRangePosFn Fn, exec_mode::Tag Mode = exec_mode::Serial>
void foreach_segment_optimized (Fn &&fn, Mode mode=exec_mode::serial) const
void foreach_range (ForeachRangeFn auto &&fn) const
template<typename T>
Vector< T > to_indices () const
std::optional< IndexRange > to_range () const
template<int64_t N = 4>
Vector< std::variant< IndexRange, IndexMaskSegment >, N > to_spans_and_ranges () const
IndexMaskData & data_for_inplace_construction ()
template<typename Fn>
static IndexMask from_predicate (const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
template<typename T, typename Fn>
static void from_groups (const IndexMask &universe, LinearAllocator<> &memory, Fn &&get_group_index, MutableSpan< IndexMask > r_masks)

Detailed Description

An IndexMask is a sequence of unique and sorted indices (BLI_unique_sorted_indices.hh). It's commonly used when a subset of elements in an array has to be processed.

IndexMask is a non-owning container. That data it references is usually either statically allocated or is owned by an IndexMaskMemory.

Internally, an index mask is split into an arbitrary number of ordered segments. Each segment contains up to max_segment_size (2^14 = 16384) indices. The indices in a segment are stored as int16_t, but each segment also has a int64_t offset.

The data structure is designed to satisfy the following key requirements:

  • Construct index mask for an IndexRange in O(1) time (after initial setup).
  • Support efficient slicing (O(log n) with a low constant factor).
  • Support multi-threaded construction without severe serial bottlenecks.
  • Support efficient iteration over indices that uses IndexRange when possible.

Construction: A new index mask is usually created by calling one of its constructors which are O(1), or for more complex masks, by calling various IndexMask::from_* functions that create masks from various sources. Those generally need additional memory which is provided with by an IndexMaskMemory.

Some of the IndexMask::from_* functions have an IndexMask universe input. When provided, the function will only consider the indices in the "universe". The term comes from mathematics: https://en.wikipedia.org/wiki/Universe_(mathematics).

Iteration: To iterate over the indices, one usually has to use one of the foreach_* functions which require a callback function. Due to the internal segmentation of the index mask, this is more efficient than using a normal C++ iterator and range-based for loops.

There are multiple variants of the foreach_* functions which are useful in different scenarios. The callback can generally take one or two arguments. The first is the index stored in the mask and the second is the index that would have to be passed into operator[] to get the first index.

The foreach_* methods also accept an execution mode optional argument. When that is provided, multi-threading might be used. Integrating multi-threading at this level works well because mask iteration and parallelism are often used at the same time.

Extraction: An IndexMask can be converted into various other forms using the to_* methods.

Definition at line 218 of file BLI_index_mask.hh.

Member Typedef Documentation

◆ Initializer

Construct a mask from some parts. This is mainly meant for more concise testing code. The individual items are unioned together.

Definition at line 282 of file BLI_index_mask.hh.

Constructor & Destructor Documentation

◆ IndexMask() [1/3]

blender::index_mask::IndexMask::IndexMask ( )
inline

Construct an empty mask.

Definition at line 704 of file BLI_index_mask.hh.

Referenced by blender::ed::object::apply_objects_internal(), blender::BKE_pbvh_sync_visibility_from_verts(), blender::ed::sculpt_paint::brushes::clay_strips::calc_node_mask(), blender::calculate_weld(), blender::bke::call_convert_to_uninitialized_fn(), blender::xpbd::color_constraints__all_independent(), blender::geometry::convert_curves_to_nurbs(), blender::io::ply::convert_ply_to_mesh(), blender::cpp_type_util::copy_assign_n_cb(), blender::bke::copy_attributes(), blender::cpp_type_util::copy_construct_n_cb(), blender::ed::transform::greasepencil::createTransGreasePencilVerts(), blender::ed::transform::pointcloud::createTransPointCloudVerts(), blender::cpp_type_util::default_construct_n_cb(), blender::cpp_type_util::destruct_n_cb(), blender::compositor::MultiFunctionProcedureOperation::execute(), blender::ed::sculpt_paint::CutOperationExecutor::execute(), blender::io::grease_pencil::SVGExporter::export_scene(), blender::cpp_type_util::fill_assign_n_cb(), blender::cpp_type_util::fill_construct_n_cb(), blender::ed::pointcloud::fill_selection_true(), blender::bke::attribute_math::SimpleMixer< float >::finalize(), blender::bke::find_faces_bad_offsets(), blender::nodes::node_geo_curve_topology_points_of_curve_cc::PointsOfCurveInput::get_varray_for_context(), blender::nodes::node_geo_material_selection_cc::MaterialSelectionFieldInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_face_cc::CornersOfFaceInput::get_varray_for_context(), blender::draw::grease_pencil_get_editable_selected_nurbs_curves(), blender::draw::grease_pencil_get_visible_nurbs_curves(), blender::ed::transform::curves::handles_by_type(), blender::bke::curves::indices_for_type(), blender::GVArrayCommon::materialize(), blender::VArrayCommon< T >::materialize(), blender::GVArrayCommon::materialize_to_uninitialized(), blender::VArrayCommon< T >::materialize_to_uninitialized(), blender::geometry::merge_points(), blender::bke::attribute_math::mix_groups(), blender::cpp_type_util::move_assign_n_cb(), blender::cpp_type_util::move_construct_n_cb(), blender::multires_stitch_grids(), blender::nodes::node_geo_filter_list_cc::node_geo_exec(), blender::ed::greasepencil::polyline_detect_corners(), blender::ed::sculpt_paint::greasepencil::process_stroke_weights(), blender::cpp_type_util::relocate_assign_n_cb(), blender::cpp_type_util::relocate_construct_n_cb(), blender::ed::greasepencil::retrieve_editable_points(), blender::ed::greasepencil::retrieve_editable_strokes(), blender::ed::curves::retrieve_selected_curves(), blender::ed::curves::pen_tool::retrieve_visible_bezier_handle_points(), blender::ed::greasepencil::retrieve_visible_bezier_handle_points(), blender::ed::greasepencil::retrieve_visible_bezier_handle_strokes(), blender::ed::greasepencil::retrieve_visible_bezier_points(), blender::ed::greasepencil::retrieve_visible_bezier_strokes(), blender::xpbd::ConstraintSet::solve_sequential_all(), blender::offset_indices::tests::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), blender::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::nodes::node_geo_transfer_attributes_cc::transfer_attributes(), and blender::cpp_type_util::value_initialize_n_cb().

◆ IndexMask() [2/3]

blender::index_mask::IndexMask::IndexMask ( int64_t size)
inlineexplicit

Construct a mask that contains the indices from 0 to size - 1. This takes O(1) time.

Definition at line 709 of file BLI_index_mask.hh.

◆ IndexMask() [3/3]

blender::index_mask::IndexMask::IndexMask ( IndexRange range)
inline

Construct a mask that contains the indices in the range. This takes O(1) time.

Definition at line 722 of file BLI_index_mask.hh.

Member Function Documentation

◆ bounds()

IndexRange blender::index_mask::IndexMask::bounds ( ) const
inline

Returns the smallest range that contains all indices stored in this mask.

Definition at line 758 of file BLI_index_mask.hh.

◆ complement()

Returns
A new index mask that contains all the indices from the universe that are not in the current mask.

Definition at line 407 of file index_mask.cc.

◆ contains()

Returns
True when the #query_index is stored in the mask.

Definition at line 965 of file index_mask.cc.

◆ data_for_inplace_construction()

IndexMaskData & blender::index_mask::IndexMask::data_for_inplace_construction ( )
inline

Is used by some functions to get low level access to the mask in order to construct it.

Definition at line 850 of file BLI_index_mask.hh.

◆ find()

std::optional< RawMaskIterator > blender::index_mask::IndexMask::find ( int64_t query_index) const
Returns
Position where the #query_index is stored, or none if the index is not in the mask.

Definition at line 897 of file index_mask.cc.

◆ find_larger_equal()

std::optional< RawMaskIterator > blender::index_mask::IndexMask::find_larger_equal ( int64_t query_index) const

Definition at line 907 of file index_mask.cc.

◆ find_smaller_equal()

std::optional< RawMaskIterator > blender::index_mask::IndexMask::find_smaller_equal ( int64_t query_index) const

Definition at line 933 of file index_mask.cc.

◆ first()

int64_t blender::index_mask::IndexMask::first ( ) const
inline

Definition at line 768 of file BLI_index_mask.hh.

◆ foreach_index()

template<ForeachIndexFn Fn, exec_mode::Tag Mode>
void blender::index_mask::IndexMask::foreach_index ( Fn && fn,
Mode mode = exec_mode::serial ) const
inline

Calls the function once for every index.

Supported function signatures:

i is the index that should be processed and pos is the position of that index in the mask: i == mask[pos]

Definition at line 856 of file BLI_index_mask.hh.

◆ foreach_index_optimized()

template<typename IndexT, ForeachIndexFn Fn, exec_mode::Tag Mode>
void blender::index_mask::IndexMask::foreach_index_optimized ( Fn && fn,
Mode mode = exec_mode::serial ) const
inline

Same as foreach_index, but generates more code, increasing compile time and binary size. This is because separate loops are generated for segments that are ranges and those that are not. Only use this when very little processing is done for each index.

Definition at line 938 of file BLI_index_mask.hh.

◆ foreach_range()

void blender::index_mask::IndexMask::foreach_range ( ForeachRangeFn auto && fn) const
inline

Calls the function once for every range. Note that this might call the function for each index separately in the worst case if there are no consecutive indices.

Support function signatures:

Definition at line 1046 of file BLI_index_mask.hh.

◆ foreach_segment() [1/2]

template<ForeachSegmentFn Fn>
void blender::index_mask::IndexMask::foreach_segment ( Fn && fn,
const exec_mode::Tag auto mode ) const
inline

Definition at line 1013 of file BLI_index_mask.hh.

◆ foreach_segment() [2/2]

template<ForeachSegmentFn Fn, exec_mode::Tag Mode = exec_mode::Serial>
void blender::index_mask::IndexMask::foreach_segment ( Fn && fn,
Mode mode = exec_mode::serial ) const

Calls the function once for every segment. This should be used instead of foreach_index if the algorithm can be implemented more efficiently by processing multiple indices at once.

Supported function signatures:

The segment_pos is the position in the mask where the segment starts: segment[0] == mask[segment_pos]

◆ foreach_segment_optimized()

template<ForeachSegmentOrRangePosFn Fn, exec_mode::Tag Mode>
void blender::index_mask::IndexMask::foreach_segment_optimized ( Fn && fn,
Mode mode = exec_mode::serial ) const
inline

This is similar to foreach_segment but supports slightly different function signatures:

The segment input is either of type IndexMaskSegment or IndexRange, so the function has to support both cases. This also means that more code is generated by the compiler because the function is instantiated twice. Only use this when very little processing happens per index.

Definition at line 969 of file BLI_index_mask.hh.

◆ foreach_segment_zipped()

Iterate over the indices in multiple masks which have the same size. The given function is called for groups of segments where each segment has the same size and comes from a different input mask. For example, if the input masks are (both have size 18): A: [0, 15), {20, 24, 25} B: [0, 5), [10, 15], {20, 30, 40, 50, 60, 70, 80, 90} Then the function will be called multiple times, each time with two segments:

  1. [0, 5), [0, 5)
  2. [5, 10), [10, 15)
  3. [10, 15), {20, 30, 40, 50, 60}
  4. {20, 24, 25}, {70, 80, 90}

Definition at line 1102 of file index_mask.cc.

Referenced by blender::ed::sculpt_paint::greasepencil::find_curve_mapping_from_index().

◆ from_batch_predicate()

This is a variant of from_predicate that is more efficient if the predicate for many indices can be evaluated at once.

Parameters
batch_predicateA function that finds indices in a certain segment that should become part of the mask. To efficiently handle ranges, this function uses IndexRangesBuilder. It returns an index offset that should be applied to each index in the builder.

Definition at line 556 of file index_mask.cc.

Referenced by blender::geometry::face_tris_mask(), and blender::bke::find_faces_bad_offsets().

◆ from_bits() [1/2]

◆ from_bits() [2/2]

Construct a mask from the indices of set bits, but limited to the indices in #universe.

Definition at line 485 of file index_mask.cc.

◆ from_bools() [1/4]

IndexMask blender::index_mask::IndexMask::from_bools ( const IndexMask & universe,
const VArray< bool > & bools,
LinearAllocator<> & memory )
static

Definition at line 649 of file index_mask.cc.

◆ from_bools() [2/4]

IndexMask blender::index_mask::IndexMask::from_bools ( const IndexMask & universe,
Span< bool > bools,
LinearAllocator<> & memory )
static

Construct a mask from the true indices, but limited by the indices in #universe.

Definition at line 613 of file index_mask.cc.

◆ from_bools() [3/4]

IndexMask blender::index_mask::IndexMask::from_bools ( const VArray< bool > & bools,
LinearAllocator<> & memory )
static

Definition at line 598 of file index_mask.cc.

◆ from_bools() [4/4]

Construct a mask from the true indices.

Definition at line 593 of file index_mask.cc.

Referenced by blender::ed::sculpt_paint::mask::apply_new_mask_bmesh(), blender::ed::sculpt_paint::mask::apply_new_mask_grids(), blender::ed::sculpt_paint::mask::apply_new_mask_mesh(), blender::ed::spreadsheet::GeometryDataSource::apply_selection_filter(), blender::BKE_pbvh_bmesh_after_stroke(), blender::bke::pbvh::bmesh_update_topology(), blender::build_drawing(), blender::draw::build_edit_selection_indices(), blender::geometry::construct::build_output_mesh(), blender::ed::spreadsheet::calc_mesh_selection_mask(), blender::ed::sculpt_paint::face_set::clear_face_sets(), blender::ed::greasepencil::boolean::create_curves_from_segments(), blender::ed::transform::pointcloud::createTransPointCloudVerts(), blender::ed::transform::curves::curve_populate_trans_data_structs(), blender::deform_drawing(), blender::ed::curves::end_points(), blender::draw::GSplatEvalCache::ensure_edit_dots_indices(), blender::ed::sculpt_paint::CombOperationExecutor::execute(), blender::ed::sculpt_paint::CutOperationExecutor::execute(), blender::ed::sculpt_paint::DeleteOperationExecutor::execute(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::ed::sculpt_paint::PinchOperationExecutor::execute(), blender::draw::extract_edituv_lines_mesh(), blender::ed::sculpt_paint::face_set::face_hide_update(), blender::ed::sculpt_paint::face_set::face_sets_update(), blender::ed::sculpt_paint::mask::fill_mask_bmesh(), blender::ed::sculpt_paint::mask::fill_mask_mesh(), blender::ed::greasepencil::find_curve_segments(), blender::ed::sculpt_paint::hide::flush_face_changes_node(), blender::ed::sculpt_paint::face_set::gesture_apply_bmesh(), blender::ed::sculpt_paint::mask::gesture_apply_for_symmetry_pass(), blender::ed::sculpt_paint::face_set::gesture_apply_mesh(), blender::get_selected_indices(), blender::nodes::node_geo_input_instance_bounds_cc::InstanceBoundsField::get_varray_for_context(), blender::ed::transform::gizmo_3d_foreach_selected(), blender::ed::greasepencil::grease_pencil_dissolve_exec(), blender::ed::sculpt_paint::hide::grid_hide_update(), blender::ed::sculpt_paint::hide::grow_shrink_visibility_grid(), blender::fn::index_mask_from_selection(), blender::geometry::interpolate_curves_with_samples(), blender::geometry::mapped_corner_selection_from_face(), blender::geometry::mesh_copy_selection(), blender::geometry::mesh_copy_selection_keep_edges(), blender::geometry::mesh_copy_selection_keep_verts(), blender::bke::mesh_select_edge_flush(), blender::bke::mesh_select_vert_flush(), blender::nodes::node_geo_filter_list_cc::node_geo_exec(), blender::bke::pbvh::nodes_to_face_selection_grids(), blender::ed::greasepencil::remove_fill_guides(), blender::ed::curves::remove_selection(), blender::ed::sculpt_paint::undo::restore_face_set_from_undo_step(), blender::ed::sculpt_paint::undo::restore_mask_from_undo_step(), blender::ed::curves::retrieve_selected_curves(), blender::ed::curves::retrieve_selected_points(), blender::ed::curves::retrieve_selected_points(), blender::ed::pointcloud::retrieve_selected_points(), blender::ed::sculpt_paint::mask::sculpt_mask_filter_exec(), blender::ed::curves::select_adjacent_mask(), blender::geometry::simplify_curve_attribute(), blender::ed::sculpt_paint::greasepencil::simplify_opacities(), blender::ed::sculpt_paint::greasepencil::simplify_stroke(), blender::geometry::smooth_curve_attribute(), blender::geometry::smooth_curve_positions(), blender::ed::sculpt_paint::expand::update_for_vert(), blender::ed::sculpt_paint::mask::update_mask_mesh(), blender::ed::sculpt_paint::hide::update_node_visibility_from_face_changes(), and blender::geometry::vert_selection_from_edge().

◆ from_bools_inverse() [1/4]

IndexMask blender::index_mask::IndexMask::from_bools_inverse ( const IndexMask & universe,
const VArray< bool > & bools,
LinearAllocator<> & memory )
static

Definition at line 668 of file index_mask.cc.

◆ from_bools_inverse() [2/4]

IndexMask blender::index_mask::IndexMask::from_bools_inverse ( const IndexMask & universe,
Span< bool > bools,
LinearAllocator<> & memory )
static

Definition at line 640 of file index_mask.cc.

◆ from_bools_inverse() [3/4]

Definition at line 608 of file index_mask.cc.

◆ from_bools_inverse() [4/4]

◆ from_difference()

◆ from_every_nth()

IndexMask blender::index_mask::IndexMask::from_every_nth ( int64_t n,
int64_t indices_num,
const int64_t initial_offset,
LinearAllocator<> & memory )
static

Constructs a mask that contains every nth index the given number of times.

Definition at line 1093 of file index_mask.cc.

Referenced by blender::offset_indices::tests::test_build_groups_from_indices_mask().

◆ from_group_ids() [1/2]

Vector< IndexMask, 4 > blender::index_mask::IndexMask::from_group_ids ( const IndexMask & universe,
const VArray< int > & group_ids,
LinearAllocator<> & memory )
static

Definition at line 1209 of file index_mask.cc.

◆ from_group_ids() [2/2]

Vector< IndexMask, 4 > blender::index_mask::IndexMask::from_group_ids ( const VArray< int > & group_ids,
LinearAllocator<> & memory )
static

◆ from_groups()

template<typename T, typename Fn>
void blender::index_mask::IndexMask::from_groups ( const IndexMask & universe,
LinearAllocator<> & memory,
Fn && get_group_index,
MutableSpan< IndexMask > r_masks )
static

◆ from_indices()

template<typename T>
template IndexMask blender::index_mask::IndexMask::from_indices ( Span< T > indices,
LinearAllocator<> & memory )
static

Construct a mask from unique sorted indices.

Definition at line 415 of file index_mask.cc.

Referenced by blender::fn::multi_function::InstructionScheduler::add_owned_indices(), blender::ed::object::apply_grease_pencil_for_modifier_all_keyframes(), blender::geometry::copy_and_reorder_curves(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_face_regions(), blender::index_mask::IndexMask::from_groups(), blender::xpbd::generic_constraint_coloring(), blender::ed::sculpt_paint::expand::geodesic_falloff_create(), blender::nodes::node_geo_mesh_topology_corners_of_edge_cc::CornersOfEdgeInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_vertex_cc::CornersOfVertInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_edges_of_vertex_cc::EdgesOfVertInput::get_varray_for_context(), blender::ed::sculpt_paint::greasepencil::interpolate_between_curves(), blender::ed::sculpt_paint::greasepencil::VertexAverageOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexPaintOperation::on_stroke_extended(), blender::ed::sculpt_paint::greasepencil::VertexReplaceOperation::on_stroke_extended(), blender::ed::greasepencil::polyline_detect_corners(), blender::bke::pbvh::search_nodes(), blender::ed::geometry::store_result_geometry(), blender::TEST(), blender::tests::TEST(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::ed::curves::tests::TEST_F(), blender::fn::multi_function::tests::TEST_F(), blender::fn::multi_function::tests::TEST_F(), blender::fn::multi_function::tests::TEST_F(), blender::fn::multi_function::tests::TEST_F(), blender::fn::tests::TEST_F(), blender::fn::tests::TEST_F(), blender::fn::tests::TEST_F(), blender::fn::tests::TEST_F(), blender::fn::tests::TEST_F(), blender::fn::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::tests::TEST_F(), blender::ed::sculpt_paint::expand::topology_falloff_create(), blender::nodes::node_geo_dual_mesh_cc::transfer_attributes(), and blender::bke::greasepencil::update_triangle_and_offsets_cache().

◆ from_initializers()

◆ from_intersection()

◆ from_predicate()

template<typename Fn>
IndexMask blender::index_mask::IndexMask::from_predicate ( const IndexMask & universe,
LinearAllocator<> & memory,
Fn && predicate,
exec_mode::Mode mode = exec_mode::parallel )
inlinestatic

Construct a mask from all the indices for which the predicate is true.

Definition at line 1074 of file BLI_index_mask.hh.

Referenced by blender::bke::pbvh::all_leaf_nodes(), blender::ed::spreadsheet::apply_filter_operation(), blender::BKE_pbvh_sync_visibility_from_verts(), blender::ed::sculpt_paint::expand::boundary_from_enabled(), blender::ed::sculpt_paint::greasepencil::brush_point_influence_mask(), blender::draw::calc_face_visibility_mesh(), blender::ed::spreadsheet::calc_mesh_selection_mask(), blender::ed::spreadsheet::calc_mesh_selection_mask_faces(), blender::ed::transform::calc_target_elems(), blender::draw::calc_vert_visibility_mapped_mesh(), blender::draw::calc_visible_loose_edge_indices(), blender::bke::CurvesGeometry::calculate_bezier_aligned_handles(), blender::geometry::convert_bezier_or_catmull_rom_to_poly_before_conversion_to_nurbs(), blender::array_utils::count_indices_with_table(), blender::ed::transform::curves::create_aligned_handles_masks(), blender::bke::curves_copy_point_selection(), blender::bke::greasepencil::curves_to_fills_mask(), blender::ed::sculpt_paint::cloth::do_simulation_step(), blender::geometry::edge_selection_from_vert(), blender::ed::sculpt_paint::cloth::ensure_nodes_constraints(), blender::ed::sculpt_paint::CurvesEffectOperationExecutor::execute(), blender::ed::sculpt_paint::PuffOperationExecutor::execute(), blender::io::grease_pencil::SVGExporter::export_scene(), blender::draw::extract_edituv_face_dots_bm(), blender::draw::extract_edituv_face_dots_mesh(), blender::draw::extract_edituv_tris_bm(), blender::draw::extract_edituv_tris_mesh(), blender::draw::extract_edituv_tris_subdiv_bm(), blender::draw::extract_edituv_tris_subdiv_mesh(), blender::draw::extract_face_dots_bm(), blender::draw::extract_lines_bm(), blender::draw::extract_points_bm(), blender::draw::extract_points_subdiv_bm(), blender::draw::extract_points_subdiv_mesh(), blender::ed::curves::pen_tool::extrude_curves(), blender::ed::greasepencil::extrude_grease_pencil_curves(), blender::geometry::face_selection_from_mapped_corner(), blender::faces_check_flip(), blender::ed::sculpt_paint::greasepencil::fill_mask_for_stroke_operation(), blender::geometry::find_collapsed_and_weld_edges(), blender::bke::find_edges_bad_verts(), blender::bke::find_faces_bad_edges(), blender::bke::find_faces_bad_verts(), blender::bke::find_faces_duplicate_verts(), blender::bke::find_faces_missing_edges(), blender::bke::pbvh::pixels::find_nodes_to_update(), blender::ed::sculpt_paint::greasepencil::InterpolateOpData::from_operator(), blender::modifier::greasepencil::get_filtered_layer_mask(), blender::modifier::greasepencil::get_filtered_stroke_mask(), blender::bke::get_invalid_float_mask(), blender::ed::greasepencil::get_visible_boundary_strokes(), blender::ed::greasepencil::grease_pencil_clean_loose_exec(), blender::draw::grease_pencil_get_editable_non_nurbs_curves(), blender::draw::grease_pencil_get_visible_non_nurbs_curves(), blender::geometry::grease_pencil_remove_points_and_split(), blender::ed::greasepencil::grease_pencil_select_by_stroke_type_exec(), blender::ed::greasepencil::grease_pencil_set_stroke_type_exec(), blender::ed::greasepencil::grease_pencil_stroke_simplify_exec(), blender::ed::sculpt_paint::hide::grids_show_all(), blender::ed::transform::curves::handles_by_type(), blender::bke::curves::indices_for_type(), blender::array_utils::indices_in_range(), blender::array_utils::indices_non_negative(), blender::ed::sculpt_paint::greasepencil::GreasePencilStrokeOperationCommon::init_auto_masking(), blender::ed::curves::pen_tool::insert_point_to_curve(), blender::geometry::construct::interpolate_new_corner_attribute_from_faces(), blender::bke::calc_edges::mask_first_distinct_edges(), blender::geometry::merge_propagation_map(), blender::geometry::merge_survivors(), blender::bke::mesh_calc_edges(), blender::draw::mesh_render_data_loose_geom_build(), blender::ed::sculpt_paint::hide::mesh_show_all(), blender::geometry::mesh_triangulate(), blender::nodes::node_geo_extrude_mesh_cc::mix_groups_or_default(), blender::bke::CurvesGeometry::nurbs_custom_knot_curves(), blender::bke::curves::point_to_curve_selection(), blender::ed::greasepencil::remove_curves_based_on_mode(), blender::ed::sculpt_paint::greasepencil::remove_points_with_low_opacity(), blender::ed::greasepencil::remove_stroke_or_fill_based_on_mode(), blender::ed::sculpt_paint::undo::restore_color_from_undo_step(), blender::ed::sculpt_paint::undo::restore_list(), blender::ed::sculpt_paint::undo::restore_position_from_undo_step(), blender::ed::greasepencil::retrieve_editable_fill_strokes(), blender::ed::greasepencil::retrieve_editable_points(), blender::ed::greasepencil::retrieve_editable_strokes(), blender::ed::greasepencil::retrieve_editable_strokes_by_material(), blender::ed::curves::retrieve_selected_curves(), blender::ed::curves::pen_tool::retrieve_visible_bezier_handle_points(), blender::ed::greasepencil::retrieve_visible_bezier_handle_points(), blender::ed::greasepencil::retrieve_visible_fills(), blender::ed::greasepencil::retrieve_visible_points(), blender::ed::greasepencil::retrieve_visible_strokes(), blender::ed::pointcloud::select_box(), blender::ed::pointcloud::select_circle(), blender::ed::greasepencil::select_fill_exec(), blender::ed::pointcloud::select_lasso(), blender::ed::curves::select_mask_from_predicates(), blender::selected_indices_from_vertex_group(), blender::bke::greasepencil::selected_mask_to_fills(), blender::simplify_drawing(), blender::ed::greasepencil::simplify_fixed(), blender::ed::sculpt_paint::simplify_fixed(), blender::simplify_fixed(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::stroke_eraser(), blender::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::geometry::tris_in_set(), blender::ed::curves::convert_to_particle_system::try_convert_single_object(), blender::bke::greasepencil::update_triangle_and_offsets_cache(), blender::bke::validate_bool_attribute(), blender::bke::validate_material_indices(), blender::bke::validate_mdisps(), blender::bke::validate_selection_history(), blender::geometry::weld_face_corner_ctx_alloc(), and blender::geometry::weld_face_find_doubles().

◆ from_ranges()

◆ from_repeating()

IndexMask blender::index_mask::IndexMask::from_repeating ( const IndexMask & mask_to_repeat,
int64_t repetitions,
int64_t stride,
int64_t initial_offset,
LinearAllocator<> & memory )
static

Constructs a mask by repeating the indices in the given mask with a stride. For example, with an input mask containing {3, 5} and a stride of 10 the resulting mask would contain {3, 5, 13, 15, 23, 25, ...}.

Definition at line 1018 of file index_mask.cc.

◆ from_segments()

Construct a mask from the given segments. The provided segments are expected to be sorted and owned by #memory already.

Definition at line 288 of file index_mask.cc.

◆ from_union() [1/2]

IndexMask blender::index_mask::IndexMask::from_union ( const IndexMask & mask_a,
const IndexMask & mask_b,
LinearAllocator<> & memory )
static

◆ from_union() [2/2]

Constructs a mask from the union of multiple masks.

Definition at line 707 of file index_mask.cc.

◆ index_range()

IndexRange blender::index_mask::IndexMask::index_range ( ) const
inline

Definition at line 753 of file BLI_index_mask.hh.

◆ index_to_iterator()

RawMaskIterator blender::index_mask::IndexMask::index_to_iterator ( int64_t index) const
inline
Returns
The iterator for the given index such that mask[iterator] == mask[index].

Definition at line 790 of file BLI_index_mask.hh.

◆ is_empty()

bool blender::index_mask::IndexMask::is_empty ( ) const
inline

Definition at line 748 of file BLI_index_mask.hh.

◆ iterator_to_index()

int64_t blender::index_mask::IndexMask::iterator_to_index ( const RawMaskIterator & it) const
inline
Returns
The index for the given iterator such that mask[iterator] == mask[index].

Definition at line 804 of file BLI_index_mask.hh.

◆ last()

int64_t blender::index_mask::IndexMask::last ( ) const
inline

Definition at line 774 of file BLI_index_mask.hh.

◆ min_array_size()

int64_t blender::index_mask::IndexMask::min_array_size ( ) const
inline
Returns
Minimum number of elements an array has to have so that it can be indexed by every index stored in the mask.

Definition at line 782 of file BLI_index_mask.hh.

◆ operator[]() [1/2]

int64_t blender::index_mask::IndexMask::operator[] ( const RawMaskIterator & it) const
inline

Same as above but takes O(1) time. It's still preferable to use foreach_* methods for iteration.

Definition at line 821 of file BLI_index_mask.hh.

◆ operator[]() [2/2]

int64_t blender::index_mask::IndexMask::operator[] ( int64_t i) const
inline

Get the index at the given position. Prefer foreach_* methods for better performance. This takes O(log n) time.

Definition at line 815 of file BLI_index_mask.hh.

◆ segment()

IndexMaskSegment blender::index_mask::IndexMask::segment ( int64_t segment_i) const
inline
Returns
Indices stored in the n-th segment.

Definition at line 831 of file BLI_index_mask.hh.

◆ segments_num()

int64_t blender::index_mask::IndexMask::segments_num ( ) const
inline
Returns
Number of segments in the mask.

Definition at line 826 of file BLI_index_mask.hh.

◆ set_bits()

Set the bits at indices in the mask to 1.

Definition at line 776 of file index_mask.cc.

◆ shift()

Adds an offset to every index in the mask.

Definition at line 205 of file index_mask.cc.

◆ size()

int64_t blender::index_mask::IndexMask::size ( ) const
inline

Definition at line 743 of file BLI_index_mask.hh.

◆ slice() [1/3]

IndexMask blender::index_mask::IndexMask::slice ( IndexRange range) const
inline

Get a new mask that contains a consecutive subset of this mask. Takes O(log n) time but can reuse the memory from the source mask.

Definition at line 845 of file BLI_index_mask.hh.

◆ slice() [2/3]

Definition at line 125 of file index_mask.cc.

◆ slice() [3/3]

IndexMask blender::index_mask::IndexMask::slice ( RawMaskIterator first_it,
RawMaskIterator last_it,
int64_t size ) const

Definition at line 144 of file index_mask.cc.

◆ slice_and_shift() [1/2]

Same slice but can also add an offset to every index in the mask. Takes O(log n + range.size()) time but with a very small constant factor.

Definition at line 184 of file index_mask.cc.

◆ slice_and_shift() [2/2]

Definition at line 191 of file index_mask.cc.

◆ slice_content() [1/2]

Slices the mask based on the stored indices. The resulting mask only contains the indices that are within the given range.

Definition at line 160 of file index_mask.cc.

◆ slice_content() [2/2]

Definition at line 165 of file index_mask.cc.

◆ to_bits()

Set the bits at indices in the mask to 1 and all other bits to 0.

Definition at line 795 of file index_mask.cc.

◆ to_bools()

Set the bools at indices in the mask to true and all others to false.

Definition at line 802 of file index_mask.cc.

◆ to_indices() [1/2]

template<typename T>
Vector< T > blender::index_mask::IndexMask::to_indices ( ) const
inline

Definition at line 1129 of file BLI_index_mask.hh.

◆ to_indices() [2/2]

template<typename T>
void blender::index_mask::IndexMask::to_indices ( MutableSpan< T > r_indices) const

Fill the provided span with the indices in the mask. The span is expected to have the same size as the mask.

Definition at line 766 of file index_mask.cc.

◆ to_range()

std::optional< IndexRange > blender::index_mask::IndexMask::to_range ( ) const
inline

Try to convert the entire index mask into a range. This only works if there are no gaps between any indices.

Definition at line 1136 of file BLI_index_mask.hh.

◆ to_ranges()

Returns
All index ranges in the mask. In the worst case this is a separate range for every index.

Definition at line 809 of file index_mask.cc.

◆ to_ranges_invert()

Returns
All index ranges in the universe that are not in the mask. In the worst case this is a separate range for every index.

Definition at line 816 of file index_mask.cc.

◆ to_spans_and_ranges()

template<int64_t N>
Vector< std::variant< IndexRange, IndexMaskSegment >, N > blender::index_mask::IndexMask::to_spans_and_ranges ( ) const
inline
Returns
All segments in sorted vector. Segments that encode a range are already converted to an IndexRange.

Definition at line 1150 of file BLI_index_mask.hh.

◆ operator!=

bool operator!= ( const IndexMask & a,
const IndexMask & b )
friend

Definition at line 1157 of file BLI_index_mask.hh.

◆ operator==

bool operator== ( const IndexMask & a,
const IndexMask & b )
friend

Definition at line 1188 of file index_mask.cc.


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