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

panda/src/egg/eggVertex.h

Go to the documentation of this file.
00001 // Filename: eggVertex.h
00002 // Created by:  drose (16Jan99)
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 #ifndef EGGVERTEX_H
00020 #define EGGVERTEX_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "eggObject.h"
00025 #include "eggAttributes.h"
00026 #include "eggMorphList.h"
00027 
00028 #include <referenceCount.h>
00029 #include <luse.h>
00030 #include "pset.h"
00031 
00032 class EggVertexPool;
00033 class EggGroup;
00034 class EggPrimitive;
00035 
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //       Class : EggVertex
00039 // Description : Any one-, two-, three-, or four-component vertex,
00040 //               possibly with attributes such as a normal.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDAEGG EggVertex : public EggObject, public EggAttributes {
00043 public:
00044   typedef pset<EggGroup *> GroupRef;
00045   typedef pmultiset<EggPrimitive *> PrimitiveRef;
00046 
00047   EggVertex();
00048   EggVertex(const EggVertex &copy);
00049   EggVertex &operator = (const EggVertex &copy);
00050   virtual ~EggVertex();
00051 
00052   INLINE EggVertexPool *get_pool() const;
00053 
00054   // The pos might have 1, 2, 3, or 4 dimensions.  That complicates
00055   // things a bit.
00056   INLINE void set_pos(double pos);
00057   INLINE void set_pos(const LPoint2d &pos);
00058   INLINE void set_pos(const LPoint3d &pos);
00059   INLINE void set_pos(const LPoint4d &pos);
00060   INLINE void set_pos4(const LPoint4d &pos);
00061 
00062   // get_pos[123] return the pos as the corresponding type.  It is an
00063   // error to call any of these without first verifying that
00064   // get_num_dimensions() matches the desired type.  However,
00065   // get_pos4() may always be called; it returns the pos as a
00066   // four-component point in homogeneous space (with a 1.0 in the last
00067   // position if the pos has fewer than four components).
00068   INLINE int get_num_dimensions() const;
00069   INLINE double get_pos1() const;
00070   INLINE LPoint2d get_pos2() const;
00071   INLINE Vertexd get_pos3() const;
00072   INLINE LPoint4d get_pos4() const;
00073 
00074   INLINE int get_index() const;
00075 
00076   INLINE void set_external_index(int external_index);
00077   INLINE int get_external_index() const;
00078 
00079   void write(ostream &out, int indent_level) const;
00080   bool sorts_less_than(const EggVertex &other) const;
00081 
00082   int get_num_local_coord() const;
00083   int get_num_global_coord() const;
00084 
00085   void transform(const LMatrix4d &mat);
00086 
00087   INLINE GroupRef::const_iterator gref_begin() const;
00088   INLINE GroupRef::const_iterator gref_end() const;
00089   INLINE GroupRef::size_type gref_size() const;
00090   bool has_gref(const EggGroup *group) const;
00091 
00092   void copy_grefs_from(const EggVertex &other);
00093   void clear_grefs();
00094 
00095   INLINE PrimitiveRef::const_iterator pref_begin() const;
00096   INLINE PrimitiveRef::const_iterator pref_end() const;
00097   INLINE PrimitiveRef::size_type pref_size() const;
00098   int has_pref(const EggPrimitive *prim) const;
00099 
00100 #ifndef NDEBUG
00101   void test_gref_integrity() const;
00102   void test_pref_integrity() const;
00103 #else
00104   void test_gref_integrity() const { }
00105   void test_pref_integrity() const { }
00106 #endif  // NDEBUG
00107 
00108   void output(ostream &out) const;
00109 
00110   EggMorphVertexList _dxyzs;
00111 
00112 private:
00113   EggVertexPool *_pool;
00114   int _index;
00115   int _external_index;
00116   LPoint4d _pos;
00117   short _num_dimensions;
00118   GroupRef _gref;
00119   PrimitiveRef _pref;
00120 
00121 public:
00122   static TypeHandle get_class_type() {
00123     return _type_handle;
00124   }
00125   static void init_type() {
00126     EggObject::init_type();
00127     EggAttributes::init_type();
00128     register_type(_type_handle, "EggVertex",
00129                   EggObject::get_class_type(),
00130                   EggAttributes::get_class_type());
00131   }
00132   virtual TypeHandle get_type() const {
00133     return get_class_type();
00134   }
00135   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00136 
00137 private:
00138   static TypeHandle _type_handle;
00139 
00140   friend class EggVertexPool;
00141   friend class EggGroup;
00142   friend class EggPrimitive;
00143 };
00144 
00145 INLINE ostream &operator << (ostream &out, const EggVertex &vert) {
00146   vert.output(out);
00147   return out;
00148 }
00149 
00150 ///////////////////////////////////////////////////////////////////
00151 //       Class : UniqueEggVertices
00152 // Description : An STL function object for sorting vertices into
00153 //               order by properties.  Returns true if the two
00154 //               referenced EggVertex pointers are in sorted order,
00155 //               false otherwise.
00156 ////////////////////////////////////////////////////////////////////
00157 class EXPCL_PANDAEGG UniqueEggVertices {
00158 public:
00159   INLINE bool operator ()(const EggVertex *v1, const EggVertex *v2) const;
00160 };
00161 
00162 #include "eggVertex.I"
00163 
00164 #endif
00165 
00166 
00167 

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