ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/math/ConvexHull.cpp
Revision: 3137
Committed: Tue May 29 22:50:14 2007 UTC (17 years, 1 month ago) by chuckv
File size: 3655 byte(s)
Log Message:
Removed CGAL from OOPSE and replaced it with qhull.

File Contents

# User Rev Content
1 chuckv 3083 /* Copyright (c) 2006 The University of Notre Dame. All Rights Reserved.
2     *
3     * The University of Notre Dame grants you ("Licensee") a
4     * non-exclusive, royalty free, license to use, modify and
5     * redistribute this software in source and binary code form, provided
6     * that the following conditions are met:
7     *
8     * 1. Acknowledgement of the program authors must be made in any
9     * publication of scientific results based in part on use of the
10     * program. An acceptable form of acknowledgement is citation of
11     * the article in which the program was described (Matthew
12     * A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
13     * J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
14     * Parallel Simulation Engine for Molecular Dynamics,"
15     * J. Comput. Chem. 26, pp. 252-271 (2005))
16     *
17     * 2. Redistributions of source code must retain the above copyright
18     * notice, this list of conditions and the following disclaimer.
19     *
20     * 3. Redistributions in binary form must reproduce the above copyright
21     * notice, this list of conditions and the following disclaimer in the
22     * documentation and/or other materials provided with the
23     * distribution.
24     *
25     * This software is provided "AS IS," without a warranty of any
26     * kind. All express or implied conditions, representations and
27     * warranties, including any implied warranty of merchantability,
28     * fitness for a particular purpose or non-infringement, are hereby
29     * excluded. The University of Notre Dame and its licensors shall not
30     * be liable for any damages suffered by licensee as a result of
31     * using, modifying or distributing the software or its
32     * derivatives. In no event will the University of Notre Dame or its
33     * licensors be liable for any lost revenue, profit or data, or for
34     * direct, indirect, special, consequential, incidental or punitive
35     * damages, however caused and regardless of the theory of liability,
36     * arising out of the use of or inability to use software, even if the
37     * University of Notre Dame has been advised of the possibility of
38     * such damages.
39     *
40     *
41     * ConvexHull.cpp
42     *
43 chuckv 3137 * Purpose: To calculate convexhull, hull volume libqhull.
44 chuckv 3083 *
45     * Created by Charles F. Vardeman II on 11 Dec 2006.
46     * @author Charles F. Vardeman II
47 chuckv 3137 * @version $Id: ConvexHull.cpp,v 1.2 2007-05-29 22:50:14 chuckv Exp $
48 chuckv 3083 *
49     */
50    
51     #include "math/ConvexHull.hpp"
52     #include <iostream>
53     #include <fstream>
54    
55 chuckv 3137 char options[] = "qhull Qt FA";
56     int dim_ = 3;
57 chuckv 3083
58     using namespace oopse;
59    
60 chuckv 3137 ConvexHull::ConvexHull(){}
61 chuckv 3083
62    
63     bool ConvexHull::genHull(std::vector<Vector3d> pos)
64     {
65 chuckv 3137 FILE *outfile = stdout;
66     FILE *errfile = stderr;
67     facetT *facet;
68     int exitcode;
69     boolT ismalloc = False;
70     int curlong,totlong;
71    
72     int numpoints = pos.size();
73    
74     coordT points[numpoints][dim_];
75    
76     for (int i=0; i<numpoints; i++)
77     {
78     points[i][0] = pos[i][0];
79     points[i][1] = pos[i][1];
80     points[i][2] = pos[i][2];
81     }
82    
83 chuckv 3083
84    
85 chuckv 3137 qh_initflags (options);
86     qh_init_B (points[0], numpoints, dim_, ismalloc);
87     qh_qhull();
88     qh_check_output();
89    
90    
91    
92     qh_getarea(qh facet_list);
93     volume_ = qh totvol;
94     area_ = qh totarea;
95    
96    
97    
98     qh_freeqhull(!qh_ALL);
99     qh_memfreeshort (&curlong, &totlong);
100     if (curlong || totlong)
101     fprintf (errfile, "qhull internal warning (main): did not free %d bytes of long memory (%d pieces)\n",
102     totlong, curlong);
103    
104    
105     return true;
106 chuckv 3083 }
107    
108 chuckv 3137
109 chuckv 3083 RealType ConvexHull::getVolume()
110     {
111 chuckv 3137 return volume_;
112 chuckv 3083 }
113    
114     void ConvexHull::geomviewHull(const std::string& geomFileName)
115     {
116    
117     std::ofstream newGeomFile;
118    
119     //create new .md file based on old .md file
120     newGeomFile.open(geomFileName.c_str());
121    
122    
123     newGeomFile.close();
124    
125    
126     }