Panda3D
geomVertexRewriter.I
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.I
10  * @author drose
11  * @date 2005-03-28
12  */
13 
14 /**
15  * Constructs an invalid GeomVertexRewriter. You must use the assignment
16  * operator to assign a valid GeomVertexRewriter to this object before you can
17  * use it.
18  */
20 GeomVertexRewriter(Thread *current_thread) :
21  GeomVertexWriter(current_thread),
22  GeomVertexReader(current_thread)
23 {
24 }
25 
26 /**
27  * Constructs a new rewriter to process the vertices of the indicated data
28  * object.
29  */
31 GeomVertexRewriter(GeomVertexData *vertex_data, Thread *current_thread) :
32  GeomVertexWriter(vertex_data, current_thread),
33  GeomVertexReader(vertex_data, current_thread)
34 {
35 }
36 
37 /**
38  * Constructs a new rewriter to process the vertices of the indicated data
39  * object. This flavor creates the rewriter specifically to process the named
40  * data type.
41  */
44  Thread *current_thread) :
45  GeomVertexWriter(vertex_data, current_thread),
46  GeomVertexReader(vertex_data, current_thread)
47 {
48  set_column(std::move(name));
49 }
50 
51 /**
52  * Constructs a new rewriter to process the vertices of the indicated array
53  * only.
54  */
56 GeomVertexRewriter(GeomVertexArrayData *array_data, Thread *current_thread) :
57  GeomVertexWriter(array_data, current_thread),
58  GeomVertexReader(array_data, current_thread)
59 {
60 }
61 
62 /**
63  * Constructs a new rewriter to process the vertices of the indicated array
64  * only.
65  */
67 GeomVertexRewriter(GeomVertexArrayData *array_data, int column,
68  Thread *current_thread) :
69  GeomVertexWriter(array_data, current_thread),
70  GeomVertexReader(array_data, current_thread)
71 {
72  set_column(column);
73 }
74 
75 /**
76  *
77  */
80  GeomVertexWriter(copy),
81  GeomVertexReader(copy)
82 {
83 }
84 
85 /**
86  *
87  */
88 INLINE void GeomVertexRewriter::
89 operator = (const GeomVertexRewriter &copy) {
90  GeomVertexWriter::operator = (copy);
91  GeomVertexReader::operator = (copy);
92 }
93 
94 /**
95  *
96  */
97 INLINE GeomVertexRewriter::
98 ~GeomVertexRewriter() {
99 }
100 
101 /**
102  * Returns the vertex data object that the rewriter is processing.
103  */
109 }
110 
111 /**
112  * Returns the particular array object that the rewriter is currently
113  * processing.
114  */
116 get_array_data() const {
120 }
121 
122 /**
123  * Returns the write handle to the array object that the rewriter is currently
124  * processing. This low-level call should be used with caution; be careful
125  * with modifying the data in the handle out from under the
126  * GeomVertexRewriter.
127  */
131 }
132 
133 /**
134  * Returns the per-row stride (bytes between consecutive rows) of the
135  * underlying vertex array. This low-level information is normally not needed
136  * to use the GeomVertexRewriter directly.
137  */
138 INLINE size_t GeomVertexRewriter::
139 get_stride() const {
142 }
143 
144 /**
145  * Returns the Thread pointer of the currently-executing thread, as passed to
146  * the constructor of this object.
147  */
153 }
154 
155 /**
156  * Sets up the rewriter to use the nth data type of the GeomVertexFormat,
157  * numbering from 0.
158  *
159  * This also resets both the read and write row numbers to the start row (the
160  * same value passed to a previous call to set_row(), or 0 if set_row() was
161  * never called.)
162  *
163  * The return value is true if the data type is valid, false otherwise.
164  */
165 INLINE bool GeomVertexRewriter::
166 set_column(int column) {
167  // It's important to invoke the writer first, then the reader. See
168  // set_row().
170  return GeomVertexReader::set_column(column);
171 }
172 
173 /**
174  * Sets up the rewriter to use the data type with the indicated name.
175  *
176  * This also resets both the read and write row numbers to the start row (the
177  * same value passed to a previous call to set_row(), or 0 if set_row() was
178  * never called.)
179  *
180  * The return value is true if the data type is valid, false otherwise.
181  */
182 INLINE bool GeomVertexRewriter::
184  // It's important to invoke the writer first, then the reader. See
185  // set_row().
187  return GeomVertexReader::set_column(std::move(name));
188 }
189 
190 /**
191  * Sets up the rewriter to use the indicated column description on the given
192  * array.
193  *
194  * This also resets both the read and write row numbers to the start row (the
195  * same value passed to a previous call to set_row(), or 0 if set_row() was
196  * never called.)
197  *
198  * The return value is true if the data type is valid, false otherwise.
199  */
200 INLINE bool GeomVertexRewriter::
201 set_column(int array, const GeomVertexColumn *column) {
202  // It's important to invoke the writer first, then the reader. See
203  // set_row().
204  GeomVertexWriter::set_column(array, column);
205  return GeomVertexReader::set_column(array, column);
206 }
207 
208 /**
209  * Resets the GeomVertexRewriter to the initial state.
210  */
211 INLINE void GeomVertexRewriter::
212 clear() {
215 }
216 
217 /**
218  * Returns true if a valid data type has been successfully set, or false if
219  * the data type does not exist.
220  */
221 INLINE bool GeomVertexRewriter::
222 has_column() const {
223  nassertr(GeomVertexWriter::get_column() ==
226 }
227 
228 /**
229  * Returns the array index containing the data type that the rewriter is
230  * working on.
231  */
232 INLINE int GeomVertexRewriter::
233 get_array() const {
234  nassertr(GeomVertexWriter::get_array() ==
237 }
238 
239 /**
240  * Returns the description of the data type that the rewriter is working on.
241  */
243 get_column() const {
244  nassertr(GeomVertexWriter::get_column() ==
245  GeomVertexReader::get_column(), nullptr);
247 }
248 
249 /**
250  * Sets the start row to the indicated value, without internal checks. This
251  * is the same as set_row(), but it does not check for the possibility that
252  * the array has been reallocated internally for some reason; use only when
253  * you are confident that the array is unchanged and you really need every bit
254  * of available performance.
255  */
256 INLINE void GeomVertexRewriter::
257 set_row_unsafe(int row) {
258  // It's important to invoke the Writer first, since that might force a
259  // recopy of the array, which might invalidate the pointer already stored by
260  // the Reader if we invoked the Reader first.
263 }
264 
265 /**
266  * Sets the start, write, and write index to the indicated value. The
267  * rewriter will begin traversing from the given row.
268  */
269 INLINE void GeomVertexRewriter::
270 set_row(int row) {
273 }
274 
275 /**
276  * Returns the row index at which the rewriter started. It will return to
277  * this row if you reset the current column.
278  */
279 INLINE int GeomVertexRewriter::
280 get_start_row() const {
281  nassertr(GeomVertexWriter::get_start_row() ==
284 }
285 
286 /**
287  * Returns true if the reader or writer is currently at the end of the list of
288  * vertices, false otherwise.
289  */
290 INLINE bool GeomVertexRewriter::
291 is_at_end() const {
293 }
bool is_at_end() const
Returns true if the reader or writer is currently at the end of the list of vertices,...
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:193
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.
void clear()
Resets the GeomVertexWriter to the initial state.
int get_array() const
Returns the array index containing the data type that the writer is working on.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the reader is working on.
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array.
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the rewriter is currently processing.
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.
bool set_column(int column)
Sets up the rewriter to use the nth data type of the GeomVertexFormat, numbering from 0.
This defines how a single column is interleaved within a vertex array stored within a Geom.
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the writer is currently processing.
bool is_at_end() const
Returns true if the writer is currently at the end of the list of vertices, false otherwise.
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the rewriter is currently processing.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
GeomVertexRewriter(Thread *current_thread=Thread::get_current_thread())
Constructs an invalid GeomVertexRewriter.
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array.
int get_array() const
Returns the array index containing the data type that the rewriter is working on.
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...
void clear()
Resets the GeomVertexRewriter to the initial state.
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.
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
A thread; that is, a lightweight process.
Definition: thread.h:46
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
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.
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the writer is currently processing.
bool set_column(int column)
Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
int get_start_row() const
Returns the row index at which the rewriter started.
void set_row(int row)
Sets the start row to the indicated value.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the writer is processing.
void clear()
Resets the GeomVertexReader to the initial state.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the rewriter is processing.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the rewriter is working on.
int get_start_row() const
Returns the row index at which the reader started.
int get_start_row() const
Returns the row index at which the writer started.
This object provides the functionality of both a GeomVertexReader and a GeomVertexWriter,...
This is the data for one array of a GeomVertexData structure.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the writer is working on.
void set_row(int row)
Sets the start, write, and write index to the indicated value.