Blender
V4.3
source
blender
blenkernel
BKE_attribute_filters.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#pragma once
6
7
#include "
BKE_anonymous_attribute_id.hh
"
8
#include "
BKE_attribute_filter.hh
"
9
10
#include "
BLI_set.hh
"
11
12
namespace
blender::bke
{
13
17
template
<
typename
Fn>
struct
AttributeFilterFromFunc
:
public
AttributeFilter
{
18
private
:
19
Fn fn_;
20
21
static_assert
(std::is_invocable_r_v<Result, Fn, StringRef>);
22
23
public
:
24
constexpr
AttributeFilterFromFunc
(Fn fn) : fn_(std::move(fn)) {}
25
26
Result
filter
(
const
StringRef
name)
const override
27
{
28
return
fn_(name);
29
}
30
};
31
36
inline
auto
attribute_filter_with_skip_ref
(
AttributeFilter
filter,
const
Span<StringRef>
skip)
37
{
38
return
AttributeFilterFromFunc
([filter, skip](
const
StringRef
name) {
39
if
(skip.
contains
(name)) {
40
return AttributeFilter::Result::AllowSkip;
41
}
42
return
filter.filter(name);
43
});
44
}
45
47
template
<
typename
StringT>
48
inline
auto
attribute_filter_with_skip_ref
(
AttributeFilter
filter,
const
Set<StringT>
&skip)
49
{
50
return
AttributeFilterFromFunc
([filter, &skip](
const
StringRef
name) {
51
if
(skip.
contains_as
(name)) {
52
return AttributeFilter::Result::AllowSkip;
53
}
54
return
filter.filter(name);
55
});
56
}
57
62
inline
auto
attribute_filter_from_skip_ref
(
const
Span<StringRef>
skip)
63
{
64
return
AttributeFilterFromFunc
([skip](
const
StringRef
name) {
65
if
(skip.
contains
(name)) {
66
return AttributeFilter::Result::AllowSkip;
67
}
68
return
AttributeFilter::Result::Process
;
69
});
70
}
71
73
template
<
typename
StringT>
inline
auto
attribute_filter_from_skip_ref
(
const
Set<StringT>
&skip)
74
{
75
return
AttributeFilterFromFunc
([&skip](
const
StringRef
name) {
76
if
(skip.
contains_as
(name)) {
77
return AttributeFilter::Result::AllowSkip;
78
}
79
return
AttributeFilter::Result::Process
;
80
});
81
}
82
83
}
// namespace blender::bke
BKE_anonymous_attribute_id.hh
BKE_attribute_filter.hh
BLI_set.hh
blender::Set
Definition
BLI_set.hh:106
blender::Set::contains_as
bool contains_as(const ForwardKey &key) const
Definition
BLI_set.hh:295
blender::Span
Definition
BLI_span.hh:75
blender::Span::contains
constexpr bool contains(const T &value) const
Definition
BLI_span.hh:278
blender::StringRef
Definition
BLI_string_ref.hh:128
blender::bke
Definition
AS_asset_library.hh:26
blender::bke::attribute_filter_from_skip_ref
auto attribute_filter_from_skip_ref(const Span< StringRef > skip)
Definition
BKE_attribute_filters.hh:62
blender::bke::attribute_filter_with_skip_ref
auto attribute_filter_with_skip_ref(AttributeFilter filter, const Span< StringRef > skip)
Definition
BKE_attribute_filters.hh:36
blender::bke::AttributeFilterFromFunc
Definition
BKE_attribute_filters.hh:17
blender::bke::AttributeFilterFromFunc::AttributeFilterFromFunc
constexpr AttributeFilterFromFunc(Fn fn)
Definition
BKE_attribute_filters.hh:24
blender::bke::AttributeFilterFromFunc::filter
Result filter(const StringRef name) const override
Definition
BKE_attribute_filters.hh:26
blender::bke::AttributeFilter
Definition
BKE_attribute_filter.hh:23
blender::bke::AttributeFilter::Result
Result
Definition
BKE_attribute_filter.hh:25
blender::bke::AttributeFilter::Result::Process
@ Process
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0