Panda3D
eggVertexAux.cxx
1 // Filename: eggVertexAux.cxx
2 // Created by: jenes (15Nov11)
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 "eggVertexAux.h"
16 #include "eggParameters.h"
17 
18 #include "indent.h"
19 
20 TypeHandle EggVertexAux::_type_handle;
21 
22 ////////////////////////////////////////////////////////////////////
23 // Function: EggVertexAux::Constructor
24 // Access: Published
25 // Description:
26 ////////////////////////////////////////////////////////////////////
27 EggVertexAux::
28 EggVertexAux(const string &name, const LVecBase4d &aux) :
29  EggNamedObject(name),
30  _aux(aux)
31 {
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: EggVertexAux::Copy Constructor
36 // Access: Published
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 EggVertexAux::
40 EggVertexAux(const EggVertexAux &copy) :
41  EggNamedObject(copy),
42  _aux(copy._aux)
43 {
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: EggVertexAux::Copy Assignment Operator
48 // Access: Published
49 // Description:
50 ////////////////////////////////////////////////////////////////////
51 EggVertexAux &EggVertexAux::
52 operator = (const EggVertexAux &copy) {
53  EggNamedObject::operator = (copy);
54  _aux = copy._aux;
55 
56  return (*this);
57 }
58 
59 ////////////////////////////////////////////////////////////////////
60 // Function: EggVertexAux::Destructor
61 // Access: Published, Virtual
62 // Description:
63 ////////////////////////////////////////////////////////////////////
64 EggVertexAux::
65 ~EggVertexAux() {
66 }
67 
68 ////////////////////////////////////////////////////////////////////
69 // Function: EggVertexAux::make_average
70 // Access: Published, Static
71 // Description: Creates a new EggVertexAux that contains the
72 // averaged values of the two given objects. It is
73 // an error if they don't have the same name.
74 ///////////////////////////////////////////////////////////////////
75 PT(EggVertexAux) EggVertexAux::
76 make_average(const EggVertexAux *first, const EggVertexAux *second) {
77  nassertr(first->get_name() == second->get_name(), NULL);
78 
79  LVecBase4d aux = (first->_aux + second->_aux) / 2;
80  return new EggVertexAux(first->get_name(), aux);
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: EggVertexAux::write
85 // Access: Public
86 // Description:
87 ////////////////////////////////////////////////////////////////////
88 void EggVertexAux::
89 write(ostream &out, int indent_level) const {
90  string inline_name = get_name();
91  if (!inline_name.empty()) {
92  inline_name += ' ';
93  }
94  indent(out, indent_level)
95  << "<Aux> " << inline_name << "{ " << get_aux() << " }\n";
96 }
97 
98 ////////////////////////////////////////////////////////////////////
99 // Function: EggVertexAux::compare_to
100 // Access: Public
101 // Description: An ordering operator to compare two vertices for
102 // sorting order. This imposes an arbitrary ordering
103 // useful to identify unique vertices.
104 ////////////////////////////////////////////////////////////////////
105 int EggVertexAux::
106 compare_to(const EggVertexAux &other) const {
107  int compare;
108  compare = _aux.compare_to(other._aux, egg_parameters->_pos_threshold);
109  if (compare != 0) {
110  return compare;
111  }
112 
113  return 0;
114 }
int compare_to(const EggVertexAux &other) const
An ordering operator to compare two vertices for sorting order.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:1677
The set of named auxiliary data that may or may not be assigned to a vertex.
Definition: eggVertexAux.h:33
int compare_to(const LVecBase4d &other) const
This flavor of compare_to uses a default threshold value based on the numeric type.
Definition: lvecBase4.h:2554
This is a fairly low-level base class–any egg object that has a name.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
const LVecBase4d & get_aux() const
Returns the auxiliary data quadruple.
Definition: eggVertexAux.I:32