Blender V5.3
geometry_component_pointcloud.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "BKE_geometry_set.hh"
12#include "BKE_lib_id.hh"
13#include "BKE_pointcloud.hh"
14
15namespace blender {
16
17namespace bke {
18
19/* -------------------------------------------------------------------- */
22
24
26 : GeometryComponent(Type::PointCloud), pointcloud_(pointcloud), ownership_(ownership)
27{
28}
29
34
36{
37 PointCloudComponent *new_component = new PointCloudComponent();
38 if (pointcloud_ != nullptr) {
39 new_component->pointcloud_ = BKE_pointcloud_copy_for_eval(pointcloud_);
40 new_component->ownership_ = GeometryOwnershipType::Owned;
41 }
42 return GeometryComponentPtr(new_component);
43}
44
46{
47 BLI_assert(this->is_mutable() || this->is_expired());
48 if (pointcloud_ != nullptr) {
49 if (ownership_ == GeometryOwnershipType::Owned) {
50 BKE_id_free(nullptr, pointcloud_);
51 }
52 pointcloud_ = nullptr;
53 }
54}
55
57{
58 return pointcloud_ != nullptr;
59}
60
62{
63 BLI_assert(this->is_mutable());
64 this->clear();
65 pointcloud_ = pointcloud;
66 ownership_ = ownership;
67}
68
70{
71 BLI_assert(this->is_mutable());
72 PointCloud *pointcloud = pointcloud_;
73 pointcloud_ = nullptr;
74 return pointcloud;
75}
76
78{
79 return pointcloud_;
80}
81
83{
84 BLI_assert(this->is_mutable());
85 if (ownership_ == GeometryOwnershipType::ReadOnly) {
86 pointcloud_ = BKE_pointcloud_copy_for_eval(pointcloud_);
88 }
89 return pointcloud_;
90}
91
93{
94 return pointcloud_ == nullptr;
95}
96
98{
99 return ownership_ == GeometryOwnershipType::Owned;
100}
101
103{
104 BLI_assert(this->is_mutable());
105 if (ownership_ != GeometryOwnershipType::Owned) {
106 if (pointcloud_) {
107 pointcloud_ = BKE_pointcloud_copy_for_eval(pointcloud_);
108 }
109 ownership_ = GeometryOwnershipType::Owned;
110 }
111}
112
114{
115 if (pointcloud_) {
116 pointcloud_->count_memory(memory);
117 }
118}
119
121
122} // namespace bke
123
124namespace bke {
125
126/* -------------------------------------------------------------------- */
129
130std::optional<AttributeAccessor> PointCloudComponent::attributes() const
131{
133}
134
135std::optional<MutableAttributeAccessor> PointCloudComponent::attributes_for_write()
136{
137 PointCloud *pointcloud = this->get_for_write();
139}
140
142
143} // namespace bke
144} // namespace blender
General operations for point clouds.
AttributeAccessor(const void *owner, const AttributeAccessorFunctions &fn)
MutableAttributeAccessor(void *owner, const AttributeAccessorFunctions &fn)
GeometryComponentPtr copy() const override
void count_memory(MemoryCounter &memory) const override
void replace(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
std::optional< MutableAttributeAccessor > attributes_for_write() final
std::optional< AttributeAccessor > attributes() const final
ImplicitSharingPtr< GeometryComponent > GeometryComponentPtr
const AttributeAccessorFunctions & pointcloud_attribute_accessor_functions()
BMesh Iterators.
PointCloud * BKE_pointcloud_copy_for_eval(const PointCloud *pointcloud_src)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_id_free(Main *bmain, void *idv)