1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2021 Tangent Animation and
* NVIDIA Corporation. All rights reserved.
*/
#pragma once
struct Main;
#include "usd.h"
#include "usd_reader_prim.h"
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdGeom/imageable.h>
#include <vector>
struct ImportSettings;
namespace blender::io::usd {
typedef std::map<pxr::SdfPath, std::vector<USDPrimReader *>> ProtoReaderMap;
class USDStageReader {
protected:
pxr::UsdStageRefPtr stage_;
USDImportParams params_;
ImportSettings settings_;
std::vector<USDPrimReader *> readers_;
public:
USDStageReader(pxr::UsdStageRefPtr stage,
const USDImportParams ¶ms,
const ImportSettings &settings);
~USDStageReader();
USDPrimReader *create_reader_if_allowed(const pxr::UsdPrim &prim);
USDPrimReader *create_reader(const pxr::UsdPrim &prim);
void collect_readers(struct Main *bmain);
bool valid() const;
pxr::UsdStageRefPtr stage()
{
return stage_;
}
const USDImportParams ¶ms() const
{
return params_;
}
const ImportSettings &settings() const
{
return settings_;
}
void clear_readers();
const std::vector<USDPrimReader *> &readers() const
{
return readers_;
};
private:
USDPrimReader *collect_readers(Main *bmain, const pxr::UsdPrim &prim);
/**
* Returns true if the given prim should be included in the
* traversal based on the import options and the prim's visibility
* attribute. Note that the prim will be trivially included
* if it has no visibility attribute or if the visibility
* is inherited.
*/
bool include_by_visibility(const pxr::UsdGeomImageable &imageable) const;
/**
* Returns true if the given prim should be included in the
* traversal based on the import options and the prim's purpose
* attribute. E.g., return false (to exclude the prim) if the prim
* represents guide geometry and the 'Import Guide' option is
* toggled off.
*/
bool include_by_purpose(const pxr::UsdGeomImageable &imageable) const;
};
}; // namespace blender::io::usd
|