1 /****************************************************************************
2 **
3 ** Copyright (c) 2008-2019 C.B. Barber. All rights reserved.
4 ** $Id: //main/2019/qhull/src/libqhullcpp/QhullFacetSet.h#1 $$Change: 2661 $
5 ** $DateTime: 2019/05/24 20:09:58 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #ifndef QHULLFACETSET_H
10 #define QHULLFACETSET_H
11 
12 #include "libqhullcpp/QhullSet.h"
13 #include "libqhullcpp/QhullFacet.h"
14 
15 #include <ostream>
16 
17 namespace orgQhull {
18 
19 #//!\name Used here
20     class Qhull;
21 
22 #//!\name Defined here
23     //! QhullFacetSet -- a set of Qhull facets, as a C++ class.  See QhullFacetList.h
24     class QhullFacetSet;
25     typedef QhullSetIterator<QhullFacet> QhullFacetSetIterator;
26 
27 class QhullFacetSet : public QhullSet<QhullFacet> {
28 
29 #//!\name Defined here
30 public:
31     typedef facetT *   base_type;  // for QhullVertexSet
32 
33 private:
34 #//!\name Fields
35     bool                select_all;   //! True if include bad facets.  Default is false.
36 
37 public:
38 #//!\name Constructor
39                         //Conversion from setT* is not type-safe.  Implicit conversion for void* to T
QhullFacetSet(const Qhull & q,setT * s)40                         QhullFacetSet(const Qhull &q, setT *s) : QhullSet<QhullFacet>(q, s), select_all(false) {}
QhullFacetSet(QhullQh * qqh,setT * s)41                         QhullFacetSet(QhullQh *qqh, setT *s) : QhullSet<QhullFacet>(qqh, s), select_all(false) {}
42                         //!Copy constructor copies pointers but not contents.  Needed for return by value and parameter passing.
QhullFacetSet(const QhullFacetSet & other)43                         QhullFacetSet(const QhullFacetSet &other) : QhullSet<QhullFacet>(other), select_all(other.select_all) {}
44                         //!Assignment copies pointers but not contents.
45     QhullFacetSet &     operator=(const QhullFacetSet &other) { QhullSet<QhullFacet>::operator=(other); select_all= other.select_all; return *this; }
46 
47 private:
48                         //!Disable default constructor.  See QhullSetBase
49                         QhullFacetSet();
50 public:
51 
52 #//!\name Conversion
53 #ifndef QHULL_NO_STL
54     std::vector<QhullFacet> toStdVector() const;
55 #endif //QHULL_NO_STL
56 #ifdef QHULL_USES_QT
57     QList<QhullFacet>   toQList() const;
58 #endif //QHULL_USES_QT
59 
60 #//!\name GetSet
61                         //! Filtered by facet.isGood().  May be 0 when !isEmpty().
62     countT              count() const;
63     bool                contains(const QhullFacet &f) const;
64     countT              count(const QhullFacet &f) const;
isSelectAll()65     bool                isSelectAll() const { return select_all; }
66                         //! operator==() does not depend on isGood()
selectAll()67     void                selectAll() { select_all= true; }
selectGood()68     void                selectGood() { select_all= false; }
69 
70 #//!\name IO
71     // Not same as QhullFacetList#IO.  A QhullFacetSet is a component of a QhullFacetList.
72 
73     struct PrintFacetSet{
74         const QhullFacetSet *facet_set;
75         const char *    print_message;  //!< non-null message
PrintFacetSetPrintFacetSet76                         PrintFacetSet(const char *message, const QhullFacetSet *s) : facet_set(s), print_message(message) {}
77     };//PrintFacetSet
print(const char * message)78     const PrintFacetSet print(const char *message) const { return PrintFacetSet(message, this); }
79 
80     struct PrintIdentifiers{
81         const QhullFacetSet *facet_set;
82         const char *    print_message;  //!< non-null message
PrintIdentifiersPrintIdentifiers83                         PrintIdentifiers(const char *message, const QhullFacetSet *s) : facet_set(s), print_message(message) {}
84     };//PrintIdentifiers
printIdentifiers(const char * message)85     PrintIdentifiers    printIdentifiers(const char *message) const { return PrintIdentifiers(message, this); }
86 
87 };//class QhullFacetSet
88 
89 }//namespace orgQhull
90 
91 #//!\name == Global namespace =========================================
92 
93 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet &fs);
94 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet::PrintFacetSet &pr);
95 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacetSet::PrintIdentifiers &p);
96 
97 #endif // QHULLFACETSET_H
98