QhullRidge_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/QhullRidge_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 
13 #include "libqhullcpp/QhullRidge.h"
14 #include "libqhullcpp/QhullError.h"
15 #include "libqhullcpp/RboxPoints.h"
16 #include "libqhullcpp/QhullFacet.h"
17 #include "libqhullcpp/Qhull.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 
27 class QhullRidge_test : public RoadTest
28 {
29  Q_OBJECT
30 
31 #
32 private slots:
33  void cleanup();
34  void t_construct();
35  void t_getSet();
36  void t_foreach();
37  void t_io();
38 };//QhullRidge_test
39 
40 void
42 {
43  new QhullRidge_test(); // RoadTest::s_testcases
44 }
45 
46 //Executed after each testcase
49 {
51 }
52 
55 {
56  // Qhull.runQhull() constructs QhullFacets as facetT
57  RboxPoints rcube("c");
58  Qhull q(rcube,"QR0"); // triangulation of rotated unit cube
59  QhullRidge r(q);
60  QVERIFY(!r.isValid());
61  QCOMPARE(r.dimension(),2);
62  QhullFacet f(q.firstFacet());
63  QhullRidgeSet rs(f.ridges());
64  QVERIFY(!rs.isEmpty()); // Simplicial facets do not have ridges()
65  QhullRidge r2(rs.first());
66  QCOMPARE(r2.dimension(), 2); // One dimension lower than the facet
67  r= r2;
68  QVERIFY(r.isValid());
69  QCOMPARE(r.dimension(), 2);
70  QhullRidge r3(q, r2.getRidgeT());
71  QCOMPARE(r,r3);
72  QhullRidge r4(q, r2.getBaseT());
73  QCOMPARE(r,r4);
74  QhullRidge r5= r2; // copy constructor
75  QVERIFY(r5==r2);
76  QVERIFY(r5==r);
77 }//t_construct
78 
81 {
82  RboxPoints rcube("c");
83  {
84  Qhull q(rcube,"QR0"); // triangulation of rotated unit cube
85  QCOMPARE(q.facetCount(), 6);
86  QCOMPARE(q.vertexCount(), 8);
87  QhullFacet f(q.firstFacet());
88  QhullRidgeSet rs= f.ridges();
90  while(i.hasNext()){
91  const QhullRidge r= i.next();
92  cout << r.id() << endl;
93  QVERIFY(r.bottomFacet()!=r.topFacet());
94  QCOMPARE(r.dimension(), 2); // Ridge one-dimension less than facet
95  QVERIFY(r.id()>=0 && r.id()<9*27);
96  QVERIFY(r.isValid());
97  QVERIFY(r==r);
98  QVERIFY(r==i.peekPrevious());
99  QCOMPARE(r.otherFacet(r.bottomFacet()),r.topFacet());
100  QCOMPARE(r.otherFacet(r.topFacet()),r.bottomFacet());
101  }
102  }
103 }//t_getSet
104 
107 {
108  RboxPoints rcube("c"); // cube
109  {
110  Qhull q(rcube, "QR0"); // rotated cube
111  QhullFacet f(q.firstFacet());
112  foreach (const QhullRidge &r, f.ridges()){ // Qt only
113  QhullVertexSet vs= r.vertices();
114  QCOMPARE(vs.count(), 2);
115  foreach (const QhullVertex &v, vs){ // Qt only
116  QVERIFY(f.vertices().contains(v));
117  }
118  }
119  QhullRidgeSet rs= f.ridges();
120  QhullRidge r= rs.first();
121  QhullRidge r2= r;
122  QList<QhullVertex> vs;
123  int count= 0;
124  while(!count || r2!=r){
125  ++count;
126  QhullVertex v(q);
127  QVERIFY2(r2.hasNextRidge3d(f),"A cube should only have non-simplicial facets.");
128  QhullRidge r3= r2.nextRidge3d(f, &v);
129  QVERIFY(!vs.contains(v));
130  vs << v;
131  r2= r2.nextRidge3d(f);
132  QCOMPARE(r3, r2);
133  }
134  QCOMPARE(vs.count(), rs.count());
135  QCOMPARE(count, rs.count());
136  }
137 }//t_foreach
138 
141 {
142  RboxPoints rcube("c");
143  {
144  Qhull q(rcube, "");
145  QhullFacet f(q.firstFacet());
146  QhullRidgeSet rs= f.ridges();
147  QhullRidge r= rs.first();
148  ostringstream os;
149  os << "Ridges\n" << rs << "Ridge\n" << r;
150  os << r.print("\nRidge with message");
151  cout << os.str();
152  QString s= QString::fromStdString(os.str());
153  QCOMPARE(s.count(" r"), 6);
154  }
155 }//t_io
156 
157 }//orgQhull
158 
159 #include "moc/QhullRidge_test.moc"
orgQhull::QhullRidge_test::cleanup
void cleanup()
Definition: QhullRidge_test.cpp:48
QhullFacet.h
orgQhull::QhullVertexSet
Definition: QhullVertexSet.h:33
orgQhull::QhullSet::first
const T first() const
Definition: QhullSet.h:163
orgQhull::QhullRidge_test::t_io
void t_io()
Definition: QhullRidge_test.cpp:140
orgQhull::QhullRidge_test::t_construct
void t_construct()
Definition: QhullRidge_test.cpp:54
orgQhull
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
Definition: Coordinates.cpp:21
Qhull.h
orgQhull::QhullVertex
Definition: QhullVertex.h:48
orgQhull::add_QhullRidge_test
void add_QhullRidge_test()
Definition: QhullRidge_test.cpp:41
orgQhull::QhullSetIterator
Faster then interator/const_iterator due to T::base_type.
Definition: QhullSet.h:289
octree.r
r
Definition: octree.py:9
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
QhullRidge.h
orgQhull::QhullSet::count
countT count(const T &t) const
Definition: QhullSet.h:395
orgQhull::QhullRidge
Definition: QhullRidge.h:58
orgQhull::QhullSet
Definition: QhullSet.h:105
orgQhull::QhullFacet::vertices
QhullVertexSet vertices() const
Definition: QhullFacet.cpp:198
orgQhull::QhullRidge_test
Definition: QhullRidge_test.cpp:27
q
q
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::QhullRidge_test::t_getSet
void t_getSet()
Definition: QhullRidge_test.cpp:80
orgQhull::QhullFacet::ridges
QhullRidgeSet ridges() const
Definition: QhullFacet.cpp:192
RoadTest.h
orgQhull::QhullRidge_test::t_foreach
void t_foreach()
Definition: QhullRidge_test.cpp:106
r2
r2
orgQhull::QhullSetIterator::next
T next()
Definition: QhullSet.h:317
RboxPoints.h
QhullError.h
orgQhull::RoadTest::cleanup
void cleanup()
Executed after each test.
Definition: RoadTest.cpp:38
obb.v
list v
Definition: obb.py:48
orgQhull::QhullSetIterator::hasNext
bool hasNext() const
Definition: QhullSet.h:315
orgQhull::QhullSetIterator::peekPrevious
T peekPrevious() const
Definition: QhullSet.h:319


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