Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:55

0001 /****************************************************************************
0002 **
0003 ** Copyright (c) 2008-2020 C.B. Barber. All rights reserved.
0004 ** $Id: //main/2019/qhull/src/libqhullcpp/Qhull.h#5 $$Change: 2956 $
0005 ** $DateTime: 2020/05/23 21:08:29 $$Author: bbarber $
0006 **
0007 ****************************************************************************/
0008 
0009 #ifndef QHULLCPP_H
0010 #define QHULLCPP_H
0011 
0012 #include "libqhullcpp/QhullPoint.h"
0013 #include "libqhullcpp/QhullVertex.h"
0014 #include "libqhullcpp/QhullFacet.h"
0015 
0016 namespace orgQhull {
0017 
0018 /***
0019    Compile qhullcpp and libqhull with the same compiler.  setjmp() and longjmp() must be the same.
0020 
0021    #define QHULL_NO_STL
0022       Do not supply conversions to STL
0023       Coordinates.h requires <vector>.  It could be rewritten for another vector class such as QList
0024    #define QHULL_USES_QT
0025       Supply conversions to QT
0026       qhulltest requires QT.  It is defined in RoadTest.h
0027 
0028   #define QHULL_ASSERT
0029       Defined by QhullError.h
0030       It invokes assert()
0031 */
0032 
0033 #//!\name Used here
0034     class QhullFacetList;
0035     class QhullPoints;
0036     class QhullQh;
0037     class RboxPoints;
0038 
0039 #//!\name Defined here
0040     class Qhull;
0041 
0042 //! Interface to Qhull from C++
0043 class Qhull {
0044 
0045 private:
0046 #//!\name Members and friends
0047     QhullQh *           qh_qh;          //! qhT for this instance
0048     Coordinates         origin_point;   //! origin for qh_qh->hull_dim.  Set by runQhull()
0049     bool                run_called;     //! True at start of runQhull.  Errors if call again.
0050     Coordinates         feasible_point;  //! feasible point for half-space intersection (alternative to qh.feasible_string for qh.feasible_point)
0051 
0052 public:
0053 #//!\name Constructors
0054                         Qhull();      //!< call runQhull() next
0055                         Qhull(const RboxPoints &rboxPoints, const char *qhullCommand2);
0056                         Qhull(const char *inputComment2, int pointDimension, int pointCount, const realT *pointCoordinates, const char *qhullCommand2);
0057                         ~Qhull() throw();
0058 private:                //! Disable copy constructor and assignment.  Qhull owns QhullQh.
0059                         Qhull(const Qhull &);
0060     Qhull &             operator=(const Qhull &);
0061 
0062 private:
0063     void                allocateQhullQh();
0064 
0065 public:
0066 
0067 #//!\name GetSet
0068     void                checkIfQhullInitialized();
0069     int                 dimension() const { return qh_qh->input_dim; } //!< Dimension of input and result
0070     void                disableOutputStream() { qh_qh->disableOutputStream(); }
0071     void                enableOutputStream() { qh_qh->enableOutputStream(); }
0072     countT              facetCount() const { return qh_qh->num_facets; }
0073     Coordinates         feasiblePoint() const; 
0074     int                 hullDimension() const { return qh_qh->hull_dim; } //!< Dimension of the computed hull
0075     bool                hasOutputStream() const { return qh_qh->hasOutputStream(); }
0076     bool                initialized() const { return (qh_qh->hull_dim>0); }
0077     const char *        inputComment() const { return qh_qh->rbox_command; }
0078     QhullPoint          inputOrigin();
0079     bool                isDelaunay() const { return qh_qh->DELAUNAY; }
0080                         //! non-const due to QhullPoint
0081     QhullPoint          origin() { QHULL_ASSERT(initialized()); return QhullPoint(qh_qh, origin_point.data()); }
0082     QhullQh *           qh() const { return qh_qh; }
0083     const char *        qhullCommand() const { return qh_qh->qhull_command; }
0084     const char *        rboxCommand() const { return qh_qh->rbox_command; }
0085     int                 rotateRandom() const { return qh_qh->ROTATErandom; } //!< Return QRn for repeating QR0 runs
0086     void                setFeasiblePoint(const Coordinates &c) { feasible_point= c; } //!< Sets qh.feasible_point via initializeFeasiblePoint
0087     countT              vertexCount() const { return qh_qh->num_vertices; }
0088 
0089 #//!\name Delegated to QhullQh
0090     double              angleEpsilon() const { return qh_qh->angleEpsilon(); } //!< Epsilon for hyperplane angle equality
0091     void                appendQhullMessage(const std::string &s) { qh_qh->appendQhullMessage(s); }
0092     void                clearQhullMessage() { qh_qh->clearQhullMessage(); }
0093     double              distanceEpsilon() const { return qh_qh->distanceEpsilon(); } //!< Epsilon for distance to hyperplane
0094     double              factorEpsilon() const { return qh_qh->factorEpsilon(); }  //!< Factor for angleEpsilon and distanceEpsilon
0095     std::string         qhullMessage() const { return qh_qh->qhullMessage(); }
0096     bool                hasQhullMessage() const { return qh_qh->hasQhullMessage(); }
0097     int                 qhullStatus() const { return qh_qh->qhullStatus(); }
0098     void                setErrorStream(std::ostream *os) { qh_qh->setErrorStream(os); }
0099     void                setFactorEpsilon(double a) { qh_qh->setFactorEpsilon(a); }
0100     void                setOutputStream(std::ostream *os) { qh_qh->setOutputStream(os); }
0101 
0102 #//!\name ForEach
0103     QhullFacet          beginFacet() const { return QhullFacet(qh_qh, qh_qh->facet_list); }
0104     QhullVertex         beginVertex() const { return QhullVertex(qh_qh, qh_qh->vertex_list); }
0105     void                defineVertexNeighborFacets(); //!< Automatically called if merging facets or Voronoi diagram
0106     QhullFacet          endFacet() const { return QhullFacet(qh_qh, qh_qh->facet_tail); }
0107     QhullVertex         endVertex() const { return QhullVertex(qh_qh, qh_qh->vertex_tail); }
0108     QhullFacetList      facetList() const;
0109     QhullFacet          firstFacet() const { return beginFacet(); }
0110     QhullVertex         firstVertex() const { return beginVertex(); }
0111     QhullPoints         points() const;
0112     QhullPointSet       otherPoints() const;
0113                         //! Same as points().coordinates()
0114     coordT *            pointCoordinateBegin() const { return qh_qh->first_point; }
0115     coordT *            pointCoordinateEnd() const { return qh_qh->first_point + qh_qh->num_points*qh_qh->hull_dim; }
0116     QhullVertexList     vertexList() const;
0117 
0118 #//!\name Methods
0119     double              area();
0120     void                outputQhull();
0121     void                outputQhull(const char * outputflags);
0122     void                prepareVoronoi(bool *isLower, int *voronoiVertexCount);
0123     void                runQhull(const RboxPoints &rboxPoints, const char *qhullCommand2);
0124     void                runQhull(const char *inputComment2, int pointDimension, int pointCount, const realT *pointCoordinates, const char *qhullCommand2);
0125     double              volume();
0126 
0127 #//!\name Helpers
0128 private:
0129     void                initializeFeasiblePoint(int hulldim);
0130 };//Qhull
0131 
0132 }//namespace orgQhull
0133 
0134 #endif // QHULLCPP_H