QhullFacetSet_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/QhullFacetSet_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 
14 #include "libqhullcpp/QhullError.h"
15 #include "libqhullcpp/QhullFacet.h"
16 #include "libqhullcpp/Qhull.h"
17 #include "libqhullcpp/RboxPoints.h"
18 
19 using std::cout;
20 using std::endl;
21 using std::ostringstream;
22 using std::ostream;
23 using std::string;
24 
25 namespace orgQhull {
26 
28 {
29  Q_OBJECT
30 
31 #
32 private slots:
33  void cleanup();
34  void t_construct();
35  void t_convert();
36  void t_readonly();
37  void t_foreach();
38  void t_io();
39 };//QhullFacetSet_test
40 
41 void
43 {
44  new QhullFacetSet_test(); // RoadTest::s_testcases
45 }
46 
47 //Executed after each testcase
50 {
52 }
53 
56 {
57  RboxPoints rcube("c");
58  Qhull q(rcube,"QR0"); // rotated unit cube
59  QhullFacet f= q.firstFacet();
61  QVERIFY(!fs2.isEmpty());
62  QCOMPARE(fs2.count(),4);
63  QhullFacetSet fs4= fs2; // copy constructor
64  QVERIFY(fs4==fs2);
65  QhullFacetSet fs3(q, q.qh()->facet_mergeset);
66  QVERIFY(fs3.isEmpty());
67 }//t_construct
68 
71 {
72  RboxPoints rcube("c");
73  Qhull q2(rcube,"QR0 QV2"); // rotated unit cube
74  QhullFacet f2= q2.firstFacet();
75  QhullFacetSet fs2= f2.neighborFacets();
76  QVERIFY(!fs2.isSelectAll());
77  QCOMPARE(fs2.count(),2);
78  std::vector<QhullFacet> fv= fs2.toStdVector();
79  QCOMPARE(fv.size(), 2u);
80  QList<QhullFacet> fv2= fs2.toQList();
81  QCOMPARE(fv2.size(), 2);
82  fs2.selectAll();
83  QVERIFY(fs2.isSelectAll());
84  std::vector<QhullFacet> fv3= fs2.toStdVector();
85  QCOMPARE(fv3.size(), 4u);
86  QList<QhullFacet> fv4= fs2.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  QVERIFY(!fs.isSelectAll());
98  QCOMPARE(fs.count(), 2);
99  fs.selectAll();
100  QVERIFY(fs.isSelectAll());
101  QCOMPARE(fs.count(), 4);
102  fs.selectGood();
103  QVERIFY(!fs.isSelectAll());
104  QCOMPARE(fs.count(), 2);
105  QhullFacet f= fs.first();
106  QhullFacet f2= fs.last();
107  fs.selectAll();
108  QVERIFY(fs.contains(f));
109  QVERIFY(fs.contains(f2));
110  QVERIFY(f.isGood());
111  QVERIFY(!f2.isGood());
112  fs.selectGood();
113  QVERIFY(fs.contains(f));
114  QVERIFY(!fs.contains(f2));
115 }//t_readonly
116 
119 {
120  RboxPoints rcube("c");
121  // Spot check predicates and accessors. See QhullLinkedList_test
122  Qhull q(rcube,"QR0"); // rotated unit cube
124  QVERIFY(!fs.contains(q.firstFacet()));
125  QVERIFY(fs.contains(fs.first()));
126  QhullFacet f= q.firstFacet().next();
127  if(!fs.contains(f)){ // check if 'f' is the facet opposite firstFacet()
128  f= f.next();
129  }
130  QVERIFY(fs.contains(f));
131  QCOMPARE(fs.first(), *fs.begin());
132  QCOMPARE(*(fs.end()-1), fs.last());
133 }//t_foreach
134 
137 {
138  RboxPoints rcube("c");
139  {
140  Qhull q(rcube,"QR0 QV0"); // good facets are adjacent to point 0
142  ostringstream os;
143  os << fs.print("Neighbors of first facet with point 0");
144  os << fs.printIdentifiers("\nFacet identifiers: ");
145  cout << os.str();
146  QString facets= QString::fromStdString(os.str());
147  QCOMPARE(facets.count(QRegExp(" f[0-9]")), 2+13*2);
148  }
149 }//t_io
150 
151 }//orgQhull
152 
153 #include "moc/QhullFacetSet_test.moc"
iterator begin()
Definition: QhullSet.h:177
QhullRidge – Qhull&#39;s ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
q
setT * facet_mergeset
Definition: libqhull.h:758
bool isEmpty() const
Definition: QhullSet.h:70
A QhullFacet is the C++ equivalent to Qhull&#39;s facetT*.
Definition: QhullFacet.h:37
QhullFacet firstFacet() const
Definition: Qhull.h:108
void add_QhullFacetSet_test()
const T last() const
Definition: QhullSet.h:163
bool contains(const QhullFacet &f) const
countT count() const
Filtered by facet.isGood(). May be 0 when !isEmpty().
QhullFacetSet neighborFacets() const
Definition: QhullFacet.cpp:180
Interface to Qhull from C++.
Definition: Qhull.h:43
iterator end()
Definition: QhullSet.h:181
QhullQh * qh() const
Definition: Qhull.h:81
PrintIdentifiers printIdentifiers(const char *message) const
Definition: QhullFacetSet.h:85
q2
void selectAll()
operator==() does not depend on isGood()
Definition: QhullFacetSet.h:67
void t_readonly()
Spot check properties and read-only. See QhullSet_test.
QhullFacet next() const
Definition: QhullFacet.h:81
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
const T first() const
Definition: QhullSet.h:157
bool isSelectAll() const
Definition: QhullFacetSet.h:65
const PrintFacetSet print(const char *message) const
Definition: QhullFacetSet.h:78
bool isGood() const
Definition: QhullFacet.h:76
std::vector< QhullFacet > toStdVector() const


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