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
96  QhullFacetSet fs= q.firstFacet().neighborFacets();
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
123  QhullFacetSet fs= q.firstFacet().neighborFacets();
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
141  QhullFacetSet fs= q.firstFacet().neighborFacets();
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"
orgQhull::QhullFacetSet::count
countT count() const
Filtered by facet.isGood(). May be 0 when !isEmpty().
Definition: QhullFacetSet.cpp:67
QhullFacet.h
orgQhull::QhullSet::first
const T first() const
Definition: QhullSet.h:163
orgQhull::QhullFacetSet
Definition: QhullFacetSet.h:33
orgQhull
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
orgQhull::QhullFacetSet::contains
bool contains(const QhullFacet &f) const
Definition: QhullFacetSet.cpp:52
orgQhull::QhullFacetSet::print
const PrintFacetSet print(const char *message) const
Definition: QhullFacetSet.h:84
QhullFacetSet.h
orgQhull::QhullFacetSet_test::t_foreach
void t_foreach()
Definition: QhullFacetSet_test.cpp:118
Qhull.h
q2
q2
orgQhull::QhullFacetSet_test::t_readonly
void t_readonly()
Spot check properties and read-only. See QhullSet_test.
Definition: QhullFacetSet_test.cpp:92
orgQhull::QhullFacetSet_test::t_io
void t_io()
Definition: QhullFacetSet_test.cpp:136
orgQhull::QhullFacetSet::isSelectAll
bool isSelectAll() const
Definition: QhullFacetSet.h:71
orgQhull::QhullFacetSet::printIdentifiers
PrintIdentifiers printIdentifiers(const char *message) const
Definition: QhullFacetSet.h:91
orgQhull::Qhull
Interface to Qhull from C++.
Definition: Qhull.h:49
orgQhull::QhullSet::isEmpty
bool isEmpty() const
Definition: QhullSet.h:76
orgQhull::add_QhullFacetSet_test
void add_QhullFacetSet_test()
Definition: QhullFacetSet_test.cpp:42
orgQhull::QhullFacet::next
QhullFacet next() const
Definition: QhullFacet.h:87
orgQhull::QhullFacetSet::toStdVector
std::vector< QhullFacet > toStdVector() const
Definition: QhullFacetSet.cpp:35
q
q
orgQhull::QhullFacetSet_test::t_construct
void t_construct()
Definition: QhullFacetSet_test.cpp:55
orgQhull::QhullSet::last
const T last() const
Definition: QhullSet.h:169
orgQhull::QhullFacetSet_test::cleanup
void cleanup()
Definition: QhullFacetSet_test.cpp:49
orgQhull::QhullFacetSet_test::t_convert
void t_convert()
Definition: QhullFacetSet_test.cpp:70
orgQhull::QhullFacet::isGood
bool isGood() const
Definition: QhullFacet.h:82
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::QhullFacetSet_test
Definition: QhullFacetSet_test.cpp:27
orgQhull::QhullFacetSet::selectGood
void selectGood()
Definition: QhullFacetSet.h:74
RoadTest.h
orgQhull::QhullFacetSet::selectAll
void selectAll()
operator==() does not depend on isGood()
Definition: QhullFacetSet.h:73
orgQhull::QhullSet::begin
iterator begin()
Definition: QhullSet.h:183
RboxPoints.h
QhullError.h
orgQhull::QhullFacet::neighborFacets
QhullFacetSet neighborFacets() const
Definition: QhullFacet.cpp:180
orgQhull::RoadTest::cleanup
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
orgQhull::QhullSet::end
iterator end()
Definition: QhullSet.h:187


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