00001
00043 #include "GGNode.h"
00044 #include "HelperFunctions.h"
00045 #include "Exceptions.h"
00046 #include <stdio.h>
00047 #include <ctype.h>
00048
00050
00051
00053 istream& GGRelation::Read(istream& is)
00054 {
00055 is.read((char*) this, sizeof(*this));
00056
00057 return is;
00058 }
00059
00061 ostream& GGRelation::Write(ostream& os) const
00062 {
00063 os.write((char*) this, sizeof(*this));
00064
00065 return os;
00066 }
00067
00069 void GGRelation::Print(ostream& os) const
00070 {
00071 os << "(type: " << m_nType << ", scale: " << m_dScaleRatio
00072 << ", orient: " << m_dOrient << ", dist1: " << m_dDist1
00073 << ", dist2: " << m_dDist2 << ", bearing: " << m_dBearing << ')' << endl;
00074 }
00075
00076
00083 istream& operator>>(istream& is, GGRelation& rel)
00084 {
00085 is >> rel.m_nType >> rel.m_dScaleRatio >> rel.m_dOrient
00086 >> rel.m_dDist1 >> rel.m_dDist2 >> rel.m_dBearing;
00087
00088 return is;
00089 }
00090
00091 ostream& operator<<(ostream& os, const GGRelation& rel)
00092 {
00093 os << rel.m_nType << rel.m_dScaleRatio << rel.m_dOrient
00094 << rel.m_dDist1 << rel.m_dDist2 << rel.m_dBearing;
00095
00096 return os;
00097 }
00098
00100
00101
00102
00103
00104
00109 DAGNode* GGNode::CreateObject() const
00110 {
00111 return (DAGNode*) new GGNode();
00112 }
00113
00114 void GGNode::Clear()
00115 {
00116 DAGNode::Clear();
00117
00118 m_nType = 0;
00119 m_dSign = 0;
00120 m_dScale = 0;
00121 m_nXPos = 0;
00122 m_nYPos = 0;
00123 m_dA = 0;
00124 m_dB = 0;
00125 m_dOrientation = 0;
00126 m_dAnisotropy = 0;
00127 m_dUnkField = 0;
00128 m_nNodeIndex = 0;
00129
00130 m_xCoords.Clear();
00131 m_weights.Clear();
00132 m_scales.Clear();
00133 }
00134
00136 DAGNode& GGNode::operator=(const DAGNode& rhs)
00137 {
00138 DAGNode::operator=(rhs);
00139
00140 const GGNode* pRhs = dynamic_cast<const GGNode*>(&rhs);
00141
00142 if (!pRhs)
00143 THROW_EXCEPTION("Invalid pointer type.");
00144
00145 m_nType = pRhs->m_nType;
00146 m_dSign = pRhs->m_dSign;
00147 m_dScale = pRhs->m_dScale;
00148 m_nXPos = pRhs->m_nXPos;
00149 m_nYPos = pRhs->m_nYPos;
00150 m_dA = pRhs->m_dA;
00151 m_dB = pRhs->m_dB;
00152 m_dOrientation = pRhs->m_dOrientation;
00153 m_dAnisotropy = pRhs->m_dAnisotropy;
00154 m_dUnkField = pRhs->m_dUnkField;
00155 m_nNodeIndex = pRhs->m_nNodeIndex;
00156
00157 m_xCoords = pRhs->m_xCoords;
00158 m_weights = pRhs->m_weights;
00159 m_scales = pRhs->m_scales;
00160
00161 return *this;
00162 }
00163
00165 istream& GGNode::Read(istream& is)
00166 {
00167 DAGNode::Read(is);
00168
00169 is.read((char*) &m_nType, sizeof(m_nType));
00170 is.read((char*) &m_dSign, sizeof(m_dSign));
00171 is.read((char*) &m_dScale, sizeof(m_dScale));
00172 is.read((char*) &m_nXPos, sizeof(m_nXPos));
00173 is.read((char*) &m_nYPos, sizeof(m_nYPos));
00174 is.read((char*) &m_dA, sizeof(m_dA));
00175 is.read((char*) &m_dB, sizeof(m_dB));
00176 is.read((char*) &m_dOrientation, sizeof(m_dOrientation));
00177 is.read((char*) &m_dAnisotropy, sizeof(m_dAnisotropy));
00178 is.read((char*) &m_dUnkField, sizeof(m_dUnkField));
00179 is.read((char*) &m_nNodeIndex, sizeof(m_nNodeIndex));
00180
00181 m_xCoords.Read(is);
00182 m_weights.Read(is);
00183 m_scales.Read(is);
00184
00185 return is;
00186 }
00187
00189 ostream& GGNode::Write(ostream& os) const
00190 {
00191 DAGNode::Write(os);
00192
00193 os.write((char*) &m_nType, sizeof(m_nType));
00194 os.write((char*) &m_dSign, sizeof(m_dSign));
00195 os.write((char*) &m_dScale, sizeof(m_dScale));
00196 os.write((char*) &m_nXPos, sizeof(m_nXPos));
00197 os.write((char*) &m_nYPos, sizeof(m_nYPos));
00198 os.write((char*) &m_dA, sizeof(m_dA));
00199 os.write((char*) &m_dB, sizeof(m_dB));
00200 os.write((char*) &m_dOrientation, sizeof(m_dOrientation));
00201 os.write((char*) &m_dAnisotropy, sizeof(m_dAnisotropy));
00202 os.write((char*) &m_dUnkField, sizeof(m_dUnkField));
00203 os.write((char*) &m_nNodeIndex, sizeof(m_nNodeIndex));
00204
00205 m_xCoords.Write(os);
00206 m_weights.Write(os);
00207 m_scales.Write(os);
00208
00209 return os;
00210 }
00211
00213 void GGNode::Print(ostream& os) const
00214 {
00215 DAGNode::Print(os);
00216
00217 os << endl;
00218
00219 PRINT(os, m_nType);
00220 PRINT(os, m_dSign);
00221 PRINT(os, m_dScale);
00222 PRINT(os, m_nXPos);
00223 PRINTN(os, m_nYPos);
00224 PRINT(os, m_dA);
00225 PRINT(os, m_dB);
00226 PRINT(os, m_dOrientation);
00227 PRINT(os, m_dAnisotropy);
00228 PRINT(os, m_dUnkField);
00229 PRINTN(os, m_nNodeIndex);
00230
00231 m_xCoords.Print(os);
00232 m_weights.Print(os);
00233 m_scales.Print(os);
00234
00235 }
00236
00237
00238
00239
00240