Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef QHULLFACET_H
00010 #define QHULLFACET_H
00011
00012 #include "Coordinates.h"
00013 #include "QhullHyperplane.h"
00014 #include "QhullPoint.h"
00015 #include "QhullSet.h"
00016 #include "QhullPointSet.h"
00017 extern "C" {
00018 #include "libqhull/qhull_a.h"
00019 }
00020
00021 #include <string>
00022 #include <vector>
00023 #include <ostream>
00024
00025 namespace orgQhull {
00026
00027 #//ClassRef
00028 class QhullFacetSet;
00029 class QhullRidge;
00030 typedef QhullSet<QhullRidge> QhullRidgeSet;
00031 class QhullVertex;
00032 class QhullVertexSet;
00033
00034 #//Types
00035
00036 class QhullFacet;
00037
00039 class QhullFacet {
00040
00041 private:
00042 #//Fields -- no additions (QhullFacetSet of facetT*)
00043 facetT *qh_facet;
00044
00045 #//Class objects
00046 static facetT s_empty_facet;
00047
00048 public:
00049 #//Constants
00050
00051 #//Constructors
00052 QhullFacet() : qh_facet(&s_empty_facet) {}
00053
00054 QhullFacet(const QhullFacet &o) : qh_facet(o.qh_facet ? o.qh_facet : &s_empty_facet) {}
00055
00056 QhullFacet &operator=(const QhullFacet &o) { qh_facet= o.qh_facet ? o.qh_facet : &s_empty_facet; return *this; }
00057 ~QhullFacet() {}
00058
00059 #//Conversion
00060
00061 QhullFacet(facetT *f) : qh_facet(f ? f : &s_empty_facet) {}
00062
00063 facetT *getFacetT() const { return qh_facet; }
00064
00065 #//QhullSet<QhullFacet>
00066 facetT *getBaseT() const { return getFacetT(); }
00067
00068 #//getSet
00069 int dimension() const;
00070 QhullPoint getCenter(int qhRunId) { return getCenter(qhRunId, qh_PRINTpoints); }
00071 QhullPoint getCenter(int qhRunId, qh_PRINT printFormat);
00072 QhullHyperplane hyperplane() const { return QhullHyperplane(dimension(), qh_facet->normal, qh_facet->offset); }
00073 int id() const { return qh_facet ? qh_facet->id : -1; }
00074 QhullHyperplane innerplane(int qhRunId) const;
00075 bool isDefined() const { return qh_facet && qh_facet != &s_empty_facet; }
00076 bool isGood() const { return qh_facet && qh_facet->good; }
00077 bool isSimplicial() const { return qh_facet->simplicial; }
00078 bool isTopOrient() const { return qh_facet->toporient; }
00079 bool isTriCoplanar() const { return qh_facet->tricoplanar; }
00080 bool isUpperDelaunay() const { return qh_facet->upperdelaunay; }
00081 QhullFacet next() const { return qh_facet->next; }
00082 bool operator==(const QhullFacet &o) const { return qh_facet==o.qh_facet; }
00083 bool operator!=(const QhullFacet &o) const { return !operator==(o); }
00084 QhullHyperplane outerplane(int qhRunId) const;
00085 QhullFacet previous() const { return qh_facet->previous; }
00086 QhullFacet tricoplanarOwner() const;
00087 QhullPoint voronoiVertex(int qhRunId);
00088
00089 #//value
00090
00091 double distance(const Coordinates &c) const { return distance(c.data()); }
00092 double distance(const pointT *p) const { return distance(QhullPoint(dimension(), const_cast<coordT *>(p))); }
00093 double distance(const QhullPoint &p) const { return hyperplane().distance(p); }
00094 double facetArea(int qhRunId);
00095
00096 #//foreach
00097
00098 QhullPointSet coplanarPoints() const;
00099 QhullFacetSet neighborFacets() const;
00100 QhullPointSet outsidePoints() const;
00101 QhullRidgeSet ridges() const;
00102 QhullVertexSet vertices() const;
00103
00104 #//IO
00105 struct PrintCenter{
00106 QhullFacet *facet;
00107 const char *message;
00108 int run_id;
00109 qh_PRINT print_format;
00110 PrintCenter(int qhRunId, QhullFacet &f, qh_PRINT printFormat, const char * s) : facet(&f), message(s), run_id(qhRunId), print_format(printFormat){}
00111 };
00112 PrintCenter printCenter(int qhRunId, qh_PRINT printFormat, const char *message) { return PrintCenter(qhRunId, *this, printFormat, message); }
00113
00114 struct PrintFacet{
00115 QhullFacet *facet;
00116 int run_id;
00117 PrintFacet(int qhRunId, QhullFacet &f) : facet(&f), run_id(qhRunId) {}
00118 };
00119 PrintFacet print(int qhRunId) { return PrintFacet(qhRunId, *this); }
00120
00121 struct PrintFlags{
00122 const QhullFacet *facet;
00123 const char *message;
00124 PrintFlags(const QhullFacet &f, const char *s) : facet(&f), message(s) {}
00125 };
00126 PrintFlags printFlags(const char *message) const { return PrintFlags(*this, message); }
00127
00128 struct PrintHeader{
00129 QhullFacet *facet;
00130 int run_id;
00131 PrintHeader(int qhRunId, QhullFacet &f) : facet(&f), run_id(qhRunId) {}
00132 };
00133 PrintHeader printHeader(int qhRunId) { return PrintHeader(qhRunId, *this); }
00134
00135 struct PrintRidges{
00136 const QhullFacet *facet;
00137 int run_id;
00138 PrintRidges(int qhRunId, QhullFacet &f) : facet(&f), run_id(qhRunId) {}
00139 };
00140 PrintRidges printRidges(int qhRunId) { return PrintRidges(qhRunId, *this); }
00141
00142 };
00143
00144 }
00145
00146 #//Global functions
00147
00148 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintCenter &pr);
00149 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintFlags &pr);
00150 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintHeader &pr);
00151 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintRidges &pr);
00152 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullFacet::PrintFacet &pr);
00153 std::ostream &operator<<(std::ostream &os, orgQhull::QhullFacet &f);
00154
00155 #endif // QHULLFACET_H