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