Panda3D
geomVertexRewriter.h
1 // Filename: geomVertexRewriter.h
2 // Created by: drose (28Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef GEOMVERTEXREWRITER_H
16 #define GEOMVERTEXREWRITER_H
17 
18 #include "pandabase.h"
19 #include "geomVertexReader.h"
20 #include "geomVertexWriter.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : GeomVertexRewriter
24 // Description : This object provides the functionality of both a
25 // GeomVertexReader and a GeomVertexWriter, combined
26 // together into one convenient package. It is designed
27 // for making a single pass over a GeomVertexData
28 // object, modifying rows as it goes.
29 //
30 // Although it doesn't provide any real performance
31 // benefit over using a separate reader and writer on
32 // the same data, it should probably be used in
33 // preference to a separate reader and writer, because
34 // it makes an effort to manage the reference counts
35 // properly between the reader and the writer to avoid
36 // accidentally dereferencing either array while
37 // recopying.
38 ////////////////////////////////////////////////////////////////////
39 class EXPCL_PANDA_GOBJ GeomVertexRewriter : public GeomVertexWriter, public GeomVertexReader {
40 PUBLISHED:
41  INLINE GeomVertexRewriter(Thread *current_thread = Thread::get_current_thread());
42  INLINE GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread = Thread::get_current_thread());
43  INLINE GeomVertexRewriter(GeomVertexData *vertex_data,
44  CPT_InternalName name,
45  Thread *current_thread = Thread::get_current_thread());
46  INLINE GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread = Thread::get_current_thread());
47  INLINE GeomVertexRewriter(GeomVertexArrayData *array_data,
48  int column, Thread *current_thread = Thread::get_current_thread());
49  INLINE GeomVertexRewriter(const GeomVertexRewriter &copy);
50  INLINE void operator = (const GeomVertexRewriter &copy);
51  INLINE ~GeomVertexRewriter();
52 
53  INLINE GeomVertexData *get_vertex_data() const;
54  INLINE GeomVertexArrayData *get_array_data() const;
56  INLINE size_t get_stride() const;
57  INLINE Thread *get_current_thread() const;
58 
59  INLINE bool set_column(int column);
60  INLINE bool set_column(CPT_InternalName name);
61  INLINE bool set_column(int array, const GeomVertexColumn *column);
62 
63  INLINE void clear();
64  INLINE bool has_column() const;
65  INLINE int get_array() const;
66  INLINE const GeomVertexColumn *get_column() const;
67 
68  INLINE void set_row_unsafe(int row);
69  INLINE void set_row(int row);
70 
71  INLINE int get_start_row() const;
72  INLINE bool is_at_end() const;
73 
74  void output(ostream &out) const;
75 };
76 
77 INLINE ostream &
78 operator << (ostream &out, const GeomVertexRewriter &rewriter) {
79  rewriter.output(out);
80  return out;
81 }
82 
83 #include "geomVertexRewriter.I"
84 
85 #endif
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition: internalName.h:197
const GeomVertexArrayData * get_array_data() const
Returns the particular array object that the reader is currently processing.
bool set_column(int column)
Sets up the reader to use the nth data type of the GeomVertexFormat, numbering from 0...
const GeomVertexColumn * get_column() const
Returns the description of the data type that the reader is working on.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array...
const GeomVertexData * get_vertex_data() const
Returns the vertex data object that the reader is processing.
This defines how a single column is interleaved within a vertex array stored within a Geom...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
const GeomVertexArrayDataHandle * get_array_handle() const
Returns the read handle to the array object that the read is currently processing.
void set_row(int row)
Sets the start row to the indicated value.
int get_array() const
Returns the array index containing the data type that the reader is working on.
A thread; that is, a lightweight process.
Definition: thread.h:51
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
bool is_at_end() const
Returns true if the reader is currently at the end of the list of vertices, false otherwise...
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
void clear()
Resets the GeomVertexReader to the initial state.
int get_start_row() const
Returns the row index at which the reader started.
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter, combined together into one convenient package.
This is the data for one array of a GeomVertexData structure.