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