Moka kernel
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dart-vertex.icc
Go to the documentation of this file.
1 /*
2  * lib-gmapkernel : Un noyau de 3-G-cartes et des opérations.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-gmapkernel
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 //******************************************************************************
25 #include "streams.hh"
26 //******************************************************************************
27 namespace GMap3d
28 {
29 //******************************************************************************
30 INLINE
32  CDart()
33 {
34 }
35 //******************************************************************************
36 INLINE
37 CDartVertex::CDartVertex(const std::bitset<NB_MARKS> & AMarks) :
38  CDart(AMarks)
39 {
40 }
41 //******************************************************************************
42 INLINE
44  CDart(ADart)
45 {
46 }
47 //******************************************************************************
48 INLINE
49 CDartVertex::CDartVertex(const std::bitset<NB_MARKS> & AMarks,
50  const CVertex & AVertex) :
51  CDart (AMarks),
52  FBurstVertex(AVertex)
53 {
54 }
55 //******************************************************************************
56 INLINE
57 CDartVertex::CDartVertex(std::istream & AStream, TSaveFormat AFormat) :
58  CDart()
59 {
60  if (!load(AStream, AFormat))
61  std::cerr << "Erreur: chargement du brin impossible" << std::endl;
62 }
63 //******************************************************************************
64 INLINE
66 {}
67 //******************************************************************************
68 INLINE
70 {
71  return FBurstVertex;
72 }
73 //------------------------------------------------------------------------------
74 INLINE
75 void CDartVertex::setBurstVertex(const CVertex & AVertex)
76 {
77  FBurstVertex = AVertex;
78 }
79 //******************************************************************************
80 INLINE
81 bool CDartVertex::save(std::ostream & AStream, TSaveFormat AFormat,
82  int ADirectInfoIndex) const
83 {
84  // Initialisations:
85  CVertex * vertex =
86  static_cast<CAttributeVertex *>
88 
89  bool hasVertex = vertex!=NULL;
90  int i;
91 
92  // Positionnement du format d'écriture:
93  switch (AFormat)
94  {
95  case AsciiFormat : setAsciiMode (); break;
96  case BinaryFormat: setBinaryMode(); break;
97  default: std::cerr << "CDartVertex.save: Format inconnu!!!" << std::endl;
98  }
99 
100  // Écriture des alpha-i:
101  for (i=0; i<=3; ++i)
102  {
103  writeInt(AStream,
104  (long int) (getAlpha(i)->getDirectInfo(ADirectInfoIndex)));
105  writeTab(AStream);
106  }
107 
108  // Écriture de l'état des marques:
109  assert(NB_MARKS % 8 == 0);
110  bool b[8];
111 
112  for (i=0; i<NB_MARKS; ++i)
113  {
114  b[i % 8] = getMark(i);
115 
116  if (i%8 == 7)
117  {
118  writeChar(AStream, bool2char(b));
119  writeTab(AStream);
120  }
121  }
122 
123  // Écriture du plongement sommet éventuel:
124  writeBool(AStream, hasVertex);
125 
126  if (hasVertex)
127  {
128  writeTab(AStream); writeCoord(AStream, vertex->getX());
129  writeTab(AStream); writeCoord(AStream, vertex->getY());
130  writeTab(AStream); writeCoord(AStream, vertex->getZ());
131  }
132 
133  writeRet(AStream);
134 
135  return AStream.good();
136 }
137 //******************************************************************************
138 INLINE
139 bool CDartVertex::load(std::istream & AStream, TSaveFormat AFormat)
140 {
141  bool hasVertex;
142 
143  // Positionnement du format de lecture:
144  switch (AFormat)
145  {
146  case AsciiFormat : setAsciiMode (); break;
147  case BinaryFormat: setBinaryMode(); break;
148  default: std::cerr << "CDartVertex.load: Format inconnu!!!" << std::endl;
149  }
150 
151  // Lecture des alpha-i:
152  setAlpha0((CDart *) (readInt(AStream)+1));
153  setAlpha1((CDart *) (readInt(AStream)+1));
154  setAlpha2((CDart *) (readInt(AStream)+1));
155  setAlpha3((CDart *) (readInt(AStream)+1));
156 
157  // Lecture de l'état des marques:
158  assert(NB_MARKS % 8 == 0);
159  bool b[8];
160 
161  for (int i=0; i<NB_MARKS; ++i)
162  {
163  if (i%8 == 0)
164  char2bool(readChar(AStream), b);
165 
166  setMark(i, b[i % 8]);
167  }
168 
169  // Lecture du plongement sommet éventuel:
170  hasVertex = readBool(AStream);
171 
172  if (hasVertex)
173  {
174  TCoordinate x = readCoord(AStream);
175  TCoordinate y = readCoord(AStream);
176  TCoordinate z = readCoord(AStream);
178  }
179 
180  return AStream.good();
181 }
182 //******************************************************************************
183 } // namespace GMap3d
184 //******************************************************************************