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
47  int point_dimension;
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); }
64  QhullPoint(QhullQh *qqh, Coordinates &c) : point_coordinates(c.data()), qh_qh(qqh), point_dimension(c.count()) {}
65  QhullPoint(QhullQh *qqh, int pointDimension, coordT *c) : point_coordinates(c), qh_qh(qqh), point_dimension(pointDimension) {}
67  QhullPoint(const QhullPoint &other) : point_coordinates(other.point_coordinates), qh_qh(other.qh_qh), point_dimension(other.point_dimension) {}
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; }
86  void defineAs(coordT *c) { QHULL_ASSERT(point_dimension>0); point_coordinates= c; }
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; }
98  void setCoordinates(coordT *c) { point_coordinates= c; }
99  void setDimension(int pointDimension) { point_dimension= pointDimension; }
100 
101 #
102  iterator begin() { return point_coordinates; }
103  const_iterator begin() const { return point_coordinates; }
104  const_iterator constBegin() const { return point_coordinates; }
105  const_iterator constEnd() const { return (point_coordinates ? point_coordinates+point_dimension : 0); }
106  int count() { return (point_coordinates ? point_dimension : 0); }
107  iterator end() { return (point_coordinates ? point_coordinates+point_dimension : 0); }
108  const_iterator end() const { return (point_coordinates ? 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;
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 
int hull_dim
Definition: libqhull.h:591
QhullPoint(QhullQh *qqh, coordT *c)
Definition: QhullPoint.h:63
PrintPoint printWithIdentifier(const char *message) const
Definition: QhullPoint.h:124
coordT * coordinates()
0 if undefined
Definition: QhullPoint.h:85
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
q
QhullQh * qh()
Definition: QhullPoint.h:97
const coordT & operator[](int idx) const
0 to hull_dim-1
Definition: QhullPoint.h:95
POD type equivalent to qhT. No virtual members.
Definition: QhullQh.h:58
int dimension() const
Definition: QhullPoint.h:89
const_iterator constBegin() const
Definition: QhullPoint.h:104
const_iterator begin() const
Definition: QhullPoint.h:103
bool operator==(const QhullPoint &other) const
Definition: QhullPoint.cpp:83
coordT * getBaseT() const
Definition: QhullPoint.h:90
int point_dimension
Default dimension is qh_qh->hull_dim.
Definition: QhullPoint.h:49
int qh_pointid(pointT *point)
Definition: poly.c:1053
QhullPoint::iterator Iterator
Definition: QhullPoint.h:40
const_iterator end() const
Definition: QhullPoint.h:108
QhullPoint & operator=(const QhullPoint &other)
Creates an alias. Does not make a deep copy of the point. Needed for vector<QhullPoint> ...
Definition: QhullPoint.h:69
c
data
coordT * point_coordinates
Pointer to first coordinate, 0 if undefined.
Definition: QhullPoint.h:45
void defineAs(coordT *c)
Definition: QhullPoint.h:86
#define coordT
Definition: libqhull.h:80
PrintPoint(const char *message, bool withIdentifier, const QhullPoint &p)
Definition: QhullPoint.h:121
bool isValid() const
Definition: QhullPoint.h:92
#define QHULL_ASSERT
Definition: QhullError.h:16
countT id() const
Definition: QhullPoint.h:91
void setDimension(int pointDimension)
Definition: QhullPoint.h:99
Interface to Qhull from C++.
Definition: Qhull.h:43
QhullPoint(QhullQh *qqh, int pointDimension, coordT *c)
Definition: QhullPoint.h:65
const coordT * iterator
Definition: QhullPoint.h:38
void defineAs(int pointDimension, coordT *c)
Definition: QhullPoint.h:87
QhullPoint::const_iterator ConstIterator
Definition: QhullPoint.h:41
bool operator!=(const QhullPoint &other) const
Definition: QhullPoint.h:94
const coordT * const_iterator
Definition: QhullPoint.h:39
QhullPoint(QhullQh *qqh)
Definition: QhullPoint.h:62
std::vector< coordT > toStdVector() const
Definition: QhullPoint.cpp:65
const_iterator constEnd() const
Definition: QhullPoint.h:105
void defineAs(QhullPoint &other)
Definition: QhullPoint.h:88
PrintPoint print(const char *message) const
Definition: QhullPoint.h:123
void setCoordinates(coordT *c)
Definition: QhullPoint.h:98
std::ostream & operator<<(std::ostream &os, const orgQhull::QhullPoint::PrintPoint &pr)
int countT
Definition: user_r.h:182
QhullPoint(const QhullPoint &other)
Creates an alias. Does not make a deep copy of the point. Needed for return by value and parameter pa...
Definition: QhullPoint.h:67
coordT & operator[](int idx)
0 to hull_dim-1
Definition: QhullPoint.h:96
QhullPoint(QhullQh *qqh, Coordinates &c)
Definition: QhullPoint.h:64
const coordT * coordinates() const
0 if undefined
Definition: QhullPoint.h:84
double distance(const QhullPoint &p) const
Return distance between two points.
Definition: QhullPoint.cpp:117
#define QHULL_DECLARE_SEQUENTIAL_ITERATOR(C, T)
Definition: QhullIterator.h:33
QhullPoint(int pointDimension, coordT *c)
Definition: QhullPoint.h:57


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:02