00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "streams.hh"
00026
00027 namespace GMap3d
00028 {
00029
00030 INLINE
00031 CDartVertex::CDartVertex() :
00032 CDart()
00033 {
00034 }
00035
00036 INLINE
00037 CDartVertex::CDartVertex(const std::bitset<NB_MARKS> & AMarks) :
00038 CDart(AMarks)
00039 {
00040 }
00041
00042 INLINE
00043 CDartVertex::CDartVertex(const CDartVertex & ADart) :
00044 CDart(ADart)
00045 {
00046 }
00047
00048 INLINE
00049 CDartVertex::CDartVertex(const std::bitset<NB_MARKS> & AMarks,
00050 const CVertex & AVertex) :
00051 CDart (AMarks),
00052 FBurstVertex(AVertex)
00053 {
00054 }
00055
00056 INLINE
00057 CDartVertex::CDartVertex(std::istream & AStream, TSaveFormat AFormat) :
00058 CDart()
00059 {
00060 if (!load(AStream, AFormat))
00061 std::cerr << "Erreur: chargement du brin impossible" << std::endl;
00062 }
00063
00064 INLINE
00065 CDartVertex::~CDartVertex()
00066 {}
00067
00068 INLINE
00069 CVertex & CDartVertex::getBurstVertex()
00070 {
00071 return FBurstVertex;
00072 }
00073
00074 INLINE
00075 void CDartVertex::setBurstVertex(const CVertex & AVertex)
00076 {
00077 FBurstVertex = AVertex;
00078 }
00079
00080 INLINE
00081 bool CDartVertex::save(std::ostream & AStream, TSaveFormat AFormat,
00082 int ADirectInfoIndex) const
00083 {
00084
00085 CVertex * vertex =
00086 static_cast<CAttributeVertex *>
00087 (getAttribute(ORBIT_VERTEX, ATTRIBUTE_VERTEX));
00088
00089 bool hasVertex = vertex!=NULL;
00090 int i;
00091
00092
00093 switch (AFormat)
00094 {
00095 case AsciiFormat : setAsciiMode (); break;
00096 case BinaryFormat: setBinaryMode(); break;
00097 default: std::cerr << "CDartVertex.save: Format inconnu!!!" << std::endl;
00098 }
00099
00100
00101 for (i=0; i<=3; ++i)
00102 {
00103 writeInt(AStream,
00104 (uint32_t) (getAlpha(i)->getDirectInfo(ADirectInfoIndex)));
00105 writeTab(AStream);
00106 }
00107
00108
00109 assert(NB_MARKS % 8 == 0);
00110 bool b[8];
00111
00112 for (i=0; i<NB_MARKS; ++i)
00113 {
00114 b[i % 8] = getMark(i);
00115
00116 if (i%8 == 7)
00117 {
00118 writeChar(AStream, bool2char(b));
00119 writeTab(AStream);
00120 }
00121 }
00122
00123
00124 writeBool(AStream, hasVertex);
00125
00126 if (hasVertex)
00127 {
00128 writeTab(AStream); writeCoord(AStream, vertex->getX());
00129 writeTab(AStream); writeCoord(AStream, vertex->getY());
00130 writeTab(AStream); writeCoord(AStream, vertex->getZ());
00131 }
00132
00133 writeRet(AStream);
00134
00135 return AStream.good();
00136 }
00137
00138 INLINE
00139 bool CDartVertex::load(std::istream & AStream, TSaveFormat AFormat)
00140 {
00141 bool hasVertex;
00142
00143
00144 switch (AFormat)
00145 {
00146 case AsciiFormat : setAsciiMode (); break;
00147 case BinaryFormat: setBinaryMode(); break;
00148 default: std::cerr << "CDartVertex.load: Format inconnu!!!" << std::endl;
00149 }
00150
00151
00152 setAlpha0((CDart *) (readInt(AStream)+1));
00153 setAlpha1((CDart *) (readInt(AStream)+1));
00154 setAlpha2((CDart *) (readInt(AStream)+1));
00155 setAlpha3((CDart *) (readInt(AStream)+1));
00156
00157
00158 assert(NB_MARKS % 8 == 0);
00159 bool b[8];
00160
00161 for (int i=0; i<NB_MARKS; ++i)
00162 {
00163 if (i%8 == 0)
00164 char2bool(readChar(AStream), b);
00165
00166 setMark(i, b[i % 8]);
00167 }
00168
00169
00170 hasVertex = readBool(AStream);
00171
00172 if (hasVertex)
00173 {
00174 TCoordinate x = readCoord(AStream);
00175 TCoordinate y = readCoord(AStream);
00176 TCoordinate z = readCoord(AStream);
00177 addAttribute(ORBIT_VERTEX, new CAttributeVertex(x,y,z));
00178 }
00179
00180 return AStream.good();
00181 }
00182
00183 }
00184