Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:56

0001 /****************************************************************************
0002 **
0003 ** Copyright (c) 2008-2020 C.B. Barber. All rights reserved.
0004 ** $Id: //main/2019/qhull/src/libqhullcpp/QhullVertex.h#4 $$Change: 3001 $
0005 ** $DateTime: 2020/07/24 20:43:28 $$Author: bbarber $
0006 **
0007 ****************************************************************************/
0008 
0009 #ifndef QHULLVERTEX_H
0010 #define QHULLVERTEX_H
0011 
0012 #include "libqhull_r/qhull_ra.h"
0013 #include "libqhullcpp/QhullPoint.h"
0014 #include "libqhullcpp/QhullLinkedList.h"
0015 #include "libqhullcpp/QhullSet.h"
0016 
0017 #include <ostream>
0018 
0019 namespace orgQhull {
0020 
0021 #//!\name Used here
0022     class QhullFacetSet;
0023 
0024 #//!\name Defined here
0025     //! QhullVertex -- Qhull's vertex structure, vertexT [libqhull_r.h], as a C++ class
0026     class QhullVertex;
0027     typedef QhullLinkedList<QhullVertex> QhullVertexList;
0028     typedef QhullLinkedListIterator<QhullVertex> QhullVertexListIterator;
0029 
0030 
0031 /*********************
0032   topological information:
0033     next,previous       doubly-linked list of all vertices
0034     neighborFacets           set of adjacent facets (only if qh.VERTEXneighbors)
0035 
0036   geometric information:
0037     point               array of DIM coordinates
0038 */
0039 
0040 class QhullVertex {
0041 
0042 #//!\name Defined here
0043 public:
0044     typedef vertexT *   base_type;  // for QhullVertexSet
0045 
0046 private:
0047 #//!\name Fields
0048     vertexT *           qh_vertex;  //!< Corresponding vertexT, never 0
0049     QhullQh *           qh_qh;      //!< QhullQh/qhT for vertexT, may be 0
0050 
0051 #//!\name Class objects
0052     static vertexT      s_empty_vertex;  // needed for shallow copy
0053 
0054 public:
0055 #//!\name Constants
0056 
0057 #//!\name Constructors
0058                         QhullVertex() : qh_vertex(&s_empty_vertex), qh_qh(0) {}
0059     explicit            QhullVertex(const Qhull &q);
0060                         QhullVertex(const Qhull &q, vertexT *v);
0061     explicit            QhullVertex(QhullQh *qqh) : qh_vertex(&s_empty_vertex), qh_qh(qqh) {}
0062                         QhullVertex(QhullQh *qqh, vertexT *v) : qh_vertex(v ? v : &s_empty_vertex), qh_qh(qqh) {}
0063                         // Creates an alias.  Does not copy QhullVertex.  Needed for return by value and parameter passing
0064                         QhullVertex(const QhullVertex &other);
0065                         // Creates an alias.  Does not copy QhullVertex.  Needed for vector<QhullVertex>
0066     QhullVertex &       operator=(const QhullVertex &other) { qh_vertex= other.qh_vertex; qh_qh= other.qh_qh; return *this; }
0067                         ~QhullVertex() {}
0068 
0069 #//!\name GetSet
0070     int                 dimension() const { return (qh_qh ? qh_qh->hull_dim : 0); }
0071     vertexT *           getBaseT() const { return getVertexT(); } //!< For QhullSet<QhullVertex>
0072     vertexT *           getVertexT() const { return qh_vertex; }
0073     bool                hasNext() const { return (qh_vertex->next != NULL && qh_vertex->next != qh_qh->vertex_tail); }
0074     bool                hasPrevious() const { return (qh_vertex->previous != NULL); }
0075     countT              id() const { return qh_vertex->id; }
0076     bool                isValid() const { return (qh_qh && qh_vertex != &s_empty_vertex); }
0077                         //! True if defineVertexNeighborFacets() already called.  Auotomatically set for facet merging, Voronoi diagrams
0078     bool                neighborFacetsDefined() const { return qh_vertex->neighbors != 0; }
0079     QhullVertex         next() const { return QhullVertex(qh_qh, qh_vertex->next); }
0080     bool                operator==(const QhullVertex &other) const { return qh_vertex==other.qh_vertex; }
0081     bool                operator!=(const QhullVertex &other) const { return !operator==(other); }
0082     QhullPoint          point() const { return QhullPoint(qh_qh, qh_vertex->point); }
0083     QhullVertex         previous() const { return QhullVertex(qh_qh, qh_vertex->previous); }
0084     QhullQh *           qh() const { return qh_qh; }
0085     void                setVertexT(QhullQh *qqh, vertexT *vertex) { qh_qh= qqh; qh_vertex= vertex; }
0086 
0087 #//!\name foreach
0088     //See also QhullVertexList
0089     QhullFacetSet       neighborFacets() const;
0090 
0091 #//!\name IO
0092     struct PrintVertex{
0093         const QhullVertex *vertex;
0094         const char *    print_message;    //!< non-null message
0095                         PrintVertex(const char *message, const QhullVertex &v) : vertex(&v), print_message(message) {}
0096     };//PrintVertex
0097     PrintVertex         print(const char *message) const { return PrintVertex(message, *this); }
0098 };//class QhullVertex
0099 
0100 }//namespace orgQhull
0101 
0102 #//!\name GLobal
0103 
0104 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex::PrintVertex &pr);
0105 inline std::ostream &operator<<(std::ostream &os, const orgQhull::QhullVertex &v) { os << v.print(""); return os; }
0106 
0107 #endif // QHULLVERTEX_H