mirror of https://github.com/CGAL/cgal
use MinMaxTuple as return value of minmax
This might slow things down. Signed-off-by: Panagiotis Cheilaris <philaris@cs.ntua.gr>
This commit is contained in:
parent
3e40227feb
commit
a3fa5a8716
|
|
@ -26,22 +26,27 @@ namespace CGAL {
|
||||||
typedef CGAL::cpp11::tuple<bool, bool, bool, bool, size_t>
|
typedef CGAL::cpp11::tuple<bool, bool, bool, bool, size_t>
|
||||||
SmallerEqTuple;
|
SmallerEqTuple;
|
||||||
|
|
||||||
|
template<typename E>
|
||||||
|
struct MinMaxTuple {
|
||||||
|
typedef CGAL::cpp11::tuple<E const *, E const *,
|
||||||
|
const bool, const bool, const bool> Type;
|
||||||
|
};
|
||||||
|
|
||||||
Compare_x_2 compare_x_2;
|
Compare_x_2 compare_x_2;
|
||||||
Compare_y_2 compare_y_2;
|
Compare_y_2 compare_y_2;
|
||||||
|
|
||||||
Orientation_Linf_2_Type orientation_Linf;
|
Orientation_Linf_2_Type orientation_Linf;
|
||||||
|
|
||||||
template <class Compare, typename E>
|
template <class Compare, typename E>
|
||||||
inline void minmax(
|
inline typename MinMaxTuple<E>::Type
|
||||||
const E &p, const E &q, const E &r,
|
minmax(const E &p, const E &q, const E &r) const
|
||||||
Point_2 const * & min_p, Point_2 const * & max_p,
|
|
||||||
bool & samepq, bool & samepr, bool & sameqr
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
Compare cmp;
|
Compare cmp;
|
||||||
samepq = false;
|
E const * min_p (NULL);
|
||||||
samepr = false;
|
E const * max_p (NULL);
|
||||||
sameqr = false;
|
bool samepq = false;
|
||||||
|
bool samepr = false;
|
||||||
|
bool sameqr = false;
|
||||||
const Comparison_result cmppq = cmp(p, q);
|
const Comparison_result cmppq = cmp(p, q);
|
||||||
switch(cmppq) {
|
switch(cmppq) {
|
||||||
case SMALLER:
|
case SMALLER:
|
||||||
|
|
@ -132,6 +137,8 @@ namespace CGAL {
|
||||||
CGAL_assertion(max_p != NULL);
|
CGAL_assertion(max_p != NULL);
|
||||||
CGAL_SDG_DEBUG(std::cout << "debug minmax cmppq=" << cmppq
|
CGAL_SDG_DEBUG(std::cout << "debug minmax cmppq=" << cmppq
|
||||||
<< " cmppr=" << cmppr << " cmpqr=" << cmpqr << std::endl; );
|
<< " cmppr=" << cmppr << " cmpqr=" << cmpqr << std::endl; );
|
||||||
|
return CGAL::cpp11::make_tuple(
|
||||||
|
min_p, max_p, samepq, samepr, sameqr);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SmallerEqTuple analyze_smalleq(
|
inline SmallerEqTuple analyze_smalleq(
|
||||||
|
|
@ -177,25 +184,25 @@ namespace CGAL {
|
||||||
|
|
||||||
CGAL_assertion(orientation_Linf(p,q,r) != DEGENERATE);
|
CGAL_assertion(orientation_Linf(p,q,r) != DEGENERATE);
|
||||||
|
|
||||||
|
typedef typename MinMaxTuple<Point_2>::Type PointMinMaxTuple;
|
||||||
|
|
||||||
//compute the minimum x and maximum x
|
//compute the minimum x and maximum x
|
||||||
Point_2 const * lft_p (NULL);
|
PointMinMaxTuple tupx = minmax<Compare_x_2>(p, q, r);
|
||||||
Point_2 const * rgt_p (NULL);
|
Point_2 const * lft_p = CGAL::cpp11::get<0>(tupx);
|
||||||
bool samex_pq (false);
|
Point_2 const * rgt_p = CGAL::cpp11::get<1>(tupx);
|
||||||
bool samex_pr (false);
|
const bool samex_pq = CGAL::cpp11::get<2>(tupx);
|
||||||
bool samex_qr (false);
|
const bool samex_pr = CGAL::cpp11::get<3>(tupx);
|
||||||
minmax<Compare_x_2>(p, q, r,
|
const bool samex_qr = CGAL::cpp11::get<4>(tupx);
|
||||||
lft_p, rgt_p, samex_pq, samex_pr, samex_qr);
|
|
||||||
CGAL_assertion(lft_p != NULL);
|
CGAL_assertion(lft_p != NULL);
|
||||||
CGAL_assertion(rgt_p != NULL);
|
CGAL_assertion(rgt_p != NULL);
|
||||||
|
|
||||||
//compute the minimum y and maximum y
|
//compute the minimum y and maximum y
|
||||||
Point_2 const * bot_p (NULL);
|
PointMinMaxTuple tupy = minmax<Compare_y_2>(p, q, r);
|
||||||
Point_2 const * top_p (NULL);
|
Point_2 const * bot_p = CGAL::cpp11::get<0>(tupy);
|
||||||
bool samey_pq (false);
|
Point_2 const * top_p = CGAL::cpp11::get<1>(tupy);
|
||||||
bool samey_pr (false);
|
const bool samey_pq = CGAL::cpp11::get<2>(tupy);
|
||||||
bool samey_qr (false);
|
const bool samey_pr = CGAL::cpp11::get<3>(tupy);
|
||||||
minmax<Compare_y_2>(p, q, r,
|
const bool samey_qr = CGAL::cpp11::get<4>(tupy);
|
||||||
bot_p, top_p, samey_pq, samey_pr, samey_qr);
|
|
||||||
CGAL_assertion(bot_p != NULL);
|
CGAL_assertion(bot_p != NULL);
|
||||||
CGAL_assertion(top_p != NULL);
|
CGAL_assertion(top_p != NULL);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue