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"
std::vector< QhullFacet > toStdVector() const
void selectGood()
operator==() does not depend on isGood()
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
q
void add_QhullFacetList_test()
A QhullFacet is the C++ equivalent to Qhull&#39;s facetT*.
Definition: QhullFacet.h:37
QhullFacet firstFacet() const
Definition: Qhull.h:108
PrintFacetList print(const char *message) const
QhullFacet previous() const
Definition: QhullFacet.h:85
QhullFacetList facetList() const
Definition: Qhull.cpp:186
countT count() const
Filtered by facet.isGood(). May be 0 when !isEmpty().
QhullFacet beginFacet() const
Definition: Qhull.h:102
bool contains(const QhullFacet &f) const
Interface to Qhull from C++.
Definition: Qhull.h:43
PrintVertices printVertices() const
std::vector< QhullVertex > vertices_toStdVector() const
Same as PrintVertices.
QhullFacet next() const
Definition: QhullFacet.h:81
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
void t_readonly()
Spot check properties and read-only. See QhullLinkedList_test.
QhullFacet endFacet() const
Definition: Qhull.h:105
bool isGood() const
Definition: QhullFacet.h:76


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:02