1
/****************************************************************************
3
** Copyright (c) 2009-2012 C.B. Barber. All rights reserved.
4
** $Id: //main/2011/qhull/src/libqhullcpp/QhullPoint.cpp#4 $$Change: 1464 $
5
** $DateTime: 2012/01/25 22:58:41 $$Author: bbarber $
7
****************************************************************************/
9
#include "UsingLibQhull.h"
10
#include "QhullPoint.h"
15
#ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
20
#//Class public variables and methods
22
//! If qhRundID undefined uses QhullPoint::s_points_begin and dimension
24
id(int qhRunId, int dimension, const coordT *c)
26
QHULL_UNUSED(dimension);
28
if(UsingLibQhull::hasPoints()){
29
if(qhRunId==UsingLibQhull::NOqhRunId){
30
const coordT *pointsEnd;
32
const coordT *points= UsingLibQhull::globalPoints(&dim, &pointsEnd);
33
if(c>=points && c<pointsEnd){
34
int offset= (int)(c-points); // WARN64
38
UsingLibQhull q(qhRunId);
39
// NOerrors from qh_pointid or qh_setindex
40
return qh_pointid(const_cast<coordT *>(c));
43
long long i=(long long)c;
44
return (int)i; // WARN64
49
// See qt-qhull.cpp for QList conversion
52
std::vector<coordT> QhullPoint::
55
QhullPointIterator i(*this);
56
std::vector<coordT> vs;
58
vs.push_back(i.next());
67
operator==(const QhullPoint &other) const
69
if(point_dimension!=other.point_dimension){
72
const coordT *c= point_coordinates;
73
const coordT *c2= other.point_coordinates;
78
for(int k= point_dimension; k--; ){
79
double diff= *c++ - *c2++;
82
double epsilon= UsingLibQhull::globalDistanceEpsilon();
83
// std::cout << "DEBUG dist2 " << dist2 << " epsilon^2 " << epsilon*epsilon << std::endl;
84
return (dist2<=(epsilon*epsilon));
90
//! Return distance betweeen two points.
92
distance(const QhullPoint &p) const
94
const coordT *c= coordinates();
95
const coordT *c2= p.coordinates();
97
QHULL_ASSERT(dim==p.dimension());
102
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]);
105
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]);
108
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]);
111
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]);
114
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]) + (c[5]-c2[5])*(c[5]-c2[5]);
117
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]) + (c[5]-c2[5])*(c[5]-c2[5]) + (c[6]-c2[6])*(c[6]-c2[6]);
120
dist= (c[0]-c2[0])*(c[0]-c2[0]) + (c[1]-c2[1])*(c[1]-c2[1]) + (c[2]-c2[2])*(c[2]-c2[2]) + (c[3]-c2[3])*(c[3]-c2[3]) + (c[4]-c2[4])*(c[4]-c2[4]) + (c[5]-c2[5])*(c[5]-c2[5]) + (c[6]-c2[6])*(c[6]-c2[6]) + (c[7]-c2[7])*(c[7]-c2[7]);
124
for(int k=dim; k--; ){
125
dist += (*c - *c2) * (*c - *c2);
134
}//namespace orgQhull
139
using orgQhull::QhullPoint;
140
using orgQhull::UsingLibQhull;
145
operator<<(ostream &os, const QhullPoint &p)
147
os << p.printWithIdentifier(UsingLibQhull::NOqhRunId, "");
151
//! Same as qh_printpointid [io.c]
153
operator<<(ostream &os, const QhullPoint::PrintPoint &pr)
155
QhullPoint p= *pr.point;
156
int i= p.id(pr.run_id);
157
if(pr.point_message){
158
if(*pr.point_message){
159
os << pr.point_message << " ";
161
if(pr.with_identifier && (i!=-1)){
162
os << "p" << i << ": ";
165
const realT *c= p.coordinates();
166
for(int k=p.dimension(); k--; ){
168
if(pr.point_message){
169
os << " " << r; // FIXUP QH11010 %8.4g
171
os << " " << r; // FIXUP QH11010 qh_REAL_1