From 1ae36cf9e9888d96caeac50d401a2fd0233217b2 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 17 Feb 2001 04:53:24 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/egg/eggVertexPool.I | 128 ++++++++++++++++++++++++ panda/src/egg/eggVertexPool.h | 8 ++ panda/src/pnmimage/pnm-image-filter.cxx | 12 +-- panda/src/putil/string_utils.cxx | 27 +++++ panda/src/putil/string_utils.h | 4 + pandatool/src/cvscopy/cvsCopy.cxx | 2 +- 6 files changed, 174 insertions(+), 7 deletions(-) diff --git a/panda/src/egg/eggVertexPool.I b/panda/src/egg/eggVertexPool.I index b7f99953ff..1b2c221cab 100644 --- a/panda/src/egg/eggVertexPool.I +++ b/panda/src/egg/eggVertexPool.I @@ -4,6 +4,13 @@ //////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::get_vertex +// Access: Public +// Description: Returns the vertex in the pool with the indicated +// index number, or NULL if no vertices have that index +// number. +//////////////////////////////////////////////////////////////////// INLINE EggVertex *EggVertexPool:: get_vertex(int index) const { IndexVertices::const_iterator ivi = _index_vertices.find(index); @@ -15,11 +22,24 @@ get_vertex(int index) const { } } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::indexing operator +// Access: Public +// Description: Returns the vertex in the pool with the indicated +// index number, or NULL if no vertices have that index +// number. +//////////////////////////////////////////////////////////////////// INLINE EggVertex *EggVertexPool:: operator [](int index) const { return get_vertex(index); } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::get_highest_index +// Access: Public +// Description: Returns the highest index number used by any vertex +// in the pool. +//////////////////////////////////////////////////////////////////// INLINE int EggVertexPool:: get_highest_index() const { if (_index_vertices.empty()) { @@ -30,6 +50,12 @@ get_highest_index() const { return (*ivi).first; } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::begin() +// Access: Public +// Description: Returns an iterator that can be used to traverse +// through all the vertices in the pool. +//////////////////////////////////////////////////////////////////// INLINE EggVertexPool::iterator EggVertexPool:: begin() const { nassertr(_index_vertices.size() == _unique_vertices.size(), @@ -37,18 +63,120 @@ begin() const { return iterator(_index_vertices.begin()); } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::end() +// Access: Public +// Description: Returns an iterator that can be used to traverse +// through all the vertices in the pool. +//////////////////////////////////////////////////////////////////// INLINE EggVertexPool::iterator EggVertexPool:: end() const { return iterator(_index_vertices.end()); } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::empty() +// Access: Public +// Description: Returns true if the pool is empty. +//////////////////////////////////////////////////////////////////// INLINE bool EggVertexPool:: empty() const { return _index_vertices.empty(); } +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::size() +// Access: Public +// Description: Returns the number of vertices in the pool. +//////////////////////////////////////////////////////////////////// INLINE EggVertexPool::size_type EggVertexPool:: size() const { nassertr(_index_vertices.size() == _unique_vertices.size(), 0); return _index_vertices.size(); } + +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::make_new_vertex() +// Access: Public +// Description: Allocates and returns a new vertex from the pool. +// This is one of three ways to add new vertices to a +// vertex pool. +//////////////////////////////////////////////////////////////////// +INLINE EggVertex *EggVertexPool:: +make_new_vertex() { + PT(EggVertex) vertex = new EggVertex; + add_vertex(vertex); + return vertex; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::make_new_vertex() +// Access: Public +// Description: Allocates and returns a new vertex from the pool. +// This is one of three ways to add new vertices to a +// vertex pool. +// +// This flavor of make_new_vertex() explicitly sets the +// vertex position as it is allocated. It does not +// attempt to share vertices. +//////////////////////////////////////////////////////////////////// +INLINE EggVertex *EggVertexPool:: +make_new_vertex(double pos) { + EggVertex *vertex = make_new_vertex(); + vertex->set_pos(pos); + return vertex; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::make_new_vertex() +// Access: Public +// Description: Allocates and returns a new vertex from the pool. +// This is one of three ways to add new vertices to a +// vertex pool. +// +// This flavor of make_new_vertex() explicitly sets the +// vertex position as it is allocated. It does not +// attempt to share vertices. +//////////////////////////////////////////////////////////////////// +INLINE EggVertex *EggVertexPool:: +make_new_vertex(const LPoint2d &pos) { + EggVertex *vertex = make_new_vertex(); + vertex->set_pos(pos); + return vertex; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::make_new_vertex() +// Access: Public +// Description: Allocates and returns a new vertex from the pool. +// This is one of three ways to add new vertices to a +// vertex pool. +// +// This flavor of make_new_vertex() explicitly sets the +// vertex position as it is allocated. It does not +// attempt to share vertices. +//////////////////////////////////////////////////////////////////// +INLINE EggVertex *EggVertexPool:: +make_new_vertex(const LPoint3d &pos) { + EggVertex *vertex = make_new_vertex(); + vertex->set_pos(pos); + return vertex; +} + +//////////////////////////////////////////////////////////////////// +// Function: EggVertexPool::make_new_vertex() +// Access: Public +// Description: Allocates and returns a new vertex from the pool. +// This is one of three ways to add new vertices to a +// vertex pool. +// +// This flavor of make_new_vertex() explicitly sets the +// vertex position as it is allocated. It does not +// attempt to share vertices. +//////////////////////////////////////////////////////////////////// +INLINE EggVertex *EggVertexPool:: +make_new_vertex(const LPoint4d &pos) { + EggVertex *vertex = make_new_vertex(); + vertex->set_pos(pos); + return vertex; +} diff --git a/panda/src/egg/eggVertexPool.h b/panda/src/egg/eggVertexPool.h index 67d772c849..6d202e3c5f 100644 --- a/panda/src/egg/eggVertexPool.h +++ b/panda/src/egg/eggVertexPool.h @@ -80,6 +80,14 @@ public: // user to allocate the vertex. void add_vertex(PT(EggVertex) vertex, int index = -1); + // make_new_vertex() allocates and returns a new vertex from the + // pool. + INLINE EggVertex *make_new_vertex(); + INLINE EggVertex *make_new_vertex(double pos); + INLINE EggVertex *make_new_vertex(const LPoint2d &pos); + INLINE EggVertex *make_new_vertex(const LPoint3d &pos); + INLINE EggVertex *make_new_vertex(const LPoint4d &pos); + // create_unique_vertex() creates a new vertex if there is not // already one identical to the indicated vertex, or returns the // existing one if there is. diff --git a/panda/src/pnmimage/pnm-image-filter.cxx b/panda/src/pnmimage/pnm-image-filter.cxx index fa024f9d78..d8bb6d4b39 100644 --- a/panda/src/pnmimage/pnm-image-filter.cxx +++ b/panda/src/pnmimage/pnm-image-filter.cxx @@ -395,10 +395,10 @@ filter_image(PNMImage &dest, const PNMImage &source, filter_red_xy(dest, source, width, make_filter); filter_green_xy(dest, source, width, make_filter); filter_blue_xy(dest, source, width, make_filter); + } - if (dest.has_alpha() && source.has_alpha()) { - filter_alpha_xy(dest, source, width, make_filter); - } + if (dest.has_alpha() && source.has_alpha()) { + filter_alpha_xy(dest, source, width, make_filter); } } else { @@ -408,10 +408,10 @@ filter_image(PNMImage &dest, const PNMImage &source, filter_red_yx(dest, source, width, make_filter); filter_green_yx(dest, source, width, make_filter); filter_blue_yx(dest, source, width, make_filter); + } - if (dest.has_alpha() && source.has_alpha()) { - filter_alpha_yx(dest, source, width, make_filter); - } + if (dest.has_alpha() && source.has_alpha()) { + filter_alpha_yx(dest, source, width, make_filter); } } } diff --git a/panda/src/putil/string_utils.cxx b/panda/src/putil/string_utils.cxx index a4c7ea99d2..8f82abd0e2 100644 --- a/panda/src/putil/string_utils.cxx +++ b/panda/src/putil/string_utils.cxx @@ -96,6 +96,33 @@ extract_words(const string &str, vector_string &words) { return num_words; } +//////////////////////////////////////////////////////////////////// +// Function: tokenize +// Description: Chops the source string up into pieces delimited by +// any of the characters specified in delimiters. +// Repeated delimiter characters represent zero-length +// tokens. +// +// It is the user's responsibility to ensure the output +// vector is cleared before calling this function; the +// results will simply be appended to the end of the +// vector. +//////////////////////////////////////////////////////////////////// +void +tokenize(const string &str, vector_string &words, const string &delimiters) { + size_t p = 0; + while (p < str.length()) { + size_t q = str.find_first_of(delimiters, p); + if (q == string::npos) { + words.push_back(str.substr(p)); + return; + } + words.push_back(str.substr(p, q - p)); + p = q + 1; + } + words.push_back(string()); +} + //////////////////////////////////////////////////////////////////// // Function: trim_left // Description: Returns a new string representing the contents of the diff --git a/panda/src/putil/string_utils.h b/panda/src/putil/string_utils.h index 5c485b6357..29db5201eb 100644 --- a/panda/src/putil/string_utils.h +++ b/panda/src/putil/string_utils.h @@ -24,6 +24,10 @@ EXPCL_PANDA string downcase(const string &s); // Separates the string into words according to whitespace. EXPCL_PANDA int extract_words(const string &str, vector_string &words); +// Separates the string into words according to the indicated delimiters. +EXPCL_PANDA void tokenize(const string &str, vector_string &words, + const string &delimiters); + // Trims leading and/or trailing whitespace from the string. EXPCL_PANDA string trim_left(const string &str); EXPCL_PANDA string trim_right(const string &str); diff --git a/pandatool/src/cvscopy/cvsCopy.cxx b/pandatool/src/cvscopy/cvsCopy.cxx index bd627bfa2b..40f6b938d1 100644 --- a/pandatool/src/cvscopy/cvsCopy.cxx +++ b/pandatool/src/cvscopy/cvsCopy.cxx @@ -158,7 +158,7 @@ handle_args(Args &args) { return false; } - _source_files = args; + _source_files.insert(_source_files.end(), args.begin(), args.end()); return true; }