Blender  V3.3
Public Member Functions | Protected Attributes | List of all members
blender::bke::AttributeAccessor Class Reference

#include <BKE_attribute.hh>

Inheritance diagram for blender::bke::AttributeAccessor:
blender::bke::MutableAttributeAccessor

Public Member Functions

 AttributeAccessor (const void *owner, const AttributeAccessorFunctions &fn)
 
bool contains (const AttributeIDRef &attribute_id) const
 
std::optional< AttributeMetaDatalookup_meta_data (const AttributeIDRef &attribute_id) const
 
bool domain_supported (const eAttrDomain domain) const
 
int domain_size (const eAttrDomain domain) const
 
bool is_builtin (const AttributeIDRef &attribute_id) const
 
GAttributeReader lookup (const AttributeIDRef &attribute_id) const
 
GVArray lookup (const AttributeIDRef &attribute_id, const eAttrDomain domain) const
 
GVArray lookup (const AttributeIDRef &attribute_id, const eCustomDataType data_type) const
 
template<typename T >
VArray< Tlookup (const AttributeIDRef &attribute_id, const std::optional< eAttrDomain > domain=std::nullopt) const
 
template<typename T >
VArray< Tlookup_or_default (const AttributeIDRef &attribute_id, const eAttrDomain domain, const T &default_value) const
 
GVArray adapt_domain (const GVArray &varray, const eAttrDomain from_domain, const eAttrDomain to_domain) const
 
template<typename T >
VArray< Tadapt_domain (const VArray< T > &varray, const eAttrDomain from_domain, const eAttrDomain to_domain) const
 
bool for_all (const AttributeForeachCallback fn) const
 
Geometry Component
GVArray lookup (const AttributeIDRef &attribute_id, const std::optional< eAttrDomain > domain, const std::optional< eCustomDataType > data_type) const
 
GVArray lookup_or_default (const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type, const void *default_value=nullptr) const
 
Set< AttributeIDRefall_ids () const
 

Protected Attributes

voidowner_
 
const AttributeAccessorFunctionsfn_
 

Detailed Description

Provides read-only access to the set of attributes on some geometry.

Note, this does not own the attributes. When the owner is freed, it is invalid to access its attributes.

Definition at line 349 of file BKE_attribute.hh.

Constructor & Destructor Documentation

◆ AttributeAccessor()

blender::bke::AttributeAccessor::AttributeAccessor ( const void owner,
const AttributeAccessorFunctions fn 
)
inline

Definition at line 368 of file BKE_attribute.hh.

Member Function Documentation

◆ adapt_domain() [1/2]

GVArray blender::bke::AttributeAccessor::adapt_domain ( const GVArray varray,
const eAttrDomain  from_domain,
const eAttrDomain  to_domain 
) const
inline

◆ adapt_domain() [2/2]

template<typename T >
VArray<T> blender::bke::AttributeAccessor::adapt_domain ( const VArray< T > &  varray,
const eAttrDomain  from_domain,
const eAttrDomain  to_domain 
) const
inline

Interpolate data from one domain to another.

Definition at line 501 of file BKE_attribute.hh.

References adapt_domain(), T, and blender::GVArray::typed().

◆ all_ids()

Set< AttributeIDRef > blender::bke::AttributeAccessor::all_ids ( ) const

◆ contains()

bool blender::bke::AttributeAccessor::contains ( const AttributeIDRef attribute_id) const
inline

◆ domain_size()

int blender::bke::AttributeAccessor::domain_size ( const eAttrDomain  domain) const
inline

◆ domain_supported()

bool blender::bke::AttributeAccessor::domain_supported ( const eAttrDomain  domain) const
inline
Returns
True, when attributes can exist on that domain.

Definition at line 392 of file BKE_attribute.hh.

References blender::bke::AttributeAccessorFunctions::domain_supported, fn_, and owner_.

Referenced by compute_attributes_to_store().

◆ for_all()

bool blender::bke::AttributeAccessor::for_all ( const AttributeForeachCallback  fn) const
inline

◆ is_builtin()

bool blender::bke::AttributeAccessor::is_builtin ( const AttributeIDRef attribute_id) const
inline
Returns
True, when the attribute has a special meaning for Blender and can't be used for arbitrary things.

Definition at line 409 of file BKE_attribute.hh.

References fn_, blender::bke::AttributeAccessorFunctions::is_builtin, and owner_.

Referenced by blender::geometry::create_curve_from_vert_indices(), blender::bke::get_attribute_domain_for_mesh(), blender::geometry::retrieve_generic_point_attributes(), and blender::bke::should_add_attribute_to_mesh().

◆ lookup() [1/5]

GAttributeReader blender::bke::AttributeAccessor::lookup ( const AttributeIDRef attribute_id) const
inline

Get read-only access to the attribute. If the attribute does not exist, the return value is empty.

Definition at line 418 of file BKE_attribute.hh.

References fn_, blender::bke::AttributeAccessorFunctions::lookup, and owner_.

Referenced by blender::nodes::node_geo_delete_geometry_cc::copy_attributes(), blender::nodes::node_geo_delete_geometry_cc::copy_attributes_based_on_map(), blender::nodes::node_geo_delete_geometry_cc::copy_attributes_based_on_mask(), copy_attributes_between_components(), blender::nodes::node_geo_duplicate_elements_cc::copy_attributes_without_id(), blender::nodes::node_geo_duplicate_elements_cc::copy_curve_attributes_without_id(), blender::nodes::node_geo_duplicate_elements_cc::copy_edge_attributes_without_id(), blender::nodes::node_geo_duplicate_elements_cc::copy_face_attributes_without_id(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_curves(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_edges(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_faces(), blender::nodes::node_geo_duplicate_elements_cc::copy_stable_id_point(), blender::geometry::create_curve_from_vert_indices(), blender::bke::curve_to_mesh_sweep(), blender::ed::sculpt_paint::AddOperationExecutor::execute(), blender::ed::sculpt_paint::DensityAddOperationExecutor::execute(), blender::ed::sculpt_paint::SlideOperationExecutor::execute(), face_corner_color_equalize_vertices(), blender::ed::spreadsheet::GeometryDataSource::get_column_values(), lookup(), lookup_or_default(), mesh_calc_modifiers(), blender::nodes::node_geo_deform_curves_on_surface_cc::node_geo_exec(), blender::geometry::point_merge_by_distance(), blender::geometry::preprocess_curves(), blender::geometry::preprocess_meshes(), blender::geometry::preprocess_pointclouds(), blender::nodes::node_geo_distribute_points_on_faces_cc::propagate_existing_attributes(), blender::bke::retrieve_attributes_for_transfer(), blender::geometry::retrieve_generic_point_attributes(), blender::ed::curves::snap_curves_to_surface::snap_curves_to_surface_exec_object(), blender::nodes::node_geo_dual_mesh_cc::transfer_attributes(), and vertex_paint_from_weight().

◆ lookup() [2/5]

GVArray blender::bke::AttributeAccessor::lookup ( const AttributeIDRef attribute_id,
const eAttrDomain  domain 
) const
inline

Get read-only access to the attribute whereby the attribute is interpolated to the given domain. The result may be empty.

Definition at line 435 of file BKE_attribute.hh.

References lookup().

◆ lookup() [3/5]

GVArray blender::bke::AttributeAccessor::lookup ( const AttributeIDRef attribute_id,
const eCustomDataType  data_type 
) const
inline

Get read-only access to the attribute whereby the attribute is converted to the given type. The result may be empty.

Definition at line 444 of file BKE_attribute.hh.

References lookup().

◆ lookup() [4/5]

GVArray blender::bke::AttributeAccessor::lookup ( const AttributeIDRef attribute_id,
const std::optional< eAttrDomain domain,
const std::optional< eCustomDataType data_type 
) const

Get read-only access to the attribute. If necessary, the attribute is interpolated to the given domain, and converted to the given type, in that order. The result may be empty.

Definition at line 925 of file attribute_access.cc.

References adapt_domain(), attribute, blender::bke::custom_data_type_to_cpp_type(), lookup(), blender::bke::try_adapt_data_type(), blender::GVArrayCommon::type(), and type.

◆ lookup() [5/5]

template<typename T >
VArray<T> blender::bke::AttributeAccessor::lookup ( const AttributeIDRef attribute_id,
const std::optional< eAttrDomain domain = std::nullopt 
) const
inline

Get read-only access to the attribute. If necessary, the attribute is interpolated to the given domain and then converted to the given type, in that order. The result may be empty.

Definition at line 454 of file BKE_attribute.hh.

References blender::bke::cpp_type_to_custom_data_type(), lookup(), T, and blender::bke::GAttributeReader::typed().

◆ lookup_meta_data()

std::optional<AttributeMetaData> blender::bke::AttributeAccessor::lookup_meta_data ( const AttributeIDRef attribute_id) const
inline

◆ lookup_or_default() [1/2]

GVArray blender::bke::AttributeAccessor::lookup_or_default ( const AttributeIDRef attribute_id,
const eAttrDomain  domain,
const eCustomDataType  data_type,
const void default_value = nullptr 
) const

Get read-only access to the attribute. If necessary, the attribute is interpolated to the given domain and then converted to the given data type, in that order. If the attribute does not exist, a virtual array with the given default value is returned. If the passed in default value is null, the default value of the type is used (generally 0).

Definition at line 954 of file attribute_access.cc.

References blender::bke::custom_data_type_to_cpp_type(), domain_size(), blender::GVArray::ForSingle(), blender::GVArray::ForSingleRef(), lookup(), and type.

Referenced by BKE_bvhtree_from_pointcloud_get(), BKE_pointcloud_from_mesh(), blender::bke::curve_to_mesh_sweep(), curves_batch_ensure_attribute(), curves_to_curve_eval(), ED_geometry_attribute_convert(), blender::ed::geometry::geometry_attribute_convert_exec(), point_cloud_bounds(), blender::geometry::point_merge_by_distance(), blender::geometry::preprocess_curves(), blender::geometry::preprocess_meshes(), blender::geometry::preprocess_pointclouds(), and blender::io::obj::OBJWriter::write_vertex_coords().

◆ lookup_or_default() [2/2]

template<typename T >
VArray<T> blender::bke::AttributeAccessor::lookup_or_default ( const AttributeIDRef attribute_id,
const eAttrDomain  domain,
const T default_value 
) const
inline

Same as the generic version above, but should be used when the type is known at compile time.

Definition at line 477 of file BKE_attribute.hh.

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

Member Data Documentation

◆ fn_

const AttributeAccessorFunctions* blender::bke::AttributeAccessor::fn_
protected

◆ owner_

void* blender::bke::AttributeAccessor::owner_
protected

The data that actually owns the attributes, for example, a pointer to a Mesh or PointCloud Most commonly this is a pointer to a Mesh or PointCloud. Under some circumstances this can be null. In that case most methods can't be used. Allowed methods are domain_size, for_all and is_builtin. We could potentially make these methods accessible without AttributeAccessor and then owner_ could always be non-null.

Note
This class cannot modify the owner's attributes, but the pointer is still non-const, so this class can be a base class for the mutable version.

Definition at line 361 of file BKE_attribute.hh.

Referenced by adapt_domain(), blender::bke::MutableAttributeAccessor::add(), contains(), domain_size(), domain_supported(), for_all(), is_builtin(), lookup(), blender::bke::MutableAttributeAccessor::lookup_for_write(), lookup_meta_data(), and blender::bke::MutableAttributeAccessor::remove().


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