Blender
V3.3
|
#include <BLI_index_mask.hh>
Static Public Member Functions | |
static bool | indices_are_valid_index_mask (Span< int64_t > indices) |
Definition at line 32 of file BLI_index_mask.hh.
|
default |
Creates an IndexMask that contains no indices.
Referenced by slice(), and slice_and_offset().
Create an IndexMask using the given integer array. This constructor asserts that the given integers are in ascending order and that there are no duplicates.
Definition at line 46 of file BLI_index_mask.hh.
References BLI_assert, indices(), and indices_are_valid_index_mask().
|
inline |
Use this method when you know that no indices are skipped. It is more efficient than preparing an integer array all the time.
Definition at line 55 of file BLI_index_mask.hh.
|
inline |
Construct an IndexMask from a sorted list of indices. Note, the created IndexMask is only valid as long as the initializer_list is valid.
Don't do this: IndexMask mask = {3, 4, 5};
Do this: do_something_with_an_index_mask({3, 4, 5});
Definition at line 69 of file BLI_index_mask.hh.
|
inlineexplicit |
Creates an IndexMask that references the indices [0, n-1].
Definition at line 76 of file BLI_index_mask.hh.
|
inline |
Returns the IndexRange referenced by this IndexMask. This method should only be called after the caller made sure that this IndexMask is actually a range.
Definition at line 151 of file BLI_index_mask.hh.
References BLI_assert, blender::Span< T >::first(), is_range(), and blender::Span< T >::size().
Referenced by blender::fn::materialize_detail::execute_materialized(), blender::nodes::node_geo_extrude_mesh_cc::save_selection_as_attribute(), and to_best_mask_type().
|
inline |
Definition at line 101 of file BLI_index_mask.hh.
References blender::Span< T >::begin().
|
inline |
Definition at line 226 of file BLI_index_mask.hh.
References blender::IndexRange::first(), blender::Span< T >::first(), blender::Span< T >::is_empty(), blender::IndexRange::last(), blender::Span< T >::last(), blender::IndexRange::size(), and blender::Span< T >::size().
Referenced by extract_ranges_invert(), and invert().
|
inline |
Definition at line 106 of file BLI_index_mask.hh.
References blender::Span< T >::end().
Vector< IndexRange > blender::IndexMask::extract_ranges | ( | ) | const |
Get all contiguous index ranges within the mask.
Definition at line 59 of file index_mask.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), is_range(), blender::Span< T >::size(), and slice().
Referenced by extract_ranges_invert(), and blender::tests::TEST().
Vector< IndexRange > blender::IndexMask::extract_ranges_invert | ( | const IndexRange | full_range, |
Vector< int64_t > * | r_skip_amounts = nullptr |
||
) | const |
Similar to extract ranges, but works on the inverted mask. So the returned ranges are in-between the indices in the mask.
Using this method is generally more efficient than first inverting the index mask and then extracting the ranges.
If #r_skip_amounts is passed in, it will contain the number of indices that have been skipped before each range in the return value starts.
Definition at line 100 of file index_mask.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BLI_assert, contained_in(), extract_ranges(), blender::Vector< T, InlineBufferCapacity, Allocator >::index_range(), blender::IndexRange::one_after_last(), blender::IndexRange::size(), and blender::IndexRange::start().
Referenced by blender::bke::copy_with_removed_curves(), blender::bke::copy_with_removed_points(), blender::ed::sculpt_paint::DeleteOperationExecutor::execute(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::geometry::fillet_curves(), invert(), blender::geometry::resample_to_evaluated(), blender::geometry::resample_to_uniform(), blender::geometry::subdivide_curves(), and blender::tests::TEST().
|
inline |
Calls the given callback for every referenced index. The callback has to take one unsigned integer as parameter.
This method implements different code paths for the cases when the IndexMask represents a range or not.
Definition at line 164 of file BLI_index_mask.hh.
References callback, mask(), and to_best_mask_type().
|
inline |
Returns an IndexRange that can be used to index this IndexMask.
The range is [0, number of indices - 1].
This is not to be confused with the as_range
method.
Definition at line 200 of file BLI_index_mask.hh.
References blender::Span< T >::index_range().
Referenced by blender::nodes::node_geo_duplicate_elements_cc::accumulate_counts_to_offsets(), blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::geometry::calculate_result_offsets(), blender::ed::sculpt_paint::CombOperationExecutor::comb_projected(), blender::geometry::convert_curves_to_bezier(), blender::geometry::convert_curves_to_nurbs(), blender::nodes::node_geo_duplicate_elements_cc::copy_curve_attributes_without_id(), blender::bke::curves::copy_point_data(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_curves(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_faces(), blender::ed::sculpt_paint::DeleteOperationExecutor::delete_projected(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_faces(), blender::geometry::duplicate_fillet_point_data(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_instances(), blender::bke::CurvesGeometry::evaluated_tangents(), blender::nodes::node_geo_extrude_mesh_cc::extrude_individual_mesh_faces(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_edges(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_vertices(), blender::bke::curves::fill_points(), blender::geometry::fillet_curves(), blender::ed::sculpt_paint::PuffOperationExecutor::find_curve_weights_projected(), blender::index_mask_ops::find_indices_based_on_predicate(), blender::index_mask_ops::find_indices_from_virtual_array(), blender::ed::sculpt_paint::SmoothOperationExecutor::find_projected_smooth_factors(), blender::nodes::node_geo_flip_faces_cc::mesh_flip_faces(), blender::ed::sculpt_paint::PinchOperationExecutor::pinch_projected(), blender::geometry::point_merge_by_distance(), blender::geometry::resample_to_evaluated(), blender::geometry::resample_to_uniform(), blender::bke::reverse_curve_point_data(), blender::bke::reverse_swap_curve_point_data(), blender::nodes::node_geo_rotate_instances_cc::rotate_instances(), blender::nodes::node_geo_scale_instances_cc::scale_instances(), blender::nodes::node_geo_set_position_cc::set_computed_position_and_offset(), blender::nodes::node_geo_set_curve_handles_cc::set_position_in_component(), blender::geometry::subdivide_attribute_catmull_rom(), blender::geometry::subdivide_attribute_linear(), blender::geometry::subdivide_curves(), and blender::nodes::node_geo_translate_instances_cc::translate_instances().
Definition at line 134 of file BLI_index_mask.hh.
Referenced by blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_edges(), IndexMask(), indices_are_valid_index_mask(), and blender::tests::TEST().
|
inlinestatic |
Checks that the indices are non-negative and in ascending order.
Definition at line 81 of file BLI_index_mask.hh.
References blender::Span< T >::first(), indices(), blender::Span< T >::is_empty(), and blender::Span< T >::size().
Referenced by blender::fn::InstructionScheduler::add_owned_indices(), and IndexMask().
IndexMask blender::IndexMask::invert | ( | const IndexRange | full_range, |
Vector< int64_t > & | r_new_indices | ||
) | const |
Get a new mask that contains all the indices that are not in the current mask. If necessary, the indices referenced by the new mask are inserted in #r_new_indices.
Definition at line 39 of file index_mask.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::as_span(), BLI_assert, blender::Vector< T, InlineBufferCapacity, Allocator >::clear(), contained_in(), extract_ranges_invert(), blender::Span< T >::is_empty(), blender::IndexRange::size(), and blender::Span< T >::size().
Referenced by blender::tests::TEST().
|
inline |
Definition at line 221 of file BLI_index_mask.hh.
References blender::Span< T >::is_empty().
Referenced by blender::nodes::node_geo_instance_on_points_cc::add_instances_from_component(), blender::ed::spreadsheet::GeometryDataSource::apply_selection_filter(), blender::nodes::node_geo_uv_unwrap_cc::construct_uv_gvarray(), blender::nodes::node_geo_uv_pack_islands_cc::construct_uv_gvarray(), blender::nodes::node_geo_instances_to_points_cc::convert_instances_to_points(), blender::nodes::node_geo_delete_geometry_cc::delete_curves_selection(), blender::nodes::node_geo_delete_geometry_cc::delete_selected_instances(), blender::bke::CurvesGeometry::evaluated_tangents(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_edges(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_face_regions(), blender::nodes::node_geo_input_shortest_edge_paths_cc::ShortestEdgePathsNextVertFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_shortest_edge_paths_cc::ShortestEdgePathsCostFieldInput::get_varray_for_context(), blender::nodes::node_geo_merge_by_distance_cc::mesh_merge_by_distance_all(), blender::nodes::node_geo_curve_reverse_cc::node_geo_exec(), blender::nodes::node_geo_curve_spline_type_cc::node_geo_exec(), blender::nodes::node_geo_merge_by_distance_cc::pointcloud_merge_by_distance(), blender::bke::CurvesGeometry::remove_curves(), blender::bke::CurvesGeometry::remove_points(), blender::nodes::node_geo_delete_geometry_cc::separate_point_cloud_selection(), and blender::tests::TEST().
|
inline |
Returns true if this IndexMask does not skip any indices. This check requires O(1) time.
Definition at line 142 of file BLI_index_mask.hh.
References blender::Span< T >::first(), blender::Span< T >::last(), and blender::Span< T >::size().
Referenced by as_range(), blender::fn::materialize_detail::execute_materialized(), extract_ranges(), blender::nodes::node_geo_extrude_mesh_cc::save_selection_as_attribute(), blender::tests::TEST(), and to_best_mask_type().
|
inline |
Returns the largest index that is referenced by this IndexMask.
Definition at line 208 of file BLI_index_mask.hh.
References blender::Span< T >::last().
|
inline |
Returns the minimum size an array has to have, if the integers in this IndexMask are going to be used as indices in that array.
Definition at line 124 of file BLI_index_mask.hh.
References blender::Span< T >::last(), and blender::Span< T >::size().
Referenced by blender::fn::MultiFunction::call_auto(), blender::bke::mesh_surface_sample::MeshAttributeInterpolator::ensure_barycentric_coords(), blender::fn::VariableState::ensure_is_mutable(), and blender::bke::mesh_surface_sample::MeshAttributeInterpolator::ensure_nearest_weights().
Definition at line 96 of file BLI_index_mask.hh.
Returns the n-th index referenced by this IndexMask. The index_range
method returns an IndexRange containing all indices that can be used as parameter here.
Definition at line 115 of file BLI_index_mask.hh.
|
inline |
Returns the number of indices referenced by this IndexMask.
Definition at line 216 of file BLI_index_mask.hh.
References blender::Span< T >::size().
Referenced by blender::nodes::node_geo_duplicate_elements_cc::accumulate_counts_to_offsets(), blender::fn::VariableState::add_as_output(), blender::fn::VariableStates::add_initial_variable_states(), blender::nodes::node_geo_set_material_cc::assign_material_to_faces(), blender::nodes::node_geo_instances_to_points_cc::convert_instances_to_points(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_edges(), blender::bke::copy_with_removed_points(), blender::nodes::node_geo_duplicate_elements_cc::create_duplicate_index_attribute(), blender::nodes::node_geo_delete_geometry_cc::delete_curves_selection(), blender::fn::VariableState::destruct(), blender::nodes::node_geo_duplicate_elements_cc::duplicate_faces(), blender::fn::evaluate_as_one(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::ed::sculpt_paint::PuffOperationExecutor::execute(), blender::fn::materialize_detail::execute_materialized(), blender::fn::materialize_detail::execute_materialized_impl(), blender::nodes::node_geo_extrude_mesh_cc::extrude_individual_mesh_faces(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_edges(), blender::nodes::node_geo_extrude_mesh_cc::extrude_mesh_vertices(), blender::bke::CurvesGeometry::fill_curve_types(), blender::index_mask_ops::detail::find_indices_based_on_predicate__merge(), blender::nodes::node_geo_mesh_to_points_cc::geometry_set_mesh_to_points(), blender::nodes::node_geo_points_to_vertices_cc::geometry_set_points_to_vertices(), blender::length_parameterize::interpolate_to_masked(), blender::fn::VariableState::is_fully_initialized(), blender::geometry::mesh_merge_by_distance_all(), blender::nodes::node_geo_mesh_to_curve_cc::node_geo_exec(), blender::geometry::point_merge_by_distance(), blender::nodes::node_geo_scale_elements_cc::prepare_edge_islands(), blender::nodes::node_geo_scale_elements_cc::prepare_face_islands(), blender::bke::CurvesGeometry::remove_curves(), InstancesComponent::remove_instances(), blender::bke::CurvesGeometry::remove_points(), blender::nodes::node_geo_delete_geometry_cc::separate_point_cloud_selection(), slice(), slice_and_offset(), spreadsheet_main_region_draw(), blender::ed::spreadsheet::SpreadsheetLayoutDrawer::SpreadsheetLayoutDrawer(), blender::tests::TEST(), and blender::nodes::node_geo_duplicate_elements_cc::threaded_slice_fill().
IndexMask blender::IndexMask::slice | ( | IndexRange | slice | ) | const |
Definition at line 13 of file index_mask.cc.
References IndexMask(), slice(), and blender::Span< T >::slice().
Definition at line 8 of file index_mask.cc.
References size().
Referenced by extract_ranges(), slice(), and slice_and_offset().
IndexMask blender::IndexMask::slice_and_offset | ( | IndexRange | slice, |
Vector< int64_t > & | r_new_indices | ||
) | const |
Create a sub-mask that is also shifted to the beginning. The shifting to the beginning allows code to work with smaller indices, which is more memory efficient.
Example:
All the indices in the sub-mask are shifted by 3 towards zero, so that the first index in the output is zero.
Definition at line 18 of file index_mask.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::as_span(), IndexMask(), offset, blender::Vector< T, InlineBufferCapacity, Allocator >::resize(), size(), slice(), and blender::Span< T >::slice().
|
inline |
Often an IndexMask wraps a range of indices without any gaps. In this case, it is more efficient to compute the indices in a loop on-the-fly instead of reading them from memory. This method makes it easy to generate code for both cases.
The given function is expected to take one parameter that can either be of type #IndexRange or Span<int64_t>.
Definition at line 181 of file BLI_index_mask.hh.
References as_range(), and is_range().
Referenced by foreach_index(), and blender::length_parameterize::interpolate_to_masked().