Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /****************************************************************************
0002 **
0003 ** Copyright (c) 2008-2020 C.B. Barber. All rights reserved.
0004 ** $Id: //main/2019/qhull/src/libqhullcpp/QhullFacetList.h#3 $$Change: 3001 $
0005 ** $DateTime: 2020/07/24 20:43:28 $$Author: bbarber $
0006 **
0007 ****************************************************************************/
0008 
0009 #ifndef QHULLFACETLIST_H
0010 #define QHULLFACETLIST_H
0011 
0012 #include "libqhullcpp/QhullLinkedList.h"
0013 #include "libqhullcpp/QhullFacet.h"
0014 
0015 #include <ostream>
0016 
0017 #ifndef QHULL_NO_STL
0018 #include <vector>
0019 #endif
0020 
0021 namespace orgQhull {
0022 
0023 #//!\name Used here
0024     class Qhull;
0025     class QhullFacet;
0026     class QhullQh;
0027 
0028 #//!\name Defined here
0029     //! QhullFacetList -- List of QhullFacet/facetT, as a C++ class.  
0030     //!\see QhullFacetSet.h
0031     class QhullFacetList;
0032     //! QhullFacetListIterator is a Java-style iterator for QhullFacetList. -- if(f.isGood()){ ... }
0033     typedef QhullLinkedListIterator<QhullFacet> QhullFacetListIterator;
0034 
0035 class QhullFacetList : public QhullLinkedList<QhullFacet> {
0036 
0037 #//!\name  Fields
0038 private:
0039     bool                select_all;   //! True if include bad facets.  Default is false.
0040 
0041 #//!\name Constructors
0042 public:
0043                         QhullFacetList(const Qhull &q, facetT *b, facetT *e);
0044                         QhullFacetList(QhullQh *qqh, facetT *b, facetT *e);
0045                         QhullFacetList(QhullFacet b, QhullFacet e) : QhullLinkedList<QhullFacet>(b, e), select_all(false) {}
0046                         //Copy constructor copies pointer but not contents.  Needed for return by value and parameter passing.
0047                         QhullFacetList(const QhullFacetList &other) : QhullLinkedList<QhullFacet>(*other.begin(), *other.end()), select_all(other.select_all) {}
0048     QhullFacetList &    operator=(const QhullFacetList &other) { QhullLinkedList<QhullFacet>::operator =(other); select_all= other.select_all; return *this; }
0049                         ~QhullFacetList() {}
0050 
0051 private:                //!Disable default constructor.  See QhullLinkedList
0052                         QhullFacetList();
0053 public:
0054 
0055 #//!\name Conversion
0056 #ifndef QHULL_NO_STL
0057     std::vector<QhullFacet> toStdVector() const;
0058     std::vector<QhullVertex> vertices_toStdVector() const;
0059 #endif //QHULL_NO_STL
0060 #ifdef QHULL_USES_QT
0061     QList<QhullFacet>   toQList() const;
0062     QList<QhullVertex>  vertices_toQList() const;
0063 #endif //QHULL_USES_QT
0064 
0065 #//!\name GetSet
0066                         //! Filtered by facet.isGood().  May be 0 when !isEmpty().
0067     countT              count() const;
0068     bool                contains(const QhullFacet &f) const;
0069     countT              count(const QhullFacet &f) const;
0070     bool                isSelectAll() const { return select_all; }
0071     QhullQh *           qh() const { return first().qh(); }
0072     void                selectAll() { select_all= true; }
0073     void                selectGood() { select_all= false; }
0074                         //!< operator==() does not depend on isGood()
0075 
0076 #//!\name IO
0077     struct PrintFacetList{
0078         const QhullFacetList *facet_list;
0079         const char *    print_message;   //!< non-null message
0080                         PrintFacetList(const QhullFacetList &fl, const char *message) : facet_list(&fl), print_message(message) {}
0081     };//PrintFacetList
0082     PrintFacetList      print(const char *message) const  { return PrintFacetList(*this, message); }
0083 
0084     struct PrintFacets{
0085         const QhullFacetList *facet_list;
0086                         PrintFacets(const QhullFacetList &fl) : facet_list(&fl) {}
0087     };//PrintFacets
0088     PrintFacets         printFacets() const { return PrintFacets(*this); }
0089 
0090     struct PrintVertices{
0091         const QhullFacetList *facet_list;
0092                         PrintVertices(const QhullFacetList &fl) : facet_list(&fl) {}
0093     };//PrintVertices
0094     PrintVertices       printVertices() const { return PrintVertices(*this); }
0095 };//class QhullFacetList
0096 
0097 }//namespace orgQhull
0098 
0099 #//!\name == Global namespace =========================================
0100 
0101 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList::PrintFacetList &p);
0102 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList::PrintFacets &p);
0103 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList::PrintVertices &p);
0104 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetList &fs);
0105 
0106 #endif // QHULLFACETLIST_H