Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #//! QhullFacetList -- Qhull's linked facets, as a C++ class
00010
00011 #include "QhullFacet.h"
00012 #include "QhullFacetList.h"
00013 #include "QhullPoint.h"
00014 #include "QhullRidge.h"
00015 #include "QhullVertex.h"
00016
00017 using std::string;
00018 using std::vector;
00019
00020 #ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
00021 #pragma warning( disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
00022 #pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
00023 #endif
00024
00025 namespace orgQhull {
00026
00027 #//Conversion
00028
00029
00030
00031 #ifndef QHULL_NO_STL
00032 std::vector<QhullFacet> QhullFacetList::
00033 toStdVector() const
00034 {
00035 QhullLinkedListIterator<QhullFacet> i(*this);
00036 std::vector<QhullFacet> vs;
00037 while(i.hasNext()){
00038 QhullFacet f= i.next();
00039 if(isSelectAll() || f.isGood()){
00040 vs.push_back(f);
00041 }
00042 }
00043 return vs;
00044 }
00045 #endif //QHULL_NO_STL
00046
00047 #ifndef QHULL_NO_STL
00048
00049 std::vector<QhullVertex> QhullFacetList::
00050 vertices_toStdVector(int qhRunId) const
00051 {
00052 std::vector<QhullVertex> vs;
00053 QhullVertexSet qvs(qhRunId, first().getFacetT(), NULL, isSelectAll());
00054
00055 for(QhullVertexSet::iterator i=qvs.begin(); i!=qvs.end(); ++i){
00056 vs.push_back(*i);
00057 }
00058 return vs;
00059 }
00060 #endif //QHULL_NO_STL
00061
00062 #//Read-only
00063
00064 bool QhullFacetList::
00065 contains(const QhullFacet &facet) const
00066 {
00067 if(isSelectAll()){
00068 return QhullLinkedList<QhullFacet>::contains(facet);
00069 }
00070 for(QhullFacetList::const_iterator i=begin(); i != end(); ++i){
00071 QhullFacet f= *i;
00072 if(f==facet && f.isGood()){
00073 return true;
00074 }
00075 }
00076 return false;
00077 }
00078
00079 int QhullFacetList::
00080 count() const
00081 {
00082 if(isSelectAll()){
00083 return QhullLinkedList<QhullFacet>::count();
00084 }
00085 int counter= 0;
00086 for(QhullFacetList::const_iterator i=begin(); i != end(); ++i){
00087 if((*i).isGood()){
00088 counter++;
00089 }
00090 }
00091 return counter;
00092 }
00093
00094 int QhullFacetList::
00095 count(const QhullFacet &facet) const
00096 {
00097 if(isSelectAll()){
00098 return QhullLinkedList<QhullFacet>::count(facet);
00099 }
00100 int counter= 0;
00101 for(QhullFacetList::const_iterator i=begin(); i != end(); ++i){
00102 QhullFacet f= *i;
00103 if(f==facet && f.isGood()){
00104 counter++;
00105 }
00106 }
00107 return counter;
00108 }
00109
00110 }
00111
00112 #//Global functions
00113
00114 using std::endl;
00115 using std::ostream;
00116 using orgQhull::QhullFacet;
00117 using orgQhull::QhullFacetList;
00118 using orgQhull::QhullVertex;
00119 using orgQhull::QhullVertexSet;
00120 using orgQhull::UsingLibQhull;
00121
00122 ostream &
00123 operator<<(ostream &os, const QhullFacetList::PrintFacetList &pr)
00124 {
00125 QhullFacetList fs= *pr.facet_list;
00126 os << "Vertices for " << fs.count() << " facets" << endl;
00127 os << fs.printVertices(pr.run_id);
00128 os << fs.printFacets(pr.run_id);
00129 return os;
00130 }
00131
00133 ostream &
00134 operator<<(ostream &os, const QhullFacetList::PrintFacets &pr)
00135 {
00136 for(QhullFacetList::const_iterator i= pr.facet_list->begin(); i != pr.facet_list->end(); ++i){
00137 QhullFacet f= *i;
00138 if(pr.facet_list->isSelectAll() || f.isGood()){
00139 os << f.print(pr.run_id);
00140 }
00141 }
00142 return os;
00143 }
00144
00147 ostream &
00148 operator<<(ostream &os, const QhullFacetList::PrintVertices &pr)
00149 {
00150 QhullVertexSet vs(pr.run_id, pr.facet_list->first().getFacetT(), NULL, pr.facet_list->isSelectAll());
00151 for(QhullVertexSet::iterator i=vs.begin(); i!=vs.end(); ++i){
00152 QhullVertex v= *i;
00153 os << v.print(pr.run_id);
00154 }
00155 return os;
00156 }
00157
00158 std::ostream &
00159 operator<<(ostream &os, const QhullFacetList &fs)
00160 {
00161 os << fs.printFacets(UsingLibQhull::NOqhRunId);
00162 return os;
00163 }
00164