Blender V4.3
blender::VArray< T > Class Template Reference

#include <BLI_virtual_array.hh>

Inherits blender::VArrayCommon< T >.

Public Member Functions

 VArray ()=default
 
 VArray (const VArray &other)=default
 
 VArray (VArray &&other) noexcept=default
 
 VArray (const VArrayImpl< T > *impl)
 
 VArray (std::shared_ptr< const VArrayImpl< T > > impl)
 
 VArray (varray_tag::span, Span< T > span)
 
 VArray (varray_tag::single, T value, const int64_t size)
 
VArrayoperator= (const VArray &other)
 
VArrayoperator= (VArray &&other) noexcept
 
- Public Member Functions inherited from blender::VArrayCommon< T >
 operator bool () const
 
T operator[] (const int64_t index) const
 
T get (const int64_t index) const
 
int64_t size () const
 
T first () const
 
T last (const int64_t n=0) const
 
bool is_empty () const
 
IndexRange index_range () const
 
CommonVArrayInfo common_info () const
 
bool is_span () const
 
Span< Tget_internal_span () const
 
bool is_single () const
 
T get_internal_single () const
 
std::optional< Tget_if_single () const
 
void materialize (MutableSpan< T > r_span) const
 
void materialize (const IndexMask &mask, MutableSpan< T > r_span) const
 
void materialize_to_uninitialized (MutableSpan< T > r_span) const
 
void materialize_to_uninitialized (const IndexMask &mask, MutableSpan< T > r_span) const
 
void materialize_compressed (const IndexMask &mask, MutableSpan< T > r_span) const
 
void materialize_compressed_to_uninitialized (const IndexMask &mask, MutableSpan< T > r_span) const
 
bool try_assign_GVArray (GVArray &varray) const
 
const VArrayImpl< T > * get_implementation () const
 

Static Public Member Functions

template<typename ImplT , typename... Args>
static VArray For (Args &&...args)
 
static VArray ForSingle (T value, const int64_t size)
 
static VArray ForSpan (Span< T > values)
 
template<typename GetFunc >
static VArray ForFunc (const int64_t size, GetFunc get_func)
 
template<typename StructT , T(*)(const StructT &) GetFunc>
static VArray ForDerivedSpan (Span< StructT > values)
 
template<typename ContainerT >
static VArray ForContainer (ContainerT container)
 

Additional Inherited Members

- Protected Types inherited from blender::VArrayCommon< T >
using Storage = Any<blender::detail::VArrayAnyExtraInfo<T>, 24, 8>
 
- Protected Member Functions inherited from blender::VArrayCommon< T >
 VArrayCommon ()=default
 
 VArrayCommon (const VArrayCommon &other)
 
 VArrayCommon (VArrayCommon &&other) noexcept
 
 VArrayCommon (const VArrayImpl< T > *impl)
 
 VArrayCommon (std::shared_ptr< const VArrayImpl< T > > impl)
 
template<typename ImplT , typename... Args>
void emplace (Args &&...args)
 
void copy_from (const VArrayCommon &other)
 
void move_from (VArrayCommon &&other) noexcept
 
const VArrayImpl< T > * impl_from_storage () const
 
- Protected Attributes inherited from blender::VArrayCommon< T >
const VArrayImpl< T > * impl_ = nullptr
 
Storage storage_
 

Detailed Description

template<typename T>
class blender::VArray< T >

A VArray wraps a virtual array implementation and provides easy access to its elements. It can be copied and moved. While it is relatively small, it should still be passed by reference if possible (other than e.g. #Span).

Definition at line 9 of file BLI_virtual_array_fwd.hh.

Constructor & Destructor Documentation

◆ VArray() [1/7]

template<typename T >
blender::VArray< T >::VArray ( )
default

◆ VArray() [2/7]

template<typename T >
blender::VArray< T >::VArray ( const VArray< T > & other)
default

◆ VArray() [3/7]

template<typename T >
blender::VArray< T >::VArray ( VArray< T > && other)
defaultnoexcept

◆ VArray() [4/7]

template<typename T >
blender::VArray< T >::VArray ( const VArrayImpl< T > * impl)
inline

Definition at line 807 of file BLI_virtual_array.hh.

◆ VArray() [5/7]

template<typename T >
blender::VArray< T >::VArray ( std::shared_ptr< const VArrayImpl< T > > impl)
inline

Definition at line 809 of file BLI_virtual_array.hh.

◆ VArray() [6/7]

template<typename T >
blender::VArray< T >::VArray ( varray_tag::span ,
Span< T > span )
inline

Definition at line 811 of file BLI_virtual_array.hh.

References blender::VArrayCommon< T >::emplace().

◆ VArray() [7/7]

template<typename T >
blender::VArray< T >::VArray ( varray_tag::single ,
T value,
const int64_t size )
inline

Member Function Documentation

◆ For()

template<typename T >
template<typename ImplT , typename... Args>
static VArray blender::VArray< T >::For ( Args &&... args)
inlinestatic

Construct a new virtual array for a custom #VArrayImpl.

Definition at line 824 of file BLI_virtual_array.hh.

References blender::VArrayCommon< T >::emplace().

Referenced by blender::VArray< T >::ForContainer(), blender::VArray< T >::ForDerivedSpan(), and blender::VArray< T >::ForFunc().

◆ ForContainer()

template<typename T >
template<typename ContainerT >
static VArray blender::VArray< T >::ForContainer ( ContainerT container)
inlinestatic

Construct a new virtual array for an existing container. Every container that lays out the elements in a plain array works. This takes ownership of the passed in container. If that is not desired, use ForSpan instead.

Definition at line 876 of file BLI_virtual_array.hh.

References blender::VArray< T >::For().

Referenced by blender::draw::attribute_interpolate(), blender::nodes::node_geo_uv_pack_islands_cc::construct_uv_gvarray(), blender::nodes::node_geo_uv_unwrap_cc::construct_uv_gvarray(), blender::bke::curve_normals_varray(), blender::nodes::node_geo_curve_handle_type_selection_cc::HandleTypeFieldInput::get_varray_for_context(), blender::nodes::node_geo_curve_topology_curve_of_point_cc::CurveOfPointInput::get_varray_for_context(), blender::nodes::node_geo_curve_topology_points_of_curve_cc::PointsOfCurveInput::get_varray_for_context(), blender::nodes::node_geo_index_of_nearest_cc::HasNeighborFieldInput::get_varray_for_context(), blender::nodes::node_geo_index_of_nearest_cc::IndexOfNearestFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_curve_handles_cc::HandlePositionFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_edge_neighbors_cc::EdgeNeighborCountFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_vertex_neighbors_cc::VertexCountFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_vertex_neighbors_cc::VertexFaceCountFieldInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_edge_cc::CornersOfEdgeCountInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_edge_cc::CornersOfEdgeInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_face_cc::CornersOfFaceInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_vertex_cc::CornersOfVertCountInput::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::EdgesOfVertCountInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_edges_of_vertex_cc::EdgesOfVertInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_offset_corner_in_face_cc::OffsetCornerInFaceFieldInput::get_varray_for_context(), blender::nodes::node_geo_offset_point_in_curve_cc::ControlPointNeighborFieldInput::get_varray_for_context(), blender::nodes::node_geo_offset_point_in_curve_cc::OffsetValidFieldInput::get_varray_for_context(), blender::nodes::node_geo_tool_selection_cc::SculptSelectionFieldInput::get_varray_for_context(), blender::bke::mesh_normals_varray(), blender::nodes::node_geo_material_selection_cc::select_by_material(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::tests::TEST().

◆ ForDerivedSpan()

template<typename T >
template<typename StructT , T(*)(const StructT &) GetFunc>
static VArray blender::VArray< T >::ForDerivedSpan ( Span< StructT > values)
inlinestatic

Construct a new virtual array for an existing span with a mapping function. This does not take ownership of the span.

Definition at line 863 of file BLI_virtual_array.hh.

References blender::VArray< T >::For(), and blender::MutableSpan< T >::size().

Referenced by blender::bke::instance_position_varray().

◆ ForFunc()

template<typename T >
template<typename GetFunc >
static VArray blender::VArray< T >::ForFunc ( const int64_t size,
GetFunc get_func )
inlinestatic

Construct a new virtual that will invoke the provided function whenever an element is accessed.

Definition at line 853 of file BLI_virtual_array.hh.

References blender::VArray< T >::For(), and T.

Referenced by blender::ed::spreadsheet::GeometryDataSource::apply_selection_filter(), blender::bke::construct_curve_length_gvarray(), blender::nodes::node_geo_input_spline_length_cc::construct_curve_point_count_gvarray(), blender::nodes::node_geo_input_mesh_edge_vertices_cc::construct_edge_positions_gvarray(), blender::nodes::node_geo_input_mesh_edge_vertices_cc::construct_edge_verts_gvarray(), blender::nodes::node_geo_input_mesh_face_area_cc::construct_face_area_varray(), blender::ed::sculpt_paint::get_fill_boundary_layers(), blender::fn::IndexFieldInput::get_index_varray(), blender::bke::NamedLayerSelectionFieldInput::get_varray_for_context(), blender::fn::tests::IndexFieldInput::get_varray_for_context(), blender::nodes::node_geo_curve_topology_curve_of_point_cc::PointIndexInCurveInput::get_varray_for_context(), blender::nodes::node_geo_curve_topology_points_of_curve_cc::CurvePointCountInput::get_varray_for_context(), blender::nodes::node_geo_input_instance_rotation_cc::InstanceRotationFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_instance_scale_cc::InstanceScaleFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_edge_angle_cc::AngleFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_edge_angle_cc::SignedAngleFieldInput::get_varray_for_context(), blender::nodes::node_geo_input_mesh_face_is_planar_cc::PlanarFieldInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_corners_of_face_cc::CornersOfFaceCountInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_edges_of_corner_cc::CornerPreviousEdgeFieldInput::get_varray_for_context(), blender::nodes::node_geo_mesh_topology_face_of_corner_cc::CornerIndexInFaceInput::get_varray_for_context(), blender::ed::sculpt_paint::greasepencil::SmoothOperation::on_stroke_extended(), blender::tests::TEST(), blender::tests::TEST(), blender::tests::TEST(), and blender::io::grease_pencil::GreasePencilExporter::try_get_uniform_point_width().

◆ ForSingle()

◆ ForSpan()

◆ operator=() [1/2]

template<typename T >
VArray & blender::VArray< T >::operator= ( const VArray< T > & other)
inline

Definition at line 881 of file BLI_virtual_array.hh.

References blender::VArrayCommon< T >::copy_from().

◆ operator=() [2/2]

template<typename T >
VArray & blender::VArray< T >::operator= ( VArray< T > && other)
inlinenoexcept

Definition at line 887 of file BLI_virtual_array.hh.

References blender::VArrayCommon< T >::move_from().


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