Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:19:28

0001 /****************************************************************************
0002 **
0003 ** Copyright (c) 2008-2020 C.B. Barber. All rights reserved.
0004 ** $Id: //main/2019/qhull/src/libqhullcpp/QhullQh.h#3 $$Change: 2963 $
0005 ** $DateTime: 2020/06/03 19:31:01 $$Author: bbarber $
0006 **
0007 ****************************************************************************/
0008 
0009 #ifndef QHULLQH_H
0010 #define QHULLQH_H
0011 
0012 #include "libqhull_r/qhull_ra.h"
0013 
0014 #include <string>
0015 
0016 #ifdef _MSC_VER  // Microsoft Visual C++ -- warning level 4
0017 #pragma warning( disable : 4611)  /* interaction between '_setjmp' and C++ object destruction is non-portable */
0018 /* setjmp should not be implemented with 'catch' */
0019 #endif
0020 
0021 //! Use QH_TRY_ or QH_TRY_NOTHROW_ to call a libqhull_r routine that may invoke qh_errexit()
0022 //! QH_TRY_(qh){...} qh->NOerrexit=true;
0023 //! No object creation -- longjmp() skips object destructors
0024 //! To test for error when done -- qh->maybeThrowQhullMessage(QH_TRY_status);
0025 //! Use the same compiler for QH_TRY_, libqhullcpp, and libqhull_r.  setjmp() is not portable between compilers.
0026 
0027 #define QH_TRY_ERROR 10071
0028 
0029 #define QH_TRY_(qh) \
0030     int QH_TRY_status; \
0031     if(qh->NOerrexit){ \
0032         qh->NOerrexit= False; \
0033         QH_TRY_status= setjmp(qh->errexit); \
0034     }else{ \
0035         throw QhullError(QH_TRY_ERROR, "Cannot invoke QH_TRY_() from inside a QH_TRY_.  Or missing 'qh->NOerrexit=true' after previously called QH_TRY_(qh){...}"); \
0036     } \
0037     if(!QH_TRY_status)
0038 
0039 #define QH_TRY_NO_THROW_(qh) \
0040     int QH_TRY_status; \
0041     if(qh->NOerrexit){ \
0042         qh->NOerrexit= False; \
0043         QH_TRY_status= setjmp(qh->errexit); \
0044     }else{ \
0045         QH_TRY_status= QH_TRY_ERROR; \
0046     } \
0047     if(!QH_TRY_status)
0048 
0049 namespace orgQhull {
0050 
0051 #//!\name Defined here
0052     //! QhullQh -- Qhull's global data structure, qhT, as a C++ class
0053     class QhullQh;
0054 
0055 //! POD type equivalent to qhT.  No virtual members
0056 class QhullQh : public qhT {
0057 
0058 #//!\name Constants
0059 
0060 #//!\name Fields
0061 private:
0062     int                 qhull_status;   //!< qh_ERRnone if valid
0063     std::string         qhull_message;  //!< Returned messages from libqhull_r
0064     std::ostream *      error_stream;   //!< overrides errorMessage, use appendQhullMessage()
0065     std::ostream *      output_stream;  //!< send output to stream
0066     double              factor_epsilon; //!< Factor to increase ANGLEround and DISTround for hyperplane equality
0067     bool                use_output_stream; //!< True if using output_stream
0068 
0069     //! modified by qh_fprintf in QhullUser.cpp
0070     friend void         ::qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... );
0071 
0072     static const double default_factor_epsilon;  //!< Default factor_epsilon is 1.0, never updated
0073 
0074 #//!\name Constructors
0075 public:
0076                         QhullQh();
0077                         ~QhullQh();
0078 private:
0079                         //!disable copy constructor and assignment
0080                         QhullQh(const QhullQh &);
0081     QhullQh &           operator=(const QhullQh &);
0082 public:
0083 
0084 #//!\name GetSet
0085     double              factorEpsilon() const { return factor_epsilon; }
0086     void                setFactorEpsilon(double a) { factor_epsilon= a; }
0087     void                disableOutputStream() { use_output_stream= false; }
0088     void                enableOutputStream() { use_output_stream= true; }
0089 
0090 #//!\name Messaging
0091     void                appendQhullMessage(const std::string &s);
0092     void                clearQhullMessage();
0093     std::string         qhullMessage() const;
0094     bool                hasOutputStream() const { return use_output_stream; }
0095     bool                hasQhullMessage() const;
0096     void                maybeThrowQhullMessage(int exitCode);
0097     void                maybeThrowQhullMessage(int exitCode, int noThrow) throw();
0098     int                 qhullStatus() const;
0099     void                setErrorStream(std::ostream *os);
0100     void                setOutputStream(std::ostream *os);
0101 
0102 #//!\name Methods
0103     double              angleEpsilon() const { return this->ANGLEround*factor_epsilon; } //!< Epsilon for hyperplane angle equality
0104     void                checkAndFreeQhullMemory();
0105     double              distanceEpsilon() const { return this->DISTround*factor_epsilon; } //!< Epsilon for distance to hyperplane
0106 
0107 };//class QhullQh
0108 
0109 }//namespace orgQhull
0110 
0111 #endif // QHULLQH_H