Blender V5.0
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, IndexMaskMemory &memory) const
IndexMask slice_and_shift (int64_t start, int64_t size, int64_t offset, IndexMaskMemory &memory) const
IndexMask shift (const int64_t offset, IndexMaskMemory &memory) const
IndexMask complement (const IndexMask &universe, IndexMaskMemory &memory) 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< IndexRangeto_ranges () const
Vector< IndexRangeto_ranges_invert (IndexRange universe) const

Static Public Member Functions

template<typename T>
static IndexMask from_indices (Span< T > indices, IndexMaskMemory &memory)
static IndexMask from_bits (BitSpan bits, IndexMaskMemory &memory)
static IndexMask from_bits (const IndexMask &universe, BitSpan bits, IndexMaskMemory &memory)
static IndexMask from_bools (Span< bool > bools, IndexMaskMemory &memory)
static IndexMask from_bools (const VArray< bool > &bools, IndexMaskMemory &memory)
static IndexMask from_bools (const IndexMask &universe, Span< bool > bools, IndexMaskMemory &memory)
static IndexMask from_bools (const IndexMask &universe, const VArray< bool > &bools, IndexMaskMemory &memory)
static IndexMask from_bools_inverse (const VArray< bool > &bools, IndexMaskMemory &memory)
static IndexMask from_bools_inverse (const IndexMask &universe, Span< bool > bools, IndexMaskMemory &memory)
static IndexMask from_bools_inverse (const IndexMask &universe, const VArray< bool > &bools, IndexMaskMemory &memory)
template<typename T>
static IndexMask from_ranges (OffsetIndices< T > offsets, const IndexMask &mask, IndexMaskMemory &memory)
static IndexMask from_repeating (const IndexMask &mask_to_repeat, int64_t repetitions, int64_t stride, int64_t initial_offset, IndexMaskMemory &memory)
static IndexMask from_every_nth (int64_t n, int64_t indices_num, const int64_t initial_offset, IndexMaskMemory &memory)
static IndexMask from_segments (Span< IndexMaskSegment > segments, IndexMaskMemory &memory)
static IndexMask from_initializers (const Span< Initializer > initializers, IndexMaskMemory &memory)
static IndexMask from_union (const IndexMask &mask_a, const IndexMask &mask_b, IndexMaskMemory &memory)
static IndexMask from_union (Span< IndexMask > masks, IndexMaskMemory &memory)
static IndexMask from_difference (const IndexMask &mask_a, const IndexMask &mask_b, IndexMaskMemory &memory)
static IndexMask from_intersection (const IndexMask &mask_a, const IndexMask &mask_b, IndexMaskMemory &memory)
static IndexMask from_batch_predicate (const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, FunctionRef< int64_t(const IndexMaskSegment &universe_segment, IndexRangesBuilder< int16_t > &builder)> batch_predicate)
static Vector< IndexMask, 4 > from_group_ids (const VArray< int > &group_ids, IndexMaskMemory &memory, VectorSet< int > &r_index_by_group_id)
static Vector< IndexMask, 4 > from_group_ids (const IndexMask &universe, const VArray< int > &group_ids, IndexMaskMemory &memory, VectorSet< int > &r_index_by_group_id)
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<typename Fn>
void foreach_index (Fn &&fn) const
template<typename Fn>
void foreach_index (GrainSize grain_size, Fn &&fn) const
template<typename IndexT, typename Fn>
void foreach_index_optimized (Fn &&fn) const
template<typename IndexT, typename Fn>
void foreach_index_optimized (GrainSize grain_size, Fn &&fn) const
template<typename Fn>
void foreach_segment (Fn &&fn) const
template<typename Fn>
void foreach_segment (GrainSize grain_size, Fn &&fn) const
template<typename Fn>
void foreach_segment_optimized (Fn &&fn) const
template<typename Fn>
void foreach_segment_optimized (GrainSize grain_size, Fn &&fn) const
template<typename Fn>
void foreach_range (Fn &&fn) const
std::optional< IndexRangeto_range () const
template<int64_t N = 4>
Vector< std::variant< IndexRange, IndexMaskSegment >, Nto_spans_and_ranges () const
IndexMaskData & data_for_inplace_construction ()
template<typename Fn>
static IndexMask from_predicate (const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
template<typename T, typename Fn>
static void from_groups (const IndexMask &universe, IndexMaskMemory &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 optional GrainSize argument. When that is provided, multi-threading is used when appropriate. 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 188 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 251 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 660 of file BLI_index_mask.hh.

◆ 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 665 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 678 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 714 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 404 of file index_mask.cc.

◆ contains()

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

Definition at line 941 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 806 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 873 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 883 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 909 of file index_mask.cc.

◆ first()

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

Definition at line 724 of file BLI_index_mask.hh.

◆ foreach_index() [1/2]

template<typename Fn>
void blender::index_mask::IndexMask::foreach_index ( Fn && fn) 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 816 of file BLI_index_mask.hh.

◆ foreach_index() [2/2]

template<typename Fn>
void blender::index_mask::IndexMask::foreach_index ( GrainSize grain_size,
Fn && fn ) const
inline

Definition at line 834 of file BLI_index_mask.hh.

◆ foreach_index_optimized() [1/2]

template<typename IndexT, typename Fn>
void blender::index_mask::IndexMask::foreach_index_optimized ( Fn && fn) 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 898 of file BLI_index_mask.hh.

◆ foreach_index_optimized() [2/2]

template<typename IndexT, typename Fn>
void blender::index_mask::IndexMask::foreach_index_optimized ( GrainSize grain_size,
Fn && fn ) const
inline

Definition at line 912 of file BLI_index_mask.hh.

◆ foreach_range()

template<typename Fn>
void blender::index_mask::IndexMask::foreach_range ( Fn && 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 1003 of file BLI_index_mask.hh.

◆ foreach_segment() [1/2]

template<typename Fn>
void blender::index_mask::IndexMask::foreach_segment ( Fn && fn) const
inline

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]

Definition at line 970 of file BLI_index_mask.hh.

◆ foreach_segment() [2/2]

template<typename Fn>
void blender::index_mask::IndexMask::foreach_segment ( GrainSize grain_size,
Fn && fn ) const
inline

Definition at line 986 of file BLI_index_mask.hh.

◆ foreach_segment_optimized() [1/2]

template<typename Fn>
void blender::index_mask::IndexMask::foreach_segment_optimized ( Fn && fn) 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 928 of file BLI_index_mask.hh.

◆ foreach_segment_optimized() [2/2]

template<typename Fn>
void blender::index_mask::IndexMask::foreach_segment_optimized ( GrainSize grain_size,
Fn && fn ) const
inline

Definition at line 953 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 1078 of file index_mask.cc.

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

◆ from_batch_predicate()

IndexMask blender::index_mask::IndexMask::from_batch_predicate ( const IndexMask & universe,
GrainSize grain_size,
IndexMaskMemory & memory,
FunctionRef< int64_t(const IndexMaskSegment &universe_segment, IndexRangesBuilder< int16_t > &builder)> batch_predicate )
static

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 553 of file index_mask.cc.

◆ 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 482 of file index_mask.cc.

◆ from_bools() [1/4]

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

Definition at line 637 of file index_mask.cc.

◆ from_bools() [2/4]

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

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

Definition at line 599 of file index_mask.cc.

◆ from_bools() [3/4]

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

Definition at line 589 of file index_mask.cc.

◆ from_bools() [4/4]

Construct a mask from the true indices.

Definition at line 584 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(), BKE_pbvh_bmesh_after_stroke(), blender::bke::pbvh::bmesh_update_topology(), blender::build_drawing(), blender::ed::spreadsheet::calc_mesh_selection_mask(), blender::ed::sculpt_paint::face_set::clear_face_sets(), blender::ed::transform::pointcloud::createTransPointCloudVerts(), blender::deform_drawing(), blender::ed::sculpt_paint::CombOperationExecutor::execute(), blender::ed::sculpt_paint::DeleteOperationExecutor::execute(), blender::ed::sculpt_paint::PinchOperationExecutor::execute(), blender::ed::sculpt_paint::face_set::face_sets_update(), blender::ed::sculpt_paint::hide::flush_face_changes_node(), blender::ed::sculpt_paint::mask::gesture_apply_for_symmetry_pass(), blender::ed::sculpt_paint::face_set::gesture_apply_mesh(), 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::fn::index_mask_from_selection(), blender::geometry::mapped_corner_selection_from_face(), blender::bke::mesh_select_edge_flush(), blender::bke::mesh_select_vert_flush(), 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::sculpt_paint::mask::sculpt_mask_filter_exec(), blender::ed::sculpt_paint::greasepencil::simplify_stroke(), blender::ed::sculpt_paint::expand::update_for_vert(), blender::ed::sculpt_paint::mask::update_mask_mesh(), and blender::geometry::vert_selection_from_edge().

◆ from_bools_inverse() [1/3]

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

Definition at line 653 of file index_mask.cc.

◆ from_bools_inverse() [2/3]

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

Definition at line 628 of file index_mask.cc.

◆ from_bools_inverse() [3/3]

◆ 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,
IndexMaskMemory & memory )
static

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

Definition at line 1069 of file index_mask.cc.

◆ from_group_ids() [1/2]

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

Definition at line 1185 of file index_mask.cc.

◆ from_group_ids() [2/2]

◆ from_groups()

template<typename T, typename Fn>
void blender::index_mask::IndexMask::from_groups ( const IndexMask & universe,
IndexMaskMemory & 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,
IndexMaskMemory & memory )
static

Construct a mask from unique sorted indices.

Definition at line 412 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::index_mask::IndexMask::from_groups(), 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::greasepencil::polyline_detect_corners(), blender::ed::geometry::store_result_geometry(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::ed::curves::tests::TEST(), blender::fn::multi_function::tests::TEST(), blender::fn::multi_function::tests::TEST(), blender::fn::multi_function::tests::TEST(), blender::fn::multi_function::tests::TEST(), blender::fn::tests::TEST(), blender::fn::tests::TEST(), blender::fn::tests::TEST(), blender::fn::tests::TEST(), blender::fn::tests::TEST(), blender::fn::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::ed::sculpt_paint::expand::topology_falloff_create().

◆ from_initializers()

◆ from_intersection()

◆ from_predicate()

template<typename Fn>
IndexMask blender::index_mask::IndexMask::from_predicate ( const IndexMask & universe,
GrainSize grain_size,
IndexMaskMemory & memory,
Fn && predicate )
inlinestatic

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

Definition at line 1031 of file BLI_index_mask.hh.

Referenced by blender::ed::spreadsheet::apply_filter_operation(), 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::draw::calc_mesh_edge_visibility(), blender::ed::spreadsheet::calc_mesh_selection_mask(), blender::ed::spreadsheet::calc_mesh_selection_mask_faces(), blender::draw::calc_vert_visibility_mesh(), blender::geometry::convert_bezier_or_catmull_rom_to_poly_before_conversion_to_nurbs(), blender::ed::transform::curves::create_aligned_handles_masks(), blender::ed::curves::curve_mask_from_points(), blender::bke::curves_copy_point_selection(), 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_face_dots_bm(), blender::ed::curves::pen_tool::extrude_curves(), blender::geometry::face_selection_from_mapped_corner(), blender::ed::sculpt_paint::greasepencil::InterpolateOpData::from_operator(), blender::modifier::greasepencil::get_filtered_layer_mask(), blender::modifier::greasepencil::get_filtered_stroke_mask(), blender::ed::greasepencil::get_visible_boundary_strokes(), blender::draw::grease_pencil_get_visible_non_nurbs_curves(), blender::draw::grease_pencil_get_visible_nurbs_curves(), blender::draw::grease_pencil_get_visible_nurbs_points(), 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::ed::sculpt_paint::greasepencil::GreasePencilStrokeOperationCommon::init_auto_masking(), blender::ed::curves::pen_tool::insert_point_to_curve(), blender::bke::calc_edges::mask_first_distinct_edges(), blender::ed::sculpt_paint::hide::mesh_show_all(), blender::bke::CurvesGeometry::nurbs_custom_knot_curves(), 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_points(), blender::ed::greasepencil::retrieve_visible_strokes(), blender::ed::pointcloud::select_box(), blender::ed::pointcloud::select_circle(), blender::ed::pointcloud::select_lasso(), blender::simplify_drawing(), blender::ed::greasepencil::simplify_fixed(), blender::ed::sculpt_paint::simplify_fixed(), blender::simplify_fixed(), and blender::ed::curves::convert_to_particle_system::try_convert_single_object().

◆ 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,
IndexMaskMemory & 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 994 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 286 of file index_mask.cc.

◆ from_union() [1/2]

◆ from_union() [2/2]

Constructs a mask from the union of multiple masks.

Definition at line 689 of file index_mask.cc.

◆ index_range()

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

Definition at line 709 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 746 of file BLI_index_mask.hh.

◆ is_empty()

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

Definition at line 704 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 760 of file BLI_index_mask.hh.

◆ last()

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

Definition at line 730 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 738 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 777 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 771 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 787 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 782 of file BLI_index_mask.hh.

◆ set_bits()

Set the bits at indices in the mask to 1.

Definition at line 757 of file index_mask.cc.

◆ shift()

Adds an offset to every index in the mask.

Definition at line 203 of file index_mask.cc.

◆ size()

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

Definition at line 699 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 801 of file BLI_index_mask.hh.

◆ slice() [2/3]

Definition at line 123 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 142 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 182 of file index_mask.cc.

◆ slice_and_shift() [2/2]

Definition at line 189 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 158 of file index_mask.cc.

◆ slice_content() [2/2]

Definition at line 163 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 776 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 783 of file index_mask.cc.

◆ to_indices()

template<typename T>
template 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 748 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 1077 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 791 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 798 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 1091 of file BLI_index_mask.hh.

◆ operator!=

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

Definition at line 1098 of file BLI_index_mask.hh.

◆ operator==

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

Definition at line 1164 of file index_mask.cc.


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