CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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#1 $$Change: 1981 $
5 ** $DateTime: 2015/09/28 20:26:32 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 
11 #include "QhullVertex.h"
12 #include "QhullVertexSet.h"
13 #include "QhullPoint.h"
14 #include "QhullRidge.h"
15 #include "QhullVertex.h"
16 #include "Qhull.h"
17 
18 using std::string;
19 using std::vector;
20 
21 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
22 #pragma warning( disable : 4611) /* interaction between '_setjmp' and C++ object destruction is non-portable */
23  /* setjmp should not be implemented with 'catch' */
24 #endif
25 
26 namespace orgQhull {
27 
28 QhullVertexSet::
29 QhullVertexSet(const Qhull &q, facetT *facetlist, setT *facetset, bool allfacets)
30 : QhullSet<QhullVertex>(q.qh(), 0)
31 , qhsettemp_defined(false)
32 {
33  QH_TRY_(q.qh()){ // no object creation -- destructors skipped on longjmp()
34  setT *vertices= qh_facetvertices(q.qh(), facetlist, facetset, allfacets);
35  defineAs(vertices);
36  qhsettemp_defined= true;
37  }
38  q.qh()->NOerrexit= true;
39  q.qh()->maybeThrowQhullMessage(QH_TRY_status);
40 }//QhullVertexSet facetlist facetset
41 
44 QhullVertexSet::
45 QhullVertexSet(QhullQh *qqh, facetT *facetlist, setT *facetset, bool allfacets)
46 : QhullSet<QhullVertex>(qqh, 0)
47 , qhsettemp_defined(false)
48 {
49  QH_TRY_(qh()){ // no object creation -- destructors skipped on longjmp()
50  setT *vertices= qh_facetvertices(qh(), facetlist, facetset, allfacets);
51  defineAs(vertices);
52  qhsettemp_defined= true;
53  }
54  qh()->NOerrexit= true;
55  qh()->maybeThrowQhullMessage(QH_TRY_status);
56 }//QhullVertexSet facetlist facetset
57 
62 QhullVertexSet::
63 QhullVertexSet(const QhullVertexSet &other)
64 : QhullSet<QhullVertex>(other)
65 , qhsettemp_defined(false)
66 {
67  if(other.qhsettemp_defined){
68  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());
69  }
70 }//copy constructor
71 
74 QhullVertexSet & QhullVertexSet::
75 operator=(const QhullVertexSet &other)
76 {
77  QhullSet<QhullVertex>::operator=(other);
78  qhsettemp_defined= false;
79  if(other.qhsettemp_defined){
80  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());
81  }
82  return *this;
83 }//assignment
84 
85 void QhullVertexSet::
86 freeQhSetTemp()
87 {
88  if(qhsettemp_defined){
89  qhsettemp_defined= false;
90  QH_TRY_(qh()){ // no object creation -- destructors skipped on longjmp()
91  qh_settempfree(qh(), referenceSetT()); // errors if not top of tempstack or if qhmem corrupted
92  }
93  qh()->NOerrexit= true;
94  qh()->maybeThrowQhullMessage(QH_TRY_status, QhullError::NOthrow);
95  }
96 }//freeQhSetTemp
97 
98 QhullVertexSet::
99 ~QhullVertexSet()
100 {
101  freeQhSetTemp();
102 }//~QhullVertexSet
103 
104 //FIXUP -- Move conditional, QhullVertexSet code to QhullVertexSet.cpp
105 #ifndef QHULL_NO_STL
106 std::vector<QhullVertex> QhullVertexSet::
107 toStdVector() const
108 {
109  QhullSetIterator<QhullVertex> i(*this);
110  std::vector<QhullVertex> vs;
111  while(i.hasNext()){
112  QhullVertex v= i.next();
113  vs.push_back(v);
114  }
115  return vs;
116 }//toStdVector
117 #endif //QHULL_NO_STL
118 
119 }//namespace orgQhull
120 
121 #
122 
123 using std::endl;
124 using std::ostream;
125 using orgQhull::QhullPoint;
126 using orgQhull::QhullVertex;
127 using orgQhull::QhullVertexSet;
128 using orgQhull::QhullVertexSetIterator;
129 
131 ostream &
132 operator<<(ostream &os, const QhullVertexSet::PrintIdentifiers &pr)
133 {
134  os << pr.print_message;
135  for(QhullVertexSet::const_iterator i= pr.vertex_set->begin(); i!=pr.vertex_set->end(); ++i){
136  const QhullVertex v= *i;
137  os << " v" << v.id();
138  }
139  os << endl;
140  return os;
141 }//<<QhullVertexSet::PrintIdentifiers
142 
144 ostream &
145 operator<<(ostream &os, const QhullVertexSet::PrintVertexSet &pr){
146 
147  os << pr.print_message;
148  const QhullVertexSet *vs= pr.vertex_set;
149  QhullVertexSetIterator i= *vs;
150  while(i.hasNext()){
151  const QhullVertex v= i.next();
152  const QhullPoint p= v.point();
153  os << " p" << p.id() << "(v" << v.id() << ")";
154  }
155  os << endl;
156 
157  return os;
158 }//<< PrintVertexSet
159 
160 
std::ostream & operator<<(std::ostream &sout, const SelectiveDynamics &sel)
Write SelectiveDynamics options.
Definition: VaspIO.hh:63
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:20