CASM  1.1.0
A Clusters Approach to Statistical Mechanics
QhullFacetList.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (c) 2008-2015 C.B. Barber. All rights reserved.
4 ** $Id: //main/2015/qhull/src/libqhullcpp/QhullFacetList.cpp#1 $$Change: 1981 $
5 ** $DateTime: 2015/09/28 20:26:32 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 
11 #include "QhullFacet.h"
12 #include "QhullFacetList.h"
13 #include "QhullPoint.h"
14 #include "QhullRidge.h"
15 #include "QhullVertex.h"
16 
17 using std::string;
18 using std::vector;
19 
20 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
21 #pragma warning( disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
22 #pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
23 #endif
24 
25 namespace orgQhull {
26 
27 #
28 
29 QhullFacetList::
30 QhullFacetList(const Qhull &q, facetT *b, facetT *e )
31 : QhullLinkedList<QhullFacet>(QhullFacet(q, b), QhullFacet(q, e))
32 , select_all(false)
33 {
34 }
35 
36 #
37 
38 // See qt_qhull.cpp for QList conversions
39 
40 #ifndef QHULL_NO_STL
41 std::vector<QhullFacet> QhullFacetList::
42 toStdVector() const
43 {
44  QhullLinkedListIterator<QhullFacet> i(*this);
45  std::vector<QhullFacet> vs;
46  while(i.hasNext()){
47  QhullFacet f= i.next();
48  if(isSelectAll() || f.isGood()){
49  vs.push_back(f);
50  }
51  }
52  return vs;
53 }//toStdVector
54 #endif //QHULL_NO_STL
55 
56 #ifndef QHULL_NO_STL
58 std::vector<QhullVertex> QhullFacetList::
59 vertices_toStdVector() const
60 {
61  std::vector<QhullVertex> vs;
62  QhullVertexSet qvs(qh(), first().getFacetT(), 0, isSelectAll());
63 
64  for(QhullVertexSet::iterator i=qvs.begin(); i!=qvs.end(); ++i){
65  vs.push_back(*i);
66  }
67  return vs;
68 }//vertices_toStdVector
69 #endif //QHULL_NO_STL
70 
71 #
72 
74 contains(const QhullFacet &facet) const
75 {
76  if(isSelectAll()){
78  }
79  for(QhullFacetList::const_iterator i=begin(); i != end(); ++i){
80  QhullFacet f= *i;
81  if(f==facet && f.isGood()){
82  return true;
83  }
84  }
85  return false;
86 }//contains
87 
89 count() const
90 {
91  if(isSelectAll()){
93  }
94  int counter= 0;
95  for(QhullFacetList::const_iterator i=begin(); i != end(); ++i){
96  if((*i).isGood()){
97  counter++;
98  }
99  }
100  return counter;
101 }//count
102 
104 count(const QhullFacet &facet) const
105 {
106  if(isSelectAll()){
108  }
109  int counter= 0;
110  for(QhullFacetList::const_iterator i=begin(); i != end(); ++i){
111  QhullFacet f= *i;
112  if(f==facet && f.isGood()){
113  counter++;
114  }
115  }
116  return counter;
117 }//count
118 
119 }//namespace orgQhull
120 
121 #
122 
123 using std::endl;
124 using std::ostream;
125 using orgQhull::QhullFacet;
126 using orgQhull::QhullFacetList;
127 using orgQhull::QhullVertex;
128 using orgQhull::QhullVertexSet;
129 
130 ostream &
131 operator<<(ostream &os, const QhullFacetList::PrintFacetList &pr)
132 {
133  os << pr.print_message;
134  QhullFacetList fs= *pr.facet_list;
135  os << "Vertices for " << fs.count() << " facets" << endl;
136  os << fs.printVertices();
137  os << fs.printFacets();
138  return os;
139 }//operator<<
140 
142 ostream &
143 operator<<(ostream &os, const QhullFacetList::PrintFacets &pr)
144 {
145  for(QhullFacetList::const_iterator i= pr.facet_list->begin(); i != pr.facet_list->end(); ++i){
146  QhullFacet f= *i;
147  if(pr.facet_list->isSelectAll() || f.isGood()){
148  os << f.print("");
149  }
150  }
151  return os;
152 }//printFacets
153 
156 ostream &
157 operator<<(ostream &os, const QhullFacetList::PrintVertices &pr)
158 {
159  QhullVertexSet vs(pr.facet_list->qh(), pr.facet_list->first().getFacetT(), NULL, pr.facet_list->isSelectAll());
160  for(QhullVertexSet::iterator i=vs.begin(); i!=vs.end(); ++i){
161  QhullVertex v= *i;
162  os << v.print("");
163  }
164  return os;
165 }//printVertices
166 
167 std::ostream &
168 operator<<(ostream &os, const QhullFacetList &fs)
169 {
170  os << fs.printFacets();
171  return os;
172 }//QhullFacetList
173 
Index count
ostream & operator<<(ostream &os, const QhullFacetList::PrintFacetList &pr)
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value)
Definition: algorithm.hh:83
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:20