| 63 | 
  | 
using namespace OpenMD; | 
| 64 | 
  | 
using namespace std; | 
| 65 | 
  | 
 | 
| 66 | 
< | 
ConvexHull::ConvexHull() : Hull(), dim_(3), options_("qhull Qt Pp") { | 
| 66 | 
> | 
ConvexHull::ConvexHull() : Hull(), dim_(3), options_("qhull FA Qt Pp") { | 
| 67 | 
  | 
} | 
| 68 | 
  | 
 | 
| 69 | 
  | 
void ConvexHull::computeHull(vector<StuntDouble*> bodydoubles) {  | 
| 77 | 
  | 
  setT *vertices; | 
| 78 | 
  | 
  int curlong, totlong; | 
| 79 | 
  | 
 | 
| 80 | 
– | 
  Vector3d boxMax; | 
| 81 | 
– | 
  Vector3d boxMin; | 
| 82 | 
– | 
   | 
| 80 | 
  | 
  vector<double> ptArray(numpoints*dim_); | 
| 81 | 
  | 
 | 
| 82 | 
  | 
  // Copy the positon vector into a points vector for qhull. | 
| 83 | 
  | 
  vector<StuntDouble*>::iterator SD; | 
| 84 | 
  | 
  int i = 0; | 
| 85 | 
< | 
   | 
| 85 | 
> | 
  | 
| 86 | 
  | 
  for (SD =bodydoubles.begin(); SD != bodydoubles.end(); ++SD){ | 
| 87 | 
  | 
    Vector3d pos = (*SD)->getPos();       | 
| 88 | 
  | 
    ptArray[dim_ * i] = pos.x(); | 
| 204 | 
  | 
  // commented out below, so comment out here also. | 
| 205 | 
  | 
  // intPoint = qh interior_point; | 
| 206 | 
  | 
  // RealType calcvol = 0.0; | 
| 207 | 
+ | 
   | 
| 208 | 
+ | 
  qh_triangulate (); | 
| 209 | 
+ | 
  int num_facets = qh num_facets; | 
| 210 | 
+ | 
  int num_vertices = qh num_vertices; | 
| 211 | 
+ | 
 | 
| 212 | 
  | 
  FORALLfacets {   | 
| 213 | 
  | 
    Triangle face; | 
| 214 | 
  | 
    //Qhull sets the unit normal in facet->normal | 
| 285 | 
  | 
  qh_getarea(qh facet_list); | 
| 286 | 
  | 
  volume_ = qh totvol; | 
| 287 | 
  | 
  area_ = qh totarea; | 
| 286 | 
– | 
 | 
| 287 | 
– | 
  int index = 0; | 
| 288 | 
– | 
  FORALLvertices { | 
| 289 | 
– | 
    Vector3d point(vertex->point[0], vertex->point[1], vertex->point[2]); | 
| 290 | 
– | 
    if (index == 0) { | 
| 291 | 
– | 
      boxMax = point; | 
| 292 | 
– | 
      boxMin = point; | 
| 293 | 
– | 
    } else { | 
| 294 | 
– | 
      for (int i = 0; i < 3; i++) { | 
| 295 | 
– | 
        boxMax[i] = max(boxMax[i], point[i]); | 
| 296 | 
– | 
        boxMin[i] = min(boxMin[i], point[i]); | 
| 297 | 
– | 
      } | 
| 298 | 
– | 
    } | 
| 299 | 
– | 
    index++; | 
| 300 | 
– | 
  } | 
| 301 | 
– | 
  boundingBox_ = Mat3x3d(0.0); | 
| 302 | 
– | 
  boundingBox_(0,0) = boxMax[0] - boxMin[0]; | 
| 303 | 
– | 
  boundingBox_(1,1) = boxMax[1] - boxMin[1]; | 
| 304 | 
– | 
  boundingBox_(2,2) = boxMax[2] - boxMin[2]; | 
| 288 | 
  | 
      | 
| 289 | 
  | 
  qh_freeqhull(!qh_ALL); | 
| 290 | 
  | 
  qh_memfreeshort(&curlong, &totlong); |