Panda3D
 All Classes Functions Variables Enumerations
partSubset.cxx
00001 // Filename: partSubset.cxx
00002 // Created by:  drose (19Jan06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "partSubset.h"
00016 
00017 ////////////////////////////////////////////////////////////////////
00018 //     Function: PartSubset::Constructor
00019 //       Access: Published
00020 //  Description: 
00021 ////////////////////////////////////////////////////////////////////
00022 PartSubset::
00023 PartSubset() {
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: PartSubset::Copy Constructor
00028 //       Access: Published
00029 //  Description: 
00030 ////////////////////////////////////////////////////////////////////
00031 PartSubset::
00032 PartSubset(const PartSubset &copy) : 
00033   _include_joints(copy._include_joints),
00034   _exclude_joints(copy._exclude_joints)
00035 {
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: PartSubset::Copy Assignment Operator
00040 //       Access: Published
00041 //  Description: 
00042 ////////////////////////////////////////////////////////////////////
00043 void PartSubset::
00044 operator = (const PartSubset &copy) {
00045   _include_joints = copy._include_joints;
00046   _exclude_joints = copy._exclude_joints;
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: PartSubset::add_include_joint
00051 //       Access: Published
00052 //  Description: Adds the named joint to the list of joints that will
00053 //               be explicitly included in the subset.  Any joint at
00054 //               or below a named node will be included in the subset
00055 //               (unless a lower node is also listed in the exclude
00056 //               list).
00057 //
00058 //               Since the name is a GlobPattern, it may of course
00059 //               include filename globbing characters like * and ?.
00060 ////////////////////////////////////////////////////////////////////
00061 void PartSubset::
00062 add_include_joint(const GlobPattern &name) {
00063   _include_joints.push_back(name);
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: PartSubset::add_exclude_joint
00068 //       Access: Published
00069 //  Description: Adds the named joint to the list of joints that will
00070 //               be explicitly exlcluded from the subset.  Any joint at
00071 //               or below a named node will not be included in the
00072 //               subset (unless a lower node is also listed in the
00073 //               include list).
00074 //
00075 //               Since the name is a GlobPattern, it may of course
00076 //               include filename globbing characters like * and ?.
00077 ////////////////////////////////////////////////////////////////////
00078 void PartSubset::
00079 add_exclude_joint(const GlobPattern &name) {
00080   _exclude_joints.push_back(name);
00081 }
00082 
00083 ////////////////////////////////////////////////////////////////////
00084 //     Function: PartSubset::append
00085 //       Access: Published
00086 //  Description: Appends the include and exclude list from the other
00087 //               object onto this object's lists.
00088 ////////////////////////////////////////////////////////////////////
00089 void PartSubset::
00090 append(const PartSubset &other) {
00091   Joints::const_iterator ji;
00092   for (ji = other._include_joints.begin(); 
00093        ji != other._include_joints.end(); 
00094        ++ji) {
00095     _include_joints.push_back(*ji);
00096   }
00097   for (ji = other._exclude_joints.begin(); 
00098        ji != other._exclude_joints.end(); 
00099        ++ji) {
00100     _exclude_joints.push_back(*ji);
00101   }
00102 }
00103 
00104 ////////////////////////////////////////////////////////////////////
00105 //     Function: PartSubset::output
00106 //       Access: Published
00107 //  Description: 
00108 ////////////////////////////////////////////////////////////////////
00109 void PartSubset::
00110 output(ostream &out) const {
00111   if (_include_joints.empty() && _exclude_joints.empty()) {
00112     out << "PartSubset, empty";
00113   } else {
00114     out << "PartSubset, include: [";
00115     Joints::const_iterator ji;
00116     for (ji = _include_joints.begin(); ji != _include_joints.end(); ++ji) {
00117       out << " " << (*ji);
00118     }
00119     out << " ], exclude: [";
00120     for (ji = _exclude_joints.begin(); ji != _exclude_joints.end(); ++ji) {
00121       out << " " << (*ji);
00122     }
00123     out << " ]";
00124   }
00125 }
00126 
00127 ////////////////////////////////////////////////////////////////////
00128 //     Function: PartSubset::is_include_empty
00129 //       Access: Published
00130 //  Description: Returns true if the include list is completely empty,
00131 //               false otherwise.  If it is empty, it is the same
00132 //               thing as including all joints.
00133 ////////////////////////////////////////////////////////////////////
00134 bool PartSubset::
00135 is_include_empty() const {
00136   return _include_joints.empty();
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: PartSubset::matches_include
00141 //       Access: Published
00142 //  Description: Returns true if the indicated name matches a name on
00143 //               the include list, false otherwise.
00144 ////////////////////////////////////////////////////////////////////
00145 bool PartSubset::
00146 matches_include(const string &joint_name) const {
00147   Joints::const_iterator ji;
00148   for (ji = _include_joints.begin(); ji != _include_joints.end(); ++ji) {
00149     if ((*ji).matches(joint_name)) {
00150       return true;
00151     }
00152   }
00153 
00154   return false;
00155 }
00156 
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: PartSubset::matches_exclude
00160 //       Access: Published
00161 //  Description: Returns true if the indicated name matches a name on
00162 //               the exclude list, false otherwise.
00163 ////////////////////////////////////////////////////////////////////
00164 bool PartSubset::
00165 matches_exclude(const string &joint_name) const {
00166   Joints::const_iterator ji;
00167   for (ji = _exclude_joints.begin(); ji != _exclude_joints.end(); ++ji) {
00168     if ((*ji).matches(joint_name)) {
00169       return true;
00170     }
00171   }
00172 
00173   return false;
00174 }
 All Classes Functions Variables Enumerations