QhullPoint.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (c) 2009-2015 C.B. Barber. All rights reserved.
4 ** $Id: //main/2015/qhull/src/libqhullcpp/QhullPoint.h#3 $$Change: 2066 $
5 ** $DateTime: 2016/01/18 19:29:17 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #ifndef QHPOINT_H
10 #define QHPOINT_H
11 
12 extern "C" {
13  #include "libqhull_r/qhull_ra.h"
14 }
15 #include "libqhullcpp/QhullError.h"
17 #include "libqhullcpp/QhullQh.h"
19 
20 #include <ostream>
21 
22 namespace orgQhull {
23 
24 #
25  class QhullPoint;
26  class QhullPointIterator;
27 
28 #
29  class Qhull;
30 
33 class QhullPoint {
34 
35 #
36 public:
37  typedef coordT * base_type; // for QhullPointSet
38  typedef const coordT * iterator;
39  typedef const coordT * const_iterator;
42 
43 #
44 protected: // For QhullPoints::iterator, QhullPoints::const_iterator
50 public:
51 
52 #
53  QhullPoint() : point_coordinates(0), qh_qh(0), point_dimension(0) {}
57  QhullPoint(int pointDimension, coordT *c) : point_coordinates(c), qh_qh(0), point_dimension(pointDimension) { QHULL_ASSERT(pointDimension>0); }
58  explicit QhullPoint(const Qhull &q);
59  QhullPoint(const Qhull &q, coordT *c);
60  QhullPoint(const Qhull &q, Coordinates &c);
61  QhullPoint(const Qhull &q, int pointDimension, coordT *c);
62  explicit QhullPoint(QhullQh *qqh) : point_coordinates(0), qh_qh(qqh), point_dimension(qqh->hull_dim) {}
63  QhullPoint(QhullQh *qqh, coordT *c) : point_coordinates(c), qh_qh(qqh), point_dimension(qqh->hull_dim) { QHULL_ASSERT(qqh->hull_dim>0); }
65  QhullPoint(QhullQh *qqh, int pointDimension, coordT *c) : point_coordinates(c), qh_qh(qqh), point_dimension(pointDimension) {}
69  QhullPoint & operator=(const QhullPoint &other) { point_coordinates= other.point_coordinates; qh_qh= other.qh_qh; point_dimension= other.point_dimension; return *this; }
71 
72 
73 #
74 
75 #ifndef QHULL_NO_STL
76  std::vector<coordT> toStdVector() const;
77 #endif //QHULL_NO_STL
78 #ifdef QHULL_USES_QT
79  QList<coordT> toQList() const;
80 #endif //QHULL_USES_QT
81 
82 #
83 public:
84  const coordT * coordinates() const { return point_coordinates; }
85  coordT * coordinates() { return point_coordinates; }
87  void defineAs(int pointDimension, coordT *c) { QHULL_ASSERT(pointDimension>=0); point_coordinates= c; point_dimension= pointDimension; }
88  void defineAs(QhullPoint &other) { point_coordinates= other.point_coordinates; qh_qh= other.qh_qh; point_dimension= other.point_dimension; }
89  int dimension() const { return point_dimension; }
90  coordT * getBaseT() const { return point_coordinates; } // for QhullPointSet
91  countT id() const { return qh_pointid(qh_qh, point_coordinates); } // NOerrors
92  bool isValid() const { return (point_coordinates!=0 && point_dimension>0); };
93  bool operator==(const QhullPoint &other) const;
94  bool operator!=(const QhullPoint &other) const { return ! operator==(other); }
95  const coordT & operator[](int idx) const { QHULL_ASSERT(point_coordinates!=0 && idx>=0 && idx<point_dimension); return *(point_coordinates+idx); }
96  coordT & operator[](int idx) { QHULL_ASSERT(point_coordinates!=0 && idx>=0 && idx<point_dimension); return *(point_coordinates+idx); }
97  QhullQh * qh() { return qh_qh; }
99  void setDimension(int pointDimension) { point_dimension= pointDimension; }
100 
101 #
102  iterator begin() { return point_coordinates; }
106  int count() { return (point_coordinates ? point_dimension : 0); }
109  size_t size() { return (size_t)(point_coordinates ? point_dimension : 0); }
110 
111 #
112  void advancePoint(countT idx) { if(point_coordinates) { point_coordinates += idx*point_dimension; } }
113  double distance(const QhullPoint &p) const;
114 
115 #
116 
117  struct PrintPoint{
119  const char * point_message;
120  bool with_identifier;
121  PrintPoint(const char *message, bool withIdentifier, const QhullPoint &p) : point(&p), point_message(message), with_identifier(withIdentifier) {}
122  };//PrintPoint
123  PrintPoint print(const char *message) const { return PrintPoint(message, false, *this); }
124  PrintPoint printWithIdentifier(const char *message) const { return PrintPoint(message, true, *this); }
125 
126 };//QhullPoint
127 
129 
130 }//namespace orgQhull
131 
132 #
133 
134 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullPoint::PrintPoint &pr);
135 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullPoint &p);
136 
137 #endif // QHPOINT_H
138 
Coordinates.h
orgQhull::QhullPoint::setDimension
void setDimension(int pointDimension)
Definition: QhullPoint.h:105
coordT
#define coordT
Definition: libqhull.h:80
orgQhull::QhullPoint::~QhullPoint
~QhullPoint()
Definition: QhullPoint.h:76
orgQhull::QhullPoint::size
size_t size()
Definition: QhullPoint.h:115
orgQhull::QhullPoint::id
countT id() const
Definition: QhullPoint.h:97
orgQhull::QhullPoint::ConstIterator
QhullPoint::const_iterator ConstIterator
Definition: QhullPoint.h:47
countT
int countT
Definition: user_r.h:182
orgQhull
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
orgQhull::QhullPoint::base_type
coordT * base_type
Definition: QhullPoint.h:43
orgQhull::QhullPoint::operator!=
bool operator!=(const QhullPoint &other) const
Definition: QhullPoint.h:100
qhT::hull_dim
int hull_dim
Definition: libqhull.h:591
orgQhull::QhullPoint
Definition: QhullPoint.h:39
orgQhull::QhullPoint::count
int count()
Definition: QhullPoint.h:112
orgQhull::QhullPoint::constEnd
const_iterator constEnd() const
Definition: QhullPoint.h:111
QhullIterator.h
data
data
orgQhull::QhullPoint::toStdVector
std::vector< coordT > toStdVector() const
Definition: QhullPoint.cpp:71
orgQhull::QhullPoint::QhullPoint
QhullPoint()
Definition: QhullPoint.h:62
orgQhull::QhullPoint::print
PrintPoint print(const char *message) const
Definition: QhullPoint.h:129
orgQhull::QhullPoint::end
iterator end()
Definition: QhullPoint.h:113
orgQhull::QhullPoint::distance
double distance(const QhullPoint &p) const
Return distance between two points.
Definition: QhullPoint.cpp:123
orgQhull::QhullPoint::PrintPoint
Definition: QhullPoint.h:123
orgQhull::Qhull
Interface to Qhull from C++.
Definition: Qhull.h:49
orgQhull::QhullPoint::setCoordinates
void setCoordinates(coordT *c)
Definition: QhullPoint.h:104
c
c
orgQhull::QhullPoint::PrintPoint::with_identifier
bool with_identifier
Definition: QhullPoint.h:126
orgQhull::QhullPoint::begin
iterator begin()
Definition: QhullPoint.h:108
orgQhull::QhullPoint::QhullPoint
QhullPoint(int pointDimension, coordT *c)
Definition: QhullPoint.h:63
orgQhull::QhullQh
POD type equivalent to qhT. No virtual members.
Definition: QhullQh.h:58
operator<<
std::ostream & operator<<(std::ostream &os, const orgQhull::QhullPoint::PrintPoint &pr)
orgQhull::QhullPoint::qh
QhullQh * qh()
Definition: QhullPoint.h:103
orgQhull::QhullPoint::printWithIdentifier
PrintPoint printWithIdentifier(const char *message) const
Definition: QhullPoint.h:130
qhull_ra.h
orgQhull::QhullPoint::iterator
const typedef coordT * iterator
Definition: QhullPoint.h:44
orgQhull::QhullPoint::dimension
int dimension() const
Definition: QhullPoint.h:95
qh_pointid
int qh_pointid(pointT *point)
Definition: poly.c:1053
orgQhull::QhullPoint::operator=
QhullPoint & operator=(const QhullPoint &other)
Creates an alias. Does not make a deep copy of the point. Needed for vector<QhullPoint>
Definition: QhullPoint.h:75
orgQhull::QhullPoint::getBaseT
coordT * getBaseT() const
Definition: QhullPoint.h:96
orgQhull::QhullPoint::PrintPoint::point_message
const char * point_message
Definition: QhullPoint.h:125
orgQhull::QhullPoint::point_dimension
int point_dimension
Default dimension is qh_qh->hull_dim.
Definition: QhullPoint.h:55
orgQhull::QhullPoint::operator==
bool operator==(const QhullPoint &other) const
Definition: QhullPoint.cpp:89
orgQhull::QhullPoint::const_iterator
const typedef coordT * const_iterator
Definition: QhullPoint.h:45
QhullQh.h
orgQhull::Coordinates
Definition: Coordinates.h:38
orgQhull::QhullPoint::constBegin
const_iterator constBegin() const
Definition: QhullPoint.h:110
orgQhull::QhullPoint::point_coordinates
coordT * point_coordinates
Pointer to first coordinate, 0 if undefined.
Definition: QhullPoint.h:51
QHULL_ASSERT
#define QHULL_ASSERT
Definition: QhullError.h:16
orgQhull::QhullPoint::defineAs
void defineAs(coordT *c)
Definition: QhullPoint.h:92
orgQhull::QhullPoint::isValid
bool isValid() const
Definition: QhullPoint.h:98
orgQhull::QhullPoint::Iterator
QhullPoint::iterator Iterator
Definition: QhullPoint.h:46
QHULL_DECLARE_SEQUENTIAL_ITERATOR
#define QHULL_DECLARE_SEQUENTIAL_ITERATOR(C, T)
Definition: QhullIterator.h:39
QhullError.h
orgQhull::QhullPoint::PrintPoint::point
const QhullPoint * point
Definition: QhullPoint.h:124
orgQhull::QhullPoint::qh_qh
QhullQh * qh_qh
Definition: QhullPoint.h:52
orgQhull::QhullPoint::PrintPoint::PrintPoint
PrintPoint(const char *message, bool withIdentifier, const QhullPoint &p)
Definition: QhullPoint.h:127


hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:14