~ubuntu-branches/ubuntu/trusty/qhull/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libqhullcpp/QhullVertex.h

  • Committer: Package Import Robot
  • Author(s): Barak A. Pearlmutter
  • Date: 2014-02-13 11:09:12 UTC
  • mfrom: (8.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20140213110912-ifwyxorlsnnl1ebh
Tags: 2012.1-4
Add convenience link to #include <qhull/qhull.h> to simplify transition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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"
 
16
extern "C" {
 
17
    #include "libqhull/qhull_a.h"
 
18
}
 
19
 
 
20
#include <ostream>
 
21
 
 
22
namespace 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
 
 
43
class QhullVertex {
 
44
 
 
45
private:
 
46
#//Fields
 
47
    vertexT            *qh_vertex;
 
48
 
 
49
#//Class objects
 
50
    static vertexT      s_empty_vertex;  // needed for shallow copy
 
51
 
 
52
public:
 
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
 
 
100
std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex::PrintVertex &pr);
 
101
inline std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex &v) { os << v.print(orgQhull::UsingLibQhull::NOqhRunId); return os; }
 
102
 
 
103
#endif // QHULLVERTEX_H