Lagrange
filter_attributes.h
1/*
2 * Copyright 2024 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/utils/BitField.h>
16
17#include <optional>
18#include <string>
19#include <variant>
20#include <vector>
21
22namespace lagrange {
23
32
37{
39 using AttributeNameOrId = std::variant<AttributeId, std::string>;
40
42 std::optional<std::vector<AttributeNameOrId>> included_attributes;
43
45 std::optional<std::vector<AttributeNameOrId>> excluded_attributes;
46
49
52
56 std::vector<AttributeFilter> or_filters;
57
61 std::vector<AttributeFilter> and_filters;
62};
63
75template <typename Scalar, typename Index>
76std::vector<AttributeId> filtered_attribute_ids(
78 const AttributeFilter& options);
79
98template <typename Scalar, typename Index>
100 SurfaceMesh<Scalar, Index> source_mesh,
101 const AttributeFilter& options = {});
102
106
107} // namespace lagrange
static constexpr BitField all()
Named constructor returning a bitfield set to 1.
Definition: BitField.h:76
SurfaceMesh< Scalar, Index > filter_attributes(SurfaceMesh< Scalar, Index > source_mesh, const AttributeFilter &options={})
Filters the attributes of mesh according to user specifications.
Definition: filter_attributes.cpp:116
std::vector< AttributeId > filtered_attribute_ids(const SurfaceMesh< Scalar, Index > &mesh, const AttributeFilter &options)
Create a list of attribute ids corresponding to the given filter.
Definition: filter_attributes.cpp:95
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Helper object to filter attributes based on name, id, usage or element type.
Definition: filter_attributes.h:37
std::vector< AttributeFilter > or_filters
If set, match all attributes that satisfy any of the filters in this list.
Definition: filter_attributes.h:56
std::optional< std::vector< AttributeNameOrId > > excluded_attributes
Optional list of attributes to exclude. If not provided, no attribute is excluded.
Definition: filter_attributes.h:45
BitField< AttributeElement > included_element_types
List of attribute element types to include. By default, all element types are included.
Definition: filter_attributes.h:51
BitField< AttributeUsage > included_usages
List of attribute usages to include. By default, all usages are included.
Definition: filter_attributes.h:48
std::variant< AttributeId, std::string > AttributeNameOrId
Variant identifying an attribute by its name or id.
Definition: filter_attributes.h:39
std::optional< std::vector< AttributeNameOrId > > included_attributes
Optional list of attributes to include. If not provided, all attributes are included.
Definition: filter_attributes.h:42
std::vector< AttributeFilter > and_filters
If set, match all attributes that satisfy all of the filters in this list.
Definition: filter_attributes.h:61