CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
QhullRidge.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/QhullRidge.cpp#1 $$Change: 1981 $
5 ** $DateTime: 2015/09/28 20:26:32 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #
10 
11 #include "QhullSets.h"
12 #include "QhullVertex.h"
13 #include "QhullRidge.h"
14 #include "Qhull.h"
15 
16 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
17 #pragma warning( disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
18 #pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
19 #endif
20 
21 namespace orgQhull {
22 
23 #
24 ridgeT QhullRidge::
25 s_empty_ridge= {0,0,0,0,0,
26  0,0};
27 
28 #
29 
30 QhullRidge::QhullRidge(const Qhull &q)
31 : qh_ridge(&s_empty_ridge)
32 , qh_qh(q.qh())
33 {
34 }//Default
35 
36 QhullRidge::QhullRidge(const Qhull &q, ridgeT *r)
37 : qh_ridge(r ? r : &s_empty_ridge)
38 , qh_qh(q.qh())
39 {
40 }//ridgeT
41 
42 #
43 
44 bool QhullRidge::
48 hasNextRidge3d(const QhullFacet &f) const
49 {
50  if(!qh_qh){
51  return false;
52  }
53  vertexT *v= 0;
54  // Does not call qh_errexit(), TRY_QHULL_ not needed
55  ridgeT *ridge= qh_nextridge3d(getRidgeT(), f.getFacetT(), &v);
56  return (ridge!=0);
57 }//hasNextRidge3d
58 
61 QhullRidge QhullRidge::
62 nextRidge3d(const QhullFacet &f, QhullVertex *nextVertex) const
63 {
64  vertexT *v= 0;
65  ridgeT *ridge= 0;
66  if(qh_qh){
67  // Does not call qh_errexit(), TRY_QHULL_ not needed
68  ridge= qh_nextridge3d(getRidgeT(), f.getFacetT(), &v);
69  if(!ridge){
70  throw QhullError(10030, "Qhull error nextRidge3d: missing next ridge for facet %d ridge %d. Does facet contain ridge?", f.id(), id());
71  }
72  }
73  if(nextVertex!=0){
74  *nextVertex= QhullVertex(qh_qh, v);
75  }
76  return QhullRidge(qh_qh, ridge);
77 }//nextRidge3d
78 
79 }//namespace orgQhull
80 
81 #
82 
83 using std::endl;
84 using std::ostream;
85 using orgQhull::QhullRidge;
86 using orgQhull::QhullVertex;
87 
88 ostream &
89 operator<<(ostream &os, const QhullRidge &r)
90 {
91  os << r.print("");
92  return os;
93 }//<< QhullRidge
94 
96 ostream &
97 operator<<(ostream &os, const QhullRidge::PrintRidge &pr)
98 {
99  if(*pr.print_message){
100  os << pr.print_message << " ";
101  }else{
102  os << " - ";
103  }
104  QhullRidge r= *pr.ridge;
105  os << "r" << r.id();
106  if(r.getRidgeT()->tested){
107  os << " tested";
108  }
109  if(r.getRidgeT()->nonconvex){
110  os << " nonconvex";
111  }
112  os << endl;
113  os << r.vertices().print(" vertices:");
114  if(r.getRidgeT()->top && r.getRidgeT()->bottom){
115  os << " between f" << r.topFacet().id() << " and f" << r.bottomFacet().id() << endl;
116  }else if(r.getRidgeT()->top){
117  os << " top f" << r.topFacet().id() << endl;
118  }else if(r.getRidgeT()->bottom){
119  os << " bottom f" << r.bottomFacet().id() << endl;
120  }
121 
122  return os;
123 }//<< PrintRidge
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