File indexing completed on 2025-01-18 10:01:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef QHULLFACET_H
0010 #define QHULLFACET_H
0011
0012 #include "libqhull_r/qhull_ra.h"
0013 #include "libqhullcpp/QhullHyperplane.h"
0014 #include "libqhullcpp/QhullPoint.h"
0015 #include "libqhullcpp/QhullSet.h"
0016 #include "libqhullcpp/QhullPointSet.h"
0017
0018 #include <ostream>
0019
0020 namespace orgQhull {
0021
0022 #
0023 class Coordinates;
0024 class Qhull;
0025 class QhullFacetSet;
0026 class QhullRidge;
0027 class QhullVertex;
0028 class QhullVertexSet;
0029
0030 #
0031 class QhullFacet;
0032 typedef QhullSet<QhullRidge> QhullRidgeSet;
0033
0034
0035 class QhullFacet {
0036
0037 #
0038 public:
0039 typedef facetT * base_type;
0040
0041 private:
0042 #
0043 facetT * qh_facet;
0044 QhullQh * qh_qh;
0045
0046 #
0047 static facetT s_empty_facet;
0048
0049 public:
0050 #
0051 QhullFacet() : qh_facet(&s_empty_facet), qh_qh(0) {}
0052 explicit QhullFacet(const Qhull &q);
0053 QhullFacet(const Qhull &q, facetT *f);
0054 explicit QhullFacet(QhullQh *qqh) : qh_facet(&s_empty_facet), qh_qh(qqh) {}
0055 QhullFacet(QhullQh *qqh, facetT *f) : qh_facet(f ? f : &s_empty_facet), qh_qh(qqh) {}
0056
0057 QhullFacet(const QhullFacet &other) : qh_facet(other.qh_facet ? other.qh_facet : &s_empty_facet), qh_qh(other.qh_qh) {}
0058
0059 QhullFacet & operator=(const QhullFacet &other) { qh_facet= other.qh_facet ? other.qh_facet : &s_empty_facet; qh_qh= other.qh_qh; return *this; }
0060 ~QhullFacet() {}
0061
0062
0063 #
0064 int dimension() const { return (qh_qh ? qh_qh->hull_dim : 0); }
0065 QhullPoint getCenter() { return getCenter(qh_PRINTpoints); }
0066 QhullPoint getCenter(qh_PRINT printFormat);
0067 facetT * getBaseT() const { return getFacetT(); }
0068
0069 facetT * getFacetT() const { return qh_facet; }
0070 bool hasNext() const { return (qh_facet->next != NULL && qh_facet->next != qh_qh->facet_tail); }
0071 bool hasPrevious() const { return (qh_facet->previous != NULL); }
0072 QhullHyperplane hyperplane() const { return QhullHyperplane(qh_qh, dimension(), qh_facet->normal, qh_facet->offset); }
0073 countT id() const { return (qh_facet ? qh_facet->id : static_cast<countT>(qh_IDunknown)); }
0074 QhullHyperplane innerplane() const;
0075 bool isValid() const { return qh_qh && qh_facet && qh_facet != &s_empty_facet; }
0076 bool isGood() const { return qh_facet && qh_facet->good; }
0077 bool isSimplicial() const { return qh_facet && qh_facet->simplicial; }
0078 bool isTopOrient() const { return qh_facet && qh_facet->toporient; }
0079 bool isTriCoplanar() const { return qh_facet && qh_facet->tricoplanar; }
0080 bool isUpperDelaunay() const { return qh_facet && qh_facet->upperdelaunay; }
0081 QhullFacet next() const { return QhullFacet(qh_qh, qh_facet->next); }
0082 QhullFacet nextFacet2d(QhullVertex *nextVertex) const;
0083 bool operator==(const QhullFacet &other) const { return qh_facet==other.qh_facet; }
0084 bool operator!=(const QhullFacet &other) const { return !operator==(other); }
0085 QhullHyperplane outerplane() const;
0086 QhullFacet previous() const { return QhullFacet(qh_qh, qh_facet->previous); }
0087 QhullQh * qh() const { return qh_qh; }
0088 void setFacetT(QhullQh *qqh, facetT *facet) { qh_qh= qqh; qh_facet= facet; }
0089 QhullFacet tricoplanarOwner() const;
0090 int visitId() const { return (qh_facet ? qh_facet->visitid : -1); }
0091 QhullPoint voronoiVertex();
0092
0093 #
0094
0095 double distance(const Coordinates &c) const { return distance(c.data()); }
0096 double distance(const pointT *p) const { return distance(QhullPoint(qh_qh, const_cast<coordT *>(p))); }
0097 double distance(const QhullPoint &p) const { return hyperplane().distance(p); }
0098 double facetArea();
0099
0100 #
0101
0102 QhullPointSet coplanarPoints() const;
0103 QhullFacetSet neighborFacets() const;
0104 QhullPointSet outsidePoints() const;
0105 QhullRidgeSet ridges() const;
0106 QhullVertexSet vertices() const;
0107
0108 #
0109 struct PrintCenter{
0110 QhullFacet * facet;
0111 const char * message;
0112 qh_PRINT print_format;
0113 PrintCenter(QhullFacet &f, qh_PRINT printFormat, const char * s) : facet(&f), message(s), print_format(printFormat){}
0114 };
0115 PrintCenter printCenter(qh_PRINT printFormat, const char *message) { return PrintCenter(*this, printFormat, message); }
0116
0117 struct PrintFacet{
0118 QhullFacet * facet;
0119 const char * message;
0120 explicit PrintFacet(QhullFacet &f, const char * s) : facet(&f), message(s) {}
0121 };
0122 PrintFacet print(const char *message) { return PrintFacet(*this, message); }
0123
0124 struct PrintFlags{
0125 const QhullFacet *facet;
0126 const char * message;
0127 PrintFlags(const QhullFacet &f, const char *s) : facet(&f), message(s) {}
0128 };
0129 PrintFlags printFlags(const char *message) const { return PrintFlags(*this, message); }
0130
0131 struct PrintHeader{
0132 QhullFacet * facet;
0133 PrintHeader(QhullFacet &f) : facet(&f) {}
0134 };
0135 PrintHeader printHeader() { return PrintHeader(*this); }
0136
0137 struct PrintRidges{
0138 const QhullFacet *facet;
0139 PrintRidges(QhullFacet &f) : facet(&f) {}
0140 };
0141 PrintRidges printRidges() { return PrintRidges(*this); }
0142
0143 };
0144
0145 }
0146
0147 #
0148
0149 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintFacet &pr);
0150 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintCenter &pr);
0151 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintFlags &pr);
0152 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintHeader &pr);
0153 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintRidges &pr);
0154 std::ostream &operator<<(std::ostream &os, orgQhull::QhullFacet &f);
0155
0156 #endif