QhullHyperplane.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (c) 2009-2011 C.B. Barber. All rights reserved.
00004 ** $Id: //main/2011/qhull/src/libqhullcpp/QhullHyperplane.h#5 $$Change: 1382 $
00005 ** $DateTime: 2011/05/14 10:45:42 $$Author: bbarber $
00006 **
00007 ****************************************************************************/
00008 
00009 #ifndef QHHYPERPLANE_H
00010 #define QHHYPERPLANE_H
00011 
00012 #include "QhullError.h"
00013 #include "QhullIterator.h"
00014 #include "UsingLibQhull.h"
00015 extern "C" {
00016     #include "libqhull/qhull_a.h"
00017 }
00018 
00019 #include <ostream>
00020 
00021 namespace orgQhull {
00022 #//ClassRef
00023     class QhullPoint;
00024 
00025 #//Types
00026 
00027     class QhullHyperplane;
00029     class QhullHyperplaneIterator;
00030 
00031 class QhullHyperplane { // Similar to QhullPoint
00032 
00033 private:
00034 #//Fields
00035     coordT             *hyperplane_coordinates;  // Keep pointers aligned
00036     int                 hyperplane_dimension;
00037     coordT              hyperplane_offset;
00038 
00039 public:
00040 #//Subtypes
00041     typedef const coordT *                  iterator;
00042     typedef const coordT *                  const_iterator;
00043     typedef QhullHyperplane::iterator       Iterator;
00044     typedef QhullHyperplane::const_iterator ConstIterator;
00045 
00046 #//Construct
00047                         QhullHyperplane() : hyperplane_coordinates(0), hyperplane_dimension(0), hyperplane_offset(0.0) {};
00048                         QhullHyperplane(int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) : hyperplane_coordinates(c), hyperplane_dimension(hyperplaneDimension), hyperplane_offset(hyperplaneOffset) {}
00049                         // Creates an alias.  Does not copy the hyperplane's coordinates.  Needed for return by value and parameter passing.
00050                         QhullHyperplane(const QhullHyperplane &other)  : hyperplane_coordinates(other.hyperplane_coordinates), hyperplane_dimension(other.hyperplane_dimension), hyperplane_offset(other.hyperplane_offset) {}
00051                         // Creates an alias.  Does not copy the hyperplane's coordinates.  Needed for vector<QhullHyperplane>
00052     QhullHyperplane    &operator=(const QhullHyperplane &other) { hyperplane_coordinates= other.hyperplane_coordinates; hyperplane_dimension= other.hyperplane_dimension; hyperplane_offset= other.hyperplane_offset; return *this; }
00053                        ~QhullHyperplane() {}
00054 
00055 #//Conversions --
00056 
00057 #ifndef QHULL_NO_STL
00058     std::vector<coordT> toStdVector() const;
00059 #endif //QHULL_NO_STL
00060 #ifdef QHULL_USES_QT
00061     QList<coordT>       toQList() const;
00062 #endif //QHULL_USES_QT
00063 
00064 #//Read-only
00065 public:
00066     const coordT       *coordinates() const { return hyperplane_coordinates; }
00067     coordT             *coordinates() { return hyperplane_coordinates; }
00068     int                 dimension() const { return hyperplane_dimension; }
00069     bool                isDefined() const { return hyperplane_coordinates!=0 && hyperplane_dimension>0; }
00070     coordT              offset() const { return hyperplane_offset; }
00071 
00072 #//Define
00073     void                defineAs(int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) { QHULL_ASSERT(hyperplaneDimension>=0); hyperplane_coordinates= c; hyperplane_dimension= hyperplaneDimension; hyperplane_offset= hyperplaneOffset; }
00075     void                defineAs(QhullHyperplane &other) { hyperplane_coordinates= other.coordinates(); hyperplane_dimension= other.dimension();  hyperplane_offset= other.offset(); }
00076     void                setCoordinates(coordT *c) { hyperplane_coordinates= c; }
00077     void                setDimension(int hyperplaneDimension) { hyperplane_dimension= hyperplaneDimension; }
00078     void                setOffset(coordT hyperplaneOffset) { hyperplane_offset= hyperplaneOffset; }
00079 
00080 #//value
00081     double              distance(const QhullPoint &p) const;
00082     double              norm() const;
00083 
00084 #//iterator
00085     iterator            begin() { return hyperplane_coordinates; }
00086     const_iterator      begin() const { return hyperplane_coordinates; }
00087     const_iterator      constBegin() const { return hyperplane_coordinates; }
00088     const_iterator      constEnd() const { return hyperplane_coordinates+hyperplane_dimension; }
00089     int                 count() { return dimension(); }
00090     iterator            end() { return hyperplane_coordinates+hyperplane_dimension; }
00091     const_iterator      end() const { return hyperplane_coordinates+hyperplane_dimension; }
00092     size_t              size() { return (size_t)dimension(); }
00093 
00094 #//Operator
00095     bool                operator==(const QhullHyperplane &other) const;
00096     bool                operator!=(const QhullHyperplane &other) const { return !operator==(other); }
00097     const coordT       &operator[](int idx) const { QHULL_ASSERT(idx>=0 && idx<hyperplane_dimension); return *(hyperplane_coordinates+idx); }
00098     coordT             &operator[](int idx) { QHULL_ASSERT(idx>=0 && idx<hyperplane_dimension); return *(hyperplane_coordinates+idx); }
00099 
00100 #//IO
00101     struct PrintHyperplane{
00102         const QhullHyperplane  *hyperplane;  
00103         const char     *print_message;
00104         const char     *hyperplane_offset_message;
00105                         PrintHyperplane(const char *message, const char *offsetMessage, const QhullHyperplane &p) : hyperplane(&p), print_message(message), hyperplane_offset_message(offsetMessage) {}
00106     };//PrintHyperplane
00107     PrintHyperplane          print() const { return  PrintHyperplane(0, 0, *this); }
00108     PrintHyperplane          print(const char *message, const char *offsetMessage) const { return PrintHyperplane(message, offsetMessage, *this); }
00109 
00110 };//QhullHyperplane
00111 
00112 QHULL_DECLARE_SEQUENTIAL_ITERATOR(QhullHyperplane, coordT)
00113 
00114 }//namespace orgQhull
00115 
00116 #//Global functions
00117 
00118 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullHyperplane::PrintHyperplane &pr);
00119 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullHyperplane &p); //FIXUP QH11015 -- multiple instances if define here
00120 
00121 #endif // QHHYPERPLANE_H
00122 


libqhull-ours
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:11