00001 /**************************************************************************** 00002 ** 00003 ** Copyright (c) 2008-2011 C.B. Barber. All rights reserved. 00004 ** $Id: //main/2011/qhull/src/libqhullcpp/QhullVertex.h#5 $$Change: 1382 $ 00005 ** $DateTime: 2011/05/14 10:45:42 $$Author: bbarber $ 00006 ** 00007 ****************************************************************************/ 00008 00009 #ifndef QHULLVERTEX_H 00010 #define QHULLVERTEX_H 00011 00012 #include "UsingLibQhull.h" 00013 #include "QhullPoint.h" 00014 #include "QhullLinkedList.h" 00015 #include "QhullSet.h" 00016 extern "C" { 00017 #include "libqhull/qhull_a.h" 00018 } 00019 00020 #include <ostream> 00021 00022 namespace orgQhull { 00023 00024 #//ClassRef 00025 class QhullFacetSet; 00026 00027 #//Types 00028 00029 class QhullVertex; 00030 typedef QhullLinkedList<QhullVertex> QhullVertexList; 00031 typedef QhullLinkedListIterator<QhullVertex> QhullVertexListIterator; 00032 00033 00034 /********************* 00035 topological information: 00036 next,previous doubly-linked list of all vertices 00037 neighborFacets set of adjacent facets (only if qh.VERTEXneighbors) 00038 00039 geometric information: 00040 point array of DIM coordinates 00041 */ 00042 00043 class QhullVertex { 00044 00045 private: 00046 #//Fields 00047 vertexT *qh_vertex; 00048 00049 #//Class objects 00050 static vertexT s_empty_vertex; // needed for shallow copy 00051 00052 public: 00053 #//Constants 00054 00055 #//Constructors 00056 QhullVertex() : qh_vertex(&s_empty_vertex) {} 00057 // Creates an alias. Does not copy QhullVertex. Needed for return by value and parameter passing 00058 QhullVertex(const QhullVertex &o) : qh_vertex(o.qh_vertex) {} 00059 // Creates an alias. Does not copy QhullVertex. Needed for vector<QhullVertex> 00060 QhullVertex &operator=(const QhullVertex &o) { qh_vertex= o.qh_vertex; return *this; } 00061 ~QhullVertex() {} 00062 00063 #//Conversion 00064 //Implicit conversion from vertexT 00065 QhullVertex(vertexT *v) : qh_vertex(v ? v : &s_empty_vertex) {} 00066 vertexT *getVertexT() const { return qh_vertex; } 00067 00068 #//QhullSet<QhullVertex> 00069 vertexT *getBaseT() const { return getVertexT(); } 00070 00071 #//getSet 00072 int dimension() const { return (qh_vertex->dim || !isDefined()) ? qh_vertex->dim : UsingLibQhull::globalVertexDimension(); } 00073 int id() const { return qh_vertex->id; } 00074 bool isDefined() const { return qh_vertex != &s_empty_vertex; } 00076 bool neighborFacetsDefined() const { return qh_vertex->neighbors != 0; } 00077 QhullVertex next() const { return qh_vertex->next; } 00078 bool operator==(const QhullVertex &o) const { return qh_vertex==o.qh_vertex; } 00079 bool operator!=(const QhullVertex &o) const { return !operator==(o); } 00080 QhullPoint point() const { return QhullPoint(dimension(), qh_vertex->point); } 00081 QhullVertex previous() const { return qh_vertex->previous; } 00082 00083 #//ForEach 00084 //See also QhullVertexList 00085 QhullFacetSet neighborFacets() const; 00086 00087 #//IO 00088 struct PrintVertex{ 00089 const QhullVertex *vertex; 00090 int run_id; 00091 PrintVertex(int qhRunId, const QhullVertex &v) : vertex(&v), run_id(qhRunId) {} 00092 };//PrintVertex 00093 PrintVertex print(int qhRunId) const { return PrintVertex(qhRunId, *this); } 00094 };//class QhullVertex 00095 00096 }//namespace orgQhull 00097 00098 #//GLobal 00099 00100 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex::PrintVertex &pr); 00101 inline std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex &v) { os << v.print(orgQhull::UsingLibQhull::NOqhRunId); return os; } 00102 00103 #endif // QHULLVERTEX_H