QhullFacetList_test.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/qhulltest/QhullFacetList_test.cpp#3 $$Change: 2062 $
5 ** $DateTime: 2016/01/17 13:13:18 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 //pre-compiled headers
10 #include <iostream>
11 #include "qhulltest/RoadTest.h" // QT_VERSION
12 
14 #include "libqhullcpp/QhullError.h"
15 #include "libqhullcpp/QhullFacet.h"
18 #include "libqhullcpp/Qhull.h"
19 #include "libqhullcpp/RboxPoints.h"
20 
21 using std::cout;
22 using std::endl;
23 using std::ostringstream;
24 using std::ostream;
25 using std::string;
26 
27 namespace orgQhull {
28 
30 {
31  Q_OBJECT
32 
33 #
34 private slots:
35  void cleanup();
36  void t_construct_qh();
37  void t_construct_q();
38  void t_convert();
39  void t_readonly();
40  void t_foreach();
41  void t_io();
42 };//QhullFacetList_test
43 
44 void
46 {
47  new QhullFacetList_test(); // RoadTest::s_testcases
48 }
49 
50 //Executed after each testcase
53 {
55 }
56 
59 {
60  RboxPoints rcube("c");
61  Qhull q(rcube,"QR0"); // rotated unit cube
62  QhullFacetList fs2= q.facetList();
63  QVERIFY(!fs2.isEmpty());
64  QCOMPARE(fs2.count(),6);
65  QhullFacetList fs3(q.endFacet(), q.endFacet());
66  QVERIFY(fs3.isEmpty());
67  QhullFacetList fs4(q.endFacet().previous(), q.endFacet());
68  QCOMPARE(fs4.count(), 1);
69  QhullFacetList fs5(q.beginFacet(), q.endFacet());
70  QCOMPARE(fs2.count(), fs5.count());
71  QVERIFY(fs2==fs5);
72  QhullFacetList fs6= fs2; // copy constructor
73  QVERIFY(fs6==fs2);
74  std::vector<QhullFacet> fv= fs2.toStdVector();
75  QCOMPARE(fv.size(), 6u);
76 }//t_construct_qh
77 
80 {
81  RboxPoints rcube("c");
82  Qhull q(rcube,"QR0"); // rotated unit cube
83  QhullFacetList fs2= q.facetList();
84  QVERIFY(!fs2.isEmpty());
85  QCOMPARE(fs2.count(),6);
86  QhullFacetList fs3(q.endFacet(), q.endFacet());
87  QVERIFY(fs3.isEmpty());
88  QhullFacetList fs4(q.endFacet().previous(), q.endFacet());
89  QCOMPARE(fs4.count(), 1);
90  QhullFacetList fs5(q.beginFacet(), q.endFacet());
91  QCOMPARE(fs2.count(), fs5.count());
92  QVERIFY(fs2==fs5);
93  QhullFacetList fs6= fs2; // copy constructor
94  QVERIFY(fs6==fs2);
95  std::vector<QhullFacet> fv= fs2.toStdVector();
96  QCOMPARE(fv.size(), 6u);
97 }//t_construct_q
98 
101 {
102  RboxPoints rcube("c");
103  Qhull q(rcube,"QR0 QV2"); // rotated unit cube
104  QhullFacetList fs2= q.facetList();
105  QVERIFY(!fs2.isSelectAll());
106  QVERIFY(!fs2.isEmpty());
107  QCOMPARE(fs2.count(),3);
108  std::vector<QhullFacet> fv= fs2.toStdVector();
109  QCOMPARE(fv.size(), 3u);
110  QList<QhullFacet> fv2= fs2.toQList();
111  QCOMPARE(fv2.size(), 3);
112  std::vector<QhullVertex> fv5= fs2.vertices_toStdVector();
113  QCOMPARE(fv5.size(), 7u);
114  QList<QhullVertex> fv6= fs2.vertices_toQList();
115  QCOMPARE(fv6.size(), 7);
116  fs2.selectAll();
117  QVERIFY(fs2.isSelectAll());
118  std::vector<QhullFacet> fv3= fs2.toStdVector();
119  QCOMPARE(fv3.size(), 6u);
120  QList<QhullFacet> fv4= fs2.toQList();
121  QCOMPARE(fv4.size(), 6);
122  std::vector<QhullVertex> fv7= fs2.vertices_toStdVector();
123  QCOMPARE(fv7.size(), 8u);
124  QList<QhullVertex> fv8= fs2.vertices_toQList();
125  QCOMPARE(fv8.size(), 8);
126 }//t_convert
127 
131 {
132  RboxPoints rcube("c");
133  Qhull q(rcube,"QV0"); // good facets are adjacent to point 0
134  QhullFacetList fs= q.facetList();
135  QVERIFY(!fs.isSelectAll());
136  QCOMPARE(fs.count(), 3);
137  QCOMPARE(fs.first(), q.firstFacet());
138  fs.selectAll();
139  QVERIFY(fs.isSelectAll());
140  QCOMPARE(fs.count(), 6);
141  fs.selectGood();
142  QVERIFY(!fs.isSelectAll());
143  QCOMPARE(fs.count(), 3);
144  fs.selectAll();
145  QVERIFY(fs.isSelectAll());
146  QCOMPARE(fs.count(), 6);
147  QhullFacet f= fs.first();
148  QhullFacet f2= fs.last();
149  fs.selectAll();
150  QVERIFY(fs.contains(f));
151  QVERIFY(fs.contains(f2));
152  QVERIFY(f.isGood());
153  QVERIFY(!f2.isGood());
154  fs.selectGood();
155  QVERIFY(fs.contains(f));
156  QVERIFY(!fs.contains(f2));
157 }//t_readonly
158 
161 {
162  RboxPoints rcube("c");
163  // Spot check predicates and accessors. See QhullLinkedList_test
164  Qhull q(rcube,"Qt QR0"); // triangulation of rotated unit cube
165  QhullFacetList fs= q.facetList();
166  QVERIFY(fs.contains(q.firstFacet()));
167  QhullFacet f= q.firstFacet().next();
168  QVERIFY(fs.contains(f));
169  QCOMPARE(fs.first(), *fs.begin());
170  QCOMPARE(*(fs.end()-1), fs.last());
171  QCOMPARE(fs.first(), q.firstFacet());
172  QCOMPARE(*fs.begin(), q.beginFacet());
173  QCOMPARE(*fs.end(), q.endFacet());
174 }//t_foreach
175 
178 {
179  RboxPoints rcube("c");
180  {
181  Qhull q(rcube,"QR0 QV0"); // good facets are adjacent to point 0
182  QhullFacetList fs= q.facetList();
183  ostringstream os;
184  os << fs.print("Show all of FacetList\n");
185  os << "\nFacets only\n" << fs;
186  os << "\nVertices only\n" << fs.printVertices();
187  cout << os.str();
188  QString facets= QString::fromStdString(os.str());
189  QCOMPARE(facets.count("(v"), 2*7+12*3*2);
190  QCOMPARE(facets.count(QRegExp("f\\d")), 2*3*7 + 13*3*2);
191  }
192 }//t_io
193 
194 }//orgQhull
195 
196 #include "moc/QhullFacetList_test.moc"
QhullFacet.h
orgQhull::QhullLinkedList::end
iterator end()
Definition: QhullLinkedList.h:124
orgQhull
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
Qhull.h
QhullVertexSet.h
QhullFacetList.h
orgQhull::QhullFacetList_test::t_readonly
void t_readonly()
Spot check properties and read-only. See QhullLinkedList_test.
Definition: QhullFacetList_test.cpp:130
orgQhull::QhullFacetList::isSelectAll
bool isSelectAll() const
Definition: QhullFacetList.h:76
orgQhull::QhullFacetList
Definition: QhullFacetList.h:41
orgQhull::Qhull
Interface to Qhull from C++.
Definition: Qhull.h:49
orgQhull::QhullFacetList::print
PrintFacetList print(const char *message) const
Definition: QhullFacetList.h:88
orgQhull::QhullFacetList_test::t_construct_qh
void t_construct_qh()
Definition: QhullFacetList_test.cpp:58
orgQhull::QhullFacetList::toStdVector
std::vector< QhullFacet > toStdVector() const
Definition: QhullFacetList.cpp:43
orgQhull::QhullFacetList::printVertices
PrintVertices printVertices() const
Definition: QhullFacetList.h:100
orgQhull::QhullFacetList::selectAll
void selectAll()
Definition: QhullFacetList.h:78
q
q
orgQhull::QhullFacetList_test::t_foreach
void t_foreach()
Definition: QhullFacetList_test.cpp:160
orgQhull::QhullFacetList_test::t_io
void t_io()
Definition: QhullFacetList_test.cpp:177
orgQhull::QhullLinkedList::begin
iterator begin()
Definition: QhullLinkedList.h:120
orgQhull::QhullFacetList_test::cleanup
void cleanup()
Definition: QhullFacetList_test.cpp:52
orgQhull::add_QhullFacetList_test
void add_QhullFacetList_test()
Definition: QhullFacetList_test.cpp:45
orgQhull::QhullFacet::isGood
bool isGood() const
Definition: QhullFacet.h:82
orgQhull::RoadTest
Definition: RoadTest.h:54
orgQhull::QhullFacet
A QhullFacet is the C++ equivalent to Qhull's facetT*.
Definition: QhullFacet.h:43
orgQhull::RboxPoints
Definition: RboxPoints.h:37
orgQhull::QhullLinkedList::isEmpty
bool isEmpty() const
Definition: QhullLinkedList.h:97
orgQhull::QhullFacetList::contains
bool contains(const QhullFacet &f) const
Definition: QhullFacetList.cpp:75
orgQhull::QhullLinkedList::first
const T & first() const
Definition: QhullLinkedList.h:106
orgQhull::QhullFacetList::vertices_toStdVector
std::vector< QhullVertex > vertices_toStdVector() const
Same as PrintVertices.
Definition: QhullFacetList.cpp:60
orgQhull::QhullFacetList_test
Definition: QhullFacetList_test.cpp:29
RoadTest.h
orgQhull::QhullFacetList_test::t_construct_q
void t_construct_q()
Definition: QhullFacetList_test.cpp:79
orgQhull::QhullFacetList::count
countT count() const
Filtered by facet.isGood(). May be 0 when !isEmpty().
Definition: QhullFacetList.cpp:90
QhullVertex.h
orgQhull::QhullFacetList_test::t_convert
void t_convert()
Definition: QhullFacetList_test.cpp:100
RboxPoints.h
QhullError.h
orgQhull::QhullLinkedList::last
const T last() const
Definition: QhullLinkedList.h:110
orgQhull::RoadTest::cleanup
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38


hpp-fcl
Author(s):
autogenerated on Fri Aug 2 2024 02:45:14