QhullFacet.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (c) 2008-2011 C.B. Barber. All rights reserved.
00004 ** $Id: //main/2011/qhull/src/libqhullcpp/QhullFacet.h#6 $$Change: 1372 $
00005 ** $DateTime: 2011/04/17 19:32:21 $$Author: bbarber $
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; // needed for shallow copy
00047 
00048 public:
00049 #//Constants
00050 
00051 #//Constructors
00052                         QhullFacet() : qh_facet(&s_empty_facet) {}
00053                         // Creates an alias.  Does not copy QhullFacet.  Needed for return by value and parameter passing
00054                         QhullFacet(const QhullFacet &o) : qh_facet(o.qh_facet ? o.qh_facet : &s_empty_facet) {}
00055                         // Creates an alias.  Does not copy QhullFacet.  Needed for vector<QhullFacet>
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                         //Implicit conversion from facetT
00061                         QhullFacet(facetT *f) : qh_facet(f ? f : &s_empty_facet) {}
00062                         // Do not define facetT().  It conflicts with return type facetT*
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     // Can not inline.  Otherwise circular reference
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;  // non-const due to facet.center()
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     };//PrintCenter
00112     PrintCenter         printCenter(int qhRunId, qh_PRINT printFormat, const char *message) { return PrintCenter(qhRunId, *this, printFormat, message); }
00113 
00114     struct PrintFacet{
00115         QhullFacet     *facet;  // non-const due to f->center()
00116         int             run_id;
00117                         PrintFacet(int qhRunId, QhullFacet &f) : facet(&f), run_id(qhRunId) {}
00118     };//PrintFacet
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     };//PrintFlags
00126     PrintFlags          printFlags(const char *message) const { return PrintFlags(*this, message); }
00127 
00128     struct PrintHeader{
00129         QhullFacet     *facet;  // non-const due to f->center()
00130         int             run_id;
00131                         PrintHeader(int qhRunId, QhullFacet &f) : facet(&f), run_id(qhRunId) {}
00132     };//PrintHeader
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     };//PrintRidges
00140     PrintRidges         printRidges(int qhRunId) { return PrintRidges(qhRunId, *this); }
00141 
00142 };//class QhullFacet
00143 
00144 }//namespace orgQhull
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); // non-const due to qh_getcenter()
00154 
00155 #endif // QHULLFACET_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libqhull
Author(s): Robert Krug
autogenerated on Tue Jun 18 2013 12:38:50