File indexing completed on 2025-01-18 10:01:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef QHHYPERPLANE_H
0010 #define QHHYPERPLANE_H
0011
0012 #include "libqhull_r/qhull_ra.h"
0013 #include "libqhullcpp/QhullError.h"
0014 #include "libqhullcpp/QhullIterator.h"
0015 #include "libqhullcpp/QhullQh.h"
0016
0017 #include <ostream>
0018
0019 namespace orgQhull {
0020
0021 #
0022 class Qhull;
0023 class QhullPoint;
0024
0025 #
0026 class QhullHyperplane;
0027 class QhullHyperplaneIterator;
0028
0029 class QhullHyperplane {
0030 public:
0031 #
0032 typedef const coordT * iterator;
0033 typedef const coordT * const_iterator;
0034 typedef QhullHyperplane::iterator Iterator;
0035 typedef QhullHyperplane::const_iterator ConstIterator;
0036
0037 private:
0038 #
0039 coordT * hyperplane_coordinates;
0040 QhullQh * qh_qh;
0041 coordT hyperplane_offset;
0042 int hyperplane_dimension;
0043
0044 #
0045 public:
0046 QhullHyperplane() : hyperplane_coordinates(0), qh_qh(0), hyperplane_offset(0.0), hyperplane_dimension(0) {}
0047 explicit QhullHyperplane(const Qhull &q);
0048 QhullHyperplane(const Qhull &q, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset);
0049 explicit QhullHyperplane(QhullQh *qqh) : hyperplane_coordinates(0), qh_qh(qqh), hyperplane_offset(0.0), hyperplane_dimension(0) {}
0050 QhullHyperplane(QhullQh *qqh, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) : hyperplane_coordinates(c), qh_qh(qqh), hyperplane_offset(hyperplaneOffset), hyperplane_dimension(hyperplaneDimension) {}
0051
0052 QhullHyperplane(const QhullHyperplane &other) : hyperplane_coordinates(other.hyperplane_coordinates), qh_qh(other.qh_qh), hyperplane_offset(other.hyperplane_offset), hyperplane_dimension(other.hyperplane_dimension) {}
0053
0054 QhullHyperplane & operator=(const QhullHyperplane &other) { hyperplane_coordinates= other.hyperplane_coordinates; qh_qh= other.qh_qh; hyperplane_offset= other.hyperplane_offset; hyperplane_dimension= other.hyperplane_dimension; return *this; }
0055 ~QhullHyperplane() {}
0056
0057 #
0058
0059 #ifndef QHULL_NO_STL
0060 std::vector<coordT> toStdVector() const;
0061 #endif
0062 #ifdef QHULL_USES_QT
0063 QList<coordT> toQList() const;
0064 #endif
0065
0066 #
0067 public:
0068 const coordT * coordinates() const { return hyperplane_coordinates; }
0069 coordT * coordinates() { return hyperplane_coordinates; }
0070 void defineAs(int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) { QHULL_ASSERT(hyperplaneDimension>=0); hyperplane_coordinates= c; hyperplane_dimension= hyperplaneDimension; hyperplane_offset= hyperplaneOffset; }
0071
0072 void defineAs(QhullHyperplane &other) { hyperplane_coordinates= other.coordinates(); hyperplane_dimension= other.dimension(); hyperplane_offset= other.offset(); }
0073 int dimension() const { return hyperplane_dimension; }
0074 bool isValid() const { return hyperplane_coordinates!=0 && hyperplane_dimension>0; }
0075 coordT offset() const { return hyperplane_offset; }
0076 bool operator==(const QhullHyperplane &other) const;
0077 bool operator!=(const QhullHyperplane &other) const { return !operator==(other); }
0078 const coordT & operator[](int idx) const { QHULL_ASSERT(idx>=0 && idx<hyperplane_dimension); return *(hyperplane_coordinates+idx); }
0079 coordT & operator[](int idx) { QHULL_ASSERT(idx>=0 && idx<hyperplane_dimension); return *(hyperplane_coordinates+idx); }
0080 void setCoordinates(coordT *c) { hyperplane_coordinates= c; }
0081 void setDimension(int hyperplaneDimension) { hyperplane_dimension= hyperplaneDimension; }
0082 void setOffset(coordT hyperplaneOffset) { hyperplane_offset= hyperplaneOffset; }
0083
0084 #
0085 iterator begin() { return hyperplane_coordinates; }
0086 const_iterator begin() const { return hyperplane_coordinates; }
0087 const_iterator constBegin() const { return hyperplane_coordinates; }
0088 const_iterator constEnd() const { return hyperplane_coordinates+hyperplane_dimension; }
0089 int count() { return hyperplane_dimension; }
0090 iterator end() { return hyperplane_coordinates+hyperplane_dimension; }
0091 const_iterator end() const { return hyperplane_coordinates+hyperplane_dimension; }
0092 size_t size() { return static_cast<size_t>(hyperplane_dimension); }
0093
0094 #
0095 double distance(const QhullPoint &p) const;
0096 double hyperplaneAngle(const QhullHyperplane &other) const;
0097 double norm() const;
0098
0099 #
0100 struct PrintHyperplane{
0101 const QhullHyperplane *hyperplane;
0102 const char * print_message;
0103 const char * hyperplane_offset_message;
0104 PrintHyperplane(const char *message, const char *offsetMessage, const QhullHyperplane &p) : hyperplane(&p), print_message(message), hyperplane_offset_message(offsetMessage) {}
0105 };
0106 PrintHyperplane print(const char *message) const { return PrintHyperplane(message, "", *this); }
0107 PrintHyperplane print(const char *message, const char *offsetMessage) const { return PrintHyperplane(message, offsetMessage, *this); }
0108
0109 };
0110
0111
0112 QHULL_DECLARE_SEQUENTIAL_ITERATOR(QhullHyperplane, coordT)
0113
0114 }
0115
0116 #
0117
0118 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullHyperplane::PrintHyperplane &pr);
0119 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullHyperplane &p);
0120
0121 #endif
0122