Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/egg2pg/computedVerticesMakerEntity.I

Go to the documentation of this file.
00001 // Filename: computedVerticesMakerEntity.I
00002 // Created by:  drose (02Mar99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: ComputedVerticesMakerEntity::Constructor
00022 //       Access: Public
00023 //  Description:
00024 ////////////////////////////////////////////////////////////////////
00025 template<class ValueType, class MorphType>
00026 INLINE ComputedVerticesMakerEntity<ValueType, MorphType>::
00027 ComputedVerticesMakerEntity(const ValueType &value, const MorphType &morphs)
00028   : _value(value), _morphs(morphs) {
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: ComputedVerticesMakerEntity::Ordering operator
00033 //       Access: Public
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 template<class ValueType, class MorphType>
00037 bool ComputedVerticesMakerEntity<ValueType, MorphType>::
00038 operator < (const ComputedVerticesMakerEntity<ValueType, MorphType> &other) const {
00039   // First, check the value.  This is some vector type, which we
00040   // compare componentwise.
00041   int compare = _value.compare_to(other._value);
00042   if (compare != 0) {
00043     return compare < 0;
00044   }
00045 
00046   // The values are identical; compare the morphs.
00047   return _morphs < other._morphs;
00048 }
00049 
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: ComputedVerticesMakerEntityMap::add_value
00053 //       Access: Public
00054 //  Description: Creates a new entry for the value type and morph
00055 //               combination, if it is unique, and returns its new
00056 //               index number, or returns the index number of a
00057 //               previously-created, identical value type and morph.
00058 //
00059 //               The PTA table is updated as each new index number is
00060 //               allocated so that table[index] == value.  It is also
00061 //               used to determine the next available index number.
00062 ////////////////////////////////////////////////////////////////////
00063 template<class ValueType, class MorphType>
00064 int ComputedVerticesMakerEntityMap<ValueType, MorphType>::
00065 add_value(const ValueType &value, const MorphType &morphs,
00066           PTA(ValueType) &table) {
00067   // First, see if we have such an entity already.
00068   ComputedVerticesMakerEntity<ValueType, MorphType> entity(value, morphs);
00069   TYPENAME MapType::const_iterator mi = _map.find(entity);
00070   if (mi != _map.end()) {
00071     // We do!  Return its index number.
00072     return (*mi).second;
00073   }
00074 
00075   // No, this is the first time we've encountered this combination.
00076   // Define it.
00077   int index = table.size();
00078   table.push_back(value);
00079   _map[entity] = index;
00080 
00081   return index;
00082 };
00083 

Generated on Fri May 2 00:38:09 2003 for Panda by doxygen1.3