61 QCOMPARE(
q.dimension(),0);
63 QCOMPARE(QString(
q.qhullCommand()),QString(
""));
64 QCOMPARE(QString(
q.rboxCommand()),QString(
""));
66 QCOMPARE(
q.area(),0.0);
67 QFAIL(
"area() did not fail.");
68 }
catch (
const std::exception &e) {
69 cout <<
"INFO : Caught " << e.what();
75 QCOMPARE(
q.dimension(),3);
76 QVERIFY(
q.volume() < 1.0);
77 QVERIFY(
q.volume() > 0.99);
85 Qhull q(
"triangle", 2, 3, points,
"");
86 QCOMPARE(
q.dimension(),2);
87 QCOMPARE(
q.facetCount(),3);
88 QCOMPARE(
q.vertexCount(),3);
89 QCOMPARE(
q.dimension(),2);
90 QCOMPARE(
q.area(), 2.0+sqrt(2.0));
91 QCOMPARE(
q.volume(), 0.5);
108 feasible << 0.0 << 0.0;
109 q.setFeasiblePoint(feasible);
111 QVERIFY(
q.feasiblePoint()==
c);
112 q.setOutputStream(&cout);
113 q.runQhull(
"normals of square", 3, 4, normals,
"H");
114 QVERIFY(
q.feasiblePoint()==
c);
115 QCOMPARE(
q.facetList().count(), 4);
116 cout <<
"Expecting summary of halfspace intersection\n";
118 q.qh()->disableOutputStream();
119 cout <<
"Expecting no output from qh_fprintf() in Qhull.cpp\n";
131 QCOMPARE(
q.qhullMessage(),
string(
""));
133 QVERIFY(!
q.hasQhullMessage());
135 q.runQhull(rcube,
"Fd");
136 QFAIL(
"runQhull Fd did not fail.");
137 }
catch (
const std::exception &e) {
138 const char *s= e.what();
139 cout <<
"INFO : Caught " << s;
140 QCOMPARE(QString::fromStdString(s).left(6), QString(
"QH6029"));
142 QVERIFY(!
q.hasQhullMessage());
145 q.clearQhullMessage();
146 QVERIFY(!
q.hasQhullMessage());
148 q.appendQhullMessage(
"Append 1");
149 QVERIFY(
q.hasQhullMessage());
150 QCOMPARE(QString::fromStdString(
q.qhullMessage()), QString(
"Append 1"));
151 q.appendQhullMessage(
"\nAppend 2\n");
152 QCOMPARE(QString::fromStdString(
q.qhullMessage()), QString(
"Append 1\nAppend 2\n"));
153 q.clearQhullMessage();
154 QVERIFY(!
q.hasQhullMessage());
155 QCOMPARE(QString::fromStdString(
q.qhullMessage()), QString(
""));
158 cout <<
"INFO : Error stream without output stream\n";
160 q.setErrorStream(&cout);
161 q.setOutputStream(0);
163 q.runQhull(rcube,
"Fd");
164 QFAIL(
"runQhull Fd did not fail.");
166 cout <<
"INFO : Caught " << e;
167 QCOMPARE(e.errorCode(), 6029);
172 q.clearQhullMessage();
173 QVERIFY(!
q.hasQhullMessage());
176 cout <<
"INFO : Error output sent to output stream without error stream\n";
179 q.setOutputStream(&cout);
181 q.runQhull(rcube,
"Tz H0");
182 QFAIL(
"runQhull TZ did not fail.");
183 }
catch (
const std::exception &e) {
184 const char *s= e.what();
185 cout <<
"INFO : Caught " << s;
186 QCOMPARE(QString::fromLatin1(s).left(6), QString(
"QH6023"));
192 q.clearQhullMessage();
193 QVERIFY(!
q.hasQhullMessage());
196 cout <<
"INFO : No error stream or output stream\n";
199 q.setOutputStream(0);
201 q.runQhull(rcube,
"Fd");
202 QFAIL(
"outputQhull did not fail.");
203 }
catch (
const std::exception &e) {
204 const char *s= e.what();
205 cout <<
"INFO : Caught " << s;
206 QCOMPARE(QString::fromLatin1(s).left(6), QString(
"QH6029"));
212 q.clearQhullMessage();
213 QVERIFY(!
q.hasQhullMessage());
223 QVERIFY(!
q.initialized());
224 q.runQhull(rcube,
"s");
225 QVERIFY(
q.initialized());
226 QCOMPARE(
q.dimension(), 3);
229 QCOMPARE(p[0]+p[1]+p[2], 0.0);
230 q.setErrorStream(&cout);
235 q.runQhull(rcube,
"");
236 q.setOutputStream(&cout);
247 q.runQhull(rcube,
"s");
248 QCOMPARE(QString(
q.qhullCommand()), QString(
"qhull s"));
249 QCOMPARE(QString(
q.rboxCommand()), QString(
"rbox \"c\""));
250 QCOMPARE(
q.facetCount(), 6);
251 QCOMPARE(
q.vertexCount(), 8);
253 QCOMPARE(
q.qh()->ALLpoints, 0u);
254 QCOMPARE(
q.qh()->GOODpoint, 0);
255 QCOMPARE(
q.qh()->IStracing, 0);
256 QCOMPARE(
q.qh()->MAXcoplanar+1.0, 1.0);
257 QCOMPARE(
q.qh()->MERGING, 1u);
258 QCOMPARE(
q.qh()->input_dim, 3);
259 QCOMPARE(QString(
q.qh()->qhull_options).left(8), QString(
" run-id"));
260 QCOMPARE(
q.qh()->num_facets, 6);
261 QCOMPARE(
q.qh()->hasTriangulation, 0u);
262 QCOMPARE(
q.qh()->max_outside -
q.qh()->min_vertex + 1.0, 1.0);
263 QCOMPARE(*
q.qh()->gm_matrix+1.0, 1.0);
273 q.runQhull(rcube,
"");
274 QCOMPARE(
q.area(), 6.0);
275 QCOMPARE(
q.volume(), 1.0);
285 QCOMPARE(
q.beginFacet(),
q.endFacet());
286 QCOMPARE(
q.beginVertex(),
q.endVertex());
287 q.runQhull(rcube,
"");
288 QCOMPARE(
q.facetList().count(), 6);
293 QCOMPARE(facets.
count(), 6);
294 QCOMPARE(
q.firstFacet(),
q.beginFacet());
296 QCOMPARE(vertices.
count(), 8);
297 QCOMPARE(
q.firstVertex(),
q.beginVertex());
299 QCOMPARE(ps.
count(), 8);
301 QCOMPARE(ps2.
count(), 0);
303 QCOMPARE(
q.facetCount(), 6);
304 QCOMPARE(
q.vertexCount(), 8);
305 coordT *
c=
q.pointCoordinateBegin();
306 QVERIFY(*
c==0.5 || *
c==-0.5);
307 coordT *c3=
q.pointCoordinateEnd();
308 QVERIFY(c3[-1]==0.5 || c3[-1]==-0.5);
310 QCOMPARE(
q.vertexList().count(), 8);
320 q.setOutputStream(&cout);
321 cout <<
"Expecting vertexList and facetList of a 3-d diamond.\n";
323 cout <<
"Expecting normals of a 3-d diamond.\n";
332 cout <<
"FAIL! : Qhull called qh_exit(). Qhull's error handling not available.\n.. See the corresponding Qhull:qhull_message or setErrorStream().\n";
340 fprintf(stderr,
"QH%.4d ", msgcode);
355 QByteArray ba = s.c_str();
356 return qstrdup(ba.data());
360 #include "moc/Qhull_test.moc"