Lagrange
find_matching_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 <vector>
19
20namespace lagrange {
21
30
35{
38
41
43 size_t num_channels = 0;
44};
45
57template <typename Scalar, typename Index>
58std::optional<AttributeId> find_matching_attribute(
60 const AttributeMatcher& options);
61
75template <typename Scalar, typename Index>
76std::optional<AttributeId> find_matching_attribute(
78 AttributeUsage usage);
79
93template <typename Scalar, typename Index>
94std::optional<AttributeId> find_matching_attribute(
96 BitField<AttributeElement> element_types);
97
109template <typename Scalar, typename Index>
110std::vector<AttributeId> find_matching_attributes(
111 const SurfaceMesh<Scalar, Index>& mesh,
112 const AttributeMatcher& options);
113
125template <typename Scalar, typename Index>
126std::vector<AttributeId> find_matching_attributes(
127 const SurfaceMesh<Scalar, Index>& mesh,
128 AttributeUsage usage);
129
141template <typename Scalar, typename Index>
142std::vector<AttributeId> find_matching_attributes(
143 const SurfaceMesh<Scalar, Index>& mesh,
144 BitField<AttributeElement> element_types);
145
149
150} // namespace lagrange
static constexpr BitField all()
Named constructor returning a bitfield set to 1.
Definition: BitField.h:76
AttributeUsage
Usage tag indicating how the attribute should behave under mesh transformations.
Definition: AttributeFwd.h:54
std::vector< AttributeId > find_matching_attributes(const SurfaceMesh< Scalar, Index > &mesh, const AttributeMatcher &options)
Finds all attributes with the specified usage/element type/number of channels.
Definition: find_matching_attributes.cpp:80
std::optional< AttributeId > find_matching_attribute(const SurfaceMesh< Scalar, Index > &mesh, const AttributeMatcher &options)
Finds the first attribute with the specified usage/element type/number of channels.
Definition: find_matching_attributes.cpp:37
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Helper object to match attributes based on usage, element type, and number of channels.
Definition: find_matching_attributes.h:35
BitField< AttributeElement > element_types
List of attribute element types to include. By default, all element types are included.
Definition: find_matching_attributes.h:40
BitField< AttributeUsage > usages
List of attribute usages to include. By default, all usages are included.
Definition: find_matching_attributes.h:37
size_t num_channels
Number of channels to match against. Default value is 0, which disables this test.
Definition: find_matching_attributes.h:43