QhullVertexSet_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/QhullVertexSet_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 
15 #include "libqhullcpp/Qhull.h"
16 #include "libqhullcpp/QhullError.h"
17 #include "libqhullcpp/QhullFacet.h"
18 #include "libqhullcpp/RboxPoints.h"
19 
20 using std::cout;
21 using std::endl;
22 using std::ostringstream;
23 using std::ostream;
24 using std::string;
25 
26 namespace orgQhull {
27 
29 {
30  Q_OBJECT
31 
32 #
33 private slots:
34  void cleanup();
35  void t_construct();
36  void t_convert();
37  void t_readonly();
38  void t_foreach();
39  void t_io();
40 };//QhullVertexSet_test
41 
42 void
44 {
45  new QhullVertexSet_test(); // RoadTest::s_testcases
46 }
47 
48 //Executed after each testcase
51 {
53 }
54 
57 {
58  RboxPoints rcube("c");
59  Qhull q(rcube,"QR0"); // rotated unit cube
60  cout << "INFO : Cube rotated by QR" << q.rotateRandom() << std::endl;
61  QhullFacet f= q.firstFacet();
62  QhullVertexSet vs= f.vertices();
63  QVERIFY(!vs.isEmpty());
64  QCOMPARE(vs.count(),4);
65  QhullVertexSet vs4= vs; // copy constructor
66  QVERIFY(vs4==vs);
67  QhullVertexSet vs3(q, q.qh()->del_vertices);
68  QVERIFY(vs3.isEmpty());
69 }//t_construct
70 
73 {
74  RboxPoints rcube("c");
75  Qhull q(rcube,"QR0 QV2"); // rotated unit cube with "good" facets adjacent to point 0
76  cout << "INFO : Cube rotated by QR" << q.rotateRandom() << std::endl;
77  QhullFacet f= q.firstFacet();
78  QhullVertexSet vs2= f.vertices();
79  QCOMPARE(vs2.count(),4);
80  std::vector<QhullVertex> fv= vs2.toStdVector();
81  QCOMPARE(fv.size(), 4u);
82  QList<QhullVertex> fv2= vs2.toQList();
83  QCOMPARE(fv2.size(), 4);
84  std::vector<QhullVertex> fv3= vs2.toStdVector();
85  QCOMPARE(fv3.size(), 4u);
86  QList<QhullVertex> fv4= vs2.toQList();
87  QCOMPARE(fv4.size(), 4);
88 }//t_convert
89 
93 {
94  RboxPoints rcube("c");
95  Qhull q(rcube,"QV0"); // good facets are adjacent to point 0
97  QCOMPARE(vs.count(), 4);
98  QCOMPARE(vs.count(), 4);
99  QhullVertex v= vs.first();
100  QhullVertex v2= vs.last();
101  QVERIFY(vs.contains(v));
102  QVERIFY(vs.contains(v2));
103 }//t_readonly
104 
107 {
108  RboxPoints rcube("c");
109  // Spot check predicates and accessors. See QhullLinkedList_test
110  Qhull q(rcube,"QR0"); // rotated unit cube
111  cout << "INFO : Cube rotated by QR" << q.rotateRandom() << std::endl;
113  QVERIFY(vs.contains(vs.first()));
114  QVERIFY(vs.contains(vs.last()));
115  QCOMPARE(vs.first(), *vs.begin());
116  QCOMPARE(*(vs.end()-1), vs.last());
117 }//t_foreach
118 
121 {
122  RboxPoints rcube("c");
123  {
124  Qhull q(rcube,"QR0 QV0"); // good facets are adjacent to point 0
125  cout << "INFO : Cube rotated by QR" << q.rotateRandom() << std::endl;
127  ostringstream os;
128  os << vs.print("Vertices of first facet with point 0");
129  os << vs.printIdentifiers("\nVertex identifiers: ");
130  cout<< os.str();
131  QString vertices= QString::fromStdString(os.str());
132  QCOMPARE(vertices.count(QRegExp(" v[0-9]")), 4);
133  }
134 }//t_io
135 
136 #ifdef QHULL_USES_QT
137 QList<QhullVertex> QhullVertexSet::
138 toQList() const
139 {
141  QList<QhullVertex> vs;
142  while(i.hasNext()){
143  QhullVertex v= i.next();
144  vs.append(v);
145  }
146  return vs;
147 }//toQList
148 #endif //QHULL_USES_QT
149 
150 }//orgQhull
151 
152 #include "moc/QhullVertexSet_test.moc"
std::vector< QhullVertex > toStdVector() const
iterator begin()
Definition: QhullSet.h:177
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
q
bool isEmpty() const
Definition: QhullSet.h:70
A QhullFacet is the C++ equivalent to Qhull&#39;s facetT*.
Definition: QhullFacet.h:37
void t_readonly()
Spot check properties and read-only. See QhullSet_test.
Faster then interator/const_iterator due to T::base_type.
Definition: QhullSet.h:283
QhullFacet firstFacet() const
Definition: Qhull.h:108
QhullVertexSet vertices() const
Definition: QhullFacet.cpp:198
list v
Definition: obb.py:45
const T last() const
Definition: QhullSet.h:163
bool contains(const T &t) const
Definition: QhullSet.h:379
const PrintVertexSet print(const char *message) const
PrintIdentifiers printIdentifiers(const char *message) const
void add_QhullVertexSet_test()
Interface to Qhull from C++.
Definition: Qhull.h:43
int rotateRandom() const
Return QRn for repeating QR0 runs.
Definition: Qhull.h:84
iterator end()
Definition: QhullSet.h:181
QhullQh * qh() const
Definition: Qhull.h:81
setT * del_vertices
Definition: libqhull.h:763
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
const T first() const
Definition: QhullSet.h:157
countT count(const T &t) const
Definition: QhullSet.h:389


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