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
96  QhullVertexSet vs= q.firstFacet().vertices();
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;
112  QhullVertexSet vs= q.firstFacet().vertices();
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;
126  QhullVertexSet vs= q.firstFacet().vertices();
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"
QhullFacet.h
orgQhull::QhullVertexSet
Definition: QhullVertexSet.h:33
orgQhull::QhullSet::first
const T first() const
Definition: QhullSet.h:163
orgQhull::QhullVertexSet_test::t_convert
void t_convert()
Definition: QhullVertexSet_test.cpp:72
orgQhull::QhullVertexSet::toStdVector
std::vector< QhullVertex > toStdVector() const
Definition: QhullVertexSet.cpp:108
orgQhull
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
Qhull.h
orgQhull::QhullVertex
Definition: QhullVertex.h:48
QhullVertexSet.h
orgQhull::QhullSetIterator
Faster then interator/const_iterator due to T::base_type.
Definition: QhullSet.h:289
orgQhull::QhullVertexSet::printIdentifiers
PrintIdentifiers printIdentifiers(const char *message) const
Definition: QhullVertexSet.h:80
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::QhullSet::isEmpty
bool isEmpty() const
Definition: QhullSet.h:76
orgQhull::QhullSet::count
countT count(const T &t) const
Definition: QhullSet.h:395
orgQhull::QhullVertexSet_test::t_foreach
void t_foreach()
Definition: QhullVertexSet_test.cpp:106
orgQhull::QhullVertexSet_test::t_io
void t_io()
Definition: QhullVertexSet_test.cpp:120
orgQhull::QhullFacet::vertices
QhullVertexSet vertices() const
Definition: QhullFacet.cpp:198
q
q
orgQhull::QhullSet::last
const T last() const
Definition: QhullSet.h:169
orgQhull::QhullVertexSet_test::t_readonly
void t_readonly()
Spot check properties and read-only. See QhullSet_test.
Definition: QhullVertexSet_test.cpp:92
orgQhull::RoadTest
Definition: RoadTest.h:54
orgQhull::QhullFacet
A QhullFacet is the C++ equivalent to Qhull's facetT*.
Definition: QhullFacet.h:43
orgQhull::RboxPoints
Definition: RboxPoints.h:37
orgQhull::QhullVertexSet_test::cleanup
void cleanup()
Definition: QhullVertexSet_test.cpp:50
orgQhull::QhullVertexSet::print
const PrintVertexSet print(const char *message) const
Definition: QhullVertexSet.h:73
RoadTest.h
orgQhull::QhullSet::begin
iterator begin()
Definition: QhullSet.h:183
QhullVertex.h
orgQhull::add_QhullVertexSet_test
void add_QhullVertexSet_test()
Definition: QhullVertexSet_test.cpp:43
orgQhull::QhullVertexSet_test::t_construct
void t_construct()
Definition: QhullVertexSet_test.cpp:56
RboxPoints.h
orgQhull::QhullVertexSet_test
Definition: QhullVertexSet_test.cpp:28
QhullError.h
orgQhull::RoadTest::cleanup
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
orgQhull::QhullSet::end
iterator end()
Definition: QhullSet.h:187
obb.v
list v
Definition: obb.py:48


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