Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef QHULLCPP_H
00010 #define QHULLCPP_H
00011
00012 #include "QhullQh.h"
00013 #include "RboxPoints.h"
00014 #include "QhullLinkedList.h"
00015 #include "QhullPoint.h"
00016 #include "QhullPoints.h"
00017 #include "QhullVertex.h"
00018 #include "QhullFacet.h"
00019
00020 #include <stdarg.h>
00021 #include <string>
00022 #include <vector>
00023 #include <sstream>
00024 #include <iostream>
00025
00026 #if qh_QHpointer != 1
00027 #error qh_QHpointer is not set. Please set it in user.h or
00028 #error compile Qhull with -Dqh_QHpointer. The C++ classes
00029 #error require dynamic allocation for Qhulls global data
00030 #error structure qhT (QhullQh).
00031 #endif
00032
00033 namespace orgQhull {
00034
00035
00036
00037
00038
00039 #//Types
00040
00041 class Qhull;
00042
00043
00044 class QhullFacetList;
00045 class RboxPoints;
00046
00047 class Qhull {
00048
00049 private:
00050 #//Members and friends
00051 QhullQh *qhull_qh;
00052 int qhull_run_id;
00053 Coordinates origin_point;
00054 int qhull_status;
00055 int qhull_dimension;
00056 bool run_called;
00057 bool qh_active;
00058 std::string qhull_message;
00059 std::ostream *error_stream;
00060 std::ostream *output_stream;
00061
00062 friend void ::qh_fprintf(FILE *fp, int msgcode, const char *fmt, ... );
00063 friend class UsingLibQhull;
00064
00065 #//Attribute
00066 public:
00067 Coordinates feasiblePoint;
00068 bool useOutputStream;
00069
00070
00071 #//constructor, assignment, destructor, invariant
00072 Qhull();
00073 Qhull(const RboxPoints &rboxPoints, const char *qhullCommand2);
00074 Qhull(const char *rboxCommand2, int pointDimension, int pointCount, const realT *pointCoordinates, const char *qhullCommand2);
00075
00076 Qhull(const Qhull &other);
00077
00078 Qhull &operator=(const Qhull &other);
00079 ~Qhull() throw();
00080 private:
00081 void initializeQhull();
00082
00083 public:
00084 #//virtual methods
00085
00086
00087 #//Messaging
00088 void appendQhullMessage(const std::string &s);
00089 void clearQhullMessage();
00090 std::string qhullMessage() const;
00091 bool hasQhullMessage() const;
00092 int qhullStatus() const;
00093 void setErrorStream(std::ostream *os);
00094 void setOutputStream(std::ostream *os);
00095
00096 #//GetSet
00097 void checkIfQhullInitialized();
00098 bool initialized() const { return qhull_dimension>0; }
00099 int dimension() const { return qhull_dimension; }
00100 int hullDimension() const { return qhullQh()->hull_dim; }
00101
00102 QhullPoint origin() { QHULL_ASSERT(initialized()); return QhullPoint(dimension(), origin_point.data()); }
00103 QhullQh *qhullQh() const { return qhull_qh; };
00104 int runId();
00105
00106 #//GetQh -- access to qhT (Qhull's global data structure)
00107 const char *qhullCommand() const { return qhull_qh->qhull_command; }
00108 const char *rboxCommand() const { return qhull_qh->rbox_command; }
00109 int facetCount() const { return qhull_qh->num_facets; }
00110 int vertexCount() const { return qhull_qh->num_vertices; }
00111
00112 #//GetValue
00113 double area();
00114 double volume();
00115
00116 #//ForEach
00117 QhullFacet beginFacet() const { return QhullFacet(qhull_qh->facet_list); }
00118 QhullVertex beginVertex() const { return QhullVertex(qhull_qh->vertex_list); }
00119 void defineVertexNeighborFacets();
00120 QhullFacet endFacet() const { return QhullFacet(qhull_qh->facet_tail); }
00121 QhullVertex endVertex() const { return QhullVertex(qhull_qh->vertex_tail); }
00122 QhullFacetList facetList() const;
00123 QhullFacet firstFacet() const { return beginFacet(); }
00124 QhullVertex firstVertex() const { return beginVertex(); }
00125 QhullPoints points() const;
00126 QhullPointSet otherPoints() const;
00128 coordT *pointCoordinateBegin() const { return qhull_qh->first_point; }
00129 coordT *pointCoordinateEnd() const { return qhull_qh->first_point + qhull_qh->num_points*qhull_qh->hull_dim; }
00130 QhullVertexList vertexList() const;
00131
00132 #//Modify
00133 void outputQhull();
00134 void outputQhull(const char * outputflags);
00135 void runQhull(const RboxPoints &rboxPoints, const char *qhullCommand2);
00136 void runQhull(const char *rboxCommand2, int pointDimension, int pointCount, const realT *rboxPoints, const char *qhullCommand2);
00137
00138 private:
00139 #//Helpers
00140 void initializeFeasiblePoint(int hulldim);
00141 void maybeThrowQhullMessage(int exitCode);
00142 void maybeThrowQhullMessage(int exitCode, int noThrow) throw();
00143 };
00144
00145 }
00146
00147 #endif // QHULLCPP_H