Panda3D
 All Classes Functions Variables Enumerations
fltFace.cxx
1 // Filename: fltFace.cxx
2 // Created by: drose (25Aug00)
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 #include "fltFace.h"
16 #include "fltRecordReader.h"
17 #include "fltRecordWriter.h"
18 #include "fltHeader.h"
19 #include "fltMaterial.h"
20 
21 TypeHandle FltFace::_type_handle;
22 
23 ////////////////////////////////////////////////////////////////////
24 // Function: FltFace::Constructor
25 // Access: Public
26 // Description:
27 ////////////////////////////////////////////////////////////////////
28 FltFace::
29 FltFace(FltHeader *header) : FltGeometry(header) {
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: FltFace::extract_record
34 // Access: Protected, Virtual
35 // Description: Fills in the information in this bead based on the
36 // information given in the indicated datagram, whose
37 // opcode has already been read. Returns true on
38 // success, false if the datagram is invalid.
39 ////////////////////////////////////////////////////////////////////
40 bool FltFace::
41 extract_record(FltRecordReader &reader) {
42  if (!FltBeadID::extract_record(reader)) {
43  return false;
44  }
45  if (!FltGeometry::extract_record(reader)) {
46  return false;
47  }
48 
49  nassertr(reader.get_opcode() == FO_face, false);
50 
51  DatagramIterator &iterator = reader.get_iterator();
52  check_remaining_size(iterator);
53  return true;
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: FltFace::build_record
58 // Access: Protected, Virtual
59 // Description: Fills up the current record on the FltRecordWriter with
60 // data for this record, but does not advance the
61 // writer. Returns true on success, false if there is
62 // some error.
63 ////////////////////////////////////////////////////////////////////
64 bool FltFace::
65 build_record(FltRecordWriter &writer) const {
66  if (!FltBeadID::build_record(writer)) {
67  return false;
68  }
69  if (!FltGeometry::build_record(writer)) {
70  return false;
71  }
72 
73  writer.set_opcode(FO_face);
74 
75  return true;
76 }
This class writes a sequence of FltRecords to an ostream, handling opcode and size counts properly...
This class turns an istream into a sequence of FltRecords by reading a sequence of Datagrams and extr...
DatagramIterator & get_iterator()
Returns an iterator suitable for extracting data from the current record.
This is a base class for both FltFace and FltMesh, which are two different kinds of geometric primiti...
Definition: fltGeometry.h:36
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition: fltHeader.h:48
void check_remaining_size(const DatagramIterator &di, const string &name=string()) const
Checks that the iterator has no bytes left, as it should at the end of a successfully read record...
Definition: fltRecord.cxx:313
FltOpcode get_opcode() const
Returns the opcode associated with the current record.
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void set_opcode(FltOpcode opcode)
Sets the opcode associated with the current record.