QhullVertexSet.cpp
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/QhullVertexSet.cpp#3 $$Change: 2066 $
5 ** $DateTime: 2016/01/18 19:29:17 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 
12 
14 #include "libqhullcpp/QhullPoint.h"
15 #include "libqhullcpp/QhullRidge.h"
17 #include "libqhullcpp/Qhull.h"
18 
19 using std::string;
20 using std::vector;
21 
22 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
23 #pragma warning( disable : 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
24  /* setjmp should not be implemented with 'catch' */
25 #endif
26 
27 namespace orgQhull {
28 
30 QhullVertexSet(const Qhull &q, facetT *facetlist, setT *facetset, bool allfacets)
31 : QhullSet<QhullVertex>(q.qh(), 0)
32 , qhsettemp_defined(false)
33 {
34  QH_TRY_(q.qh()){ // no object creation -- destructors skipped on longjmp()
35  setT *vertices= qh_facetvertices(q.qh(), facetlist, facetset, allfacets);
36  defineAs(vertices);
37  qhsettemp_defined= true;
38  }
39  q.qh()->NOerrexit= true;
40  q.qh()->maybeThrowQhullMessage(QH_TRY_status);
41 }//QhullVertexSet facetlist facetset
42 
46 QhullVertexSet(QhullQh *qqh, facetT *facetlist, setT *facetset, bool allfacets)
47 : QhullSet<QhullVertex>(qqh, 0)
48 , qhsettemp_defined(false)
49 {
50  QH_TRY_(qh()){ // no object creation -- destructors skipped on longjmp()
51  setT *vertices= qh_facetvertices(qh(), facetlist, facetset, allfacets);
52  defineAs(vertices);
53  qhsettemp_defined= true;
54  }
55  qh()->NOerrexit= true;
56  qh()->maybeThrowQhullMessage(QH_TRY_status);
57 }//QhullVertexSet facetlist facetset
58 
65 : QhullSet<QhullVertex>(other)
66 , qhsettemp_defined(false)
67 {
68  if(other.qhsettemp_defined){
69  throw QhullError(10077, "QhullVertexSet: Cannot use copy constructor since qhsettemp_defined (e.g., QhullVertexSet for a set and/or list of QhFacet). Contains %d vertices", other.count());
70  }
71 }//copy constructor
72 
77 {
79  qhsettemp_defined= false;
80  if(other.qhsettemp_defined){
81  throw QhullError(10078, "QhullVertexSet: Cannot use copy constructor since qhsettemp_defined (e.g., QhullVertexSet for a set and/or list of QhFacet). Contains %d vertices", other.count());
82  }
83  return *this;
84 }//assignment
85 
88 {
90  qhsettemp_defined= false;
91  QH_TRY_(qh()){ // no object creation -- destructors skipped on longjmp()
92  qh_settempfree(qh(), referenceSetT()); // errors if not top of tempstack or if qhmem corrupted
93  }
94  qh()->NOerrexit= true;
96  }
97 }//freeQhSetTemp
98 
101 {
102  freeQhSetTemp();
103 }//~QhullVertexSet
104 
105 //FIXUP -- Move conditional, QhullVertexSet code to QhullVertexSet.cpp
106 #ifndef QHULL_NO_STL
107 std::vector<QhullVertex> QhullVertexSet::
108 toStdVector() const
109 {
111  std::vector<QhullVertex> vs;
112  while(i.hasNext()){
113  QhullVertex v= i.next();
114  vs.push_back(v);
115  }
116  return vs;
117 }//toStdVector
118 #endif //QHULL_NO_STL
119 
120 }//namespace orgQhull
121 
122 #
123 
124 using std::endl;
125 using std::ostream;
130 
132 ostream &
133 operator<<(ostream &os, const QhullVertexSet::PrintIdentifiers &pr)
134 {
135  os << pr.print_message;
136  for(QhullVertexSet::const_iterator i= pr.vertex_set->begin(); i!=pr.vertex_set->end(); ++i){
137  const QhullVertex v= *i;
138  os << " v" << v.id();
139  }
140  os << endl;
141  return os;
142 }//<<QhullVertexSet::PrintIdentifiers
143 
145 ostream &
146 operator<<(ostream &os, const QhullVertexSet::PrintVertexSet &pr){
147 
148  os << pr.print_message;
149  const QhullVertexSet *vs= pr.vertex_set;
150  QhullVertexSetIterator i= *vs;
151  while(i.hasNext()){
152  const QhullVertex v= i.next();
153  const QhullPoint p= v.point();
154  os << " p" << p.id() << "(v" << v.id() << ")";
155  }
156  os << endl;
157 
158  return os;
159 }//<< PrintVertexSet
160 
161 
std::vector< QhullVertex > toStdVector() const
QhullSetIterator< QhullVertex > QhullVertexSetIterator
Definition: qset.h:83
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
void maybeThrowQhullMessage(int exitCode)
Definition: QhullQh.cpp:118
QhullSet< T > & operator=(const QhullSet< T > &other)
Definition: QhullSet.h:120
POD type equivalent to qhT. No virtual members.
Definition: QhullQh.h:58
QhullQh * qh() const
Definition: QhullSet.h:71
Faster then interator/const_iterator due to T::base_type.
Definition: QhullSet.h:283
#define QH_TRY_(qh)
Definition: QhullQh.h:31
QhullVertexSet & operator=(const QhullVertexSet &other)
ostream & operator<<(ostream &os, const QhullVertexSet::PrintIdentifiers &pr)
Print Vertex identifiers to stream. Space prefix. From qh_printVertexheader [io_r.c].
list v
Definition: obb.py:45
#define qh
Definition: libqhull.h:457
QhullPoint point() const
Definition: QhullVertex.h:82
countT id() const
Definition: QhullPoint.h:91
void qh_settempfree(setT **set)
Definition: qset.c:1174
Interface to Qhull from C++.
Definition: Qhull.h:43
QhullVertexSet()
Default constructor disabled. Will implement allocation later.
boolT NOerrexit
Definition: libqhull.h:737
QhullQh * qh() const
Definition: Qhull.h:81
void defineAs(setT *s)
Not type-safe since setT may contain any type.
Definition: QhullSet.h:67
setT ** referenceSetT()
Definition: QhullSet.h:72
countT count(const T &t) const
Definition: QhullSet.h:389
setT * qh_facetvertices(facetT *facetlist, setT *facets, boolT allfacets)
Definition: io.c:801
countT id() const
Definition: QhullVertex.h:75


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