PointCoordinates.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/PointCoordinates.h#4 $$Change: 1348 $
00005 ** $DateTime: 2011/03/25 23:54:58 $$Author: bbarber $
00006 **
00007 ****************************************************************************/
00008 
00009 #ifndef QHPOINTCOORDINATES_H
00010 #define QHPOINTCOORDINATES_H
00011 
00012 #include "QhullPoints.h"
00013 #include "Coordinates.h"
00014 extern "C" {
00015     #include "libqhull/qhull_a.h"
00016 }
00017 
00018 #include <ostream>
00019 #include <vector>
00020 
00021 namespace orgQhull {
00022 
00023 #//Types
00024 
00025     class PointCoordinates;
00026 
00027 class PointCoordinates : public QhullPoints {
00028 
00029 private:
00030 #//Field
00031     Coordinates         point_coordinates;      
00032 
00033     std::string         point_comment;          
00034 
00035 public:
00036 #//Construct
00037                         PointCoordinates();
00038     explicit            PointCoordinates(int pointDimension);
00039     explicit            PointCoordinates(const std::string &aComment);
00040                         PointCoordinates(int pointDimension, const std::string &aComment);
00041                         PointCoordinates(int pointDimension, const std::string &aComment, int coordinatesCount, const coordT *c); // may be invalid
00043                         PointCoordinates(const PointCoordinates &other);
00044     PointCoordinates   &operator=(const PointCoordinates &other);
00045     ~PointCoordinates();
00046 
00047 #//Convert
00048 
00049 #ifndef QHULL_NO_STL
00050     void                append(const std::vector<coordT> &otherCoordinates) { if(!otherCoordinates.empty()){ append((int)otherCoordinates.size(), &otherCoordinates[0]); } }
00051     std::vector<coordT> toStdVector() const { return point_coordinates.toStdVector(); }
00052 #endif //QHULL_NO_STL
00053 #ifdef QHULL_USES_QT
00054     void                append(const QList<coordT> &pointCoordinates) { if(!pointCoordinates.isEmpty()){ append(pointCoordinates.count(), &pointCoordinates[0]); } }
00055     QList<coordT>       toQList() const { return point_coordinates.toQList(); }
00056 #endif //QHULL_USES_QT
00057 
00058 #//GetSet
00059 
00060     void                checkValid() const;
00061     std::string         comment() const { return point_comment; }
00062     void                makeValid() { defineAs(point_coordinates.count(), point_coordinates.data()); }
00063     const Coordinates  &getCoordinates() const { return point_coordinates; }
00064     void                setComment(const std::string &s) { point_comment= s; }
00065     void                setDimension(int i);
00066 
00067 private:
00068     void                defineAs(int coordinatesCount, coordT *c) { QhullPoints::defineAs(coordinatesCount, c); }
00070 public:
00071 
00072 #//ElementAccess
00073 
00074 
00075 #//Foreach
00076 
00077     Coordinates::ConstIterator  beginCoordinates() const { return point_coordinates.begin(); }
00078     Coordinates::Iterator       beginCoordinates() { return point_coordinates.begin(); }
00079     Coordinates::ConstIterator  beginCoordinates(int pointIndex) const;
00080     Coordinates::Iterator       beginCoordinates(int pointIndex);
00081     Coordinates::ConstIterator  endCoordinates() const { return point_coordinates.end(); }
00082     Coordinates::Iterator       endCoordinates() { return point_coordinates.end(); }
00083 
00084 #//Search
00085 
00086 
00087 #//Read-only
00088     PointCoordinates    operator+(const PointCoordinates &other) const;
00089 
00090 #//Modify
00091     //FIXUP QH11001: Add clear() and other modify operators from Coordinates.h.  Include QhullPoint::operator=()
00092     void                append(int coordinatesCount, const coordT *c);  
00093     void                append(const coordT &c) { append(1, &c); } 
00094     void                append(const QhullPoint &p);
00096     void                append(const Coordinates &c) { append(c.count(), c.data()); }
00097     void                append(const PointCoordinates &other);
00098     void                appendComment(const std::string &s);
00099     void                appendPoints(std::istream &in);
00100     PointCoordinates   &operator+=(const PointCoordinates &other) { append(other); return *this; }
00101     PointCoordinates   &operator+=(const coordT &c) { append(c); return *this; }
00102     PointCoordinates   &operator+=(const QhullPoint &p) { append(p); return *this; }
00103     PointCoordinates   &operator<<(const PointCoordinates &other) { return *this += other; }
00104     PointCoordinates   &operator<<(const coordT &c) { return *this += c; }
00105     PointCoordinates   &operator<<(const QhullPoint &p) { return *this += p; }
00106     // reserve() is non-const
00107     void                reserveCoordinates(int newCoordinates);
00108 
00109 #//Helpers
00110 private:
00111     int                 indexOffset(int i) const;
00112 
00113 };//PointCoordinates
00114 
00115 // No references to QhullPoint.  Prevents use of QHULL_DECLARE_SEQUENTIAL_ITERATOR(PointCoordinates, QhullPoint)
00116 class PointCoordinatesIterator
00117 {
00118     typedef PointCoordinates::const_iterator const_iterator;
00119     const PointCoordinates *c;
00120     const_iterator i;
00121     public:
00122     inline PointCoordinatesIterator(const PointCoordinates &container)
00123     : c(&container), i(c->constBegin()) {}
00124     inline PointCoordinatesIterator &operator=(const PointCoordinates &container)
00125     { c = &container; i = c->constBegin(); return *this; }
00126     inline void toFront() { i = c->constBegin(); }
00127     inline void toBack() { i = c->constEnd(); }
00128     inline bool hasNext() const { return i != c->constEnd(); }
00129     inline const QhullPoint next() { return *i++; }
00130     inline const QhullPoint peekNext() const { return *i; }
00131     inline bool hasPrevious() const { return i != c->constBegin(); }
00132     inline const QhullPoint previous() { return *--i; }
00133     inline const QhullPoint peekPrevious() const { const_iterator p = i; return *--p; }
00134     inline bool findNext(const QhullPoint &t)
00135     { while (i != c->constEnd()) if (*i++ == t) return true; return false; }
00136     inline bool findPrevious(const QhullPoint &t)
00137     { while (i != c->constBegin()) if (*(--i) == t) return true;
00138     return false;  }
00139 };//CoordinatesIterator
00140 
00141 // FIXUP QH11002:  Add MutablePointCoordinatesIterator after adding modify operators
00142 \
00143 }//namespace orgQhull
00144 
00145 #//Global functions
00146 
00147 std::ostream           &operator<<(std::ostream &os, const orgQhull::PointCoordinates &p);
00148 
00149 #endif // QHPOINTCOORDINATES_H


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