Panda3D

Loading...
Searching...
No Matches
partSubset.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file partSubset.cxx
10 * @author drose
11 * @date 2006-01-19
12 */
13
14#include "partSubset.h"
15
16/**
17 *
18 */
19PartSubset::
20PartSubset() {
21}
22
23/**
24 *
25 */
26PartSubset::
27PartSubset(const PartSubset &copy) :
28 _include_joints(copy._include_joints),
29 _exclude_joints(copy._exclude_joints)
30{
31}
32
33/**
34 *
35 */
36 void PartSubset::
37operator = (const PartSubset &copy) {
38 _include_joints = copy._include_joints;
39 _exclude_joints = copy._exclude_joints;
40}
41
42/**
43 * Adds the named joint to the list of joints that will be explicitly included
44 * in the subset. Any joint at or below a named node will be included in the
45 * subset (unless a lower node is also listed in the exclude list).
46 *
47 * Since the name is a GlobPattern, it may of course include filename globbing
48 * characters like * and ?.
49 */
50 void PartSubset::
51 add_include_joint(const GlobPattern &name) {
52 _include_joints.push_back(name);
53}
54
55/**
56 * Adds the named joint to the list of joints that will be explicitly
57 * exlcluded from the subset. Any joint at or below a named node will not be
58 * included in the subset (unless a lower node is also listed in the include
59 * list).
60 *
61 * Since the name is a GlobPattern, it may of course include filename globbing
62 * characters like * and ?.
63 */
64 void PartSubset::
65 add_exclude_joint(const GlobPattern &name) {
66 _exclude_joints.push_back(name);
67}
68
69/**
70 * Appends the include and exclude list from the other object onto this
71 * object's lists.
72 */
73 void PartSubset::
74 append(const PartSubset &other) {
75 Joints::const_iterator ji;
76 for (ji = other._include_joints.begin();
77 ji != other._include_joints.end();
78 ++ji) {
79 _include_joints.push_back(*ji);
80 }
81 for (ji = other._exclude_joints.begin();
82 ji != other._exclude_joints.end();
83 ++ji) {
84 _exclude_joints.push_back(*ji);
85 }
86}
87
88/**
89 *
90 */
91 void PartSubset::
92output(std::ostream &out) const {
93 if (_include_joints.empty() && _exclude_joints.empty()) {
94 out << "PartSubset, empty";
95 } else {
96 out << "PartSubset, include: [";
97 Joints::const_iterator ji;
98 for (ji = _include_joints.begin(); ji != _include_joints.end(); ++ji) {
99 out << " " << (*ji);
100 }
101 out << " ], exclude: [";
102 for (ji = _exclude_joints.begin(); ji != _exclude_joints.end(); ++ji) {
103 out << " " << (*ji);
104 }
105 out << " ]";
106 }
107}
108
109/**
110 * Returns true if the include list is completely empty, false otherwise. If
111 * it is empty, it is the same thing as including all joints.
112 */
113 bool PartSubset::
114 is_include_empty() const {
115 return _include_joints.empty();
116}
117
118/**
119 * Returns true if the indicated name matches a name on the include list,
120 * false otherwise.
121 */
122 bool PartSubset::
123 matches_include(const std::string &joint_name) const {
124 Joints::const_iterator ji;
125 for (ji = _include_joints.begin(); ji != _include_joints.end(); ++ji) {
126 if ((*ji).matches(joint_name)) {
127 return true;
128 }
129 }
130
131 return false;
132}
133
134
135/**
136 * Returns true if the indicated name matches a name on the exclude list,
137 * false otherwise.
138 */
139 bool PartSubset::
140 matches_exclude(const std::string &joint_name) const {
141 Joints::const_iterator ji;
142 for (ji = _exclude_joints.begin(); ji != _exclude_joints.end(); ++ji) {
143 if ((*ji).matches(joint_name)) {
144 return true;
145 }
146 }
147
148 return false;
149}
GlobPattern
This class can be used to test for string matches against standard Unix- shell filename globbing conv...
Definition globPattern.h:32
PartSubset
This class is used to define a subset of part names to apply to the PartBundle::bind_anim() operation...
Definition partSubset.h:25
PartSubset::add_include_joint
void add_include_joint(const GlobPattern &name)
Adds the named joint to the list of joints that will be explicitly included in the subset.
Definition partSubset.cxx:51
PartSubset::matches_exclude
bool matches_exclude(const std::string &joint_name) const
Returns true if the indicated name matches a name on the exclude list, false otherwise.
Definition partSubset.cxx:140
PartSubset::append
void append(const PartSubset &other)
Appends the include and exclude list from the other object onto this object's lists.
Definition partSubset.cxx:74
PartSubset::is_include_empty
bool is_include_empty() const
Returns true if the include list is completely empty, false otherwise.
Definition partSubset.cxx:114
PartSubset::matches_include
bool matches_include(const std::string &joint_name) const
Returns true if the indicated name matches a name on the include list, false otherwise.
Definition partSubset.cxx:123
PartSubset::add_exclude_joint
void add_exclude_joint(const GlobPattern &name)
Adds the named joint to the list of joints that will be explicitly exlcluded from the subset.
Definition partSubset.cxx:65
partSubset.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.