Lagrange
Loading...
Searching...
No Matches
bind_indexed_attribute.h
1/*
2 * Copyright 2022 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 "PyIndexedAttribute.h"
15
16#include <lagrange/IndexedAttribute.h>
17#include <lagrange/python/binding.h>
18
19namespace lagrange::python {
20
21void bind_indexed_attribute(nanobind::module_& m)
22{
23 namespace nb = nanobind;
24 using namespace nb::literals;
25
26 auto indexed_attr_class = nb::class_<PyIndexedAttribute>(
27 m,
28 "IndexedAttribute",
29 R"(Indexed attribute data structure.
30
31An indexed attribute stores values and indices separately, allowing for efficient
32storage when multiple elements share the same values. This is commonly used for
33UV coordinates, normals, or colors where the same value may be referenced by
34multiple vertices, corners, or facets.)");
35
36 indexed_attr_class.def_prop_ro(
37 "element_type",
38 [](PyIndexedAttribute& self) { return self->get_element_type(); },
39 R"(Element type (i.e. Indexed).)");
40
41 indexed_attr_class.def_prop_ro(
42 "usage",
43 [](PyIndexedAttribute& self) { return self->get_usage(); },
44 "Usage type (Position, Normal, UV, Color, etc.).");
45
46 indexed_attr_class.def_prop_ro(
47 "num_channels",
48 [](PyIndexedAttribute& self) { return self->get_num_channels(); },
49 "Number of channels per element.");
50
51 indexed_attr_class.def_prop_ro(
52 "values",
53 &PyIndexedAttribute::values,
54 R"(The values array of the indexed attribute.
55
56:returns: Attribute containing the unique values referenced by the indices)");
57 indexed_attr_class.def_prop_ro(
58 "indices",
59 &PyIndexedAttribute::indices,
60 R"(The indices array of the indexed attribute.
61
62:returns: Attribute containing the indices that reference into the values array)");
63}
64
65} // namespace lagrange::python
Definition PyIndexedAttribute.h:27