Lagrange
IndexedAttribute.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 <lagrange/Attribute.h>
15
16namespace lagrange {
17
20
27template <typename ValueType_, typename Index_>
29{
30public:
32 using ValueType = ValueType_;
33
35 using Index = Index_;
36
38 static constexpr bool IsIndexed = true;
39
40public:
44
51 IndexedAttribute(AttributeUsage usage, size_t num_channels);
52
57
64
73
79 explicit IndexedAttribute(const IndexedAttribute& other);
80
89
95 [[nodiscard]] AttributeValueType get_value_type() const override
96 {
97 return m_values.get_value_type();
98 }
99
103
109 Attribute<ValueType>& values() { return m_values; }
110
116 const Attribute<ValueType>& values() const { return m_values; }
117
123 Attribute<Index>& indices() { return m_indices; }
124
130 const Attribute<Index>& indices() const { return m_indices; }
131
133
134protected:
135 Attribute<ValueType> m_values;
136 Attribute<Index> m_indices;
137
138 // TODO:
139 // copy_on_write_ptr<Attribute<ValueType>> m_values;
140 // copy_on_write_ptr<Attribute<Index>> m_indices;
141};
142
144
145} // namespace lagrange
Base handle for attributes.
Definition: Attribute.h:41
AttributeValueType get_value_type() const override
Gets the attribute value type.
Derived attribute class that stores the actual information.
Definition: IndexedAttribute.h:29
AttributeValueType get_value_type() const override
Gets the attribute value type.
Definition: IndexedAttribute.h:95
IndexedAttribute(IndexedAttribute &&other) noexcept
Move constructor.
Attribute< ValueType > & values()
Access attribute values.
Definition: IndexedAttribute.h:109
static constexpr bool IsIndexed
Whether this attribute type is indexed.
Definition: IndexedAttribute.h:38
IndexedAttribute(const IndexedAttribute &other)
Copy constructor.
ValueType_ ValueType
Attribute value type.
Definition: IndexedAttribute.h:32
IndexedAttribute & operator=(const IndexedAttribute &other)
Assignment copy operator.
Index_ Index
Attribute index type.
Definition: IndexedAttribute.h:35
const Attribute< Index > & indices() const
Access attribute indices.
Definition: IndexedAttribute.h:130
~IndexedAttribute() override
Destroys the object.
Attribute< Index > & indices()
Access attribute indices.
Definition: IndexedAttribute.h:123
IndexedAttribute(AttributeUsage usage, size_t num_channels)
Constructs a new instance.
Definition: IndexedAttribute.cpp:29
const Attribute< ValueType > & values() const
Access attribute values.
Definition: IndexedAttribute.h:116
IndexedAttribute & operator=(IndexedAttribute &&other) noexcept
Assignment move operator.
AttributeUsage
Usage tag indicating how the attribute should behave under mesh transformations.
Definition: AttributeFwd.h:54
AttributeValueType
Enum describing at runtime the value type of an attribute.
Definition: AttributeValueType.h:25
Main namespace for Lagrange.
Definition: AABBIGL.h:30