OpenVDB: PointUtils.h Source File

OpenVDB 8.0.0

PointUtils.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3
9
10 #ifndef OPENVDB_HOUDINI_POINT_UTILS_HAS_BEEN_INCLUDED
11 #define OPENVDB_HOUDINI_POINT_UTILS_HAS_BEEN_INCLUDED
12
13 #include <openvdb/math/Vec3.h>
14 #include <openvdb/Types.h>
15 #include <openvdb/points/PointDataGrid.h>
16
17 #include <GA/GA_Attribute.h>
18 #include <GU/GU_Detail.h>
19 #include <PRM/PRM_ChoiceList.h>
20
21 #include <iosfwd>
22 #include <map>
23 #include <memory>
24 #include <string>
25 #include <vector>
26
27
28 #ifdef SESI_OPENVDB
29 #ifdef OPENVDB_HOUDINI_API
30 #undef OPENVDB_HOUDINI_API
31 #define OPENVDB_HOUDINI_API
32 #endif
33 #endif
34
35
36 namespace openvdb_houdini {
37
38 using OffsetList = std::vector<GA_Offset>;
39 using OffsetListPtr = std::shared_ptr<OffsetList>;
40
41 using OffsetPair = std::pair<GA_Offset, GA_Offset>;
42 using OffsetPairList = std::vector<OffsetPair>;
43 using OffsetPairListPtr = std::shared_ptr<OffsetPairList>;
44
45 // note that the bool parameter here for toggling in-memory compression is now deprecated
46 using AttributeInfoMap = std::map<openvdb::Name, std::pair<int, bool>>;
47
48 using WarnFunc = std::function<void (const std::string&)>;
49
51 const std::string META_GROUP_VIEWPORT = "group_viewport";
52
53
55 enum POINT_COMPRESSION_TYPE
56 {
57 COMPRESSION_NONE = 0,
58 COMPRESSION_TRUNCATE,
59 COMPRESSION_UNIT_VECTOR,
60 COMPRESSION_UNIT_FIXED_POINT_8,
61 COMPRESSION_UNIT_FIXED_POINT_16,
62 };
63
64
65 // forward declaration
66 class Interrupter;
67
68
76 OPENVDB_HOUDINI_API
77 float
78 computeVoxelSizeFromHoudini(
79 const GU_Detail& detail,
80 const openvdb::Index pointsPerVoxel,
81 const openvdb::math::Mat4d& matrix,
82 const openvdb::Index decimalPlaces,
83 Interrupter& interrupter);
84
85
94 OPENVDB_HOUDINI_API
95 openvdb::points::PointDataGrid::Ptr
96 convertHoudiniToPointDataGrid(
97 const GU_Detail& detail,
98 const int compression,
99 const AttributeInfoMap& attributes,
100 const openvdb::math::Transform& transform,
101 const WarnFunc& warnings = [](const std::string&){});
102
103
115 OPENVDB_HOUDINI_API
116 void
117 convertPointDataGridToHoudini(
118 GU_Detail& detail,
119 const openvdb::points::PointDataGrid& grid,
120 const std::vector<std::string>& attributes = {},
121 const std::vector<std::string>& includeGroups = {},
122 const std::vector<std::string>& excludeGroups = {},
123 const bool inCoreOnly = false);
124
125
131 OPENVDB_HOUDINI_API
132 void
133 populateMetadataFromHoudini(
134 openvdb::points::PointDataGrid& grid,
135 const GU_Detail& detail,
136 const WarnFunc& warnings = [](const std::string&){});
137
138
144 OPENVDB_HOUDINI_API
145 void
146 convertMetadataToHoudini(
147 GU_Detail& detail,
148 const openvdb::MetaMap& metaMap,
149 const WarnFunc& warnings = [](const std::string&){});
150
151
153 OPENVDB_HOUDINI_API
154 int16_t
155 attributeTupleSize(const GA_Attribute* const attribute);
156
157
159 OPENVDB_HOUDINI_API
160 GA_Storage
161 attributeStorageType(const GA_Attribute* const attribute);
162
163
165
166
170 OPENVDB_HOUDINI_API
171 void
172 pointDataGridSpecificInfoText(std::ostream&, const openvdb::GridBase&);
173
185 OPENVDB_HOUDINI_API
186 void
187 collectPointInfo(const openvdb::points::PointDataGrid& grid,
188 std::string& countStr,
189 std::string& groupStr,
190 std::string& attributeStr);
191
192
194
195
196 // VDB Points group name drop-down menu
197
198 OPENVDB_HOUDINI_API extern const PRM_ChoiceList VDBPointsGroupMenuInput1;
199 OPENVDB_HOUDINI_API extern const PRM_ChoiceList VDBPointsGroupMenuInput2;
200 OPENVDB_HOUDINI_API extern const PRM_ChoiceList VDBPointsGroupMenuInput3;
201 OPENVDB_HOUDINI_API extern const PRM_ChoiceList VDBPointsGroupMenuInput4;
202
206 OPENVDB_HOUDINI_API extern const PRM_ChoiceList VDBPointsGroupMenu;
207
208 } // namespace openvdb_houdini
209
210 #endif // OPENVDB_HOUDINI_POINT_UTILS_HAS_BEEN_INCLUDED
Types.h
openvdb_houdini::COMPRESSION_NONE
@ COMPRESSION_NONE
Definition: PointUtils.h:57
openvdb_houdini::VDBPointsGroupMenuInput4
OPENVDB_HOUDINI_API const PRM_ChoiceList VDBPointsGroupMenuInput4
openvdb_houdini
Definition: AttributeTransferUtil.h:33
openvdb::v8_2::math::Mat4d
Mat4< double > Mat4d
Definition: Mat4.h:1368
openvdb_houdini::POINT_COMPRESSION_TYPE
POINT_COMPRESSION_TYPE
Enum to store available compression types for point grids.
Definition: PointUtils.h:56
openvdb_houdini::VDBPointsGroupMenuInput3
OPENVDB_HOUDINI_API const PRM_ChoiceList VDBPointsGroupMenuInput3
openvdb_houdini::OffsetPairListPtr
std::shared_ptr< OffsetPairList > OffsetPairListPtr
Definition: PointUtils.h:43
openvdb_houdini::Interrupter
Wrapper class that adapts a Houdini UT_Interrupt object for use with OpenVDB library routines.
Definition: openvdb_houdini/openvdb_houdini/Utils.h:174
openvdb::v8_2::Index
Index32 Index
Definition: openvdb/Types.h:32
openvdb_houdini::WarnFunc
std::function< void(const std::string &)> WarnFunc
Definition: PointUtils.h:48
openvdb_houdini::collectPointInfo
OPENVDB_HOUDINI_API void collectPointInfo(const openvdb::points::PointDataGrid &grid, std::string &countStr, std::string &groupStr, std::string &attributeStr)
Populates string data with information about the provided OpenVDB Points grid.
openvdb::v8_2::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb_houdini::attributeStorageType
OPENVDB_HOUDINI_API GA_Storage attributeStorageType(const GA_Attribute *const attribute)
Returns supported Storage types for conversion from GA_Attribute.
openvdb::v8_2::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
openvdb_houdini::COMPRESSION_UNIT_VECTOR
@ COMPRESSION_UNIT_VECTOR
Definition: PointUtils.h:59
openvdb_houdini::convertPointDataGridToHoudini
OPENVDB_HOUDINI_API void convertPointDataGridToHoudini(GU_Detail &detail, const openvdb::points::PointDataGrid &grid, const std::vector< std::string > &attributes={}, const std::vector< std::string > &includeGroups={}, const std::vector< std::string > &excludeGroups={}, const bool inCoreOnly=false)
Convert a VDB Points grid into Houdini points and append them to a Houdini Detail.
Vec3.h
openvdb_houdini::COMPRESSION_TRUNCATE
@ COMPRESSION_TRUNCATE
Definition: PointUtils.h:58
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
openvdb_houdini::COMPRESSION_UNIT_FIXED_POINT_16
@ COMPRESSION_UNIT_FIXED_POINT_16
Definition: PointUtils.h:61
openvdb_houdini::OffsetPair
std::pair< GA_Offset, GA_Offset > OffsetPair
Definition: PointUtils.h:41
openvdb_houdini::convertHoudiniToPointDataGrid
OPENVDB_HOUDINI_API openvdb::points::PointDataGrid::Ptr convertHoudiniToPointDataGrid(const GU_Detail &detail, const int compression, const AttributeInfoMap &attributes, const openvdb::math::Transform &transform, const WarnFunc &warnings=[](const std::string &){})
Convert a Houdini detail into a VDB Points grid.
openvdb_houdini::AttributeInfoMap
std::map< openvdb::Name, std::pair< int, bool > > AttributeInfoMap
Definition: PointUtils.h:46
openvdb::v8_2::points::PointDataGrid
Grid< PointDataTree > PointDataGrid
Point data grid.
Definition: PointDataGrid.h:189
openvdb_houdini::attributeTupleSize
OPENVDB_HOUDINI_API int16_t attributeTupleSize(const GA_Attribute *const attribute)
Returns supported tuple sizes for conversion from GA_Attribute.
openvdb_houdini::pointDataGridSpecificInfoText
OPENVDB_HOUDINI_API void pointDataGridSpecificInfoText(std::ostream &, const openvdb::GridBase &)
If the given grid is a PointDataGrid, add node specific info text to the stream provided....
openvdb_houdini::COMPRESSION_UNIT_FIXED_POINT_8
@ COMPRESSION_UNIT_FIXED_POINT_8
Definition: PointUtils.h:60
openvdb_houdini::VDBPointsGroupMenuInput1
OPENVDB_HOUDINI_API const PRM_ChoiceList VDBPointsGroupMenuInput1
openvdb_houdini::computeVoxelSizeFromHoudini
OPENVDB_HOUDINI_API float computeVoxelSizeFromHoudini(const GU_Detail &detail, const openvdb::Index pointsPerVoxel, const openvdb::math::Mat4d &matrix, const openvdb::Index decimalPlaces, Interrupter &interrupter)
Compute a voxel size from a Houdini detail.
openvdb_houdini::VDBPointsGroupMenuInput2
OPENVDB_HOUDINI_API const PRM_ChoiceList VDBPointsGroupMenuInput2
openvdb_houdini::OffsetPairList
std::vector< OffsetPair > OffsetPairList
Definition: PointUtils.h:42
openvdb_houdini::convertMetadataToHoudini
OPENVDB_HOUDINI_API void convertMetadataToHoudini(GU_Detail &detail, const openvdb::MetaMap &metaMap, const WarnFunc &warnings=[](const std::string &){})
Convert VDB Points grid metadata into Houdini detail attributes.
openvdb_houdini::OffsetList
std::vector< GA_Offset > OffsetList
Definition: PointUtils.h:38
openvdb_houdini::populateMetadataFromHoudini
OPENVDB_HOUDINI_API void populateMetadataFromHoudini(openvdb::points::PointDataGrid &grid, const GU_Detail &detail, const WarnFunc &warnings=[](const std::string &){})
Populate VDB Points grid metadata from Houdini detail attributes.
openvdb_houdini::VDBPointsGroupMenu
OPENVDB_HOUDINI_API const PRM_ChoiceList VDBPointsGroupMenu
OPENVDB_HOUDINI_API
#define OPENVDB_HOUDINI_API
Definition: Platform.h:216
openvdb_houdini::OffsetListPtr
std::shared_ptr< OffsetList > OffsetListPtr
Definition: PointUtils.h:39
openvdb_houdini::META_GROUP_VIEWPORT
const std::string META_GROUP_VIEWPORT
Metadata name for viewport groups.
Definition: PointUtils.h:51