QhullVertex_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/QhullVertex_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 "RoadTest.h" // QT_VERSION
12 
15 #include "libqhullcpp/QhullError.h"
16 #include "libqhullcpp/RboxPoints.h"
17 #include "libqhullcpp/QhullFacet.h"
20 #include "libqhullcpp/Qhull.h"
21 
22 using std::cout;
23 using std::endl;
24 using std::ostringstream;
25 using std::ostream;
26 using std::string;
27 
28 namespace orgQhull {
29 
30 class QhullVertex_test : public RoadTest
31 {
32  Q_OBJECT
33 
34 #
35 private slots:
36  void cleanup();
37  void t_constructConvert();
38  void t_getSet();
39  void t_foreach();
40  void t_io();
41 };//QhullVertex_test
42 
43 void
45 {
46  new QhullVertex_test(); // RoadTest::s_testcases
47 }
48 
49 //Executed after each testcase
52 {
54 }
55 
58 {
59  QhullVertex v6;
60  QVERIFY(!v6.isValid());
61  QCOMPARE(v6.dimension(),0);
62  // Qhull.runQhull() constructs QhullFacets as facetT
63  RboxPoints rcube("c");
64  Qhull q(rcube,"Qt QR0"); // triangulation of rotated unit cube
65  QhullVertex v(q);
66  QVERIFY(!v.isValid());
67  QCOMPARE(v.dimension(),3);
68  QhullVertex v2(q.beginVertex());
69  QCOMPARE(v2.dimension(),3);
70  v= v2; // copy assignment
71  QVERIFY(v.isValid());
72  QCOMPARE(v.dimension(),3);
73  QhullVertex v5= v2; // copy constructor
74  QVERIFY(v5==v2);
75  QVERIFY(v5==v);
76  QhullVertex v3(q, v2.getVertexT());
77  QCOMPARE(v,v3);
78  QhullVertex v4(q, v2.getBaseT());
79  QCOMPARE(v,v4);
80 }//t_constructConvert
81 
84 {
85  RboxPoints rcube("c");
86  {
87  Qhull q(rcube,"Qt QR0"); // triangulation of rotated unit cube
88  QCOMPARE(q.facetCount(), 12);
89  QCOMPARE(q.vertexCount(), 8);
90 
91  // Also spot-test QhullVertexList. See QhullLinkedList_test.cpp
92  QhullVertexList vs= q.vertexList();
94  while(i.hasNext()){
95  const QhullVertex v= i.next();
96  cout << v.id() << endl;
97  QCOMPARE(v.dimension(),3);
98  QVERIFY(v.id()>=0 && v.id()<9);
99  QVERIFY(v.isValid());
100  if(i.hasNext()){
101  QCOMPARE(v.next(), i.peekNext());
102  QVERIFY(v.next()!=v);
103  QVERIFY(v.next().previous()==v);
104  }
105  QVERIFY(i.hasPrevious());
106  QCOMPARE(v, i.peekPrevious());
107  }
108 
109  // test point()
110  foreach (QhullVertex v, q.vertexList()){ // Qt only
111  QhullPoint p= v.point();
112  int j= p.id();
113  cout << "Point " << j << ":\n" << p << endl;
114  QVERIFY(j>=0 && j<8);
115  }
116  }
117 }//t_getSet
118 
121 {
122  RboxPoints rcube("c W0 300"); // 300 points on surface of cube
123  {
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));
130  }
131  }
132  }
133 }//t_foreach
134 
137 {
138  RboxPoints rcube("c");
139  {
140  Qhull q(rcube, "");
141  QhullVertex v= q.beginVertex();
142  ostringstream os;
143  os << "Vertex and vertices:\n";
144  os << v;
145  QhullVertexSet vs= q.firstFacet().vertices();
146  os << vs;
147  os << "\nVertex and vertices with message:\n";
148  os << v.print("Vertex");
149  os << vs.print("\nVertices:");
150  cout << os.str();
151  QString s= QString::fromStdString(os.str());
152  QCOMPARE(s.count("(v"), 10);
153  QCOMPARE(s.count(": f"), 2);
154  }
155  RboxPoints r10("10 D3"); // Without QhullVertex::facetNeighbors
156  {
157  Qhull q(r10, "");
158  QhullVertex v= q.beginVertex();
159  ostringstream os;
160  os << "\nTry again with simplicial facets. No neighboring facets listed for vertices.\n";
161  os << "Vertex and vertices:\n";
162  os << v;
163  q.defineVertexNeighborFacets();
164  os << "This time with neighborFacets() defined for all vertices:\n";
165  os << v;
166  cout << os.str();
167  QString s= QString::fromStdString(os.str());
168  QCOMPARE(s.count(": f"), 1);
169 
170  Qhull q2(r10, "v"); // Voronoi diagram
171  QhullVertex v2= q2.beginVertex();
172  ostringstream os2;
173  os2 << "\nTry again with Voronoi diagram of simplicial facets. Neighboring facets automatically defined for vertices.\n";
174  os2 << "Vertex and vertices:\n";
175  os2 << v2;
176  cout << os2.str();
177  QString s2= QString::fromStdString(os2.str());
178  QCOMPARE(s2.count(": f"), 1);
179  }
180 }//t_io
181 
182 }//orgQhull
183 
184 #include "moc/QhullVertex_test.moc"
Coordinates.h
orgQhull::QhullFacetSet::count
countT count() const
Filtered by facet.isGood(). May be 0 when !isEmpty().
Definition: QhullFacetSet.cpp:67
QhullFacet.h
orgQhull::QhullVertex_test::cleanup
void cleanup()
Definition: QhullVertex_test.cpp:51
orgQhull::QhullVertexSet
Definition: QhullVertexSet.h:33
orgQhull::QhullPoint::id
countT id() const
Definition: QhullPoint.h:97
orgQhull::QhullVertex_test::t_getSet
void t_getSet()
Definition: QhullVertex_test.cpp:83
orgQhull::QhullLinkedListIterator::peekPrevious
T peekPrevious() const
Definition: QhullLinkedList.h:215
orgQhull::QhullFacetSet
Definition: QhullFacetSet.h:33
orgQhull
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
QhullFacetSet.h
orgQhull::QhullPoint
Definition: QhullPoint.h:39
Qhull.h
q2
q2
orgQhull::QhullVertex
Definition: QhullVertex.h:48
QhullVertexSet.h
orgQhull::add_QhullVertex_test
void add_QhullVertex_test()
Definition: QhullVertex_test.cpp:44
orgQhull::QhullLinkedListIterator::hasNext
bool hasNext() const
Definition: QhullLinkedList.h:211
orgQhull::QhullVertex_test::t_io
void t_io()
Definition: QhullVertex_test.cpp:136
orgQhull::QhullVertex::dimension
int dimension() const
Definition: QhullVertex.h:85
orgQhull::QhullVertex_test
Definition: QhullVertex_test.cpp:30
orgQhull::Qhull
Interface to Qhull from C++.
Definition: Qhull.h:49
orgQhull::QhullSet::contains
bool contains(const T &t) const
Definition: QhullSet.h:385
orgQhull::QhullLinkedListIterator::next
T next()
Definition: QhullLinkedList.h:213
orgQhull::QhullFacet::vertices
QhullVertexSet vertices() const
Definition: QhullFacet.cpp:198
q
q
orgQhull::RoadTest
Definition: RoadTest.h:54
orgQhull::QhullVertex::getVertexT
vertexT * getVertexT() const
Definition: QhullVertex.h:87
orgQhull::QhullFacet
A QhullFacet is the C++ equivalent to Qhull's facetT*.
Definition: QhullFacet.h:43
orgQhull::RboxPoints
Definition: RboxPoints.h:37
orgQhull::QhullVertex::isValid
bool isValid() const
Definition: QhullVertex.h:89
orgQhull::QhullLinkedListIterator::hasPrevious
bool hasPrevious() const
Definition: QhullLinkedList.h:212
orgQhull::QhullLinkedListIterator
Definition: QhullLinkedList.h:200
RoadTest.h
orgQhull::QhullLinkedList
Definition: QhullLinkedList.h:50
orgQhull::QhullLinkedListIterator::peekNext
T peekNext() const
Definition: QhullLinkedList.h:214
QhullVertex.h
RboxPoints.h
orgQhull::QhullVertex_test::t_constructConvert
void t_constructConvert()
Definition: QhullVertex_test.cpp:57
QhullError.h
orgQhull::RoadTest::cleanup
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
obb.v
list v
Definition: obb.py:48
orgQhull::QhullVertex_test::t_foreach
void t_foreach()
Definition: QhullVertex_test.cpp:120


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:59