1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../road-faq/xsl/road-faq.xsl"?>
<rf:topic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.roadintranet.org/road-faq-1 /road/road-faq/xsl/road-faq.xsd"
xmlns:rf="http://schemas.roadintranet.org/road-faq-1"
title=" C++ interface to Qhull"
file="qhull-cpp.xml"
fileid="$Id: //main/2019/qhull/html/qhull-cpp.xml#2 $$Change: 2954 $"
fileChange="$DateTime: 2020/05/21 22:30:09 $$Author: bbarber $">
<div><h4>Qhull C++ -- C++ interface to Qhull</h4></div>
<rf:copyright>
<a href="../cpp/COPYING.txt">Copyright</a> (c) 2009-2020, C.B. Barber
</rf:copyright>
<rf:section id="cpp-cpp-links" title="Useful Links for Qhull C++">
<div>
<p> This draft
document records some of the design decisions for Qhull C++. Convert it to HTML by road-faq.xsl from <a href="http://www.qhull.org/road/road-faq/road-faq.html">road-faq</a>.
Please send comments and suggestions to <a
href="mailto:bradb@shore.net">bradb@shore.net</a>
</p>
</div>
<div class="twocol">
<div class="col leftcol">
Help
<ul><li>
</li><li>
</li><li>
</li></ul>
</div>
<div class="col rightcol">
<ul><li>
</li><li>
</li></ul>
</div>
</div>
<div>
. <!-- clear the two column display -->
</div>
</rf:section>
<rf:section id="qhull-api" title="Qhull's collection classes">
<rf:item id="collection-api" title="API for Qhull collections" date="Feb 2009" author="bbarber">
Qhull's collection APIs are modeled on Qt's collection API (QList, QVector, QHash) w/o QT_STRICT_ITERATORS. They support STL and Qt programming.
<p>Some of Qhull's collection classes derive from STL classes. If so,
please avoid additional STL functions and operators added by inheritance.
These collection classes may be rewritten to derive from Qt classes instead.
See Road's <rf:iref item="cpp-collection-api"/>.
</p>
Qhull's collection API (where applicable). For documentation, see Qt's QList, QMap, QListIterator, QMapIterator, QMutableListIterator, and QMutableMapIterator
<ul><li>
STL types [list, qlinkedlist, qlist, qvector, vector] -- const_iterator, iterator
</li><li>
STL types describing iterators [list, qlinkedlist, qlist, qvector, vector] -- const_pointer, const_reference, difference_type,
pointer, reference, size_type, value_type.
Pointer and reference types not defined if unavailable (not needed for <algorithm>)
</li><li>
const_iterator, iterator types -- difference_type, iterator_category, pointer, reference, value_type
</li><li>
Qt types [qlinkedlist, qlist, qvector] -- ConstIterator, Iterator, QhullclassIterator, MutableQhullclassIterator.
Qt's foreach requires const_iterator.
</li><li>
Types for sets/maps [hash_map, QHash] -- key_compare, key_type, mapped_type
</li><li>
Constructor -- default constructor, copy constructor, assignment operator, destructor
</li><li>
Conversion -- to/from/as corresponding C, STL, and Qt constructs. Include toQList and toStdVector (may be filtered, e.g., QhullFacetSet).
Do not define fromStdList and fromQList if container is not reference counted (i.e., acts like a value)
</li><li>
Get/set -- configuration options for class
</li><li>
STL-style iterator - begin, constBegin, constEnd, end, key, value, =, *, [], ->, ++, --, +, -, ==, !=, <,
<=, >, >=, const_iterator(iterator), iterator COMPARE const_iterator.
An iterator is an abstraction of a pointer. It is not aware of its container.
</li><li>
Java-style iterator [qiterator.h] - countRemaining, findNext, findPrevious, hasNext, hasPrevious, next, peekNext, peekPrevious, previous, toBack, toFront, = Coordinates
</li><li>
Mutable Java-style iterator adds - insert, remove, setValue, value
</li><li>
Element access -- back, first, front, last
</li><li>
Element access w/ index -- [], at (const& only), constData, data, mid, value
</li><li>
Read-only - (int)count, empty, isEmpty, (size_t)size. Count() and size() may be filtered. If so, they may be zero when !empty().
</li><li>
Read-only for sets/maps - capacity, key, keys, reserve, resize, values
</li><li>
Operator - ==, !=, +, +=, <<
</li><li>
Read-write -- append, clear, erase, insert, move, prepend, pop_back, pop_front, push_back, push_front, removeAll, removeAt, removeFirst, removeLast, replace,
swap, takeAt, takeFirst, takeLast
</li><li>
Read-write for sets/maps -- insertMulti, squeeze, take, unite
</li><li>
Search -- contains(const T &), count(const T &), indexOf, lastIndexOf
</li><li>
Search for sets/maps -- constFind, lowerBound, upperBound
</li><li>
Stream I/O -- stream <<
</li></ul>
STL list and vector -- For unfiltered access to each element.
<ul><li>
<a href="http://stdcxx.apache.org/doc/stdlibug/16-3.html">Apache: Creating your own containers</a> -- requirements for STL containers. Iterators should define the types from 'iterator_traits'.
</li><li>
STL types -- allocator_type, const_iterator, const_pointer, const_reference, const_reverse_iterator, difference_type, iterator, iterator_category, pointer, reference, reverse_iterator, size_type, value_type
</li><li>
STL constructors -- MyType(), MyType(count), MyType(count, value), MyType(first, last),
MyType(MyType&),
</li><li>
STL getter/setters -- at (random_access only), back, begin, capacity, end, front, rbegin, rend, size, max_size
</li><li>
STL predicates -- empty
</li><li>
STL iterator types -- const_pointer, const_reference, difference_type, iterator_category, pointer, reference, value_type
</li><li>
STL iterator operators -- *, -<, ++, --, +=, -=, +, -, [], ==, !=, <, >, >=, <=
</li><li>
STL operators -- =, [] (random_access only), ==, !=, <, >, <=, >=
</li><li>
STL modifiers -- assign, clear, erase, insert, pop_back, push_back, reserve, resize, swap
</li><li>
</li></ul>
Qt Qlist -- For unfiltered access to each element
<ul><li>
</li><li>
Additional Qt types -- ConstIterator, Iterator, QListIterator, QMutableListIterator
</li><li>
Additional Qt get/set -- constBegin, constEnd, count, first, last, value (random_access only)
</li><li>
Additional Qt predicates -- isEmpty
</li><li>
Additional Qt -- mid (random_access only)
</li><li>
Additional Qt search -- contains, count(T&), indexOf (random_access only), lastIndeOf (random_access only)
</li><li>
Additional Qt modifiers -- append, insert(index,value) (random_access only), move (random_access only), pop_front, prepend, push_front, removeAll, removeAt (random_access only), removeFirst, removeLast, replace, swap by index, takeAt, takeFirst, takeLast
</li><li>
Additional Qt operators -- +, <<, +=,
stream << and >>
</li><li>
Unsupported types by Qt -- allocator_type, const_reverse_iterator, reverse_iterator
</li><li>
Unsupported accessors by Qt -- max_size, rbegin, rend
</li><li>
Unsupported constructors by Qt -- multi-value constructors
</li><li>
unsupported modifiers by Qt -- assign, muli-value inserts, STL's swaps
</li><li>
</li></ul>
STL map and Qt QMap. These use nearly the same API as list and vector classes. They add the following.
<ul><li>
STL types -- key_compare, key_type, mapped_type
</li><li>
STL search -- equal_range, find, lower_bound, upper_bound
</li><li>
Qt removes -- equal_range, key_compare
</li><li>
Qt renames -- lowerBound, upperBound
</li><li>
Qt adds -- constFind, insertMulti, key, keys, take, uniqueKeys, unite, values
</li><li>
Not applicable to map and QMap -- at, back, pop_back, pop_front, push_back, push_front, swap
</li><li>
Not applicable to QMap -- append, first, last, lastIndexOf, mid, move, prepend, removeAll, removeAt, removeFirst, removeLast, replace, squeeze, takeAt, takeFirst, takeLast
</li><li>
Not applicable to map -- assign
</li></ul>
Qt QHash. STL extensions provide similar classes, e.g., Microsoft's stdext::hash_set. THey are nearly the same as QMap
<ul><li>
</li><li>
</li><li>
Not applicable to Qhash -- lowerBound, unite, upperBound,
</li><li>
Qt adds -- squeeze
</li></ul>
</rf:item>
<rf:item id="class-api" title="API for Qhull collections" date="Feb 2009" author="bbarber">
<ul><li>
check... -- Throw error on failure
</li><li>
try... -- Return false on failure. Do not throw errors.
</li><li>
...Temporarily -- lifetime depends on source. e.g., toByteArrayTemporarily
</li><li>
...p -- indicates pointer-to.
</li><li>
end... -- points to one beyond the last available
</li><li>
private functions -- No syntactic indication. They may become public later on.
</li><li>
Error messages -- Preceed error messages with the name of the class throwing the error (e.g. "ClassName: ..."). If this is an internal error, use "ClassName inconsistent: ..."
</li><li>
parameter order -- qhRunId, dimension, coordinates, count.
</li><li>
toClass -- Convert into a Class object (makes a deep copy)
</li><li>
qRunId -- Requires Qh installed. Some routines allow 0 for limited info (e.g., operator<<)
</li><li>
Disable methods in derived classes -- If the default constructor, copy constructor, or copy assignment is disabled, it should be also disabled in derived classes (better error messages).
</li><li>
Constructor order -- default constructor, other constructors, copy constructor, copy assignment, destructor
</li></ul>
</rf:item>
</rf:section>
</rf:topic>
|