// Filename: eggVertex.I // Created by: drose (16Jan99) // //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_pool // Access: Public // Description: //////////////////////////////////////////////////////////////////// INLINE EggVertexPool *EggVertex:: get_pool() const { return _pool; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::set_pos // Access: Public // Description: Sets the vertex position. This variant sets the // vertex to a one-dimensional value. //////////////////////////////////////////////////////////////////// INLINE void EggVertex:: set_pos(double pos) { _num_dimensions = 1; _pos.set(pos, 0.0, 0.0, 1.0); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::set_pos // Access: Public // Description: Sets the vertex position. This variant sets the // vertex to a two-dimensional value. //////////////////////////////////////////////////////////////////// INLINE void EggVertex:: set_pos(const LPoint2d &pos) { _num_dimensions = 2; _pos.set(pos[0], pos[1], 0.0, 1.0); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::set_pos // Access: Public // Description: Sets the vertex position. This variant sets the // vertex to a three-dimensional value. //////////////////////////////////////////////////////////////////// INLINE void EggVertex:: set_pos(const LPoint3d &pos) { _num_dimensions = 3; _pos.set(pos[0], pos[1], pos[2], 1.0); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::set_pos // Access: Public // Description: Sets the vertex position. This variant sets the // vertex to a four-dimensional value. //////////////////////////////////////////////////////////////////// INLINE void EggVertex:: set_pos(const LPoint4d &pos) { _num_dimensions = 4; _pos = pos; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::set_pos4 // Access: Public // Description: This special flavor of set_pos() sets the vertex as a // four-component value, but does not change the set // number of dimensions. It's handy for retrieving the // vertex position via get_pos4, manipulating it, then // storing it back again, without worrying about the // number of dimensions it actually had. //////////////////////////////////////////////////////////////////// INLINE void EggVertex:: set_pos4(const LPoint4d &pos) { _pos = pos; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_num_dimensions // Access: Public // Description: Returns the number of dimensions the vertex uses. // Usually this will be 3, but it may be 1, 2, 3, or 4. //////////////////////////////////////////////////////////////////// INLINE int EggVertex:: get_num_dimensions() const { return _num_dimensions; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_pos1 // Access: Public // Description: Only valid if get_num_dimensions() returns 1. // Returns the position as a one-dimensional value. //////////////////////////////////////////////////////////////////// INLINE double EggVertex:: get_pos1() const { nassertr(_num_dimensions == 1, 0.0); return _pos[0]; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_pos2 // Access: Public // Description: Only valid if get_num_dimensions() returns 2. // Returns the position as a two-dimensional value. //////////////////////////////////////////////////////////////////// INLINE LPoint2d EggVertex:: get_pos2() const { nassertr(_num_dimensions == 2, LPoint2d(0.0, 0.0)); return LPoint2d(_pos[0], _pos[1]); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_pos3 // Access: Public // Description: Only valid if get_num_dimensions() returns 3. // Returns the position as a three-dimensional value. //////////////////////////////////////////////////////////////////// INLINE Vertexd EggVertex:: get_pos3() const { nassertr(_num_dimensions == 3, LPoint3d(0.0, 0.0, 0.0)); return Vertexd(_pos[0], _pos[1], _pos[2]); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_pos4 // Access: Public // Description: This is always valid, regardless of the value of // get_num_dimensions. It returns the position as a // four-dimensional value. If the pos has fewer than // four dimensions, this value represents the pos // extended into four-dimensional homogenous space, // e.g. by adding 1 as the fourth component. //////////////////////////////////////////////////////////////////// INLINE LPoint4d EggVertex:: get_pos4() const { return _pos; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::get_index // Access: Public // Description: Returns the index number of the vertex within its // pool. //////////////////////////////////////////////////////////////////// INLINE int EggVertex:: get_index() const { return _index; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::gref_begin // Access: Public // Description: Returns an iterator that can, in conjunction with // gref_end(), be used to traverse the entire set of // groups that reference this vertex. Each iterator // returns a pointer to a group. //////////////////////////////////////////////////////////////////// INLINE EggVertex::GroupRef::const_iterator EggVertex:: gref_begin() const { return _gref.begin(); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::gref_end // Access: Public // Description: Returns an iterator that can, in conjunction with // gref_begin(), be used to traverse the entire set of // groups that reference this vertex. Each iterator // returns a pointer to a group. //////////////////////////////////////////////////////////////////// INLINE EggVertex::GroupRef::const_iterator EggVertex:: gref_end() const { return _gref.end(); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::gref_size // Access: Public // Description: Returns the number of elements between gref_begin() // and gref_end(). //////////////////////////////////////////////////////////////////// INLINE EggVertex::GroupRef::size_type EggVertex:: gref_size() const { return _gref.size(); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::has_gref // Access: Public // Description: Returns true if the indicated group references this // vertex, false otherwise. //////////////////////////////////////////////////////////////////// INLINE bool EggVertex:: has_gref(const EggGroup *group) const { return _gref.count((EggGroup *)group) != 0; } //////////////////////////////////////////////////////////////////// // Function: EggVertex::pref_begin // Access: Public // Description: Returns an iterator that can, in conjunction with // pref_end(), be used to traverse the entire set of // primitives that reference this vertex. Each iterator // returns a pointer to a primitive. //////////////////////////////////////////////////////////////////// INLINE EggVertex::PrimitiveRef::const_iterator EggVertex:: pref_begin() const { return _pref.begin(); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::pref_end // Access: Public // Description: Returns an iterator that can, in conjunction with // pref_begin(), be used to traverse the entire set of // primitives that reference this vertex. Each iterator // returns a pointer to a primitive. //////////////////////////////////////////////////////////////////// INLINE EggVertex::PrimitiveRef::const_iterator EggVertex:: pref_end() const { return _pref.end(); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::pref_size // Access: Public // Description: Returns the number of elements between pref_begin() // and pref_end(). //////////////////////////////////////////////////////////////////// INLINE EggVertex::GroupRef::size_type EggVertex:: pref_size() const { return _pref.size(); } //////////////////////////////////////////////////////////////////// // Function: EggVertex::has_pref // Access: Public // Description: Returns the number of times the vertex appears in the // indicated primitive, or 0 if it does not appear. //////////////////////////////////////////////////////////////////// INLINE int EggVertex:: has_pref(const EggPrimitive *prim) const { return _pref.count((EggPrimitive *)prim); } //////////////////////////////////////////////////////////////////// // Function: UniqueEggVertices::Function operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// INLINE bool UniqueEggVertices:: operator ()(const EggVertex *v1, const EggVertex *v2) const { return v1->sorts_less_than(*v2); }