Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/qhull-2012.1/src/libqhullcpp/QhullVertex.h @ 10207

Last change on this file since 10207 was 10207, checked in by ascheibe, 11 years ago

#1886 added a unit test for volume calculation and the qhull library

File size: 3.9 KB
Line 
1/****************************************************************************
2**
3** Copyright (c) 2008-2012 C.B. Barber. All rights reserved.
4** $Id: //main/2011/qhull/src/libqhullcpp/QhullVertex.h#6 $$Change: 1464 $
5** $DateTime: 2012/01/25 22:58:41 $$Author: bbarber $
6**
7****************************************************************************/
8
9#ifndef QHULLVERTEX_H
10#define QHULLVERTEX_H
11
12#include "UsingLibQhull.h"
13#include "QhullPoint.h"
14#include "QhullLinkedList.h"
15#include "QhullSet.h"
16extern "C" {
17    #include "libqhull/qhull_a.h"
18}
19
20#include <ostream>
21
22namespace orgQhull {
23
24#//ClassRef
25    class QhullFacetSet;
26
27#//Types
28    //! QhullVertex -- Qhull's vertex structure, vertexT [libqhull.h], as a C++ class
29    class QhullVertex;
30    typedef QhullLinkedList<QhullVertex> QhullVertexList;
31    typedef QhullLinkedListIterator<QhullVertex> QhullVertexListIterator;
32
33
34/*********************
35  topological information:
36    next,previous       doubly-linked list of all vertices
37    neighborFacets           set of adjacent facets (only if qh.VERTEXneighbors)
38
39  geometric information:
40    point               array of DIM coordinates
41*/
42
43class QhullVertex {
44
45private:
46#//Fields
47    vertexT            *qh_vertex;
48
49#//Class objects
50    static vertexT      s_empty_vertex;  // needed for shallow copy
51
52public:
53#//Constants
54
55#//Constructors
56                        QhullVertex() : qh_vertex(&s_empty_vertex) {}
57                        // Creates an alias.  Does not copy QhullVertex.  Needed for return by value and parameter passing
58                        QhullVertex(const QhullVertex &o) : qh_vertex(o.qh_vertex) {}
59                        // Creates an alias.  Does not copy QhullVertex.  Needed for vector<QhullVertex>
60    QhullVertex        &operator=(const QhullVertex &o) { qh_vertex= o.qh_vertex; return *this; }
61                       ~QhullVertex() {}
62
63#//Conversion
64                        //Implicit conversion from vertexT
65                        QhullVertex(vertexT *v) : qh_vertex(v ? v : &s_empty_vertex) {}
66    vertexT            *getVertexT() const { return qh_vertex; }
67
68#//QhullSet<QhullVertex>
69    vertexT            *getBaseT() const { return getVertexT(); }
70
71#//getSet
72    int                 dimension() const { return (qh_vertex->dim || !isDefined()) ? qh_vertex->dim : UsingLibQhull::globalVertexDimension(); }
73    int                 id() const { return qh_vertex->id; }
74    bool                isDefined() const { return qh_vertex != &s_empty_vertex; }
75                        //! True if defineVertexNeighborFacets() already called.  Auotomatically set for facet merging, Voronoi diagrams
76    bool                neighborFacetsDefined() const { return qh_vertex->neighbors != 0; }
77    QhullVertex         next() const { return qh_vertex->next; }
78    bool                operator==(const QhullVertex &o) const { return qh_vertex==o.qh_vertex; }
79    bool                operator!=(const QhullVertex &o) const { return !operator==(o); }
80    QhullPoint          point() const { return QhullPoint(dimension(), qh_vertex->point); }
81    QhullVertex         previous() const { return qh_vertex->previous; }
82
83#//ForEach
84    //See also QhullVertexList
85    QhullFacetSet       neighborFacets() const;
86
87#//IO
88    struct PrintVertex{
89        const QhullVertex *vertex;
90        int             run_id;
91                        PrintVertex(int qhRunId, const QhullVertex &v) : vertex(&v), run_id(qhRunId) {}
92    };//PrintVertex
93    PrintVertex         print(int qhRunId) const { return PrintVertex(qhRunId, *this); }
94};//class QhullVertex
95
96}//namespace orgQhull
97
98#//GLobal
99
100std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex::PrintVertex &pr);
101inline std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex &v) { os << v.print(orgQhull::UsingLibQhull::NOqhRunId); return os; }
102
103#endif // QHULLVERTEX_H
Note: See TracBrowser for help on using the repository browser.