1
/****************************************************************************
3
** Copyright (c) 2008-2012 C.B. Barber. All rights reserved.
4
** $Id: //main/2011/qhull/src/qhulltest/QhullVertex_test.cpp#6 $$Change: 1490 $
5
** $DateTime: 2012/02/19 20:27:01 $$Author: bbarber $
7
****************************************************************************/
12
#include "QhullVertex.h"
13
#include "Coordinates.h"
14
#include "QhullError.h"
15
#include "RboxPoints.h"
16
#include "QhullFacet.h"
17
#include "QhullFacetSet.h"
18
#include "QhullVertexSet.h"
23
using std::ostringstream;
29
class QhullVertex_test : public RoadTest
36
void t_constructConvert();
43
add_QhullVertex_test()
45
new QhullVertex_test();
48
//Executed after each testcase
49
void QhullVertex_test::
52
UsingLibQhull::checkQhullMemoryEmpty();
56
void QhullVertex_test::
59
// Qhull.runQhull() constructs QhullFacets as facetT
61
QVERIFY(!v.isDefined());
62
QCOMPARE(v.dimension(),0);
63
RboxPoints rcube("c");
64
Qhull q(rcube,"Qt QR0"); // triangulation of rotated unit cube
65
QhullVertex v2(q.beginVertex());
66
QCOMPARE(v2.dimension(),3);
67
v= v2; // copy assignment
68
QVERIFY(v.isDefined());
69
QCOMPARE(v.dimension(),3);
70
QhullVertex v5= v2; // copy constructor
73
QhullVertex v3= v2.getVertexT();
75
QhullVertex v4= v2.getBaseT();
79
void QhullVertex_test::
82
RboxPoints rcube("c");
84
Qhull q(rcube,"Qt QR0"); // triangulation of rotated unit cube
85
QCOMPARE(q.facetCount(), 12);
86
QCOMPARE(q.vertexCount(), 8);
88
// Also spot-test QhullVertexList. See QhullLinkedList_test.cpp
89
QhullVertexList vs= q.vertexList();
90
QhullVertexListIterator i(vs);
92
const QhullVertex v= i.next();
93
cout << v.id() << endl;
94
QCOMPARE(v.dimension(),3);
95
QVERIFY(v.id()>=0 && v.id()<9);
96
QVERIFY(v.isDefined());
98
QCOMPARE(v.next(), i.peekNext());
100
QVERIFY(v.next().previous()==v);
102
QVERIFY(i.hasPrevious());
103
QCOMPARE(v, i.peekPrevious());
105
QhullVertexListIterator i2(i);
106
QEXPECT_FAIL("", "ListIterator copy constructor not reset to BOT", Continue);
107
QVERIFY(!i2.hasPrevious());
110
foreach (QhullVertex v, q.vertexList()){ // Qt only
111
QhullPoint p= v.point();
112
int j= p.id(q.runId());
113
cout << "Point " << j << ":\n" << p.print(q.runId()) << endl;
114
QVERIFY(j>=0 && j<8);
119
void QhullVertex_test::
122
RboxPoints rcube("c W0 300"); // 300 points on surface of cube
124
Qhull q(rcube, "QR0 Qc"); // keep coplanars, thick facet, and rotate the cube
125
foreach (QhullVertex v, q.vertexList()){ // Qt only
126
QhullFacetSet fs= v.neighborFacets();
127
QCOMPARE(fs.count(), 3);
128
foreach (QhullFacet f, fs){ // Qt only
129
QVERIFY(f.vertices().contains(v));
135
void QhullVertex_test::
138
RboxPoints rcube("c");
141
QhullVertex v= q.beginVertex();
143
os << "Vertex and vertices w/o runId:\n";
145
QhullVertexSet vs= q.firstFacet().vertices();
147
os << "Vertex and vertices w/ runId:\n";
148
os << v.print(q.runId());
149
os << vs.print(q.runId(), "vertices:");
151
QString s= QString::fromStdString(os.str());
152
QCOMPARE(s.count("(v"), 10);
153
QCOMPARE(s.count(": f"), 2);
155
RboxPoints r10("10 D3"); // Without QhullVertex::facetNeighbors
158
QhullVertex v= q.beginVertex();
160
os << "\nTry again with simplicial facets. No neighboring facets listed for vertices.\n";
161
os << "Vertex and vertices w/o runId:\n";
163
q.defineVertexNeighborFacets();
164
os << "This time with neighborFacets() defined for all vertices:\n";
167
QString s= QString::fromStdString(os.str());
168
QCOMPARE(s.count(": f"), 1);
170
Qhull q2(r10, "v"); // Voronoi diagram
171
QhullVertex v2= q2.beginVertex();
173
os2 << "\nTry again with Voronoi diagram of simplicial facets. Neighboring facets automatically defined for vertices.\n";
174
os2 << "Vertex and vertices w/o runId:\n";
177
QString s2= QString::fromStdString(os2.str());
178
QCOMPARE(s2.count(": f"), 1);
184
#include "moc/QhullVertex_test.moc"