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
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
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, "");
142  ostringstream os;
143  os << "Vertex and vertices:\n";
144  os << v;
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, "");
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;
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"
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
q
int dimension() const
Definition: QhullVertex.h:72
void add_QhullVertex_test()
A QhullFacet is the C++ equivalent to Qhull&#39;s facetT*.
Definition: QhullFacet.h:37
QhullFacet firstFacet() const
Definition: Qhull.h:108
QhullFacetSet neighborFacets() const
Definition: QhullVertex.cpp:50
QhullVertexSet vertices() const
Definition: QhullFacet.cpp:198
QhullVertexList vertexList() const
Return vertices of the convex hull.
Definition: Qhull.cpp:204
void defineVertexNeighborFacets()
Automatically called if merging facets or Voronoi diagram.
Definition: Qhull.cpp:174
list v
Definition: obb.py:45
QhullVertex beginVertex() const
Definition: Qhull.h:103
bool contains(const T &t) const
Definition: QhullSet.h:379
countT vertexCount() const
Definition: Qhull.h:86
QhullPoint point() const
Definition: QhullVertex.h:82
countT id() const
Definition: QhullPoint.h:91
const PrintVertexSet print(const char *message) const
countT count() const
Filtered by facet.isGood(). May be 0 when !isEmpty().
Interface to Qhull from C++.
Definition: Qhull.h:43
bool isValid() const
Definition: QhullVertex.h:76
QhullVertex next() const
Definition: QhullVertex.h:79
q2
QhullVertex previous() const
Definition: QhullVertex.h:83
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
countT facetCount() const
Definition: Qhull.h:72
countT id() const
Definition: QhullVertex.h:75


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