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

panda/src/builder/mesherEdge.I

Go to the documentation of this file.
00001 // Filename: mesherEdge.I
00002 // Created by:  drose (15Sep97)
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 template <class PrimType>
00022 INLINE MesherEdge<PrimType>::
00023 MesherEdge(const Vertex *a, const Vertex *b) : _a(a), _b(b) {
00024   _opposite = NULL;
00025 }
00026 
00027 template <class PrimType>
00028 INLINE MesherEdge<PrimType>::
00029 MesherEdge(const MesherEdge &copy) :
00030   _a(copy._a),
00031   _b(copy._b),
00032   _strips(copy._strips),
00033   _opposite(copy._opposite)
00034 {
00035 }
00036 
00037 template <class PrimType>
00038 INLINE bool MesherEdge<PrimType>::
00039 contains_vertex(const Vertex *v) const {
00040   return (_a==v || _b==v);
00041 }
00042 
00043 
00044 template <class PrimType>
00045 INLINE bool MesherEdge<PrimType>::
00046 matches(const MesherEdge &other) const {
00047   return (_a == other._a && _b == other._b) ||
00048     (_b == other._a && _a == other._b);
00049 }
00050 
00051 template <class PrimType>
00052 INLINE MesherEdge<PrimType> *MesherEdge<PrimType>::
00053 common_ptr() {
00054   return min(this, _opposite);
00055 }
00056 
00057 template <class PrimType>
00058 INLINE bool MesherEdge<PrimType>::
00059 operator == (const MesherEdge &other) const {
00060   return _a == other._a && _b == other._b;
00061 }
00062 
00063 template <class PrimType>
00064 INLINE bool MesherEdge<PrimType>::
00065 operator != (const MesherEdge &other) const {
00066   return !operator == (other);
00067 }
00068 
00069 template <class PrimType>
00070 INLINE bool MesherEdge<PrimType>::
00071 operator < (const MesherEdge &other) const {
00072   return _a < other._a || (_a == other._a && _b < other._b);
00073 }
00074 
00075 template <class PrimType>
00076 INLINE float MesherEdge<PrimType>::
00077 compute_length(const BuilderBucket &bucket) const {
00078   LVector3f v = ((const Vertexf &)_a->get_coord_value(bucket) -
00079                  (const Vertexf &)_b->get_coord_value(bucket));
00080   return length(v);
00081 }
00082 
00083 template <class PrimType>
00084 INLINE Vertexf MesherEdge<PrimType>::
00085 compute_box(const BuilderBucket &bucket) const {
00086   LVector3f v = ((const Vertexf &)_a->get_coord_value(bucket) -
00087                  (const Vertexf &)_b->get_coord_value(bucket));
00088   return Vertexf(fabs(v[0]), fabs(v[1]), fabs(v[2]));
00089 }
00090 
00091 
00092 ////////////////////////////////////////////////////////////////////
00093 //     Function: MesherEdge::remove
00094 //       Access: Public
00095 //  Description: Removes an edge from a particular strip.
00096 ////////////////////////////////////////////////////////////////////
00097 template <class PrimType>
00098 void MesherEdge<PrimType>::
00099 remove(Strip *strip) {
00100   strip->_edges.remove(this);
00101   strip->_edges.remove(_opposite);
00102 
00103   _strips.remove(strip);
00104   _opposite->_strips.remove(strip);
00105 }
00106 
00107 
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: MesherEdge::change_strip
00111 //       Access: Public
00112 //  Description: Reparents the edge from strip "from" to strip "to".
00113 ////////////////////////////////////////////////////////////////////
00114 template <class PrimType>
00115 void MesherEdge<PrimType>::
00116 change_strip(Strip *from, Strip *to) {
00117   TYPENAME Strips::iterator si;
00118 
00119   for (si = _strips.begin(); si != _strips.end(); ++si) {
00120     if (*si == from) {
00121       *si = to;
00122     }
00123   }
00124 
00125   for (si = _opposite->_strips.begin();
00126        si != _opposite->_strips.end();
00127        ++si) {
00128     if (*si == from) {
00129       *si = to;
00130     }
00131   }
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 //     Function: MesherEdge::output
00136 //       Access: Public
00137 //  Description: Formats the edge for output in some sensible way.
00138 ////////////////////////////////////////////////////////////////////
00139 template <class PrimType>
00140 ostream &MesherEdge<PrimType>::
00141 output(ostream &out) const {
00142   out << "Edge [" << *_a << " to " << *_b << "], "
00143       << _strips.size() << " strips:";
00144 
00145   TYPENAME Strips::const_iterator si;
00146   for (si = _strips.begin(); si != _strips.end(); ++si) {
00147     out << " " << (*si)->_index;
00148   }
00149 
00150   if (_opposite!=NULL) {
00151     out << " opposite "
00152         << _opposite->_strips.size() << " strips:";
00153 
00154     for (si = _opposite->_strips.begin();
00155          si != _opposite->_strips.end();
00156          ++si) {
00157       out << " " << (*si)->_index;
00158     }
00159   }
00160 
00161   return out;
00162 }

Generated on Fri May 2 00:34:48 2003 for Panda by doxygen1.3