/**************************************************************************** ** ** Copyright (c) 2009-2015 C.B. Barber. All rights reserved. ** $Id: //main/2015/qhull/src/libqhullcpp/QhullHyperplane.h#3 $$Change: 2066 $ ** $DateTime: 2016/01/18 19:29:17 $$Author: bbarber $ ** ****************************************************************************/ #ifndef QHHYPERPLANE_H #define QHHYPERPLANE_H extern "C" { #include "libqhull_r/qhull_ra.h" } #include "libqhullcpp/QhullError.h" #include "libqhullcpp/QhullIterator.h" #include "libqhullcpp/QhullQh.h" #include namespace orgQhull { #//!\name Used here class Qhull; class QhullPoint; #//!\name Defined here //! QhullHyperplane as an offset, dimension, and pointer to coordinates class QhullHyperplane; //! Java-style iterator for QhullHyperplane coordinates class QhullHyperplaneIterator; class QhullHyperplane { // Similar to QhullPoint public: #//!\name Subtypes typedef const coordT * iterator; typedef const coordT * const_iterator; typedef QhullHyperplane::iterator Iterator; typedef QhullHyperplane::const_iterator ConstIterator; private: #//!\name Fields coordT * hyperplane_coordinates; //!< Normal to hyperplane. facetT.normal is normalized to 1.0 QhullQh * qh_qh; //!< qhT for distanceEpsilon() in operator== coordT hyperplane_offset; //!< Distance from hyperplane to origin int hyperplane_dimension; //!< Dimension of hyperplane #//!\name Construct public: QhullHyperplane() : hyperplane_coordinates(0), qh_qh(0), hyperplane_offset(0.0), hyperplane_dimension(0) {} explicit QhullHyperplane(const Qhull &q); QhullHyperplane(const Qhull &q, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset); explicit QhullHyperplane(QhullQh *qqh) : hyperplane_coordinates(0), qh_qh(qqh), hyperplane_offset(0.0), hyperplane_dimension(0) {} QhullHyperplane(QhullQh *qqh, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) : hyperplane_coordinates(c), qh_qh(qqh), hyperplane_offset(hyperplaneOffset), hyperplane_dimension(hyperplaneDimension) {} // Creates an alias. Does not copy the hyperplane's coordinates. Needed for return by value and parameter passing. QhullHyperplane(const QhullHyperplane &other) : hyperplane_coordinates(other.hyperplane_coordinates), qh_qh(other.qh_qh), hyperplane_offset(other.hyperplane_offset), hyperplane_dimension(other.hyperplane_dimension) {} // Creates an alias. Does not copy the hyperplane's coordinates. Needed for vector QhullHyperplane & operator=(const QhullHyperplane &other) { hyperplane_coordinates= other.hyperplane_coordinates; qh_qh= other.qh_qh; hyperplane_offset= other.hyperplane_offset; hyperplane_dimension= other.hyperplane_dimension; return *this; } ~QhullHyperplane() {} #//!\name Conversions -- //! Includes offset at end #ifndef QHULL_NO_STL std::vector toStdVector() const; #endif //QHULL_NO_STL #ifdef QHULL_USES_QT QList toQList() const; #endif //QHULL_USES_QT #//!\name GetSet public: const coordT * coordinates() const { return hyperplane_coordinates; } coordT * coordinates() { return hyperplane_coordinates; } void defineAs(int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) { QHULL_ASSERT(hyperplaneDimension>=0); hyperplane_coordinates= c; hyperplane_dimension= hyperplaneDimension; hyperplane_offset= hyperplaneOffset; } //! Creates an alias to other using the same qh_qh void defineAs(QhullHyperplane &other) { hyperplane_coordinates= other.coordinates(); hyperplane_dimension= other.dimension(); hyperplane_offset= other.offset(); } int dimension() const { return hyperplane_dimension; } bool isValid() const { return hyperplane_coordinates!=0 && hyperplane_dimension>0; } coordT offset() const { return hyperplane_offset; } bool operator==(const QhullHyperplane &other) const; bool operator!=(const QhullHyperplane &other) const { return !operator==(other); } const coordT & operator[](int idx) const { QHULL_ASSERT(idx>=0 && idx=0 && idx