BALL 1.5.0
Loading...
Searching...
No Matches
graphVertex.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_STRUCTURE_GRAPHVERTEX_H
6#define BALL_STRUCTURE_GRAPHVERTEX_H
7
8#ifndef BALL_COMMON_H
9# include <BALL/common.h>
10#endif
11
12#ifndef BALL_DATATYPE_HASHSET_H
14#endif
15
16namespace BALL
17{
18
19 template <typename Vertex, typename Edge, typename Face>
20 class GraphEdge;
21
22 template <typename Vertex, typename Edge, typename Face>
23 class GraphFace;
24
25 template <typename Vertex, typename Edge, typename Face>
27
31 template <typename Vertex, typename Edge, typename Face>
33 {
34 public:
35
43 friend class GraphEdge<Vertex,Edge,Face>;
44 friend class GraphFace<Vertex,Edge,Face>;
45 friend class GraphTriangle<Vertex,Edge,Face>;
46
48
49
52
53 typedef typename HashSet<Edge*>::Iterator EdgeIterator;
54 typedef typename HashSet<Edge*>::ConstIterator ConstEdgeIterator;
55 typedef typename HashSet<Face*>::Iterator FaceIterator;
56 typedef typename HashSet<Face*>::ConstIterator ConstFaceIterator;
57
59
62
67 ;
68
76 GraphVertex(const GraphVertex<Vertex,Edge,Face>& vertex, bool deep = false)
77 ;
78
82 virtual ~GraphVertex()
83 ;
85
89
97 void set(const GraphVertex<Vertex,Edge,Face>& vertex, bool deep = false)
98 ;
99
105 GraphVertex<Vertex,Edge,Face>& operator =
106 (const GraphVertex<Vertex,Edge,Face>& vertex)
107 ;
108
110
113
117 void insert(Edge* edge)
118 ;
119
123 void insert(Face* face)
124 ;
125
129 void remove(Edge* edge)
130 ;
131
135 void remove(Face* face)
136 ;
137
142 ;
143
148 ;
149
153 void setIndex(Index index)
154 ;
155
160 ;
161
168 bool join(const Vertex& vertex)
169 ;
170
177 bool substitute(Vertex* vertex)
178 ;
179
180
182
185
189 virtual bool operator == (const Vertex&) const
190 ;
191
195 virtual bool operator != (const Vertex&) const
196 ;
197
201 virtual bool operator *= (const Vertex&) const
202 ;
203
208 Face* has(Face* face) const
209 ;
210
215 Edge* has(Edge* edge) const
216 ;
217
220 bool hasEdges() const
221 ;
222
225 bool hasFaces() const
226 ;
227
229
232
234 ;
236 ;
238 ;
240 ;
242 ;
244 ;
246 ;
248 ;
249
251
252 protected:
253
254 /*_ @name Attributes
255 */
257
258 /*_ The RSEdges the RSVetex belongs to
259 */
261 /*_ The RSFaces the RSVetex belongs to
262 */
264 /*_ The index of the GraphVertex
265 */
267
269
270 };
271
272
273
274 template <typename Vertex, typename Edge, typename Face>
276
277 : edges_(),
278 faces_(),
279 index_(-1)
280 {
281 }
282
283
284 template <typename Vertex, typename Edge, typename Face>
286 (const GraphVertex<Vertex,Edge,Face>& vertex, bool deep)
287
288 : edges_(),
289 faces_(),
290 index_(vertex.index_)
291 {
292 if (deep)
293 {
294 edges_ = vertex.edges_;
295 faces_ = vertex.faces_;
296 }
297 }
298
299
300 template <typename Vertex, typename Edge, typename Face>
305
306
307 template <typename Vertex, typename Edge, typename Face>
309 (const GraphVertex<Vertex,Edge,Face>& vertex, bool deep)
310
311 {
312 if (this != &vertex)
313 {
314 if (deep)
315 {
316 edges_ = vertex.edges_;
317 faces_ = vertex.faces_;
318 }
319 index_ = vertex.index_;
320 }
321 }
322
323
324 template <typename Vertex, typename Edge, typename Face>
326 (const GraphVertex<Vertex,Edge,Face>& vertex)
327
328 {
329 if (this != &vertex)
330 {
331 edges_ = vertex.edges_;
332 faces_ = vertex.faces_;
333 index_ = vertex.index_;
334 }
335 return *this;
336 }
337
338
339 template <typename Vertex, typename Edge, typename Face>
341
342 {
343 edges_.insert(edge);
344 }
345
346
347 template <typename Vertex, typename Edge, typename Face>
349
350 {
351 faces_.insert(face);
352 }
353
354
355 template <typename Vertex, typename Edge, typename Face>
357
358 {
359 edges_.erase(edge);
360 }
361
362
363 template <typename Vertex, typename Edge, typename Face>
365
366 {
367 faces_.erase(face);
368 }
369
370
371 template <typename Vertex, typename Edge, typename Face>
373
374 {
375 return edges_.size();
376 }
377
378
379 template <typename Vertex, typename Edge, typename Face>
381
382 {
383 return faces_.size();
384 }
385
386
387 template <typename Vertex, typename Edge, typename Face>
389
390 {
391 index_ = index;
392 }
393
394
395 template <typename Vertex, typename Edge, typename Face>
397
398 {
399 return index_;
400 }
401
402
403 template <typename Vertex, typename Edge, typename Face>
405
406 {
407 if (*this *= *vertex)
408 {
409 typename HashSet<Edge*>::Iterator e;
410 for (e = edges_.begin(); e != edges_.end(); e++)
411 {
412 (*e)->substitute((Vertex*)this,vertex);
413 }
414 typename HashSet<Face*>::Iterator f;
415 for (f = faces_.begin(); f != faces_.end(); f++)
416 {
417 (*f)->substitute((Vertex*)this,vertex);
418 }
419 return true;
420 }
421 return false;
422 }
423
424
425 template <typename Vertex, typename Edge, typename Face>
427
428 {
429 if (*this *= vertex)
430 {
432 for (e = vertex.edges_.begin(); e != vertex.edges_.end(); e++)
433 {
434 edges_.insert(*e);
435 }
437 for (f = vertex.faces_.begin(); f != vertex.faces_.end(); f++)
438 {
439 faces_.insert(*f);
440 }
441 return true;
442 }
443 else
444 {
445 return false;
446 }
447 }
448
449
450 template <typename Vertex, typename Edge, typename Face>
452
453 {
455 for (f = faces_.begin(); f != faces_.end(); f++)
456 {
457 if (*(*f) == *face)
458 {
459 return *f;
460 }
461 }
462 return NULL;
463 }
464
465
466 template <typename Vertex, typename Edge, typename Face>
468
469 {
471 for (e = edges_.begin(); e != edges_.end(); e++)
472 {
473 if (*(*e) == *edge)
474 {
475 return *e;
476 }
477 }
478 return NULL;
479 }
480
481
482 template <typename Vertex, typename Edge, typename Face>
484
485 {
486 return !edges_.isEmpty();
487 }
488
489
490 template <typename Vertex, typename Edge, typename Face>
492
493 {
494 return !faces_.isEmpty();
495 }
496
497
498 template <typename Vertex, typename Edge, typename Face>
501
502 {
503 return edges_.begin();
504 }
505
506
507 template <typename Vertex, typename Edge, typename Face>
510
511 {
512 return edges_.begin();
513 }
514
515
516 template <typename Vertex, typename Edge, typename Face>
519
520 {
521 return edges_.end();
522 }
523
524
525 template <typename Vertex, typename Edge, typename Face>
528
529 {
530 return edges_.end();
531 }
532
533
534 template <typename Vertex, typename Edge, typename Face>
537
538 {
539 return faces_.begin();
540 }
541
542
543 template <typename Vertex, typename Edge, typename Face>
546
547 {
548 return faces_.begin();
549 }
550
551
552 template <typename Vertex, typename Edge, typename Face>
555
556 {
557 return faces_.end();
558 }
559
560
561 template <typename Vertex, typename Edge, typename Face>
564
565 {
566 return faces_.end();
567 }
568
569
570 template <typename Vertex, typename Edge, typename Face>
572
573 {
574 return true;
575 }
576
577
578 template <typename Vertex, typename Edge, typename Face>
580
581 {
582 return false;
583 }
584
585
586 template <typename Vertex, typename Edge, typename Face>
588
589 {
590 return true;
591 }
592
593} // namespace BALL
594
595#endif // BALL_STRUCTURE_GRAPHVERTEX_H
#define BALL_CREATE(name)
Definition create.h:62
static ConstForwardIterator begin(const Container &container)
static ConstForwardIterator end(const Container &container)
static ForwardIterator begin(const Container &container)
static ForwardIterator end(const Container &container)
void set(const GraphVertex< Vertex, Edge, Face > &vertex, bool deep=false)
virtual bool operator!=(const Vertex &) const
Index getIndex() const
bool substitute(Vertex *vertex)
void setIndex(Index index)
EdgeIterator endEdge()
FaceIterator beginFace()
EdgeIterator beginEdge()
void insert(Edge *edge)
HashSet< Edge * > edges_
virtual bool operator==(const Vertex &) const
bool hasEdges() const
HashSet< Face * > faces_
virtual bool operator*=(const Vertex &) const
bool join(const Vertex &vertex)
Face * has(Face *face) const
Position numberOfEdges() const
void remove(Edge *edge)
Position numberOfFaces() const
bool hasFaces() const
FaceIterator endFace()
virtual ~GraphVertex()