QhullHyperplane.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/QhullHyperplane.h#3 $$Change: 2066 $
5 ** $DateTime: 2016/01/18 19:29:17 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #ifndef QHHYPERPLANE_H
10 #define QHHYPERPLANE_H
11 
12 extern "C" {
13  #include "libqhull_r/qhull_ra.h"
14 }
15 #include "libqhullcpp/QhullError.h"
17 #include "libqhullcpp/QhullQh.h"
18 
19 #include <ostream>
20 
21 namespace orgQhull {
22 
23 #
24  class Qhull;
25  class QhullPoint;
26 
27 #
28  class QhullHyperplane;
30  class QhullHyperplaneIterator;
32 
33 class QhullHyperplane { // Similar to QhullPoint
34 public:
35 #
36  typedef const coordT * iterator;
37  typedef const coordT * const_iterator;
40 
41 private:
42 #
43  coordT * hyperplane_coordinates;
44  QhullQh * qh_qh;
45  coordT hyperplane_offset;
46  int hyperplane_dimension;
47 
48 #
49 public:
51  explicit QhullHyperplane(const Qhull &q);
52  QhullHyperplane(const Qhull &q, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset);
54  QhullHyperplane(QhullQh *qqh, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) : hyperplane_coordinates(c), qh_qh(qqh), hyperplane_offset(hyperplaneOffset), hyperplane_dimension(hyperplaneDimension) {}
55  // Creates an alias. Does not copy the hyperplane's coordinates. Needed for return by value and parameter passing.
57  // Creates an alias. Does not copy the hyperplane's coordinates. Needed for vector<QhullHyperplane>
60 
61 #
62 #ifndef QHULL_NO_STL
64  std::vector<coordT> toStdVector() const;
65 #endif //QHULL_NO_STL
66 #ifdef QHULL_USES_QT
67  QList<coordT> toQList() const;
68 #endif //QHULL_USES_QT
69 
70 #
71 public:
72  const coordT * coordinates() const { return hyperplane_coordinates; }
74  void defineAs(int hyperplaneDimension, coordT *c, coordT hyperplaneOffset) { QHULL_ASSERT(hyperplaneDimension>=0); hyperplane_coordinates= c; hyperplane_dimension= hyperplaneDimension; hyperplane_offset= hyperplaneOffset; }
77  int dimension() const { return hyperplane_dimension; }
78  bool isValid() const { return hyperplane_coordinates!=0 && hyperplane_dimension>0; }
79  coordT offset() const { return hyperplane_offset; }
80  bool operator==(const QhullHyperplane &other) const;
81  bool operator!=(const QhullHyperplane &other) const { return !operator==(other); }
82  const coordT & operator[](int idx) const { QHULL_ASSERT(idx>=0 && idx<hyperplane_dimension); return *(hyperplane_coordinates+idx); }
83  coordT & operator[](int idx) { QHULL_ASSERT(idx>=0 && idx<hyperplane_dimension); return *(hyperplane_coordinates+idx); }
85  void setDimension(int hyperplaneDimension) { hyperplane_dimension= hyperplaneDimension; }
86  void setOffset(coordT hyperplaneOffset) { hyperplane_offset= hyperplaneOffset; }
87 
88 #
89  iterator begin() { return hyperplane_coordinates; }
90  const_iterator begin() const { return hyperplane_coordinates; }
91  const_iterator constBegin() const { return hyperplane_coordinates; }
92  const_iterator constEnd() const { return hyperplane_coordinates+hyperplane_dimension; }
93  int count() { return hyperplane_dimension; }
95  const_iterator end() const { return hyperplane_coordinates+hyperplane_dimension; }
96  size_t size() { return (size_t)hyperplane_dimension; }
97 
98 #
99  double distance(const QhullPoint &p) const;
100  double hyperplaneAngle(const QhullHyperplane &other) const;
101  double norm() const;
102 
103 #
104  struct PrintHyperplane{
106  const char * print_message;
108  PrintHyperplane(const char *message, const char *offsetMessage, const QhullHyperplane &p) : hyperplane(&p), print_message(message), hyperplane_offset_message(offsetMessage) {}
109  };//PrintHyperplane
110  PrintHyperplane print(const char *message) const { return PrintHyperplane(message, "", *this); }
111  PrintHyperplane print(const char *message, const char *offsetMessage) const { return PrintHyperplane(message, offsetMessage, *this); }
112 
113 };//QhullHyperplane
114 
116 
117 }//namespace orgQhull
118 
119 #
120 
121 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullHyperplane::PrintHyperplane &pr);
122 std::ostream &operator<<(std::ostream &os, const orgQhull::QhullHyperplane &p);
123 
124 #endif // QHHYPERPLANE_H
125 
coordT hyperplane_offset
Distance from hyperplane to origin.
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
q
bool operator!=(const QhullHyperplane &other) const
POD type equivalent to qhT. No virtual members.
Definition: QhullQh.h:58
const char * print_message
non-null message
PrintHyperplane print(const char *message, const char *offsetMessage) const
QhullHyperplane & operator=(const QhullHyperplane &other)
PrintHyperplane print(const char *message) const
coordT & operator[](int idx)
c
#define coordT
Definition: libqhull.h:80
const coordT * coordinates() const
#define QHULL_ASSERT
Definition: QhullError.h:16
int hyperplane_dimension
Dimension of hyperplane.
const_iterator constBegin() const
void defineAs(QhullHyperplane &other)
Creates an alias to other using the same qh_qh.
const_iterator constEnd() const
void setDimension(int hyperplaneDimension)
Interface to Qhull from C++.
Definition: Qhull.h:43
QhullHyperplane(const QhullHyperplane &other)
std::vector< coordT > toStdVector() const
double hyperplaneAngle(const QhullHyperplane &other) const
std::ostream & operator<<(std::ostream &os, const orgQhull::QhullHyperplane::PrintHyperplane &pr)
QhullQh * qh_qh
qhT for distanceEpsilon() in operator==
const_iterator begin() const
QhullHyperplane(QhullQh *qqh, int hyperplaneDimension, coordT *c, coordT hyperplaneOffset)
bool operator==(const QhullHyperplane &other) const
void defineAs(int hyperplaneDimension, coordT *c, coordT hyperplaneOffset)
void setCoordinates(coordT *c)
const_iterator end() const
coordT * hyperplane_coordinates
Normal to hyperplane. facetT.normal is normalized to 1.0.
QhullHyperplane::iterator Iterator
const coordT * const_iterator
void setOffset(coordT hyperplaneOffset)
const char * hyperplane_offset_message
non-null message
#define QHULL_DECLARE_SEQUENTIAL_ITERATOR(C, T)
Definition: QhullIterator.h:33
const coordT & operator[](int idx) const
PrintHyperplane(const char *message, const char *offsetMessage, const QhullHyperplane &p)
QhullHyperplane::const_iterator ConstIterator


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