CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
QhullFacetSet.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/QhullFacetSet.cpp#1 $$Change: 1981 $
5 ** $DateTime: 2015/09/28 20:26:32 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 
11 #include "QhullFacetSet.h"
12 
13 #include "QhullFacet.h" // Before QhullFacetSet for base_type
14 #include "QhullPoint.h"
15 #include "QhullRidge.h"
16 #include "QhullVertex.h"
17 
18 #ifndef QHULL_NO_STL
19 using std::vector;
20 #endif
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 #pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
25 #endif
26 
27 namespace orgQhull {
28 
29 #
30 
31 // See qt-qhull.cpp for QList conversions
32 
33 #ifndef QHULL_NO_STL
34 std::vector<QhullFacet> QhullFacetSet::
35 toStdVector() const
36 {
37  QhullSetIterator<QhullFacet> i(*this);
38  std::vector<QhullFacet> vs;
39  while(i.hasNext()){
40  QhullFacet f= i.next();
41  if(isSelectAll() || f.isGood()){
42  vs.push_back(f);
43  }
44  }
45  return vs;
46 }//toStdVector
47 #endif //QHULL_NO_STL
48 
49 #
50 
51 bool QhullFacetSet::
52 contains(const QhullFacet &facet) const
53 {
54  if(isSelectAll()){
55  return QhullSet<QhullFacet>::contains(facet);
56  }
57  for(QhullFacetSet::const_iterator i=begin(); i != end(); ++i){
58  QhullFacet f= *i;
59  if(f==facet && f.isGood()){
60  return true;
61  }
62  }
63  return false;
64 }//contains
65 
66 int QhullFacetSet::
67 count() const
68 {
69  if(isSelectAll()){
70  return QhullSet<QhullFacet>::count();
71  }
72  int counter= 0;
73  for(QhullFacetSet::const_iterator i=begin(); i != end(); ++i){
74  QhullFacet f= *i;
75  if(f.isGood()){
76  counter++;
77  }
78  }
79  return counter;
80 }//count
81 
82 int QhullFacetSet::
83 count(const QhullFacet &facet) const
84 {
85  if(isSelectAll()){
86  return QhullSet<QhullFacet>::count(facet);
87  }
88  int counter= 0;
89  for(QhullFacetSet::const_iterator i=begin(); i != end(); ++i){
90  QhullFacet f= *i;
91  if(f==facet && f.isGood()){
92  counter++;
93  }
94  }
95  return counter;
96 }//count
97 
98 }//namespace orgQhull
99 
100 #
101 
102 using std::endl;
103 using std::ostream;
104 using orgQhull::QhullFacet;
105 using orgQhull::QhullFacetSet;
106 
107 ostream &
108 operator<<(ostream &os, const QhullFacetSet &fs)
109 {
110  os << fs.print("");
111  return os;
112 }//<<QhullFacetSet
113 
114 ostream &
115 
116 operator<<(ostream &os, const QhullFacetSet::PrintFacetSet &pr)
117 {
118  os << pr.print_message;
119  QhullFacetSet fs= *pr.facet_set;
120  for(QhullFacetSet::iterator i=fs.begin(); i != fs.end(); ++i){
121  QhullFacet f= *i;
122  if(fs.isSelectAll() || f.isGood()){
123  os << f;
124  }
125  }
126  return os;
127 }//<< QhullFacetSet::PrintFacetSet
128 
130 ostream &
131 operator<<(ostream &os, const QhullFacetSet::PrintIdentifiers &p)
132 {
133  os << p.print_message;
134  for(QhullFacetSet::const_iterator i=p.facet_set->begin(); i!=p.facet_set->end(); ++i){
135  const QhullFacet f= *i;
136  if(f.getFacetT()==qh_MERGEridge){
137  os << " MERGE";
138  }else if(f.getFacetT()==qh_DUPLICATEridge){
139  os << " DUP";
140  }else if(p.facet_set->isSelectAll() || f.isGood()){
141  os << " f" << f.id();
142  }
143  }
144  os << endl;
145  return os;
146 }//<<QhullFacetSet::PrintIdentifiers
147 
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
bool contains(const Container &container, const T &value)
Equivalent to container.end() != std::find(container.begin(), container.end(), value) ...
Definition: algorithm.hh:66